onPointerMove doesnt pick/collide?


There is this classic PG where you place stuff by scene.onPointerDown on top of a plane:

if I change it to onPointerMove, i was expecting to move the thing around the plane, but is not workng.
the event gets triggered but it doesnt pick the mesh, see:

any idea why?

thanks for the help!

Hi! I am not fully sure why this happens, but I think that you need to launch a ray manually in the onPointerMove callback like that:

 scene.onPointerMove = function (evt, pickResult) {
        var pickResult = scene.pick(scene.pointerX, scene.pointerY);

        // if the click hits the ground object, we change the impact position
        if (pickResult.hit) {
            impact.position.x = pickResult.pickedPoint.x;
            impact.position.y = pickResult.pickedPoint.y;
        } else {

This will cause some lags though. Maybe only a PointerDown-event will use the scene.pick() in the background and PointerMove does not :thinking:

1 Like

thats probably it…then the documentation needs an update :slight_smile: according to the documentation…both pointermove and pointer down should work the same

Hmm not quite sure, but you are right the doc does not mention this one…

guess we need to study the InputManager to make sure what happens

Actually this is because casting a ray on each move can be expensive. So you need to turn it on with:

wall.enablePointerMoveEvents = true;