当前位置:网站首页>Three -- orbitcontrols track controller
Three -- orbitcontrols track controller
2022-07-24 05:35:00 【Plum blossom three】
Constructors
OrbitControls( object : Camera, domElement : HTMLDOMElement )
object: ( must ) The camera to be controlled . The camera is not allowed to be a child of any other object , Unless the object is the scene itself .
domElement: For event listening HTML Elements .
Sample code
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
const controls = new OrbitControls( camera, renderer.domElement );
//controls.update() must be called after any manual changes to the camera's transform
camera.position.set( 0, 20, 100 );
controls.update();
function animate() {
requestAnimationFrame( animate );
// required if controls.enableDamping or controls.autoRotate are set to true
controls.update();
renderer.render( scene, camera );
}
Modular references
export
stay node_modules\three\examples\js\controls\OrbitControls.js Add... At the top import * as THREE from ‘three’
import * as THREE from 'three'
Import
Introduce
import 'three/examples/js/controls/OrbitControls'
Usage mode
Mode one
In the rendering function, as in the previous code block animate In the method , Use controls.update()
Mode two
Use event monitoring , Callback function rendering :controls.addEventListener(‘change’, animate)
边栏推荐
猜你喜欢
随机推荐
函数多种类型
php的多选、单选结果怎么在前台显示?
Array_ 01return in foreach
Canvas - round
自定义MVC 1.0
Draw a circle and a square on the screen. The square is in front and the circle is behind. You can move the square through the keyboard. In the following cases, the square can only move within the cir
[[[recursion]]]
visibility:hidden 和 display:none
函数闭包
自定义MVC 3.0
special effects - 蜘蛛网背景特效
special effects - 鼠标移动,出现星星拖尾
收藏==学废
OpenGL draws a cone on the screen, which has four faces, each of which is a triangle. Add lighting and texture effects to the cone
Latex learning notes (I) - installation configuration
[common skills]
JS:为什么 [] == ![] 返回 true ?
Opengl模拟现实生活中,球掉到地面上再弹起来的过程,在屏幕上绘制一个球,球从上往下掉,碰到地面,再弹起来。
Some thoughts on being a professional
canvas - Bezier 贝塞尔曲线









