gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 13:19:33 31 4
gpt4 key购买 nike

如何在鼠标交互时停止 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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com