@null3d/engine 0.0.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 (517) hide show
  1. package/README.md +109 -0
  2. package/THIRD-PARTY-NOTICES.txt +0 -1
  3. package/dist/wasm/single/null3d.js +25 -10
  4. package/dist/wasm/single/null3d_bg.wasm +0 -0
  5. package/dist/wasm/threaded/null3d.js +25 -10
  6. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  7. package/docs/api/animation.md +114 -86
  8. package/docs/api/assets.md +135 -49
  9. package/docs/api/cameras.md +45 -12
  10. package/docs/api/controls.md +88 -62
  11. package/docs/api/debug.md +116 -41
  12. package/docs/api/engine.md +117 -35
  13. package/docs/api/feature-draws.md +23 -17
  14. package/docs/api/feature-effects.md +11 -11
  15. package/docs/api/feature-instances.md +70 -19
  16. package/docs/api/features.md +77 -47
  17. package/docs/api/geometry.md +132 -82
  18. package/docs/api/grass.md +55 -13
  19. package/docs/api/impostors.md +175 -22
  20. package/docs/api/input.md +24 -18
  21. package/docs/api/lights.md +78 -51
  22. package/docs/api/lines.md +41 -33
  23. package/docs/api/materials.md +248 -121
  24. package/docs/api/math.md +12 -13
  25. package/docs/api/objects.md +47 -22
  26. package/docs/api/page.md +58 -7
  27. package/docs/api/particles.md +33 -20
  28. package/docs/api/points.md +19 -31
  29. package/docs/api/post.md +75 -42
  30. package/docs/api/quality.md +42 -17
  31. package/docs/api/raycast.md +65 -51
  32. package/docs/api/reference/animation.md +10 -11
  33. package/docs/api/reference/assets.md +25 -22
  34. package/docs/api/reference/cameras.md +8 -4
  35. package/docs/api/reference/controls.md +134 -25
  36. package/docs/api/reference/debug.md +81 -14
  37. package/docs/api/reference/engine.md +58 -17
  38. package/docs/api/reference/feature-draws.md +3 -4
  39. package/docs/api/reference/feature-effects.md +2 -3
  40. package/docs/api/reference/feature-instances.md +5 -4
  41. package/docs/api/reference/features.md +7 -4
  42. package/docs/api/reference/geometry.md +287 -97
  43. package/docs/api/reference/grass.md +63 -3
  44. package/docs/api/reference/impostors.md +208 -13
  45. package/docs/api/reference/input.md +4 -5
  46. package/docs/api/reference/lights.md +13 -12
  47. package/docs/api/reference/lines.md +10 -11
  48. package/docs/api/reference/materials.md +54 -53
  49. package/docs/api/reference/math.md +35 -24
  50. package/docs/api/reference/objects.md +11 -12
  51. package/docs/api/reference/particles.md +31 -6
  52. package/docs/api/reference/points.md +6 -7
  53. package/docs/api/reference/post.md +21 -20
  54. package/docs/api/reference/quality.md +8 -5
  55. package/docs/api/reference/raycast.md +7 -8
  56. package/docs/api/reference/render.md +5 -4
  57. package/docs/api/reference/scene.md +52 -30
  58. package/docs/api/reference/sketch.md +15 -11
  59. package/docs/api/reference/sound.md +234 -0
  60. package/docs/api/reference/splats.md +42 -3
  61. package/docs/api/reference/sprites.md +7 -8
  62. package/docs/api/reference/tasks.md +16 -3
  63. package/docs/api/reference/terrain.md +27 -5
  64. package/docs/api/reference/textures.md +5 -6
  65. package/docs/api/reference/three-compat.md +18 -7
  66. package/docs/api/reference/time.md +1 -2
  67. package/docs/api/reference/ui.md +12 -9
  68. package/docs/api/reference/vertex-draws.md +5 -6
  69. package/docs/api/reference/water.md +153 -9
  70. package/docs/api/reference/wind.md +17 -4
  71. package/docs/api/render.md +73 -29
  72. package/docs/api/scene.md +164 -60
  73. package/docs/api/sketch.md +102 -15
  74. package/docs/api/sound.md +205 -0
  75. package/docs/api/splats.md +46 -12
  76. package/docs/api/sprites.md +10 -24
  77. package/docs/api/tasks.md +33 -24
  78. package/docs/api/terrain.md +42 -22
  79. package/docs/api/textures.md +68 -19
  80. package/docs/api/three-compat.md +15 -7
  81. package/docs/api/time.md +3 -5
  82. package/docs/api/ui.md +19 -23
  83. package/docs/api/vertex-draws.md +13 -12
  84. package/docs/api/water.md +262 -35
  85. package/docs/api/wind.md +63 -17
  86. package/docs/cli/null3d.md +177 -27
  87. package/docs/concepts/architecture.md +73 -27
  88. package/docs/concepts/assets.md +57 -33
  89. package/docs/concepts/backends.md +69 -27
  90. package/docs/concepts/color-management.md +54 -36
  91. package/docs/concepts/culling.md +68 -47
  92. package/docs/concepts/handles.md +14 -5
  93. package/docs/concepts/instances.md +74 -25
  94. package/docs/concepts/large-worlds.md +18 -8
  95. package/docs/concepts/lighting.md +155 -87
  96. package/docs/concepts/lod.md +126 -44
  97. package/docs/concepts/materials.md +58 -27
  98. package/docs/concepts/particle-buffer.md +48 -35
  99. package/docs/concepts/post-processing.md +84 -43
  100. package/docs/concepts/quality-preset-tables.md +56 -52
  101. package/docs/concepts/quality-presets.md +164 -52
  102. package/docs/concepts/render-graph.md +69 -29
  103. package/docs/concepts/render-layers.md +11 -21
  104. package/docs/concepts/shadows.md +105 -52
  105. package/docs/concepts/static-dynamic.md +22 -7
  106. package/docs/cookbook/index.md +164 -120
  107. package/docs/data/threejs-mapping.json +362 -367
  108. package/docs/errors/E1101.md +23 -5
  109. package/docs/errors/E1102.md +11 -3
  110. package/docs/errors/E1103.md +11 -3
  111. package/docs/errors/E1104.md +11 -3
  112. package/docs/errors/E1105.md +13 -5
  113. package/docs/errors/E1106.md +11 -3
  114. package/docs/errors/E1107.md +15 -5
  115. package/docs/errors/E1108.md +11 -3
  116. package/docs/errors/E1109.md +32 -6
  117. package/docs/errors/E1110.md +23 -5
  118. package/docs/errors/E1111.md +11 -3
  119. package/docs/errors/E1112.md +11 -3
  120. package/docs/errors/E1203.md +12 -4
  121. package/docs/errors/E1204.md +11 -3
  122. package/docs/errors/E1205.md +11 -3
  123. package/docs/errors/E1206.md +28 -6
  124. package/docs/errors/E1207.md +11 -3
  125. package/docs/errors/E1208.md +12 -3
  126. package/docs/errors/E1209.md +11 -3
  127. package/docs/errors/E1213.md +27 -5
  128. package/docs/errors/E1214.md +14 -6
  129. package/docs/errors/E1215.md +31 -6
  130. package/docs/errors/E1216.md +31 -6
  131. package/docs/errors/E1217.md +29 -6
  132. package/docs/errors/E1218.md +22 -6
  133. package/docs/errors/E1219.md +11 -3
  134. package/docs/errors/E1220.md +24 -5
  135. package/docs/errors/E1221.md +24 -5
  136. package/docs/errors/E1222.md +11 -3
  137. package/docs/errors/E1223.md +39 -6
  138. package/docs/errors/E1224.md +11 -3
  139. package/docs/errors/E1225.md +11 -3
  140. package/docs/errors/E1301.md +11 -3
  141. package/docs/errors/E1302.md +11 -3
  142. package/docs/errors/E1303.md +11 -3
  143. package/docs/errors/E1304.md +11 -3
  144. package/docs/errors/E1305.md +13 -3
  145. package/docs/errors/E1306.md +11 -3
  146. package/docs/errors/E1307.md +40 -0
  147. package/docs/errors/E1401.md +11 -3
  148. package/docs/errors/E1402.md +13 -5
  149. package/docs/errors/E1403.md +11 -3
  150. package/docs/errors/E1404.md +13 -3
  151. package/docs/errors/E1405.md +15 -4
  152. package/docs/errors/E1406.md +31 -5
  153. package/docs/errors/E1407.md +11 -3
  154. package/docs/errors/E1408.md +11 -3
  155. package/docs/errors/E1409.md +11 -3
  156. package/docs/errors/E1410.md +13 -5
  157. package/docs/errors/E1411.md +11 -3
  158. package/docs/errors/E1412.md +29 -6
  159. package/docs/errors/E1413.md +11 -3
  160. package/docs/errors/E1414.md +11 -3
  161. package/docs/errors/E1415.md +11 -3
  162. package/docs/errors/E1416.md +27 -6
  163. package/docs/errors/E1417.md +11 -3
  164. package/docs/errors/E1418.md +12 -3
  165. package/docs/errors/E1419.md +13 -5
  166. package/docs/errors/E1420.md +14 -6
  167. package/docs/errors/E1421.md +11 -3
  168. package/docs/errors/E1422.md +12 -3
  169. package/docs/errors/E1423.md +12 -3
  170. package/docs/errors/E1424.md +24 -5
  171. package/docs/errors/E1425.md +11 -3
  172. package/docs/errors/E1426.md +11 -3
  173. package/docs/errors/E1430.md +11 -3
  174. package/docs/errors/E1431.md +11 -3
  175. package/docs/errors/E1432.md +11 -3
  176. package/docs/errors/E1433.md +11 -3
  177. package/docs/errors/E1434.md +15 -6
  178. package/docs/errors/E1435.md +11 -3
  179. package/docs/errors/E1436.md +11 -3
  180. package/docs/errors/E1437.md +14 -6
  181. package/docs/errors/E1501.md +41 -6
  182. package/docs/errors/E1502.md +13 -3
  183. package/docs/errors/E1503.md +11 -3
  184. package/docs/errors/E1504.md +11 -3
  185. package/docs/errors/E1505.md +23 -5
  186. package/docs/errors/E1506.md +11 -3
  187. package/docs/errors/index.md +54 -30
  188. package/docs/getting-started/cdn.md +32 -10
  189. package/docs/getting-started/first-scene.md +21 -13
  190. package/docs/getting-started/hosting.md +152 -63
  191. package/docs/getting-started/install.md +44 -28
  192. package/docs/getting-started/network-use.md +33 -15
  193. package/docs/getting-started/project-structure.md +33 -12
  194. package/docs/getting-started/third-party-notices.md +12 -14
  195. package/docs/guides/accessibility.md +5 -5
  196. package/docs/guides/add-ons.md +86 -15
  197. package/docs/guides/agents.md +16 -9
  198. package/docs/guides/assets-pipeline.md +259 -82
  199. package/docs/guides/audio.md +115 -128
  200. package/docs/guides/baked-light-data.md +44 -23
  201. package/docs/guides/car-paint.md +38 -32
  202. package/docs/guides/content-pages.md +63 -35
  203. package/docs/guides/custom-passes.md +65 -22
  204. package/docs/guides/custom-shaders.md +59 -39
  205. package/docs/guides/debugging.md +74 -10
  206. package/docs/guides/deploying.md +85 -6
  207. package/docs/guides/deterministic-simulation.md +24 -17
  208. package/docs/guides/first-use-shaders.md +83 -45
  209. package/docs/guides/lens-kit.md +29 -26
  210. package/docs/guides/loading-screens.md +132 -47
  211. package/docs/guides/multiple-views.md +63 -13
  212. package/docs/guides/performance.md +192 -38
  213. package/docs/guides/phones.md +78 -15
  214. package/docs/guides/physics.md +7 -11
  215. package/docs/guides/screens.md +47 -33
  216. package/docs/guides/start-time.md +363 -0
  217. package/docs/guides/testing.md +152 -95
  218. package/docs/guides/ui-overlays.md +19 -14
  219. package/docs/guides/video-textures.md +14 -13
  220. package/docs/images/api/animation/character.webp +0 -0
  221. package/docs/images/api/animation/look-at-ring.webp +0 -0
  222. package/docs/images/api/animation/morph-tulips.webp +0 -0
  223. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  224. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  225. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  226. package/docs/images/api/debug/debug-shapes.webp +0 -0
  227. package/docs/images/api/debug/levels-view.webp +0 -0
  228. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  229. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  230. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  231. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  232. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  233. package/docs/images/api/geometry/generators.webp +0 -0
  234. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  235. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  236. package/docs/images/api/grass/grass-grove.webp +0 -0
  237. package/docs/images/api/grass/grass-presets.webp +0 -0
  238. package/docs/images/api/grass/grass-shadow.webp +0 -0
  239. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  240. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  241. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  242. package/docs/images/api/lights/spot-cookies.webp +0 -0
  243. package/docs/images/api/lines/lines-lit.webp +0 -0
  244. package/docs/images/api/lines/lines-widths.webp +0 -0
  245. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  246. package/docs/images/api/materials/decals.webp +0 -0
  247. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  248. package/docs/images/api/materials/relief.webp +0 -0
  249. package/docs/images/api/materials/shader-inputs.webp +0 -0
  250. package/docs/images/api/materials/standard-grid.webp +0 -0
  251. package/docs/images/api/materials/subsurface.webp +0 -0
  252. package/docs/images/api/materials/translucency.webp +0 -0
  253. package/docs/images/api/objects/objects-turntable.webp +0 -0
  254. package/docs/images/api/particles/campfire.webp +0 -0
  255. package/docs/images/api/points/galaxy.webp +0 -0
  256. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  257. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  258. package/docs/images/api/render/reflection-mirror.webp +0 -0
  259. package/docs/images/api/render/security-camera.webp +0 -0
  260. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  261. package/docs/images/api/sound/sound-demo.webp +0 -0
  262. package/docs/images/api/splats/splats-demo.webp +0 -0
  263. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  264. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  265. package/docs/images/api/textures/canvas-screen.webp +0 -0
  266. package/docs/images/api/textures/mipmaps.webp +0 -0
  267. package/docs/images/api/vertex-draws/rain.webp +0 -0
  268. package/docs/images/api/water/ocean.webp +0 -0
  269. package/docs/images/api/water/water-demo.webp +0 -0
  270. package/docs/images/api/water/water-rain.webp +0 -0
  271. package/docs/images/api/water/waterfall.webp +0 -0
  272. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  273. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  274. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  275. package/docs/images/concepts/instances/instances.webp +0 -0
  276. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  277. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  278. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  279. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  280. package/docs/images/concepts/lighting/environment.webp +0 -0
  281. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  282. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  283. package/docs/images/concepts/lod/forest.webp +0 -0
  284. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  285. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  286. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  287. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  288. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  289. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  290. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  291. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  292. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  293. package/docs/images/cookbook/index/picking.webp +0 -0
  294. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  295. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  296. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  297. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  298. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  299. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  300. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  301. package/docs/images/index/showcase-island.webp +0 -0
  302. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  303. package/docs/images/shaders/builtins/builtins.webp +0 -0
  304. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  305. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  306. package/docs/images/shots.json +2231 -0
  307. package/docs/index.md +18 -23
  308. package/docs/moves.json +1 -0
  309. package/docs/nav.json +300 -0
  310. package/docs/pages.md +230 -209
  311. package/docs/porting/react-three-fiber.md +225 -6
  312. package/docs/porting/threejs-loop-and-threads.md +217 -7
  313. package/docs/porting/threejs-mapping.md +1249 -233
  314. package/docs/porting/threejs-materials.md +218 -6
  315. package/docs/porting/threejs-overview.md +240 -7
  316. package/docs/porting/threejs-postprocessing.md +4 -8
  317. package/docs/porting/threejs-shaders.md +301 -6
  318. package/docs/porting/threejs-unsupported.md +83 -7
  319. package/docs/porting/verification.md +178 -6
  320. package/docs/shaders/builtins.md +15 -4
  321. package/docs/shaders/library.md +72 -45
  322. package/docs/shaders/surface-functions.md +59 -23
  323. package/docs/shaders/wgsl-rules.md +12 -5
  324. package/lib/debug/channel.d.ts +103 -0
  325. package/lib/debug/channel.js +269 -0
  326. package/lib/debug/debug.d.ts +11 -9
  327. package/lib/debug/draw.d.ts +11 -2
  328. package/lib/debug/draw.js +57 -6
  329. package/lib/debug/inspector.d.ts +60 -0
  330. package/lib/debug/inspector.js +475 -0
  331. package/lib/debug/overlay-look.d.ts +6 -0
  332. package/lib/debug/overlay-look.js +29 -7
  333. package/lib/debug/overlay.js +15 -11
  334. package/lib/debug/stats-options.d.ts +13 -0
  335. package/lib/debug/stats-panel.d.ts +22 -7
  336. package/lib/debug/stats-panel.js +80 -13
  337. package/lib/debug/stats.d.ts +2 -3
  338. package/lib/errors/codes.d.ts +17 -3
  339. package/lib/errors/codes.js +117 -105
  340. package/lib/errors/engine-error.js +25 -10
  341. package/lib/errors/fixes.d.ts +1 -0
  342. package/lib/errors/fixes.js +20 -19
  343. package/lib/generated/core.d.ts +1 -1
  344. package/lib/generated/core.js +1 -1
  345. package/lib/gpu/early-builds.d.ts +68 -0
  346. package/lib/gpu/early-builds.js +158 -0
  347. package/lib/gpu/pipeline-name.d.ts +6 -0
  348. package/lib/gpu/pipeline-name.js +23 -0
  349. package/lib/gpu/variants.d.ts +8 -2
  350. package/lib/gpu/variants.js +39 -7
  351. package/lib/gpu/webgl2/backend.d.ts +63 -2
  352. package/lib/gpu/webgl2/backend.js +226 -8
  353. package/lib/gpu/webgl2/programs.d.ts +18 -0
  354. package/lib/gpu/webgl2/programs.js +5 -2
  355. package/lib/gpu/webgpu/backend.d.ts +89 -2
  356. package/lib/gpu/webgpu/backend.js +255 -8
  357. package/lib/gpu/webgpu/pipelines.d.ts +13 -0
  358. package/lib/gpu/webgpu/pipelines.js +28 -14
  359. package/lib/index.d.ts +7 -5
  360. package/lib/index.js +3 -2
  361. package/lib/math/color.d.ts +5 -5
  362. package/lib/math/color.js +5 -5
  363. package/lib/math/mat4.d.ts +6 -12
  364. package/lib/math/mat4.js +6 -12
  365. package/lib/math/namespaces/quat.d.ts +3 -3
  366. package/lib/math/namespaces/quat.js +3 -3
  367. package/lib/math/quat.d.ts +8 -12
  368. package/lib/math/quat.js +8 -12
  369. package/lib/math/random.d.ts +2 -3
  370. package/lib/math/random.js +2 -3
  371. package/lib/math/types.d.ts +4 -4
  372. package/lib/math/vec3.d.ts +3 -6
  373. package/lib/math/vec3.js +3 -6
  374. package/lib/page/capabilities.d.ts +8 -8
  375. package/lib/page/capabilities.js +39 -25
  376. package/lib/page/check-store.d.ts +14 -2
  377. package/lib/page/check-store.js +34 -11
  378. package/lib/page/engine.d.ts +117 -31
  379. package/lib/page/engine.js +438 -99
  380. package/lib/page/first-frame.d.ts +16 -0
  381. package/lib/page/first-frame.js +35 -0
  382. package/lib/page/frame-stats.d.ts +34 -1
  383. package/lib/page/frame-stats.js +15 -0
  384. package/lib/page/label-loop.d.ts +7 -3
  385. package/lib/page/label-loop.js +26 -14
  386. package/lib/page/labels.d.ts +3 -3
  387. package/lib/page/pipeline-store.d.ts +25 -0
  388. package/lib/page/pipeline-store.js +84 -0
  389. package/lib/page/start-marker.d.ts +4 -1
  390. package/lib/page/start-marker.js +5 -2
  391. package/lib/page/stats-switch.js +2 -0
  392. package/lib/page/switches.d.ts +38 -6
  393. package/lib/page/switches.js +29 -5
  394. package/lib/quality/check.d.ts +24 -3
  395. package/lib/quality/check.js +21 -7
  396. package/lib/quality/chooser.d.ts +6 -0
  397. package/lib/quality/chooser.js +8 -0
  398. package/lib/quality/governor.d.ts +98 -6
  399. package/lib/quality/governor.js +250 -20
  400. package/lib/quality/preset-docs.d.ts +16 -1
  401. package/lib/quality/preset-docs.js +3 -0
  402. package/lib/quality/presets.d.ts +84 -7
  403. package/lib/quality/presets.js +94 -2
  404. package/lib/render/draw.d.ts +3 -2
  405. package/lib/render/draw.js +15 -5
  406. package/lib/render/load-draw.d.ts +7 -5
  407. package/lib/render/load-draw.js +7 -5
  408. package/lib/render/loss.d.ts +28 -10
  409. package/lib/render/loss.js +50 -22
  410. package/lib/render/recovery.d.ts +20 -0
  411. package/lib/render/recovery.js +44 -4
  412. package/lib/render/renderer.d.ts +85 -9
  413. package/lib/render/renderer.js +181 -42
  414. package/lib/render/scene-renderer.d.ts +19 -1
  415. package/lib/render/scene-renderer.js +25 -1
  416. package/lib/render/webgl2-renderers.js +8 -5
  417. package/lib/render/webgpu-renderers.js +5 -4
  418. package/lib/scene/animation.d.ts +28 -32
  419. package/lib/scene/animation.js +12 -15
  420. package/lib/scene/assets.d.ts +61 -86
  421. package/lib/scene/assets.js +103 -236
  422. package/lib/scene/background.d.ts +14 -18
  423. package/lib/scene/background.js +5 -2
  424. package/lib/scene/baked-light.d.ts +2 -2
  425. package/lib/scene/color.d.ts +3 -3
  426. package/lib/scene/downloads.d.ts +2 -0
  427. package/lib/scene/downloads.js +371 -0
  428. package/lib/scene/environment.d.ts +7 -7
  429. package/lib/scene/environment.js +1 -1
  430. package/lib/scene/fake-call-values.js +3 -3
  431. package/lib/scene/fog.d.ts +11 -4
  432. package/lib/scene/fog.js +8 -2
  433. package/lib/scene/frame-cameras.d.ts +35 -4
  434. package/lib/scene/frame-cameras.js +86 -10
  435. package/lib/scene/gltf.d.ts +33 -3
  436. package/lib/scene/gltf.js +78 -49
  437. package/lib/scene/grading.d.ts +2 -2
  438. package/lib/scene/grading.js +3 -3
  439. package/lib/scene/ktx2.d.ts +9 -1
  440. package/lib/scene/ktx2.js +3 -2
  441. package/lib/scene/level-rule.d.ts +121 -0
  442. package/lib/scene/level-rule.js +130 -0
  443. package/lib/scene/lines.d.ts +13 -17
  444. package/lib/scene/lines.js +3 -3
  445. package/lib/scene/lut.d.ts +1 -2
  446. package/lib/scene/lut.js +1 -2
  447. package/lib/scene/particles.d.ts +7 -3
  448. package/lib/scene/particles.js +3 -1
  449. package/lib/scene/picks.d.ts +2 -2
  450. package/lib/scene/pointer-events.d.ts +4 -7
  451. package/lib/scene/post.d.ts +39 -43
  452. package/lib/scene/post.js +4 -1
  453. package/lib/scene/prefab.d.ts +7 -8
  454. package/lib/scene/prefab.js +7 -8
  455. package/lib/scene/property-animation.d.ts +1 -1
  456. package/lib/scene/property-animation.js +1 -1
  457. package/lib/scene/queries.d.ts +7 -13
  458. package/lib/scene/resources.d.ts +238 -261
  459. package/lib/scene/resources.js +179 -81
  460. package/lib/scene/scene.d.ts +167 -120
  461. package/lib/scene/scene.js +243 -103
  462. package/lib/scene/serial-loads.d.ts +29 -0
  463. package/lib/scene/serial-loads.js +68 -0
  464. package/lib/scene/shader-preloads.d.ts +34 -0
  465. package/lib/scene/shader-preloads.js +38 -0
  466. package/lib/scene/sprites.d.ts +14 -17
  467. package/lib/scene/sprites.js +5 -6
  468. package/lib/scene/textures.d.ts +11 -12
  469. package/lib/scene/textures.js +9 -10
  470. package/lib/scene/time-of-day.d.ts +11 -7
  471. package/lib/scene/time-of-day.js +11 -8
  472. package/lib/scene/vertex-draws.d.ts +5 -4
  473. package/lib/scene/vertex-draws.js +7 -5
  474. package/lib/shader-artifact.json +1 -0
  475. package/lib/shared/core.d.ts +5 -0
  476. package/lib/shared/core.js +1 -0
  477. package/lib/shared/import-once.d.ts +6 -0
  478. package/lib/shared/import-once.js +19 -0
  479. package/lib/shared/labels.d.ts +5 -2
  480. package/lib/shared/labels.js +5 -2
  481. package/lib/shared/metrics.d.ts +38 -0
  482. package/lib/shared/metrics.js +62 -1
  483. package/lib/shared/permutation-words.d.ts +2 -0
  484. package/lib/shared/permutation-words.js +8 -0
  485. package/lib/shared/recording.d.ts +13 -5
  486. package/lib/shared/recording.js +31 -10
  487. package/lib/shared/run-task.js +7 -1
  488. package/lib/shared/sketch-data.d.ts +9 -0
  489. package/lib/shared/sketch-data.js +57 -0
  490. package/lib/shared/task-pending.d.ts +12 -0
  491. package/lib/shared/task-pending.js +61 -1
  492. package/lib/shared/tasks.js +79 -32
  493. package/lib/shared/version.d.ts +17 -1
  494. package/lib/shared/version.js +19 -1
  495. package/lib/shared/wasm.d.ts +12 -4
  496. package/lib/shared/wasm.js +50 -27
  497. package/lib/shared/worker-start.d.ts +7 -0
  498. package/lib/shared/worker-start.js +27 -0
  499. package/lib/sketch/define-sketch.d.ts +51 -7
  500. package/lib/sketch/define-sketch.js +2 -1
  501. package/lib/sketch/input.d.ts +2 -2
  502. package/lib/sketch/preset-check.d.ts +20 -6
  503. package/lib/sketch/preset-check.js +42 -17
  504. package/lib/sketch/quality.d.ts +69 -11
  505. package/lib/sketch/quality.js +54 -13
  506. package/lib/sketch/runner.d.ts +80 -9
  507. package/lib/sketch/runner.js +390 -52
  508. package/lib/sketch/ui.d.ts +5 -8
  509. package/lib/sketch/ui.js +4 -2
  510. package/lib/stats.d.ts +1 -0
  511. package/lib/workers/probe-worker.d.ts +5 -0
  512. package/lib/workers/probe-worker.js +13 -4
  513. package/lib/workers/protocol.d.ts +71 -13
  514. package/lib/workers/protocol.js +4 -0
  515. package/lib/workers/render-worker.js +29 -5
  516. package/lib/workers/sketch-worker.js +108 -16
  517. package/package.json +2 -2
