mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
fix raycaster scoping
This commit is contained in:
parent
09d5248f24
commit
0eb03737de
@ -133,14 +133,15 @@ export default {
|
||||
this._intersects = intersects;
|
||||
},
|
||||
onMouseMove(evt) {
|
||||
this.pointer.x = (evt.offsetX / this.three.size.width) * 2 - 1;
|
||||
this.pointer.y = - (evt.offsetY / this.three.size.height) * 2 + 1;
|
||||
const { top: canvasTop, left: canvasLeft } = this.three.mouse_move_element.getBoundingClientRect()
|
||||
this.pointer.x = ((evt.x - canvasLeft) / this.three.size.width) * 2 - 1;
|
||||
this.pointer.y = - ((evt.y - canvasTop) / this.three.size.height) * 2 + 1;
|
||||
},
|
||||
onTouchMove(evt) {
|
||||
const touch = evt.touches[0]
|
||||
const { top: canvasTop, left: canvasLeft } = touch.target.getBoundingClientRect()
|
||||
this.pointer.x = ((touch.clientX - canvasLeft) / this.three.size.width) * 2 - 1
|
||||
this.pointer.y = -((touch.clientY) / this.three.size.height) * 2 + 1
|
||||
const { top: canvasTop, left: canvasLeft } = this.three.mouse_move_element.getBoundingClientRect()
|
||||
this.pointer.x = ((touch.x - canvasLeft) / this.three.size.width) * 2 - 1
|
||||
this.pointer.y = -((touch.y - canvasTop) / this.three.size.height) * 2 + 1
|
||||
}
|
||||
},
|
||||
render() {
|
||||
|
Loading…
Reference in New Issue
Block a user