当前位置:网站首页>『Three.js』辅助坐标轴
『Three.js』辅助坐标轴
2022-06-12 07:48:00 【InfoQ】
本文简介
Three.jsThree.js编码
<style>
body {
margin: 0;
}
</style>
<div id="canvasBox"></div>
<script type="module">
import {
Scene,
PerspectiveCamera,
WebGLRenderer,
BoxGeometry,
MeshBasicMaterial,
Mesh
} from '../js/Three/Three.js'
// 场景
const scene = new Scene()
// 相机
const camera = new PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
// 渲染器
const renderer = new WebGLRenderer()
// 将渲染器的大小设置为窗口的大小
renderer.setSize(window.innerWidth, window.innerHeight)
// 将渲染器绑定到指定的DOM元素中
document.getElementById('canvasBox').appendChild(renderer.domElement)
// 几何体
const geometry = new BoxGeometry()
// 网格基础材质,设置颜色
const material = new MeshBasicMaterial({color: 0xff2299})
const cube = new Mesh(geometry, material)
scene.add(cube)
// 设置摄像机在z轴上的距离
camera.position.x = -3
camera.position.y = 5
camera.position.z = 5
// 将摄像机的方向对准场景的中心点
camera.lookAt(scene.position)
// 适当的旋转一下立方体
cube.rotation.x += 0.8
cube.rotation.y += 0.8
// 将场景和相机添加到渲染器中并执行渲染
renderer.render(scene, camera)
</script>

创建坐标轴
AxesHelper<!-- 省略上面的 html 代码 -->
<script type="module">
import {
// 省略前面的引入
AxesHelper
} from '../js/Three/Three.js'
// 省略部分代码...
// 创建坐标轴
const axes = new AxesHelper()
// 将坐标轴添加到场景中
scene.add(axes)
// 将场景和相机添加到渲染器中并执行渲染
renderer.render(scene, camera)
</script>

设置坐标轴长度
const axes = new AxesHelper(2)
设置坐标轴颜色
setColors// 创建坐标轴
const axes = new AxesHelper(2)
// 设置坐标轴颜色
axes.setColors('pink', 0xf0ff00, 'rgb(60, 200, 130)')

代码仓库
边栏推荐
- Summary of machine learning + pattern recognition learning (VI) -- feature selection and feature extraction
- Chapter 3 - Fundamentals of cryptography
- Modelants II
- Utilize user behavior data
- R语言e1071包的naiveBayes函数构建朴素贝叶斯模型、predict函数使用朴素贝叶斯模型对测试数据进行预测推理、table函数构建混淆矩阵
- Voice assistant - those classification models used in the assistant
- 数值计算方法 Chapter6. 解线性方程组的迭代法
- Topic 1 Single_Cell_analysis(1)
- 20220607. face recognition
- 2022 simulated test platform operation of hoisting machinery command test questions
猜你喜欢

Seeking for a new situation and promoting development, the head goose effect of Guilin's green digital economy

Topic 1 Single_ Cell_ analysis(3)

Topic 1 Single_ Cell_ analysis(1)

20220526 yolov1-v5

In depth learning - overview of image classification related models

Primal problem and dual problem

最新hbuilderX编辑uni-app项目运行于夜神模拟器

Fcpx plug-in: simple line outgoing text title introduction animation call outs with photo placeholders for fcpx

BI技巧丨当月期初

The latest hbuilderx editing uni app project runs in the night God simulator
随机推荐
modelarts二
Classic paper review: palette based photo retrieval
20220524 深度学习技术点
数值计算方法 Chapter6. 解线性方程组的迭代法
Voice assistant -- Qu -- query error correction and rewriting
Bi skills - beginning of the month
二、八、十、十六进制相互转换
AI fanaticism | come to this conference and work together on the new tools of AI!
Exploring shared representations for personalized federated learning paper notes + code interpretation
Summary of machine learning + pattern recognition learning (V) -- Integrated Learning
Voice assistant -- vertical class perpetual motion machine -- automated iteration framework
解决逆向工程Mapper重复问题
Some summaries of mathematical modeling competition in 2022
Leverage contextual information
Solve the problem of uploading sftporg apache. commons. net. MalformedServerReplyException: Could not parse respon
Utilize user behavior data
2022 simulated test platform operation of hoisting machinery command test questions
R语言dplyr包mutate_at函数和one_of函数将dataframe数据中指定数据列(通过向量指定)的数据类型转化为因子类型
MySQL index (easy to handle in one article)
谋新局、促发展,桂林绿色数字经济的头雁效应