Texture resizing to power-of-two sides is slow #105
This commit is contained in:
parent
8f4151fce5
commit
55aafe8d88
@ -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;
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user