Michael Herzog 4 роки тому
батько
коміт
7b8815b329

+ 30 - 2
examples/js/lines/LineMaterial.js

@@ -276,7 +276,6 @@
 				clipping: true // required for clipping support
 
 			} );
-			this.dashed = false;
 			Object.defineProperties( this, {
 				color: {
 					enumerable: true,
@@ -304,6 +303,35 @@
 
 					}
 				},
+				dashed: {
+					enumerable: true,
+					get: function () {
+
+						return Boolean( 'USE_DASH' in this.defines );
+
+					},
+
+					set( value ) {
+
+						if ( Boolean( value ) !== Boolean( 'USE_DASH' in this.defines ) ) {
+
+							this.needsUpdate = true;
+
+						}
+
+						if ( value === true ) {
+
+							this.defines.USE_DASH = '';
+
+						} else {
+
+							delete this.defines.USE_DASH;
+
+						}
+
+					}
+
+				},
 				dashScale: {
 					enumerable: true,
 					get: function () {
@@ -397,7 +425,7 @@
 
 						}
 
-						if ( value ) {
+						if ( value === true ) {
 
 							this.defines.ALPHA_TO_COVERAGE = '';
 							this.extensions.derivatives = true;

+ 91 - 72
examples/js/loaders/GLTFLoader.js

@@ -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;
 
 		}
 		/**

+ 3 - 4
examples/jsm/nodes/procedural/Fractal3DNode.js

@@ -4,7 +4,6 @@ import { FunctionCallNode } from '../core/FunctionCallNode.js';
 import { IntNode } from '../inputs/IntNode.js';
 import { FloatNode } from '../inputs/FloatNode.js';
 import { PositionNode } from '../accessors/PositionNode.js';
-import { Noise2DNode } from './Noise2DNode.js';
 import { Noise3DNode } from './Noise3DNode.js';
 
 const FRACTAL3D_SRC = `
@@ -70,7 +69,7 @@ class Fractal3DNode extends TempNode {
 
 	toJSON( meta ) {
 
-		const data = this.getJSONNode( meta );
+		let data = this.getJSONNode( meta );
 
 		if ( ! data ) {
 
@@ -92,7 +91,7 @@ class Fractal3DNode extends TempNode {
 
 Fractal3DNode.prototype.nodeType = 'Fractal3D';
 
-Fractal3DNode.Nodes = (function () {
+Fractal3DNode.Nodes = ( function () {
 
 	const fractal3d = new FunctionNode( FRACTAL3D_SRC );
 
@@ -100,6 +99,6 @@ Fractal3DNode.Nodes = (function () {
 
 	return { fractal3d };
 
-})();
+} )();
 
 export { Fractal3DNode };

+ 4 - 5
examples/jsm/nodes/procedural/Noise2DNode.js

@@ -1,7 +1,6 @@
 import { TempNode } from '../core/TempNode.js';
 import { FunctionNode } from '../core/FunctionNode.js';
 import { FunctionCallNode } from '../core/FunctionCallNode.js';
-import { IntNode } from '../inputs/IntNode.js';
 import { FloatNode } from '../inputs/FloatNode.js';
 import { UVNode } from '../accessors/UVNode.js';
 
@@ -97,7 +96,7 @@ class Noise2DNode extends TempNode {
 
 	}
 
-	generate(builder, output) {
+	generate( builder, output ) {
 
 		const noise2d = new FunctionCallNode( Noise2DNode.Nodes.noise2d, [ this.uv, this.amplitude, this.pivot ] );
 		return builder.format( noise2d.generate( builder, output ), this.getType( builder ), output );
@@ -116,7 +115,7 @@ class Noise2DNode extends TempNode {
 
 	toJSON( meta ) {
 
-		const data = this.getJSONNode( meta );
+		let data = this.getJSONNode( meta );
 
 		if ( ! data ) {
 
@@ -136,7 +135,7 @@ class Noise2DNode extends TempNode {
 
 Noise2DNode.prototype.nodeType = 'Noise2D';
 
-Noise2DNode.Nodes = (function () {
+Noise2DNode.Nodes = ( function () {
 
 	const noiseCommon = new FunctionNode( NOISE_COMMON_SRC );
 	const noise2d = new FunctionNode( NOISE2D_SRC );
@@ -145,6 +144,6 @@ Noise2DNode.Nodes = (function () {
 
 	return { noiseCommon, noise2d };
 
-})();
+} )();
 
 export { Noise2DNode };

+ 4 - 5
examples/jsm/nodes/procedural/Noise3DNode.js

@@ -1,7 +1,6 @@
 import { TempNode } from '../core/TempNode.js';
 import { FunctionNode } from '../core/FunctionNode.js';
 import { FunctionCallNode } from '../core/FunctionCallNode.js';
-import { IntNode } from '../inputs/IntNode.js';
 import { FloatNode } from '../inputs/FloatNode.js';
 import { PositionNode } from '../accessors/PositionNode.js';
 import { Noise2DNode } from './Noise2DNode.js';
@@ -90,7 +89,7 @@ class Noise3DNode extends TempNode {
 
 	}
 
-	generate(builder, output) {
+	generate( builder, output ) {
 
 		const noise3d = new FunctionCallNode( Noise3DNode.Nodes.noise3d, [ this.position, this.amplitude, this.pivot ] );
 		return builder.format( noise3d.generate( builder, output ), this.getType( builder ), output );
@@ -109,7 +108,7 @@ class Noise3DNode extends TempNode {
 
 	toJSON( meta ) {
 
-		const data = this.getJSONNode( meta );
+		let data = this.getJSONNode( meta );
 
 		if ( ! data ) {
 
@@ -129,7 +128,7 @@ class Noise3DNode extends TempNode {
 
 Noise3DNode.prototype.nodeType = 'Noise3D';
 
-Noise3DNode.Nodes = (function () {
+Noise3DNode.Nodes = ( function () {
 
 	const noise3d = new FunctionNode( NOISE3D_SRC );
 
@@ -137,6 +136,6 @@ Noise3DNode.Nodes = (function () {
 
 	return { noise3d };
 
-})();
+} )();
 
 export { Noise3DNode };