Browse Source

fix-lint-issues (#31738)

Co-authored-by: Samuel Rigaud <rigaud@gmail.com>
Samuel Rigaud 6 months ago
parent
commit
65bfbd8e51

+ 5 - 5
examples/jsm/loaders/EXRLoader.js

@@ -2515,7 +2515,7 @@ class EXRLoader extends DataTextureLoader {
 						EXRDecoder.outputChannels = 1;
 						EXRDecoder.decodeChannels = { R: 0 };
 
-					} else  {
+					} else {
 
 						invalidOutput = true;
 
@@ -2549,7 +2549,7 @@ class EXRLoader extends DataTextureLoader {
 						EXRDecoder.outputChannels = 1;
 						EXRDecoder.decodeChannels = { Y: 0 };
 
-					} else  {
+					} else {
 
 						invalidOutput = true;
 
@@ -2563,7 +2563,7 @@ class EXRLoader extends DataTextureLoader {
 
 			}
 
-			if (invalidOutput) throw new Error( 'EXRLoader.parse: invalid output format for specified file.' );
+			if ( invalidOutput ) throw new Error( 'EXRLoader.parse: invalid output format for specified file.' );
 
 			if ( EXRDecoder.type == 1 ) {
 
@@ -2712,12 +2712,12 @@ class EXRLoader extends DataTextureLoader {
 			if ( this.outputFormat == RGBAFormat ) {
 
 				for ( let i = 0; i < byteArray.length; i += 4 )
-					byteArray [i + 2 ] = ( byteArray [ i + 1 ] = byteArray[ i ] );
+					byteArray[ i + 2 ] = ( byteArray[ i + 1 ] = byteArray[ i ] );
 
 			} else if ( this.outputFormat == RGFormat ) {
 
 				for ( let i = 0; i < byteArray.length; i += 2 )
-					byteArray [ i + 1 ] = byteArray[ i ] ;
+					byteArray[ i + 1 ] = byteArray[ i ];
 
 			}
 

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

@@ -42,7 +42,7 @@ class HDRCubeTextureLoader extends Loader {
 		 *
          * @type {HDRLoader}
 		 */
-        this.hdrLoader = new HDRLoader();
+		this.hdrLoader = new HDRLoader();
 
 		/**
 		 * The texture type.

+ 274 - 274
examples/jsm/loaders/HDRLoader.js

@@ -1,10 +1,10 @@
 import {
-    DataTextureLoader,
-    DataUtils,
-    FloatType,
-    HalfFloatType,
-    LinearFilter,
-    LinearSRGBColorSpace
+	DataTextureLoader,
+	DataUtils,
+	FloatType,
+	HalfFloatType,
+	LinearFilter,
+	LinearSRGBColorSpace
 } from 'three';
 
 /**
@@ -23,461 +23,461 @@ import {
  */
 class HDRLoader extends DataTextureLoader {
 
-    /**
+	/**
      * Constructs a new RGBE/HDR loader.
      *
      * @param {LoadingManager} [manager] - The loading manager.
      */
-    constructor( manager ) {
+	constructor( manager ) {
 
-        super( manager );
+		super( manager );
 
-        /**
+		/**
          * The texture type.
          *
          * @type {(HalfFloatType|FloatType)}
          * @default HalfFloatType
          */
-        this.type = HalfFloatType;
+		this.type = HalfFloatType;
 
-    }
+	}
 
-    /**
+	/**
      * Parses the given RGBE texture data.
      *
      * @param {ArrayBuffer} buffer - The raw texture data.
      * @return {DataTextureLoader~TexData} An object representing the parsed texture data.
      */
-    parse( buffer ) {
+	parse( buffer ) {
 
-        // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
+		// adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
 
-        const
-            /* default error routine.  change this to change error handling */
-            rgbe_read_error = 1,
-            rgbe_write_error = 2,
-            rgbe_format_error = 3,
-            rgbe_memory_error = 4,
-            rgbe_error = function ( rgbe_error_code, msg ) {
+		const
+			/* default error routine.  change this to change error handling */
+			rgbe_read_error = 1,
+			rgbe_write_error = 2,
+			rgbe_format_error = 3,
+			rgbe_memory_error = 4,
+			rgbe_error = function ( rgbe_error_code, msg ) {
 
-                switch ( rgbe_error_code ) {
+				switch ( rgbe_error_code ) {
 
-                    case rgbe_read_error: throw new Error( 'THREE.HDRLoader: Read Error: ' + ( msg || '' ) );
-                    case rgbe_write_error: throw new Error( 'THREE.HDRLoader: Write Error: ' + ( msg || '' ) );
-                    case rgbe_format_error: throw new Error( 'THREE.HDRLoader: Bad File Format: ' + ( msg || '' ) );
-                    default:
-                    case rgbe_memory_error: throw new Error( 'THREE.HDRLoader: Memory Error: ' + ( msg || '' ) );
+					case rgbe_read_error: throw new Error( 'THREE.HDRLoader: Read Error: ' + ( msg || '' ) );
+					case rgbe_write_error: throw new Error( 'THREE.HDRLoader: Write Error: ' + ( msg || '' ) );
+					case rgbe_format_error: throw new Error( 'THREE.HDRLoader: Bad File Format: ' + ( msg || '' ) );
+					default:
+					case rgbe_memory_error: throw new Error( 'THREE.HDRLoader: Memory Error: ' + ( msg || '' ) );
 
-                }
+				}
 
-            },
+			},
 
-            /* offsets to red, green, and blue components in a data (float) pixel */
-            //RGBE_DATA_RED = 0,
-            //RGBE_DATA_GREEN = 1,
-            //RGBE_DATA_BLUE = 2,
+			/* offsets to red, green, and blue components in a data (float) pixel */
+			//RGBE_DATA_RED = 0,
+			//RGBE_DATA_GREEN = 1,
+			//RGBE_DATA_BLUE = 2,
 
-            /* number of floats per pixel, use 4 since stored in rgba image format */
-            //RGBE_DATA_SIZE = 4,
+			/* number of floats per pixel, use 4 since stored in rgba image format */
+			//RGBE_DATA_SIZE = 4,
 
-            /* flags indicating which fields in an rgbe_header_info are valid */
-            RGBE_VALID_PROGRAMTYPE = 1,
-            RGBE_VALID_FORMAT = 2,
-            RGBE_VALID_DIMENSIONS = 4,
+			/* flags indicating which fields in an rgbe_header_info are valid */
+			RGBE_VALID_PROGRAMTYPE = 1,
+			RGBE_VALID_FORMAT = 2,
+			RGBE_VALID_DIMENSIONS = 4,
 
-            NEWLINE = '\n',
+			NEWLINE = '\n',
 
-            fgets = function ( buffer, lineLimit, consume ) {
+			fgets = function ( buffer, lineLimit, consume ) {
 
-                const chunkSize = 128;
+				const chunkSize = 128;
 
-                lineLimit = ! lineLimit ? 1024 : lineLimit;
-                let p = buffer.pos,
-                    i = - 1, len = 0, s = '',
-                    chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
+				lineLimit = ! lineLimit ? 1024 : lineLimit;
+				let p = buffer.pos,
+					i = - 1, len = 0, s = '',
+					chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
 
-                while ( ( 0 > ( i = chunk.indexOf( NEWLINE ) ) ) && ( len < lineLimit ) && ( p < buffer.byteLength ) ) {
+				while ( ( 0 > ( i = chunk.indexOf( NEWLINE ) ) ) && ( len < lineLimit ) && ( p < buffer.byteLength ) ) {
 
-                    s += chunk; len += chunk.length;
-                    p += chunkSize;
-                    chunk += String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
+					s += chunk; len += chunk.length;
+					p += chunkSize;
+					chunk += String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
 
-                }
+				}
 
-                if ( - 1 < i ) {
+				if ( - 1 < i ) {
 
-                    /*for (i=l-1; i>=0; i--) {
+					/*for (i=l-1; i>=0; i--) {
                         byteCode = m.charCodeAt(i);
                         if (byteCode > 0x7f && byteCode <= 0x7ff) byteLen++;
                         else if (byteCode > 0x7ff && byteCode <= 0xffff) byteLen += 2;
                         if (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate
                     }*/
-                    if ( false !== consume ) buffer.pos += len + i + 1;
-                    return s + chunk.slice( 0, i );
+					if ( false !== consume ) buffer.pos += len + i + 1;
+					return s + chunk.slice( 0, i );
 
-                }
+				}
 
-                return false;
+				return false;
 
-            },
+			},
 
-            /* minimal header reading.  modify if you want to parse more information */
-            RGBE_ReadHeader = function ( buffer ) {
+			/* minimal header reading.  modify if you want to parse more information */
+			RGBE_ReadHeader = function ( buffer ) {
 
 
-                // regexes to parse header info fields
-                const magic_token_re = /^#\?(\S+)/,
-                    gamma_re = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,
-                    exposure_re = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,
-                    format_re = /^\s*FORMAT=(\S+)\s*$/,
-                    dimensions_re = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,
+				// regexes to parse header info fields
+				const magic_token_re = /^#\?(\S+)/,
+					gamma_re = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,
+					exposure_re = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,
+					format_re = /^\s*FORMAT=(\S+)\s*$/,
+					dimensions_re = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,
 
-                    // RGBE format header struct
-                    header = {
+					// RGBE format header struct
+					header = {
 
-                        valid: 0, /* indicate which fields are valid */
+						valid: 0, /* indicate which fields are valid */
 
-                        string: '', /* the actual header string */
+						string: '', /* the actual header string */
 
-                        comments: '', /* comments found in header */
+						comments: '', /* comments found in header */
 
-                        programtype: 'RGBE', /* listed at beginning of file to identify it after "#?". defaults to "RGBE" */
+						programtype: 'RGBE', /* listed at beginning of file to identify it after "#?". defaults to "RGBE" */
 
-                        format: '', /* RGBE format, default 32-bit_rle_rgbe */
+						format: '', /* RGBE format, default 32-bit_rle_rgbe */
 
-                        gamma: 1.0, /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */
+						gamma: 1.0, /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */
 
-                        exposure: 1.0, /* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */
+						exposure: 1.0, /* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */
 
-                        width: 0, height: 0 /* image dimensions, width/height */
+						width: 0, height: 0 /* image dimensions, width/height */
 
-                    };
+					};
 
-                let line, match;
+				let line, match;
 
-                if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) {
+				if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) {
 
-                    rgbe_error( rgbe_read_error, 'no header found' );
+					rgbe_error( rgbe_read_error, 'no header found' );
 
-                }
+				}
 
-                /* if you want to require the magic token then uncomment the next line */
-                if ( ! ( match = line.match( magic_token_re ) ) ) {
+				/* if you want to require the magic token then uncomment the next line */
+				if ( ! ( match = line.match( magic_token_re ) ) ) {
 
-                    rgbe_error( rgbe_format_error, 'bad initial token' );
+					rgbe_error( rgbe_format_error, 'bad initial token' );
 
-                }
+				}
 
-                header.valid |= RGBE_VALID_PROGRAMTYPE;
-                header.programtype = match[ 1 ];
-                header.string += line + '\n';
+				header.valid |= RGBE_VALID_PROGRAMTYPE;
+				header.programtype = match[ 1 ];
+				header.string += line + '\n';
 
-                while ( true ) {
+				while ( true ) {
 
-                    line = fgets( buffer );
-                    if ( false === line ) break;
-                    header.string += line + '\n';
+					line = fgets( buffer );
+					if ( false === line ) break;
+					header.string += line + '\n';
 
-                    if ( '#' === line.charAt( 0 ) ) {
+					if ( '#' === line.charAt( 0 ) ) {
 
-                        header.comments += line + '\n';
-                        continue; // comment line
+						header.comments += line + '\n';
+						continue; // comment line
 
-                    }
+					}
 
-                    if ( match = line.match( gamma_re ) ) {
+					if ( match = line.match( gamma_re ) ) {
 
-                        header.gamma = parseFloat( match[ 1 ] );
+						header.gamma = parseFloat( match[ 1 ] );
 
-                    }
+					}
 
-                    if ( match = line.match( exposure_re ) ) {
+					if ( match = line.match( exposure_re ) ) {
 
-                        header.exposure = parseFloat( match[ 1 ] );
+						header.exposure = parseFloat( match[ 1 ] );
 
-                    }
+					}
 
-                    if ( match = line.match( format_re ) ) {
+					if ( match = line.match( format_re ) ) {
 
-                        header.valid |= RGBE_VALID_FORMAT;
-                        header.format = match[ 1 ];//'32-bit_rle_rgbe';
+						header.valid |= RGBE_VALID_FORMAT;
+						header.format = match[ 1 ];//'32-bit_rle_rgbe';
 
-                    }
+					}
 
-                    if ( match = line.match( dimensions_re ) ) {
+					if ( match = line.match( dimensions_re ) ) {
 
-                        header.valid |= RGBE_VALID_DIMENSIONS;
-                        header.height = parseInt( match[ 1 ], 10 );
-                        header.width = parseInt( match[ 2 ], 10 );
+						header.valid |= RGBE_VALID_DIMENSIONS;
+						header.height = parseInt( match[ 1 ], 10 );
+						header.width = parseInt( match[ 2 ], 10 );
 
-                    }
+					}
 
-                    if ( ( header.valid & RGBE_VALID_FORMAT ) && ( header.valid & RGBE_VALID_DIMENSIONS ) ) break;
+					if ( ( header.valid & RGBE_VALID_FORMAT ) && ( header.valid & RGBE_VALID_DIMENSIONS ) ) break;
 
-                }
+				}
 
-                if ( ! ( header.valid & RGBE_VALID_FORMAT ) ) {
+				if ( ! ( header.valid & RGBE_VALID_FORMAT ) ) {
 
-                    rgbe_error( rgbe_format_error, 'missing format specifier' );
+					rgbe_error( rgbe_format_error, 'missing format specifier' );
 
-                }
+				}
 
-                if ( ! ( header.valid & RGBE_VALID_DIMENSIONS ) ) {
+				if ( ! ( header.valid & RGBE_VALID_DIMENSIONS ) ) {
 
-                    rgbe_error( rgbe_format_error, 'missing image size specifier' );
+					rgbe_error( rgbe_format_error, 'missing image size specifier' );
 
-                }
+				}
 
-                return header;
+				return header;
 
-            },
+			},
 
-            RGBE_ReadPixels_RLE = function ( buffer, w, h ) {
+			RGBE_ReadPixels_RLE = function ( buffer, w, h ) {
 
-                const scanline_width = w;
+				const scanline_width = w;
 
-                if (
-                    // run length encoding is not allowed so read flat
-                    ( ( scanline_width < 8 ) || ( scanline_width > 0x7fff ) ) ||
+				if (
+				// run length encoding is not allowed so read flat
+					( ( scanline_width < 8 ) || ( scanline_width > 0x7fff ) ) ||
                     // this file is not run length encoded
                     ( ( 2 !== buffer[ 0 ] ) || ( 2 !== buffer[ 1 ] ) || ( buffer[ 2 ] & 0x80 ) )
-                ) {
+				) {
 
-                    // return the flat buffer
-                    return new Uint8Array( buffer );
+					// return the flat buffer
+					return new Uint8Array( buffer );
 
-                }
+				}
 
-                if ( scanline_width !== ( ( buffer[ 2 ] << 8 ) | buffer[ 3 ] ) ) {
+				if ( scanline_width !== ( ( buffer[ 2 ] << 8 ) | buffer[ 3 ] ) ) {
 
-                    rgbe_error( rgbe_format_error, 'wrong scanline width' );
+					rgbe_error( rgbe_format_error, 'wrong scanline width' );
 
-                }
+				}
 
-                const data_rgba = new Uint8Array( 4 * w * h );
+				const data_rgba = new Uint8Array( 4 * w * h );
 
-                if ( ! data_rgba.length ) {
+				if ( ! data_rgba.length ) {
 
-                    rgbe_error( rgbe_memory_error, 'unable to allocate buffer space' );
+					rgbe_error( rgbe_memory_error, 'unable to allocate buffer space' );
 
-                }
+				}
 
-                let offset = 0, pos = 0;
+				let offset = 0, pos = 0;
 
-                const ptr_end = 4 * scanline_width;
-                const rgbeStart = new Uint8Array( 4 );
-                const scanline_buffer = new Uint8Array( ptr_end );
-                let num_scanlines = h;
+				const ptr_end = 4 * scanline_width;
+				const rgbeStart = new Uint8Array( 4 );
+				const scanline_buffer = new Uint8Array( ptr_end );
+				let num_scanlines = h;
 
-                // read in each successive scanline
-                while ( ( num_scanlines > 0 ) && ( pos < buffer.byteLength ) ) {
+				// read in each successive scanline
+				while ( ( num_scanlines > 0 ) && ( pos < buffer.byteLength ) ) {
 
-                    if ( pos + 4 > buffer.byteLength ) {
+					if ( pos + 4 > buffer.byteLength ) {
 
-                        rgbe_error( rgbe_read_error );
+						rgbe_error( rgbe_read_error );
 
-                    }
+					}
 
-                    rgbeStart[ 0 ] = buffer[ pos ++ ];
-                    rgbeStart[ 1 ] = buffer[ pos ++ ];
-                    rgbeStart[ 2 ] = buffer[ pos ++ ];
-                    rgbeStart[ 3 ] = buffer[ pos ++ ];
+					rgbeStart[ 0 ] = buffer[ pos ++ ];
+					rgbeStart[ 1 ] = buffer[ pos ++ ];
+					rgbeStart[ 2 ] = buffer[ pos ++ ];
+					rgbeStart[ 3 ] = buffer[ pos ++ ];
 
-                    if ( ( 2 != rgbeStart[ 0 ] ) || ( 2 != rgbeStart[ 1 ] ) || ( ( ( rgbeStart[ 2 ] << 8 ) | rgbeStart[ 3 ] ) != scanline_width ) ) {
+					if ( ( 2 != rgbeStart[ 0 ] ) || ( 2 != rgbeStart[ 1 ] ) || ( ( ( rgbeStart[ 2 ] << 8 ) | rgbeStart[ 3 ] ) != scanline_width ) ) {
 
-                        rgbe_error( rgbe_format_error, 'bad rgbe scanline format' );
+						rgbe_error( rgbe_format_error, 'bad rgbe scanline format' );
 
-                    }
+					}
 
-                    // read each of the four channels for the scanline into the buffer
-                    // first red, then green, then blue, then exponent
-                    let ptr = 0, count;
+					// read each of the four channels for the scanline into the buffer
+					// first red, then green, then blue, then exponent
+					let ptr = 0, count;
 
-                    while ( ( ptr < ptr_end ) && ( pos < buffer.byteLength ) ) {
+					while ( ( ptr < ptr_end ) && ( pos < buffer.byteLength ) ) {
 
-                        count = buffer[ pos ++ ];
-                        const isEncodedRun = count > 128;
-                        if ( isEncodedRun ) count -= 128;
+						count = buffer[ pos ++ ];
+						const isEncodedRun = count > 128;
+						if ( isEncodedRun ) count -= 128;
 
-                        if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) {
+						if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) {
 
-                            rgbe_error( rgbe_format_error, 'bad scanline data' );
+							rgbe_error( rgbe_format_error, 'bad scanline data' );
 
-                        }
+						}
 
-                        if ( isEncodedRun ) {
+						if ( isEncodedRun ) {
 
-                            // a (encoded) run of the same value
-                            const byteValue = buffer[ pos ++ ];
-                            for ( let i = 0; i < count; i ++ ) {
+							// a (encoded) run of the same value
+							const byteValue = buffer[ pos ++ ];
+							for ( let i = 0; i < count; i ++ ) {
 
-                                scanline_buffer[ ptr ++ ] = byteValue;
+								scanline_buffer[ ptr ++ ] = byteValue;
 
-                            }
-                            //ptr += count;
+							}
+							//ptr += count;
 
-                        } else {
+						} else {
 
-                            // a literal-run
-                            scanline_buffer.set( buffer.subarray( pos, pos + count ), ptr );
-                            ptr += count; pos += count;
+							// a literal-run
+							scanline_buffer.set( buffer.subarray( pos, pos + count ), ptr );
+							ptr += count; pos += count;
 
-                        }
+						}
 
-                    }
+					}
 
 
-                    // now convert data from buffer into rgba
-                    // first red, then green, then blue, then exponent (alpha)
-                    const l = scanline_width; //scanline_buffer.byteLength;
-                    for ( let i = 0; i < l; i ++ ) {
+					// now convert data from buffer into rgba
+					// first red, then green, then blue, then exponent (alpha)
+					const l = scanline_width; //scanline_buffer.byteLength;
+					for ( let i = 0; i < l; i ++ ) {
 
-                        let off = 0;
-                        data_rgba[ offset ] = scanline_buffer[ i + off ];
-                        off += scanline_width; //1;
-                        data_rgba[ offset + 1 ] = scanline_buffer[ i + off ];
-                        off += scanline_width; //1;
-                        data_rgba[ offset + 2 ] = scanline_buffer[ i + off ];
-                        off += scanline_width; //1;
-                        data_rgba[ offset + 3 ] = scanline_buffer[ i + off ];
-                        offset += 4;
+						let off = 0;
+						data_rgba[ offset ] = scanline_buffer[ i + off ];
+						off += scanline_width; //1;
+						data_rgba[ offset + 1 ] = scanline_buffer[ i + off ];
+						off += scanline_width; //1;
+						data_rgba[ offset + 2 ] = scanline_buffer[ i + off ];
+						off += scanline_width; //1;
+						data_rgba[ offset + 3 ] = scanline_buffer[ i + off ];
+						offset += 4;
 
-                    }
+					}
 
-                    num_scanlines --;
+					num_scanlines --;
 
-                }
+				}
 
-                return data_rgba;
+				return data_rgba;
 
-            };
+			};
 
-        const RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) {
+		const RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) {
 
-            const e = sourceArray[ sourceOffset + 3 ];
-            const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
+			const e = sourceArray[ sourceOffset + 3 ];
+			const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
 
-            destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale;
-            destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale;
-            destArray[ destOffset + 2 ] = sourceArray[ sourceOffset + 2 ] * scale;
-            destArray[ destOffset + 3 ] = 1;
+			destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale;
+			destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale;
+			destArray[ destOffset + 2 ] = sourceArray[ sourceOffset + 2 ] * scale;
+			destArray[ destOffset + 3 ] = 1;
 
-        };
+		};
 
-        const RGBEByteToRGBHalf = function ( sourceArray, sourceOffset, destArray, destOffset ) {
+		const RGBEByteToRGBHalf = function ( sourceArray, sourceOffset, destArray, destOffset ) {
 
-            const e = sourceArray[ sourceOffset + 3 ];
-            const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
+			const e = sourceArray[ sourceOffset + 3 ];
+			const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
 
-            // clamping to 65504, the maximum representable value in float16
-            destArray[ destOffset + 0 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 0 ] * scale, 65504 ) );
-            destArray[ destOffset + 1 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 1 ] * scale, 65504 ) );
-            destArray[ destOffset + 2 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 2 ] * scale, 65504 ) );
-            destArray[ destOffset + 3 ] = DataUtils.toHalfFloat( 1 );
+			// clamping to 65504, the maximum representable value in float16
+			destArray[ destOffset + 0 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 0 ] * scale, 65504 ) );
+			destArray[ destOffset + 1 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 1 ] * scale, 65504 ) );
+			destArray[ destOffset + 2 ] = DataUtils.toHalfFloat( Math.min( sourceArray[ sourceOffset + 2 ] * scale, 65504 ) );
+			destArray[ destOffset + 3 ] = DataUtils.toHalfFloat( 1 );
 
