Skip to content

Commit

Permalink
Merge pull request #14711 from Mugen87/dev2
Browse files Browse the repository at this point in the history
BufferGeometry: Support name of morph targets in .fromGeometry()
  • Loading branch information
mrdoob authored Aug 14, 2018
2 parents 7e75294 + 95e93fe commit b392564
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/core/BufferGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,10 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy

var morphTarget = morphTargets[ i ];

var attribute = new Float32BufferAttribute( morphTarget.length * 3, 3 );
var attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );
attribute.name = morphTarget.name;

array.push( attribute.copyVector3sArray( morphTarget ) );
array.push( attribute.copyVector3sArray( morphTarget.data ) );

}

Expand Down
14 changes: 10 additions & 4 deletions src/core/DirectGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ Object.assign( DirectGeometry.prototype, {

for ( var i = 0; i < morphTargetsLength; i ++ ) {

morphTargetsPosition[ i ] = [];
morphTargetsPosition[ i ] = {
name: morphTargets[ i ].name,
data: []
};

}

Expand All @@ -122,7 +125,10 @@ Object.assign( DirectGeometry.prototype, {

for ( var i = 0; i < morphNormalsLength; i ++ ) {

morphTargetsNormal[ i ] = [];
morphTargetsNormal[ i ] = {
name: morphNormals[ i ].name,
data: []
};

}

Expand Down Expand Up @@ -222,15 +228,15 @@ Object.assign( DirectGeometry.prototype, {

var morphTarget = morphTargets[ j ].vertices;

morphTargetsPosition[ j ].push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );
morphTargetsPosition[ j ].data.push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );

}

for ( var j = 0; j < morphNormalsLength; j ++ ) {

var morphNormal = morphNormals[ j ].vertexNormals[ i ];

morphTargetsNormal[ j ].push( morphNormal.a, morphNormal.b, morphNormal.c );
morphTargetsNormal[ j ].data.push( morphNormal.a, morphNormal.b, morphNormal.c );

}

Expand Down

0 comments on commit b392564

Please sign in to comment.