Dad72 Posted December 5, 2018 Share Posted December 5, 2018 I explain the problem: I record a first camera position in a variable. Then I move the camera to compare in the state the new position of the camera and the variable in the old position. The problem is that the variable is reassigned in real time when the camera is moving, which I find very strange. The variable should not be changed. See in this PG and the console. Click once on the button to save the variable. Then move the camera, the variable changes all alone. So at the second click on the button, the alert is never reached, because the variable has the same value as the new position of the camera, while the record was made on an old camera position. https://www.babylonjs-playground.com/#XCPP9Y#744 If we look at this PG more simple, it's the same thing : https://www.babylonjs-playground.com/#XCPP9Y#745 It's something I saw a long time ago, but that did not bother me, but here I can not record a camera position to compare it to a new position without the variable being rewritten by the Holy Spirit, LOL. [Edite] : This does not seem to be related to Chrome 71. I have tried FireFox and Opera too and it's the same thing. So I think that the Babylon reassigns the variables that it has to assign, maybe the light as well as something else in Babylon reassigns the variables that it has to assign. I will check it Yes, the lights too. As soon as the light is moved, it rewritten the variable that it has assigned previously. I think that all entities in Babylon are rewritten the variables automatically. https://www.babylonjs-playground.com/#XCPP9Y#746 So currently, we can no longer record transformations (position, rotation, scale and other modifications) in a variable to preserve previous states and compare them with new transformations. This is a big problem for the editor that one develops Quote Link to comment Share on other sites More sharing options...
Sebavan Posted December 5, 2018 Share Posted December 5, 2018 You need to clone if you record the info or record the individual components (x y z for instance): https://www.babylonjs-playground.com/#XCPP9Y#747 Position and other containers are not recreated on every frame to save GC. That means everywhere in the framework, we are using the toRef functions. Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted December 5, 2018 Author Share Posted December 5, 2018 Ok, so we have to clone all the recordings that we make ? I think it's something that should be indicated somewhere in the documentation, because it's not easy to know or not intuitive. Thank you Sebavan 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.