three.js - OrbitControls 交互时自动旋转停止?

标签 three.js controls interactive autorotate

如何在鼠标交互时停止 OrbitControls 的自动旋转,并在几秒钟后像 P3D.in 一样开始使用他们的 Logo (http://p3d.in/)

最佳答案

对于谷歌搜索的人,如果你想在第一次交互后停止自动旋转;您可以在 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);
});

关于three.js - OrbitControls 交互时自动旋转停止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20112043/

相关文章:

c++ - 在 Visual C++ 和 Python 之间交换数据

WPF:无法设置焦点

c# - 我如何在 Visual Studio 2017 中使用 "C# Interactive"窗口来查询我的 "Data Connections"中的源

javascript - View 向量与法线之间的 Angular ?

three.js - 在球体上的three.js中翻转法线

c# - 屏幕触摸控制在 Unity 中移动 Cinemachine 摄像机

javascript - 使用 JavaScript 使按钮使用react(添加动画)

namespaces - 在 clojure 中,如何取消命名空间中的 var 定义?

javascript - 无法打开所选对象的指向 url

javascript - 如何使用 THREE.js 将样条曲线拉伸(stretch)到场景的原点