From c21e5a97335a482027c81e9e703f94e1d173eb33 Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Fri, 8 Jan 2021 17:01:47 -0800 Subject: [PATCH] KTX2Loader: Improve readability of level size calculation. --- examples/jsm/loaders/KTX2Loader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/jsm/loaders/KTX2Loader.js b/examples/jsm/loaders/KTX2Loader.js index f743cd400e54fb..1e0cd3650147e3 100644 --- a/examples/jsm/loaders/KTX2Loader.js +++ b/examples/jsm/loaders/KTX2Loader.js @@ -524,8 +524,8 @@ class KTX2Container { for ( var level = 0; level < this.header.levelCount; level ++ ) { - var levelWidth = Math.floor( width / ( 1 << level ) ) || 1; - var levelHeight = Math.floor( height / ( 1 << level ) ) || 1; + var levelWidth = Math.max( 1, Math.floor( width / Math.pow( 2, level ) ) ); + var levelHeight = Math.max( 1, Math.floor( height / Math.pow( 2, level ) ) ); var numImagesInLevel = 1; // TODO(donmccurdy): Support cubemaps, arrays and 3D. var imageOffsetInLevel = 0;