-        };
+		};
 
-        const byteArray = new Uint8Array( buffer );
-        byteArray.pos = 0;
-        const rgbe_header_info = RGBE_ReadHeader( byteArray );
+		const byteArray = new Uint8Array( buffer );
+		byteArray.pos = 0;
+		const rgbe_header_info = RGBE_ReadHeader( byteArray );
 
-        const w = rgbe_header_info.width,
-            h = rgbe_header_info.height,
-            image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h );
+		const w = rgbe_header_info.width,
+			h = rgbe_header_info.height,
+			image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h );
 
 
-        let data, type;
-        let numElements;
+		let data, type;
+		let numElements;
 
-        switch ( this.type ) {
+		switch ( this.type ) {
 
-            case FloatType:
+			case FloatType:
 
-                numElements = image_rgba_data.length / 4;
-                const floatArray = new Float32Array( numElements * 4 );
+				numElements = image_rgba_data.length / 4;
+				const floatArray = new Float32Array( numElements * 4 );
 
-                for ( let j = 0; j < numElements; j ++ ) {
+				for ( let j = 0; j < numElements; j ++ ) {
 
-                    RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 4 );
+					RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 4 );
 
-                }
+				}
 
-                data = floatArray;
-                type = FloatType;
-                break;
+				data = floatArray;
+				type = FloatType;
+				break;
 
