Skip to content

Commit

Permalink
Fix issue with binary glTF compressed textures.
Browse files Browse the repository at this point in the history
  • Loading branch information
bagnell committed Jan 5, 2017
1 parent 1eef793 commit c67a2ca
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Source/Core/loadKTX.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c67a2ca

Please sign in to comment.