在模型中移动鼠标,在mousemove中执行raycaster导致CPU使用率高
在模型中移动鼠标,在mousemove中执行raycaster导致CPU使用率很高,当我移动鼠标时,CPU使用率飙升至90% 这是我的代码:
this.container.addEventListener('mousemove', (e) => {
console.log('intersect:', this.intersect(e, this.camera), this.objects)
this.lastMove = Date.now()
})
intersect(event, camera) {
let raycaster = new THREE.Raycaster();
let vector = new THREE.Vector2();
vector.x = event.clientX / window.innerWidth * 2 - 1;
vector.y = -event.clientY / window.innerHeight * 2 + 1;
raycaster.setFromCamera(vector, camera);
let intersectObj = raycaster.intersectObjects(this.objects, false);
return intersectObj;
}
move the mouse in the model, executing raycaster in mousemove causes high CPU usage, when I move the mouse,CPU usage soars to 90%
here is my code:
this.container.addEventListener('mousemove', (e) => {
console.log('intersect:', this.intersect(e, this.camera), this.objects)
this.lastMove = Date.now()
})
intersect(event, camera) {
let raycaster = new THREE.Raycaster();
let vector = new THREE.Vector2();
vector.x = event.clientX / window.innerWidth * 2 - 1;
vector.y = -event.clientY / window.innerHeight * 2 + 1;
raycaster.setFromCamera(vector, camera);
let intersectObj = raycaster.intersectObjects(this.objects, false);
return intersectObj;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论