@@ -0,0 +1,16 @@
1
+ import { EngineError } from '../errors/engine-error.js';
2
+ /** The first frame's promise, which the start settles once. */
3
+ export declare class FirstFrame {
4
+ readonly promise: Promise<void>;
5
+ private resolve;
6
+ private reject;
7
+ constructor();
8
+ /** The GPU has finished the first frame. */
9
+ drawn(): void;
10
+ /**
11
+ * The engine draws no more frames. `drawn` says whether the GPU finished the first frame first,
12
+ * which resolves the promise. Otherwise it rejects with `failure`, the failure that ended the
13
+ * frames, or with E1420 for a stop that no failure caused.
14
+ */
15
+ stopped(drawn: boolean, failure?: EngineError): void;
16
+ }
@@ -0,0 +1,35 @@
1
+ // `engine.firstFrame`: resolves once the GPU has finished the first frame after the setup, and
2
+ // rejects when the engine stops drawing first, so a page that waits only for the first frame
3
+ // hears why it never came. The engine starts its frames once the setup has run, and the preset
4
+ // check measures them during play, so a failure of the thread that draws at its first frame comes
5
+ // after `createEngine` has resolved.
6
+ import { EngineError } from '../errors/engine-error.js';
7
+ /** The first frame's promise, which the start settles once. */
8
+ export class FirstFrame {
9
+ promise;
10
+ resolve = () => { };
11
+ reject = () => { };
12
+ constructor() {
13
+ this.promise = new Promise((resolve, reject) => {
14
+ this.resolve = resolve;
15
+ this.reject = reject;
16
+ });
17
+ // A page that never waits for the first frame hears nothing of a rejection.
18
+ this.promise.catch(() => { });
19
+ }
20
+ /** The GPU has finished the first frame. */
21
+ drawn() {
22
+ this.resolve();
23
+ }
24
+ /**
25
+ * The engine draws no more frames. `drawn` says whether the GPU finished the first frame first,
26
+ * which resolves the promise. Otherwise it rejects with `failure`, the failure that ended the
27
+ * frames, or with E1420 for a stop that no failure caused.
28
+ */
29
+ stopped(drawn, failure) {
30
+ if (drawn)
31
+ this.resolve();
32
+ else
33
+ this.reject(failure ?? new EngineError('E1420', 'the engine stopped before it drew its first frame.'));
34
+ }
35
+ }
@@ -1,4 +1,4 @@
1
- import { type PhaseName, type RingRecords } from '../shared/metrics.js';
1
+ import { type MetricsReader, type PhaseName, type RingRecords } from '../shared/metrics.js';
2
2
  import { type Percentiles } from '../shared/stats.js';
