Screen xy to world coordinates

Hi,
apologize if looking in the forum I have already missed the answer to the question I’m about to ask

Someone can give me a concrete example of how to use Vector3 Unproject, to convert screen xy coordinates into world coordinates?

thank you in advance for any help!

Hey and welcome back!

here is how to use it:

        var vector= BABYLON.Vector3.Unproject(
                        mousePosition,
            	        engine.getRenderWidth(),
                        engine.getRenderHeight(),
                        BABYLON.Matrix.Identity(), scene.getViewMatrix(),
                        scene.getProjectionMatrix());
2 Likes

Thank you @Deltakosh!: )

the scenario is to set the position of a mesh.
Before I used the pickedPoint with this.scene.pick(this.scene.pointerX, this.scene.pointerY)

Does using Vector.Unproject way give the same results?

yep :slight_smile: mousePosition is your pointerX/Y thingy

1 Like