Hartha Posted April 25, 2017 Share Posted April 25, 2017 HI, How to convert world point to screen 2D point using specific camera, I'm stuck and this is my try https://www.babylonjs-playground.com/#25RB80#3 Quote Link to comment Share on other sites More sharing options...
jellix Posted April 25, 2017 Share Posted April 25, 2017 Hi, have a look at https://www.babylonjs.com/demos/dragndrop Here you can see how the cursors position (2D) is transformed into a 3d-vector. Maybe it helps? Quote Link to comment Share on other sites More sharing options...
Hartha Posted April 25, 2017 Author Share Posted April 25, 2017 Thanks @jellix for your answer, but I need to convert 3D-vector to 2D position, I found this way to do that : let p = BABYLON.Vector3.Project(vector, Identity, scene.getTransformMatrix(), camera.viewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight())); But I don't know how to modify it to convert the vector according to specific camera, I tried to change the camera view port but it dose not change anything as shown in the playground. if anyone can explain the parameters it will be a good help, Thanks. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 25, 2017 Share Posted April 25, 2017 Hello to take in account a specific camera you can just use this: let p = BABYLON.Vector3.Project(vector, Identity, camera.getViewMatrix().multiply(camera.getProjectionMatrix()), camera.viewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight())); Hartha 1 Quote Link to comment Share on other sites More sharing options...
Hartha Posted April 26, 2017 Author Share Posted April 26, 2017 Ok it works, Thank you Deltakosh 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.