轨道控制器
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"
var control = new OrbitControls(camera, renderer.domElement);
control.autoRotate=true;
围绕物体旋转
var clock=new THREE.Clock();
var timer=0;
function updateCamera(delta) {
timer+=delta/5;
var x=30*Math.cos(timer)
var z=30*Math.sin(timer)
var y=20;
camera.position.set(x,y,z);
camera.lookAt(new THREE.Vector3());
}
//----------------------------------------------------------------
update()
function update() {
console.log('刷新')
var delta =clock.getDelta();
updateCamera(delta);
renderer.render(scene, camera);
requestAnimationFrame(update);//不会卡塞,专门针对图形渲染刷新的方法
}