Skip to content

Commit 8e1a5a4

Browse files
committed
fix: touch device ui click not getting correct coords
1 parent 87dfccc commit 8e1a5a4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/core/nodes/UI.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,12 @@ export class UI extends Node {
168168
const canvas = this.canvas
169169
const world = this.ctx.world
170170
const onPointerEnter = e => {
171+
const rect = canvas.getBoundingClientRect()
172+
const x = (e.clientX - rect.left) * this._res
173+
const y = (e.clientY - rect.top) * this._res
171174
hit = {
172175
node: this,
173-
coords: new THREE.Vector3(0, 0, 0),
176+
coords: new THREE.Vector3(x, y, 0),
174177
}
175178
world.pointer.setScreenHit(hit)
176179
}

0 commit comments

Comments
 (0)