-            case HalfFloatType:
+			case HalfFloatType:
 
-                numElements = image_rgba_data.length / 4;
-                const halfArray = new Uint16Array( numElements * 4 );
+				numElements = image_rgba_data.length / 4;
+				const halfArray = new Uint16Array( numElements * 4 );
 
-                for ( let j = 0; j < numElements; j ++ ) {
+				for ( let j = 0; j < numElements; j ++ ) {
 
-                    RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 4 );
+					RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 4 );
 
-                }
+				}
 
-                data = halfArray;
-                type = HalfFloatType;
-                break;
+				data = halfArray;
+				type = HalfFloatType;
+				break;
 
-            default:
+			default:
 
-                throw new Error( 'THREE.HDRLoader: Unsupported type: ' + this.type );
-                break;
+				throw new Error( 'THREE.HDRLoader: Unsupported type: ' + this.type );
+				break;
 
-        }
+		}
 
-        return {
-            width: w, height: h,
-            data: data,
-            header: rgbe_header_info.string,
-            gamma: rgbe_header_info.gamma,
-            exposure: rgbe_header_info.exposure,
-            type: type
-        };
+		return {
+			width: w, height: h,
+			data: data,
+			header: rgbe_header_info.string,
+			gamma: rgbe_header_info.gamma,
+			exposure: rgbe_header_info.exposure,
+			type: type
+		};
 
