route-graphics 1.46.1 → 1.48.0

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 CHANGED
@@ -80,6 +80,27 @@ other backend. The selected value is available as `app.rendererType`. Inline
80
80
  shader effects always provide both GLSL and WGSL so the same state works on
81
81
  either backend.
82
82
 
83
+ For scene/editor/preview handoffs, use `await app.reset({ eventHandler })`
84
+ instead of destroying and recreating the renderer. Reset clears the display tree,
85
+ animations, audio playback, keyboard bindings, DOM input controls, cursor state,
86
+ snapshot audio-effect requests, and pending render callbacks while preserving the
87
+ same canvas and GPU context. A render that reset interrupts is reported to the
88
+ previous `eventHandler` as `renderComplete` with `aborted: true`, and the first
89
+ render after a reset calls `onFirstRender` again.
90
+ It accepts runtime initialization overrides, including width/height and plugins;
91
+ renderer backend, fallback policy, and debug mode must remain unchanged.
92
+ Loaded assets stay owned by the instance: use `unloadAssets()` for media no longer
93
+ needed, and `destroy()` when the rendering surface is permanently discarded.
94
+ Serialize reset with asset loading and unloading. This avoids repeated WebGL
95
+ context creation during rapid view changes, which can exhaust WebKit's context
96
+ accounting even after explicit context loss ([WebKit bug 218305](https://bugs.webkit.org/show_bug.cgi?id=218305)).
97
+
98
+ Run `bun run build && node scripts/testRendererReset.mjs` to verify 40 resets in
99
+ Chromium and WebKit reuse one context, clear runtime state, and release the context
100
+ on final destruction, and that reset removes input controls and keyboard
101
+ bindings, stops animations, and keeps pointer events working. CI runs it in the
102
+ browser suite; the `reset-stops-audio` AVT spec covers audio.
103
+
83
104
  `createAssetBufferManager()` may keep image and video assets as direct source
84
105
  URLs when possible, while audio and font assets remain buffer-backed.
85
106
 
@@ -102,6 +123,20 @@ Use `renderComplete` when playback completion is required. The PNG CLI waits
102
123
  for scene readiness before applying `--time`; `--wait-for-render-complete`
103
124
  retains its separate playback-completion meaning.
104
125
 
126
+ `extractBase64()` encodes the frame as a PNG data URL. To scale or re-encode
127
+ the frame instead, such as for a thumbnail, take the same pixels as a canvas
128
+ and skip encoding and decoding a full-size PNG:
129
+
130
+ ```javascript
131
+ const frame = await app.extractCanvas();
132
+ const thumbnail = document.createElement("canvas");
133
+ thumbnail.width = 400;
134
+ thumbnail.height = 225;
135
+ thumbnail.getContext("2d").drawImage(frame, 0, 0, 400, 225);
136
+ ```
137
+
138
+ Both take an optional element label to extract that element alone.
139
+
105
140
  Assets loaded by an app instance can be released after no rendered or
106
141
  transitioning element still references them:
107
142