@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.
33 lines (27 loc) • 998 B
text/typescript
// REMOVE once we switch to TypeScript 5.x
// OffscreenCanvas has a convertToBlob method, but TypeScript 4.x doesn't have the proper types for it.
/** @internal */
export declare type OffscreenCanvasExt = OffscreenCanvas & {
convertToBlob: (options?: any) => Promise<Blob>;
}
// REMOVE once usage of browsers that don't support OffscreenCanvas is low
// Shim for missing OffscreenCanvas in iOS 16.x
if (typeof globalThis !== undefined && !('OffscreenCanvas' in globalThis)) {
// @ts-ignore
globalThis['OffscreenCanvas'] = class OffscreenCanvas {
canvas: HTMLCanvasElement;
constructor(width, height) {
this.canvas = document.createElement("canvas");
this.canvas.width = width;
this.canvas.height = height;
// @ts-ignore
this.canvas.convertToBlob = (type?: string, quality?: any) => {
return new Promise(resolve => {
this.canvas.toBlob(resolve, type, quality);
});
};
// @ts-ignore
return this.canvas;
}
};
}