-    }
+	}
 
-    /**
+	/**
      * Sets the texture type.
      *
      * @param {(HalfFloatType|FloatType)} value - The texture type to set.
      * @return {HDRLoader} A reference to this loader.
      */
-    setDataType( value ) {
+	setDataType( value ) {
 
-        this.type = value;
-        return this;
+		this.type = value;
+		return this;
 
-    }
+	}
 
-    load( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-        function onLoadCallback( texture, texData ) {
+		function onLoadCallback( texture, texData ) {
 
-            switch ( texture.type ) {
+			switch ( texture.type ) {
 
-                case FloatType:
-                case HalfFloatType:
+				case FloatType:
+				case HalfFloatType:
 
-                    texture.colorSpace = LinearSRGBColorSpace;
-                    texture.minFilter = LinearFilter;
-                    texture.magFilter = LinearFilter;
-                    texture.generateMipmaps = false;
-                    texture.flipY = true;
+					texture.colorSpace = LinearSRGBColorSpace;
+					texture.minFilter = LinearFilter;
+					texture.magFilter = LinearFilter;
+					texture.generateMipmaps = false;
+					texture.flipY = true;
 
-                    break;
+					break;
 
-            }
+			}
 
-            if ( onLoad ) onLoad( texture, texData );
+			if ( onLoad ) onLoad( texture, texData );
 
-        }
+		}
 
-        return super.load( url, onLoadCallback, onProgress, onError );
+		return super.load( url, onLoadCallback, onProgress, onError );
 
-    }
+	}
 
 }
 

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

