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);