当前位置:网站首页>"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
边栏推荐
- Question bank and answers of special operation certificate examination for safety management personnel of hazardous chemical business units in 2022
- Topic 1 Single_Cell_analysis(1)
- Summary of machine learning + pattern recognition learning (VI) -- feature selection and feature extraction
- 謀新局、促發展,桂林綠色數字經濟的頭雁效應
- 最新hbuilderX编辑uni-app项目运行于夜神模拟器
- Exposure compensation, white increase and black decrease theory
- xshell安装
- 2022 G3 boiler water treatment recurrent training question bank and answers
- Thyristor, it is a very important AC control device
- Voice assistant - Qu - single entity recall
猜你喜欢

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

Topic 1 Single_ Cell_ analysis(3)

tar之多线程解压缩

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

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

AI fanaticism | come to this conference and work together on the new tools of AI!

Windows10 configuration database

Dynamic simulation method of security class using Matlab based Matpower toolbox

The latest hbuilderx editing uni app project runs in the night God simulator

In depth learning - overview of image classification related models
随机推荐
20220524 deep learning technology points
Chapter 2 - cyber threats and attacks
FPGA based communication system receiver [packet detection] development document
Chapter 6 - identity authentication, Chapter 7 - access control
Vs2019 MFC IP address Control Control inherit cipaddressctrl class redessine
Latex usage problems and skills summary (under update)
vscode 1.68变化与关注点(整理导入语句/实验性新命令中心等)
LeetCode笔记:Weekly Contest 296
Leetcode notes: Weekly contest 295
Architecture and performance analysis of convolutional neural network
Windows10 configuration database
解决逆向工程Mapper重复问题
解决上传SFTPorg.apache.commons.net.MalformedServerReplyException: Could not parse respon
Compiling principle on computer -- function drawing language (II): lexical analyzer
Compiling principle on computer -- function drawing language (III): parser
Improvement of hash function based on life game (continued 1)
Visual studio code batch comment and uncomment
R语言使用epiDisplay包的summ函数计算dataframe中指定变量在不同分组变量下的描述性统计汇总信息并可视化有序点图、使用dot.col参数设置不同分组数据点的颜色
2021.10.24-25 scientific research log
Support vector machine (SVM)