@@ -1045,7 +1045,7 @@ async function createRawTexture( container ) {
 	// TODO: Merge the TYPE_MAP warning into the thrown error above, after r190.
 	if ( TYPE_MAP[ vkFormat ] === undefined ) {
 
-		console.warn( 'THREE.KTX2Loader: Missing ".type" for vkFormat: ' + vkFormat  );
+		console.warn( 'THREE.KTX2Loader: Missing ".type" for vkFormat: ' + vkFormat );
 
 	}
 

+ 4 - 4
examples/jsm/loaders/RGBELoader.js

@@ -4,12 +4,12 @@ import { HDRLoader } from './HDRLoader.js';
 
 class RGBELoader extends HDRLoader {
 
-    constructor( manager ) {
+	constructor( manager ) {
 
-        console.warn( 'RGBELoader has been deprecated. Please use HDRLoader instead.' );
-        super( manager );
+		console.warn( 'RGBELoader has been deprecated. Please use HDRLoader instead.' );
+		super( manager );
 
-    }
+	}
 
 }
 

+ 4 - 4
examples/jsm/loaders/TTFLoader.js

@@ -153,13 +153,13 @@ class TTFLoader extends Loader {
 					} );
 
 					if ( Array.isArray( glyph.unicodes ) && glyph.unicodes.length > 0 ) {
-						
+
 						glyph.unicodes.forEach( function ( unicode ) {
-							
+
 							glyphs[ String.fromCodePoint( unicode ) ] = token;
-							
+
 						} );
-						
+
 					} else {
 
 						glyphs[ String.fromCodePoint( glyph.unicode ) ] = token;

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

@@ -510,7 +510,7 @@ class OutlinePass extends Pass {
 
 				}
 
-			} else if ( object.isMesh || object.isSprite) {
+			} else if ( object.isMesh || object.isSprite ) {
 
 				// only meshes and sprites are supported by OutlinePass
 

+ 1 - 0
examples/jsm/tsl/display/ChromaticAberrationNode.js

@@ -203,4 +203,5 @@ export const chromaticAberration = ( node, strength = 1.0, center = null, scale
 			nodeObject( scale )
 		)
 	);
