@null3d/engine 0.1.0 → 0.1.2

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 (388) 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 +40 -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 +68 -24
  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/E1308.md +31 -0
  146. package/docs/errors/E1401.md +11 -3
  147. package/docs/errors/E1402.md +13 -5
  148. package/docs/errors/E1403.md +11 -3
  149. package/docs/errors/E1404.md +13 -3
  150. package/docs/errors/E1405.md +15 -4
  151. package/docs/errors/E1406.md +31 -5
  152. package/docs/errors/E1407.md +11 -3
  153. package/docs/errors/E1408.md +11 -3
  154. package/docs/errors/E1409.md +11 -3
  155. package/docs/errors/E1410.md +13 -5
  156. package/docs/errors/E1411.md +11 -3
  157. package/docs/errors/E1412.md +29 -6
  158. package/docs/errors/E1413.md +11 -3
  159. package/docs/errors/E1414.md +11 -3
  160. package/docs/errors/E1415.md +11 -3
  161. package/docs/errors/E1416.md +27 -6
  162. package/docs/errors/E1417.md +11 -3
  163. package/docs/errors/E1418.md +12 -3
  164. package/docs/errors/E1419.md +13 -5
  165. package/docs/errors/E1420.md +11 -3
  166. package/docs/errors/E1421.md +11 -3
  167. package/docs/errors/E1422.md +12 -3
  168. package/docs/errors/E1423.md +12 -3
  169. package/docs/errors/E1424.md +24 -5
  170. package/docs/errors/E1425.md +11 -3
  171. package/docs/errors/E1426.md +11 -3
  172. package/docs/errors/E1430.md +11 -3
  173. package/docs/errors/E1431.md +11 -3
  174. package/docs/errors/E1432.md +11 -3
  175. package/docs/errors/E1433.md +11 -3
  176. package/docs/errors/E1434.md +15 -6
  177. package/docs/errors/E1435.md +11 -3
  178. package/docs/errors/E1436.md +11 -3
  179. package/docs/errors/E1437.md +14 -6
  180. package/docs/errors/E1501.md +41 -6
  181. package/docs/errors/E1502.md +13 -3
  182. package/docs/errors/E1503.md +11 -3
  183. package/docs/errors/E1504.md +11 -3
  184. package/docs/errors/E1505.md +23 -5
  185. package/docs/errors/E1506.md +11 -3
  186. package/docs/errors/index.md +53 -29
  187. package/docs/getting-started/cdn.md +15 -9
  188. package/docs/getting-started/first-scene.md +20 -12
  189. package/docs/getting-started/hosting.md +113 -63
  190. package/docs/getting-started/install.md +39 -24
  191. package/docs/getting-started/network-use.md +31 -21
  192. package/docs/getting-started/project-structure.md +20 -8
  193. package/docs/getting-started/third-party-notices.md +6 -10
  194. package/docs/guides/accessibility.md +4 -4
  195. package/docs/guides/add-ons.md +83 -13
  196. package/docs/guides/agents.md +13 -14
  197. package/docs/guides/assets-pipeline.md +294 -72
  198. package/docs/guides/audio.md +17 -15
  199. package/docs/guides/baked-light-data.md +44 -23
  200. package/docs/guides/car-paint.md +37 -31
  201. package/docs/guides/content-pages.md +86 -29
  202. package/docs/guides/custom-passes.md +59 -17
  203. package/docs/guides/custom-shaders.md +54 -37
  204. package/docs/guides/debugging.md +31 -41
  205. package/docs/guides/deploying.md +10 -27
  206. package/docs/guides/deterministic-simulation.md +23 -16
  207. package/docs/guides/first-use-shaders.md +83 -45
  208. package/docs/guides/lens-kit.md +29 -26
  209. package/docs/guides/loading-screens.md +74 -30
  210. package/docs/guides/multiple-views.md +22 -11
  211. package/docs/guides/performance.md +188 -37
  212. package/docs/guides/phones.md +71 -19
  213. package/docs/guides/physics.md +6 -10
  214. package/docs/guides/screens.md +41 -29
  215. package/docs/guides/start-time.md +126 -85
  216. package/docs/guides/testing.md +137 -98
  217. package/docs/guides/ui-overlays.md +17 -12
  218. package/docs/guides/video-textures.md +14 -13
  219. package/docs/images/api/animation/character.webp +0 -0
  220. package/docs/images/api/animation/look-at-ring.webp +0 -0
  221. package/docs/images/api/animation/morph-tulips.webp +0 -0
  222. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  223. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  224. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  225. package/docs/images/api/debug/debug-shapes.webp +0 -0
  226. package/docs/images/api/debug/levels-view.webp +0 -0
  227. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  228. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  229. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  230. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  231. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  232. package/docs/images/api/geometry/generators.webp +0 -0
  233. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  234. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  235. package/docs/images/api/grass/grass-grove.webp +0 -0
  236. package/docs/images/api/grass/grass-presets.webp +0 -0
  237. package/docs/images/api/grass/grass-shadow.webp +0 -0
  238. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  239. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  240. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  241. package/docs/images/api/lights/spot-cookies.webp +0 -0
  242. package/docs/images/api/lines/lines-lit.webp +0 -0
  243. package/docs/images/api/lines/lines-widths.webp +0 -0
  244. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  245. package/docs/images/api/materials/decals.webp +0 -0
  246. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  247. package/docs/images/api/materials/relief.webp +0 -0
  248. package/docs/images/api/materials/shader-inputs.webp +0 -0
  249. package/docs/images/api/materials/standard-grid.webp +0 -0
  250. package/docs/images/api/materials/subsurface.webp +0 -0
  251. package/docs/images/api/materials/translucency.webp +0 -0
  252. package/docs/images/api/objects/objects-turntable.webp +0 -0
  253. package/docs/images/api/particles/campfire.webp +0 -0
  254. package/docs/images/api/points/galaxy.webp +0 -0
  255. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  256. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  257. package/docs/images/api/render/reflection-mirror.webp +0 -0
  258. package/docs/images/api/render/security-camera.webp +0 -0
  259. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  260. package/docs/images/api/sound/sound-demo.webp +0 -0
  261. package/docs/images/api/splats/splats-demo.webp +0 -0
  262. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  263. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  264. package/docs/images/api/textures/canvas-screen.webp +0 -0
  265. package/docs/images/api/textures/mipmaps.webp +0 -0
  266. package/docs/images/api/vertex-draws/rain.webp +0 -0
  267. package/docs/images/api/water/ocean.webp +0 -0
  268. package/docs/images/api/water/water-demo.webp +0 -0
  269. package/docs/images/api/water/water-rain.webp +0 -0
  270. package/docs/images/api/water/waterfall.webp +0 -0
  271. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  272. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  273. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  274. package/docs/images/concepts/instances/instances.webp +0 -0
  275. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  276. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  277. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  278. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  279. package/docs/images/concepts/lighting/environment.webp +0 -0
  280. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  281. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  282. package/docs/images/concepts/lod/forest.webp +0 -0
  283. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  284. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  285. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  286. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  287. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  288. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  289. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  290. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  291. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  292. package/docs/images/cookbook/index/picking.webp +0 -0
  293. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  294. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  295. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  296. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  297. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  298. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  299. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  300. package/docs/images/index/showcase-island.webp +0 -0
  301. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  302. package/docs/images/shaders/builtins/builtins.webp +0 -0
  303. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  304. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  305. package/docs/images/shots.json +2231 -0
  306. package/docs/index.md +14 -23
  307. package/docs/moves.json +1 -0
  308. package/docs/nav.json +300 -0
  309. package/docs/pages.md +230 -212
  310. package/docs/porting/react-three-fiber.md +2 -6
  311. package/docs/porting/threejs-loop-and-threads.md +1 -5
  312. package/docs/porting/threejs-mapping.md +1248 -234
  313. package/docs/porting/threejs-materials.md +10 -5
  314. package/docs/porting/threejs-overview.md +26 -6
  315. package/docs/porting/threejs-postprocessing.md +2 -6
  316. package/docs/porting/threejs-shaders.md +16 -14
  317. package/docs/porting/threejs-unsupported.md +6 -6
  318. package/docs/porting/verification.md +0 -4
  319. package/docs/shaders/builtins.md +15 -4
  320. package/docs/shaders/library.md +9 -6
  321. package/docs/shaders/surface-functions.md +51 -16
  322. package/docs/shaders/wgsl-rules.md +12 -5
  323. package/lib/debug/debug.d.ts +2 -2
  324. package/lib/debug/draw.d.ts +2 -2
  325. package/lib/debug/draw.js +8 -4
  326. package/lib/debug/overlay-look.d.ts +6 -0
  327. package/lib/debug/overlay-look.js +29 -7
  328. package/lib/debug/overlay.js +15 -11
  329. package/lib/debug/stats-options.d.ts +13 -0
  330. package/lib/debug/stats-panel.d.ts +21 -6
  331. package/lib/debug/stats-panel.js +80 -13
  332. package/lib/errors/codes.d.ts +17 -3
  333. package/lib/errors/codes.js +116 -105
  334. package/lib/errors/engine-error.js +1 -1
  335. package/lib/errors/fixes.d.ts +1 -0
  336. package/lib/errors/fixes.js +19 -18
  337. package/lib/generated/shader-permutations.d.ts +6 -0
  338. package/lib/generated/shader-permutations.js +6 -0
  339. package/lib/gpu/variants.d.ts +8 -2
  340. package/lib/gpu/variants.js +39 -7
  341. package/lib/gpu/webgl2/programs.js +1 -1
  342. package/lib/gpu/webgpu/pipelines.js +13 -13
  343. package/lib/index.d.ts +1 -1
  344. package/lib/page/capabilities.d.ts +1 -1
  345. package/lib/page/engine.d.ts +29 -7
  346. package/lib/page/engine.js +79 -7
  347. package/lib/page/label-loop.js +9 -4
  348. package/lib/page/stats-switch.js +2 -0
  349. package/lib/page/switches.d.ts +6 -4
  350. package/lib/page/switches.js +20 -4
  351. package/lib/scene/baked-light.d.ts +2 -2
  352. package/lib/scene/fake-call-values.js +2 -2
  353. package/lib/scene/frame-cameras.d.ts +16 -4
  354. package/lib/scene/frame-cameras.js +28 -10
  355. package/lib/scene/gltf.d.ts +1 -1
  356. package/lib/scene/level-rule.d.ts +6 -5
  357. package/lib/scene/level-rule.js +2 -2
  358. package/lib/scene/particles.d.ts +7 -3
  359. package/lib/scene/particles.js +3 -1
  360. package/lib/scene/post.d.ts +3 -2
  361. package/lib/scene/resources.d.ts +15 -9
  362. package/lib/scene/scene.d.ts +18 -2
  363. package/lib/scene/scene.js +47 -5
  364. package/lib/scene/time-of-day.d.ts +10 -5
  365. package/lib/scene/time-of-day.js +11 -7
  366. package/lib/shader-artifact.json +1 -1
  367. package/lib/shared/labels.d.ts +5 -2
  368. package/lib/shared/labels.js +5 -2
  369. package/lib/shared/permutation-words.d.ts +8 -0
  370. package/lib/shared/permutation-words.js +14 -0
  371. package/lib/shared/recording.d.ts +13 -5
  372. package/lib/shared/recording.js +31 -10
  373. package/lib/shared/sketch-data.d.ts +9 -0
  374. package/lib/shared/sketch-data.js +57 -0
  375. package/lib/shared/tier.d.ts +9 -0
  376. package/lib/shared/tier.js +4 -1
  377. package/lib/shared/version.d.ts +1 -1
  378. package/lib/shared/version.js +1 -1
  379. package/lib/sketch/define-sketch.d.ts +16 -7
  380. package/lib/sketch/define-sketch.js +2 -1
  381. package/lib/sketch/runner.d.ts +4 -0
  382. package/lib/sketch/runner.js +5 -0
  383. package/lib/sketch/ui.js +4 -2
  384. package/lib/stats.d.ts +1 -0
  385. package/lib/workers/protocol.d.ts +10 -0
  386. package/lib/workers/render-worker.js +4 -1
  387. package/lib/workers/sketch-worker.js +4 -1
  388. package/package.json +1 -1
