Skip to content

Commit 53bfe8b

Browse files
committed
Use offsetX and Y instead of clientX and Y for mouse
1 parent 9401f0a commit 53bfe8b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/clientSideScene/sceneInfra.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,9 @@ export class SceneInfra {
455455
return
456456
}
457457
this.currentMouseVector.x =
458-
(mouseEvent.clientX / mouseEvent.currentTarget.clientWidth) * 2 - 1
458+
(mouseEvent.offsetX / mouseEvent.currentTarget.clientWidth) * 2 - 1
459459
this.currentMouseVector.y =
460-
-(mouseEvent.clientY / mouseEvent.currentTarget.clientHeight) * 2 + 1
460+
-(mouseEvent.offsetY / mouseEvent.currentTarget.clientHeight) * 2 + 1
461461

462462
const planeIntersectPoint = this.getPlaneIntersectPoint()
463463
const intersects = this.raycastRing()
@@ -623,9 +623,9 @@ export class SceneInfra {
623623
return
624624
}
625625
this.currentMouseVector.x =
626-
(event.clientX / event.currentTarget.clientWidth) * 2 - 1
626+
(event.offsetX / event.currentTarget.clientWidth) * 2 - 1
627627
this.currentMouseVector.y =
628-
-(event.clientY / event.currentTarget.clientHeight) * 2 + 1
628+
-(event.offsetY / event.currentTarget.clientHeight) * 2 + 1
629629

630630
const mouseDownVector = this.currentMouseVector.clone()
631631
const intersect = this.raycastRing()[0]
@@ -648,9 +648,9 @@ export class SceneInfra {
648648
return
649649
}
650650
this.currentMouseVector.x =
651-
(mouseEvent.clientX / mouseEvent.currentTarget.clientWidth) * 2 - 1
651+
(mouseEvent.offsetX / mouseEvent.currentTarget.clientWidth) * 2 - 1
652652
this.currentMouseVector.y =
653-
-(mouseEvent.clientY / mouseEvent.currentTarget.clientHeight) * 2 + 1
653+
-(mouseEvent.offsetY / mouseEvent.currentTarget.clientHeight) * 2 + 1
654654
const planeIntersectPoint = this.getPlaneIntersectPoint()
655655
const intersects = this.raycastRing()
656656

0 commit comments

Comments
 (0)