Skip to content

Commit

Permalink
fix morphtarget normals not defined breaking export
Browse files Browse the repository at this point in the history
  • Loading branch information
memelotsqui committed Oct 24, 2023
1 parent 5347f4f commit f3f69e1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/library/VRMExporterv0.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,20 @@ export default class VRMExporterv0 {
for (const prop in mesh.morphTargetDictionary){

mesh.geometry.userData.targetNames.push(prop);

const morphIndex = mesh.morphTargetDictionary[prop];
const morphAttribute = mesh.geometry.morphAttributes;

meshDatas.push(new MeshData(morphAttribute.position[morphIndex], WEBGL_CONST.FLOAT, MeshDataType.BLEND_POSITION, AccessorsType.VEC3, mesh.name, BLENDSHAPE_PREFIX + prop));
meshDatas.push(new MeshData(morphAttribute.normal[morphIndex], WEBGL_CONST.FLOAT, MeshDataType.BLEND_NORMAL, AccessorsType.VEC3, mesh.name, BLENDSHAPE_PREFIX + prop));
}

if (morphAttribute.normal){
meshDatas.push(new MeshData(
morphAttribute.normal[morphIndex],
WEBGL_CONST.FLOAT,
MeshDataType.BLEND_NORMAL,
AccessorsType.VEC3,
mesh.name,
BLENDSHAPE_PREFIX + prop));
}
}
});
// inverseBindMatrices length = 16(matrixの要素数) * 4バイト * ボーン数
// TODO: とりあえず数合わせでrootNode以外のBoneのmatrixをいれた
Expand Down

0 comments on commit f3f69e1

Please sign in to comment.