modern-canvas 0.24.6 → 0.24.8

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/dist/Engine.d.ts CHANGED
@@ -51,8 +51,42 @@ export declare class Engine extends SceneTree {
51
51
  nextTick(): Promise<void>;
52
52
  waitUntilLoad(): Promise<void>;
53
53
  waitAndRender(delta?: number): Promise<void>;
54
+ /**
55
+ * Like {@link waitAndRender} but without the final `_render`. Used by the
56
+ * export pipeline, where rendering at the full (possibly oversized) logical
57
+ * size would allocate a render target beyond the GPU limit; {@link toPixels}
58
+ * performs the actual (tiled) rendering instead.
59
+ */
60
+ waitUntilProcessed(delta?: number): Promise<void>;
61
+ /**
62
+ * Resize for an export pass. The requested size is remembered as the export
63
+ * output size, but the root viewport + canvas are capped at the GPU limit:
64
+ * the root's RenderTarget texture is reactive and re-uploads (texImage2D) on
65
+ * every size change, so setting it beyond MAX_TEXTURE_SIZE — even just to hold
66
+ * a "logical" size — throws `width or height out of range`. {@link toPixels}
67
+ * tiles within the cap and stitches the full image. Does not render.
68
+ */
69
+ resizeForExport(width: number, height: number): this;
54
70
  render(node?: Node, delta?: number): void;
55
71
  start(): Promise<void>;
72
+ /**
73
+ * Largest dimension (in device pixels) a single offscreen render pass can
74
+ * allocate. The root scene renders into a RenderTarget texture (plus a
75
+ * stencil renderbuffer when masks are used) sized to the canvas, so any
76
+ * export larger than these GPU limits throws
77
+ * `texImage2D: width or height out of range`. Oversized exports are tiled
78
+ * within this budget instead.
79
+ */
80
+ protected _maxExportPassSize(): number;
81
+ /** Tile budget in logical units (the GPU limit is in device pixels). */
82
+ protected _exportTileLimit(): number;
83
+ /** Resize the renderer + root viewport without triggering a render. */
84
+ protected _resizeSilently(width: number, height: number): void;
85
+ /** Full export size (set by {@link resizeForExport}); falls back to the root size. */
86
+ protected _exportWidth: number;
87
+ protected _exportHeight: number;
88
+ get exportWidth(): number;
89
+ get exportHeight(): number;
56
90
  needsChunkReadPixels(): boolean;
57
91
  toPixels(): Uint8ClampedArray<ArrayBuffer>;
58
92
  toImageData(): ImageData;
@@ -1,3 +1,4 @@
1
+ import type { GlUniform } from './GlProgram';
1
2
  export declare class GlProgramData {
2
3
  native: WebGLProgram;
3
4
  /**
@@ -6,5 +7,16 @@ export declare class GlProgramData {
6
7
  * group's data is (re)uploaded to this program.
7
8
  */
8
9
  uniformDirtyGroups: Record<number, number>;
10
+ /**
11
+ * Per-context uniform metadata: introspected name/type/size plus the lazily
12
+ * resolved {@link GlUniform.location} and the shadow copy of the last uploaded
13
+ * value. Both `location` and `value` are specific to THIS linked program in
14
+ * THIS GL context, so they must live here — not on the shared {@link GlProgram},
15
+ * which a module-level (static) Material reuses across multiple renderers/contexts.
16
+ * Storing them on the shared program would let one context clobber another's
17
+ * locations/shadows (e.g. a sampler `uniform1i` silently dropped → the sampler
18
+ * falls back to texture unit 0).
19
+ */
20
+ uniforms: Record<string, GlUniform>;
9
21
  constructor(native: WebGLProgram);
10
22
  }
@@ -36,7 +36,7 @@ export declare class GlShaderSystem extends GlSystem {
36
36
  * the group has not changed since it was last synced to this program.
37
37
  */
38
38
  updateUniformGroup(group: UniformGroup, glProgram: GlProgram): void;
39
- protected _uploadUniforms(glProgram: GlProgram, glProgramData: GlProgramData, uniforms: Record<string, any>): void;
39
+ protected _uploadUniforms(glProgramData: GlProgramData, uniforms: Record<string, any>): void;
40
40
  reset(): void;
41
41
  destroy(): void;
42
42
  }
@@ -1,3 +1,21 @@
1
1
  export declare const PI: number;
2
2
  export declare const PI_2: number;
3
3
  export declare function isPow2(v: number): boolean;
4
+ export interface ExportTile {
5
+ /** Left offset of the tile in the full image (logical units). */
6
+ x: number;
7
+ /** Top offset of the tile in the full image (logical units). */
8
+ y: number;
9
+ /** Tile width (logical units); clamped at the right edge. */
10
+ width: number;
11
+ /** Tile height (logical units); clamped at the bottom edge. */
12
+ height: number;
13
+ }
14
+ /**
15
+ * Split a `width × height` image into a grid of tiles no larger than `limit`
16
+ * on either axis. Used to export images that exceed a single GPU render pass
17
+ * (texture / renderbuffer / viewport limits). Tiles are returned row-major and
18
+ * cover the whole image with no overlap; edge tiles are clamped to the
19
+ * remaining size. Returns an empty array for a degenerate (zero-area) image.
20
+ */
21
+ export declare function planExportTiles(width: number, height: number, limit: number): ExportTile[];