@viji-dev/core 0.13.0 → 0.15.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.
@@ -340,6 +340,7 @@
340
340
  * @property {OffscreenCanvas} canvas - The `OffscreenCanvas` driving the scene. The host owns its lifecycle and dimensions; prefer `useContext()` over touching this directly.
341
341
  * @property {OffscreenCanvasRenderingContext2D} [ctx] - 2D rendering context. `undefined` until `viji.useContext('2d')` is called; afterwards equals the cached context.
342
342
  * @property {WebGLRenderingContext | WebGL2RenderingContext} [gl] - WebGL rendering context. `undefined` until `viji.useContext('webgl')` or `'webgl2'` is called; afterwards equals the cached context.
343
+ * @property {GPUCanvasContext} [gpu] - WebGPU canvas context. `undefined` until `viji.useContext('webgpu')` (or a direct `viji.canvas.getContext('webgpu')`) succeeds; afterwards equals the acquired context. Stays `undefined` on browsers without WebGPU support.
343
344
  * @property {number} width - Current canvas width in pixels. Updates automatically when the host resizes the canvas; read every frame.
344
345
  * @property {number} height - Current canvas height in pixels. Updates automatically when the host resizes the canvas; read every frame.
345
346
  * @property {number} time - Seconds elapsed since the scene started (monotonically increasing float). Use for oscillations and absolute-time effects.
@@ -368,6 +369,7 @@
368
369
  * @property {(type: '2d') => OffscreenCanvasRenderingContext2D} useContext - Selects the 2D canvas rendering context. Returns the same instance on subsequent calls and also stores it on `viji.ctx`. A canvas only supports one context type. If a different context type was already requested, the call returns `null`. Choose ONE type and use it for the entire scene. @example const ctx = viji.useContext('2d'); ctx.fillRect(0, 0, viji.width, viji.height);
369
370
  * @property {(type: 'webgl') => WebGLRenderingContext} useContext - Selects a WebGL 1 rendering context. Returns the same instance on subsequent calls and also stores it on `viji.gl`. A canvas only supports one context type. If a different context type was already requested, the call returns `null`. Choose ONE type and use it for the entire scene.
370
371
  * @property {(type: 'webgl2') => WebGL2RenderingContext} useContext - Selects a WebGL 2 rendering context. Returns the same instance on subsequent calls and also stores it on `viji.gl`. A canvas only supports one context type. If a different context type was already requested, the call returns `null`. Choose ONE type and use it for the entire scene.
372
+ * @property {(type: 'webgpu') => GPUCanvasContext |null} useContext - Selects a WebGPU canvas context. Returns the raw `GPUCanvasContext` and also stores it on `viji.gpu`. Adapter and device acquisition stay in scene code (`navigator.gpu` is available; top-level `await` works), and the scene must call `configure()` on the context before rendering. A canvas only supports one context type. Returns `null` when a different context type was already requested OR when the browser has no WebGPU support, so always guard and provide a fallback. Choose ONE type and use it for the entire scene. @example const gctx = viji.useContext('webgpu'); if (!navigator.gpu || !gctx) { // fall back, e.g. render a message via a 2d scene variant } else { const adapter = await navigator.gpu.requestAdapter(); const device = await adapter.requestDevice(); const format = navigator.gpu.getPreferredCanvasFormat(); gctx.configure({ device, format, alphaMode: 'opaque' }); }
371
373
  */
372
374
 
373
375
  /**