ソースを参照

some eslint fixes in the examples folder (#22942)

* some eslint fixes in the examples folder

* remove eslint errors in docs folder (#22941)

* Cleanup eslint globals + update deprecated config (#22940)
gero3 3 年 前
コミット
34645cb976

+ 2 - 2
examples/jsm/loaders/KTX2Loader.js

@@ -169,7 +169,7 @@ class KTX2Loader extends Loader {
 
 			}
 
-			_activeLoaders++;
+			_activeLoaders ++;
 
 		}
 
@@ -265,7 +265,7 @@ class KTX2Loader extends Loader {
 		URL.revokeObjectURL( this.workerSourceURL );
 		this.workerPool.dispose();
 
-		_activeLoaders--;
+		_activeLoaders --;
 
 		return this;
 

+ 30 - 9
examples/jsm/loaders/TDSLoader.js

@@ -140,7 +140,7 @@ class TDSLoader extends Loader {
 
 				} else {
 
-					this.debugMessage( 'Unknown main chunk: ' + next.hexId);
+					this.debugMessage( 'Unknown main chunk: ' + next.hexId );
 
 				}
 
@@ -218,7 +218,9 @@ class TDSLoader extends Loader {
 				const mesh = this.readMesh( next );
 				mesh.name = name;
 				this.meshes.push( mesh );
+
 			} else {
+
 				this.debugMessage( 'Unknown named object chunk: ' + next.hexId );
 
 			}
@@ -239,7 +241,7 @@ class TDSLoader extends Loader {
 	readMaterialEntry( chunk, path ) {
 
 		let next = chunk.readChunk();
-		let material = new MeshPhongMaterial();
+		const material = new MeshPhongMaterial();
 
 		while ( next ) {
 
@@ -485,7 +487,7 @@ class TDSLoader extends Loader {
 		let materialIndex = 0;
 		let start = 0;
 
-		while ( !chunk.endOfChunk ) {
+		while ( ! chunk.endOfChunk ) {
 
 			const subchunk = chunk.readChunk( );
 
@@ -696,11 +698,13 @@ class TDSLoader extends Loader {
 		}
 
 	}
+
 }
 
 
 /** Read data/sub-chunks from chunk */
 class Chunk {
+
 	/**
 	 * Create a new chunk
 	 *
@@ -709,7 +713,8 @@ class Chunk {
 	 * @param {Number} position in data.
 	 * @param {Function} debugMessage logging callback.
 	 */
-	constructor(data, position, debugMessage) {
+	constructor( data, position, debugMessage ) {
+
 		this.data = data;
 		// the offset to the begin of this chunk
 		this.offset = position;
@@ -717,17 +722,22 @@ class Chunk {
 		this.position = position;
 		this.debugMessage = debugMessage;
 
-		if (this.debugMessage instanceof Function) {
-			this.debugMessage = function() {};
+		if ( this.debugMessage instanceof Function ) {
+
+			this.debugMessage = function () {};
+
 		}
 
 		this.id = this.readWord();
 		this.size = this.readDWord();
 		this.end = this.offset + this.size;
 
-		if (this.end > data.byteLength) {
+		if ( this.end > data.byteLength ) {
+
 			this.debugMessage( 'Bad chunk size for chunk at ' + position );
+
 		}
+
 	}
 
 	/**
@@ -736,18 +746,22 @@ class Chunk {
 	 * @method readChunk
 	 * @return {Chunk | null} next sub chunk
 	 */
-	readChunk () {
+	readChunk() {
 
 		if ( this.endOfChunk ) {
+
 			return null;
+
 		}
 
 		try {
-			let next = new Chunk( this.data, this.position, this.debugMessage );
+
+			const next = new Chunk( this.data, this.position, this.debugMessage );
 			this.position += next.size;
 			return next;
 
 		}	catch ( e ) {
+
 			this.debugMessage( 'Unable to read chunk at ' + this.position );
 			return null;
 
@@ -762,11 +776,15 @@ class Chunk {
 	 * @return {String} hex-string of id
 	 */
 	get hexId() {
+
 		return this.id.toString( 16 );
+
 	}
 
 	get endOfChunk() {
+
 		return this.position >= this.end;
+
 	}
 
 	/**
@@ -873,11 +891,14 @@ class Chunk {
 		let s = '';
 		let c = this.readByte();
 		while ( c ) {
+
 			s += String.fromCharCode( c );
 			c = this.readByte();
+
 		}
 
 		return s;
+
 	}
 
 }

+ 1 - 1
examples/jsm/node-editor/NodeEditor.js

@@ -259,7 +259,7 @@ export class NodeEditor extends EventDispatcher {
 		const context = new ContextMenu( this.domElement );
 
 		let isContext = false;
-		let contextPosition = {};
+		const contextPosition = {};
 
 		const add = ( node ) => {
 

+ 1 - 1
examples/jsm/node-editor/utils/OscillatorEditor.js

@@ -33,7 +33,7 @@ export class OscillatorEditor extends ObjectNode {
 			node.timeNode = timeElement.linkedExtra || NULL_VALUE;
 
 		} );
-		
+
 		this.add( new LabelElement( 'Method' ).add( methodInput ) )
 			.add( timeElement );
 

+ 1 - 1
examples/jsm/postprocessing/SAOPass.js

@@ -78,7 +78,7 @@ class SAOPass extends Pass {
 			format: RGBAFormat
 		} );
 		this.depthRenderTarget = this.normalRenderTarget.clone();
-		
+
 		let depthTexture;
 
 		if ( this.supportsDepthTextureExtension ) {

+ 1 - 0
examples/jsm/renderers/nodes/Nodes.js

@@ -151,6 +151,7 @@ export {
 
 	// utils
 	ArrayElementNode,
+	ConvertNode,
 	JoinNode,
 	SplitNode,
 	SpriteSheetUVNode,

+ 6 - 6
examples/jsm/renderers/nodes/ShaderNode.js

@@ -209,9 +209,9 @@ export const cond = ( ...params ) => {
 
 export const vec2 = ( ...params ) => {
 
-	if ( params[0]?.isNode === true ) {
+	if ( params[ 0 ]?.isNode === true ) {
 
-		return ShaderNodeObject( new ConvertNode( params[0], 'vec2' ) );
+		return ShaderNodeObject( new ConvertNode( params[ 0 ], 'vec2' ) );
 
 	} else {
 
@@ -231,9 +231,9 @@ export const vec2 = ( ...params ) => {
 
 export const vec3 = ( ...params ) => {
 
-	if ( params[0]?.isNode === true ) {
+	if ( params[ 0 ]?.isNode === true ) {
 
-		return ShaderNodeObject( new ConvertNode( params[0], 'vec3' ) );
+		return ShaderNodeObject( new ConvertNode( params[ 0 ], 'vec3' ) );
 
 	} else {
 
@@ -253,9 +253,9 @@ export const vec3 = ( ...params ) => {
 
 export const vec4 = ( ...params ) => {
 
-	if ( params[0]?.isNode === true ) {
+	if ( params[ 0 ]?.isNode === true ) {
 
-		return ShaderNodeObject( new ConvertNode( params[0], 'vec4' ) );
+		return ShaderNodeObject( new ConvertNode( params[ 0 ], 'vec4' ) );
 
 	} else {
 

+ 1 - 1
examples/jsm/renderers/nodes/core/InputNode.js

@@ -26,7 +26,7 @@ class InputNode extends Node {
 
 	}
 
-	getInputType( builder ) {
+	getInputType( /* builder */ ) {
 
 		return this.inputType;
 

+ 3 - 2
examples/jsm/renderers/nodes/display/ColorSpaceNode.js

@@ -52,7 +52,7 @@ const EncodingLib = {
 	LinearTosRGB
 };
 
-function getEncodingComponents ( encoding ) {
+function getEncodingComponents( encoding ) {
 
 	switch ( encoding ) {
 
@@ -72,6 +72,7 @@ function getEncodingComponents ( encoding ) {
 		case GammaEncoding:
 			return [ 'Gamma', new CodeNode( 'float( GAMMA_FACTOR )' ) ];
 */
+
 	}
 
 }
@@ -82,7 +83,7 @@ class ColorSpaceNode extends TempNode {
 
 	static SRGB_TO_LINEAR = 'sRGBToLinear';
 	static LINEAR_TO_SRGB = 'LinearTosRGB';
-/*
+	/*
 	static GAMMA_TO_LINEAR = 'GammaToLinear';
 	static LINEAR_TO_GAMMA = 'LinearToGamma';
 

+ 1 - 1
examples/jsm/renderers/nodes/inputs/TextureNode.js

@@ -21,7 +21,7 @@ class TextureNode extends InputNode {
 
 		if ( ! texture || texture.isTexture !== true ) {
 
-			throw new Error( `TextureNode: Need a three.js texture.` );
+			throw new Error( 'TextureNode: Need a three.js texture.' );
 
 		}
 

+ 1 - 1
examples/jsm/renderers/nodes/utils/TimerNode.js

@@ -3,7 +3,7 @@ import { NodeUpdateType } from '../core/constants.js';
 
 class TimerNode extends FloatNode {
 
-	static LOCAL = 'local';	
+	static LOCAL = 'local';
 	static GLOBAL = 'global';
 	static DELTA = 'delta';
 

+ 4 - 3
examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js

@@ -3,7 +3,7 @@ import SlotNode from './SlotNode.js';
 import GLSLNodeParser from '../../nodes/parsers/GLSLNodeParser.js';
 import WebGLPhysicalContextNode from './WebGLPhysicalContextNode.js';
 
-import { ShaderChunk, LinearEncoding, RGBAFormat, UnsignedByteType, sRGBEncoding } from '../../../../../build/three.module.js';
+import { ShaderChunk /*, LinearEncoding, RGBAFormat, UnsignedByteType, sRGBEncoding */ } from '../../../../../build/three.module.js';
 
 const shaderStages = [ 'vertex', 'fragment' ];
 
@@ -216,7 +216,7 @@ class WebGLNodeBuilder extends NodeBuilder {
 
 	}
 
-	getVarys( shaderStage ) {
+	getVarys( /* shaderStage */ ) {
 
 		let snippet = '';
 
@@ -285,7 +285,8 @@ class WebGLNodeBuilder extends NodeBuilder {
 	}
 
 	getTextureEncodingFromMap( map ) {
-/*
+
+		/*
 		const isWebGL2 = this.renderer.capabilities.isWebGL2;
 
 		if ( isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding ) {

+ 1 - 1
examples/jsm/renderers/webgpu/WebGPURenderPipeline.js

@@ -706,7 +706,7 @@ class WebGPURenderPipeline {
 		const nodeAttributes = nodeBuilder.attributes;
 		const attributes = [];
 
-		for ( let slot = 0; slot < nodeAttributes.length; slot++ ) {
+		for ( let slot = 0; slot < nodeAttributes.length; slot ++ ) {
 
 			const nodeAttribute = nodeAttributes[ slot ];
 

+ 4 - 4
examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js

@@ -150,7 +150,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
 
 			colorNode = this.addFlow( 'fragment', new VarNode( colorNode, 'Color', 'vec3' ) );
 
-			const diffuseNode = this.addFlow( 'fragment', new VarNode( colorNode, 'DiffuseColor', 'vec4' ) );
+			this.addFlow( 'fragment', new VarNode( colorNode, 'DiffuseColor', 'vec4' ) );
 
 			// OPACITY
 
@@ -269,10 +269,10 @@ class WebGPUNodeBuilder extends NodeBuilder {
 			const outputEncoding = this.renderer.outputEncoding;
 
 			if ( outputEncoding !== LinearEncoding ) {
-				
+
 				outputNode = new ColorSpaceNode( ColorSpaceNode.LINEAR_TO_LINEAR, vec4( outputNode ) );
 				outputNode.fromEncoding( outputEncoding );
-				
+
 			}
 
 			this.addFlow( 'fragment', new VarNode( outputNode, 'Output', 'vec4' ) );
@@ -293,7 +293,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
 
 	}
 
-	getTexture( textureProperty, uvSnippet, biasSnippet = null, shaderStage = this.shaderStage ) {
+	getTexture( textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
 
 		if ( shaderStage === 'fragment' ) {
 

+ 11 - 11
examples/jsm/utils/WorkerPool.js

@@ -4,7 +4,7 @@
 
 export class WorkerPool {
 
-	constructor ( pool = 4 ) {
+	constructor( pool = 4 ) {
 
 		this.pool = pool;
 		this.queue = [];
@@ -14,9 +14,9 @@ export class WorkerPool {
 
 	}
 
-	_initWorker ( workerId ) {
+	_initWorker( workerId ) {
 
-		if ( !this.workers[ workerId ] ) {
+		if ( ! this.workers[ workerId ] ) {
 
 			const worker = this.workerCreator();
 			worker.addEventListener( 'message', this._onMessage.bind( this, workerId ) );
@@ -26,12 +26,12 @@ export class WorkerPool {
 
 	}
 
-	_getIdleWorker () {
+	_getIdleWorker() {
 
-		for ( let i = 0 ; i < this.pool ; i ++ ) 
+		for ( let i = 0; i < this.pool; i ++ )
 			if ( ! ( this.workerStatus & ( 1 << i ) ) ) return i;
 
-		return -1;
+		return - 1;
 
 	}
 
@@ -54,25 +54,25 @@ export class WorkerPool {
 
 	}
 
-	setWorkerCreator ( workerCreator ) {
+	setWorkerCreator( workerCreator ) {
 
 		this.workerCreator = workerCreator;
 
 	}
 
-	setWorkerLimit ( pool ) {
+	setWorkerLimit( pool ) {
 
 		this.pool = pool;
 
 	}
 
-	postMessage ( msg, transfer ) {
+	postMessage( msg, transfer ) {
 
 		return new Promise( ( resolve ) => {
 
 			const workerId = this._getIdleWorker();
 
-			if ( workerId !== -1 ) {
+			if ( workerId !== - 1 ) {
 
 				this._initWorker( workerId );
 				this.workerStatus |= 1 << workerId;
@@ -89,7 +89,7 @@ export class WorkerPool {
 
 	}
 
-	dispose () {
+	dispose() {
 
 		this.workers.forEach( ( worker ) => worker.terminate() );
 		this.workersResolve.length = 0;

+ 5 - 1
package.json

@@ -48,7 +48,11 @@
       "OIMO": "readonly",
       "Stats": "readonly",
       "XRWebGLBinding": "readonly",
-      "XRWebGLLayer": "readonly"
+      "XRWebGLLayer": "readonly",
+
+      "GPUShaderStage": "readonly",
+      "GPUBufferUsage": "readonly",
+      "GPUTextureUsage": "readonly"
     },
     "rules": {
       "quotes": [