[SOLVED] findByName() and glb and material

1、load glb model and add to a new entity and show it in the scene successfully

app.assets.loadFromUrl(glbPath, "binary", function (err, asset) {xx}

2、add material on this model and this entity has shown with materials in the scene successfully

3、then use findByName() to find this entity

var ent = visibleEnt.findByName(modelName);

but ent’s hirachy is this sometimes which shows that it is only glb file:

the interesting thing is the entity as a child in the visibleEnt is this:

I don’t know why,please give me some advice,thank you.

Sorry, I don’t understand the problem.

Would you be able to provide a project or more code on what is being done there as I can’t see what is being done with the GLB asset nor what visibleEnt is.

In other word,I got a car in the scene,and this car shows well(include glb models and some materials).
then I use ‘findByName()’ to get a door entity whose name is ‘door_fl’.
In the car entity,door_fl entity is normal,and I consoled Its hirachy which is as second picture shows,it has its model and materials.
but when I use this code to get door_fl entity:

var door_fl_entity = carEnt.findByName('door_fl');

I found that its hirachy shows as the first picture,which is the same as only glb models.

The phenomenon is that I got a child entity from a father entity,but this child entity is different from the entity in the father’s,this happens only occasionally,all I used is ‘findByName()’ and glb models.
I have considered whether the father entity was changed by me when I took the child entity from the father entity. However, by printing the log, I found that the hierarchy tree in the father entity is normal and unchanged, but the child entity taken out is different from the child entity in the father entity.

Just to be clear here:

app.root.findByName('door_fl') gives you a different node compared to carEnt.findByName('door_fl')?

If that’s the case, are you sure that there’s only one node in the whole scene that is named door_fl?

Its a bit hard to tell without seeing the project/scene what could be causing you to see different results.

1 Like

I solved this problem just now,I just changed the name of child entity to be ‘door_flL’.I know it shows that there maybe other entity named ‘door_fl’,what I can say is I have checked it by logging app.root before,and I am prety sure there is only one entity who named ‘door_fl’.but I did not compare the results of the two methods with code you mentioned,maybe I should. and I will do this to check it in the afternoon.
thank you very much!

1 Like

I think it was my fault. I checked later and found that some entities had not been deleted, but I thought they had been deleted,what a fool mistake :blush:

1 Like