Skip to content

Commit

Permalink
GLTFLoader: Ensure that geometry cache includes Draco-encoded primiti…
Browse files Browse the repository at this point in the history
…ves.
  • Loading branch information
Don McCurdy committed Feb 16, 2018
1 parent 7d95279 commit ef9ffde
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions examples/js/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,6 @@ THREE.GLTFLoader = ( function () {
* DRACO Mesh Compression Extension
*
* Specification: https://github.com/KhronosGroup/glTF/pull/874
*
* TODO: Support fallback to uncompressed data if decoder is unavailable.
*/
function GLTFDracoMeshCompressionExtension ( dracoLoader ) {

Expand Down Expand Up @@ -1090,8 +1088,6 @@ THREE.GLTFLoader = ( function () {
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
*
* TODO: Implement support for morph targets on TANGENT attribute.
*
* @param {THREE.Mesh} mesh
* @param {GLTF.Mesh} meshDef
* @param {GLTF.Primitive} primitiveDef
Expand Down Expand Up @@ -1254,7 +1250,7 @@ THREE.GLTFLoader = ( function () {

if ( isPrimitiveEqual( cached.primitive, newPrimitive ) ) {

return cached.geometry;
return cached.promise;

}

Expand Down Expand Up @@ -2017,24 +2013,30 @@ THREE.GLTFLoader = ( function () {
if ( cached ) {

// Use the cached geometry if it exists
geometries.push( cached );
pending.push( cached.then( function ( geometry ) {

geometries.push( geometry );

continue;
} ) );

} else if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) {

// Use DRACO geometry if available
pending.push( extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ]
var geometryPromise = extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ]
.decodePrimitive( primitive, parser )
.then( function ( geometry ) {

addPrimitiveAttributes( geometry, primitive, accessors );

geometries.push( geometry );

// TODO(donmccurdy): Cache DRACO geometries.
return geometry;

} );

cache.push( { primitive: primitive, promise: geometryPromise } );

} ) );
pending.push( geometryPromise );

} else {

Expand All @@ -2047,7 +2049,7 @@ THREE.GLTFLoader = ( function () {
cache.push( {

primitive: primitive,
geometry: geometry
promise: Promise.resolve( geometry )

} );

Expand Down

0 comments on commit ef9ffde

Please sign in to comment.