ソースを参照

Remove comments / clean code

Popov72 5 年 前
コミット
804459f7ad

+ 1 - 15
src/Misc/KTX2/KTX2FileReader.ts

@@ -189,11 +189,9 @@ export class KTX2FileReader {
         }
 
         if (header.faceCount > 1) {
-            //throw new Error(`Failed to parse KTX2 file - Cube textures are not currently supported.`);
+            throw new Error(`Failed to parse KTX2 file - Cube textures are not currently supported.`);
         }
 
-        console.log(header);
-
         offsetInFile += hdrReader.byteOffset;
 
         /**
@@ -215,8 +213,6 @@ export class KTX2FileReader {
 
         offsetInFile += levelReader.byteOffset;
 
-        console.log(levels);
-
         /**
          * Get the data format descriptor (DFD) blocks
          */
@@ -275,14 +271,6 @@ export class KTX2FileReader {
             dfdBlock.samples.push(sample);
         }
 
-        console.log(dfdBlock);
-
-        /*if (header.vkFormat !== KhronosTextureContainer2.VK_FORMAT_UNDEFINED &&
-             !(header.supercompressionScheme === supercompressionScheme.BasisLZ ||
-                dfdBlock.colorModel === dfdModel.UASTC)) {
-            throw new Error(`Failed to upload - Only Basis Universal supercompression is currently supported.`);
-        }*/
-
         /**
          * Get the Supercompression Global Data (sgd)
          */
@@ -322,8 +310,6 @@ export class KTX2FileReader {
             sgd.extendedData = new Uint8Array(this._data.buffer, extendedByteOffset, sgd.extendedByteLength);
         }
 
-        console.log("sgd", sgd);
-
     }
 
     private _getImageCount(): number {

+ 0 - 2
src/Misc/KTX2/KTX2WorkerThreadJS.ts

@@ -829,8 +829,6 @@ export function workerFunc() {
             targetFormat = transcodeTarget.RGBA32;
             transcodedFormat = RGBA8Format;
         }
-        targetFormat = transcodeTarget.RGBA32;
-        transcodedFormat = RGBA8Format;
         var transcoder = transcoderMgr.findTranscoder(srcTexFormat, targetFormat);
         if (transcoder === null) {
             throw new Error("no transcoder found to transcode source texture format \"" + sourceTextureFormat[srcTexFormat] + "\" to format \"" + transcodeTarget[targetFormat] + "\"");

+ 6 - 11
src/Misc/KTX2/khronosTextureContainer2.ts

@@ -105,25 +105,20 @@ export class KhronosTextureContainer2 {
     protected _createTexture(data: IDecodedData, internalTexture: InternalTexture) {
         this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D, internalTexture);
 
-        internalTexture.generateMipMaps = false;
-        internalTexture.invertY = false;
-        internalTexture.width = internalTexture.baseWidth = data.width;
-        internalTexture.height = internalTexture.baseHeight = data.height;
-        internalTexture.samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;
-
-        console.log("transcoded format=", data.transcodedFormat);
+        if (data.transcodedFormat === 0x8058 /* RGBA8 */) {
+            internalTexture.type = Constants.TEXTURETYPE_UNSIGNED_BYTE;
+            internalTexture.format = Constants.TEXTUREFORMAT_RGBA;
+        } else {
+            internalTexture.format = data.transcodedFormat;
+        }
 
         for (let t = 0; t < data.mipmaps.length; ++t) {
             let mipmap = data.mipmaps[t];
 
-            if (t !== 0) break;
-
             if (!mipmap || !mipmap.data) {
                 throw new Error("KTX2 container - could not transcode one of the image");
             }
 
-            console.log(`mipmap #${t} byte length=`, mipmap.data.byteLength);
-
             if (data.transcodedFormat === 0x8058 /* RGBA8 */) {
                 // uncompressed RGBA
                 internalTexture.width = internalTexture.baseWidth = mipmap.width;