From 67dcebc3f6220da790a82e3d5b8cb94754131dd7 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Fri, 10 Sep 2021 16:33:58 +0200 Subject: [PATCH] Examples: Clean up. (#22526) --- examples/jsm/loaders/KTX2Loader.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/examples/jsm/loaders/KTX2Loader.js b/examples/jsm/loaders/KTX2Loader.js index 5671bd5793..3d5fc30b11 100644 --- a/examples/jsm/loaders/KTX2Loader.js +++ b/examples/jsm/loaders/KTX2Loader.js @@ -31,7 +31,7 @@ import { sRGBEncoding, UnsignedByteType } from '../../../build/three.module.js'; -import { WorkerPool } from '../utils/WorkerPool.js' +import { WorkerPool } from '../utils/WorkerPool.js'; const KTX2TransferSRGB = 2; const KTX2_ALPHA_PREMULTIPLIED = 1; @@ -120,7 +120,7 @@ class KTX2Loader extends Loader { binaryLoader.setPath( this.transcoderPath ); binaryLoader.setResponseType( 'arraybuffer' ); binaryLoader.setWithCredentials( this.withCredentials ); - const binaryContent = binaryLoader.loadAsync( 'basis_transcoder.wasm' ) + const binaryContent = binaryLoader.loadAsync( 'basis_transcoder.wasm' ); this.transcoderPending = Promise.all( [ jsContent, binaryContent ] ) .then( ( [ jsContent, binaryContent ] ) => { @@ -145,11 +145,11 @@ class KTX2Loader extends Loader { const worker = new Worker( this.workerSourceURL ); const transcoderBinary = this.transcoderBinary.slice( 0 ); - + worker.postMessage( { type: 'init', config: this.workerConfig, transcoderBinary }, [ transcoderBinary ] ); - + return worker; - + } ); } ); @@ -205,6 +205,7 @@ class KTX2Loader extends Loader { } _createTextureFrom( transcodeResult ) { + const { mipmaps, width, height, format, type, error, dfdTransferFn, dfdFlags } = transcodeResult; if ( type === 'error' ) return Promise.reject( error ); @@ -214,7 +215,7 @@ class KTX2Loader extends Loader { texture.magFilter = LinearFilter; texture.generateMipmaps = false; texture.needsUpdate = true; - texture.encoding = dfdTransferFn === KTX2TransferSRGB ? sRGBEncoding: LinearEncoding; + texture.encoding = dfdTransferFn === KTX2TransferSRGB ? sRGBEncoding : LinearEncoding; texture.premultiplyAlpha = !! ( dfdFlags & KTX2_ALPHA_PREMULTIPLIED ); return texture; @@ -382,7 +383,7 @@ KTX2Loader.BasisWorker = function () { } - if ( !ktx2File.isValid() ) { + if ( ! ktx2File.isValid() ) { cleanup(); throw new Error( 'THREE.KTX2Loader: Invalid or unsupported .ktx2 file' ); @@ -417,7 +418,7 @@ KTX2Loader.BasisWorker = function () { for ( let mip = 0; mip < levels; mip ++ ) { - const levelInfo = ktx2File.getImageLevelInfo( mip, 0, 0 ) + const levelInfo = ktx2File.getImageLevelInfo( mip, 0, 0 ); const mipWidth = levelInfo.origWidth; const mipHeight = levelInfo.origHeight; const dst = new Uint8Array( ktx2File.getImageTranscodedSizeInBytes( mip, 0, 0, transcoderFormat ) ); @@ -429,8 +430,8 @@ KTX2Loader.BasisWorker = function () { 0, transcoderFormat, 0, - -1, - -1, + - 1, + - 1, ); if ( ! status ) { @@ -566,6 +567,6 @@ KTX2Loader.BasisWorker = function () { } -} +}; export { KTX2Loader }; -- GitLab