modern-canvas 0.24.10 → 0.24.11

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
@@ -71,13 +71,23 @@ export declare class Engine extends SceneTree {
71
71
  start(): Promise<void>;
72
72
  /**
73
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.
74
+ * allocate. Capped by the GPU's MAX_TEXTURE_SIZE / MAX_RENDERBUFFER_SIZE /
75
+ * MAX_VIEWPORT_DIMS *and* crucially the actual WebGL drawing-buffer size,
76
+ * which the browser/GPU often clamps far below MAX_TEXTURE_SIZE (tied to
77
+ * screen size / VRAM, e.g. ~5760 on a laptop while MAX_TEXTURE_SIZE is 16384).
78
+ * The export reads pixels back from the drawing buffer, so anything beyond it
79
+ * is lost/garbled. Oversized exports are tiled within this budget instead.
79
80
  */
80
81
  protected _maxExportPassSize(): number;
82
+ protected _maxDrawingBufferCache: number;
83
+ /**
84
+ * Probe the real drawing-buffer cap on the *renderer's own* GL context (its
85
+ * attributes — preserveDrawingBuffer / stencil / antialias — lower the cap vs
86
+ * a bare context, so a throwaway probe overestimates). Temporarily sizes the
87
+ * canvas (default framebuffer only, not the FBO textures) to `cap` and reads
88
+ * `drawingBufferWidth/Height`, then restores. Cached per engine.
89
+ */
90
+ protected _maxDrawingBufferSize(cap: number): number;
81
91
  /** Tile budget in logical units (the GPU limit is in device pixels). */
82
92
  protected _exportTileLimit(): number;
83
93
  /** Resize the renderer + root viewport without triggering a render. */
package/dist/index.js CHANGED
@@ -9633,8 +9633,18 @@ var Ja = "WeakRef" in globalThis, Ya = class extends e {
9633
9633
  });
9634
9634
  }
9635
9635
  _maxExportPassSize() {
9636
- let e = this.gl, t = this.renderer.texture.maxTextureSize || e.getParameter(e.MAX_TEXTURE_SIZE) || 4096, n = e.getParameter(e.MAX_RENDERBUFFER_SIZE) || t, r = e.getParameter(e.MAX_VIEWPORT_DIMS), i = r && r.length >= 2 ? Math.min(r[0], r[1]) : t;
9637
- return Math.max(1, Math.min(t, n, i));
9636
+ let e = this.gl, t = this.renderer.texture.maxTextureSize || e.getParameter(e.MAX_TEXTURE_SIZE) || 4096, n = e.getParameter(e.MAX_RENDERBUFFER_SIZE) || t, r = e.getParameter(e.MAX_VIEWPORT_DIMS), i = r && r.length >= 2 ? Math.min(r[0], r[1]) : t, a = Math.max(1, Math.min(t, n, i));
9637
+ return this._maxDrawingBufferSize(a);
9638
+ }
9639
+ _maxDrawingBufferCache = 0;
9640
+ _maxDrawingBufferSize(e) {
9641
+ if (this._maxDrawingBufferCache) return this._maxDrawingBufferCache;
9642
+ let t = e;
9643
+ try {
9644
+ let n = this.gl, r = n.canvas, i = r.width, a = r.height;
9645
+ r.width = e, r.height = e, t = Math.min(n.drawingBufferWidth || e, n.drawingBufferHeight || e), r.width = i, r.height = a;
9646
+ } catch {}
9647
+ return this._maxDrawingBufferCache = Math.max(1, Math.min(e, t));
9638
9648
  }
9639
9649
  _exportTileLimit() {
9640
9650
  let e = this.pixelRatio || 1;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.24.10",
4
+ "version": "0.24.11",
5
5
  "packageManager": "pnpm@10.19.0",
6
6
  "description": "A JavaScript WebGL rendering engine. only the ESM.",
7
7
  "author": "wxm",