@null3d/engine 0.1.1 → 0.1.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.
Files changed (63) hide show
  1. package/dist/wasm/single/null3d.js +4 -4
  2. package/dist/wasm/single/null3d_bg.wasm +0 -0
  3. package/dist/wasm/threaded/null3d.js +4 -4
  4. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  5. package/docs/api/reference/engine.md +2 -1
  6. package/docs/cli/null3d.md +60 -4
  7. package/docs/concepts/backends.md +4 -0
  8. package/docs/concepts/quality-presets.md +2 -0
  9. package/docs/errors/E1308.md +31 -0
  10. package/docs/errors/E1404.md +5 -1
  11. package/docs/errors/index.md +1 -0
  12. package/docs/getting-started/cdn.md +1 -1
  13. package/docs/getting-started/first-scene.md +3 -1
  14. package/docs/getting-started/hosting.md +13 -3
  15. package/docs/getting-started/install.md +21 -1
  16. package/docs/getting-started/project-structure.md +1 -1
  17. package/docs/guides/agents.md +12 -9
  18. package/docs/guides/assets-pipeline.md +77 -6
  19. package/docs/guides/content-pages.md +33 -0
  20. package/docs/guides/debugging.md +2 -0
  21. package/docs/guides/deploying.md +5 -1
  22. package/docs/guides/deterministic-simulation.md +5 -2
  23. package/docs/guides/loading-screens.md +4 -0
  24. package/docs/guides/performance.md +2 -0
  25. package/docs/guides/start-time.md +8 -0
  26. package/docs/guides/testing.md +20 -0
  27. package/docs/pages.md +1 -1
  28. package/docs/porting/verification.md +1 -1
  29. package/lib/errors/codes.js +11 -0
  30. package/lib/errors/engine-error.js +1 -1
  31. package/lib/errors/fixes.d.ts +1 -0
  32. package/lib/errors/fixes.js +2 -1
  33. package/lib/generated/shader-permutations.d.ts +6 -0
  34. package/lib/generated/shader-permutations.js +6 -0
  35. package/lib/gpu/device-shaders.d.ts +5 -0
  36. package/lib/gpu/device-shaders.js +10 -1
  37. package/lib/gpu/variants.d.ts +25 -0
  38. package/lib/gpu/variants.js +75 -5
  39. package/lib/gpu/webgl2/backend.d.ts +22 -3
  40. package/lib/gpu/webgl2/backend.js +108 -22
  41. package/lib/gpu/webgl2/programs.d.ts +5 -0
  42. package/lib/gpu/webgl2/programs.js +25 -2
  43. package/lib/gpu/webgpu/backend.d.ts +34 -1
  44. package/lib/gpu/webgpu/backend.js +173 -27
  45. package/lib/gpu/webgpu/pipelines.d.ts +2 -2
  46. package/lib/gpu/webgpu/pipelines.js +15 -15
  47. package/lib/page/engine.d.ts +15 -2
  48. package/lib/page/engine.js +124 -9
  49. package/lib/page/permutation-recording.d.ts +5 -3
  50. package/lib/page/permutation-recording.js +13 -7
  51. package/lib/quality/chooser.d.ts +2 -0
  52. package/lib/quality/chooser.js +4 -0
  53. package/lib/shader-artifact.json +1 -1
  54. package/lib/shared/permutation-words.d.ts +6 -0
  55. package/lib/shared/permutation-words.js +6 -0
  56. package/lib/shared/tier.d.ts +9 -0
  57. package/lib/shared/tier.js +4 -1
  58. package/lib/shared/version.d.ts +1 -1
  59. package/lib/shared/version.js +1 -1
  60. package/lib/workers/protocol.d.ts +29 -0
  61. package/lib/workers/render-worker.js +6 -3
  62. package/lib/workers/sketch-worker.js +6 -3
  63. package/package.json +1 -1
