@null3d/engine 0.1.0 → 0.1.1

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 (381) hide show
  1. package/dist/wasm/single/null3d.js +10 -8
  2. package/dist/wasm/single/null3d_bg.wasm +0 -0
  3. package/dist/wasm/threaded/null3d.js +10 -8
  4. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  5. package/docs/api/animation.md +96 -24
  6. package/docs/api/assets.md +99 -29
  7. package/docs/api/cameras.md +38 -7
  8. package/docs/api/controls.md +47 -23
  9. package/docs/api/debug.md +105 -35
  10. package/docs/api/engine.md +108 -32
  11. package/docs/api/feature-draws.md +21 -15
  12. package/docs/api/feature-effects.md +8 -8
  13. package/docs/api/feature-instances.md +68 -17
  14. package/docs/api/features.md +68 -37
  15. package/docs/api/geometry.md +83 -14
  16. package/docs/api/grass.md +55 -13
  17. package/docs/api/impostors.md +92 -50
  18. package/docs/api/input.md +22 -9
  19. package/docs/api/lights.md +67 -16
  20. package/docs/api/lines.md +38 -13
  21. package/docs/api/materials.md +187 -59
  22. package/docs/api/math.md +6 -6
  23. package/docs/api/objects.md +40 -15
  24. package/docs/api/page.md +58 -7
  25. package/docs/api/particles.md +36 -11
  26. package/docs/api/points.md +18 -8
  27. package/docs/api/post.md +57 -23
  28. package/docs/api/quality.md +36 -16
  29. package/docs/api/raycast.md +57 -24
  30. package/docs/api/reference/animation.md +1 -2
  31. package/docs/api/reference/assets.md +7 -4
  32. package/docs/api/reference/cameras.md +3 -2
  33. package/docs/api/reference/controls.md +59 -2
  34. package/docs/api/reference/debug.md +58 -6
  35. package/docs/api/reference/engine.md +39 -10
  36. package/docs/api/reference/feature-draws.md +3 -4
  37. package/docs/api/reference/feature-effects.md +2 -3
  38. package/docs/api/reference/feature-instances.md +5 -4
  39. package/docs/api/reference/features.md +7 -4
  40. package/docs/api/reference/geometry.md +132 -21
  41. package/docs/api/reference/grass.md +62 -2
  42. package/docs/api/reference/impostors.md +120 -16
  43. package/docs/api/reference/input.md +1 -2
  44. package/docs/api/reference/lights.md +4 -3
  45. package/docs/api/reference/lines.md +3 -4
  46. package/docs/api/reference/materials.md +7 -6
  47. package/docs/api/reference/math.md +13 -2
  48. package/docs/api/reference/objects.md +2 -3
  49. package/docs/api/reference/particles.md +31 -6
  50. package/docs/api/reference/points.md +2 -3
  51. package/docs/api/reference/post.md +4 -3
  52. package/docs/api/reference/quality.md +1 -2
  53. package/docs/api/reference/raycast.md +1 -2
  54. package/docs/api/reference/render.md +4 -3
  55. package/docs/api/reference/scene.md +24 -5
  56. package/docs/api/reference/sketch.md +11 -11
  57. package/docs/api/reference/sound.md +33 -2
  58. package/docs/api/reference/splats.md +42 -3
  59. package/docs/api/reference/sprites.md +2 -3
  60. package/docs/api/reference/tasks.md +16 -3
  61. package/docs/api/reference/terrain.md +26 -5
  62. package/docs/api/reference/textures.md +1 -2
  63. package/docs/api/reference/three-compat.md +18 -7
  64. package/docs/api/reference/time.md +1 -2
  65. package/docs/api/reference/ui.md +10 -7
  66. package/docs/api/reference/vertex-draws.md +2 -3
  67. package/docs/api/reference/water.md +78 -5
  68. package/docs/api/reference/wind.md +15 -2
  69. package/docs/api/render.md +67 -25
  70. package/docs/api/scene.md +129 -36
  71. package/docs/api/sketch.md +45 -19
  72. package/docs/api/sound.md +48 -12
  73. package/docs/api/splats.md +42 -15
  74. package/docs/api/sprites.md +8 -6
  75. package/docs/api/tasks.md +31 -22
  76. package/docs/api/terrain.md +44 -12
  77. package/docs/api/textures.md +61 -12
  78. package/docs/api/three-compat.md +15 -7
  79. package/docs/api/time.md +3 -5
  80. package/docs/api/ui.md +18 -10
  81. package/docs/api/vertex-draws.md +13 -12
  82. package/docs/api/water.md +111 -67
  83. package/docs/api/wind.md +61 -15
  84. package/docs/cli/null3d.md +90 -15
  85. package/docs/concepts/architecture.md +69 -23
  86. package/docs/concepts/assets.md +57 -16
  87. package/docs/concepts/backends.md +65 -25
  88. package/docs/concepts/color-management.md +42 -13
  89. package/docs/concepts/culling.md +68 -47
  90. package/docs/concepts/handles.md +14 -5
  91. package/docs/concepts/instances.md +72 -23
  92. package/docs/concepts/large-worlds.md +17 -7
  93. package/docs/concepts/lighting.md +117 -44
  94. package/docs/concepts/lod.md +128 -33
  95. package/docs/concepts/materials.md +43 -12
  96. package/docs/concepts/particle-buffer.md +48 -35
  97. package/docs/concepts/post-processing.md +77 -14
  98. package/docs/concepts/quality-preset-tables.md +3 -2
  99. package/docs/concepts/quality-presets.md +122 -39
  100. package/docs/concepts/render-graph.md +56 -21
  101. package/docs/concepts/render-layers.md +9 -5
  102. package/docs/concepts/shadows.md +96 -25
  103. package/docs/concepts/static-dynamic.md +22 -7
  104. package/docs/cookbook/index.md +163 -119
  105. package/docs/data/threejs-mapping.json +301 -340
  106. package/docs/errors/E1101.md +23 -5
  107. package/docs/errors/E1102.md +11 -3
  108. package/docs/errors/E1103.md +11 -3
  109. package/docs/errors/E1104.md +11 -3
  110. package/docs/errors/E1105.md +13 -5
  111. package/docs/errors/E1106.md +11 -3
  112. package/docs/errors/E1107.md +15 -5
  113. package/docs/errors/E1108.md +11 -3
  114. package/docs/errors/E1109.md +32 -6
  115. package/docs/errors/E1110.md +23 -5
  116. package/docs/errors/E1111.md +11 -3
  117. package/docs/errors/E1112.md +11 -3
  118. package/docs/errors/E1203.md +12 -4
  119. package/docs/errors/E1204.md +11 -3
  120. package/docs/errors/E1205.md +11 -3
  121. package/docs/errors/E1206.md +28 -6
  122. package/docs/errors/E1207.md +11 -3
  123. package/docs/errors/E1208.md +12 -3
  124. package/docs/errors/E1209.md +11 -3
  125. package/docs/errors/E1213.md +27 -5
  126. package/docs/errors/E1214.md +11 -3
  127. package/docs/errors/E1215.md +31 -6
  128. package/docs/errors/E1216.md +31 -6
  129. package/docs/errors/E1217.md +29 -6
  130. package/docs/errors/E1218.md +22 -6
  131. package/docs/errors/E1219.md +11 -3
  132. package/docs/errors/E1220.md +24 -5
  133. package/docs/errors/E1221.md +24 -5
  134. package/docs/errors/E1222.md +11 -3
  135. package/docs/errors/E1223.md +39 -6
  136. package/docs/errors/E1224.md +11 -3
  137. package/docs/errors/E1225.md +11 -3
  138. package/docs/errors/E1301.md +11 -3
  139. package/docs/errors/E1302.md +11 -3
  140. package/docs/errors/E1303.md +11 -3
  141. package/docs/errors/E1304.md +11 -3
  142. package/docs/errors/E1305.md +13 -3
  143. package/docs/errors/E1306.md +11 -3
  144. package/docs/errors/E1307.md +23 -6
  145. package/docs/errors/E1401.md +11 -3
  146. package/docs/errors/E1402.md +13 -5
  147. package/docs/errors/E1403.md +11 -3
  148. package/docs/errors/E1404.md +13 -3
  149. package/docs/errors/E1405.md +15 -4
  150. package/docs/errors/E1406.md +31 -5
  151. package/docs/errors/E1407.md +11 -3
  152. package/docs/errors/E1408.md +11 -3
  153. package/docs/errors/E1409.md +11 -3
  154. package/docs/errors/E1410.md +13 -5
  155. package/docs/errors/E1411.md +11 -3
  156. package/docs/errors/E1412.md +29 -6
  157. package/docs/errors/E1413.md +11 -3
  158. package/docs/errors/E1414.md +11 -3
  159. package/docs/errors/E1415.md +11 -3
  160. package/docs/errors/E1416.md +27 -6
  161. package/docs/errors/E1417.md +11 -3
  162. package/docs/errors/E1418.md +12 -3
  163. package/docs/errors/E1419.md +13 -5
  164. package/docs/errors/E1420.md +11 -3
  165. package/docs/errors/E1421.md +11 -3
  166. package/docs/errors/E1422.md +12 -3
  167. package/docs/errors/E1423.md +12 -3
  168. package/docs/errors/E1424.md +24 -5
  169. package/docs/errors/E1425.md +11 -3
  170. package/docs/errors/E1426.md +11 -3
  171. package/docs/errors/E1430.md +11 -3
  172. package/docs/errors/E1431.md +11 -3
  173. package/docs/errors/E1432.md +11 -3
  174. package/docs/errors/E1433.md +11 -3
  175. package/docs/errors/E1434.md +15 -6
  176. package/docs/errors/E1435.md +11 -3
  177. package/docs/errors/E1436.md +11 -3
  178. package/docs/errors/E1437.md +14 -6
  179. package/docs/errors/E1501.md +41 -6
  180. package/docs/errors/E1502.md +13 -3
  181. package/docs/errors/E1503.md +11 -3
  182. package/docs/errors/E1504.md +11 -3
  183. package/docs/errors/E1505.md +23 -5
  184. package/docs/errors/E1506.md +11 -3
  185. package/docs/errors/index.md +52 -29
  186. package/docs/getting-started/cdn.md +15 -9
  187. package/docs/getting-started/first-scene.md +20 -12
  188. package/docs/getting-started/hosting.md +111 -63
  189. package/docs/getting-started/install.md +39 -24
  190. package/docs/getting-started/network-use.md +31 -21
  191. package/docs/getting-started/project-structure.md +20 -8
  192. package/docs/getting-started/third-party-notices.md +6 -10
  193. package/docs/guides/accessibility.md +4 -4
  194. package/docs/guides/add-ons.md +83 -13
  195. package/docs/guides/agents.md +2 -6
  196. package/docs/guides/assets-pipeline.md +248 -72
  197. package/docs/guides/audio.md +17 -15
  198. package/docs/guides/baked-light-data.md +44 -23
  199. package/docs/guides/car-paint.md +37 -31
  200. package/docs/guides/content-pages.md +53 -29
  201. package/docs/guides/custom-passes.md +59 -17
  202. package/docs/guides/custom-shaders.md +54 -37
  203. package/docs/guides/debugging.md +31 -41
  204. package/docs/guides/deploying.md +6 -27
  205. package/docs/guides/deterministic-simulation.md +23 -16
  206. package/docs/guides/first-use-shaders.md +83 -45
  207. package/docs/guides/lens-kit.md +29 -26
  208. package/docs/guides/loading-screens.md +70 -30
  209. package/docs/guides/multiple-views.md +22 -11
  210. package/docs/guides/performance.md +188 -37
  211. package/docs/guides/phones.md +71 -19
  212. package/docs/guides/physics.md +6 -10
  213. package/docs/guides/screens.md +41 -29
  214. package/docs/guides/start-time.md +120 -85
  215. package/docs/guides/testing.md +137 -98
  216. package/docs/guides/ui-overlays.md +17 -12
  217. package/docs/guides/video-textures.md +14 -13
  218. package/docs/images/api/animation/character.webp +0 -0
  219. package/docs/images/api/animation/look-at-ring.webp +0 -0
  220. package/docs/images/api/animation/morph-tulips.webp +0 -0
  221. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  222. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  223. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  224. package/docs/images/api/debug/debug-shapes.webp +0 -0
  225. package/docs/images/api/debug/levels-view.webp +0 -0
  226. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  227. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  228. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  229. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  230. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  231. package/docs/images/api/geometry/generators.webp +0 -0
  232. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  233. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  234. package/docs/images/api/grass/grass-grove.webp +0 -0
  235. package/docs/images/api/grass/grass-presets.webp +0 -0
  236. package/docs/images/api/grass/grass-shadow.webp +0 -0
  237. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  238. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  239. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  240. package/docs/images/api/lights/spot-cookies.webp +0 -0
  241. package/docs/images/api/lines/lines-lit.webp +0 -0
  242. package/docs/images/api/lines/lines-widths.webp +0 -0
  243. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  244. package/docs/images/api/materials/decals.webp +0 -0
  245. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  246. package/docs/images/api/materials/relief.webp +0 -0
  247. package/docs/images/api/materials/shader-inputs.webp +0 -0
  248. package/docs/images/api/materials/standard-grid.webp +0 -0
  249. package/docs/images/api/materials/subsurface.webp +0 -0
  250. package/docs/images/api/materials/translucency.webp +0 -0
  251. package/docs/images/api/objects/objects-turntable.webp +0 -0
  252. package/docs/images/api/particles/campfire.webp +0 -0
  253. package/docs/images/api/points/galaxy.webp +0 -0
  254. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  255. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  256. package/docs/images/api/render/reflection-mirror.webp +0 -0
  257. package/docs/images/api/render/security-camera.webp +0 -0
  258. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  259. package/docs/images/api/sound/sound-demo.webp +0 -0
  260. package/docs/images/api/splats/splats-demo.webp +0 -0
  261. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  262. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  263. package/docs/images/api/textures/canvas-screen.webp +0 -0
  264. package/docs/images/api/textures/mipmaps.webp +0 -0
  265. package/docs/images/api/vertex-draws/rain.webp +0 -0
  266. package/docs/images/api/water/ocean.webp +0 -0
  267. package/docs/images/api/water/water-demo.webp +0 -0
  268. package/docs/images/api/water/water-rain.webp +0 -0
  269. package/docs/images/api/water/waterfall.webp +0 -0
  270. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  271. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  272. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  273. package/docs/images/concepts/instances/instances.webp +0 -0
  274. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  275. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  276. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  277. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  278. package/docs/images/concepts/lighting/environment.webp +0 -0
  279. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  280. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  281. package/docs/images/concepts/lod/forest.webp +0 -0
  282. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  283. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  284. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  285. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  286. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  287. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  288. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  289. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  290. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  291. package/docs/images/cookbook/index/picking.webp +0 -0
  292. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  293. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  294. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  295. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  296. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  297. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  298. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  299. package/docs/images/index/showcase-island.webp +0 -0
  300. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  301. package/docs/images/shaders/builtins/builtins.webp +0 -0
  302. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  303. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  304. package/docs/images/shots.json +2231 -0
  305. package/docs/index.md +14 -23
  306. package/docs/moves.json +1 -0
  307. package/docs/nav.json +300 -0
  308. package/docs/pages.md +230 -212
  309. package/docs/porting/react-three-fiber.md +2 -6
  310. package/docs/porting/threejs-loop-and-threads.md +1 -5
  311. package/docs/porting/threejs-mapping.md +1248 -234
  312. package/docs/porting/threejs-materials.md +10 -5
  313. package/docs/porting/threejs-overview.md +26 -6
  314. package/docs/porting/threejs-postprocessing.md +2 -6
  315. package/docs/porting/threejs-shaders.md +16 -14
  316. package/docs/porting/threejs-unsupported.md +6 -6
  317. package/docs/porting/verification.md +0 -4
  318. package/docs/shaders/builtins.md +15 -4
  319. package/docs/shaders/library.md +9 -6
  320. package/docs/shaders/surface-functions.md +51 -16
  321. package/docs/shaders/wgsl-rules.md +12 -5
  322. package/lib/debug/debug.d.ts +2 -2
  323. package/lib/debug/draw.d.ts +2 -2
  324. package/lib/debug/draw.js +8 -4
  325. package/lib/debug/overlay-look.d.ts +6 -0
  326. package/lib/debug/overlay-look.js +29 -7
  327. package/lib/debug/overlay.js +15 -11
  328. package/lib/debug/stats-options.d.ts +13 -0
  329. package/lib/debug/stats-panel.d.ts +21 -6
  330. package/lib/debug/stats-panel.js +80 -13
  331. package/lib/errors/codes.d.ts +17 -3
  332. package/lib/errors/codes.js +111 -105
  333. package/lib/errors/fixes.js +18 -18
  334. package/lib/gpu/variants.d.ts +8 -2
  335. package/lib/gpu/variants.js +39 -7
  336. package/lib/gpu/webgl2/programs.js +1 -1
  337. package/lib/gpu/webgpu/pipelines.js +13 -13
  338. package/lib/index.d.ts +1 -1
  339. package/lib/page/capabilities.d.ts +1 -1
  340. package/lib/page/engine.d.ts +14 -5
  341. package/lib/page/engine.js +18 -2
  342. package/lib/page/label-loop.js +9 -4
  343. package/lib/page/stats-switch.js +2 -0
  344. package/lib/page/switches.d.ts +6 -4
  345. package/lib/page/switches.js +20 -4
  346. package/lib/scene/baked-light.d.ts +2 -2
  347. package/lib/scene/fake-call-values.js +2 -2
  348. package/lib/scene/frame-cameras.d.ts +16 -4
  349. package/lib/scene/frame-cameras.js +28 -10
  350. package/lib/scene/gltf.d.ts +1 -1
  351. package/lib/scene/level-rule.d.ts +6 -5
  352. package/lib/scene/level-rule.js +2 -2
  353. package/lib/scene/particles.d.ts +7 -3
  354. package/lib/scene/particles.js +3 -1
  355. package/lib/scene/post.d.ts +3 -2
  356. package/lib/scene/resources.d.ts +15 -9
  357. package/lib/scene/scene.d.ts +18 -2
  358. package/lib/scene/scene.js +47 -5
  359. package/lib/scene/time-of-day.d.ts +10 -5
  360. package/lib/scene/time-of-day.js +11 -7
  361. package/lib/shader-artifact.json +1 -1
  362. package/lib/shared/labels.d.ts +5 -2
  363. package/lib/shared/labels.js +5 -2
  364. package/lib/shared/permutation-words.d.ts +2 -0
  365. package/lib/shared/permutation-words.js +8 -0
  366. package/lib/shared/recording.d.ts +13 -5
  367. package/lib/shared/recording.js +31 -10
  368. package/lib/shared/sketch-data.d.ts +9 -0
  369. package/lib/shared/sketch-data.js +57 -0
  370. package/lib/shared/version.d.ts +1 -1
  371. package/lib/shared/version.js +1 -1
  372. package/lib/sketch/define-sketch.d.ts +16 -7
  373. package/lib/sketch/define-sketch.js +2 -1
  374. package/lib/sketch/runner.d.ts +4 -0
  375. package/lib/sketch/runner.js +5 -0
  376. package/lib/sketch/ui.js +4 -2
  377. package/lib/stats.d.ts +1 -0
  378. package/lib/workers/protocol.d.ts +10 -0
  379. package/lib/workers/render-worker.js +4 -1
  380. package/lib/workers/sketch-worker.js +4 -1
  381. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  // Each error code's fix: the text that ends every EngineError message, and the only part of the
