Przeglądaj źródła

Clean up (#24121)

* Clean up

* Fix
Levi Pesin 3 lat temu
rodzic
commit
dfe7b239fc

+ 7 - 6
docs/scenes/ccdiksolver-browser.html

@@ -50,7 +50,6 @@
 				Float32BufferAttribute,
 				MeshPhongMaterial,
 				PerspectiveCamera,
-				PointLight,
 				Scene,
 				SkinnedMesh,
 				Skeleton,
@@ -215,18 +214,18 @@
 				gui.add( mesh, 'pose' ).name( 'mesh.pose()' );
 
 				mesh.skeleton.bones
-					.filter((bone) => bone.name === "target")
-					.forEach(function (bone) {
+					.filter( ( bone ) => bone.name === "target" )
+					.forEach( function (bone) {
 						const folder = gui.addFolder( bone.name );
 
 						const delta = 20;
 						folder.add( bone.position, 'x', - delta + bone.position.x, delta + bone.position.x );
 						folder.add( bone.position, 'y', - bone.position.y, bone.position.y );
 						folder.add( bone.position, 'z', - delta + bone.position.z, delta + bone.position.z );
-					});
+					} );
 				
 				gui.add( ikSolver, 'update' ).name( 'ikSolver.update()' );
-				gui.add( state, 'ikSolverAutoUpdate' )
+				gui.add( state, 'ikSolverAutoUpdate' );
 
 			}
 
@@ -258,7 +257,7 @@
 					{
 						target: 5,
 						effector: 4,
-						links: [{ index: 3 }, { index: 2 }, { index: 1 }]
+						links: [ { index: 3 }, { index: 2 }, { index: 1 } ]
 					}
 				];
 				ikSolver = new CCDIKSolver( mesh, iks );
@@ -271,7 +270,9 @@
 				requestAnimationFrame( render );
 
 				if ( state.ikSolverAutoUpdate ) {
+
 					ikSolver?.update();
+
 				}
 
 				renderer.render( scene, camera );

+ 2 - 2
editor/js/EditorControls.js

