引入

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

添加轨道控制器

const controls = new OrbitControls( camera, renderer.domElement );

在动画函数中使用

function animate( time) {

    mesh.rotation.x = time / 2000;
    mesh.rotation.y = time / 1000;

    controls.update()
    renderer.render( scene, camera );

  }

添加阻尼

controls.enableDamping = true
controls.dampingFactor = 0.01

自动旋转

controls.autoRotate = true
controls.autoRotateSpeed = 1.2