Skip to content

Commit

Permalink
Merge pull request #39 from MozillaReality/GLTFLoader/animation-path-…
Browse files Browse the repository at this point in the history
…uuid

Use node uuids for animation paths and fix morph target caching
  • Loading branch information
robertlong authored Aug 7, 2019
2 parents 6041920 + 7a8a69f commit 0f9b002
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
7 changes: 4 additions & 3 deletions examples/js/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ THREE.GLTFExporter.prototype = {

meshes: new Map(),
attributes: new Map(),
attributesRelative: new Map(),
attributesNormalized: new Map(),
materials: new Map(),
textures: new Map(),
Expand Down Expand Up @@ -1250,9 +1251,9 @@ THREE.GLTFExporter.prototype = {

var baseAttribute = geometry.attributes[ attributeName ];

if ( cachedData.attributes.has( getUID( attribute ) ) ) {
if ( cachedData.attributesRelative.has( getUID( attribute ) ) ) {

target[ gltfAttributeName ] = cachedData.attributes.get( getUID( attribute ) );
target[ gltfAttributeName ] = cachedData.attributesRelative.get( getUID( attribute ) );
continue;

}
Expand All @@ -1272,7 +1273,7 @@ THREE.GLTFExporter.prototype = {
}

target[ gltfAttributeName ] = processAccessor( relativeAttribute, geometry );
cachedData.attributes.set( getUID( baseAttribute ), target[ gltfAttributeName ] );
cachedData.attributesRelative.set( getUID( baseAttribute ), target[ gltfAttributeName ] );

}

Expand Down
6 changes: 2 additions & 4 deletions examples/js/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2810,8 +2810,6 @@ THREE.GLTFLoader = ( function () {

}

var targetName = node.name ? node.name : node.uuid;

var interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : THREE.InterpolateLinear;

var targetNames = [];
Expand All @@ -2823,15 +2821,15 @@ THREE.GLTFLoader = ( function () {

if ( object.isMesh === true && object.morphTargetInfluences ) {

targetNames.push( object.name ? object.name : object.uuid );
targetNames.push( object.uuid );

}

} );

} else {

targetNames.push( targetName );
targetNames.push( node.uuid );

}

Expand Down
7 changes: 4 additions & 3 deletions examples/jsm/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ GLTFExporter.prototype = {

meshes: new Map(),
attributes: new Map(),
attributesRelative: new Map(),
attributesNormalized: new Map(),
materials: new Map(),
textures: new Map(),
Expand Down Expand Up @@ -1274,9 +1275,9 @@ GLTFExporter.prototype = {

var baseAttribute = geometry.attributes[ attributeName ];

if ( cachedData.attributes.has( getUID( attribute ) ) ) {
if ( cachedData.attributesRelative.has( getUID( attribute ) ) ) {

target[ gltfAttributeName ] = cachedData.attributes.get( getUID( attribute ) );
target[ gltfAttributeName ] = cachedData.attributesRelative.get( getUID( attribute ) );
continue;

}
Expand All @@ -1296,7 +1297,7 @@ GLTFExporter.prototype = {
}

target[ gltfAttributeName ] = processAccessor( relativeAttribute, geometry );
cachedData.attributes.set( getUID( baseAttribute ), target[ gltfAttributeName ] );
cachedData.attributesRelative.set( getUID( baseAttribute ), target[ gltfAttributeName ] );

}

Expand Down
6 changes: 2 additions & 4 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2876,8 +2876,6 @@ var GLTFLoader = ( function () {

}

var targetName = node.name ? node.name : node.uuid;

var interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : InterpolateLinear;

var targetNames = [];
Expand All @@ -2889,15 +2887,15 @@ var GLTFLoader = ( function () {

if ( object.isMesh === true && object.morphTargetInfluences ) {

targetNames.push( object.name ? object.name : object.uuid );
targetNames.push( object.uuid );

}

} );

} else {

targetNames.push( targetName );
targetNames.push( node.uuid );

}

Expand Down

0 comments on commit 0f9b002

Please sign in to comment.