Skip to content

Commit

Permalink
Merge pull request #429 from KhronosGroup/fix/robustness_missing_ibm
Browse files Browse the repository at this point in the history
Accept missing inverse bind matrices
  • Loading branch information
UX3D-kanzler authored Nov 4, 2022
2 parents 75d834d + 909fd24 commit 0cd6901
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions source/gltf/skin.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ class gltfSkin extends GltfObject

computeJoints(gltf, parentNode, webGlContext)
{
const ibmAccessor = gltf.accessors[this.inverseBindMatrices].getDeinterlacedView(gltf);
let ibmAccessor = null;
if (this.inverseBindMatrices !== undefined) {
ibmAccessor = gltf.accessors[this.inverseBindMatrices].getDeinterlacedView(gltf);
}

this.jointMatrices = [];
this.jointNormalMatrices = [];

Expand All @@ -80,10 +84,13 @@ class gltfSkin extends GltfObject
{
const node = gltf.nodes[joint];

let jointMatrix = mat4.create();
let ibm = jsToGlSlice(ibmAccessor, i * 16, 16);
mat4.mul(jointMatrix, node.worldTransform, ibm);
mat4.mul(jointMatrix, parentNode.inverseWorldTransform, jointMatrix);
let jointMatrix = mat4.clone(node.worldTransform);

if (ibmAccessor !== null) {
let ibm = jsToGlSlice(ibmAccessor, i * 16, 16);
mat4.mul(jointMatrix, jointMatrix, ibm);
mat4.mul(jointMatrix, parentNode.inverseWorldTransform, jointMatrix);
}

let normalMatrix = mat4.create();
mat4.invert(normalMatrix, jointMatrix);
Expand Down

0 comments on commit 0cd6901

Please sign in to comment.