@@ -15,7 +15,8 @@ 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 { SHIPPED_GPU_PATHS } from '../generated/shader-permutations.js';
19
+ import { recordPermutations, reportPermutations, stopRecordingPermutations } from '../gpu/variants.js';
19
20
  import { maxTargetFps, } from '../quality/check.js';
20
21
  import { choosePreset, crashLowest, crashTier, deviceKind, gpuOcclusionChoice, memoryPreset, textureMemoryCap, withinTier, } from '../quality/chooser.js';
21
22
  import { readDeviceHints } from '../quality/device-hints.js';
@@ -32,7 +33,10 @@ import { KEY_CODES } from '../shared/key-codes.js';
32
33
  import { memoryBytes } from '../shared/memory-views.js';
33
34
  import { createMetricsBuffer, MetricsReader, threadRoles } from '../shared/metrics.js';
34
35
  import { addMeasurementRelease } from '../shared/page-measurement.js';
36
+ import { GPU_PATH_EVENT, PERMUTATION_WORD_EVENT } from '../shared/permutation-words.js';
37
+ import { sketchDataText } from '../shared/sketch-data.js';
35
38
  import { clearJobTasks, jobAsker, setJobTasks } from '../shared/task-host.js';
39
+ import { pathOfTier } from '../shared/tier.js';
36
40
  import { hearAddonsEarly, onAddonChecked } from '../shared/version.js';
