How to hide smoothly some meshes in BJS

Hello guys,

here is my PG https://www.babylonjs-playground.com/#LCKHB2#9
there is three level and the quayside so when I click to moveToEscalator button I hide level3 and 2 in order to see escalator inside and I move through, so here I hide them very fast :frowning:
is there a way to hide them smoothly or to make them transparent to see what behind (some attractive viszualization)

thank you best forum
:v:

Hey

probably animation mesh.visibility or material.alpha :slight_smile:

@Deltakosh I tried but no way :worried::worried::worried::worried:

can you repro what you tried in a simpler PG? (no need to bring all your assets :))

1 Like

@Deltakosh here is a simple pg with 3 spheres : Babylon.js Playground
so I wanted to hide red and green spheres but not directly kind of smoothly with the movement of the camera (or make the spheres transparent and can see what is behind)

thanks dud

Like that?
https://playground.babylonjs.com/#99XJ1H#2

1 Like

@Deltakosh yes like that but when I reach my goal spheres does not disappear at all, I want that I I can see them a bit but transparent

thank you so much dud

Change 0 values lines 118 and 122 https://playground.babylonjs.com/#99XJ1H#3

https://doc.babylonjs.com/api/classes/babylon.animation#createandstartanimation

2 Likes

@Deltakosh @JohnK it works fine here but when I replace sphere by my mesh loaded by scene.getMeshByID(“MySketchUp”), it doesn’t work :(, I think because “My SketchUp” is just an empty parent doesn’t it ?, if yes how can I call all childs from parent because there is a lot of childs in one node calls “MySketchup” and I want to hide(MySketchUp) with BJS function (so hold all his childs)

TransformNode - Babylon.js Documentation may help

You can use mesh.getChildren();

@JohnK @Raggar I try it but no way
I called var MyMesh= MyNode.getChildMeshes();
and then try hide(MyMesh) I also tried MyMesh.forEach(mesh=>hide(mesh)); it doesn’t work :(((
when I use MyMesh.forEach(mesh=>hide(mesh)); I’ve this error Uncaught TypeError: Cannot set property visibility of [object Object] which has only a getter

Difficult to help without a playground. Could you use Using External Assets - Babylon.js Documentation to load your meshes?

@JohnK I have the PG here is the link https://playground.babylonjs.com/#KI8BJH#27
I did it with simple meshes cuz @Deltakosh told me that it is simple to help u with simple meshes.
I use here mesh.isVisible in the place of hide and show cuz it doesn’t work

Yes a simple as possible playground showing any errors is always best. In the PG you just posted where does the

happen?

Here is a PG with the spheres parented to an empty mesh and it still works https://playground.babylonjs.com/#99XJ1H#4

Can you produce a PG that loads a parent and its children and then does the hide and show animations?

@JohnK here is the PG https://playground.babylonjs.com/#KI8BJH#28
line 201,203 and 206 here I called children and then in line 175 and 180 I call hide()

Interesting issue I have raised a bug The mesh visibility property cannot be set with an animation in some circumstances

As answer there:

This is all expected with instanced meshes.

You should either play the animation on the source mesh or not create it as an instance.

The main point so not have the setter affecting the source is to prevent the confusion of why they all changed.

Got it - need to access none instanced meshes and source of instanced meshes in children of niv[1] and niv[2]

Lines 204 to 213 and 216 to 225 use sets niv1Set and niv2Set to list single versions of non-instanced meshes from niv1 and niv2

These are then run through to hide and show meshes 300 to 309 and 173 to 182

1 Like

@JohnK thank u it works but when I click to move it is so slow !