Disabling entities in a node graph

I’m working on a “door” configurator. The door is animated via FBX so I am loading in one animation that has multiple door panels. The idea is I can hide and show the panels based on user selection.

When I try to disable stuff in the graph it doesn’t hide the panel. Here’s the code:

var graph = this.hero.model.model.getGraph();
graph.findByName(“Hardware_Top”).enabled = false;
console.log(graph);

A screen shot of the console log is included below. The object is shown as disabled but it’s still visible.

Any ideas what I’m doing wrong?

Is there more than one graph node that could be called ‘Hardware_Top’? This may include mesh instance names in the FBX.

The hierarchy of the graph looks like:
Rootnode
-Locator
–Panel_Top
—Hardware_Top

So if I substitute the findByName with:

graph.children[0].children[0].children[0].enabled = false;

I get the same results. The console.log indicates the entity is disabled but it’s still visible on the canvas

P.S. the meshinstances and such have different names, the meshinstances for the one I am trying to disable in this case is “Hardware”.

It’s definitely getting the right object. If I do:

graph.children[0].children[0].children[0].setLocalScale(0,0,0);

or

graph.findByName(“Hardware_Top”).setLocalScale(0,0,0);

That works. Doesn’t seem like the greatest way to hide stuff though…feels like a engine bug maybe?

P.S. started implementing the setLocalScale deal as a workaround until I realized the FBX animation has scale keyframes, so all the panels appear when the animation runs. Not sure how to get around this issue now.

Is this a project that you can share?

Right now all the playcanvas functionality is encapsulated in a proprietary framework I wrote for a client and the whole thing is embedded in a reactjs app. It’s for a project bid too so not sure if my client wants that available or not. If I get the go ahead I’ll see if I can create a vanilla javascript app that loads the model and tries to hide the nodes and upload it.

@jhinrichs Just coming across this post again from another and I just remembered that disabling a graph entity doesn’t remove it from the scene graph. I vaguely remember that there is some code that adds/remove the mesh from a render list of some sort. The code logic can be seen when you disable/enable an entity.

I got the same problem here. The enabled properties doesn’t change anything visually if set to true or false.

Yeah, it’s a pain. There’s some work being done to make this a lot easier and be able to see the full hierarchy in the Editor.

For the moment, you have to find the meshInstance and set visible true/false: [SOLVED] Disabling Mesh Instance Nodes

1 Like