37
41
  import { VIDEO_FOLLOW } from '../shared/videos.js';
38
42
  import { notifySlot, setWakeByMessage } from '../shared/wake.js';
@@ -114,11 +118,26 @@ const INSPECT_REPLY_LIMIT_MS = 30_000;
114
118
  * than waiting for a worker that may never speak.
115
119
  */
116
120
  export const RETRY_REPLY_MS = 10_000;
117
- /** Picks the GPU tier from feature tests, never from browser or GPU names. */
118
- export function chooseTier(report, wanted, inWorker) {
121
+ /** The GPU paths whose shaders this build ships, or null for both, as the plugin's build wrote it. */
122
+ const SHIPPED_PATHS = SHIPPED_GPU_PATHS === null ? null : new Set(SHIPPED_GPU_PATHS);
123
+ /** True when this build holds the shaders of `path`. */
124
+ export function shipsPath(path) {
125
+ return SHIPPED_PATHS === null || SHIPPED_PATHS.has(path);
126
+ }
127
+ /** The path that a page's GPU switch draws with, or undefined for the engine's own choice. */
128
+ function pathOfSwitch(wanted) {
129
+ return wanted === 'auto' ? undefined : pathOfTier(wanted === 'webgl2' ? 'webgl2' : 'webgpu');
130
+ }
131
+ /**
132
+ * Picks the GPU tier from feature tests, never from browser or GPU names. A path whose shaders this
133
+ * build does not ship counts as unavailable, whether or not the browser offers it.
134
+ */
135
+ export function chooseTier(report, wanted, inWorker, ships = shipsPath) {
119
136
  const worker = 'failure' in report.worker ? undefined : report.worker;
120
- const webgpu = report.webgpu.compatibilityAdapter && (!inWorker || worker?.offscreenWebGPU === true);
121
- const webgl2 = inWorker ? worker?.offscreenWebGL2 === true : report.webgl2.available;
137
+ const webgpu = ships('webgpu') &&
138
+ report.webgpu.compatibilityAdapter &&
139
+ (!inWorker || worker?.offscreenWebGPU === true);
140
+ const webgl2 = ships('webgl2') && (inWorker ? worker?.offscreenWebGL2 === true : report.webgl2.available);
122
141
  if (wanted === 'webgl2')
123
142
  return webgl2 ? { tier: 'webgl2', forceCompat: false } : null;
124
143
  if (wanted === 'compat')
@@ -134,6 +153,38 @@ export function chooseTier(report, wanted, inWorker) {
134
153
  };
135
154
  return webgl2 ? { tier: 'webgl2', forceCompat: false } : null;
136
155
  }
156
+ /** The name of a GPU path, as the error messages carry it. */
157
+ function pathName(path) {
158
+ return path === 'webgl2' ? 'WebGL2' : 'WebGPU';
159
+ }
160
+ /** The GPU paths that this build ships, as the error messages carry them. */
161
+ function shippedNames(ships) {
162
+ if (ships('webgpu') && ships('webgl2'))
163
+ return 'WebGPU and WebGL2';
164
+ return ships('webgpu') ? 'WebGPU' : 'WebGL2';
165
+ }
166
+ /**
167
+ * The error for a start that found no usable GPU tier. When the build holds the shaders of one path
168
+ * and this start would draw with the other, it names the build's choice (E1308), because no browser
169
+ * or setting can fix that page. Otherwise the browser offers no path the engine can draw with, or
170
+ * none that the page asked for (E1301).
171
+ */
172
+ export function noTierError(report, requested, inWorker, ships = shipsPath) {
173
+ const named = pathOfSwitch(requested);
174
+ if (named !== undefined && !ships(named))
175
+ return new EngineError('E1308', `this build ships only the ${shippedNames(ships)} shaders, and ?gpu=${requested} asks for ${pathName(named)}. Build the project with both GPU paths, or remove the switch.`);
176
+ if (named !== undefined)
177
+ return new EngineError('E1301', `no usable GPU path for ?gpu=${requested} in this browser.`);
178
+ const worker = 'failure' in report.worker ? undefined : report.worker;
179
+ const offered = report.webgpu.compatibilityAdapter
180
+ ? 'webgpu'
181
+ : (inWorker ? worker?.offscreenWebGL2 === true : report.webgl2.available)
182
+ ? 'webgl2'
183
+ : undefined;
184
+ if (offered !== undefined && !ships(offered))
185
+ return new EngineError('E1308', `this build ships only the ${shippedNames(ships)} shaders, and this device would draw with ${pathName(offered)}. The Vite plugin's shaders.gpuPaths option left ${pathName(offered)} out. Build the project with both GPU paths, or run the page in a browser that offers ${pathName(ships('webgpu') ? 'webgpu' : 'webgl2')}.`);
186
+ return new EngineError('E1301', `no usable GPU path for ?gpu=${requested} in this browser.`);
187
+ }
137
188
  /**
138
189
  * True while this page is hidden. A hidden page draws no frames, so a capture's answer comes once
139
190
  * the page shows again, however long that takes, and the answer's limit counts only the time the
@@ -277,6 +328,10 @@ export class EngineWorker {
277
328
  // frame has built the scene's pipelines.
278
329
  this.recording?.answered(reply.role, reply.permutations);
279
330
  return;
331
+ case 'permutation':
332
+ if (DEV)
333
+ announcePermutationWord(reply.word);
334
+ return;
280
335
  case 'sketch-message':
281
336
  events.sketchMessage(reply.name, reply.data);
282
337
  return;
@@ -866,6 +921,7 @@ export async function createEngine(options) {
866
921
  };
867
922
  try {
868
923
  checkPreload(options.preload);
924
+ const sketchData = sketchDataText(options.sketchData);
869
925
  const hold = holdSeconds(options.hold, switches.hold);
870
926
  // A test tool may set a timed script before the page loads. Only hold mode performs it, so a
871
927
  // live engine ignores one left on the page.
@@ -881,7 +937,7 @@ export async function createEngine(options) {
881
937
  }, () => new EngineError('E1419', 'createEngine() got a canvas that another engine draws on, which has not stopped.'));
882
938
  if (canvas.dead)
883
939
  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);
940
+ return await startEngine(options, switches, { hold, holdScript, replay: switches.replay, record: switches.record, sketchData }, place, canvas, holder, release);
885
941
  }
886
942
  catch (error) {
887
943
  release();
@@ -914,6 +970,16 @@ function placement(options, switches) {
914
970
  const main = !threaded || (switches.sketchThread ?? options.sketchThread) === 'main';
915
971
  return { threaded, sketchThread: main ? 'main' : 'worker' };
916
972
  }
973
+ /** Fires the event that hands a permutation word that the page draws with to the dev server. */
974
+ function announcePermutationWord(word) {
975
+ globalThis.dispatchEvent?.(new CustomEvent(PERMUTATION_WORD_EVENT, { detail: word }));
976
+ }
977
+ /** In a development build, tells the dev server the GPU path that this engine draws with. */
978
+ function announceGpuPath(tier) {
979
+ if (!DEV)
980
+ return;
981
+ globalThis.dispatchEvent?.(new CustomEvent(GPU_PATH_EVENT, { detail: pathOfTier(tier) }));
982
+ }
917
983
  /**
918
984
  * Starts the engine with the page's switches. With a hold time or a replay, it resolves once the
919
985
  * last frame is read back, and publishes it.
@@ -1603,8 +1669,9 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
1603
1669
  drawModule ??= loadDrawModule();
1604
1670
  }
1605
1671
  if (!choice)
1606
- throw new EngineError('E1301', `no usable GPU path for ?gpu=${requested} in this browser.`);
1672
+ throw noTierError(report, requested, renderThread !== 'main');
1607
1673
  tier = choice.tier;
1674
+ announceGpuPath(tier);
1608
1675
  const { forceCompat } = choice;
1609
1676
  // Where the page draws, it moves the label elements right after each frame it draws.
1610
1677
  const labels = new PageLabels(views, renderThread === 'main');
@@ -1717,6 +1784,9 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
1717
1784
  globalThis.__null3dStopRecording = stopRecording;
1718
1785
  if (recording && renderThread === 'main')
1719
1786
  recordPermutations();
1787
+ // The dev server compares each word that the page draws with against the project's list.
1788
+ if (DEV && renderThread === 'main')
1789
+ reportPermutations(announcePermutationWord);
1720
1790
  // What the thread that draws needs besides its canvas, whichever thread that is.
1721
1791
  const rendererSetup = {
1722
1792
  tier,
@@ -2017,6 +2087,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
2017
2087
  ...senders,
2018
2088
  pageUrl: pageUrl ?? sketchUrl,
2019
2089
  sketchUrl,
2090
+ data: modes.sketchData,
2020
2091
  maxTargetFps: maxTarget,
2021
2092
  threads: engineThreads,
2022
2093
  twoStepProbe: DEV && switches.twoStep,
@@ -2063,6 +2134,7 @@ async function startEngine(options, switches, modes, { threaded, sketchThread },
2063
2134
  ...handoff,
2064
2135
  sketchUrl,
2065
2136
  pageUrl: pageUrl ?? sketchUrl,
2137
+ data: modes.sketchData,
2066
2138
  keyCodes: KEY_CODES,
2067
2139
  jobWorkers,
2068
2140
  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) {
@@ -26,7 +26,7 @@ export interface BakedLightMap {
26
26
  * little-endian half floats. Rows run along v from the first texel at u = 0, v = 0.
27
27
  */
28
28
  readonly radiance: Uint8Array;
29
- /** Three signed bytes per texel, each axis divided by 127, or undefined without one. */
29
+ /** Three signed bytes per texel, each axis times 127, or undefined without one. */
30
30
  readonly direction: Int8Array | undefined;
31
31
  }
