|
@@ -329,10 +329,10 @@
|
|
|
EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression'
|
|
|
};
|
|
|
/**
|
|
|
- * Punctual Lights Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
|
|
|
- */
|
|
|
+ * Punctual Lights Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
|
|
|
+ */
|
|
|
|
|
|
class GLTFLightsExtension {
|
|
|
|
|
@@ -444,10 +444,10 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * Unlit Materials Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
|
|
|
- */
|
|
|
+ * Unlit Materials Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFMaterialsUnlitExtension {
|
|
@@ -495,10 +495,10 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * Clearcoat Materials Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
|
|
|
- */
|
|
|
+ * Clearcoat Materials Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFMaterialsClearcoatExtension {
|
|
@@ -577,11 +577,11 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * Transmission Materials Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
|
|
|
- * Draft: https://github.com/KhronosGroup/glTF/pull/1698
|
|
|
- */
|
|
|
+ * Transmission Materials Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
|
|
|
+ * Draft: https://github.com/KhronosGroup/glTF/pull/1698
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFMaterialsTransmissionExtension {
|
|
@@ -634,10 +634,10 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * BasisU Texture Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
|
|
|
- */
|
|
|
+ * BasisU Texture Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFTextureBasisUExtension {
|
|
@@ -686,10 +686,10 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * WebP Texture Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
|
|
|
- */
|
|
|
+ * WebP Texture Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFTextureWebPExtension {
|
|
@@ -770,10 +770,10 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * meshopt BufferView Compression Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
|
|
|
- */
|
|
|
+ * meshopt BufferView Compression Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFMeshoptCompression {
|
|
@@ -905,10 +905,10 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * DRACO THREE.Mesh Compression Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
|
|
|
- */
|
|
|
+ * DRACO THREE.Mesh Compression Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFDracoMeshCompressionExtension {
|
|
@@ -986,10 +986,10 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * Texture Transform Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
|
|
|
- */
|
|
|
+ * Texture Transform Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFTextureTransformExtension {
|
|
@@ -1002,6 +1002,19 @@
|
|
|
|
|
|
extendTexture( texture, transform ) {
|
|
|
|
|
|
+ if ( transform.texCoord !== undefined ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined ) {
|
|
|
+
|
|
|
+ // See https://github.com/mrdoob/three.js/issues/21819.
|
|
|
+ return texture;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
texture = texture.clone();
|
|
|
|
|
|
if ( transform.offset !== undefined ) {
|
|
@@ -1022,12 +1035,6 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( transform.texCoord !== undefined ) {
|
|
|
-
|
|
|
- console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
texture.needsUpdate = true;
|
|
|
return texture;
|
|
|
|
|
@@ -1035,16 +1042,16 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * Specular-Glossiness Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness
|
|
|
- */
|
|
|
+ * Specular-Glossiness Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness
|
|
|
+ */
|
|
|
|
|
|
/**
|
|
|
- * A sub class of StandardMaterial with some of the functionality
|
|
|
- * changed via the `onBeforeCompile` callback
|
|
|
- * @pailhead
|
|
|
- */
|
|
|
+ * A sub class of StandardMaterial with some of the functionality
|
|
|
+ * changed via the `onBeforeCompile` callback
|
|
|
+ * @pailhead
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFMeshStandardSGMaterial extends THREE.MeshStandardMaterial {
|
|
@@ -1277,10 +1284,10 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * THREE.Mesh Quantization Extension
|
|
|
- *
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
|
|
|
- */
|
|
|
+ * THREE.Mesh Quantization Extension
|
|
|
+ *
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
|
|
|
+ */
|
|
|
|
|
|
|
|
|
class GLTFMeshQuantizationExtension {
|
|
@@ -1481,8 +1488,8 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
|
|
|
- */
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
|
|
|
+ */
|
|
|
|
|
|
|
|
|
function createDefaultMaterial( cache ) {
|
|
@@ -1521,9 +1528,9 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * @param {Object3D|Material|BufferGeometry} object
|
|
|
- * @param {GLTF.definition} gltfDef
|
|
|
- */
|
|
|
+ * @param {Object3D|Material|BufferGeometry} object
|
|
|
+ * @param {GLTF.definition} gltfDef
|
|
|
+ */
|
|
|
|
|
|
|
|
|
function assignExtrasToUserData( object, gltfDef ) {
|
|
@@ -1544,13 +1551,13 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
|
|
|
- *
|
|
|
- * @param {BufferGeometry} geometry
|
|
|
- * @param {Array<GLTF.Target>} targets
|
|
|
- * @param {GLTFParser} parser
|
|
|
- * @return {Promise<BufferGeometry>}
|
|
|
- */
|
|
|
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
|
|
|
+ *
|
|
|
+ * @param {BufferGeometry} geometry
|
|
|
+ * @param {Array<GLTF.Target>} targets
|
|
|
+ * @param {GLTFParser} parser
|
|
|
+ * @return {Promise<BufferGeometry>}
|
|
|
+ */
|
|
|
|
|
|
|
|
|
function addMorphTargets( geometry, targets, parser ) {
|
|
@@ -1604,9 +1611,9 @@
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
- * @param {Mesh} mesh
|
|
|
- * @param {GLTF.Mesh} meshDef
|
|
|
- */
|
|
|
+ * @param {Mesh} mesh
|
|
|
+ * @param {GLTF.Mesh} meshDef
|
|
|
+ */
|
|
|
|
|
|
|
|
|
function updateMorphTargets( mesh, meshDef ) {
|
|
@@ -1735,7 +1742,8 @@
|
|
|
this.lightCache = {
|
|
|
refs: {},
|
|
|
uses: {}
|
|
|
- }; // Track node names, to ensure no duplicates
|
|
|
+ };
|
|
|
+ this.textureCache = {}; // Track node names, to ensure no duplicates
|
|
|
|
|
|
this.nodeNamesUsed = {}; // Use an THREE.ImageBitmapLoader if imageBitmaps are supported. Moves much of the
|
|
|
// expensive work of uploading a texture to the GPU off the main thread.
|
|
@@ -2273,6 +2281,15 @@
|
|
|
const json = this.json;
|
|
|
const options = this.options;
|
|
|
const textureDef = json.textures[ textureIndex ];
|
|
|
+ const cacheKey = ( source.uri || source.bufferView ) + ':' + textureDef.sampler;
|
|
|
+
|
|
|
+ if ( this.textureCache[ cacheKey ] ) {
|
|
|
+
|
|
|
+ // See https://github.com/mrdoob/three.js/issues/21559.
|
|
|
+ return this.textureCache[ cacheKey ];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
const URL = self.URL || self.webkitURL;
|
|
|
let sourceURI = source.uri;
|
|
|
let isObjectURL = false;
|
|
@@ -2312,7 +2329,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- return Promise.resolve( sourceURI ).then( function ( sourceURI ) {
|
|
|
+ const promise = Promise.resolve( sourceURI ).then( function ( sourceURI ) {
|
|
|
|
|
|
return new Promise( function ( resolve, reject ) {
|
|
|
|
|
@@ -2358,6 +2375,8 @@
|
|
|
return texture;
|
|
|
|
|
|
} );
|
|
|
+ this.textureCache[ cacheKey ] = promise;
|
|
|
+ return promise;
|
|
|
|
|
|
}
|
|
|
/**
|