Setting position now requires setting _isDirty to true..?

Hi all,

So I had to update my project to the most recent babylon engine to hopefully get around some ios bugs , anyway ( Babylon.js v4.2.1 - WebGL2 - Parallel shader compilation )

I found that there is an issue in my project now with changing transform properties.

This was previously working as is, in that I am creating some transform variants for nodes which could have any of the TRS Vector3 objects. (i only use the ones i need )

Then in the application when a specific scene requirement is met and it calls for a node transform to be updated , i am then getting a reference to these vector3 objects and then just setting the nodes position , rotation and scale ( where applicable )

one such stored node transform is stored under the key DEFAULT. I use this to just reset a transform to any of its starting values.

eg…

if (a.requiresTransformReset) {

            a.requiresTransformReset = false;

            //set to default transform

            var t = a.collectionTransforms.DEFAULT;

                     

            if (t.location !== null && t.location !== undefined) {

              a.node.position = t.location;

              t.location._isDirty = true;

            }

            if (t.rotation !== null && t.rotation !== undefined) {

              a.node.rotation = t.rotation;

            }

            if (t.scaling !== null && t.scaling !== undefined) {

              a.node.scaling = t.scaling;

            }

          }

this worked before but stopped working and I traced it down to a variable in the vector3 named _isDirty
if I manually set this to true ( as can now be seen in the code above ), then it works.

but based on the fact it is a underscored field and not a setter is telling me this is technically not something I should be setting manually , i did not see a setter for it. Did something get missed here?

Seems I can set the scale back and forth just fine without changing the isDirty prop … but not position.

well I get to do one change actually , its the second change that fails without setting this _isDirty prop to true manually

the assets are loaded at runtime with BABYLON.SceneLoader.ImportMesh

it does depend on what exactly you are trying to achieve, but if I may suggest a better solution - instead of replacing the position with a new variable, can you try using the copyFrom function to copy the values of the new vector to the already existing one? Your garbage collecter will thank you, your code will be a bit mroe optimized, and (I believe) your issue will be resolved.

1 Like

Swapping a node position should work but there is definitely an issue there… https://playground.babylonjs.com/#6CCHQX#2 @RaananW can you have a look ? or I ll dig in today ?

Scratch that, actually @Deltakosh is checking :slight_smile:

Will be fixed by the Babylon Daddy himself here: Fix cache issue when parenting by deltakosh · Pull Request #12138 · BabylonJS/Babylon.js · GitHub

1 Like