瀏覽代碼

Updated examples builds.

Mr.doob 3 年之前
父節點
當前提交
494d74748d

+ 2 - 2
examples/js/controls/experimental/CameraControls.js

@@ -138,7 +138,7 @@
 					if ( sphericalDelta.theta ) {
 
 						vec.set( 0, 1, 0 ).applyQuaternion( scope.object.quaternion );
-						var factor = scope.enableDamping ? scope.dampingFactor : 1;
+						const factor = scope.enableDamping ? scope.dampingFactor : 1;
 						q.setFromAxisAngle( vec, sphericalDelta.theta * factor );
 						scope.object.quaternion.premultiply( q );
 						offset.applyQuaternion( q );
@@ -149,7 +149,7 @@
 					if ( sphericalDelta.phi ) {
 
 						vec.set( 1, 0, 0 ).applyQuaternion( scope.object.quaternion );
-						var factor = scope.enableDamping ? scope.dampingFactor : 1;
+						const factor = scope.enableDamping ? scope.dampingFactor : 1;
 						q.setFromAxisAngle( vec, sphericalDelta.phi * factor );
 						scope.object.quaternion.premultiply( q );
 						offset.applyQuaternion( q );

+ 2 - 2
examples/js/effects/AsciiEffect.js

@@ -45,7 +45,7 @@
 			this.render = function ( scene, camera ) {
 
 				renderer.render( scene, camera );
-				asciifyImage( renderer, oAscii );
+				asciifyImage( oAscii );
 
 			};
 
@@ -205,7 +205,7 @@
 			// convert img element to ascii
 
 
-			function asciifyImage( canvasRenderer, oAscii ) {
+			function asciifyImage( oAscii ) {
 
 				oCtx.clearRect( 0, 0, iWidth, iHeight );
 				oCtx.drawImage( oCanvasImg, 0, 0, iWidth, iHeight );

+ 7 - 6
examples/js/exporters/OBJExporter.js

@@ -230,17 +230,18 @@
 
 					}
 
-				}
+					output += 'p ';
+
+					for ( let j = 1, l = vertices.count; j <= l; j ++ ) {
 
-				output += 'p ';
+						output += indexVertex + j + ' ';
 
-				for ( let j = 1, l = vertices.count; j <= l; j ++ ) {
+					}
 
-					output += indexVertex + j + ' ';
+					output += '\n';
 
-				}
+				} // update index
 
-				output += '\n'; // update index
 
 				indexVertex += nbVertex;
 

+ 1 - 1
examples/js/exporters/PLYExporter.js

@@ -368,7 +368,7 @@
 
 								line += ' ' + uvs.getX( i ) + ' ' + uvs.getY( i );
 
-							} else if ( includeUVs !== false ) {
+							} else {
 
 								line += ' 0 0';
 

+ 4 - 9
examples/js/loaders/3MFLoader.js

@@ -73,7 +73,6 @@
 				let relsName;
 				let modelRelsName;
 				const modelPartNames = [];
-				const printTicketPartNames = [];
 				const texturesPartNames = [];
 				let modelRels;
 				const modelParts = {};
@@ -109,10 +108,6 @@
 
 						modelPartNames.push( file );
 
-					} else if ( file.match( /^3D\/Metadata\/.*\.xml$/ ) ) {
-
-						printTicketPartNames.push( file );
-
 					} else if ( file.match( /^3D\/Textures?\/.*/ ) ) {
 
 						texturesPartNames.push( file );
@@ -902,7 +897,7 @@
 
 			}
 