+
 };

+ 3 - 3
examples/webgl_loader_texture_ktx2.html

@@ -132,7 +132,7 @@
 						{ path: '2d_uastc_hdr4x4.ktx2' },
 					]
 				},
-			]
+			];
 
 			init();
 
@@ -192,14 +192,14 @@
 						try {
 
 							const texture = await loader.loadAsync( supported === false ? 'fail_load.ktx2' : path );
-							const mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial({ map: texture }) );
+							const mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) );
 
 							labelElement.innerText += '\ncolorSpace: ' + texture.colorSpace;
 
 							scene.add( mesh );
 							scenes.push( scene );
 
-						} catch (e) {
+						} catch ( e ) {
 
 							console.error( `Failed to load ${path}`, e );
 

+ 2 - 2
examples/webgl_shadowmap.html

@@ -37,8 +37,8 @@
 
 			const SHADOW_MAP_WIDTH = 2048, SHADOW_MAP_HEIGHT = 1024;
 
-			let SCREEN_WIDTH = window.innerWidth;
-			let SCREEN_HEIGHT = window.innerHeight;
+			const SCREEN_WIDTH = window.innerWidth;
+			const SCREEN_HEIGHT = window.innerHeight;
 			const FLOOR = - 250;
 
 			let camera, controls, scene, renderer;

+ 20 - 12
examples/webgpu_loader_materialx.html

@@ -125,20 +125,20 @@
 
 					const coord = positionWorld.xz.div( gridSize );
 					const grid = fract( coord );
-					
+
 					// Screen-space derivative for automatic antialiasing
 					const fw = fwidth( coord );
 					const smoothing = max( fw.x, fw.y ).mul( 0.5 );
-					
+
 					// Create squares at cell centers
 					const squareDist = max( abs( grid.x.sub( 0.5 ) ), abs( grid.y.sub( 0.5 ) ) );
 					const dots = smoothstep( dotWidth.add( smoothing ), dotWidth.sub( smoothing ), squareDist );
-					
+
 					// Create grid lines
 					const lineX = smoothstep( lineWidth.add( smoothing ), lineWidth.sub( smoothing ), abs( grid.x.sub( 0.5 ) ) );
 					const lineZ = smoothstep( lineWidth.add( smoothing ), lineWidth.sub( smoothing ), abs( grid.y.sub( 0.5 ) ) );
 					const lines = max( lineX, lineZ );
-					
+
 					return max( dots, lines );
 
 				} );
