threejs 实现3d全景 鼠标 旋转

1、引入  <script type="text/javascript" src="../libs/OrbitControls.js"></script> ,请修改OrbitControls对应的地址

2、创建对象

    function initControls() {
      controls = new THREE.OrbitControls(camera);
      controls.addEventListener('change', render);
      controls.autoRotate = false; //自动旋转开关
      controls.autoRotateSpeed = 2;
    }

3,在animate方法中调用Controls对象

  function render() {
      //plane.rotation.y = step += 0.01;
      renderer.render(scene, camera);

    }

    function animate() {
      // render using requestAnimationFrame
      requestAnimationFrame(animate);
      controls.update();

    }

猜你喜欢

转载自blog.csdn.net/adenfeng/article/details/89358396