Skip to content

Commit

Permalink
KTX2Loader: Support mips.
Browse files Browse the repository at this point in the history
  • Loading branch information
Don McCurdy committed Jan 31, 2020
1 parent 187457d commit 37b035d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions examples/jsm/loaders/KTX2Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,11 @@ class KTX2Container {

for ( var level = 0; level < this.header.levelCount; level ++ ) {

var numBlocksX = Math.floor( ( width + ( blockWidth - 1 ) ) / blockWidth );
var numBlocksY = Math.floor( ( height + ( blockHeight - 1 ) ) / blockHeight );
var levelWidth = width / Math.pow( 2, level );
var levelHeight = height / Math.pow( 2, level );

var numBlocksX = Math.floor( ( levelWidth + ( blockWidth - 1 ) ) / blockWidth );
var numBlocksY = Math.floor( ( levelHeight + ( blockHeight - 1 ) ) / blockHeight );

var numImagesInLevel = 1; // TODO(donmccurdy): Support cubemaps.

Expand All @@ -416,7 +419,7 @@ class KTX2Container {
new Uint8Array( this.levels[level].bytes, imageDesc.alphaSliceByteOffset, imageDesc.alphaSliceByteLength ),
targetFormat,
level,
width, height,
levelWidth, levelHeight,
numBlocksX,
numBlocksY,
isVideo,
Expand All @@ -429,7 +432,7 @@ class KTX2Container {

}

mipmaps.push( { data: result.transcodedImage, width: width, height: height } );
mipmaps.push( { data: result.transcodedImage, width: levelWidth, height: levelHeight } );

}

Expand Down

0 comments on commit 37b035d

Please sign in to comment.