@@ -148,12 +148,12 @@
 					return smoothstep( radius, radius.sub( falloff ), length( positionWorld ) );
 
 				} );
-				
+
 				// Create grid pattern
 				const gridPattern = gridXZ( 1.0, 0.03, 0.005 );
 				const baseColor = vec4( 1.0, 1.0, 1.0, 0.0 );
 				const gridColor = vec4( 0.5, 0.5, 0.5, 1.0 );
-				
+
 				// Mix base color with grid lines
 				material.colorNode = gridPattern.mix( baseColor, gridColor ).mul( radialGradient( 30.0, 20.0 ) );
 				material.transparent = true;
@@ -241,7 +241,7 @@
 					.setPath( path )
 					.loadAsync( sample )
 					.then( ( { materials } ) => Object.values( materials ).pop() );
-			
+
 				const calibrationMesh = model.getObjectByName( 'Calibration_Mesh' );
 				calibrationMesh.material = material;
 
@@ -269,18 +269,26 @@
 				const folder = gui.addFolder( 'SHOW' );
 
 				folder.add( API, 'showCalibrationMesh' )
-					.name( 'Calibration Mesh')
-					.onChange( function( value ) { setVisibility( 'Calibration_Mesh', value ) } );
+					.name( 'Calibration Mesh' )
+					.onChange( function ( value ) {
+
+						setVisibility( 'Calibration_Mesh', value );
+
+					} );
 
 				folder.add( API, 'showPreviewMesh' )