@@ -3754,13 +3754,13 @@ export function writeParticleRecords(id, count, first) {
3754
3754
  function __wbg_get_imports() {
3755
3755
  const import0 = {
3756
3756
  __proto__: null,
3757
- __wbg___null3dWantJobWorkers_10d524ad0ed0e256: function() {
3757
+ __wbg___null3dWantJobWorkers_fb79ee3a7793eeaf: function() {
3758
3758
  globalThis.__null3dWantJobWorkers();
3759
3759
  },
3760
- __wbg_error_d1f27407881ca75b: function(arg0, arg1) {
3760
+ __wbg_error_75431c505258125f: function(arg0, arg1) {
3761
3761
  console.error(getStringFromWasm0(arg0, arg1));
3762
3762
  },
3763
- __wbg_now_5de1fa58eeb98466: function() {
3763
+ __wbg_now_cba0f5047a8baddf: function() {
3764
3764
  const ret = performance.now();
3765
3765
  return ret;
3766
3766
  },
@@ -3971,4 +3971,4 @@ async function __wbg_init(module_or_path) {
3971
3971
 
3972
3972
  export { initSync, __wbg_init as default };
3973
3973
 
3974
- export const coreSources = "51abe3b07231ee49";
3974
+ export const coreSources = "98d22e5dcf6e2cb8";
Binary file
@@ -3754,13 +3754,13 @@ export function writeParticleRecords(id, count, first) {
3754
3754
  function __wbg_get_imports(memory) {
3755
3755
  const import0 = {
3756
3756
  __proto__: null,
3757
- __wbg___null3dWantJobWorkers_10d524ad0ed0e256: function() {
3757
+ __wbg___null3dWantJobWorkers_fb79ee3a7793eeaf: function() {
3758
3758
  globalThis.__null3dWantJobWorkers();
3759
3759
  },
3760
- __wbg_error_d1f27407881ca75b: function(arg0, arg1) {
3760
+ __wbg_error_75431c505258125f: function(arg0, arg1) {
3761
3761
  console.error(getStringFromWasm0(arg0, arg1));
3762
3762
  },
3763
- __wbg_now_5de1fa58eeb98466: function() {
3763
+ __wbg_now_cba0f5047a8baddf: function() {
3764
3764
  const ret = performance.now();
3765
3765
  return ret;
3766
3766
  },
@@ -3987,4 +3987,4 @@ export function releaseInstance() {
3987
3987
  dropMemoryViews();
3988
3988
  }
3989
3989
 
3990
- export const coreSources = "51abe3b07231ee49";
3990
+ export const coreSources = "98d22e5dcf6e2cb8";
Binary file
@@ -280,6 +280,7 @@ type ErrorCode =
280
280
  | 'E1305'
281
281
  | 'E1306'
282
282
  | 'E1307'
283
+ | 'E1308'
283
284
  | 'E1401'
284
285
  | 'E1402'
285
286
  | 'E1403'
@@ -590,7 +591,7 @@ The GPU path the engine draws with: core WebGPU, WebGPU in compatibility mode on
590
591
  ## `VERSION`
591
592
 
592
593
  ```ts
593
- const VERSION: '0.1.1'
594
+ const VERSION: '0.1.3'
594
595
  ```
595
596
 
596
597
  The engine version, which the WebAssembly core and this package always share.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  id: cli/null3d
3
3
  title: "The `null3d` command"
4
- summary: "create, test, bench, check-addon, shot, upgrade, assets, mcp, shaders record."
4
+ summary: "create, test, bench, check-addon, shot, upgrade, assets, mcp, shaders record, shaders verify."
5
5
  ---
6
6
 
7
7
  # The `null3d` command
@@ -30,6 +30,8 @@ The command needs Node 20.19 or later, or Node 22.12 or later, as Vite 8 does.
30
30
  | [`mcp`](#mcp) | Connect a coding agent to the live scene. |
31
31
  | [`check-addon`](#check-addon) | Run the engine's checks for add-ons on a package. |
32
32
  | [`assets`](#assets) | Optimize and convert models and textures. |
33
+ | [`shaders record`](#shaders-record) | Record the shader words that your pages draw with. |
34
+ | [`shaders verify`](#shaders-verify) | Check a production build against its shader list. |
33
35
  | [`upgrade`](#upgrade) | Update a project's packages to one version. |
34
36
  | [Where the commands draw](#where-the-commands-draw) | Which GPU and browser each command uses. |
35
37
 
@@ -581,6 +583,7 @@ flowchart LR
581
583
  bunx @null3d/cli shaders record
582
584
  bunx @null3d/cli shaders record --page / --page /level-2.html --live /
583
585
  bunx @null3d/cli shaders record --live / --scroll
586
+ bunx @null3d/cli shaders record --live / --live-ms 60000
584
587
  bunx @null3d/cli shaders record --base http://localhost:8080 --live /game.html --click "#play"
585
588
  bunx @null3d/cli shaders record --manual --gpu webgl2 --preset low
586
589
  ```
@@ -589,9 +592,14 @@ bunx @null3d/cli shaders record --manual --gpu webgl2 --preset low
589
592
  | --- | --- | --- |
590
593
  | `--base <url>` | The address of a server that serves the pages with a development build of the engine | The command starts the project's own Vite dev server in the current folder |
591
594
  | `--page <path>` | A page to record in hold mode, at the low and high presets on WebGPU and on WebGL2. Repeat it for each page. A path that names its own `hold=` time keeps it | `/`, when no `--live` page is named either |
592
- | `--live <path>` | A page to record live on both GPU paths. It draws for five seconds, and the recorder presses every button of its controls HUD. Repeat it for each page | `/`, when no `--page` is named either |
595
+ | `--live <path>` | A page to record live on both GPU paths. It draws until its word set stops growing, and the recorder presses every button of its controls HUD. Repeat it for each page | `/`, when no `--page` is named either |
596
+ | `--live-ms <ms>` | The least time each live page draws, in milliseconds. A state that arrives with time, such as an idle camera turning a mesh into a fading band, needs a longer time. It does not reach a state that waits for a visitor's action, which `--manual`, `--steps` or a browser test does | 15000 |
597
+ | `--settle-ms <ms>` | How long the word set must stay unchanged before the recorder stops the page | 5000 |
598
+ | `--max-ms <ms>` | The longest time a live page draws before the recorder stops it. It is at least `--live-ms` | 60000 |
593
599
  | `--scroll` | Scrolls each live page down to its end, one window's height at a time. After each step it waits until the page has asked for nothing for half a second, at least one second and at most fifteen | The live pages stay at their top |
600
+ | `--scroll-dwell <ms>` | Rests after each scroll step, for a state that arrives with time | 0 |
594
601
  | `--click <selector>` | An element to press after each page loads, for a page whose engine starts on a click | No element is pressed |
602
+ | `--steps <file>` | A module whose default export, or `steps` export, is a function of `{ page, log, path }` that drives the page through its states. Use it for action-gated and time-based states | The recorder presses the controls HUD instead |
595
603
  | `--extra <words>` | Words to add by hand, as hexadecimal numbers joined by commas, such as `0x10,0x14` | Only the recorded words |
596
604
  | `--out <file>` | The list to write | `shader-permutations.txt` |
597
605
  | `--replace` | Writes the run's words alone | The words join those that the list holds |
@@ -613,7 +621,53 @@ A page that fails gets a second try. A second failure stops the run with the pag
613
621
 
614
622
  With `--manual`, the command opens one page in a window on your screen. Play through its menus, settings and levels, then press Enter in the terminal. Run it on both GPU paths at the low and high presets, as the automatic run records them. A reload starts a new recording, so record each page in a run of its own. A project's browser tests can write the list too, with `saveRecordedWords` from `@null3d/cli/shaders`, as [Record from your browser tests](../guides/assets-pipeline.md#record-from-your-browser-tests) shows.
615
623
 
616
- A production build ignores the recording switch, so a page that `--base` names must come from a development build: the dev server, or `vite build --mode development`. The plugin's `urlSwitches` option also lets a production build read it. Record again after the project gains a feature that draws with a new word. A build whose list lacks a word stops the pipeline that needs it, with a message that names the word.
624
+ A production build ignores the recording switch, so a page that `--base` names must come from a development build: the dev server, or `vite build --mode development`. The plugin's `urlSwitches` option also lets a production build read it.
625
+
626
+ Record again after the project gains a feature that draws with a new word, or a state that arrives later. A build whose list lacks a word skips the pipeline or pass that asks for it and reports the word. Check the build with [`shaders verify`](#shaders-verify).
627
+
628
+ A `--steps` module drives the page in the recorder's own browser. Its function takes the Playwright page, so it can press, wait and read the page as a browser test does:
629
+
630
+ ```js
631
+ // steps.mjs
632
+ export default async function steps({ page }) {
633
+ await page.getByRole('button', { name: 'Play' }).click();
634
+ await page.waitForTimeout(20_000); // a state that arrives with time
635
+ }
636
+ ```
637
+
638
+ ## shaders verify
639
+
640
+ ```mermaid
641
+ flowchart LR
642
+ verify["bunx @null3d/cli<br/>shaders verify"] --> build["A production build<br/>with the shader list"]
643
+ build --> pages["Each page on both<br/>GPU paths, driven<br/>through its states"]
644
+ pages --> word["A missing word fails<br/>the check, with its page<br/>and path"]
645
+ ```
646
+
647
+ `shaders verify` builds your project for production with the shader list that the Vite plugin names. It serves the build and drives each page on both GPU paths. The engine reports each word that the list lacks, and the command fails when a page asks for one. A missed word then fails in CI, not in front of a player.
648
+
649
+ A pipeline or pass whose word is missing is skipped, so the rest of the page still draws.
650
+
651
+ ```sh
652
+ bunx @null3d/cli shaders verify
653
+ bunx @null3d/cli shaders verify --live / --live /game.html --steps ./steps.mjs
654
+ bunx @null3d/cli shaders verify --base https://preview.example.com --live /
655
+ ```
656
+
657
+ | Option | Effect | Without it |
658
+ | --- | --- | --- |
659
+ | `--base <url>` | The address of a server that serves a production build with the project's list | The command builds the project and serves the build |
660
+ | `--live <path>` | A page to drive. Repeat it for each page | `/` |
661
+ | `--click <selector>` | An element to press after each page loads | No element is pressed |
662
+ | `--steps <file>` | A module whose default export, or `steps` export, is a function of `{ page, log, path }` that drives the page through its states | The recorder presses the controls HUD and scrolls, if `--scroll` |
663
+ | `--scroll` | Scrolls each live page down to its end | The live pages stay at their top |
664
+ | `--scroll-dwell <ms>` | Rests after each scroll step, for a state that arrives with time | 0 |
665
+ | `--gpu <path>` | Checks `webgpu` or `webgl2` alone, or both joined by a comma | `webgpu,webgl2` |
666
+ | `--settle-ms <ms>` | Rests after the states are driven, so a late pipeline reports its word | 5000 |
667
+ | `--max-ms <ms>` | The longest a page may draw before the check reads its words | 60000 |
668
+ | `--timeout-ms <ms>` | The longest a page may take to load and start | 120000 |
669
+
670
+ The command prints one line for each page and path, and exits with 1 when any lacks a word. A page that the device cannot start on a path is reported as skipped, and the other pages and paths still run. Run it after the build that ships, with the same list. [When the list lacks a word](../guides/assets-pipeline.md#when-the-list-lacks-a-word) explains what a page does without a word.
617
671
 
618
672
  ## upgrade
619
673
 
@@ -653,13 +707,15 @@ Run it after you upgrade the engine alone, or when a page stops with [E1432](../
653
707
 
654
708
  ## Where the commands draw
655
709
 
656
- `shot`, `test`, `bench`, `check-addon` and `shaders record` draw with Chrome for Testing on your computer's GPU. So does `mcp`, unless `--connect` drives your own Chrome. When the `CI` variable is set, they draw with Playwright's Chromium on SwiftShader, a GPU in software. Most CI machines have no GPU. Set `CI=1` to draw the software GPU's images on your own computer:
710
+ `shot`, `test`, `bench`, `check-addon`, `shaders record` and `shaders verify` draw with Chrome for Testing on your computer's GPU. So does `mcp`, unless `--connect` drives your own Chrome. When the `CI` variable is set, they draw with Playwright's Chromium on SwiftShader, a GPU in software. Most CI machines have no GPU. Set `CI=1` to draw the software GPU's images on your own computer:
657
711
 
658
712
  ```sh
659
713
  CI=1 bunx @null3d/cli shot --out ci-shot.png
660
714
  CI=1 bunx @null3d/cli test --update-references
661
715
  ```
662
716
 
717
+ Both browsers draw the WebGPU path where the device offers it. A test browser of your own needs `--enable-unsafe-webgpu` ([Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path)).
718
+
663
719
  The two draw the edges of objects a little differently, so keep reference images for each. When Playwright's Chromium is missing, the command prints the command that installs it.
664
720
 
665
721
  ### Chrome for Testing
@@ -187,6 +187,10 @@ Some laptops have a separate graphics chip next to the one built into the proces
187
187
 
188
188
  Other switches make one device test the paths of other devices. They cover copied uploads, shader compiles without the parallel compile extension, the 8-bit color path, each WebGL2 depth mode and each compressed texture family. The engine reads them in development builds, or in a production build with the Vite plugin's `urlSwitches` option on.
189
189
 
190
+ A production build can ship the shaders of one path alone. It suits a deployment whose browser always offers that path. The engine then refuses a tier that the build lacks, with [E1308](../errors/E1308.md), even where the browser offers it.
191
+
192
+ `engine.report` still describes the browser, and `engine.capabilities.tier` still names the path that the page draws with. The Vite plugin's `shaders.gpuPaths` option makes such a build, and the build is smaller than one of both paths ([Ship a subset of the GPU paths](../guides/assets-pipeline.md#ship-a-subset-of-the-gpu-paths)).
193
+
190
194
  On WebGL2, uploads read straight from the engine's shared memory. A browser that refuses to read shared memory gets a copy of each upload instead.
191
195
 
192
196
  The switch `?depth=` forces a WebGL2 depth mode: `reversed`, `reversed-gl` or `standard`, where the near plane stores 0 and the far plane 1. A browser without `EXT_clip_control` cannot draw `reversed`, so it draws its own mode instead. Shadow maps hold the same depth values as on WebGPU in `reversed` and `reversed-gl`. In `standard` they would hold them the other way around, so WebGL2 draws no shadows in that mode.
@@ -71,6 +71,8 @@ In the S4 benchmark, an 11-inch iPad Pro held 60 frames per second at Medium whi
71
71
 
72
72
  The GPU path then caps the preset, because WebGL2 and WebGPU's compatibility mode lack features that the heavier presets use. For example, compatibility mode cannot draw multisampled float targets.
73
73
 
74
+ High and Ultra need WebGPU. A WebGL2 page runs Medium at most.
75
+
74
76
  The [highest preset of each GPU path](quality-preset-tables.md#highest-preset-of-each-gpu-path) gives each cap.
75
77
 
76
78
  A page can name a preset instead, such as a preset that a player picked in a menu. The GPU path still caps it:
@@ -0,0 +1,31 @@
1
+ ---
2
+ id: errors/E1308
3
+ title: "E1308: GPU path not in this build"
4
+ generated: true
5
+ summary: "This page's build holds the shaders of one GPU path, and this device would draw with the other. The Vite plugin's shaders.gpuPaths option left the other path out, for a deployment whose browser always offers the shipped one, such as an Electron app whose Chromium draws with WebGPU."
6
+ ---
7
+
8
+ # E1308: GPU path not in this build
9
+
10
+ ## What happened
11
+
12
+ This page's build holds the shaders of one GPU path, and this device would draw with the other. The Vite plugin's shaders.gpuPaths option left the other path out, for a deployment whose browser always offers the shipped one, such as an Electron app whose Chromium draws with WebGPU.
13
+
14
+ ## How to fix it
15
+
16
+ Add 'webgl2' to the Vite plugin's shaders.gpuPaths option and build the page again, for a deployment whose devices may lack WebGPU. A build that ships one GPU path must always offer it.
17
+
18
+ [Where problems appear](../guides/debugging.md#where-problems-appear) says where each kind of error reaches your code.
19
+
20
+ ## Example message
21
+
22
+ The engine prints the part below, then the fix above and a link to this page.
23
+
24
+ ```text
25
+ E1308: this build ships only the WebGPU shaders, and this device would draw with WebGL2. The Vite plugin's shaders.gpuPaths option left WebGL2 out.
26
+ ```
27
+
28
+ ## See also
29
+
30
+ - [Error codes](index.md)
31
+ - [Debugging](../guides/debugging.md)
@@ -11,12 +11,16 @@ summary: "An engine thread, or the drawing on the page, hit an error it could no
11
11
 
12
12
  An engine thread, or the drawing on the page, hit an error it could not handle, such as a trap in the engine core. After the start, the thread stops its loop: the engine draws no new frames, and engine.onFailure receives this error. During the start, createEngine() stops the engine and rejects with this error.
13
13
 
14
+ - The message may quote a failed import of a table of shared shader paragraphs. An older build's module names a fixed table file, so a deploy that mixes builds can pair it with a table from another build. The browser reports that the module does not provide an export that it imports, such as AREA_LIGHTS_SHARED_126.
15
+
14
16
  ## How to fix it
15
17
 
16
- This is an engine bug. Report it with the message and the browser, then destroy the engine and start it again.
18
+ When the message quotes a failed import of a shader table, rebuild the page with this version of the plugin. Or purge the host's cache. Otherwise this is an engine bug: report it with the message and the browser, then destroy the engine and start it again.
17
19
 
18
20
  Report engine bugs on [GitHub Issues](https://github.com/null3d-engine/null3d/issues). Add the full message and [engine.report](../guides/debugging.md#how-the-engine-runs-on-this-device).
19
21
 
22
+ - If an older build's page shows this, rebuild it with this version of the plugin. That version names each table after its content, so the page cannot ask for an old table. A cache purge also removes the old files.
23
+
20
24
  [Where problems appear](../guides/debugging.md#where-problems-appear) says where each kind of error reaches your code.
21
25
 
22
26
  ## Example message
@@ -64,6 +64,7 @@ Codes from E2000 to E9999 belong to add-ons. An add-on's message starts with its
64
64
  | [E1305](E1305.md) | GPU rejected work | The GPU path refused a command that the engine gave it after the start, such as a buffer larger than the device allows. The objects that the command made or drew are missing, and the canvas can stay black. The engine reports the first time this happens on each GPU device, and draws on. |
65
65
  | [E1306](E1306.md) | Safari before 18 | The browser runs the WebKit engine of a Safari before 18, which null3D does not support. Every browser on iPhone and iPad runs WebKit, so Chrome, Edge and Firefox there count too. |
66
66
  | [E1307](E1307.md) | Pipeline not built | After the start, the GPU's driver could not build one pipeline that draws objects of the scene. The objects that draw with it are missing from the pass that the message names, and the engine draws on. |
67
+ | [E1308](E1308.md) | GPU path not in this build | This page's build holds the shaders of one GPU path, and this device would draw with the other. The Vite plugin's shaders.gpuPaths option left the other path out, for a deployment whose browser always offers the shipped one, such as an Electron app whose Chromium draws with WebGPU. |
67
68
 
68
69
  ## Setup, loading and runtime
69
70
 
@@ -71,7 +71,7 @@ A benchmark page may time a production build and still set switches, such as `?g
71
71
 
72
72
  ## One HTML file
73
73
 
74
- Save this page, change the CDN address to your own, and serve it from a web server. A browser refuses the modules and workers of a page opened from a file on disk.
74
+ Save this page, change the CDN address to your own, and serve it from a web server. A browser refuses the modules and workers of a page opened from a file on disk. Serve it over HTTPS or open it as `localhost`; a browser that drives a test needs `--enable-unsafe-webgpu` ([Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path)).
75
75
 
76
76
  ```html
77
77
  <!doctype html>
@@ -122,7 +122,9 @@ The plugin sends the two headers that let the engine's threads share memory, and
122
122
  bunx vite
123
123
  ```
124
124
 
125
- Open the address that Vite prints. `bunx vite build` writes the production files, and `bunx vite preview` serves them with the same headers.
125
+ Open the address that Vite prints. Serve the page over HTTPS or open it as `localhost`, and give the browser WebGPU.
126
+
127
+ [Hosting and cross-origin isolation](hosting.md#during-development) gives the certificate, and [Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path) gives the browser switch. `bunx vite build` writes the production files, and `bunx vite preview` serves them with the same headers.
126
128
 
127
129
  ## Next steps
128
130
 
@@ -194,6 +194,8 @@ The `startsWith` check refuses an address that points outside `dist/`. The game'
194
194
 
195
195
  To check the app, open its developer tools and read `crossOriginIsolated` in the console, or read `engine.capabilities.threaded` in the page's code. Both are `true` when the engine runs threaded.
196
196
 
197
+ An app that controls its browser frame can ship a subset of the GPU paths, which saves most of the shader set's size in its package and installer. Electron's Chromium draws with WebGPU where the device and its driver allow it, and that differs by operating system and Chromium version. Check each system that the app ships on, and test the built app there, before you rely on WebGPU alone ([Ship a subset of the GPU paths](../guides/assets-pipeline.md#ship-a-subset-of-the-gpu-paths)).
198
+
197
199
  ## Send the files with Brotli
198
200
 
199
201
  The engine's shader text compresses well with Brotli, which finds text that repeats far apart. gzip finds only repeats that are close together. So the host's compression changes what a page downloads at its start. On a threaded page, in the default latency mode ([Architecture](../concepts/architecture.md#latency-modes)), the engine's part of the start downloads about:
@@ -258,7 +260,11 @@ Over HTTP/1.1 a browser opens at most six connections to one server, and each la
258
260
 
259
261
  </details>
260
262
 
261
- Vite names the files in `assets/` with a hash of their content, so a file under a given name never changes. Serve them with a long cache lifetime, and serve the HTML page so that browsers check it each time:
263
+ Vite names its own files in `assets/` with a hash of their content. The null3D plugin does the same for the shader copies and the tables of shared shader paragraphs that it emits. Such a file under a given name never changes, and a changed file has a new name.
264
+
265
+ Vite names a page or worker chunk before the plugin edits a copy name inside it. A chunk may therefore keep its name when only a copy changes. A browser that kept an old chunk can then ask for a copy that the new build removed. The engine warns and draws without that shader.
266
+
267
+ Serve one build's files together. Serve them with a long cache lifetime, and serve the HTML page so that browsers check it each time:
262
268
 
263
269
  ```text
264
270
  /assets/*
@@ -410,9 +416,13 @@ The dev server compresses its answers to every request from another device, and
410
416
 
411
417
  </details>
412
418
 
413
- Shared memory and WebGPU also need a secure context: HTTPS, or `localhost`. WebGPU, and so the High and Ultra presets, only exist there. A page served over plain HTTP on a network address silently falls back to WebGL2 at Medium. An Android phone connected by USB can reach your computer's `localhost` through `adb reverse tcp:5173 tcp:5173`.
419
+ Serve every development page and every preview over HTTPS. The exception is a page on `localhost` or `127.0.0.1`, which is a secure context already. A phone or tablet reaches the page over a network address, and that address needs HTTPS. Without a secure context the engine runs single-threaded and falls back to WebGL2 at Medium, with no error.
420
+
421
+ A browser that drives a test must also start with `--enable-unsafe-webgpu`. Playwright's Chromium reports `navigator.gpu` but offers no adapter without that switch, so the engine draws WebGL2. HTTPS alone does not give a test suite WebGPU. [Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path) gives the browser setup.
422
+
423
+ An Android phone connected by USB can reach your computer's `localhost` through `adb reverse tcp:5173 tcp:5173`.
414
424
 
415
- To test on a phone or tablet over your local network, serve HTTPS with a local certificate. Make one with [mkcert](https://github.com/FiloSottile/mkcert), for `localhost` and your computer's network name:
425
+ To test on a phone or tablet over your local network, add a local certificate. Make one with [mkcert](https://github.com/FiloSottile/mkcert), for `localhost` and your computer's network name:
416
426
 
417
427
  ```sh
418
428
  mkdir certs
@@ -52,7 +52,7 @@ Every Vite build of a null3D project needs the plugin, for the dev server and fo
52
52
  - Starts each worker's on-demand imports together with the file that imports them, so a worker does not wait one round trip for each file.
53
53
  - Writes the notices of the third-party code that the engine and the add-ons ship beside the page in each production build. [Hosting](hosting.md#publish-the-third-party-notices) says what to do with them.
54
54
  - Writes the list of the build's files, `null3d-files.json`, beside the page in each production build. A game's service worker caches the files of that list for offline play, as [Hosting](hosting.md#offline-play) shows.
55
- - Copies the engine's compiled shader files into a production build, each as a file of its own. Its `shaders.list` option names a list of the permutation words that your pages draw with. The build then copies only their builds ([Build only the shader permutations you draw with](../guides/assets-pipeline.md#build-only-the-shader-permutations-you-draw-with)).
55
+ - Copies the engine's compiled shader files into a production build, each as a file of its own. Its `shaders.list` option names a list of the permutation words that your pages draw with. The build then copies only their builds ([Build only the shader permutations you draw with](../guides/assets-pipeline.md#build-only-the-shader-permutations-you-draw-with)). Its `shaders.gpuPaths` option ships a subset of the GPU paths, such as WebGPU alone, for an app whose browser always offers them ([Ship a subset of the GPU paths](../guides/assets-pipeline.md#ship-a-subset-of-the-gpu-paths)).
56
56
  - Keeps each of the engine's files a file of its own, so a strict Content-Security-Policy does not block them. Vite still turns your own small files into `data:` addresses, which such a policy blocks.
57
57
 
58
58
  <details>
@@ -68,6 +68,26 @@ The built file of your sketch, and of each add-on's task, names every file that
68
68
 
69
69
  The build's files may come from a CDN, with the HTML page on your own origin. [The engine's files on a CDN](hosting.md#the-engines-files-on-a-cdn) gives the headers and the policy that this needs.
70
70
 
71
+ ## Serve over HTTPS
72
+
73
+ WebGPU and the High and Ultra presets need a secure page. `localhost` and `127.0.0.1` are secure already. A phone or tablet on your network is not, so serve it over HTTPS with a local certificate.
74
+
75
+ Make a certificate for `localhost` and your computer's network name:
76
+
77
+ ```sh
78
+ mkdir certs
79
+ mkcert -cert-file certs/cert.pem -key-file certs/key.pem localhost my-computer.local
80
+ ```
81
+
82
+ Turn on the plugin's `https` option, and keep `certs` out of version control because it holds a private key:
83
+
84
+ ```ts
85
+ // vite.config.ts
86
+ export default defineConfig({ plugins: [null3d({ https: true, certDir: 'certs' })] });
87
+ ```
88
+
89
+ Install mkcert's root certificate on every device that opens the page. A browser that drives a test must also start with `--enable-unsafe-webgpu`, or it draws WebGL2. [Hosting and cross-origin isolation](hosting.md#during-development) gives the certificate steps, and [Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path) gives the browser setup.
90
+
71
91
  ## Run the sketch
72
92
 
73
93
  Write `page.ts` and `sketch.ts` as [Your first scene](first-scene.md) shows, then start Vite:
@@ -35,7 +35,7 @@ bun install
35
35
  bunx vite
36
36
  ```
37
37
 
38
- `create` writes the template's files, and it writes the version of the command into each package pin. It installs nothing, so run `bun install` in the new folder.
38
+ `create` writes the template's files, and it writes the version of the command into each package pin. It installs nothing, so run `bun install` in the new folder. `bunx vite` serves the project on `localhost`, which is a secure context, so WebGPU is available. A browser that drives a test needs `--enable-unsafe-webgpu` ([Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path)).
39
39
 
40
40
  | Option | Effect | Without it |
41
41
  | --- | --- | --- |
@@ -13,12 +13,12 @@ null3D comes with two agent skills. A skill is a folder of instructions that a c
13
13
  | `null3d-develop` | Builds, debugs and speeds up null3D projects, including product and marketing pages |
14
14
  | `null3d-port-threejs` | Ports three.js and React Three Fiber projects to null3D |
15
15
 
16
- Install the skills that match the engine version your project uses. Each release of the engine has its own skills.
16
+ Each release of the engine has its own skills. The links in this page give the latest release's skills. [Other agent tools](#other-agent-tools) shows how to pin an older release.
17
17
 
18
18
  ## Claude Code
19
19
 
20
20
  ```sh
21
- claude plugin marketplace add https://raw.githubusercontent.com/null3d-engine/null3d/main/.claude-plugin/marketplace.json
21
+ claude plugin marketplace add null3d-engine/null3d
22
22
  claude plugin install null3d@null3d
23
23
  ```
24
24
 
@@ -26,20 +26,23 @@ The plugin holds the skills of the latest release, and Claude Code downloads onl
26
26
 
27
27
  ## claude.ai and the Claude desktop app
28
28
 
29
- Each release's page on GitHub has `null3d-develop.zip` and `null3d-port-threejs.zip` attached. Upload each zip where the app lets you add skills.
29
+ Download each skill as a zip and upload it where the app lets you add skills:
30
+
31
+ - [null3d-develop](https://null3d.dev/skills/null3d-develop)
32
+ - [null3d-port-threejs](https://null3d.dev/skills/null3d-port-threejs)
30
33
 
31
34
  ## Other agent tools
32
35
 
33
- The [`skills` command](https://github.com/vercel-labs/skills) installs a skill into many agent tools, including Claude Code, Cursor and OpenCode. Give it the folder of each skill in the release that your project uses:
36
+ The [`skills` command](https://github.com/vercel-labs/skills) installs a skill into many agent tools, including Claude Code, Cursor and OpenCode:
34
37
 
35
38
  ```sh
36
- bunx skills add https://github.com/null3d-engine/null3d/tree/0.1.0/.claude/skills/null3d-develop
37
- bunx skills add https://github.com/null3d-engine/null3d/tree/0.1.0/.claude/skills/null3d-port-threejs
39
+ bunx skills add https://null3d.dev/skills/null3d-develop
40
+ bunx skills add https://null3d.dev/skills/null3d-port-threejs
38
41
  ```
39
42
 
40
- Replace `0.1.0` with your engine version. The command asks which agents to install into, and `-a` names them.
43
+ The command asks which agents to install into, and `-a` names them. These links give the latest release. For an older engine, add its release tag as a last path segment, such as `/skills/null3d-develop/<tag>`.
41
44
 
42
- To install by hand, copy each skill's folder from `.claude/skills/` in the release into your agent's skills folder, and keep the folder's name. Use those copies: the repository's `skills/` folder also holds test material for the skills.
45
+ To install by hand, unzip a skill into your agent's skills folder and keep the folder's name.
43
46
 
44
47
  ## Docs by ID
45
48
 
@@ -54,7 +57,7 @@ An agent checks its work with the `null3d` command, which prints short lines of
54
57
  3. Read the lines that it prints: pass or fail for each check, the reason, and the image files.
55
58
  4. When an image test fails, open the image and its diff. Fix the code, or keep the new image with `bunx @null3d/cli test --update-references` when the change was on purpose.
56
59
 
57
- `bunx @null3d/cli shot` draws one frame of a page, to look at a change that has no test yet.
60
+ `bunx @null3d/cli shot` draws one frame of a page, to look at a change that has no test yet. The command's browser draws the WebGPU path where the device offers it. A browser of your own needs `--enable-unsafe-webgpu` ([Testing your sketch](testing.md#the-browser-must-take-the-webgpu-path)).
58
61
 
59
62
  ## The MCP server
60
63
 
@@ -536,7 +536,8 @@ Build such an app without a list. The build copies the whole set, and each page
536
536
 
537
537
  An app whose content is all in the build can ship a list. Keep the list complete:
538
538
 
539
- - Run your browser tests against the production build with the list. A page that asks for a word that the list lacks stops with an error that names the word, so the suite fails. [Record from your browser tests](#record-from-your-browser-tests) shows how the same tests can write the list.
539
+ - Run `bunx @null3d/cli shaders verify` against the production build with the list. It drives every page on both GPU paths and fails when the engine reports a missing word. [Check the production build](#check-the-production-build) shows the command.
540
+ - Run your browser tests against the production build with the list too. A missing word leaves the pipeline or pass without its shader, and the engine reports the word. [Record from your browser tests](#record-from-your-browser-tests) shows how the same tests can write the list.
540
541
  - Record again after you add a feature, a material or a level. The dev server also warns about a word that the list lacks, as [When the list lacks a word](#when-the-list-lacks-a-word) says.
541
542
 
542
543
  ### Record the list
@@ -549,9 +550,13 @@ bunx @null3d/cli shaders record --page / --live /
549
550
 
550
551
  A held page (`--page`) loads in hold mode at the low and high quality presets, on WebGPU and on WebGL2. A preset turns on a few bits, and each GPU path lists bits of its own. WebGL2 has the morph targets, and WebGPU has the instance index.
551
552
 
552
- A live page (`--live`) loads on both GPU paths and draws for five seconds. The recorder presses every button of the page's controls HUD, when it has one, so the words of those states reach the list. Without either option, the command records `/` both ways. It writes `shader-permutations.txt`, or the file that `--out` names. [The `null3d` command](../cli/null3d.md#shaders-record) lists every option.
553
+ A live page (`--live`) loads on both GPU paths and draws until its word set stops growing. It draws at least fifteen seconds, then until five seconds pass with no new word, and at most sixty seconds. `--live-ms`, `--settle-ms` and `--max-ms` set those times. The recorder presses every button of the page's controls HUD, when it has one, so the words of those states reach the list. Without either option, the command records `/` both ways. It writes `shader-permutations.txt`, or the file that `--out` names. [The `null3d` command](../cli/null3d.md#shaders-record) lists every option.
553
554
 
554
- A page that builds more of its scene as the visitor scrolls needs `--scroll`. The recorder then scrolls each live page down to its end, one window's height at a time. After each step, it waits until the page has asked for nothing for half a second. So each stage that a scroll reveals has loaded its shaders, and its pipelines have asked for their words.
555
+ Some states arrive only after the page has drawn for a while. An idle camera can turn a mesh into a level of detail's fading band. A day and night cycle can change the look. A stage can load after the first frame. Give such a page a longer `--live-ms`, and a longer `--max-ms`, so the recorder is still drawing when the state arrives.
556
+
557
+ A state that waits for a visitor's action needs a person or a test. Play it with `--manual`, or drive it from a browser test, as [Record by hand](#record-by-hand) and [Record from your browser tests](#record-from-your-browser-tests) show. A project can also give the recorder its own steps with `--steps <file>`: a module whose function of `{ page, log, path }` drives the page, so the same steps record and verify its states.
558
+
559
+ A page that builds more of its scene as the visitor scrolls needs `--scroll`. The recorder then scrolls each live page down to its end, one window's height at a time. After each step, it waits until the page has asked for nothing for half a second. `--scroll-dwell <ms>` also rests each step for a state that arrives with time. So each stage that a scroll reveals has loaded its shaders, and its pipelines have asked for their words.
555
560
 
556
561
  A game page that starts its engine on a click needs `--live` pages and `--click <selector>`, such as `--click "#play"`. Pages that another server serves take `--base <url>`. That server must serve a development build, because a production build ignores the recording switch. The [deterministic simulation guide](deterministic-simulation.md#a-production-build-of-a-games-engine-files) gives the full sequence for a game.
557
562
 
@@ -602,6 +607,8 @@ test('plays the first level', async ({ page }) => {
602
607
 
603
608
  The `saveRecordedWords` call ends the page's recording, waits until the engine publishes its words, and adds them to the list. With `{ replace: true }` it writes them alone. The page must run a development build, such as the dev server. A production build ignores the recording switch, unless the plugin's `urlSwitches` option is on. Run the tests on both GPU paths at the low and high presets, as the switches in the address above do for one of them.
604
609
 
610
+ The test browser must take the WebGPU path, or the WebGPU words never reach the list. [Testing your sketch](testing.md#the-browser-must-take-the-webgpu-path) gives the setup.
611
+
605
612
  ### Build with the list
606
613
 
607
614
  Name the list in the plugin's options. The path is relative to Vite's root:
@@ -642,16 +649,34 @@ With null3D 0.1.0's shader set, the builds copied these shader files:
642
649
 
643
650
  A listed word that no shader build of the project holds stops the build, and the message names the word. The builds are those of the engine's set and of the project's own shaders, such as its custom materials and its add-ons' shaders. Such a word comes from a typing mistake, or from a list that another version of the engine recorded. Record the list again.
644
651
 
645
- A page that asks for a word that the list lacks fails the pipeline that needs it. The message names the word, as the list writes it:
652
+ A page that asks for a word that the list lacks draws without it. A pipeline whose word is missing draws nothing, and an engine pass whose shader is missing does nothing. A later pass that reads a skipped pass's target draws from a blank target, so that part of the scene can be lost. The engine reports the word once and keeps drawing.
653
+
654
+ A shader file that fails to load leaves the pipeline or pass without its shader. The engine warns once and draws without it.
655
+
656
+ A table of shared shader paragraphs can also fail to load, and that fault is not a missing word. The browser reports that the module "does not provide an export named ...". This happens to a page that an older version of the plugin built: its modules name a fixed table file. A mixed deploy can then pair that page with a table from another build.
657
+
658
+ Recording the list again does not fix it. Rebuild the page with this version of the plugin, or purge those files from the host's cache. Each table's name carries a hash of its content, so a current build never asks for an old table.
659
+
660
+ The engine publishes each missing word on `window.__null3dMissingWords`, and logs it once:
646
661
 
647
662
  ```text
648
- the shader set holds only the permutation words of the project's shader list, and this pipeline asks for 0x00000010, which the list lacks. Record the pages again with bunx @null3d/cli shaders record so that the word reaches the list, or add 0x00000010 to the list by hand, and build again.
663
+ null3D: engine template 7 asks for the permutation word 0x00000010, which the shader list lacks. The engine draws without it. Record the pages again with bunx @null3d/cli shaders record.
649
664
  ```
650
665
 
666
+ ### Check the production build
667
+
668
+ `shaders verify` builds your project for production with its shader list, serves the build, and drives each page on both GPU paths. It fails when the engine reports a word that the list lacks:
669
+
670
+ ```sh
671
+ bunx @null3d/cli shaders verify --live / --live /game.html --steps ./steps.mjs
672
+ ```
673
+
674
+ `--base <url>` checks a build that another server holds. `--gpu` narrows the paths, and `--click`, `--scroll` and `--steps` drive a page's states. The command names each missing word, the page and the path. Run it in CI after the build that ships, so a missed word fails there and not in front of a player. [The null3D command](../cli/null3d.md#shaders-verify) lists every option.
675
+
651
676
  The dev server names such a word before a build ships the page. It still draws with the whole set. When a page first draws with a word that the list lacks, the terminal and the browser's console show a warning:
652
677
 
653
678
  ```text
654
- null3D: /level.html draws with the permutation word 0x00000010, which the shader list shader-permutations.txt lacks. The dev server draws it, but a production build with this list stops the page with an error that names the word. Record the page again with bunx @null3d/cli shaders record, or add the word by hand with bunx @null3d/cli shaders record --extra 0x00000010.
679
+ null3D: /level.html draws with the permutation word 0x00000010, which the shader list shader-permutations.txt lacks. The dev server draws it, but a production build with this list skips the pipeline or pass that asks for the word and reports it. Record the page again with bunx @null3d/cli shaders record, add the word by hand with bunx @null3d/cli shaders record --extra 0x00000010, or check the build with bunx @null3d/cli shaders verify.
655
680
  ```
656
681
 
657
682
  The terminal shows each word once, until the list changes. The dev server reads the list again after each change, so a word that a new recording adds stops the warning at once. A recording run shows no warning, because it adds its words to the list.
@@ -679,3 +704,49 @@ NULL3D_SHADER_PERMUTATIONS=examples/shader-permutations.txt bun run build
679
704
  Without the variable, or with it empty, `bun run build` compiles every permutation. `bun run examples:build` reads the examples' list this way. With it, the build's cache keys and its input hash include the list, so a changed list builds again.
680
705
 
681
706
  The file that the asset command writes into a model, `asset.extras.NULL3D_shaders`, names the bits that the model turns on. The list here is different: it holds the whole words that your scenes draw with. [Loading screens](loading-screens.md#loading-everything-up-front) describes the model's list.
707
+
708
+ ## Ship a subset of the GPU paths
709
+
710
+ The engine draws with WebGPU where the browser offers it, and with WebGL2 everywhere else ([GPU tiers and backends](../concepts/backends.md)). A production build copies the shaders of both paths, so a host or a desktop app stores both. Most of that is the WebGL2 half: GLSL text is about nine tenths of the shader set's bytes.
711
+
712
+ A deployment that knows which paths its devices offer can ship a subset of them. An Electron app ships Chromium, and Chromium draws with WebGPU where the device lets it. A kiosk, a game inside a WebView, and a game that requires Chrome all know the same. Such a build drops the other path's shader files, and its app package holds no WebGL2 shader files.
713
+
714
+ The build, the app package and the installer get smaller. The download shrinks too, wherever a visitor downloads the whole app. That covers an Electron installer, an archive of the site, and the files that a service worker caches for offline play. A page's own start download does not change, because a page already downloads one path's files.
715
+
716
+ Ship a subset only when every device that runs the app offers the paths it keeps. A page on a device without WebGPU stops with [E1308](../errors/E1308.md), and the engine cannot fall back. Check the devices and the operating systems that the app ships on, with a run of `navigator.gpu` or `engine.capabilities.tier` on each.
717
+
718
+ ```ts
719
+ // vite.config.ts
720
+ import null3d from '@null3d/vite-plugin';
721
+ import { defineConfig } from 'vite';
722
+
723
+ export default defineConfig({
724
+ plugins: [null3d({ shaders: { gpuPaths: ['webgpu'] } })],
725
+ });
726
+ ```
727
+
728
+ The option takes `'webgpu'` and `'webgl2'`, and it must include `'webgpu'`. The shader compiler builds every shader for WebGPU, so a project's own shaders and its add-ons' shaders have no other form. That leaves `['webgpu']` as the one path a build can ship, and leaving the option out ships both.
729
+
730
+ A build with the option does these things:
731
+
732
+ - It copies only the WebGPU files of the engine's shader set. The set keeps its module of loader tables, which name the WebGL2 files, so those tables resolve to one empty module instead.
733
+ - It compiles your own custom shaders and their materials for WebGPU alone, and drops the WebGL2 sets of a custom material, effect or sky layer.
734
+ - It drops the WebGL2 builds of an add-on package's compiled shaders.
735
+ - It writes the shipped paths into the engine's marker module, which is how the engine knows its build's choice.
736
+
737
+ The examples' production build, with the whole set and no list, shows the difference:
738
+
739
+ | GPU paths that the build ships | Shader files | Size |
740
+ | --- | --- | --- |
741
+ | Both, the default | 8,689 | 4,118 MB |
742
+ | WebGPU alone | 1,967 | 330 MB |
743
+
744
+ The files that remain of the dropped path are eight stub modules of about 60 bytes. Each stands in for a module that a page would load by name, and a page never reads one on the WebGPU path.
745
+
746
+ The option combines with `shaders.list`: a build with both copies only the listed words' builds of the shipped path.
747
+
748
+ The dev server keeps both paths, so you can test the other one with `?gpu=webgl2`. When a page draws with a path that a production build does not ship, the dev server warns. It warns in its terminal and in the browser's console, once for each page.
749
+
750
+ Test the production build on the shipped path before you ship it. Run your browser tests against it, and check that each page draws. A test that forces the other path with `?gpu=webgl2` fails with E1308, which is the message that a device without WebGPU shows.
751
+
752
+ The build still holds the JavaScript of both GPU paths, which is a small part of the engine's code. It also holds the engine's own passes' GLSL text, which is in the shared shader module. An add-on that a page loads from a CDN at run time keeps both paths, because the plugin narrows only what the build bundles.
@@ -83,6 +83,39 @@ For a game, the late state has no page content to show. There it changes the mes
83
83
 
84
84
  Later page blocks run after a successful start, inside that `try`.
85
85
 
86
+ ### A scene that builds in stages
87
+
88
+ A scene whose later stages build after the first frame still reveals its canvas at the first frame. A canvas held back for a later stage makes the visitor wait for that stage's whole build.
89
+
90
+ On a Galaxy S24 on the WebGL2 path, a page whose canvas waits for its city stage shows it 6.4 seconds into a repeat visit. Revealed at the first frame, the same canvas shows after 1.8 seconds, and after 3.2 seconds on a first visit.
91
+
92
+ Hide the place of a stage that has not built yet. Fog that lies thick on the ground and thins with height hides empty ground, and leaves a subject high above it in clear air. Once the stage shows, clear the fog over a second or two. Clear it by the clock, because the next warm-up can hold the frames back.
93
+
94
+ ```ts
95
+ // sketch.ts: fog over the place of the city, which builds after the first frame.
96
+ const mist = { color: '#5a6472', density: 0.2, height: 0, heightFalloff: 0.03, background: 1 };
97
+ scene.setFog(mist);
98
+ let clearFrom = 0;
99
+ void engine.firstFrame.then(async () => {
100
+ await buildCity(); // creates the city hidden, warms it up, then shows it
101
+ clearFrom = performance.now();
102
+ });
103
+ return {
104
+ onUpdate() {
105
+ if (clearFrom === 0 || mist.density === 0) return;
106
+ mist.density = 0.2 * Math.max(0, 1 - (performance.now() - clearFrom) / 2000);
107
+ scene.setFog(mist);
108
+ },
109
+ };
110
+ ```
111
+
112
+ - Give the fog the tone of what it hides. Light words over a pale fog do not read, and a darker fog keeps the page's contrast.
113
+ - Start every value that the sketch eases at the page's own state, such as the hour of a day cycle. The first frame shows the ease. Pass the page's state in `sketchData`.
114
+ - After the deadline, the poster shows the finished scene. When the first frame comes later, keep the poster until the canvas shows as much as the poster does.
115
+ - Words styled to stand over the scene need the page's own ink while a loader stands on a plain background. Fade them to their color as the canvas comes in.
116
+ - A fill light that only a plain first view needs fades with that view. A directional light lights every view, and a device that skips the richer stage keeps it.
117
+ - Build each part that an interaction needs in an early stage that every device gets. A part that a lighter device skips takes the interaction with it. For example, a cube that opens round a glowing heart never opens where the heart is missing.
118
+
86
119
  ## Mark a decorative canvas
87
120
 
88
121
  A scene that only decorates gets `aria-hidden="true"`, so screen readers skip it. It takes no keyboard focus. Give it `pointer-events: none` when it does not react to the pointer, so clicks reach the page. [Accessibility](accessibility.md) covers a canvas the visitor operates.