Skip to content

Commit

Permalink
Accept missing inverse bind matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-ec committed Sep 27, 2022
1 parent 78e6453 commit 909fd24
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 909fd24

Please sign in to comment.