浏览代码

Updated examples builds.

Mr.doob 3 年之前
父节点
当前提交
890aea742e

+ 14 - 2
examples/js/interactive/HTMLMesh.js

@@ -14,7 +14,7 @@
 
 			function onEvent( event ) {
 
-				material.map.dispatchEvent( event );
+				material.map.dispatchDOMEvent( event );
 
 			}
 
@@ -23,6 +23,18 @@
 			this.addEventListener( 'mouseup', onEvent );
 			this.addEventListener( 'click', onEvent );
 
+			this.dispose = function () {
+
+				geometry.dispose();
+				material.dispose();
+				material.map.dispose();
+				this.removeEventListener( 'mousedown', onEvent );
+				this.removeEventListener( 'mousemove', onEvent );
+				this.removeEventListener( 'mouseup', onEvent );
+				this.removeEventListener( 'click', onEvent );
+
+			};
+
 		}
 
 	}
@@ -40,7 +52,7 @@
 
 		}
 
-		dispatchEvent( event ) {
+		dispatchDOMEvent( event ) {
 
 			htmlevent( this.dom, event.type, event.data.x, event.data.y );
 			this.update();

+ 1 - 1
examples/js/loaders/GLTFLoader.js

@@ -2006,7 +2006,7 @@
 			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.
 
-			if ( typeof createImageBitmap !== 'undefined' && /Firefox|Safari/.test( navigator.userAgent ) === false ) {
+			if ( typeof createImageBitmap !== 'undefined' && /Firefox|^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === false ) {
 
 				this.textureLoader = new THREE.ImageBitmapLoader( this.options.manager );
 

+ 2 - 1
examples/js/loaders/LDrawLoader.js

@@ -2029,7 +2029,8 @@
 
 		getMainEdgeMaterial() {
 
-			return this.getMaterial( MAIN_EDGE_COLOUR_CODE );
+			const mainMat = this.getMainMaterial();
+			return mainMat && mainMat.userData ? mainMat.userData.edgeMaterial : null;
 
 		}
 

+ 10 - 3
examples/js/loaders/MTLLoader.js

@@ -327,6 +327,13 @@
 				map.offset.copy( texParams.offset );
 				map.wrapS = scope.wrap;
 				map.wrapT = scope.wrap;
+
+				if ( mapType === 'map' || mapType === 'emissiveMap' ) {
+
+					map.encoding = THREE.sRGBEncoding;
+
+				}
+
 				params[ mapType ] = map;
 
 			}
@@ -342,17 +349,17 @@
 					// Ns is material specular exponent
 					case 'kd':
 						// Diffuse color (color under white light) using RGB values
-						params.color = new THREE.Color().fromArray( value );
+						params.color = new THREE.Color().fromArray( value ).convertSRGBToLinear();
 						break;
 
 					case 'ks':
 						// Specular color (color when light is reflected from shiny surface) using RGB values
-						params.specular = new THREE.Color().fromArray( value );
+						params.specular = new THREE.Color().fromArray( value ).convertSRGBToLinear();
 						break;
 
 					case 'ke':
 						// Emissive using RGB values
-						params.emissive = new THREE.Color().fromArray( value );
+						params.emissive = new THREE.Color().fromArray( value ).convertSRGBToLinear();
 						break;
 
 					case 'map_kd':

+ 1 - 2
examples/js/loaders/SVGLoader.js

@@ -110,8 +110,7 @@
 
 					case 'use':
 						style = parseStyle( node, style );
-
-						const href = node.getAttributeNS( "http://www.w3.org/1999/xlink", "href" ) || "";
+						const href = node.getAttributeNS( 'http://www.w3.org/1999/xlink', 'href' ) || '';
 						const usedNodeId = href.substring( 1 );
 						const usedNode = node.viewportElement.getElementById( usedNodeId );
 

+ 1 - 5
examples/js/postprocessing/OutlinePass.js

@@ -25,10 +25,6 @@
 			};
 			const resx = Math.round( this.resolution.x / this.downSampleRatio );
 			const resy = Math.round( this.resolution.y / this.downSampleRatio );
-			this.maskBufferMaterial = new THREE.MeshBasicMaterial( {
-				color: 0xffffff
-			} );
-			this.maskBufferMaterial.side = THREE.DoubleSide;
 			this.renderTargetMaskBuffer = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, pars );
 			this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask';
 			this.renderTargetMaskBuffer.texture.generateMipmaps = false;
@@ -93,7 +89,7 @@
 
 			function replaceDepthToViewZ( string, camera ) {
 
-				var type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic';
+				const type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic';
 				return string.replace( /DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ' );
 
 			}

+ 3 - 1
examples/jsm/loaders/SVGLoader.js

@@ -129,7 +129,9 @@ class SVGLoader extends Loader {
 
 				case 'use':
 					style = parseStyle( node, style );
-					const usedNodeId = node.href.baseVal.substring( 1 );
+
+					const href = node.getAttributeNS( 'http://www.w3.org/1999/xlink', 'href' ) || '';
+					const usedNodeId = href.substring( 1 );
 					const usedNode = node.viewportElement.getElementById( usedNodeId );
 					if ( usedNode ) {