diff --git a/src/GLTFLoaderAnimationPointer.js b/src/GLTFLoaderAnimationPointer.js index 56a9f64..aee5ded 100644 --- a/src/GLTFLoaderAnimationPointer.js +++ b/src/GLTFLoaderAnimationPointer.js @@ -247,23 +247,29 @@ export class GLTFAnimationPointerExtension { const pathStartNode = path.substring( 0, pathIndexNode ); targetProperty = path.substring( pathIndexNode ); - switch ( targetProperty ) { - - case 'translation': - targetProperty = 'position'; - break; - case 'rotation': - targetProperty = 'quaternion'; - break; - case 'scale': - targetProperty = 'scale'; - break; - case 'weights': - targetProperty = 'morphTargetInfluences'; - break; - case "extensions/KHR_node_visibility/visible": - targetProperty = 'visible'; - break; + if ( targetProperty.startsWith( 'weights/' ) ) { + // `/nodes/{}/weights/{}` - control individual morph weights + const weightIndex = targetProperty.substring( 'weights/'.length ); + targetProperty = 'morphTargetInfluences[' + weightIndex + ']'; + } else { + switch ( targetProperty ) { + + case 'translation': + targetProperty = 'position'; + break; + case 'rotation': + targetProperty = 'quaternion'; + break; + case 'scale': + targetProperty = 'scale'; + break; + case 'weights': + targetProperty = 'morphTargetInfluences'; + break; + case "extensions/KHR_node_visibility/visible": + targetProperty = 'visible'; + break; + } } path = pathStartNode + targetProperty; @@ -385,8 +391,11 @@ export class GLTFAnimationPointerExtension { // specially handle the morphTargetInfluences property for multi-material meshes // in which case the target object is a Group and the children are the actual targets + // Note that there is also morphTargetInfluences[i] for individual morph targets // see NE-3311 - if ( parts[ 3 ] === 'morphTargetInfluences' ) { + if ( parts[ 3 ].startsWith( 'morphTargetInfluences' ) ) { + + const property = parts[ 3 ]; if ( node.type === 'Group' ) { @@ -399,7 +408,7 @@ export class GLTFAnimationPointerExtension { if ( ch instanceof SkinnedMesh && ch.morphTargetInfluences ) { parts[ 3 ] = ch.name; - parts[ 4 ] = 'morphTargetInfluences'; + parts[ 4 ] = property; __createTrack( this.parser ); }