playcanvas / playcanvas/engine

Architectural Issue: The skin is defined within the mesh.

Open
#5,680 8 comments 0 reactions 1 assignee View on GitHub

@mvaligursky is already working on this.

Since Sep 26, 2023.

area: graphics
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

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?

  1. The current implementation requires that if we have two nodes with the same mesh and these nodes have unrelated skeletons, we need to create two Meshes. Otherwise, the skinning/animation of the mesh on the second node will be incorrect. Cloning a mesh is resource-intensive, and it requires tracking more allocated resources. Note: the engine does not provide API to clone a mesh.
  2. I believe the PlayCanvas architecture is very compatible with glTF. According to its specification glTF 2.0 Specification

A skin is instantiated within a node using a combination of the node’s mesh and skin properties. The mesh for a skin instance is defined in the mesh property. The skin property contains the index of the skin to instance.

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.