3
3
  /**
4
4
  * One thread's CPU time per frame, in `FrameSummary.threads`.
@@ -261,6 +261,13 @@ export interface FrameMetrics extends FrameSummary {
261
261
  firstDrawMs: number | null;
262
262
  /** GPU pipelines that the first frame built, or null before the first frame. */
263
263
  firstFramePipelines: number | null;
264
+ /**
265
+ * When the thread that draws reached each step of its start, in milliseconds from the start
266
+ * of page navigation. Right after the probe, the page tells that thread which GPU path and
267
+ * device to start, so it asks for its device and its shader files while the core downloads.
268
+ * A step that the thread has not reached, or does not take, is null.
269
+ */
270
+ drawingStart: DrawingStart;
264
271
  /**
265
272
  * The quality preset in force when the first frame was drawn: the one the engine starts with.
266
273
  * It can differ from the preset the page ends on, because the engine's own preset check may
@@ -296,6 +303,32 @@ export interface FrameMetrics extends FrameSummary {
296
303
  */
297
304
  slow?: SlowFrame[];
298
305
  }
306
+ /**
307
+ * When the thread that draws reached each step of its start, in `FrameMetrics.load.drawingStart`:
308
+ * milliseconds from the start of page navigation, or null for a step that it has not reached or
309
+ * does not take.
310
+ *
311
+ * @category api/debug
312
+ */
313
+ export interface DrawingStart {
314
+ /**
315
+ * The page's message after the probe arrived. The thread then started the downloads of its
316
+ * renderers and shader files, and on WebGPU the request for its device.
317
+ */
318
+ requestMs: number | null;
319
+ /** Its WebGPU adapter arrived. Null on WebGL2. */
320
+ adapterMs: number | null;
321
+ /** Its WebGPU device arrived. Null on WebGL2. */
322
+ deviceMs: number | null;
323
+ /** The shader file of its device arrived. */
324
+ shadersMs: number | null;
325
+ /** The core and the thread's setup arrived from the page. */
326
+ initMs: number | null;
327
+ /** Its first renderer was built, so its frame loop could start. */
328
+ rendererMs: number | null;
329
+ }
330
+ /** The start of the thread that draws, as `reader` holds it, on the page's timeline. */
331
+ export declare function drawingStartFigures(reader: MetricsReader): DrawingStart;
299
332
  /**
300
333
  * The frame rates of one second of a measurement, in `FrameMetrics.perSecond`.
301
334
  *
@@ -7,6 +7,21 @@ import { commonStep, stepMs } from '../shared/gpu-clock.js';
7
7
  import { COUNTER_NAMES, Counter, GPU_TIMED_PASSES, GpuCounter, PHASE_NAMES, Role, UNTIMED, } from '../shared/metrics.js';
8
8
  import { measureWithEveryThread } from '../shared/page-measurement.js';
9
9
  import { countPerSecond, percentiles, ratePerSecond, spanMs, } from '../shared/stats.js';
10
+ /** The start of the thread that draws, as `reader` holds it, on the page's timeline. */
11
+ export function drawingStartFigures(reader) {
12
+ const at = (step) => {
13
+ const epoch = reader.drawingStep(step);
14
+ return epoch > 0 ? epoch - performance.timeOrigin : null;
15
+ };
16
+ return {
17
+ requestMs: at('request'),
18
+ adapterMs: at('adapter'),
19
+ deviceMs: at('device'),
20
+ shadersMs: at('shaders'),
21
+ initMs: at('init'),
22
+ rendererMs: at('renderer'),
23
+ };
24
+ }
10
25
  const NO_RECORDS = {
11
26
  frames: [],
12
27
  busy: [],
@@ -25,6 +25,8 @@ export declare class LabelLoop {
25
25
  private readonly seen;
26
26
  /** The camera that the containers show, and the canvas size, as the update read them. */
27
27
  private readonly cameraSeen;
28
+ /** The presented frame's camera, which the update reads with the tables. */
29
+ private readonly cameraNext;
28
30
  /** The transform of a container, and the container of each parent element that holds 3D labels. */
29
31
  private containerTransform;
30
32
  private readonly containers;
@@ -52,11 +54,13 @@ export declare class LabelLoop {
52
54
  /** Moves each bound element to its label in the frame on screen, if anything changed. */
53
55
  update(): void;
54
56
  /**
55
- * Reads each binding's place from the presented tables into `next`. Returns false when the thread
56
- * that draws kept changing the tables, so the elements stay as they are until the next update.
57
+ * Reads each binding's place from the presented tables into `next`, and the presented frame's
58
+ * camera with them, under the same sequence count, so the elements and the containers show one
59
+ * frame. Returns that count, or -1 when the thread that draws kept changing the tables, so the
60
+ * elements stay as they are until the next update.
57
61
  */
58
62
  private read;
59
- /** Moves the containers to the presented frame's camera, when the camera or the canvas changed. */
63
+ /** Moves the containers to the camera that the update read, when it or the canvas changed. */
60
64
  private updateCamera;
61
65
  /** Writes the styles of the elements whose place or view changed, after every read. */
62
66
  private write;
@@ -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. */
@@ -50,6 +50,8 @@ export class LabelLoop {
50
50
  seen = Float64Array.of(-1, 0, 0);
51
51
  /** The camera that the containers show, and the canvas size, as the update read them. */
52
52
  cameraSeen = new Float64Array(CAMERA_STATE).fill(Number.NaN);
53
+ /** The presented frame's camera, which the update reads with the tables. */
54
+ cameraNext = new Float64Array(CAMERA_STATE - 2);
53
55
  /** The transform of a container, and the container of each parent element that holds 3D labels. */
54
56
  containerTransform = '';
55
57
  containers = new Map();
@@ -146,19 +148,22 @@ export class LabelLoop {
146
148
  const sequence = labelSequence(region);
147
149
  if (!this.changed && sequence === seen[0] && width === seen[1] && height === seen[2])
148
150
  return;
149
- if (!this.read(region, count, width, height))
151
+ const read = this.read(region, count, width, height);
152
+ if (read < 0)
150
153
  return;
151
- seen[0] = labelSequence(region);
154
+ seen[0] = read;
152
155
  seen[1] = width;
153
156
  seen[2] = height;
154
157
  this.changed = false;
155
158
  if (this.three > 0)
156
- this.updateCamera(region, width, height);
159
+ this.updateCamera(width, height);
157
160
  this.write(count);
158
161
  }
159
162
  /**
160
- * Reads each binding's place from the presented tables into `next`. Returns false when the thread
161
- * that draws kept changing the tables, so the elements stay as they are until the next update.
163
+ * Reads each binding's place from the presented tables into `next`, and the presented frame's
164
+ * camera with them, under the same sequence count, so the elements and the containers show one
165
+ * frame. Returns that count, or -1 when the thread that draws kept changing the tables, so the
166
+ * elements stay as they are until the next update.
162
167
  */
163
168
  read(region, count, width, height) {
164
169
  const { ints, floats } = region;
@@ -194,17 +199,19 @@ export class LabelLoop {
194
199
  next[n + STATE_X] = ((floats[at + LABEL_X] + 1) / 2) * width;
195
200
  next[n + STATE_Y] = ((1 - floats[at + LABEL_Y]) / 2) * height;
196
201
  }
202
+ if (this.three > 0)
203
+ this.cameraNext.set(region.presentedCamera);
197
204
  if (labelSequence(region) !== sequence)
198
205
  continue;
199
206
  this.frame = frame;
200
- return true;
207
+ return sequence;
201
208
  }
202
- return false;
209
+ return -1;
203
210
  }
204
- /** Moves the containers to the presented frame's camera, when the camera or the canvas changed. */
205
- updateCamera(region, width, height) {
211
+ /** Moves the containers to the camera that the update read, when it or the canvas changed. */
212
+ updateCamera(width, height) {
206
213
  const seen = this.cameraSeen;
207
- const camera = region.presentedCamera;
214
+ const camera = this.cameraNext;
208
215
  let changed = seen[CAMERA_STATE - 2] !== width || seen[CAMERA_STATE - 1] !== height;
209
216
  for (let k = 0; k < CAMERA_STATE - 2; k++) {
210
217
  if (seen[k] !== camera[k])
@@ -399,10 +406,15 @@ export function cameraTransform(camera, width, height) {
399
406
  `${number(camera[1])},${number(-camera[4])},${number(camera[7])},0,` +
400
407
  `${number(camera[2])},${number(-camera[5])},${number(camera[8])},0,` +
401
408
  `${number(tx)},${number(-ty)},${number(tz)},1)`;
402
- const head = camera[CAMERA_ORTHO] !== 0
409
+ const lens = camera[CAMERA_ORTHO] !== 0
403
410
  ? `scale(${number(focal)}) translate(${number(-camera[CAMERA_CENTER_X])}px,${number(camera[CAMERA_CENTER_Y])}px) `
404
411
  : `perspective(${number(focal)}px) translateZ(${number(focal)}px) `;
405
- 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)`;
406
418
  }
407
419
  /** A number as CSS takes it, with the noise of a turn that did not move it set to zero. */
408
420
  function number(value) {
@@ -16,9 +16,9 @@ export interface EngineLabels {
16
16
  *
17
17
  * A label that the sketch tracks with `transform: 'world'` or `'billboard'` is a plane of the
18
18
  * scene: the engine moves the element into a container of its own inside the element's parent,
19
- * and turns it with the scene's perspective, as three.js's `CSS3DRenderer` does. Leave the
20
- * element's `transform-origin` at its center, and size the element in CSS pixels, which are the
21
- * scene's units at the distance where the view is one pixel per unit.
19
+ * and turns it with the scene's perspective. Leave the element's `transform-origin` at its
20
+ * center, and size the element in CSS pixels, which are the scene's units at the distance where
21
+ * the view is one pixel per unit.
22
22
  */
23
23
  bind(id: string, element: HTMLElement): () => void;
24
24
  }
@@ -0,0 +1,25 @@
1
+ import type { QualityPreset } from '../quality/presets.js';
2
+ import type { Tier } from '../shared/tier.js';
3
+ /**
4
+ * The facts that a pipeline list depends on, as one text: the engine's version, the GPU path, the
5
+ * device's fixed shader bits, the preset and the canvas's format. Two starts with the same text
6
+ * ask for the same pipelines for the same scene.
7
+ */
8
+ export declare function pipelineConditions(tier: Tier, shaderBits: number, preset: QualityPreset, canvasFormat: string | undefined): string;
9
+ /** True when `list` holds whole create commands only, as a thread that draws lists them. */
10
+ export declare function isPipelineList(list: readonly number[]): boolean;
11
+ /** The stored pipeline list of one sketch, for one start of it. */
12
+ export declare class PipelineStore {
13
+ private readonly conditions;
14
+ private readonly storage;
15
+ private readonly key;
16
+ /**
17
+ * `conditions` are the start's, as `pipelineConditions` gives them. `storage` stands in for the
18
+ * page's localStorage in tests.
19
+ */
20
+ constructor(sketchUrl: string, conditions: string, storage?: Storage | undefined);
21
+ /** The stored list that applies to this start, or undefined. */
22
+ read(): Uint32Array | undefined;
23
+ /** Stores the list of the pipelines that this start's first frame built. */
24
+ save(list: Uint32Array): void;
25
+ }
@@ -0,0 +1,84 @@
1
+ // The stored pipeline list: the pipelines that the first frame of each sketch's last start built,
2
+ // kept in the page's localStorage. The next start of the sketch in the same browser hands the list
3
+ // to the thread that draws, which starts those builds as soon as their shaders are there, while
4
+ // the core downloads and the setup runs (`gpu/early-builds.ts`). A start without a stored list
5
+ // builds each pipeline when the first frame asks for it. Chrome's own cache of compiled pipelines
6
+ // is small on Android, so a scene of a few dozen pipelines outgrows it and each visit compiles
7
+ // every pipeline again. A list applies only to a start on the same GPU path, with the same fixed
8
+ // shader bits, at the same preset, with the same engine version. It only names pipelines, so a
9
+ // list that the scene outgrew costs builds that no frame takes, never a wrong picture. Storage that
10
+ // cannot be read or written counts as empty.
11
+ import { OP_CREATE_COMPUTE_PIPELINE, OP_CREATE_RENDER_PIPELINE } from '../generated/gpu.js';
12
+ import { operandsAfterId, PIPELINE_LIST_LIMIT } from '../gpu/early-builds.js';
13
+ import { VERSION } from '../shared/version.js';
14
+ import { pageStorage } from './start-marker.js';
15
+ const KEY_PREFIX = 'null3d.pipelines:';
16
+ /**
17
+ * The facts that a pipeline list depends on, as one text: the engine's version, the GPU path, the
18
+ * device's fixed shader bits, the preset and the canvas's format. Two starts with the same text
19
+ * ask for the same pipelines for the same scene.
20
+ */
21
+ export function pipelineConditions(tier, shaderBits, preset, canvasFormat) {
22
+ return JSON.stringify([VERSION, tier, shaderBits, preset, canvasFormat ?? null]);
23
+ }
24
+ /** True when `list` holds whole create commands only, as a thread that draws lists them. */
25
+ export function isPipelineList(list) {
26
+ let commands = 0;
27
+ for (let i = 0; i < list.length; commands++) {
28
+ const op = list[i];
29
+ if (op !== OP_CREATE_RENDER_PIPELINE && op !== OP_CREATE_COMPUTE_PIPELINE)
30
+ return false;
31
+ const end = i + 1 + operandsAfterId(op);
32
+ if (end > list.length || commands >= PIPELINE_LIST_LIMIT)
33
+ return false;
34
+ for (let k = i + 1; k < end; k++) {
35
+ const word = list[k];
36
+ if (!Number.isInteger(word) || word < 0 || word > 0xffffffff)
37
+ return false;
38
+ }
39
+ i = end;
40
+ }
41
+ return list.length > 0;
42
+ }
43
+ /** The stored pipeline list of one sketch, for one start of it. */
44
+ export class PipelineStore {
45
+ conditions;
46
+ storage;
47
+ key;
48
+ /**
49
+ * `conditions` are the start's, as `pipelineConditions` gives them. `storage` stands in for the
50
+ * page's localStorage in tests.
51
+ */
52
+ constructor(sketchUrl, conditions, storage = pageStorage()) {
53
+ this.conditions = conditions;
54
+ this.storage = storage;
55
+ this.key = KEY_PREFIX + sketchUrl;
56
+ }
57
+ /** The stored list that applies to this start, or undefined. */
58
+ read() {
59
+ try {
60
+ const text = this.storage?.getItem(this.key);
61
+ if (!text)
62
+ return undefined;
63
+ const stored = JSON.parse(text);
64
+ if (stored?.conditions !== this.conditions || !Array.isArray(stored.list))
65
+ return undefined;
66
+ return isPipelineList(stored.list) ? Uint32Array.from(stored.list) : undefined;
67
+ }
68
+ catch {
69
+ return undefined;
70
+ }
71
+ }
72
+ /** Stores the list of the pipelines that this start's first frame built. */
73
+ save(list) {
74
+ if (!isPipelineList(Array.from(list)))
75
+ return;
76
+ const stored = { conditions: this.conditions, list: Array.from(list) };
77
+ try {
78
+ this.storage?.setItem(this.key, JSON.stringify(stored));
79
+ }
80
+ catch {
81
+ // The next start builds each pipeline when its first frame asks for it.
82
+ }
83
+ }
84
+ }
@@ -37,7 +37,10 @@ export declare class StartMarker {
37
37
  * and removes it when the page leaves.
38
38
  */
39
39
  begin(history: StartHistory, tier: Tier): void;
40
- /** Removes the note once the engine has drawn for `playMs` after `firstFrame`. */
40
+ /**
41
+ * Removes the note once the engine has drawn for `playMs` after `firstFrame`. A first frame that
42
+ * never comes leaves the note to the stop, which removes it.
43
+ */
41
44
  endAfter(firstFrame: Promise<void>, playMs?: number): void;
42
45
  /** Removes the note, if this page load wrote it. Later calls do nothing. */
43
46
  end(): void;
@@ -90,12 +90,15 @@ export class StartMarker {
90
90
  }
91
91
  globalThis.addEventListener?.('pagehide', this.onPageHide);
92
92
  }
93
- /** Removes the note once the engine has drawn for `playMs` after `firstFrame`. */
93
+ /**
94
+ * Removes the note once the engine has drawn for `playMs` after `firstFrame`. A first frame that
95
+ * never comes leaves the note to the stop, which removes it.
96
+ */
94
97
  endAfter(firstFrame, playMs = STABLE_PLAY_MS) {
95
98
  void firstFrame.then(() => {
96
99
  if (!this.ended)
97
100
  this.timer = setTimeout(() => this.end(), playMs);
98
- });
101
+ }, () => { });
99
102
  }
100
103
  /** Removes the note, if this page load wrote it. Later calls do nothing. */
101
104
  end() {
@@ -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');
@@ -1,5 +1,5 @@
1
1
  import type { StatsRequest } from '../debug/stats-options.js';
2
- import type { TargetFps } from '../quality/check.js';
2
+ import { type PresetCheckTiming, type TargetFps } from '../quality/check.js';
3
3
  import { type QualityPreset } from '../quality/presets.js';
4
4
  export type GpuSwitch = 'auto' | 'webgpu' | 'compat' | 'webgl2';
5
5
  /**
@@ -34,17 +34,25 @@ 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
- * `standard` depth, the near plane stores 0, as in three.js's WebGL renderer.
42
+ * `standard` depth, the near plane stores 0 and the far plane 1.
42
43
  *
43
44
  * @category api/engine
44
45
  */
45
46
  export type DepthMode = 'reversed' | 'reversed-gl' | 'standard';
46
47
  /** A format of the HDR scene color that the ?scene-format= switch names. */
47
48
  export type SceneFormat = 'rg11b10' | 'rgba16f';
49
+ /**
50
+ * The quality tier that ?tier= names: `lowest` starts the page in the tier below the four presets,
51
+ * with its start values; `off` keeps the governor out of the tier, so a test measures the presets
52
+ * alone. Without the switch the governor enters the tier only when frames still miss at the
53
+ * preset's floor (D-382).
54
+ */
55
+ export type LowestTier = 'lowest' | 'off';
48
56
  /** The bits per texel of the shadow cascades' depth. */
49
57
  export type ShadowDepthBits = 16 | 32;
50
58
  /**
@@ -108,6 +116,11 @@ export interface Switches {
108
116
  * of taking the preset check's stored result from an earlier start.
109
117
  */
110
118
  freshCheck: boolean;
119
+ /**
120
+ * True when ?builds=fresh makes the first frame start every pipeline build itself, as on a first
121
+ * visit, instead of building the stored list of an earlier start's first frame ahead of it.
122
+ */
123
+ freshBuilds: boolean;
111
124
  /**
112
125
  * True when ?two-step=report makes a development page log the two-step pass's answers once the
113
126
  * first frame is on screen: whether the frame wanted the pass, declared it, had its second step
@@ -231,6 +244,12 @@ export interface Switches {
231
244
  * the page's `targetFps` option, or undefined without the switch or with another value.
232
245
  */
233
246
  targetFps: TargetFps | undefined;
247
+ /**
248
+ * When the preset check measures, from ?preset-check=: `during-play` or `before-play`, which
249
+ * wins over the page's `presetCheck` option, or undefined without the switch or with another
250
+ * value.
251
+ */
252
+ presetCheck: PresetCheckTiming | undefined;
234
253
  /**
235
254
  * The most job workers that ?jobs= lets the engine start, or undefined for the count from the
236
255
  * device's cores. The engine starts them as the work grows, and no more than the device has
@@ -253,6 +272,13 @@ export interface Switches {
253
272
  * crash marker, or undefined without the switch or with a name that is no preset.
254
273
  */
255
274
  preset: QualityPreset | undefined;
275
+ /**
276
+ * `'lowest'` when ?tier=lowest starts the page in the lowest quality tier: the render scale at
277
+ * a third, the sun's shadows and bloom off, and WebGL2's depth prepass off. The tier exists for
278
+ * tests, devices and a known weak class, while the governor is the default path to it. Undefined
279
+ * for any other name, or without the switch.
280
+ */
281
+ lowestTier: LowestTier | undefined;
256
282
  /**
257
283
  * The text of ?hold=, an empty text for a bare ?hold, or undefined without the switch. The
258
284
  * engine checks it when it starts, so a bad time fails at once instead of starting a live engine.
@@ -274,6 +300,11 @@ export interface Switches {
274
300
  still: boolean;
275
301
  /** True when ?bench asks the engine to publish itself on the page for a benchmark tool. */
276
302
  bench: boolean;
303
+ /**
304
+ * True when ?inspect opens the development build's in-page inspector, which lists the scene,
305
+ * selects an object and edits its transform, material and visibility.
306
+ */
307
+ inspect: boolean;
277
308
  /**
278
309
  * The debug view that ?view= asks for, by the name that `debug.view` takes: one of the engine's
279
310
  * own views, or a view that an add-on's feature registers. Undefined without the switch.
@@ -281,8 +312,9 @@ export interface Switches {
281
312
  view: string | undefined;
282
313
  /**
283
314
  * True when a bare ?stats or ?stats=on shows the stats overlay, false when ?stats=off hides it,
284
- * options when ?stats=collapsed or ?stats=open shows it collapsed or open, and undefined without
285
- * 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.
286
318
  */
287
319
  stats: StatsRequest | undefined;
288
320
  /**
@@ -17,12 +17,16 @@
17
17
  // in a pass each, none joined, for pages that measure what joining saves. ?replay-delay= makes the
18
18
  // thread that draws wait before it replays each frame's list, for a test of memory that the sketch
19
19
  // thread frees while the list may still point at it. ?hold starts hold mode for image tests, ?preset= fixes the quality preset,
20
- // ?target-fps= sets the frame rate that the engine defends, ?bench publishes the running engine
20
+ // ?tier=lowest starts in the lowest quality tier, ?target-fps= sets the frame rate that the
21
+ // engine defends, ?preset-check= says whether the preset check measures during play or before it,
22
+ // ?bench publishes the running engine
21
23
  // for benchmark tools, ?gl-timing times each WebGL call for benchmark pages, ?stats shows the
22
24
  // stats overlay, and ?view picks a debug view, one of the engine's own or one that an add-on's
23
25
  // feature registers.
26
+ import { PRESET_CHECK_TIMINGS } from '../quality/check.js';
24
27
  import { QUALITY_PRESETS, QUALITY_SETTINGS } from '../quality/presets.js';
25
28
  const SCENE_FORMATS = ['rg11b10', 'rgba16f'];
29
+ const LOWEST_TIERS = ['lowest', 'off'];
26
30
  const COMPRESSION_FAMILIES = ['astc', 'bc', 'etc2'];
27
31
  /** The longest wait that ?replay-delay= gives, in ms: longer would stall the frames for good. */
28
32
  const MAX_REPLAY_DELAY_MS = 1000;
@@ -51,11 +55,27 @@ function oneOf(value, allowed) {
51
55
  function onOff(value) {
52
56
  return value === 'on' ? true : value === 'off' ? false : undefined;
53
57
  }
54
- /** ?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
+ */
55
63
  function statsSwitch(value) {
56
- return value === 'collapsed' || value === 'open'
57
- ? { collapsed: value === 'collapsed' }
58
- : 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;
59
79
  }
60
80
  /** A number above 0, or undefined for a missing or unusable value. */
61
81
  function positive(value) {
@@ -97,6 +117,7 @@ export function parseSwitches(search) {
97
117
  parallelCompile: params.get('compile') !== 'wait',
98
118
  freshShaders: params.get('shaders') === 'fresh',
99
119
  freshCheck: params.get('check') === 'fresh',
120
+ freshBuilds: params.get('builds') === 'fresh',
100
121
  wakeByMessage: params.get('wake') === 'message',
101
122
  twoStep: params.get('two-step') === 'report',
102
123
  displayChecks: params.get('display-check') !== 'off',
@@ -119,15 +140,18 @@ export function parseSwitches(search) {
119
140
  derivedCache: params.get('derived-cache') !== 'off',
120
141
  fps: positive(params.get('fps')),
121
142
  targetFps: params.get('target-fps') === 'display' ? 'display' : whole(params.get('target-fps')),
143
+ presetCheck: oneOf(params.get('preset-check'), PRESET_CHECK_TIMINGS),
122
144
  jobs: whole(params.get('jobs'), MAX_JOB_WORKERS),
123
145
  queue: params.get('queue') === 'off' ? Number.POSITIVE_INFINITY : whole(params.get('queue')),
124
146
  memoryMiB: within(whole(params.get('memory')), MEMORY_MIB.min, MEMORY_MIB.max),
125
147
  preset: oneOf(params.get('preset'), QUALITY_PRESETS),
148
+ lowestTier: oneOf(params.get('tier'), LOWEST_TIERS),
126
149
  hold: params.get('hold') ?? undefined,
127
150
  replay: params.get('replay') ?? undefined,
128
151
  record: params.has('record'),
129
152
  still: params.get('still-camera') !== 'off',
130
153
  bench: params.has('bench'),
154
+ inspect: params.has('inspect'),
131
155
  view: params.get('view') || undefined,
132
156
  stats: statsSwitch(params.get('stats')),
133
157
  permutations: params.get('permutations') === 'record' ? 'record' : undefined,