【问题标题】:OrbitControls auto rotate stop when interactive?OrbitControls 交互时自动旋转停止?
【发布时间】:2013-11-21 03:46:17
【问题描述】:

如何在鼠标交互时停止 OrbitControls 的自动旋转,几秒钟后它会像 P3D.in 一样开始,这里有他们的徽标 (http://p3d.in/)

【问题讨论】:

    标签: three.js controls interactive autorotate


    【解决方案1】:

    对于使用谷歌搜索的人,如果您想在第一次交互后停止自动旋转;您可以在 OrbitControls 发出的 3 个事件之一上连接一个事件侦听器:

    // stop autorotate after the first interaction
    controls.addEventListener('start', function(){
      controls.autoRotate = false;
    });
    

    或者更高级,在用户结束最后一次交互后重新启动自动旋转,超时时间为 1000 毫秒:

    // stop autorotate after the first interaction
    controls.addEventListener('start', function(){
      clearTimeout(autorotateTimeout);
      controls.autoRotate = false;
    });
    
    // restart autorotate after the last interaction & an idle time has passed
    this.controls.addEventListener('end', function(){
      autorotateTimeout = setTimeout(function(){
        controls.autoRotate = true;
      }, 1000);
    });
    

    【讨论】:

      【解决方案2】:
      controls.autoRotate = false;
      

      只需在初始化时使用“true”启动它,然后使用 onMouseMove,执行以下操作:

      if (controls.AutoRotate)
        controls.autoRotate = false;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-19
        • 1970-01-01
        • 2016-03-11
        相关资源
        最近更新 更多