From 55aafe8d886bf473cbba01b175f0a38f3a2aea4c Mon Sep 17 00:00:00 2001 From: kovacsv Date: Wed, 28 Jul 2021 20:25:55 +0200 Subject: [PATCH] Texture resizing to power-of-two sides is slow #105 --- source/import/importerutils.js | 18 ------------------ source/threejs/threeconverter.js | 1 - 2 files changed, 19 deletions(-) diff --git a/source/import/importerutils.js b/source/import/importerutils.js index b50395a..b4dc250 100644 --- a/source/import/importerutils.js +++ b/source/import/importerutils.js @@ -53,24 +53,6 @@ OV.NextPowerOfTwo = function (x) return parseInt (npot, 10); }; -OV.ResizeImageToPowerOfTwoSides = function (image) -{ - if (OV.IsPowerOfTwo (image.width) && OV.IsPowerOfTwo (image.height)) { - return image; - } - - let width = OV.NextPowerOfTwo (image.width); - let height = OV.NextPowerOfTwo (image.height); - - let canvas = document.createElement ('canvas'); - canvas.width = width; - canvas.height = height; - - let context = canvas.getContext ('2d'); - context.drawImage (image, 0, 0, width, height); - return context.getImageData (0, 0, width, height); -}; - OV.UpdateMaterialTransparency = function (material) { material.transparent = false; diff --git a/source/threejs/threeconverter.js b/source/threejs/threeconverter.js index aa24852..7dc66a1 100644 --- a/source/threejs/threeconverter.js +++ b/source/threejs/threeconverter.js @@ -37,7 +37,6 @@ OV.ConvertModelToThreeMeshes = function (model, params, output, callbacks) let loader = new THREE.TextureLoader (); loader.load (texture.url, (threeTexture) => { SetTextureParameters (texture, threeTexture); - threeTexture.image = OV.ResizeImageToPowerOfTwoSides (threeTexture.image); threeMaterial.needsUpdate = true; onLoad (threeTexture); });