From c67a2ca30012f89282d28fe66deadbf5ab2a5ca4 Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Thu, 5 Jan 2017 15:15:39 -0500 Subject: [PATCH] Fix issue with binary glTF compressed textures. --- Source/Core/loadKTX.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Core/loadKTX.js b/Source/Core/loadKTX.js index 03622acc8819..85038080d13f 100644 --- a/Source/Core/loadKTX.js +++ b/Source/Core/loadKTX.js @@ -216,7 +216,12 @@ define([ var imageSize = view.getUint32(byteOffset, true); byteOffset += sizeOfUint32; - var texture = new Uint8Array(data, byteOffset, imageSize); + var texture; + if (defined(data.buffer)) { + texture = new Uint8Array(data.buffer, byteOffset, imageSize); + } else { + texture = new Uint8Array(data, byteOffset, imageSize); + } // Some tools use a sized internal format. // See table 2: https://www.opengl.org/sdk/docs/man/html/glTexImage2D.xhtml @@ -263,7 +268,7 @@ define([ // Only use the level 0 mipmap if (PixelFormat.isCompressedFormat(glInternalFormat) && numberOfMipmapLevels > 1) { var levelSize = PixelFormat.compressedTextureSize(glInternalFormat, pixelWidth, pixelHeight); - texture = new Uint8Array(texture.buffer, 0, levelSize); + texture = texture.slice(0, levelSize); } return new CompressedTextureBuffer(glInternalFormat, pixelWidth, pixelHeight, texture);