'move the mouse in the model, executing raycaster in mousemove causes high CPU usage
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;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