-			function buildVertexColorMesh( colorgroup, triangleProperties, meshData, objects, objectData ) {
+			function buildVertexColorMesh( colorgroup, triangleProperties, meshData, objectData ) {
 
 				// geometry
 				const geometry = new THREE.BufferGeometry();
@@ -1001,7 +996,7 @@
 
 						case 'vertexColors':
 							const colorgroup = modelData.resources.colorgroup[ resourceId ];
-							meshes.push( buildVertexColorMesh( colorgroup, triangleProperties, meshData, objects, objectData ) );
+							meshes.push( buildVertexColorMesh( colorgroup, triangleProperties, meshData, objectData ) );
 							break;
 
 						case 'default':
@@ -1045,7 +1040,7 @@
 
 			}
 
-			function analyzeObject( modelData, meshData, objectData ) {
+			function analyzeObject( meshData, objectData ) {
 
 				const resourceMap = {};
 				const triangleProperties = meshData[ 'triangleProperties' ];
@@ -1068,7 +1063,7 @@
 			function buildGroup( meshData, objects, modelData, textureData, objectData ) {
 
 				const group = new THREE.Group();
-				const resourceMap = analyzeObject( modelData, meshData, objectData );
+				const resourceMap = analyzeObject( meshData, objectData );
 				const meshes = buildMeshes( resourceMap, meshData, objects, modelData, textureData, objectData );
 
 				for ( let i = 0, l = meshes.length; i < l; i ++ ) {

+ 8 - 8
examples/js/loaders/EXRLoader.js

@@ -191,7 +191,7 @@
 
 			}
 
-			function hufUnpackEncTable( uInt8Array, inDataView, inOffset, ni, im, iM, hcode ) {
+			function hufUnpackEncTable( uInt8Array, inOffset, ni, im, iM, hcode ) {
 
 				const p = inOffset;
 				let c = 0;
@@ -354,7 +354,7 @@
 				lc: 0
 			};
 
-			function getCode( po, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outBufferOffset, outBufferEndOffset ) {
+			function getCode( po, rlc, c, lc, uInt8Array, inOffset, outBuffer, outBufferOffset, outBufferEndOffset ) {
 
 				if ( po == rlc ) {
 
@@ -548,7 +548,7 @@
 
 			}
 
-			function hufDecode( encodingTable, decodingTable, uInt8Array, inDataView, inOffset, ni, rlc, no, outBuffer, outOffset ) {
+			function hufDecode( encodingTable, decodingTable, uInt8Array, inOffset, ni, rlc, no, outBuffer, outOffset ) {
 
 				let c = 0;
 				let lc = 0;
@@ -569,7 +569,7 @@
 						if ( pl.len ) {
 
 							lc -= pl.len;
-							getCode( pl.lit, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset );
+							getCode( pl.lit, rlc, c, lc, uInt8Array, inOffset, outBuffer, outOffset, outBufferEndOffset );
 							c = getCodeReturn.c;
 							lc = getCodeReturn.lc;
 
@@ -600,7 +600,7 @@
 									if ( hufCode( encodingTable[ pl.p[ j ] ] ) == ( c >> lc - l & ( 1 << l ) - 1 ) ) {
 
 										lc -= l;
-										getCode( pl.p[ j ], rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset );
+										getCode( pl.p[ j ], rlc, c, lc, uInt8Array, inOffset, outBuffer, outOffset, outBufferEndOffset );
 										c = getCodeReturn.c;
 										lc = getCodeReturn.lc;
 										break;
@@ -634,7 +634,7 @@
 					if ( pl.len ) {
 
 						lc -= pl.len;
-						getCode( pl.lit, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset );
+						getCode( pl.lit, rlc, c, lc, uInt8Array, inOffset, outBuffer, outOffset, outBufferEndOffset );
 						c = getCodeReturn.c;
 						lc = getCodeReturn.lc;
 
@@ -672,7 +672,7 @@
 				const hdec = new Array( HUF_DECSIZE );
 				hufClearDecTable( hdec );
 				const ni = nCompressed - ( inOffset.value - initialInOffset );
-				hufUnpackEncTable( uInt8Array, inDataView, inOffset, ni, im, iM, freq );
+				hufUnpackEncTable( uInt8Array, inOffset, ni, im, iM, freq );
 
 				if ( nBits > 8 * ( nCompressed - ( inOffset.value - initialInOffset ) ) ) {
 
@@ -681,7 +681,7 @@
 				}
 
 				hufBuildDecTable( freq, im, iM, hdec );
-				hufDecode( freq, hdec, uInt8Array, inDataView, inOffset, nBits, iM, nRaw, outBuffer, outOffset );
+				hufDecode( freq, hdec, uInt8Array, inOffset, nBits, iM, nRaw, outBuffer, outOffset );
 
 			}
 

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

@@ -54,7 +54,6 @@
 		bin.readUshort( data, offset );
 		offset += 2;
 		var ifdo = bin.readUint( data, offset );
-		offset += 4;
 		var ifds = [];
 
 		while ( true ) {
@@ -430,7 +429,7 @@
 			if ( prm.debug ) console.log( '   '.repeat( depth ), tag, type, UTIF.tags[ tag ], arr );
 			ifd[ 't' + tag ] = arr;
 
-			if ( tag == 330 && ifd[ 't272' ] && ifd[ 't272' ][ 0 ] == 'DSLR-A100' ) {} else if ( tag == 330 || tag == 34665 || tag == 34853 || tag == 50740 && bin.readUshort( data, bin.readUint( arr, 0 ) ) < 300 || tag == 61440 ) {
+			if ( tag == 330 || tag == 34665 || tag == 34853 || tag == 50740 && bin.readUshort( data, bin.readUint( arr, 0 ) ) < 300 || tag == 61440 ) {
 
 				var oarr = tag == 50740 ? [ bin.readUint( arr, 0 ) ] : arr;
 				var subfd = [];

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

@@ -126,7 +126,7 @@
 				PCDheader.points = /POINTS (.*)/i.exec( PCDheader.str ); // evaluate
 
 				if ( PCDheader.version !== null ) PCDheader.version = parseFloat( PCDheader.version[ 1 ] );
-				if ( PCDheader.fields !== null ) PCDheader.fields = PCDheader.fields[ 1 ].split( ' ' );
+				PCDheader.fields = PCDheader.fields !== null ? PCDheader.fields[ 1 ].split( ' ' ) : [];
 				if ( PCDheader.type !== null ) PCDheader.type = PCDheader.type[ 1 ].split( ' ' );
 				if ( PCDheader.width !== null ) PCDheader.width = parseInt( PCDheader.width[ 1 ] );
 				if ( PCDheader.height !== null ) PCDheader.height = parseInt( PCDheader.height[ 1 ] );

+ 12 - 15
examples/js/loaders/RGBMLoader.js

@@ -134,8 +134,7 @@
 			if ( i != 0 ) for ( var j = 0; j < len; j ++ ) prev[ j ] = img[ j ];
 			if ( frm.blend == 0 ) UPNG._copyTile( fdata, fw, fh, img, w, h, fx, fy, 0 ); else if ( frm.blend == 1 ) UPNG._copyTile( fdata, fw, fh, img, w, h, fx, fy, 1 );
 			frms.push( img.buffer.slice( 0 ) );
-
-			if ( frm.dispose == 0 ) {} else if ( frm.dispose == 1 ) UPNG._copyTile( empty, fw, fh, img, w, h, fx, fy, 0 ); else if ( frm.dispose == 2 ) for ( var j = 0; j < len; j ++ ) img[ j ] = prev[ j ];
+			if ( frm.dispose == 1 ) UPNG._copyTile( empty, fw, fh, img, w, h, fx, fy, 0 ); else if ( frm.dispose == 2 ) for ( var j = 0; j < len; j ++ ) img[ j ] = prev[ j ];
 
 		}
 
@@ -391,6 +390,7 @@
 		var fd,
 			foff = 0; // frames
 
+		var text, keyw, bfr;
 		var mgck = [ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a ];
 
 		for ( var i = 0; i < 8; i ++ ) if ( data[ i ] != mgck[ i ] ) throw new Error( 'The input is not a PNG file!' );
@@ -471,13 +471,11 @@
 
 				if ( out.tabs[ type ] == null ) out.tabs[ type ] = {};
 				var nz = bin.nextZero( data, offset );
-				var keyw = bin.readASCII( data, offset, nz - offset );
-				var text,
-					tl = offset + len - nz - 1;
+				keyw = bin.readASCII( data, offset, nz - offset );
+				var tl = offset + len - nz - 1;
 				if ( type == 'tEXt' ) text = bin.readASCII( data, nz + 1, tl ); else {
 
-					var bfr = UPNG.decode._inflate( data.slice( nz + 2, nz + 2 + tl ) );
-
+					bfr = UPNG.decode._inflate( data.slice( nz + 2, nz + 2 + tl ) );
 					text = bin.readUTF8( bfr, 0, bfr.length );
 
 				}
@@ -490,7 +488,7 @@
 				var nz = 0,
 					off = offset;
 				nz = bin.nextZero( data, off );
-				var keyw = bin.readASCII( data, off, nz - off );
+				keyw = bin.readASCII( data, off, nz - off );
 				off = nz + 1;
 				var cflag = data[ off ];
 				off += 2;
@@ -500,12 +498,10 @@
 				nz = bin.nextZero( data, off );
 				bin.readUTF8( data, off, nz - off );
 				off = nz + 1;
-				var text,
-					tl = len - ( off - offset );
+				var tl = len - ( off - offset );
 				if ( cflag == 0 ) text = bin.readUTF8( data, off, tl ); else {
 
-					var bfr = UPNG.decode._inflate( data.slice( off, off + tl ) );
-
+					bfr = UPNG.decode._inflate( data.slice( off, off + tl ) );
 					text = bin.readUTF8( bfr, 0, bfr.length );
 
 				}
@@ -1087,6 +1083,7 @@
 
 			var y = 0,
 				row = starting_row[ pass ];
+			var val;
 
 			while ( row < h ) {
 
@@ -1097,7 +1094,7 @@
 
 					if ( bpp == 1 ) {
 
-						var val = data[ cdi >> 3 ];
+						val = data[ cdi >> 3 ];
 						val = val >> 7 - ( cdi & 7 ) & 1;
 						img[ row * bpl + ( col >> 3 ) ] |= val << 7 - ( ( col & 7 ) << 0 );
 
@@ -1105,7 +1102,7 @@
 
 					if ( bpp == 2 ) {
 
-						var val = data[ cdi >> 3 ];
+						val = data[ cdi >> 3 ];
 						val = val >> 6 - ( cdi & 7 ) & 3;
 						img[ row * bpl + ( col >> 2 ) ] |= val << 6 - ( ( col & 3 ) << 1 );
 
@@ -1113,7 +1110,7 @@
 
 					if ( bpp == 4 ) {
 
-						var val = data[ cdi >> 3 ];
+						val = data[ cdi >> 3 ];
 						val = val >> 4 - ( cdi & 7 ) & 15;
 						img[ row * bpl + ( col >> 1 ) ] |= val << 4 - ( ( col & 1 ) << 2 );
 

+ 2 - 5
examples/js/loaders/VTKLoader.js

@@ -309,9 +309,7 @@
 
 				let points = [];
 				let normals = [];
-				let indices = []; // Going to make a big array of strings
-
-				const vtk = [];
+				let indices = [];
 				let index = 0;
 
 				function findString( buffer, start ) {
@@ -352,8 +350,7 @@
 
 					} else if ( line.indexOf( 'POINTS' ) === 0 ) {
 
-						vtk.push( line ); // Add the points
-
+						// Add the points
 						const numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 ); // Each point is 3 4-byte floats
 
 						const count = numberOfPoints * 4 * 3;

+ 15 - 2
examples/js/objects/Reflector.js

@@ -11,7 +11,8 @@
 			const textureWidth = options.textureWidth || 512;
 			const textureHeight = options.textureHeight || 512;
 			const clipBias = options.clipBias || 0;
-			const shader = options.shader || Reflector.ReflectorShader; //
+			const shader = options.shader || Reflector.ReflectorShader;
+			const multisample = options.multisample || 4; //
 
 			const reflectorPlane = new THREE.Plane();
 			const normal = new THREE.Vector3();
@@ -25,7 +26,19 @@
 			const q = new THREE.Vector4();
 			const textureMatrix = new THREE.Matrix4();
 			const virtualCamera = new THREE.PerspectiveCamera();
-			const renderTarget = new THREE.WebGLRenderTarget( textureWidth, textureHeight );
+			let renderTarget;
+
+			if ( multisample > 0 ) {
+
+				renderTarget = new THREE.WebGLMultisampleRenderTarget( textureWidth, textureHeight );
+				renderTarget.samples = multisample;
+
+			} else {
+
+				renderTarget = new THREE.WebGLRenderTarget( textureWidth, textureHeight );
+
+			}
+
 			const material = new THREE.ShaderMaterial( {
 				uniforms: THREE.UniformsUtils.clone( shader.uniforms ),
 				fragmentShader: shader.fragmentShader,

+ 15 - 2
examples/js/objects/Refractor.js

@@ -11,7 +11,8 @@
 			const textureWidth = options.textureWidth || 512;
 			const textureHeight = options.textureHeight || 512;
 			const clipBias = options.clipBias || 0;
-			const shader = options.shader || Refractor.RefractorShader; //
+			const shader = options.shader || Refractor.RefractorShader;
+			const multisample = options.multisample || 4; //
 
 			const virtualCamera = new THREE.PerspectiveCamera();
 			virtualCamera.matrixAutoUpdate = false;
@@ -20,7 +21,19 @@
 			const refractorPlane = new THREE.Plane();
 			const textureMatrix = new THREE.Matrix4(); // render target
 
-			const renderTarget = new THREE.WebGLRenderTarget( textureWidth, textureHeight ); // material
+			let renderTarget;
+
+			if ( multisample > 0 ) {
+
+				renderTarget = new THREE.WebGLMultisampleRenderTarget( textureWidth, textureHeight );
+				renderTarget.samples = multisample;
+
+			} else {
+
+				renderTarget = new THREE.WebGLRenderTarget( textureWidth, textureHeight );
+
+			} // material
+
 
 			this.material = new THREE.ShaderMaterial( {
 				uniforms: THREE.UniformsUtils.clone( shader.uniforms ),

+ 2 - 2
examples/js/renderers/SVGRenderer.js

@@ -217,7 +217,7 @@
 
 						if ( _clipBox.intersectsBox( _elemBox ) === true ) {
 
-							renderLine( _v1, _v2, element, material );
+							renderLine( _v1, _v2, material );
 
 						}
 
@@ -379,7 +379,7 @@
 
 			}
 
-			function renderLine( v1, v2, element, material ) {
+			function renderLine( v1, v2, material ) {
 
 				const path = 'M' + convert( v1.positionScreen.x ) + ',' + convert( v1.positionScreen.y ) + 'L' + convert( v2.positionScreen.x ) + ',' + convert( v2.positionScreen.y );