for example,i want to import a model of car which has a lot of nodes(parts),and i plan to change children’s position or rotation,likes this
this is my project’s link:https://playcanvas.com/project/643550/overview/my--first-webvr.
it’s a VR scene.
This does not directly answer your question, but the way we currently deal with this is to bring each mesh that needs to be animated/moved in as a separate mesh and then create a unique entity for it.
I am hoping that someone will have an answer to how to deal with the child nodes separately by their nodes though. Being able to address child nodes directly might be useful for reducing clutter. OTOH, if you need to attach any other components to the “child”, then it would have to be a unique entity anyway.
Each sub mesh in the model gets imported as a graphNode so you can do findByName on the entity that has the model component to find the sub meshes by name.
thanks a lot for your help,i solved this problem by F12 in debug webPage,which i could see the relationship of all nodes,
this.targetEntity.children.children.children[i]._sync();"yeah, it finally really changed my children’s position.
today,i try this line: this.targetEntity.children.children.children[i].setLocalPosition(new pc.Vec3(90,10,10));,it also worked,didn’t need refreshing
it shuld be a way ,i will try it.thank you ,bro
setLocalPosition. That is public API.
Do not use
_sync. Those are private and internal.
sometimes it makes me confused,it does exist,but i can’t see the api when i write the script,just like “setLocalPosition”,
the Documents.hope it improving.
Interesting. Note that if you change “targetEntity” to simply “entity” that you get a different API reference from the auto-complete. I guess the issue is that the autocomplete may have a hard time determining the appropriate context at times?
thanks,my friend,i got it.