@grida/canvas-wasm 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -13
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -9
- package/dist/index.mjs +1 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,23 +12,16 @@ pnpm install @grida/canvas-wasm
|
|
|
12
12
|
import init from "@grida/canvas-wasm";
|
|
13
13
|
|
|
14
14
|
const factory = await init({
|
|
15
|
-
// locate the wasm binary file
|
|
15
|
+
// locate the wasm binary file (location may vary by version)
|
|
16
|
+
// e.g. this will resolve to https://unpkg.com/@grida/canvas-wasm@0.0.2/dist/grida_canvas_wasm.wasm
|
|
16
17
|
locateFile: (path) =>
|
|
17
|
-
`https://unpkg.com/@grida/canvas-wasm@<VERSION
|
|
18
|
+
`https://unpkg.com/@grida/canvas-wasm@<VERSION>/${path}`,
|
|
18
19
|
});
|
|
19
20
|
|
|
20
21
|
// your canvas element
|
|
21
|
-
const canvas = document.
|
|
22
|
-
const
|
|
23
|
-
antialias: true,
|
|
24
|
-
depth: true,
|
|
25
|
-
stencil: true,
|
|
26
|
-
alpha: true,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const scene = factory.createSurface(context, 100, 100);
|
|
22
|
+
const canvas = document.getElementById("canvas") as HTMLCanvasElement;
|
|
23
|
+
const scene = factory.createWebGLCanvasSurface(canvas);
|
|
30
24
|
|
|
31
25
|
// ready to draw
|
|
32
|
-
scene.
|
|
33
|
-
scene.redraw();
|
|
26
|
+
scene.loadDummyScene();
|
|
34
27
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -105,8 +105,7 @@ declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory
|
|
|
105
105
|
declare class ApplicationFactory {
|
|
106
106
|
private readonly module;
|
|
107
107
|
constructor(module: createGridaCanvas.GridaCanvasWasmBindings);
|
|
108
|
-
|
|
109
|
-
createSurface(width: number, height: number): Grida2D;
|
|
108
|
+
createWebGLCanvasSurface(canvas: HTMLCanvasElement): Grida2D;
|
|
110
109
|
}
|
|
111
110
|
declare class Grida2D {
|
|
112
111
|
private ptr;
|
package/dist/index.d.ts
CHANGED
|
@@ -105,8 +105,7 @@ declare function init(opts?: GridaCanvasInitOptions): Promise<ApplicationFactory
|
|
|
105
105
|
declare class ApplicationFactory {
|
|
106
106
|
private readonly module;
|
|
107
107
|
constructor(module: createGridaCanvas.GridaCanvasWasmBindings);
|
|
108
|
-
|
|
109
|
-
createSurface(width: number, height: number): Grida2D;
|
|
108
|
+
createWebGLCanvasSurface(canvas: HTMLCanvasElement): Grida2D;
|
|
110
109
|
}
|
|
111
110
|
declare class Grida2D {
|
|
112
111
|
private ptr;
|
package/dist/index.js
CHANGED
|
@@ -7394,11 +7394,7 @@ var ApplicationFactory = class {
|
|
|
7394
7394
|
constructor(module2) {
|
|
7395
7395
|
this.module = module2;
|
|
7396
7396
|
}
|
|
7397
|
-
|
|
7398
|
-
const canvas = document.getElementById(htmlcanvasid);
|
|
7399
|
-
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
7400
|
-
throw new Error(`Element with id ${htmlcanvasid} is not a <canvas>`);
|
|
7401
|
-
}
|
|
7397
|
+
createWebGLCanvasSurface(canvas) {
|
|
7402
7398
|
const context = canvas.getContext("webgl2", {
|
|
7403
7399
|
antialias: true,
|
|
7404
7400
|
depth: true,
|
|
@@ -7415,10 +7411,6 @@ var ApplicationFactory = class {
|
|
|
7415
7411
|
const ptr = this.module._init(canvas.width, canvas.height);
|
|
7416
7412
|
return new Grida2D(this.module, ptr);
|
|
7417
7413
|
}
|
|
7418
|
-
createSurface(width, height) {
|
|
7419
|
-
const ptr = this.module._init(width, height);
|
|
7420
|
-
return new Grida2D(this.module, ptr);
|
|
7421
|
-
}
|
|
7422
7414
|
};
|
|
7423
7415
|
var ApplicationCommandID = {
|
|
7424
7416
|
ZoomIn: 1,
|
package/dist/index.mjs
CHANGED
|
@@ -7390,11 +7390,7 @@ var ApplicationFactory = class {
|
|
|
7390
7390
|
constructor(module) {
|
|
7391
7391
|
this.module = module;
|
|
7392
7392
|
}
|
|
7393
|
-
|
|
7394
|
-
const canvas = document.getElementById(htmlcanvasid);
|
|
7395
|
-
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
7396
|
-
throw new Error(`Element with id ${htmlcanvasid} is not a <canvas>`);
|
|
7397
|
-
}
|
|
7393
|
+
createWebGLCanvasSurface(canvas) {
|
|
7398
7394
|
const context = canvas.getContext("webgl2", {
|
|
7399
7395
|
antialias: true,
|
|
7400
7396
|
depth: true,
|
|
@@ -7411,10 +7407,6 @@ var ApplicationFactory = class {
|
|
|
7411
7407
|
const ptr = this.module._init(canvas.width, canvas.height);
|
|
7412
7408
|
return new Grida2D(this.module, ptr);
|
|
7413
7409
|
}
|
|
7414
|
-
createSurface(width, height) {
|
|
7415
|
-
const ptr = this.module._init(width, height);
|
|
7416
|
-
return new Grida2D(this.module, ptr);
|
|
7417
|
-
}
|
|
7418
7410
|
};
|
|
7419
7411
|
var ApplicationCommandID = {
|
|
7420
7412
|
ZoomIn: 1,
|