Container positions doesnt match scene.pointerX

Hi everyone!

I am trying to add a right-click menu, but I got a weird problem:

  1. I click on scene, and scene.pointerX/Y can get coordinates of cursor in pixel unit;
  2. Although it’s not integer due to Why are scene.pointerX and scene.pointerY not integers? - #7 by wulf11, but I think it doesn’t matter;
  3. I create a container with the XY (container.left=X…) but container wont show near my cursor
  4. the more cursor off the scene center, the more container shift away cursor.
  5. The XY i got is correct, i have calibrated on the corner of scene, and compared with canvas size.
  6. the funny thing is I cannot reproduce it in playground…

Here is a screenshot: I hardcode container at (1000px, 500px), and red point is where scene.pointerX, Y equal to this value.

Can you please give me some advice how to debug this?

Sorry for this confusing question…

Bests,

Although I hear that the issue doesn’t repro in the playground, could you provide one anyway that shows what you’re trying to do? It would help with debugging. Thanks!

Here is the example of the GUI Context Menu on the Right Click - https://playground.babylonjs.com/#PIKP4K#16

1 Like