未验证 提交 67dcebc3 编写于 作者: M Michael Herzog 提交者: GitHub

Examples: Clean up. (#22526)

上级 db72a7d8
......@@ -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 };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册