From f3f69e1ad78bef1bc0502c74c256c6f138b90db4 Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Tue, 24 Oct 2023 17:58:43 -0600 Subject: [PATCH] fix morphtarget normals not defined breaking export --- src/library/VRMExporterv0.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/library/VRMExporterv0.js b/src/library/VRMExporterv0.js index 864739f8..53813068 100644 --- a/src/library/VRMExporterv0.js +++ b/src/library/VRMExporterv0.js @@ -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をいれた