Andrey Zimin Posted February 8, 2018 Share Posted February 8, 2018 Hello, friends! I'm tracking the mouse movement around the object. How do I get the mouse coordinates relative to this object rather than the screen? When I use BABYLON.PointerEventTypes.POINTERDOWN, then I can get it, and how to do it if you use BABYLON.PointerEventTypes.POINTERMOVE ? scene.onPointerObservable.add((evt) => { logger.log('evt', evt) }, BABYLON.PointerEventTypes.POINTERMOVE) Quote Link to comment Share on other sites More sharing options...
brianzinn Posted February 8, 2018 Share Posted February 8, 2018 If you mean relative to the object, as in the canvas, then I think it's event.offsetX and event.offsetY. Those are x,y coordinates from the top left corner and I think they are from : https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/offsetX I haven't tried on a mobile (non-mouse) device, where you may have better luck with code like this: canvas.addEventListener("pointermove", function(evt) { // x,y from scene object, not event. pickTouchResult = scene.pick(scene.pointerX, scene.pointerY); }); Andrey Zimin 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted February 8, 2018 Share Posted February 8, 2018 Hello @Andrey Zimin, there should not be any difference between MOVE and DOWN event data. Can you repro your issue in the PG? Quote Link to comment Share on other sites More sharing options...
Andrey Zimin Posted February 9, 2018 Author Share Posted February 9, 2018 17 hours ago, Deltakosh said: Hello @Andrey Zimin, there should not be any difference between MOVE and DOWN event data. Can you repro your issue in the PG? It`s Ok! No problem! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.