-					.name( 'Preview Mesh')
-					.onChange( function( value ) { setVisibility( 'Preview_Mesh', value ) } );
+					.name( 'Preview Mesh' )
+					.onChange( function ( value ) {
+
+						setVisibility( 'Preview_Mesh', value );
+
+					} );
 
 			}
 
 			function setVisibility( name, visible ) {
 
-				scene.traverse( function( node ) {
+				scene.traverse( function ( node ) {
 
 					if ( node.isMesh ) {
 

+ 2 - 2
examples/webgpu_reflection_roughness.html

@@ -48,7 +48,7 @@
 
 				const loader = new UltraHDRLoader();
 				loader.setDataType( THREE.HalfFloatType );
-				loader.load( `textures/equirectangular/spruit_sunrise_2k.hdr.jpg`, function ( texture ) {
+				loader.load( 'textures/equirectangular/spruit_sunrise_2k.hdr.jpg', function ( texture ) {
 
 					texture.mapping = THREE.EquirectangularReflectionMapping;
 					texture.needsUpdate = true;
@@ -71,7 +71,7 @@
 				perlinMap.colorSpace = THREE.SRGBColorSpace;
 
 				// uv box for debugging
-				
+			
 				const mesh = new THREE.Mesh(
 					new THREE.BoxGeometry( 1, 1, 1 ),
 					new THREE.MeshStandardNodeMaterial( {

+ 5 - 1
examples/webgpu_tsl_transpiler.html

@@ -244,17 +244,21 @@ float pNoise(vec2 p, int res){
 					const encoderSelect = document.getElementById( 'encoder-select' );
 
 					decoderSelect.addEventListener( 'change', () => {
+
 						options.decoder = decoderSelect.value;
 						build();
+
 					} );
 
 					encoderSelect.addEventListener( 'change', () => {
+
 						options.encoder = encoderSelect.value;
-						
+
 						const language = encoderLanguages[ encoderSelect.value ];
 						window.monaco.editor.setModelLanguage( result.getModel(), language );
 
 						build();
+
 					} );
 
 				} );

+ 1 - 0
examples/webgpu_xr_native_layers.html

@@ -481,6 +481,7 @@
 				guiCamera.top = bbox.max.y;
 				guiCamera.bottom = bbox.min.y;
 				guiCamera.updateProjectionMatrix();
+
 			}
 
 			function renderGui() {

+ 4 - 4
examples/webxr_ar_camera_access.html

@@ -64,7 +64,7 @@
 				const boxGeometry = new THREE.BoxGeometry( 1, 1, 1 );
 				const boxMaterial = new THREE.MeshStandardMaterial();
 				cube = new THREE.Mesh( boxGeometry, boxMaterial );
-				cube.position.z = -3;
+				cube.position.z = - 3;
 
 				scene.add( cube );
 
@@ -103,21 +103,21 @@
 				const frame = renderer.xr.getFrame();
 				const referenceSpace = renderer.xr.getReferenceSpace();
 
-				if ( !frame || !referenceSpace ) return;
+				if ( ! frame || ! referenceSpace ) return;
 
 				const viewerPose = frame.getViewerPose( referenceSpace );
 
 				if ( ! viewerPose ) return;
 
 				const view = viewerPose.views.find( view => view.camera );
-				
+			
 				const cameraTexture = renderer.xr.getCameraTexture( view.camera );
 
 				if ( cube.material.map === cameraTexture ) return;
 
 				cube.material.map = cameraTexture;
 				cube.material.needsUpdate = true;
-				
+			
 			}
 
 			function animate() {

+ 1 - 1
examples/webxr_xr_haptics.html

@@ -187,7 +187,7 @@
 			}
 
 
-			function handleCollisions( controller ) {
+			function handleCollisions() {
 
 				for ( let i = 0; i < group.children.length; i ++ ) {
 

+ 10 - 8
test/unit/src/objects/BatchedMesh.tests.js

@@ -14,22 +14,24 @@ export default QUnit.module( 'Objects', () => {
 
 			const box = new BoxGeometry( 1, 1, 1 );
 			const material = new MeshBasicMaterial( { color: 0x00ff00 } );
-			
+
 			// initialize and add a geometry into the batched mesh
 			const batchedMesh = new BatchedMesh( 4, 5000, 10000, material );
 			const boxGeometryId = batchedMesh.addGeometry( box );
-			
+
 			// create instances of this geometry
-			let boxInstanceIds = [];
-			for (let i = 0; i < 4; i++){
+			const boxInstanceIds = [];
+			for ( let i = 0; i < 4; i ++ ) {
+
 				boxInstanceIds.push( batchedMesh.addInstance( boxGeometryId ) );
+
 			}
-			
-			batchedMesh.deleteInstance( boxInstanceIds[2] );
-			batchedMesh.deleteInstance( boxInstanceIds[3] );
+
+			batchedMesh.deleteInstance( boxInstanceIds[ 2 ] );
+			batchedMesh.deleteInstance( boxInstanceIds[ 3 ] );
 
 			// shrink the instance count
-			batchedMesh.setInstanceCount(2);
+			batchedMesh.setInstanceCount( 2 );
 
 			assert.ok( batchedMesh.instanceCount === 2, 'instance count unequal 2' );
 

粤ICP备19079148号