2
- // error table that runtime code needs. The page imports this table and hands it to each worker it
3
- // starts, so the text downloads once, with the page. The rest of each code's docs text is in
4
- // codes.ts, which only the docs generator and the tests import. Codes group by area: 11xx objects
2
+ // error table that runtime code needs. A thread loads the table when it first reports an error, so
3
+ // the text does not weigh on a page's start. The rest of each code's docs text is in codes.ts,
4
+ // which only the docs generator and the tests import. Codes group by area: 11xx objects
5
5
  // and handles, 12xx values, 13xx browsers and GPUs, 14xx setup and loading, 15xx rendering.
6
6
  export const ERROR_FIXES = {
7
7
  E1101: 'Stop using an object after you call destroy() on it. Look for places that still keep a reference, such as arrays of enemies or selection state.',
@@ -12,28 +12,28 @@ export const ERROR_FIXES = {
12
12
  E1106: 'Fix the call that created the object. When the frame applied that call, the engine logged why it failed, such as E1101 for a parent that was already destroyed.',
13
13
  E1107: 'This is an engine bug. Report it with the code that created the object.',
14
14
  E1108: 'Pass a value inside the range that the message gives. For an instance batch, keep counts and indices within the capacity you created it with, or create a larger batch.',
15
- E1109: 'See how near the scene comes to its limit: engine.measure() gives the memory in use in memory.wasmBytes, which does not shrink, so a reading after the first frames is the peak, and engine.mode.memoryMaximumMiB gives the limit. Add ?direct=on to the address to read the draw path that needs the most. To use less, share meshes and create fewer of them, since every mesh passes through the first frame. Use fewer instance rows. Size each batch for the rows it uses, and give a batch colors only when it needs them. Split a mesh of millions of vertices into smaller meshes, or simplify it. Destroy the batches you no longer draw. A scene that needs more memory can ask for a larger maximum with the memory option of createEngine. When a new engine fails to start this way, destroy the engines you no longer use, or keep one engine and detach and attach it. A smaller maximum leaves room for more engines.',
15
+ E1109: 'Measure how near the scene comes to its limit with `engine.measure()`. Compare its `memory.wasmBytes` with `engine.mode.memoryMaximumMiB`, and add `?direct=on` to read the path that needs the most. Use less: share meshes, draw fewer rows, size each batch for its rows, and destroy batches you no longer draw. A scene that still needs more can ask for a larger maximum with the `memory` option of `createEngine()`.',
16
16
  E1110: 'Change a static object with setPosition(), setRotation(), setScale() or another setter: each one marks the object for the engine to update. Code that writes values straight into engine memory needs a dynamic object, which the engine updates in every frame. For a row of a static batch, call markDirty(start, count) on the batch after you write its arrays, or create the batch with dynamic: true. If your code writes no engine memory, this is an engine bug: report it with the message.',
17
17
  E1111: 'Destroy the objects and instance batches that use the mesh or model first, with destroy() on each. Then destroy the mesh or model, in the same frame or later. Destroying the group that scene.instantiate() returned takes the whole copy of a model. To keep an object and drop its mesh, give it another mesh with setMesh() first.',
18
18
  E1112: 'Give a still 2D texture, such as one that assets.loadTexture, textures.fromImageBitmap or textures.fromData makes. A texture that changes every frame needs a cookie of its own, copied in each frame.',
19
- E1203: 'Check the value computed before this call. NaN often comes from dividing zero by zero, or from normalizing a zero-length vector.',
19
+ E1203: 'Check the value computed before this call: NaN often comes from dividing zero by zero, or from normalizing a zero-length vector. Most calls check their numbers only in development builds, and a release build leaves the check out. The bad value then reaches the scene, and the frame draws wrong, or not at all, with no error. Scene queries such as raycasts check in every build.',
20
20
  E1204: "Pass a hex string such as '#4a8cff', a number such as 0x4a8cff, or three linear components from 0 to 1, such as [0.07, 0.26, 1].",
21
21
  E1205: "Use a KeyboardEvent.code name such as 'KeyW' or 'ArrowLeft', or a mouse button from 'Mouse0' to 'Mouse4'. Gamepad names start with 'Gamepad', such as 'GamepadA' or 'GamepadLeftStickUp'. Define an action with input.actions.define() before you use it, and give it a name that no key or button has. Objects take the pointer events 'click', 'pointerdown', 'pointerup', 'pointermove', 'pointerenter' and 'pointerleave'.",
22
- E1206: 'Give positions and normals three numbers per vertex, uvs and uvs1 two, colors three or four, and tangents four. Give three indices per triangle, each below the vertex count. Without indices, use a vertex count that is a multiple of three. Pass normals or computeNormals: true, and pass uvs with computeTangents: true. Replace NaN and Infinity values. Give mesh.updateVertices() the values of every vertex in the array type the mesh was made with, for an attribute the mesh has, and a range within its vertices. A mesh with joints or morph targets takes no updates.',
22
+ E1206: 'Give positions and normals three numbers per vertex, uvs and uvs1 two, colors three or four, and tangents four. Give three indices per triangle, each below the vertex count, or no indices and a vertex count that is a multiple of three. Pass normals or `computeNormals: true`, and pass uvs with `computeTangents: true`. Replace NaN and Infinity values.',
23
23
  E1207: 'Pass a whole number whose bits name the layers: 1 << n is layer n. The operator | joins layers, so (1 << 0) | (1 << 3) is layers 0 and 3. Layers run from 0 to 31.',
24
24
  E1208: "Give options from the texture's docs page, such as wrap: 'repeat', filter: 'nearest' or anisotropy: 8. Give fromDatafour numbers per texel: a Uint8Array for rgba8unorm, and a Uint16Array of half floats or a Float32Array for rgba16float. Resize images larger than textures.maxSize, and decode a closed image again. Encode a KTX2 file flipped instead of passing flipY: true, and load it again instead of updating its texture.",
25
25
  E1209: "Give the material fewer textures. WebGL2 gives each shader stage at least 16 texture units, as many as the device reports, and the engine's lit shader reads most of them, so a custom material's own textures must fit in what is left. Use the standard material's own maps where they draw the effect.",
26
26
  E1213: "Pass only the settings that the call has, each with a value that it takes. The call's docs page lists them.",
27
27
  E1214: "Give fixedRate the fixed steps per second, a number above 0 such as 60 or 120. Give maxFixedSteps a whole number of 1 or more, such as 8. Give downloads an array of the files that the setup loads, each a URL or an address string such as 'models/ship.glb'.",
28
- E1215: 'Add the null3D Vite plugin to vite.config.ts. Write the WGSL in a template literal right after a /* wgsl */ comment, or import it from a .wgsl file. Declare fn surface(input: SurfaceInput) -> Surface, fn vertexOffset(input: VertexInput) -> vec3f or fn lobe(input: LobeInput) -> vec3f in it, with no @vertex or @fragment entry point. For a full shader, give the @vertex entry point an InstanceIn from null3d::mesh. For a draw that makes its own vertices, give it @builtin(vertex_index) and @builtin(instance_index) and no mesh attribute. Give post.addEffect() WGSL that declares fn effect(input: EffectInput) -> vec4f, post.set({ toneMapping }) WGSL that declares fn toneCurve(color: vec3f) -> vec3f, and scene.setSkyLayer() WGSL that declares fn skyLayer(input: SkyLayerInput) -> SkyLayer.',
29
- E1216: 'Use the names of the fields of struct Uniforms in the WGSL. Give an f32 a number, and an i32 or a u32 a whole number. Give a vec2f, vec3f or vec4f an array of 2, 3 or 4 numbers. A vec3f also takes a color. Rename a field that has the name of a standard value, such as color. Give a slot that the WGSL declares as a texture_2d<f32> a texture of one layer, and a slot that it declares as a texture_2d_array<f32> a texture of several layers, from textures.fromData with a depth or a KTX2 file of layers. Give post.setEffectUniform() an effect that post.addEffect() returned.',
30
- E1217: "Give alphaMode 'opaque', 'mask', 'hash' or 'blend', and blending 'normal', 'additive', 'multiply' or 'weighted'. three.js's transparent: true is alphaMode: 'blend', and its alphaTest is alphaMode: 'mask' with alphaCutoff. A custom material takes 'opaque', 'mask', 'hash' or 'blend', and no 'weighted' blending. It takes alphaToCoverage or the hash mode only where its WGSL sets or reads the surface's alpha, such as s.alpha = texel.a in fn surface. A draw that makes its own vertices blends, and its WGSL declares no texture. A material with transmission takes 'opaque', 'mask' or 'blend', not the 'weighted' blending, and a custom one needs WGSL that sets the surface's transmission. A layered material takes no lightMap or specular maps: give clearcoatMap with clearcoatRoughnessMap as one texture, and sheenColorMap with sheenRoughnessMap as one. Give diffuseTransmissionMap and diffuseTransmissionColorMap only with diffuseTransmission, and no specular maps beside them. Give transmissionMap and thicknessMap only with transmission. Each samples a specular slot's texture array at a layer of its own, so a specular map may draw beside them when the two textures share an array, and a thicknessMap refuses a specularColorMap, whose sRGB texture never shares its array. A layered material keeps them beside the layer map of the light map's slot, but not beside a layer map of the array that one of them samples: transmissionMap samples the specular intensity slot's array, and thicknessMap the specular color slot's. Give diffuseTransmission without a clear coat, a sheen or the 'weighted' blending. A material's layer maps come from one family: the coat's and the sheen's, or iridescence's and the anisotropy's, since they take the same slots. Give an anisotropy map, and another map that gives the surface's texture coordinates. A custom material with diffuseTransmission needs WGSL that sets the surface's diffuseTransmission. Give subsurfaceRadius to materials.standard: a custom material draws no subsurface blur. Give a custom material that declares a coverage function alphaMode 'mask', or 'blend' with the alphaCutoff that its caster tests.",
31
- E1218: "Use the names in animator.clips, and the joint names of the model's skeleton. Give layers whole numbers from 0 to 3, weights from 0 to 1, and fades of 0 or more seconds. Call animator() only on an object that a glTF file with animations created. Name your clip events anything but 'loop' and 'finished', which the animator reports itself. Give setMorphWeight a target number below its geometry's morphTargets, or a name in its morphTargetNames. Trim a clip that holds keys hours apart, or split a long clip into shorter ones.",
28
+ E1215: 'Add the null3D Vite plugin to `vite.config.ts`. Write the WGSL in a template literal right after a `/* wgsl */` comment, or import it from a `.wgsl` file. Give each call the WGSL that its kind declares: the table on this page lists each declaration.',
29
+ E1216: 'Use the names of the fields of `struct Uniforms` in the WGSL, and the names of its texture declarations. Give each value the type that its declaration takes. Rename a field that has the name of a standard value, such as `color`. Give `post.setEffectUniform()` an effect that `post.addEffect()` returned.',
30
+ E1217: "Give alphaMode 'opaque', 'mask', 'hash' or 'blend', and blending 'normal', 'additive', 'multiply' or 'weighted'. three.js's transparent: true is alphaMode: 'blend', and its alphaTest is alphaMode: 'mask' with alphaCutoff. For a conflict between two options, follow the message, or read the rule for each kind of material on the E1217 docs page.",
31
+ E1218: "Use the names in `animator.clips`, and the joint names of the model's skeleton. Call `animator()` only on an object that a glTF file with animations created, and name clip events anything but `loop` and `finished`. Give `setMorphWeight` a target number below its geometry's `morphTargets`, or a name in its `morphTargetNames`. Trim or split a clip that holds keys hours apart, and keep layers, weights and fades inside the range that the message gives.",
32
32
  E1219: "Give each label an id of its own, such as 'hp-12', and pass the same id to engine.labels.bind on the page. Give transform one of 'screen', 'world' or 'billboard', and a rotation only to a billboard label. Untrack labels that you no longer show with ui.untrackLabel. To track more labels at once, raise createEngine's maxLabels option, or maxLabels3d for labels that are planes of the scene.",
33
33
  E1220: "Give render.addPass the options of its kind, such as { kind: 'scene', camera, writes: 'minimap', size: [256, 256] }. Give a compute pass a workgroup size that the shader declares and that a device runs, and a fallback for WebGL2. Give each pass a name and a texture name of its own. Remove passes that no longer draw before you add more.",
34
34
  E1221: 'List the levels from the most detailed down, each with a larger error, a farther distance or a smaller coverage than the one before, at most 15 of them. Make each level from the same kind of arrays as the base mesh, with the same attributes, such as the same texture coordinates and tangents. Give a mesh that poses or moves its levels with setLevels, not buildLevels.',
35
35
  E1222: "Make the grid's texture with LightProbeGridData.toTexture(), which a 3D texture alone holds, or with textures.fromVolumeData(). An image texture, or one made with textures.fromData() and a depth, is a texture array, which the probe grid cannot bind.",
36
- E1223: "Give each feature and output a name of its own. Give a frame point and a kind that go together, such as 'opaque' with 'draw' or 'post' with 'fullscreen'. Keep an order inside its band. Name resources, lighting slots and views from the lists. Give every output a neutral default: 'black', 'white' or 'transparent', and 'black' or 'transparent' for a compute pass. One feature provides each lighting slot. Give each setting's presets a value that its values take, and a governor only with a budget. Give the budget four times in ms above 0. A full-screen effect records at the resolve point, in the main view, reads 'sceneColor' and the depth only when its WGSL reads it with effectDepth, effectViewPosition or effectDistance, and writes 'sceneColor' alone. A sky layer's description records at the background point, as a draw, provides the sky, and draws in the main, scene-pass and reflection views.",
36
+ E1223: 'Give each feature and output a name of its own. Give a frame point and a kind that go together, and keep the order inside its band. Name resources, lighting slots and views from the lists, and give every output a neutral default. One feature provides each lighting slot, and a setting takes the values that its range allows.',
37
37
  E1224: 'Give scene.overrideMaterial a material that draws meshes, from materials.standard(), materials.unlit(), materials.shader() or materials.decal(), or null to draw each mesh with its own material.',
38
38
  E1225: "Give each add-on a namespace of its own: one name at declareAddonNamespace(), claimed once where the add-on's module loads, with the package that owns it. Let its shader library default to that name, keep its error codes inside 2000 to 9999, and give its quality keys names that the engine's table lacks. Give each feature, output and lighting slot a name that no other add-on registers. Two add-ons that share a name cannot load together.",
39
39
  E1301: 'Remove a ?gpu= switch or createEngine gpu option that forces a path this browser lacks. Update the browser, or turn on hardware acceleration in its settings.',
@@ -42,23 +42,23 @@ export const ERROR_FIXES = {
42
42
  E1304: 'Lower the quality preset, use smaller or compressed textures, and share meshes and textures between objects. Destroy objects and textures that the scene no longer shows.',
43
43
  E1305: "Read the message: it quotes the GPU path. A buffer or texture past the device's limits names the limit: make the scene smaller there. Otherwise this is an engine bug: report it with the message and the browser.",
44
44
  E1306: 'Update Safari to version 18 or later. On iPhone and iPad, update iOS or iPadOS to 18 or later, which updates the engine of every browser there.',
45
- E1307: "The engine draws on without those objects. Read the message: it names the pipeline and quotes the driver. When it names a custom material, check that material's WGSL on the device. A shorter shader, with fewer texture reads, loops and calls, gives the driver less to compile. On a device with little memory, use less of it: a lower quality preset, smaller textures and fewer objects. Update the browser and the device's system software. If the message names an engine template, report it with the device.",
45
+ E1307: "Read the message: it names the pipeline and quotes the driver. If it names a custom material, shorten that material's WGSL, with fewer texture reads, loops and calls. On a device with little memory, use a lower quality preset, smaller textures and fewer objects. Update the browser and the device's system software, and report an engine template with the device.",
46
46
  E1401: 'End the sketch module with export default defineSketch(...), and pass that module to createEngine.',
47
47
  E1402: 'Reinstall the engine package so all of its parts come from one version. If you build the engine from source, run bun run build again.',
48
48
  E1403: 'Create objects in the setup function you pass to defineSketch, or later, never when the sketch module loads.',
49
49
  E1404: 'This is an engine bug. Report it with the message and the browser, then destroy the engine and start it again.',
50
- E1405: "Read the message: it names the worker that did not start, and why. The sketch worker also reports an error that your sketch's setup function threw, with that error's message: fix the setup function. Otherwise, check that the page is served with the isolation headers and that the engine files load. Allow the workers in the worker-src of a Content-Security-Policy. For the engine's files on another origin, such as a CDN, the hosting page of the docs gives the headers and the policy. Report the error if it repeats.",
50
+ E1405: "Read the message: it names the worker that did not start, and why. The sketch worker also reports an error that your sketch's setup function threw: fix the setup function. Otherwise, check that the page is served with the isolation headers and that the engine files load. Allow the workers in the `worker-src` of a Content-Security-Policy, and report the error if it repeats.",
51
51
  E1406: "Check that the host serves every file that the build wrote, at the paths that the build gave them. The engine's .wasm files, the KTX2 transcoder's files, the glTF loader's files, the meshopt decoder and the level planner's simplifier are among them. If the page loads at other times, the network dropped: reload the page.",
52
52
  E1407: 'Give the sketch time to hold at in seconds, such as ?hold=1.5 or hold: 1.5. A bare ?hold holds at the time of the hold option, or at 0 without one.',
53
53
  E1408: 'Fix the error that the message quotes. When the message gives a sketch time, the sketch failed at that time, and the console shows the error with its stack.',
54
54
  E1409: 'Give memory.maximumMiB a whole number of MiB from 256 to 4096, such as 2048, or leave the option out for the default of 1024.',
55
55
  E1410: "Pass the sketch as new URL('./sketch.ts', import.meta.url), so that the bundler ships the module and the engine finds it. When the download worked, the module's own code threw the error that the message quotes while the module loaded: fix that error.",
56
56
  E1411: "Check the file's address: a relative address resolves against the page's address, and new URL('./file.png', import.meta.url) resolves against the sketch module's. Check that the server sends the file, and handle the error where the file is optional.",
57
- E1412: 'Give loadTexture and loadImageBitmap a PNG, JPEG or WebP file, or an AVIF file in browsers that decode AVIF. Give loadTexture KTX2 files of 2D ETC1S or UASTC data, as basisu writes them. Give loadJson valid JSON. Check that the server sends the file itself, not an error page. Save KTX2 textures no larger than textures.maxSize on each side.',
57
+ E1412: 'Give `loadTexture` and `loadImageBitmap` a PNG, JPEG or WebP file, or an AVIF file in a browser that decodes AVIF. Give `loadTexture` KTX2 files of 2D ETC1S or UASTC data, as basisu writes them. Give `loadJson` valid JSON, and check that the server sends the file itself, not an error page. Save KTX2 textures no larger than `textures.maxSize` on each side.',
58
58
  E1413: "Serve the file from the same origin as the page, or have its server send Access-Control-Allow-Origin with the page's origin or *. On a page with Cross-Origin-Embedder-Policy: require-corp, the file needs that header too.",
59
59
  E1414: 'Call engine.capture() while the engine runs, before destroy(). When the message names a GPU failure, wait for the engine to recover from it and call capture() again. When it says that the worker did not answer, the thread that draws is stuck, often inside a GPU call that never returned: reload the page, or start another engine on another canvas.',
60
60
  E1415: "Stop the other engine with destroy() and wait for its promise before you start this one. To run both at once, leave out sketchThread: 'main' on one of them, so that its sketch runs in a worker.",
61
- E1416: 'Check that the file is a glTF 2.0 model, as a .glb file or a .gltf file with its buffers and images beside it. Open it in the Khronos glTF Validator, which names the broken part, and export it again from your modelling tool. For a model whose skeleton is too large, export each character to a file of its own. A file that passes a limit on what it decodes to is broken, or holds more than a scene can use. Split it into several files, or simplify its meshes.',
61
+ E1416: 'Check that the file is a glTF 2.0 model: a .glb file, or a .gltf file with its buffers and images beside it. For a broken file, open it in the Khronos glTF Validator and export it again. For a skeleton that is too large, export each character to its own file. For a file over a size limit, split it or simplify its meshes.',
62
62
  E1417: 'Export the model again without the extension that the message names, or import the add-on that the message names and register its handler on assets. Call createInstances with a model that has meshes and no instancing of its own, or with one of its meshes and a material.',
63
63
  E1418: "Add 'wasm-unsafe-eval' to the script-src of the page's Content-Security-Policy, for example script-src 'self' 'wasm-unsafe-eval'. It allows WebAssembly and no JavaScript eval. The hosting page of the docs gives the whole policy that the engine needs.",
64
64
  E1419: "Wait for the other engine's destroy() promise before you start a new engine on its canvas. In React, call destroy() in the effect's cleanup. When the message says that no engine can draw on the canvas again, put a new canvas element in its place.",
@@ -73,11 +73,11 @@ export const ERROR_FIXES = {
73
73
  E1431: "Serve the engine's area-light-tables.bin file at the address that the message names. A build with the null3D Vite plugin copies it beside the engine's code: deploy it with the rest of the build. When the engine's files come from another origin, that server must send Access-Control-Allow-Origin, and the page's connect-src must allow the origin.",
74
74
  E1432: "Run bunx @null3d/cli upgrade in the project's folder, then bun install, so that every null3D package takes one version. An add-on that the project builds itself names the engine version that the project develops against.",
75
75
  E1433: "Install the release of the add-on that matches this engine's plugin interface, or run the project on an engine whose plugin interface the add-on declares. The engine's own add-ons need no range: run bunx @null3d/cli upgrade, then bun install, so that each one takes the engine's version.",
76
- E1434: "Read the fault that the message names in the baked light file. Write version 1 of the format, which docs/guides/baked-light-data.md describes: a JSON object with the marker null3d.baked-light, the version, the kind, and the base64 payloads that its kind needs. Make each payload's length match the counts or the size that the same file gives. Read the file to its end, since a file cut short has no complete JSON.",
76
+ E1434: "Read the fault that the message names in the baked light file. Write version 1 of the format, which https://github.com/null3d-engine/null3d/blob/generated/docs/guides/baked-light-data.md describes: a JSON object with the marker null3d.baked-light, the version, the kind, and the base64 payloads that its kind needs. Make each payload's length match the counts or the size that the same file gives. Read the file to its end, since a file cut short has no complete JSON.",
77
77
  E1435: "Record the session again with the engine that recorded it, or update the engine that reads the file. When the message names a sketch, open the page with that sketch: a replay runs the file's frames on the scene that recorded them. When it names a key or a fixed step rate, the recording came from a sketch that this engine cannot run as it ran. A replay starts at the file's first frame, so a file must come from a session that started at the page's first frame.",
78
78
  E1436: 'Ask for the pick again: the engine started a new GPU device, which answers a new pick. A pick that waits when the device is lost is rejected rather than repeated, because the frame that recorded it drew on the lost device.',
79
- E1437: "Run the command again. A download that broke off, or that something changed on the way, fails the check. If the check fails again, a proxy or a mirror between this computer and Google's storage changes the file, so download without it. On a platform that has no Chrome for Testing build, set CI=1 to draw with Playwright's Chromium on the software GPU, or NULL3D_CHROME=installed to draw with the installed Google Chrome.",
80
- E1501: 'Share meshes and materials between objects instead of creating them per object. Draw many copies of one mesh with an instance batch. Every row of a batch counts toward the culling limit, active or not, so size each batch for the rows it uses. For a large crowd of skinned characters on WebGPU, use models with fewer vertices or fewer copies. Each copy skins its own vertices, even when copies share a mesh. The crowd draws again once it fits.',
79
+ E1437: "Run the command again: a download that broke off, or that something changed on the way, fails the check. If the check fails again, a proxy or a mirror between this computer and Google's storage changes the file, so download without it. A refused archive is a warning, and stops the command only when `NULL3D_CHROME=testing` asks for Chrome for Testing alone. A platform with no Chrome for Testing build draws with the installed Google Chrome, or with Playwright's Chromium when `CI=1` is set.",
80
+ E1501: 'Share meshes, materials and textures between objects instead of creating them per object. Draw many copies of one mesh with an instance batch, and size each batch for the rows it uses. For a large crowd of skinned characters on WebGPU, use models with fewer vertices or fewer copies. The crowd draws again once it fits.',
81
81
  E1502: "Name in reads only the textures that your other passes write, as their writes option spells them. Add the pass that writes a texture before a pass that reads it, and remove a pass that reads a texture before the pass that writes it. If the message names only the engine's own passes, report it with the message, the browser and the quality preset.",
82
82
  E1503: "Give each pass's texture a name that no other pass writes. The engine's own passes write sceneColor, sceneDepth, outlineMask and the other names that render.dumpGraph() shows, so pick another name.",
83
83
  E1504: 'Break the loop: a pass cannot read its own texture. To show a mirror in a mirror, add a pass for the inner mirror first, and let the outer pass read its texture.',
@@ -10,7 +10,13 @@ export declare function variantFor<Pipeline extends string>(shader: ShaderVarian
10
10
  /**
11
11
  * The message for a pipeline whose variant no loaded module holds. A variant that loads on first
12
12
  * use is absent until its module arrives, so only a caller that has waited for every module calls
13
- * this. A set narrowed to a recorded list names the word to add, and a full set names the word
14
- * that its manifest cannot make.
13
+ * this. A set narrowed to a project's list names the word to add, as the list writes it, without
14
+ * the bits that a device fixes. A full set names the word that its manifest cannot make.
15
15
  */
16
16
  export declare function missingVariant(permutation: number, listed?: boolean): string;
17
+ /**
18
+ * The message for an engine pass whose shader, which the device's modules hold from the start, no
19
+ * module holds with the word `permutation`. A set narrowed to a project's list names the word
20
+ * that the list lacks, as `missingVariant` does.
21
+ */
22
+ export declare function missingShader(name: string, permutation: number, listed?: boolean): string;
@@ -3,6 +3,7 @@
3
3
  // backend builds a render pipeline from the variant that the pipeline's permutation word names.
4
4
  import { PERMUTATION_DRAW_INDEX, PERMUTATION_HALF, PERMUTATION_TONE_MAP } from '../generated/gpu.js';
5
5
  import { LISTED_PERMUTATIONS } from '../generated/shader-permutations.js';
6
+ import { DEV } from '../shared/dev.js';
6
7
  /** The variant built with exactly the bits of `permutation`, with output for `target`. */
7
8
  function exactly(shader, permutation, target) {
8
9
  for (const name in shader) {
@@ -36,6 +37,20 @@ export function stopRecordingPermutations() {
36
37
  recorded = undefined;
37
38
  return words;
38
39
  }
40
+ /**
41
+ * In a development build, the words that this thread has reported, and where it reports each new
42
+ * one. The dev server compares them with the project's shader list, so a word that a production
43
+ * build with the list lacks shows while the page runs, not first in the built page.
44
+ */
45
+ let reporting;
46
+ /**
47
+ * @internal In a development build, hands `report` each permutation word that a pipeline finds
48
+ * from now on, once per word, as a recording lists it. A production build reports nothing.
49
+ */
50
+ export function reportPermutations(report) {
51
+ if (DEV)
52
+ reporting = { words: new Set(), report };
53
+ }
39
54
  /**
40
55
  * The variant of a shader for a pipeline's permutation word, with output for `target`, or
41
56
  * undefined when the shader has none. The word never holds the half precision bit, which the
@@ -49,19 +64,36 @@ export function variantFor(shader, permutation, target) {
49
64
  const found = exactly(shader, half, target) ?? exactly(shader, permutation, target);
50
65
  // A recording lists the words that the scene draws with, so a narrowed build builds them. The
51
66
  // bits a device fixes are left out, so one list holds the words of every device module.
52
- if (found !== undefined)
53
- recorded?.add((permutation & ~DEVICE_BITS) >>> 0);
67
+ // A development build reports the same words to the dev server.
68
+ if (found !== undefined) {
69
+ const word = (permutation & ~DEVICE_BITS) >>> 0;
70
+ recorded?.add(word);
71
+ if (DEV && reporting !== undefined && !reporting.words.has(word)) {
72
+ reporting.words.add(word);
73
+ reporting.report(word);
74
+ }
75
+ }
54
76
  return found;
55
77
  }
56
78
  /**
57
79
  * The message for a pipeline whose variant no loaded module holds. A variant that loads on first
58
80
  * use is absent until its module arrives, so only a caller that has waited for every module calls
59
- * this. A set narrowed to a recorded list names the word to add, and a full set names the word
60
- * that its manifest cannot make.
81
+ * this. A set narrowed to a project's list names the word to add, as the list writes it, without
82
+ * the bits that a device fixes. A full set names the word that its manifest cannot make.
61
83
  */
62
84
  export function missingVariant(permutation, listed = LISTED_PERMUTATIONS !== null) {
63
- const word = `0x${(permutation >>> 0).toString(16)}`;
85
+ if (!listed)
86
+ return `the shader set has no variant for the permutation word 0x${(permutation >>> 0).toString(16)}.`;
87
+ const word = `0x${((permutation & ~DEVICE_BITS) >>> 0).toString(16).padStart(8, '0')}`;
88
+ return `the shader set holds only the permutation words of the project's shader list, and this pipeline asks for ${word}, which the list lacks. Record the pages again with bunx @null3d/cli shaders record so that the word reaches the list, or add ${word} to the list by hand, and build again.`;
89
+ }
90
+ /**
91
+ * The message for an engine pass whose shader, which the device's modules hold from the start, no
92
+ * module holds with the word `permutation`. A set narrowed to a project's list names the word
93
+ * that the list lacks, as `missingVariant` does.
94
+ */
95
+ export function missingShader(name, permutation, listed = LISTED_PERMUTATIONS !== null) {
64
96
  return listed
65
- ? `the shader set holds only the permutation words that its recording listed, and this pipeline asks for ${word}, which it lacks. Record the scene again so that the word reaches the list, or add the word to the file by hand.`
66
- : `the shader set has no variant for the permutation word ${word}.`;
97
+ ? `the ${name} shader is missing: ${missingVariant(permutation, true)}`
98
+ : `the device's shader modules have no ${name} shader`;
67
99
  }
@@ -289,7 +289,7 @@ export function createProgram(gl, template, permutation) {
289
289
  const shading = variantFor(template.shader, build, 'glsl')?.glsl?.[template.pipeline];
290
290
  const source = shading && build !== permutation ? { ...shading, fragment: PREPASS_FRAGMENT } : shading;
291
291
  if (!source)
292
- throw new Error(`a render pipeline template: ${missingVariant(permutation)}`);
292
+ throw new Error(`a render pipeline template: ${missingVariant(build)}`);
293
293
  const { program, shaders } = link(gl, source, '');
294
294
  return {
295
295
  program,
@@ -8,7 +8,7 @@ import { DEBUG_LINES_SHADER, DEBUG_VIEW_SHADER, MOTION_VIEW_SHADER, } from '../.
8
8
  import { LINE_VERTICES } from '../line-vertices.js';
9
9
  import { PARTICLE_RECORDS } from '../particle-records.js';
10
10
  import { pipelineName } from '../pipeline-name.js';
11
- import { missingVariant, variantFor } from '../variants.js';
11
+ import { missingShader, missingVariant, variantFor } from '../variants.js';
12
12
  import { plainScale, variantLocations, vertexAttribute, vertexStride, } from '../vertex-format.js';
13
13
  /**
14
14
  * True in development builds, which add the debug views' templates. This file reads the constant
@@ -1693,7 +1693,7 @@ export class Pipelines {
1693
1693
  const build = ownPrepass && !cutoutPrepass ? (permutation & ~PERMUTATION_PREPASS) >>> 0 : permutation;
1694
1694
  const shader = variantFor(t.shader, build, 'wgsl')?.wgsl;
1695
1695
  if (!shader)
1696
- throw new Error(`render template ${template}: ${missingVariant(permutation)}`);
1696
+ throw new Error(`render template ${template}: ${missingVariant(build)}`);
1697
1697
  const module = this.module(t.label, shader);
1698
1698
  const entryPoints = shader.pipelines[t.pipeline];
1699
1699
  const skins = (permutation & PERMUTATION_SKIN) !== 0;
@@ -1837,7 +1837,7 @@ export class Pipelines {
1837
1837
  mipDescriptor(format, entry) {
1838
1838
  const shader = this.mipmap;
1839
1839
  if (!shader)
1840
- throw new Error("the device's shader module has no mip level shader");
1840
+ throw new Error(missingShader('mip level', 0));
1841
1841
  const module = this.module('mipmaps', shader);
1842
1842
  const entryPoints = shader.pipelines[entry];
1843
1843
  return {
@@ -1895,7 +1895,7 @@ export class Pipelines {
1895
1895
  const color = (permutation & PERMUTATION_VERTEX_COLOR) !== 0 ? ' color' : '';
1896
1896
  const shader = variantFor(this.skin, permutation, 'wgsl')?.wgsl;
1897
1897
  if (!shader)
1898
- throw new Error("the device's shader modules have no skinning shader");
1898
+ throw new Error(missingShader('skinning', permutation));
1899
1899
  const constants = this.floatSkinnedDirections ? { [NARROW_DIRECTIONS_ID]: 0 } : undefined;
1900
1900
  return {
1901
1901
  label: `skin${tangent}${color}`,
@@ -1906,7 +1906,7 @@ export class Pipelines {
1906
1906
  if (template === TEMPLATE_CULL && permutation & PERMUTATION_MOTION) {
1907
1907
  const shader = variantFor(this.cullMotion, permutation, 'wgsl')?.wgsl;
1908
1908
  if (!shader)
1909
- throw new Error("the device's shader modules have no motion culling shader");
1909
+ throw new Error(missingShader('motion culling', permutation));
1910
1910
  return {
1911
1911
  label: 'cull motion',
1912
1912
  layout: this.cullLayout,
@@ -1915,7 +1915,7 @@ export class Pipelines {
1915
1915
  }
1916
1916
  if (template === TEMPLATE_CULL) {
1917
1917
  if (!this.cull)
1918
- throw new Error("the device's shader module has no culling shader");
1918
+ throw new Error(missingShader('culling', 0));
1919
1919
  return {
1920
1920
  label: 'cull',
1921
1921
  layout: this.cullLayout,
@@ -1926,7 +1926,7 @@ export class Pipelines {
1926
1926
  if (phase) {
1927
1927
  const shader = variantFor(this.occlusion, 0, 'wgsl')?.wgsl;
1928
1928
  if (!shader)
1929
- throw new Error("the device's shader modules have no occlusion culling shader");
1929
+ throw new Error(missingShader('occlusion culling', 0));
1930
1930
  return {
1931
1931
  label: `occlusion ${phase}`,
1932
1932
  layout: this.cullLayout,
@@ -1936,7 +1936,7 @@ export class Pipelines {
1936
1936
  if (template === TEMPLATE_CLUSTER) {
1937
1937
  const shader = this.cluster ? variantFor(this.cluster, 0, 'wgsl')?.wgsl : undefined;
1938
1938
  if (!shader)
1939
- throw new Error("the device's shader modules have no cluster shader");
1939
+ throw new Error(missingShader('cluster', 0));
1940
1940
  return {
1941
1941
  label: 'cluster cull',
1942
1942
  layout: this.clusterLayout,
@@ -1946,7 +1946,7 @@ export class Pipelines {
1946
1946
  if (template === TEMPLATE_DEPTH_PYRAMID) {
1947
1947
  const shader = variantFor(this.pyramid, 0, 'wgsl')?.wgsl;
1948
1948
  if (!shader)
1949
- throw new Error("the device's shader modules have no depth pyramid shader");
1949
+ throw new Error(missingShader('depth pyramid', 0));
1950
1950
  return {
1951
1951
  label: 'depth pyramid',
1952
1952
  layout: this.pyramidLayout,
@@ -1956,7 +1956,7 @@ export class Pipelines {
1956
1956
  if (template === TEMPLATE_FEATURE_ROWS) {
1957
1957
  const shader = variantFor(this.featureRows, 0, 'wgsl')?.wgsl;
1958
1958
  if (!shader)
1959
- throw new Error("the device's shader modules have no feature rows shader");
1959
+ throw new Error(missingShader('feature rows', 0));
1960
1960
  this.featureRowsLayout ??= this.device.createPipelineLayout({
1961
1961
  bindGroupLayouts: [this.layout(LAYOUT_FEATURE_ROWS)],
1962
1962
  });
@@ -1970,7 +1970,7 @@ export class Pipelines {
1970
1970
  if (exposureEntry) {
1971
1971
  const shader = variantFor(this.exposureHistogram, 0, 'wgsl')?.wgsl;
1972
1972
  if (!shader)
1973
- throw new Error("the device's shader modules have no exposure histogram shader");
1973
+ throw new Error(missingShader('exposure histogram', 0));
1974
1974
  this.exposureLayout ??= this.device.createPipelineLayout({
1975
1975
  bindGroupLayouts: [this.layout(LAYOUT_EXPOSURE)],
1976
1976
  });
@@ -1988,7 +1988,7 @@ export class Pipelines {
1988
1988
  const clear = template === TEMPLATE_LIGHT_DEPTH_CLEAR || template === TEMPLATE_LIGHT_DEPTH_CLEAR_MS;
1989
1989
  const shader = multisampled ? this.lightDepthMs : this.lightDepth;
1990
1990
  if (!shader)
1991
- throw new Error("the device's shader modules have no light depth shader");
1991
+ throw new Error(missingShader('light depth', 0));
1992
1992
  return {
1993
1993
  label: clear ? 'light depth clear' : 'light depth',
1994
1994
  layout: multisampled ? this.lightDepthMsLayout : this.lightDepthLayout,
@@ -2003,7 +2003,7 @@ export class Pipelines {
2003
2003
  throw new Error(`unknown compute template ${template}`);
2004
2004
  const shader = this.lightClusters;
2005
2005
  if (!shader)
2006
- throw new Error("the device's shader module has no light clustering shader");
2006
+ throw new Error(missingShader('light clustering', 0));
2007
2007
  return {
2008
2008
  label: entryPoint,
2009
2009
  layout: this.lightLayout,
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { Debug, DebugGridOptions, DebugLightOptions, DebugView, DebugViewName, } from './debug/debug.js';
2
2
  export type { FrameStats, FrameStatsStep, FrameStatsThread } from './debug/stats.js';
3
- export type { StatsOverlayOptions } from './debug/stats-options.js';
3
+ export type { StatsCorner, StatsOverlayOptions } from './debug/stats-options.js';
4
4
  export type { EngineDebugView } from './debug/view-names.js';
5
5
  export { EngineError } from './errors/engine-error.js';
6
6
  export type { ErrorCode } from './errors/fixes.js';
@@ -31,7 +31,7 @@ export interface WebGPUReport {
31
31
  * True when the start-up probe measured the device drawing a bucket faster with direct draws
32
32
  * than with the engine's indirect draws, so the engine draws directly. The probe runs on a
33
33
  * worker's device, and only on an Apple GPU in WebKit, whose validation of each indirect draw
34
- * the direct path removes (D-174). False on WebGL2.
34
+ * the direct path removes. False on WebGL2.
35
35
  */
36
36
  directDraws: boolean;
37
37
  /** Why the probe chose that draw path, or why it did not measure. */
@@ -33,6 +33,15 @@ export interface EngineOptions {
33
33
  canvas: HTMLCanvasElement;
34
34
  /** The sketch module, which runs in the sketch worker; `new URL('./sketch.ts', import.meta.url)`. */
35
35
  sketch: URL | string;
36
+ /**
37
+ * Start data for the sketch, which its setup reads as `ctx.data`: the state that the page knows
38
+ * before the scene starts, such as the section that the address names, a saved color mode or a
39
+ * level number. It reaches the setup before the first frame, also in hold mode, where no message
40
+ * can. It takes plain JSON data: objects, arrays, strings, finite numbers, booleans and null, up
41
+ * to 64 KiB as JSON. Another value fails with E1213. A recording keeps it, and a replay gives
42
+ * the sketch the recorded data.
43
+ */
44
+ sketchData?: unknown;
36
45
  /**
37
46
  * The quality preset: `auto`, the default, lets the engine choose one for the device, and
38
47
  * `low`, `medium`, `high` or `ultra` names one. The GPU path caps it: WebGL2 and WebGPU's
@@ -200,8 +209,8 @@ export interface EngineOptions {
200
209
  transparent?: boolean;
201
210
  /**
202
211
  * False draws the scene into 8-bit color, where each material's shader applies the output
203
- * transform, instead of HDR color, which the final pass tone maps. Both paths honour a
204
- * material's `toneMapped: false`, and the 8-bit path also honours it on a blended surface. The
212
+ * transform, instead of HDR color, which the final pass tone maps. Both paths honor a
213
+ * material's `toneMapped: false`, and the 8-bit path also honors it on a blended surface. The
205
214
  * default lets the engine pick the path from the device, which draws HDR color wherever it
206
215
  * can. The `?hdr=off` switch takes the 8-bit path too.
207
216
  */
@@ -640,12 +649,12 @@ export interface Engine {
640
649
  */
641
650
  inspect?(call: string, args?: unknown): Promise<unknown>;
642
651
  /**
643
- * Shows an overlay of figures over the top-right corner of the canvas, or hides it with
652
+ * Shows an overlay of figures over a right-hand corner of the canvas, or hides it with
644
653
  * `false`: the GPU path, the frame rates, CPU time per frame of each thread, GPU time, draw
645
654
  * calls, triangles and objects drawn, memory, and the page thread's long tasks and input delay.
646
655
  * Its header is a button with the frame rate, which shows and hides the other figures. Options
647
- * pick whether the overlay starts collapsed to its header; a call on a shown overlay changes
648
- * the options it names. The page draws the overlay and updates it a few times a second, and its
656
+ * pick whether the overlay starts collapsed to its header, and its corner: the top right by
657
+ * default, or the bottom right. A call on a shown overlay changes the options it names. The page draws the overlay and updates it a few times a second, and its
649
658
  * code downloads at the first call. While the other figures show, the engine times one frame in
650
659
  * eleven on the GPU and reads back the counts of the objects that the GPU culls, which costs a
651
660
  * little GPU time. The sketch's `debug.stats` shows and hides the same overlay, and the last
@@ -15,7 +15,7 @@ import { EngineError, errorFixesReady, errorOfMessage } from '../errors/engine-e
15
15
  import { messageOf } from '../errors/message.js';
16
16
  import { FORMAT_CANVAS, PERMUTATION_HALF } from '../generated/gpu.js';
17
17
  import { SHADER_FEATURES } from '../generated/shader-features.js';
18
- import { recordPermutations, stopRecordingPermutations } from '../gpu/variants.js';
18
+ import { recordPermutations, reportPermutations, stopRecordingPermutations } from '../gpu/variants.js';
19
19
  import { maxTargetFps, } from '../quality/check.js';
20
20
  import { choosePreset, crashLowest, crashTier, deviceKind, gpuOcclusionChoice, memoryPreset, textureMemoryCap, withinTier, } from '../quality/chooser.js';
21
21
  import { readDeviceHints } from '../quality/device-hints.js';
@@ -32,6 +32,8 @@ import { KEY_CODES } from '../shared/key-codes.js';
32
32
  import { memoryBytes } from '../shared/memory-views.js';
33
33
  import { createMetricsBuffer, MetricsReader, threadRoles } from '../shared/metrics.js';
34
34
  import { addMeasurementRelease } from '../shared/page-measurement.js';
35
+ import { PERMUTATION_WORD_EVENT } from '../shared/permutation-words.js';
36
+ import { sketchDataText } from '../shared/sketch-data.js';
35
37
  import { clearJobTasks, jobAsker, setJobTasks } from '../shared/task-host.js';
36
38
  import { hearAddonsEarly, onAddonChecked } from '../shared/version.js';
37
39
  import { VIDEO_FOLLOW } from '../shared/videos.js';
@@ -277,6 +279,10 @@ export class EngineWorker {
277
279
  // frame has built the scene's pipelines.
278
280
  this.recording?.answered(reply.role, reply.permutations);
279
281
  return;
282
+ case 'permutation':
283
+ if (DEV)
284
+ announcePermutationWord(reply.word);
285
+ return;
280
286
  case 'sketch-message':
281
287
  events.sketchMessage(reply.name, reply.data);
282
288
  return;
@@ -866,6 +872,7 @@ export async function createEngine(options) {
866
872
  };
867
873
  try {
868
874
  checkPreload(options.preload);
875
+ const sketchData = sketchDataText(options.sketchData);
869
876
  const hold = holdSeconds(options.hold, switches.hold);
870
877
  // A test tool may set a timed script before the page loads. Only hold mode performs it, so a
871
878
  // live engine ignores one left on the page.
@@ -881,7 +888,7 @@ export async function createEngine(options) {
881
888
  }, () => new EngineError('E1419', 'createEngine() got a canvas that another engine draws on, which has not stopped.'));
882
889
  if (canvas.dead)
883
890
  throw new EngineError('E1419', `createEngine() got a canvas that no engine can draw on again: ${canvas.dead}.`);
884
- return await startEngine(options, switches, { hold, holdScript, replay: switches.replay, record: switches.record }, place, canvas, holder, release);
891
+ return await startEngine(options, switches, { hold, holdScript, replay: switches.replay, record: switches.record, sketchData }, place, canvas, holder, release);
885
892
  }
886
893
  catch (error) {
887
894
  release();
@@ -914,6 +921,10 @@ function placement(options, switches) {
914
921
  const main = !threaded || (switches.sketchThread ?? options.sketchThread) === 'main';
915
922
  return { threaded, sketchThread: main ? 'main' : 'worker' };
916
923
  }
924
+ /** Fires the event that hands a permutation word that the page draws with to the dev server. */
925
+ function announcePermutationWord(word) {
926
+ globalThis.dispatchEvent?.(new CustomEvent(PERMUTATION_WORD_EVENT, { detail: word }));
927
+ }
917
928
  /**
918
929
  * Starts the engine with the page's switches. With a hold time or a replay, it resolves once the
919
930
  * last frame is read back, and publishes it.
@@ -1717,6 +1728,9 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
1717
1728
  globalThis.__null3dStopRecording = stopRecording;
1718
1729
  if (recording && renderThread === 'main')
1719
1730
  recordPermutations();
1731
+ // The dev server compares each word that the page draws with against the project's list.
1732
+ if (DEV && renderThread === 'main')
1733
+ reportPermutations(announcePermutationWord);
1720
1734
  // What the thread that draws needs besides its canvas, whichever thread that is.
1721
1735
  const rendererSetup = {
1722
1736
  tier,
@@ -2017,6 +2031,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
2017
2031
  ...senders,
2018
2032
  pageUrl: pageUrl ?? sketchUrl,
2019
2033
  sketchUrl,
2034
+ data: modes.sketchData,
2020
2035
  maxTargetFps: maxTarget,
2021
2036
  threads: engineThreads,
2022
2037
  twoStepProbe: DEV && switches.twoStep,
@@ -2063,6 +2078,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
2063
2078
  ...handoff,
2064
2079
  sketchUrl,
2065
2080
  pageUrl: pageUrl ?? sketchUrl,
2081
+ data: modes.sketchData,
2066
2082
  keyCodes: KEY_CODES,
2067
2083
  jobWorkers,
2068
2084
  capabilities,
@@ -11,7 +11,7 @@
11
11
  // scene: it sits in a container of its own, which holds the camera's perspective and turn, and its
12
12
  // transform is the element's world matrix. The browser then turns it as it turns the scene.
13
13
  import { controlLabels, Slot } from '../shared/control.js';
14
- import { CAMERA_CENTER_X, CAMERA_CENTER_Y, CAMERA_HALF_HEIGHT, CAMERA_ORTHO, GENERATION_SHIFT, LABEL_SHOWN, LABEL_STATE, LABEL_WORDS, LABEL_X, LABEL_Y, LABEL3D_STATE, LABEL3D_WORDS, labelSequence, PRESENTED_TABLE, presentedCount, presentedCount3d, presentedFrame, presentedTable3d, TABLE_3D, } from '../shared/labels.js';
14
+ import { CAMERA_CENTER_X, CAMERA_CENTER_Y, CAMERA_FLOATS, CAMERA_HALF_HEIGHT, CAMERA_ORTHO, CAMERA_SHIFT_X, CAMERA_SHIFT_Y, GENERATION_SHIFT, LABEL_SHOWN, LABEL_STATE, LABEL_WORDS, LABEL_X, LABEL_Y, LABEL3D_STATE, LABEL3D_WORDS, labelSequence, PRESENTED_TABLE, presentedCount, presentedCount3d, presentedFrame, presentedTable3d, TABLE_3D, } from '../shared/labels.js';
15
15
  /** How many times an update reads the labels again when the thread that draws changed them meanwhile. */
16
16
  const READ_TRIES = 3;
17
17
  /** The smallest move, in CSS pixels, that moves a screen label's element. */
@@ -23,7 +23,7 @@ const STATE_Y = 1;
23
23
  const STATE_SHOWN = 2;
24
24
  const STATE_MATRIX = 3;
25
25
  /** The camera record that the containers show, then the canvas size they were made for. */
26
- const CAMERA_STATE = 18;
26
+ const CAMERA_STATE = CAMERA_FLOATS + 2;
27
27
  /** The smallest number of a matrix that counts as zero, so a turn of the camera writes no noise. */
28
28
  const EPSILON = 1e-10;
29
29
  /** The bound elements, and the loop that moves them. */
@@ -406,10 +406,15 @@ export function cameraTransform(camera, width, height) {
406
406
  `${number(camera[1])},${number(-camera[4])},${number(camera[7])},0,` +
407
407
  `${number(camera[2])},${number(-camera[5])},${number(camera[8])},0,` +
408
408
  `${number(tx)},${number(-ty)},${number(tz)},1)`;
409
- const head = camera[CAMERA_ORTHO] !== 0
409
+ const lens = camera[CAMERA_ORTHO] !== 0
410
410
  ? `scale(${number(focal)}) translate(${number(-camera[CAMERA_CENTER_X])}px,${number(camera[CAMERA_CENTER_Y])}px) `
411
411
  : `perspective(${number(focal)}px) translateZ(${number(focal)}px) `;
412
- return `${head}${matrix} translate(${number(width / 2)}px,${number(height / 2)}px)`;
412
+ // A lens shift moves the whole image after the projection, left and down for a view shifted
413
+ // right and up.
414
+ const shiftX = camera[CAMERA_SHIFT_X] * width;
415
+ const shiftY = camera[CAMERA_SHIFT_Y] * height;
416
+ const shift = shiftX === 0 && shiftY === 0 ? '' : `translate(${number(-shiftX)}px,${number(shiftY)}px) `;
417
+ return `${shift}${lens}${matrix} translate(${number(width / 2)}px,${number(height / 2)}px)`;
413
418
  }
414
419
  /** A number as CSS takes it, with the noise of a turn that did not move it set to zero. */
415
420
  function number(value) {
@@ -27,6 +27,8 @@ export class StatsSwitch {
27
27
  if (show !== true) {
28
28
  if (show.collapsed !== undefined)
29
29
  this.options.collapsed = show.collapsed;
30
+ if (show.corner !== undefined)
31
+ this.options.corner = show.corner;
30
32
  this.overlay?.configure(show);
31
33
  }
32
34
  this.load ??= import('../debug/overlay.js');
@@ -34,8 +34,9 @@ export type LatencyMode = 'pipelined' | 'low';
34
34
  export type SketchThread = 'worker' | 'main';
35
35
  /**
36
36
  * How the GPU path stores depth. In `reversed` depth, the near plane stores 1 and the far plane 0,
37
- * in a 32-bit float depth buffer. That keeps depth precise far from the camera. WebGPU always
38
- * draws it. WebGL2 draws it where the browser has the `EXT_clip_control` extension, which gives
37
+ * in a 32-bit float depth buffer. That keeps depth precise far from the camera.
38
+ *
39
+ * WebGPU always draws it. WebGL2 draws it where the browser has the `EXT_clip_control` extension, which gives
39
40
  * WebGL2 the depth range from 0 to 1 that WebGPU has. The `reversed-gl` mode keeps the same
40
41
  * order, but in WebGL2's own depth range from -1 to 1, which loses most of the precision. In
41
42
  * `standard` depth, the near plane stores 0 and the far plane 1.
@@ -311,8 +312,9 @@ export interface Switches {
311
312
  view: string | undefined;
312
313
  /**
313
314
  * True when a bare ?stats or ?stats=on shows the stats overlay, false when ?stats=off hides it,
314
- * options when ?stats=collapsed or ?stats=open shows it collapsed or open, and undefined without
315
- * the switch. It wins over the page's option.
315
+ * and undefined without the switch. Options when the switch names a start state, `collapsed` or
316
+ * `open`, a corner, `top-right` or `bottom-right`, or one of each with a comma between, such as
317
+ * ?stats=collapsed,bottom-right. It wins over the page's option.
316
318
  */
317
319
  stats: StatsRequest | undefined;
318
320
  /**
@@ -55,11 +55,27 @@ function oneOf(value, allowed) {
55
55
  function onOff(value) {
56
56
  return value === 'on' ? true : value === 'off' ? false : undefined;
57
57
  }
58
- /** ?stats: on for a bare switch or `on`, off for `off`, or the start state for `collapsed` or `open`. */
58
+ /**
59
+ * ?stats: on for a bare switch or `on`, off for `off`, or options from a comma-separated list of a
60
+ * start state, `collapsed` or `open`, and a corner, `top-right` or `bottom-right`. A word that none
61
+ * of these is leaves the switch out.
62
+ */
59
63
  function statsSwitch(value) {
60
- return value === 'collapsed' || value === 'open'
61
- ? { collapsed: value === 'collapsed' }
62
- : value === '' || onOff(value);
64
+ if (value === '')
65
+ return true;
66
+ const on = onOff(value);
67
+ if (on !== undefined || value === null)
68
+ return on;
69
+ const options = {};
70
+ for (const word of value.split(',')) {
71
+ if (word === 'collapsed' || word === 'open')
72
+ options.collapsed = word === 'collapsed';
73
+ else if (word === 'top-right' || word === 'bottom-right')
74
+ options.corner = word;
75
+ else
76
+ return undefined;
77
+ }
78
+ return options;
63
79
  }
64
80
  /** A number above 0, or undefined for a missing or unusable value. */
65
81
  function positive(value) {