diff --git a/packages/core/src/adapters/EquirectangularAdapter.ts b/packages/core/src/adapters/EquirectangularAdapter.ts index b1d9a2505..f34804474 100644 --- a/packages/core/src/adapters/EquirectangularAdapter.ts +++ b/packages/core/src/adapters/EquirectangularAdapter.ts @@ -236,9 +236,7 @@ export class EquirectangularAdapter extends AbstractAdapter SYSTEM.maxTextureWidth) { const ratio = Math.min(1, SYSTEM.maxCanvasWidth / img.width); - const buffer = document.createElement('canvas'); - buffer.width = img.width * ratio; - buffer.height = img.height * ratio; + const buffer = new OffscreenCanvas(Math.floor(img.width * ratio), Math.floor(img.height * ratio)); const ctx = buffer.getContext('2d'); diff --git a/packages/core/src/utils/psv.ts b/packages/core/src/utils/psv.ts index 1aa75cdbb..ddbd83668 100644 --- a/packages/core/src/utils/psv.ts +++ b/packages/core/src/utils/psv.ts @@ -330,7 +330,7 @@ export function parseAngle(angle: string | number, zeroCenter = false, halfCircl /** * Creates a THREE texture from an image */ -export function createTexture(img: HTMLImageElement | HTMLCanvasElement, mimaps = false): Texture { +export function createTexture(img: TexImageSource, mimaps = false): Texture { const texture = new Texture(img); texture.needsUpdate = true; texture.minFilter = mimaps ? LinearMipmapLinearFilter : LinearFilter; diff --git a/packages/cubemap-adapter/src/CubemapAdapter.ts b/packages/cubemap-adapter/src/CubemapAdapter.ts index 184cb8e7e..72d792781 100644 --- a/packages/cubemap-adapter/src/CubemapAdapter.ts +++ b/packages/cubemap-adapter/src/CubemapAdapter.ts @@ -232,9 +232,7 @@ export class CubemapAdapter extends AbstractAdapter SYSTEM.maxTextureWidth) { const ratio = Math.min(1, SYSTEM.maxCanvasWidth / img.width); - const buffer = document.createElement('canvas'); - buffer.width = img.width * ratio; - buffer.height = img.height * ratio; + const buffer = new OffscreenCanvas(Math.floor(img.width * ratio), Math.floor(img.height * ratio)); const ctx = buffer.getContext('2d'); @@ -267,14 +265,12 @@ export class CubemapAdapter extends AbstractAdapter