PlayCanvas for Beginners - need some help to understand

Hello,

I’m trying to learn PlayCanvas, I’ve already experimented with three.js a few things (3D furniture configurator) and found that was easy.
But I can’t do the same with PlayCanvas (I’m not coding expert, just enthusiastic one :slight_smile: )

What I want to do : hiding some child elements of my model.

What I’ve done : (googled and have read a thousand of articles, the API reference also and tried a lot of options without success)

  • I’ve loaded my dae file in the editor
  • Then added the JSON file to my scene
  • My dae file has group of elements (doors, drawers, etc)
  • So I want to hide some child elements from my model and then making them visible by clicking on a button.

I just need to understand the PlayCanvas coding logic… and this seems to be easy but…

For the moment I have this code :

AccessSubmodel.prototype.initialize = function() {

var e = this.app.root.findByName("Model");

var m = e.findByName("_5_DRAWERS");

m.enabled = false;

console.log(e);
console.log(m);

};

In the console I see my Entity “Model” and my GraphNode “_5_DRAWERS”
But the drawers are still visible… :confused:

Can someone be kind to explain or give me an example what kind of code do I need to use for accessing my sub-elements and manipulating them?

I think this will be a good start for me to understand how.

Thank you.

What you are finding (m) is a graphnode rather than a entity.

Traditionally, the practise is to import the model parts separately, that way each part is an entity and can be disabled/enabled the traditional way.

To directly answer your question, I can’t remember if a meshinstance is also a graphnode or whether it is possible to get the meshinstance from the graphnode.

You might be better off writing your own ‘findByName’ like function that searches through the meshinstances. That way, you can set visible to be true/false.