当前位置:网站首页>"Three.js" auxiliary coordinate axis
"Three.js" auxiliary coordinate axis
2022-06-12 07:52:00 【InfoQ】
Brief introduction
Three.jsThree.jscode
<style>
body {
margin: 0;
}
</style>
<div id="canvasBox"></div>
<script type="module">
import {
Scene,
PerspectiveCamera,
WebGLRenderer,
BoxGeometry,
MeshBasicMaterial,
Mesh
} from '../js/Three/Three.js'
// scene
const scene = new Scene()
// The camera
const camera = new PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
// Renderers
const renderer = new WebGLRenderer()
// Set the size of the renderer to the size of the window
renderer.setSize(window.innerWidth, window.innerHeight)
// Bind the renderer to the specified DOM In the elements
document.getElementById('canvasBox').appendChild(renderer.domElement)
// Geometry
const geometry = new BoxGeometry()
// Mesh base material , Set the color
const material = new MeshBasicMaterial({color: 0xff2299})
const cube = new Mesh(geometry, material)
scene.add(cube)
// Set the camera to z The distance on the axis
camera.position.x = -3
camera.position.y = 5
camera.position.z = 5
// Aim the camera at the center of the scene
camera.lookAt(scene.position)
// Rotate the cube properly
cube.rotation.x += 0.8
cube.rotation.y += 0.8
// Add the scene and camera to the renderer and perform rendering
renderer.render(scene, camera)
</script>

Create axes
AxesHelper<!-- Omit the above html Code -->
<script type="module">
import {
// Omit the previous introduction
AxesHelper
} from '../js/Three/Three.js'
// Omitted code ...
// Create axes
const axes = new AxesHelper()
// Add axes to the scene
scene.add(axes)
// Add the scene and camera to the renderer and perform rendering
renderer.render(scene, camera)
</script>

Set the axis length
const axes = new AxesHelper(2)
Sets the axis color
setColors// Create axes
const axes = new AxesHelper(2)
// Sets the axis color
axes.setColors('pink', 0xf0ff00, 'rgb(60, 200, 130)')

Code warehouse
边栏推荐
- Solve mapper duplication problem in reverse engineering
- Model deployment learning notes (I)
- Topic 1 Single_Cell_analysis(3)
- Topic 1 Single_Cell_analysis(4)
- Exposure compensation, white increase and black decrease theory
- Topic 1 Single_Cell_analysis(2)
- Knife4j first use
- R language uses rstudio to save visualization results as PDF files (export--save as PDF)
- 2021.10.31-11.1 scientific research log
- Latex usage problems and skills summary (under update)
猜你喜欢

Topic 1 Single_ Cell_ analysis(1)
![[redistemplate method details]](/img/ef/66d8e3fe998d9a788170016495cb10.png)
[redistemplate method details]

Chapter V - message authentication and digital signature

Topic 1 Single_Cell_analysis(1)

BI技巧丨当月期初

The project file contains toolsversion= "14.0". This toolset may be unknown or missing workarounds

Utilize user behavior data

Meter Reading Instrument(MRI) Remote Terminal Unit electric gas water

谋新局、促发展,桂林绿色数字经济的头雁效应

Process terminated
随机推荐
20220524 深度学习技术点
初步认知Next.js中ISR/RSC/Edge Runtime/Streaming等新概念
FPGA based communication system receiver [packet detection] development document
Ecmascript6 interview questions
Arrangement of statistical learning knowledge points gradient descent, least square method, Newton method
Exposure compensation, white increase and black decrease theory
AI fanaticism | come to this conference and work together on the new tools of AI!
LeetCode34. 在排序数组中查找元素的第一个和最后一个位置
NaiveBayes function of R language e1071 package constructs naive Bayes model, predict function uses naive Bayes model to predict and reason test data, and table function constructs confusion matrix
Leetcode notes: Weekly contest 295
Topic 1 Single_ Cell_ analysis(1)
ECMAScript6面试题
R语言将dataframe数据中指定数据列的数据从小数转化为百分比表示、数据转换为百分数
Meter Reading Instrument(MRI) Remote Terminal Unit electric gas water
The Poisson regression model (posion) is constructed by GLM function of R language, and the poisgof function of epidisplay package is used to test the goodness of fit of the fitted Poisson regression
The latest hbuilderx editing uni app project runs in the night God simulator
Interview questions on mobile terminal, Android and IOS compatibility
2021.10.31-11.1 scientific research log
Summary of machine learning + pattern recognition learning (V) -- Integrated Learning
Windows10 configuration database