Root transformNode with children of various "types" and scaling

I have a (simplistic) graph similar to the following (the children all have their parents set to root):

scene
  |__ root (BABYLON.TransformNode)
           |__ skybox (BABYLON.MeshBuilder.CreateBox)
           |__ point cloud system (PointsCloudSystem)
           |__ particle system (BABYLON.ParticleSystem)
           |__ mesh instances (BABYLON.MeshBuilder.CreateDisc -> instances)
           |__ a simple "plane" (BABYLON.MeshBuilder.CreatePlane)

A range input allows me to play with the scaling of the root node:

root = new BABYLON.TransformNode('root', scene);
// <input type="range" value="1" step="0.01" max="10" min="0.01" id="root-scale">
d.querySelector('#root-scale').addEventListener('change', function(){
    root.scaling.x = this.value;
    root.scaling.y = this.value;
    root.scaling.z = this.value;
}, false);

This range input has a visible effect on only the “plane” element of the scene // root children.

Is there anything special to be done so that:
. instances
. particle systems
. point cloud systems
. etc?
. all get rescaled?

Thanks!

  • a skybox has no use of scale as it should be at infinity
  • a PointsCloudSystem is not a mesh or a node so it is not within an hierarchy. You could nevertheless try to parent its “mesh” property
  • a ParticleSystem like a point cloud is not a node so not within an hierarchy but it can use from a mesh emitter
  • mesh instances should work I believe. cc @Evgeni_Popov to confirm.

I think mesh instances are created with parent = null. You should probably set instance.parent = mesh.parent if you want the instance to be created at the same location in the node hierarchy than the mesh it has been instanced from.

hey thanks, that’s a great step in the right direction :slight_smile:

the culprit was:

instance.freezeWorldMatrix();

Any idea about the particle systems?

As @sebavan mentioned, did you try to add emitter TransformNode and set your root as parent?

particleSystem.emitter = new TransformNode(...)
particleSystem.emitter.parent = root

Sorry I haven’t as my emitter is set a a Vector3(0,0,0). Should I change that?

Yes, else you won’t be able to parent it.

haven’t figured out the BABYLON.ParticleSystem scaling yet, but the scaling of a PointsCloudSystem seems to work nicely like this:

pcs.buildMeshAsync().then(function(){
    pcs.mesh.parent = root;
});

What will work is to directly set minSize/maxSize if you change root scaling:

particleSystem.minSize *= 5
particleSystem.maxSize *= 5

Thank you guys, this all seems to work.

However, I just ran into something: when applying a scale to the root node, picking suddenly stops working. Any idea why that could be? Thanks! :slight_smile:

What you mean by “stops working”?

Which way do you pick by ActionManager or PointerObservable?

I assume you pick by LeftClick (PointerDown,PointerObservable) and nothing happens.

What does the PickingInfo say (mesh.name etc.)? In case you pick another mesh in front i.e. skybox, you could disable isPickable and verify its scaling = infinty.

To help you further I need a repro.