Jouerose Posted May 22, 2018 Share Posted May 22, 2018 Hello, In the playground below, I am trying to move a TextBlock using the moveToVector3 method, however it does not seem to work. while i get linkWithMesh to work (it is commented out in the code), I do not understand why moveToVector3 does not work. thank you for your help. https://www.babylonjs-playground.com/#XCPP9Y#523 Quote Link to comment Share on other sites More sharing options...
SinhNQ Posted May 22, 2018 Share Posted May 22, 2018 Hi, Welcome to the Babylon.js's forum ? Before use moveToVector3 method you must call scene.updateTransformMatrix() function. https://www.babylonjs-playground.com/#XCPP9Y#526 I don't know why but i have encountered this problem. @Deltakosh or someone will explain to you. Jouerose 1 Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted May 22, 2018 Share Posted May 22, 2018 Hi Jouerose ! Don't know mush about GUI, but from what I understand : linkWithMesh makes your Control link to a mesh, so the control position in 2D is recomputed each frame as the position in 2D (projection) of the mesh changes at every camera move. moveToVector3 makes your Control at a given 3D position, so 2D projection when you call it and do nothing at next camera moves. I think your camera, or scene, is not ready in your playground, that's why the projection of your Vector3 is not well computed and is set to (0,0,0). With executeWhenReady, you can see that your moveToVector3 is working.. but it doesn't update your 2D position when camera moves : https://www.babylonjs-playground.com/#XCPP9Y#524 If you want to have to same behaviour as linkWithMesh, you may use a moveToVector3 each frame : https://www.babylonjs-playground.com/#XCPP9Y#527 Or you can create a mesh, set its absolute position and disable it. Maybe a bit heavier but may be easier to understand, using this "pivotMesh" as 3D pivot for your Control Quote Link to comment Share on other sites More sharing options...
Jouerose Posted May 22, 2018 Author Share Posted May 22, 2018 7 hours ago, SinhNQ said: Hi, Welcome to the Babylon.js's forum ? Before use moveToVector3 method you must call scene.updateTransformMatrix() function. https://www.babylonjs-playground.com/#XCPP9Y#526 I don't know why but i have encountered this problem. @Deltakosh or someone will explain to you. Thank you very much @SinhNQ for your help. I also wish @Deltakosh tell us more about it. Quote Link to comment Share on other sites More sharing options...
Jouerose Posted May 22, 2018 Author Share Posted May 22, 2018 7 hours ago, Amarth2Estel said: Hi Jouerose ! Don't know mush about GUI, but from what I understand : linkWithMesh makes your Control link to a mesh, so the control position in 2D is recomputed each frame as the position in 2D (projection) of the mesh changes at every camera move. moveToVector3 makes your Control at a given 3D position, so 2D projection when you call it and do nothing at next camera moves. I think your camera, or scene, is not ready in your playground, that's why the projection of your Vector3 is not well computed and is set to (0,0,0). With executeWhenReady, you can see that your moveToVector3 is working.. but it doesn't update your 2D position when camera moves : https://www.babylonjs-playground.com/#XCPP9Y#524 If you want to have to same behaviour as linkWithMesh, you may use a moveToVector3 each frame : https://www.babylonjs-playground.com/#XCPP9Y#527 Or you can create a mesh, set its absolute position and disable it. Maybe a bit heavier but may be easier to understand, using this "pivotMesh" as 3D pivot for your Control Thank you for your comments @Amarth2Estel Quote Link to comment Share on other sites More sharing options...
Guest Posted May 23, 2018 Share Posted May 23, 2018 Quote Before use moveToVector3 method you must call scene.updateTransformMatrix() function. This is because the scene was not yet rendered and thus the view and projection matrices are not set on the scene 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.