Open querielo opened 12 months ago
possibly related to https://github.com/playcanvas/engine/issues/5329
I'm not sure I understand this, but I'm not sure it is correct what it is saying.
You can definitely have a single mesh, and have it twice in the scene, each being animated by a separate skeleton, Is that what you need?
NOTE: tried to disable https://github.com/playcanvas/engine/blob/e5fa96b2411bc345478d873914f9dca3413a85c8/src/framework/parsers/glb-parser.js#L665 It doesn't help.
Have you tried a single skinned character in the glb. Import it to the Editor, and place the template twice in the scene. Attach the anim component to both hierarchies, set up rootBone of the render component to point to those skeletons, and play two different animations - that should work fine. There will be a single mesh and a single skin in memory, and two mesh instances and two skin instances.
The main problem is that at the stage of the glb-parser we lose information about actual bones of skinned meshes. This is because at least the parser assumes that each mesh is in a one-to-one/many-to-one relationship with a skin.
Thanks for your suggestion. In this case there will be different skin instances. But "Import it to the Editor" contradicts with our assets preparation pipeline.
Our current workaround is:
implemented after a .glb-file is parsed. The idea is to call _clearSkinInstances and _cloneSkinInstances with correct rootBone. But in general it is not correct.
It won't work for all possible cases but works for us.
Currently, it's not possible to instantiate multiple skins on one mesh. It seems that the Mesh shouldn't contain the skin (Mesh.skin)
I believe that the Mesh and Skin should be in a many-to-many relationship (Mesh has many data, Skin has many data) and one shouldn't be stored inside the other to avoid excessive resource allocation when we need to copy or reuse one without other. Note that the information about Skin in MeshInstance is delegated to SkinInstance. This means, through skinInstance and mesh in MeshInstance, we can ideally maintain a many-to-many relationship, rather than storing Skin in Mesh.
What problems does this cause?
This means that the mesh and skin can be instantiated in different combinations in a node, which in the current architecture can only be implemented by cloning the mesh (rather than reusing it). Here is the issue place in glb-parser.js