@@ -301,9 +301,9 @@ function EditorControls( object, domElement ) {
 
 			var closest = touches[ 0 ];
 
-			for ( var i in touches ) {
+			for ( var touch2 of touches ) {
 
-				if ( closest.distanceTo( touch ) > touches[ i ].distanceTo( touch ) ) closest = touches[ i ];
+				if ( closest.distanceTo( touch ) > touch2.distanceTo( touch ) ) closest = touch2;
 
 			}
 

+ 1 - 1
examples/jsm/animation/MMDPhysics.js

@@ -211,7 +211,7 @@ class MMDPhysics {
 
 		let parent = mesh.parent;
 
-		if ( parent !== null ) parent = null;
+		if ( parent !== null ) mesh.parent = null;
 
 		const currentPosition = manager.allocThreeVector3();
 		const currentQuaternion = manager.allocThreeQuaternion();

+ 7 - 20
examples/jsm/effects/AsciiEffect.js

@@ -14,14 +14,13 @@ class AsciiEffect {
 
 		// Some ASCII settings
 
-		const bResolution = ! options[ 'resolution' ] ? 0.15 : options[ 'resolution' ]; // Higher for more details
-		const iScale = ! options[ 'scale' ] ? 1 : options[ 'scale' ];
-		const bColor = ! options[ 'color' ] ? false : options[ 'color' ]; // nice but slows down rendering!
-		const bAlpha = ! options[ 'alpha' ] ? false : options[ 'alpha' ]; // Transparency
-		const bBlock = ! options[ 'block' ] ? false : options[ 'block' ]; // blocked characters. like good O dos
-		const bInvert = ! options[ 'invert' ] ? false : options[ 'invert' ]; // black is white, white is black
-
-		const strResolution = 'low';
+		const fResolution = options[ 'resolution' ] || 0.15; // Higher for more details
+		const iScale = options[ 'scale' ] || 1;
+		const bColor = options[ 'color' ] || false; // nice but slows down rendering!
+		const bAlpha = options[ 'alpha' ] || false; // Transparency
+		const bBlock = options[ 'block' ] || false; // blocked characters. like good O dos
+		const bInvert = options[ 'invert' ] || false; // black is white, white is black
+		const strResolution = options[ 'strResolution' ] || 'low';
 
 		let width, height;
 
@@ -122,18 +121,6 @@ class AsciiEffect {
 
 		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
 
 		const fFontSize = ( 2 / fResolution ) * iScale;

+ 1 - 1
examples/jsm/loaders/DDSLoader.js

@@ -146,7 +146,7 @@ class DDSLoader extends CompressedTextureLoader {
 
 		}
 
-		if ( ! header[ off_pfFlags ] & DDPF_FOURCC ) {
+		if ( ! ( header[ off_pfFlags ] & DDPF_FOURCC ) ) {
 
 			console.error( 'THREE.DDSLoader.parse: Unsupported format, must contain a FourCC code.' );
 			return dds;

+ 2 - 0
examples/jsm/loaders/FBXLoader.js

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

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

@@ -173,8 +173,7 @@ class NRRDLoader extends Loader {
 
 					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();

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

@@ -112,7 +112,7 @@ class VOXLoader extends Loader {
 			}
 
 			const chunkSize = data.getUint32( i, true ); i += 4;
-			data.getUint32( i, true ); i += 4; // childChunks
+			i += 4; // childChunks
 
 			if ( id === 'SIZE' ) {
 

+ 1 - 6
examples/webgl_materials_instance_uniform_nodes.html

@@ -50,12 +50,7 @@
 
 				update( frame ) {
 
-					const rendererState = frame.renderer.state;
-					const mesh = frame.object;
-
-					const meshColor = mesh.color;
-
-					this.uniformNode.value.copy( meshColor );
+					this.uniformNode.value.copy( frame.object.color );
 
 				}
 

+ 0 - 2
examples/webgpu_instance_uniform.html

@@ -200,8 +200,6 @@
 
 			function render() {
 
-				const timer = 0.0001 * Date.now();
-
 				for ( let i = 0, l = objects.length; i < l; i ++ ) {
 
 					const object = objects[ i ];

+ 1 - 1
examples/webgpu_materials.html

@@ -33,7 +33,7 @@
 
 			import { TeapotGeometry } from './jsm/geometries/TeapotGeometry.js';
 
-			import { ShaderNode, vec3, dot, sampler } from 'three-nodes/Nodes.js';
+			import { ShaderNode, vec3, dot } from 'three-nodes/Nodes.js';
 
 			import Stats from './jsm/libs/stats.module.js';
 

+ 1 - 21
examples/webxr_vr_teleport.html

@@ -41,8 +41,6 @@
 			let INTERSECTION;
 			const tempMatrix = new THREE.Matrix4();
 
-			const clock = new THREE.Clock();
-
 			init();
 			animate();
 
@@ -84,7 +82,7 @@
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.outputEncoding = THREE.sRGBEncoding;
-				renderer.xr.addEventListener( 'sessionstart', () => { baseReferenceSpace = renderer.xr.getReferenceSpace(); } )
+				renderer.xr.addEventListener( 'sessionstart', () => baseReferenceSpace = renderer.xr.getReferenceSpace() )
 				renderer.xr.enabled = true;
 				document.body.appendChild( renderer.domElement );
 
@@ -203,24 +201,6 @@
 
 			}
 
-			function handleController( controller ) {
-
-				if ( controller.userData.isSelecting ) {
-
-					const object = room.children[ count ++ ];
-
-					object.position.copy( controller.position );
-					object.userData.velocity.x = ( Math.random() - 0.5 ) * 3;
-					object.userData.velocity.y = ( Math.random() - 0.5 ) * 3;
-					object.userData.velocity.z = ( Math.random() - 9 );
-					object.userData.velocity.applyQuaternion( controller.quaternion );
-
-					if ( count === room.children.length ) count = 0;
-
-				}
-
-			}
-
 			//
 
 			function animate() {

+ 15 - 15
manual/resources/prettify.js

@@ -253,7 +253,7 @@ var prettyPrint;
     var needToFoldCase = false;
     var ignoreCase = false;
     for (var i = 0, n = regexs.length; i < n; ++i) {
-      var regex = regexs[i];
+      const regex = regexs[i];
       if (regex.ignoreCase) {
         ignoreCase = true;
       } else if (/[a-z]/i.test(regex.source.replace(
@@ -352,7 +352,7 @@ var prettyPrint;
       var consolidatedRanges = [];
       var lastRange = [];
       for (var i = 0; i < ranges.length; ++i) {
-        var range = ranges[i];
+        const range = ranges[i];
         if (range[0] <= lastRange[1] + 1) {
           lastRange[1] = Math.max(lastRange[1], range[1]);
         } else {
@@ -361,7 +361,7 @@ var prettyPrint;
       }
   
       for (var i = 0; i < consolidatedRanges.length; ++i) {
-        var range = consolidatedRanges[i];
+        const range = consolidatedRanges[i];
         out.push(encodeEscape(range[0]));
         if (range[1] > range[0]) {
           if (range[1] + 1 > range[0]) { out.push('-'); }
@@ -398,13 +398,13 @@ var prettyPrint;
   
       // Walk over and identify back references to build the capturedGroups
       // mapping.
-      for (var i = 0, groupIndex = 0; i < n; ++i) {
+      for (let i = 0, groupIndex = 0; i < n; ++i) {
         var p = parts[i];
         if (p === '(') {
           // groups are 1-indexed, so max group index is count of '('
           ++groupIndex;
         } else if ('\\' === p.charAt(0)) {
-          var decimalValue = +p.substring(1);
+          const decimalValue = +p.substring(1);
           if (decimalValue) {
             if (decimalValue <= groupIndex) {
               capturedGroups[decimalValue] = -1;
@@ -425,7 +425,7 @@ var prettyPrint;
           capturedGroups[i] = ++capturedGroupIndex;
         }
       }
-      for (var i = 0, groupIndex = 0; i < n; ++i) {
+      for (let i = 0, groupIndex = 0; i < n; ++i) {
         var p = parts[i];
         if (p === '(') {
           ++groupIndex;
@@ -433,7 +433,7 @@ var prettyPrint;
             parts[i] = '(?:';
           }
         } else if ('\\' === p.charAt(0)) {
-          var decimalValue = +p.substring(1);
+          const decimalValue = +p.substring(1);
           if (decimalValue && decimalValue <= groupIndex) {
             parts[i] = '\\' + capturedGroups[decimalValue];
           }
@@ -471,7 +471,7 @@ var prettyPrint;
   
     var rewritten = [];
     for (var i = 0, n = regexs.length; i < n; ++i) {
-      var regex = regexs[i];
+      const regex = regexs[i];
       if (regex.global || regex.multiline) { throw new Error('' + regex); }
       rewritten.push(
           '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
@@ -1104,7 +1104,7 @@ var prettyPrint;
     }
   
     var ol = document.createElement(opt_numberLines ? 'ol' : 'ul');
-    var classNames = [];
+    const classNames = [];
     if (opt_numberLines) {
       classNames.push('linenums');
     }
@@ -1112,13 +1112,13 @@ var prettyPrint;
       classNames.push('modifiedlines');
     }
     ol.className = classNames.join(" ");
-    var offset = Math.max(0, ((opt_startLineNum - 1 /* zero index */)) | 0) || 0;
+    var offset = Math.max(0, (opt_startLineNum - 1 /* zero index */) | 0) || 0;
     for (var i = 0, n = listItems.length; i < n; ++i) {
       li = listItems[i];
       // Stick a class on the LIs so that stylesheets can
       // color odd/even rows, or any other row pattern that
       // is co-prime with 10.
-      var classNames = [];
+      const classNames = [];
       if (opt_numberLines) {
         classNames.push('L' + ((i + offset) % 10));
       }
@@ -1217,7 +1217,7 @@ var prettyPrint;
       var startPos = decorations[i];
       // Conflate all adjacent decorations that use the same style.
       var startDec = decorations[i + 1];
-      var end = i + 2;
+      let end = i + 2;
       while (end + 2 <= nDecorations && decorations[end + 1] === startDec) {
         end += 2;
       }
@@ -1241,7 +1241,7 @@ var prettyPrint;
   
         var decEnd = decorations[decorationIndex + 2] || sourceLength;
   
-        var end = Math.min(spanEnd, decEnd);
+        const end = Math.min(spanEnd, decEnd);
   
         var textNode = spans[spanIndex + 1];
         var styledText;
@@ -1686,9 +1686,9 @@ var prettyPrint;
            IN_GLOBAL_SCOPE
              ? (win['prettyPrintOne'] = $prettyPrintOne)
              : (prettyPrintOne = $prettyPrintOne),
-        'prettyPrint': prettyPrint =
+        'prettyPrint':
            IN_GLOBAL_SCOPE
-             ? (win['prettyPrint'] = $prettyPrint)
+             ? (prettyPrint = win['prettyPrint'] = $prettyPrint)
              : (prettyPrint = $prettyPrint)
       };
 

+ 1 - 1
manual/resources/threejs-post-processing-3dlut.js

@@ -26,7 +26,7 @@
           '[id$=-Input]',
           '[id$=-Output]',
           '[id$=-Result]',
-        ].map((selector) => {
+        ].forEach((selector) => {
           [...svg.querySelectorAll('[id^=Effect]')].forEach((elem) => {
             // because affinity designer doesn't export blend modes (T_T)
             // and because I'd prefer not to have to manually fix things as I edit.

+ 1 - 1
manual/resources/tools/geo-picking/shapefile.js

@@ -281,7 +281,7 @@ function ringContains(ring, point) {
     if (segmentContains(pi, pj, point)) {
       return 0;
     }
-    if (((yi > y) !== (yj > y)) && ((x < (xj - xi) * (y - yi) / (yj - yi) + xi))) {
+    if (((yi > y) !== (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi)) {
       contains = -contains;
     }
   }

+ 0 - 10
test/benchmark/core/Float32Array.js

@@ -9,16 +9,6 @@
 
 	}
 
-	var inputVectors = [];
-	var outputVectors = [];
-
-	for ( var j = 0, jl = input.length / 3; j < jl; j ++ ) {
-
-		inputVectors.push( new THREE.Vector3( j * 3, j * 3 + 1, j * 3 + 2 ) );
-		outputVectors.push( new THREE.Vector3() );
-
-	}
-
 	var s = Bench.newSuite( 'Float 32 Arrays' );
 
 	s.add( 'Float32Array-Float32Array', function () {