浏览代码

Updated examples builds.

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

+ 2 - 2
examples/js/animation/MMDPhysics.js

@@ -185,8 +185,8 @@
 			// mesh's default world transform as position(0, 0, 0),
 			// quaternion(0, 0, 0, 1) and scale(0, 0, 0)
 
-			let parent = mesh.parent;
-			if ( parent !== null ) parent = null;
+			const parent = mesh.parent;
+			if ( parent !== null ) mesh.parent = null;
 			const currentPosition = manager.allocThreeVector3();
 			const currentQuaternion = manager.allocThreeQuaternion();
 			const currentScale = manager.allocThreeVector3();

+ 8 - 27
examples/js/effects/AsciiEffect.js

@@ -13,18 +13,18 @@
 			// darker bolder character set from https://github.com/saw/Canvas-ASCII-Art/
 			// ' .\'`^",:;Il!i~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$'.split('');
 			// Some ASCII settings
-			const bResolution = ! options[ 'resolution' ] ? 0.15 : options[ 'resolution' ]; // Higher for more details
+			const fResolution = options[ 'resolution' ] || 0.15; // Higher for more details
 
-			const iScale = ! options[ 'scale' ] ? 1 : options[ 'scale' ];
-			const bColor = ! options[ 'color' ] ? false : options[ 'color' ]; // nice but slows down rendering!
+			const iScale = options[ 'scale' ] || 1;
+			const bColor = options[ 'color' ] || false; // nice but slows down rendering!
 
-			const bAlpha = ! options[ 'alpha' ] ? false : options[ 'alpha' ]; // Transparency
+			const bAlpha = options[ 'alpha' ] || false; // Transparency
 
-			const bBlock = ! options[ 'block' ] ? false : options[ 'block' ]; // blocked characters. like good O dos
+			const bBlock = options[ 'block' ] || false; // blocked characters. like good O dos
 
-			const bInvert = ! options[ 'invert' ] ? false : options[ 'invert' ]; // black is white, white is black
+			const bInvert = options[ 'invert' ] || false; // black is white, white is black
 
-			const strResolution = 'low';
+			const strResolution = options[ 'strResolution' ] || 'low';
 			let width, height;
 			const domElement = document.createElement( 'div' );
 			domElement.style.cursor = 'default';
@@ -108,26 +108,7 @@
 			}
 
 			let aCharList = bColor ? aDefaultColorCharList : aDefaultCharList;
-			if ( charSet ) aCharList = charSet;
-			let fResolution = 0.5;
-
-			switch ( strResolution ) {
-
-				case 'low':
-					fResolution = 0.25;
-					break;
-
-				case 'medium':
-					fResolution = 0.5;
-					break;
-
-				case 'high':
-					fResolution = 1;
-					break;
-
-			}
-
-			if ( bResolution ) fResolution = bResolution; // Setup dom
+			if ( charSet ) aCharList = charSet; // Setup dom
 
 			const fFontSize = 2 / fResolution * iScale;
 			const fLineHeight = 2 / fResolution * iScale; // adjust letter-spacing for all combinations of scale and resolution to get it to fit the image width.

+ 16 - 8
examples/js/exporters/GLTFExporter.js

@@ -539,17 +539,25 @@
 
 		}
 		/**
-   * Assign and return a temporal unique id for an object
-   * especially which doesn't have .uuid
+   * Returns ids for buffer attributes.
    * @param  {Object} object
    * @return {Integer}
    */
 
 
-		getUID( object ) {
+		getUID( attribute, isRelativeCopy = false ) {
 
-			if ( ! this.uids.has( object ) ) this.uids.set( object, this.uid ++ );
-			return this.uids.get( object );
+			if ( this.uids.has( attribute ) === false ) {
+
+				const uids = new Map();
+				uids.set( true, this.uid ++ );
+				uids.set( false, this.uid ++ );
+				this.uids.set( attribute, uids );
+
+			}
+
+			const uids = this.uids.get( attribute );
+			return uids.get( isRelativeCopy );
 
 		}
 		/**
@@ -1456,9 +1464,9 @@
 
 						const baseAttribute = geometry.attributes[ attributeName ];
 
-						if ( cache.attributes.has( this.getUID( attribute ) ) ) {
+						if ( cache.attributes.has( this.getUID( attribute, true ) ) ) {
 
-							target[ gltfAttributeName ] = cache.attributes.get( this.getUID( attribute ) );
+							target[ gltfAttributeName ] = cache.attributes.get( this.getUID( attribute, true ) );
 							continue;
 
 						} // Clones attribute not to override
@@ -1477,7 +1485,7 @@
 						}
 
 						target[ gltfAttributeName ] = this.processAccessor( relativeAttribute, geometry );
-						cache.attributes.set( this.getUID( baseAttribute ), target[ gltfAttributeName ] );
+						cache.attributes.set( this.getUID( baseAttribute, true ), target[ gltfAttributeName ] );
 
 					}
 

+ 23 - 30
examples/js/loaders/DDSLoader.js

@@ -21,17 +21,17 @@
 			// All values and structures referenced from:
 			// http://msdn.microsoft.com/en-us/library/bb943991.aspx/
 
-			const DDS_MAGIC = 0x20534444; // let DDSD_CAPS = 0x1;
-			// let DDSD_HEIGHT = 0x2;
-			// let DDSD_WIDTH = 0x4;
-			// let DDSD_PITCH = 0x8;
-			// let DDSD_PIXELFORMAT = 0x1000;
-
-			const DDSD_MIPMAPCOUNT = 0x20000; // let DDSD_LINEARSIZE = 0x80000;
-			// let DDSD_DEPTH = 0x800000;
-			// let DDSCAPS_COMPLEX = 0x8;
-			// let DDSCAPS_MIPMAP = 0x400000;
-			// let DDSCAPS_TEXTURE = 0x1000;
+			const DDS_MAGIC = 0x20534444; // const DDSD_CAPS = 0x1;
+			// const DDSD_HEIGHT = 0x2;
+			// const DDSD_WIDTH = 0x4;
+			// const DDSD_PITCH = 0x8;
+			// const DDSD_PIXELFORMAT = 0x1000;
+
+			const DDSD_MIPMAPCOUNT = 0x20000; // const DDSD_LINEARSIZE = 0x80000;
+			// const DDSD_DEPTH = 0x800000;
+			// const DDSCAPS_COMPLEX = 0x8;
+			// const DDSCAPS_MIPMAP = 0x400000;
+			// const DDSCAPS_TEXTURE = 0x1000;
 
 			const DDSCAPS2_CUBEMAP = 0x200;
 			const DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
@@ -39,13 +39,13 @@
 			const DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
 			const DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
 			const DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
-			const DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000; // let DDSCAPS2_VOLUME = 0x200000;
-			// let DDPF_ALPHAPIXELS = 0x1;
-			// let DDPF_ALPHA = 0x2;
-
-			const DDPF_FOURCC = 0x4; // let DDPF_RGB = 0x40;
-			// let DDPF_YUV = 0x200;
-			// let DDPF_LUMINANCE = 0x20000;
+			const DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000; // const DDSCAPS2_VOLUME = 0x200000;
+			// const DDPF_ALPHAPIXELS = 0x1;
+			// const DDPF_ALPHA = 0x2;
+			// const DDPF_FOURCC = 0x4;
+			// const DDPF_RGB = 0x40;
+			// const DDPF_YUV = 0x200;
+			// const DDPF_LUMINANCE = 0x20000;
 
 			function fourCCToInt32( value ) {
 
@@ -111,17 +111,17 @@
 			const off_flags = 2;
 			const off_height = 3;
 			const off_width = 4;
-			const off_mipmapCount = 7;
-			const off_pfFlags = 20;
+			const off_mipmapCount = 7; // const off_pfFlags = 20;
+
 			const off_pfFourCC = 21;
 			const off_RGBBitCount = 22;
 			const off_RBitMask = 23;
 			const off_GBitMask = 24;
 			const off_BBitMask = 25;
-			const off_ABitMask = 26; // let off_caps = 27;
+			const off_ABitMask = 26; // const off_caps = 27;
 
-			const off_caps2 = 28; // let off_caps3 = 29;
-			// let off_caps4 = 30;
+			const off_caps2 = 28; // const off_caps3 = 29;
+			// const off_caps4 = 30;
 			// Parse header
 
 			const header = new Int32Array( buffer, 0, headerLengthInt );
@@ -133,13 +133,6 @@
 
 			}
 
-			if ( ! header[ off_pfFlags ] & DDPF_FOURCC ) {
-
-				console.error( 'THREE.DDSLoader.parse: Unsupported format, must contain a FourCC code.' );
-				return dds;
-
-			}
-
 			let blockBytes;
 			const fourCC = header[ off_pfFourCC ];
 			let isRGBAUncompressed = false;

+ 3 - 0
examples/js/loaders/FBXLoader.js

@@ -3284,6 +3284,9 @@
 
 					}
 
+					break;
+					// cannot happen but is required by the DeepScan
+
 				default:
 					throw new Error( 'THREE.FBXLoader: Unknown property type ' + type );
 

+ 3 - 1
examples/js/loaders/LWOLoader.js

@@ -277,6 +277,8 @@
 			params = Object.assign( maps, params );
 			params = Object.assign( params, attributes );
 			const materialType = this.getMaterialType( connections.attributes );
+			if ( materialType !== THREE.MeshPhongMaterial ) delete params.refractionRatio; // PBR materials do not support "refractionRatio"
+
 			return new materialType( params );
 
 		}
@@ -525,7 +527,6 @@
 			}
 
 			if ( attributes[ 'Bump Height' ] ) params.bumpScale = attributes[ 'Bump Height' ].value * 0.1;
-			if ( attributes[ 'Refraction Index' ] ) params.refractionRatio = 0.98 / attributes[ 'Refraction Index' ].value;
 			this.parsePhysicalAttributes( params, attributes, maps );
 			this.parseStandardAttributes( params, attributes, maps );
 			this.parsePhongAttributes( params, attributes, maps );
@@ -576,6 +577,7 @@
 
 		parsePhongAttributes( params, attributes, maps ) {
 
+			if ( attributes[ 'Refraction Index' ] ) params.refractionRatio = 0.98 / attributes[ 'Refraction Index' ].value;
 			if ( attributes.Diffuse ) params.color.multiplyScalar( attributes.Diffuse.value );
 
 			if ( attributes.Reflection ) {

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

@@ -172,7 +172,7 @@
 
 						headerObject.isNrrd = true;
 
-					} else if ( l.match( /^#/ ) ) {} else if ( m = l.match( /(.*):(.*)/ ) ) {
+					} else if ( ! l.match( /^#/ ) && ( m = l.match( /(.*):(.*)/ ) ) ) {
 
 						field = m[ 1 ].trim();
 						data = m[ 2 ].trim();

+ 3 - 8
examples/js/loaders/PCDLoader.js

@@ -21,7 +21,7 @@
 
 				try {
 
-					onLoad( scope.parse( data, url ) );
+					onLoad( scope.parse( data ) );
 
 				} catch ( e ) {
 
@@ -43,7 +43,7 @@
 
 		}
 
-		parse( data, url ) {
+		parse( data ) {
 
 			// from https://gitlab.com/taketwo/three-pcd-loader/blob/master/decompress-lzf.js
 			function decompressLZF( inData, outLength ) {
@@ -352,12 +352,7 @@
 			} // build point cloud
 
 
-			const mesh = new THREE.Points( geometry, material );
-			let name = url.split( '' ).reverse().join( '' );
-			name = /([^\/]*)/.exec( name );
-			name = name[ 1 ].split( '' ).reverse().join( '' );
-			mesh.name = name;
-			return mesh;
+			return new THREE.Points( geometry, material );
 
 		}
 

+ 0 - 1
examples/js/loaders/VOXLoader.js

@@ -65,7 +65,6 @@
 
 				const chunkSize = data.getUint32( i, true );
 				i += 4;
-				data.getUint32( i, true );
 				i += 4; // childChunks
 
 				if ( id === 'SIZE' ) {

+ 2 - 2
examples/js/misc/MorphAnimMesh.js

@@ -54,9 +54,9 @@
 
 		}
 
-		copy( source ) {
+		copy( source, recursive ) {
 
-			super.copy( source );
+			super.copy( source, recursive );
 			this.mixer = new THREE.AnimationMixer( this );
 			return this;
 

+ 2 - 2
examples/js/objects/LightningStorm.js

@@ -177,9 +177,9 @@
 
 		}
 
-		copy( source ) {
+		copy( source, recursive ) {
 
-			super.copy( source );
+			super.copy( source, recursive );
 			this.stormParams.size = source.stormParams.size;
 			this.stormParams.minHeight = source.stormParams.minHeight;
 			this.stormParams.maxHeight = source.stormParams.maxHeight;