32
32
  /** A baked light file that this engine reads. */
@@ -45,7 +45,7 @@ export interface LightMapData {
45
45
  /** The radiance, as a texture that a material takes as `lightMap`. */
46
46
  readonly texture: Texture;
47
47
  /**
48
- * Three signed bytes per texel, from -127 to 127, each axis a direction divided by 127. It runs
48
+ * Three signed bytes per texel, from -127 to 127: each axis of the direction times 127. It runs
49
49
  * from the same first texel as the radiance, and it is undefined for a light map without a
50
50
  * direction.
51
51
  */
@@ -11,8 +11,8 @@ const READS = {
11
11
  setBatchBounds: 1,
12
12
  setMaterialValue: 3,
13
13
  setMaterialValues: 4,
14
- setPerspectiveCamera: 3,
15
- setOrthographicCamera: 6,
14
+ setPerspectiveCamera: 5,
15
+ setOrthographicCamera: 8,
16
16
  addSceneView: 4,
17
17
  setSceneViewRect: 4,
18
18
  setLightColor: 3,
@@ -49,7 +49,13 @@ export declare const LENS_CENTER_Y = 4;
49
49
  /** The distances along the view to the near and far planes. */
50
50
  export declare const LENS_NEAR = 5;
51
51
  export declare const LENS_FAR = 6;
52
- export declare const LENS_FLOATS = 7;
52
+ /**
53
+ * The lens shift: how far the view sits right of and above the camera's axis, or an orthographic
54
+ * view's center, as fractions of the view's width and height.
55
+ */
56
+ export declare const LENS_SHIFT_X = 7;
57
+ export declare const LENS_SHIFT_Y = 8;
58
+ export declare const LENS_FLOATS = 9;
53
59
  /** The cameras of the last frames, and the math of rays and projections from them. */
54
60
  export declare class FrameCameras {
55
61
  private readonly core;
@@ -153,10 +159,10 @@ export declare class FrameCameras {
153
159
  * A camera's projection, made once and used for many points. The first 9 numbers are the inverse
154
160
  * of the 3 × 3 part of the camera's world matrix, row by row, then the camera's position. Then come
155
161
  * half the view's width and height (one unit in front of a perspective camera, or across an
156
- * orthographic view), 1 for an orthographic lens or 0, the orthographic view's center, and the
157
- * distances to the near and far planes.
162
+ * orthographic view), 1 for an orthographic lens or 0, the orthographic view's center, the
163
+ * distances to the near and far planes, and the lens shift.
158
164
  */
159
- export declare const VIEW_FLOATS = 19;
165
+ export declare const VIEW_FLOATS = 21;
160
166
  export declare const VIEW_SCALE_Y = 13;
161
167
  /** 1 in a view that `viewOf` wrote for an orthographic lens, or 0. */
162
168
  export declare const VIEW_ORTHO = 14;
@@ -166,6 +172,12 @@ export declare const VIEW_CENTER_Y = 16;
166
172
  /** The distances to the near and far planes in a view that `viewOf` wrote. */
167
173
  export declare const VIEW_NEAR = 17;
168
174
  export declare const VIEW_FAR = 18;
175
+ /**
176
+ * The lens shift in a view that `viewOf` wrote, as fractions of the view's width and height. It moves
177
+ * the image by twice that fraction in normalized device coordinates.
178
+ */
179
+ export declare const VIEW_SHIFT_X = 19;
180
+ export declare const VIEW_SHIFT_Y = 20;
169
181
  /**
170
182
  * Writes where `point` lies for the camera of `view` into `out`: x and y in normalized device
171
183
  * coordinates, from -1 to 1 across the canvas with y up, then the distance in front of the camera
@@ -27,7 +27,13 @@ export const LENS_CENTER_Y = 4;
27
27
  /** The distances along the view to the near and far planes. */
28
28
  export const LENS_NEAR = 5;
29
29
  export const LENS_FAR = 6;
30
- export const LENS_FLOATS = 7;
30
+ /**
31
+ * The lens shift: how far the view sits right of and above the camera's axis, or an orthographic
32
+ * view's center, as fractions of the view's width and height.
33
+ */
34
+ export const LENS_SHIFT_X = 7;
35
+ export const LENS_SHIFT_Y = 8;
36
+ export const LENS_FLOATS = 9;
31
37
  /** The views whose cameras the ring keeps. */
32
38
  const RING_VIEWS = 4;
33
39
  /** The frames of an entry that holds no frame yet. */
@@ -301,10 +307,10 @@ function sameView(ring, at, view) {
301
307
  * A camera's projection, made once and used for many points. The first 9 numbers are the inverse
302
308
  * of the 3 × 3 part of the camera's world matrix, row by row, then the camera's position. Then come
303
309
  * half the view's width and height (one unit in front of a perspective camera, or across an
304
- * orthographic view), 1 for an orthographic lens or 0, the orthographic view's center, and the
305
- * distances to the near and far planes.
310
+ * orthographic view), 1 for an orthographic lens or 0, the orthographic view's center, the
311
+ * distances to the near and far planes, and the lens shift.
306
312
  */
307
- export const VIEW_FLOATS = 19;
313
+ export const VIEW_FLOATS = 21;
308
314
  const VIEW_POSITION = 9;
309
315
  /** Half the view's width and height in a view that `viewOf` wrote. */
310
316
  const VIEW_SCALE_X = 12;
@@ -317,6 +323,12 @@ export const VIEW_CENTER_Y = 16;
317
323
  /** The distances to the near and far planes in a view that `viewOf` wrote. */
318
324
  export const VIEW_NEAR = 17;
319
325
  export const VIEW_FAR = 18;
326
+ /**
327
+ * The lens shift in a view that `viewOf` wrote, as fractions of the view's width and height. It moves
328
+ * the image by twice that fraction in normalized device coordinates.
329
+ */
330
+ export const VIEW_SHIFT_X = 19;
331
+ export const VIEW_SHIFT_Y = 20;
320
332
  /** Writes the projection of the camera of the entry at `at` into `view`. */
321
333
  function writeView(e, at, view) {
322
334
  const m = at + MATRIX;
@@ -350,6 +362,8 @@ function writeView(e, at, view) {
350
362
  view[VIEW_CENTER_Y] = e[lens + LENS_CENTER_Y];
351
363
  view[VIEW_NEAR] = e[lens + LENS_NEAR];
352
364
  view[VIEW_FAR] = e[lens + LENS_FAR];
365
+ view[VIEW_SHIFT_X] = e[lens + LENS_SHIFT_X];
366
+ view[VIEW_SHIFT_Y] = e[lens + LENS_SHIFT_Y];
353
367
  }
354
368
  /**
355
369
  * Writes where `point` lies for the camera of `view` into `out`: x and y in normalized device
@@ -366,13 +380,16 @@ export function projectPoint(view, point, out) {
366
380
  const lz = view[6] * px + view[7] * py + view[8] * pz;
367
381
  const sx = view[VIEW_SCALE_X];
368
382
  const sy = view[VIEW_SCALE_Y];
383
+ // A lens shift moves the whole image, after the perspective division.
384
+ const shiftX = 2 * view[VIEW_SHIFT_X];
385
+ const shiftY = 2 * view[VIEW_SHIFT_Y];
369
386
  if (view[VIEW_ORTHO] !== 0) {
370
- out[0] = (lx - view[VIEW_CENTER_X]) / sx;
371
- out[1] = (ly - view[VIEW_CENTER_Y]) / sy;
387
+ out[0] = (lx - view[VIEW_CENTER_X]) / sx - shiftX;
388
+ out[1] = (ly - view[VIEW_CENTER_Y]) / sy - shiftY;
372
389
  }
373
390
  else {
374
- out[0] = lx / (-lz * sx);
375
- out[1] = ly / (-lz * sy);
391
+ out[0] = lx / (-lz * sx) - shiftX;
392
+ out[1] = ly / (-lz * sy) - shiftY;
376
393
  }
377
394
  out[2] = -lz;
378
395
  }
@@ -448,9 +465,10 @@ function writeRay(e, at, point, out) {
448
465
  const y = point[1];
449
466
  const width = e[at + CSS_WIDTH];
450
467
  const height = e[at + CSS_HEIGHT];
451
- const ndcX = width > 0 ? (x / width) * 2 - 1 : 0;
452
- const ndcY = height > 0 ? 1 - (y / height) * 2 : 0;
453
468
  const lens = at + LENS;
469
+ // A lens shift moves the view right and up, so a point of the canvas sees that much further.
470
+ const ndcX = (width > 0 ? (x / width) * 2 - 1 : 0) + 2 * e[lens + LENS_SHIFT_X];
471
+ const ndcY = (height > 0 ? 1 - (y / height) * 2 : 0) + 2 * e[lens + LENS_SHIFT_Y];
454
472
  writeScaleX(e, at, rayScale, 0);
455
473
  const sx = ndcX * rayScale[0];
456
474
  const sy = ndcY * e[lens + LENS_HALF_HEIGHT];
@@ -92,7 +92,7 @@ export declare function fileLevelMeasure(errors: readonly number[] | undefined,
92
92
  };
93
93
  /** One band of a tree of cluster patches, as a stage file holds it. */
94
94
  export interface StageBand {
95
- /** Each patch's bounding sphere: its centre, then its radius. */
95
+ /** Each patch's bounding sphere: its center, then its radius. */
96
96
  bounds: Float32Array;
97
97
  /** Each patch's first index, count, parent's place plus one, and error's bits. */
98
98
  records: Uint32Array;
@@ -22,8 +22,9 @@ export interface LevelView {
22
22
  */
23
23
  readonly orthographic?: boolean;
24
24
  /**
25
- * The source's threshold bias, as Godot's `lod_bias`: above 1 switches every level nearer, so
26
- * coarser levels draw, and below 1 keeps its detail. The default is 1.
25
+ * The source's threshold bias, as the inverse of Godot's `lod_bias`: a Godot bias of 2 is
26
+ * about a null3D bias of 0.5. Above 1 switches every level nearer, so coarser levels draw, and
27
+ * below 1 keeps its detail. The default is 1.
27
28
  */
28
29
  readonly bias?: number;
29
30
  }
@@ -41,13 +42,13 @@ export type LevelSwitch = {
41
42
  readonly coverage: number;
42
43
  };
43
44
  /**
44
- * A source's world bounds about the camera: the centre of its bounding sphere relative to the
45
+ * A source's world bounds about the camera: the center of its bounding sphere relative to the
45
46
  * camera, and the sphere's radius.
46
47
  *
47
48
  * @category api/geometry
48
49
  */
49
50
  export interface LevelBounds {
50
- /** The bounding sphere's centre, relative to the camera. */
51
+ /** The bounding sphere's center, relative to the camera. */
51
52
  readonly centre: readonly [number, number, number];
52
53
  /** The bounding sphere's radius, in meters. */
53
54
  readonly radius: number;
@@ -96,7 +97,7 @@ export declare function levelSwitchDistance(view: LevelView, level: LevelSwitch,
96
97
  * point for the other measures.
97
98
  *
98
99
  * @param view The view that measures the source.
99
- * @param bounds The source's bounds, with the centre relative to the camera.
100
+ * @param bounds The source's bounds, with the center relative to the camera.
100
101
  * @returns The two distances, in meters.
101
102
  * @category api/geometry
102
103
  */
@@ -26,7 +26,7 @@
26
26
  * @category api/geometry
27
27
  */
28
28
  export const LEAST_LEVEL_DISTANCE = 1e-3;
29
- /** The share of the bounds' radius that an error's distance takes off the distance to the centre. */
29
+ /** The share of the bounds' radius that an error's distance takes off the distance to the center. */
30
30
  const ERROR_RADIUS_SHARE = 0.5;
31
31
  /** The multiple of the distance to the nearest point that caps an error's distance. */
32
32
  const ERROR_NEAREST_SHARE = 2;
@@ -84,7 +84,7 @@ export function levelSwitchDistance(view, level, scale, radius = 0) {
84
84
  * point for the other measures.
85
85
  *
86
86
  * @param view The view that measures the source.
87
- * @param bounds The source's bounds, with the centre relative to the camera.
87
+ * @param bounds The source's bounds, with the center relative to the camera.
88
88
  * @returns The two distances, in meters.
89
89
  * @category api/geometry
90
90
  */
@@ -198,8 +198,10 @@ export interface ParticleBufferOptions extends ParticleValues {
198
198
  /**
199
199
  * Where an emitter's particles are born, in its own space, and which way they set off. A `point`
200
200
  * emits at the emitter, along `direction`. A `sphere` emits inside a ball of `radius`, or on its
201
- * surface with `surface`, and sends particles outward. A `cone` emits on a disc of `radius` across
202
- * the emitter's +y axis. It sends particles up within `angle` radians of that axis. A `box` emits
201
+ * surface with `surface`, and sends particles outward.
202
+ *
203
+ * A `cone` emits on a disc of `radius` across the emitter's +y axis. It sends particles up within
204
+ * `angle` radians of that axis. A `box` emits
203
205
  * inside a box of `size`, centered on the emitter, along `direction`. A `disc` emits on a disc of
204
206
  * `radius` across the +y axis, along `direction`.
205
207
  *
@@ -294,7 +296,9 @@ export interface ParticleEmitterOptions {
294
296
  * particles add-on's emitters write records into it. Write a particle's record once, when it is
295
297
  * born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it
296
298
  * and changes its look as it ages, as the buffer's values say. It stops drawing the particle at
297
- * the end of its lifetime. Once per frame, write the buffer's time and the records the GPU reads
299
+ * the end of its lifetime.
300
+ *
301
+ * Once per frame, write the buffer's time and the records the GPU reads
298
302
  * into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's
299
303
  * calls allocate nothing.
300
304
  *
@@ -202,7 +202,9 @@ const NO_FLOAT64 = new Float64Array(0);
202
202
  * particles add-on's emitters write records into it. Write a particle's record once, when it is
203
203
  * born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it
204
204
  * and changes its look as it ages, as the buffer's values say. It stops drawing the particle at
205
- * the end of its lifetime. Once per frame, write the buffer's time and the records the GPU reads
205
+ * the end of its lifetime.
206
+ *
207
+ * Once per frame, write the buffer's time and the records the GPU reads
206
208
  * into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's
207
209
  * calls allocate nothing.
208
210
  *
@@ -17,8 +17,9 @@ export type { GradingSettings, SplitToningSettings, WhiteBalanceSettings, } from
17
17
  * AgX, the curve of Blender and Filament. The `'agx-punchy'` curve is AgX with Filament's punchy
18
18
  * look, which adds contrast and color. The `'neutral'` curve is Khronos PBR Neutral, which keeps
19
19
  * base colors as they are until they near white. The `'aces'` curve is a fit of the ACES filmic
20
- * curve, which first scales the color by 1 / 0.6 and shifts the hues of bright colors. The value
21
- * `'none'` clips the exposed color at 1.
20
+ * curve, which first scales the color by 1 / 0.6 and shifts the hues of bright colors.
21
+ *
22
+ * The value `'none'` clips the exposed color at 1.
22
23
  *
23
24
  * @category api/post
24
25
  */
@@ -7,9 +7,11 @@ import type { TextureValues, UniformValues } from './wgsl-uniforms.js';
7
7
  * A lower level of detail of a mesh: a simpler mesh that draws in the base mesh's place. Give its
8
8
  * `error`, the `distance` at which it switches in, or the screen `coverage` under which it draws.
9
9
  * A level with a measured error, which the asset tool writes, changes the picture by under a pixel
10
- * at a small threshold and switches at once. When the governor raises the threshold above about
11
- * one and a half pixels, that switch shows, and such a level then fades too. A level given by a distance, by
12
- * a coverage or by a hand-set error fades over a short band, so its switch does not pop.
10
+ * at a small threshold and switches at once.
11
+ *
12
+ * When the governor raises the threshold above about one and a half pixels, that switch shows, and
13
+ * such a level then fades too. A level given by a distance, by a coverage or by a hand-set error
14
+ * fades over a short band, so its switch does not pop.
13
15
  *
14
16
  * @category api/geometry
15
17
  */
@@ -110,8 +112,10 @@ export interface BuildLevelsOptions {
110
112
  * The levels of detail that a mesh made in code plans on its own. By default it plans them the
111
113
  * first time the scene draws it, when it holds `geometry.automaticLevelTriangles` triangles or
112
114
  * more, or when it holds at least `geometry.automaticCopyTriangles` triangles and its copies hold `geometry.automaticDrawnTriangles` together; `false` plans none,
113
- * and `true` or options plan them when the mesh is made, at any size. `'pieces'` plans no lower
114
- * levels, and sorts a mesh of 32,768 triangles or more into pieces by space at its first draw, as
115
+ * and `true` or options plan them when the mesh is made, at any size.
116
+ *
117
+ * `'pieces'` plans no lower levels, and sorts a mesh of 32,768 triangles or more into pieces by
118
+ * space at its first draw, as
115
119
  * a merged far cell or a large ground whose levels come from elsewhere gains from.
116
120
  *
117
121
  * @category api/geometry
@@ -764,8 +768,10 @@ export interface MaterialOptions {
764
768
  /**
765
769
  * How a material uses its alpha: its opacity, times its base color map's alpha, and times its
766
770
  * mesh's vertex alpha with `vertexColors`. The `opaque` mode ignores the alpha. The `mask` mode
767
- * draws nothing where the alpha falls below `alphaCutoff`, and draws the rest opaque. The `hash`
768
- * mode draws each point of the surface opaque or not at all, by a pattern that stays on the mesh.
771
+ * draws nothing where the alpha falls below `alphaCutoff`, and draws the rest opaque.
772
+ *
773
+ * The `hash` mode draws each point of the surface opaque or not at all, by a pattern that stays on
774
+ * the mesh.
769
775
  * The alpha then sets how much of the surface draws. The `blend` mode blends the surface over what
770
776
  * lies behind it. Blended objects draw after the opaque ones, farthest first.
771
777
  *
@@ -1083,8 +1089,8 @@ export interface StandardMaps {
1083
1089
  /**
1084
1090
  * The thickness of the volume under the surface, in green, in linear color. Its green
1085
1091
  * multiplies `thickness`. Only a material created with `transmission` takes it. It keeps a row
1086
- * slot of its own and samples the specular color map's texture array at its own layer, so a
1087
- * specular color map may draw beside it when the two textures share an array. A material with
1092
+ * slot of its own and samples the specular color map's texture array at its own layer, so it
1093
+ * takes no specular color map, whose sRGB texture never shares that array. A material with
1088
1094
  * layers keeps it unless a layer map fills that slot: the sheen's maps and an anisotropy map do.
1089
1095
  */
1090
1096
  thicknessMap?: Texture;
@@ -833,8 +833,9 @@ export declare class Mesh extends Object3D {
833
833
  */
834
834
  setRenderOrder(order: number): void;
835
835
  /**
836
- * Raises or lowers the threshold that picks this mesh's levels of detail, as Godot's
837
- * `lod_bias` does. A bias above 1 makes every switch happen nearer, so the object draws
836
+ * Raises or lowers the threshold that picks this mesh's levels of detail, as the inverse of
837
+ * Godot's `lod_bias`: a Godot bias of 2 is about a null3D bias of 0.5. A bias above 1 makes
838
+ * every switch happen nearer, so the object draws
838
839
  * coarser levels. A bias below 1 keeps its detail, which a hero object wants. The bias
839
840
  * multiplies the threshold of the level switches and of the distance at which the object
840
841
  * hides, so both move by the same factor. The default is 1. The object's mesh needs levels
@@ -882,6 +883,21 @@ export declare abstract class Camera extends Object3D {
882
883
  setLayers(mask: number): void;
883
884
  /** Sets the distances to the near and far clipping planes. */
884
885
  setNearFar(near: number, far: number): void;
886
+ /**
887
+ * The lens shift: how far the view sits right of and above the camera's axis, as fractions of the
888
+ * view's width and height. The array is the camera's own and changes with `setLensShift`, so
889
+ * copy it to keep a value.
890
+ */
891
+ get lensShift(): readonly [number, number];
892
+ /**
893
+ * Moves the view off the camera's axis, as a shift lens on a real camera does: right by `x`
894
+ * times the view's width, and up by `y` times its height. The perspective stays as it is, so the
895
+ * image is a crop of a wider view from the same place. A shift of 0.25 across puts the camera's
896
+ * axis, and a `target` it looks at, a quarter of the width left of the middle. Culling,
897
+ * shadows, picking, `screenToRay`, `worldToScreen`, views and labels all follow the shifted
898
+ * view. The default is no shift. It allocates nothing.
899
+ */
900
+ setLensShift(x: number, y: number): void;
885
901
  /**
886
902
  * Writes the ray from the camera through a point on the canvas into `out`: `x` and `y` are CSS
887
903
  * pixels from the canvas's top-left corner, as `input.pointer` gives them. A perspective ray