浏览代码

More clean up. (#23397)

Michael Herzog 3 年之前
父节点
当前提交
67ff114e55

+ 7 - 1
docs/scenes/material-browser.html

@@ -722,7 +722,13 @@
 
 			//
 
-			document.getElementById( 'newWindow' ).href += window.location.hash;
+			const selectedMaterial = window.location.hash.substring( 1 );
+
+			if ( THREE[ selectedMaterial ] !== undefined ) {
+
+				document.getElementById( 'newWindow' ).href += '#' + selectedMaterial;
+
+			}
 
 			const gui = new GUI();
 

+ 17 - 17
examples/jsm/interactive/HTMLMesh.js

@@ -121,12 +121,12 @@ const canvases = new WeakMap();
 
 function html2canvas( element ) {
 
-	var range = document.createRange();
+	const range = document.createRange();
 
 	function Clipper( context ) {
 
-		var clips = [];
-		var isClipping = false;
+		const clips = [];
+		let isClipping = false;
 
 		function doClip() {
 
@@ -139,12 +139,12 @@ function html2canvas( element ) {
 
 			if ( clips.length === 0 ) return;
 
-			var minX = - Infinity, minY = - Infinity;
-			var maxX = Infinity, maxY = Infinity;
+			let minX = - Infinity, minY = - Infinity;
+			let maxX = Infinity, maxY = Infinity;
 
-			for ( var i = 0; i < clips.length; i ++ ) {
+			for ( let i = 0; i < clips.length; i ++ ) {
 
-				var clip = clips[ i ];
+				const clip = clips[ i ];
 
 				minX = Math.max( minX, clip.x );
 				minY = Math.max( minY, clip.y );
@@ -203,9 +203,9 @@ function html2canvas( element ) {
 
 	function drawBorder( style, which, x, y, width, height ) {
 
-		var borderWidth = style[ which + 'Width' ];
-		var borderStyle = style[ which + 'Style' ];
-		var borderColor = style[ which + 'Color' ];
+		const borderWidth = style[ which + 'Width' ];
+		const borderStyle = style[ which + 'Style' ];
+		const borderColor = style[ which + 'Color' ];
 
 		if ( borderWidth !== '0px' && borderStyle !== 'none' && borderColor !== 'transparent' && borderColor !== 'rgba(0, 0, 0, 0)' ) {
 
@@ -221,7 +221,7 @@ function html2canvas( element ) {
 
 	function drawElement( element, style ) {
 
-		var x = 0, y = 0, width = 0, height = 0;
+		let x = 0, y = 0, width = 0, height = 0;
 
 		if ( element.nodeType === 3 ) {
 
@@ -229,7 +229,7 @@ function html2canvas( element ) {
 
 			range.selectNode( element );
 
-			var rect = range.getBoundingClientRect();
+			const rect = range.getBoundingClientRect();
 
 			x = rect.left - offset.left - 0.5;
 			y = rect.top - offset.top - 0.5;
@@ -253,7 +253,7 @@ function html2canvas( element ) {
 
 			if ( element.style.display === 'none' ) return;
 
-			var rect = element.getBoundingClientRect();
+			const rect = element.getBoundingClientRect();
 
 			x = rect.left - offset.left - 0.5;
 			y = rect.top - offset.top - 0.5;
@@ -262,7 +262,7 @@ function html2canvas( element ) {
 
 			style = window.getComputedStyle( element );
 
-			var backgroundColor = style.backgroundColor;
+			const backgroundColor = style.backgroundColor;
 
 			if ( backgroundColor !== 'transparent' && backgroundColor !== 'rgba(0, 0, 0, 0)' ) {
 
@@ -294,11 +294,11 @@ function html2canvas( element ) {
 		context.strokeRect( x - 0.5, y - 0.5, width + 1, height + 1 );
 		*/
 
-		var isClipping = style.overflow === 'auto' || style.overflow === 'hidden';
+		const isClipping = style.overflow === 'auto' || style.overflow === 'hidden';
 
 		if ( isClipping ) clipper.add( { x: x, y: y, width: width, height: height } );
 
-		for ( var i = 0; i < element.childNodes.length; i ++ ) {
+		for ( let i = 0; i < element.childNodes.length; i ++ ) {
 
 			drawElement( element.childNodes[ i ], style );
 
@@ -365,7 +365,7 @@ function htmlevent( element, event, x, y ) {
 
 			}
 
-			for ( var i = 0; i < element.childNodes.length; i ++ ) {
+			for ( let i = 0; i < element.childNodes.length; i ++ ) {
 
 				traverse( element.childNodes[ i ] );
 

+ 0 - 6
examples/webgl_loader_obj.html

@@ -81,12 +81,6 @@
 
 				const manager = new THREE.LoadingManager( loadModel );
 
-				manager.onProgress = function ( item, loaded, total ) {
-
-					console.log( item, loaded, total );
-
-				};
-
 				// texture
 
 				const textureLoader = new THREE.TextureLoader( manager );

+ 1 - 8
examples/webgl_materials_physical_reflectivity.html

@@ -92,14 +92,7 @@
 					premultipliedAlpha: true
 				} );
 
-				const manager = new THREE.LoadingManager();
-				manager.onProgress = function ( item, loaded, total ) {
-
-					console.log( item, loaded, total );
-
-				};
-
-				const loader = new OBJLoader( manager );
+				const loader = new OBJLoader();
 				loader.load( 'models/obj/emerald.obj', function ( object ) {
 
 					object.traverse( function ( child ) {

+ 1 - 9
examples/webgl_postprocessing_outline.html

@@ -167,15 +167,7 @@
 
 				// model
 
-				const manager = new THREE.LoadingManager();
-
-				manager.onProgress = function ( item, loaded, total ) {
-
-					console.log( item, loaded, total );
-
-				};
-
-				const loader = new OBJLoader( manager );
+				const loader = new OBJLoader();
 				loader.load( 'models/obj/tree.obj', function ( object ) {
 
 					let scale = 1.0;

+ 0 - 31
manual/resources/tools/geo-picking/make-geo-picking-texture.js

@@ -238,35 +238,4 @@ function wait(ms = 0) {
   });
 }
 
-function r(min, max) {
-  if (min === undefined) {
-    min = 0;
-    max = 1;
-  } else if (max === undefined){
-    max = min;
-    min = 0;
-  }
-  return min + Math.random() * (max - min);
-}
-
-function rgb(r, g, b) {
-  return `rgb(${r * 255 | 0},${g * 255 | 0},${b * 255 | 0})`;
-}
-
-function hsl(h, s, l) {
-  return `hsl(${h * 360 | 0},${s * 100 | 0}%,${l * 100 | 0}%)`;
-}
-
-function base64ToUint8Array(base64) {
-  const raw = window.atob(base64);
-  const rawLength = raw.length;
-  const array = new Uint8Array(new ArrayBuffer(rawLength));
-
-  for (let i = 0; i < rawLength; ++i) {
-    array[i] = raw.charCodeAt(i);
-  }
-
-  return array;
-}
-
 main();

+ 1 - 2
manual/resources/tools/geo-picking/ogc-parser.js

@@ -99,7 +99,7 @@ function parse(buf) {
 
   const getDouble = () => { const v = dataView.getFloat64(cursor, littleEndian); cursor += 8 ; return v; };
   // const getFloat =  () => { const v = dataView.getFloat32(cursor, littleEndian); cursor += 4 ; return v; };
-  const getInt8 =   () => { const v = dataView.getInt8(cursor, littleEndian);    cursor += 1 ; return v; };
+  const getInt8 =   () => { const v = dataView.getInt8(cursor);    cursor += 1 ; return v; };
   // const getUint8 =  () => { const v = dataView.getUint8(cursor, littleEndian);   cursor += 1 ; return v; };
   // const getInt16 =  () => { const v = dataView.getInt16(cursor, littleEndian);   cursor += 2 ; return v; };
   // const getUint16 = () => { const v = dataView.getUint16(cursor, littleEndian);  cursor += 2 ; return v; };
@@ -230,4 +230,3 @@ function parse(buf) {
 }
 
 window.ogcParser = {parse};
-

+ 2 - 2
src/materials/Material.js

@@ -322,13 +322,13 @@ class Material extends EventDispatcher {
 		data.stencilZPass = this.stencilZPass;
 
 		// rotation (SpriteMaterial)
-		if ( this.rotation && this.rotation !== 0 ) data.rotation = this.rotation;
+		if ( this.rotation !== undefined && this.rotation !== 0 ) data.rotation = this.rotation;
 
 		if ( this.polygonOffset === true ) data.polygonOffset = true;
 		if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;
 		if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;
 
-		if ( this.linewidth && this.linewidth !== 1 ) data.linewidth = this.linewidth;
+		if ( this.linewidth !== undefined && this.linewidth !== 1 ) data.linewidth = this.linewidth;
 		if ( this.dashSize !== undefined ) data.dashSize = this.dashSize;
 		if ( this.gapSize !== undefined ) data.gapSize = this.gapSize;
 		if ( this.scale !== undefined ) data.scale = this.scale;

+ 3 - 3
src/renderers/webgl/WebGLShadowMap.js

@@ -233,7 +233,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
 
 	}
 
-	function getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) {
+	function getDepthMaterial( object, material, light, shadowCameraNear, shadowCameraFar, type ) {
 
 		let result = null;
 
@@ -345,7 +345,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
 
 						if ( groupMaterial && groupMaterial.visible ) {
 
-							const depthMaterial = getDepthMaterial( object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type );
+							const depthMaterial = getDepthMaterial( object, groupMaterial, light, shadowCamera.near, shadowCamera.far, type );
 
 							_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
 
@@ -355,7 +355,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
 
 				} else if ( material.visible ) {
 
-					const depthMaterial = getDepthMaterial( object, geometry, material, light, shadowCamera.near, shadowCamera.far, type );
+					const depthMaterial = getDepthMaterial( object, material, light, shadowCamera.near, shadowCamera.far, type );
 
 					_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );