@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
@@ -293,12 +293,12 @@ function probeWebGL2(powerPreference, multiDraw = true) {
293
293
  */
294
294
  const WORKER_PROBE_TIMEOUTS_MS = [5000, 10_000];
295
295
  /**
296
- * Runs the probe worker, with each of `timeoutsMs` in turn as its time limit while it gives no
297
- * answer. A worker that fails to start is not tried again.
296
+ * Runs the probe worker on the GPU that `powerPreference` picks, with each of `timeoutsMs` in turn
297
+ * as its time limit while it gives no answer. A worker that fails to start is not tried again.
298
298
  */
299
- export async function probeWorker(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS) {
299
+ export async function probeWorker(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS, powerPreference) {
300
300
  for (const timeoutMs of timeoutsMs) {
301
- const result = await probeWorkerOnce(timeoutMs);
301
+ const result = await probeWorkerOnce(timeoutMs, powerPreference);
302
302
  if (!('failure' in result) || result.failure !== 'no-answer')
303
303
  return result;
304
304
  }
@@ -309,34 +309,39 @@ export async function probeWorker(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS) {
309
309
  };
310
310
  }
311
311
  /**
312
- * The probe worker's answer that the page's engine starts share. Firefox makes a new WebGL2
313
- * context wait for the WebGL work that other contexts have queued, such as a shader link. On a
314
- * software renderer an engine's links take seconds, so a start's probe can outlast its time
315
- * limits while another engine on the page starts. A worker's abilities hold for the page's life,
316
- * so one full answer serves every later start. A failure is not kept.
312
+ * The probe worker's answers that the page's engine starts share, by the power preference that
313
+ * picked the GPU they tested. Firefox makes a new WebGL2 context wait for the WebGL work that other
314
+ * contexts have queued, such as a shader link. On a software renderer an engine's links take
315
+ * seconds, so a start's probe can outlast its time limits while another engine on the page starts.
316
+ * A worker's abilities hold for the page's life, so one full answer serves every later start on
317
+ * the same GPU. A failure is not kept.
317
318
  */
318
- let pageProbe;
319
+ const pageProbes = new Map();
319
320
  /**
320
- * The probe worker's answer for the page: the kept answer, the answer of a probe that is running,
321
- * or a new probe's, with `timeoutsMs` as its time limits.
321
+ * The probe worker's answer for the page on the GPU that `powerPreference` picks: the kept answer,
322
+ * the answer of a probe that is running, or a new probe's, with `timeoutsMs` as its time limits.
322
323
  */
323
- export function pageWorkerProbe(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS) {
324
- if (pageProbe)
325
- return pageProbe;
326
- const probe = probeWorker(timeoutsMs);
327
- pageProbe = probe;
324
+ export function pageWorkerProbe(timeoutsMs = WORKER_PROBE_TIMEOUTS_MS, powerPreference) {
325
+ const kept = pageProbes.get(powerPreference);
326
+ if (kept)
327
+ return kept;
328
+ const probe = probeWorker(timeoutsMs, powerPreference);
329
+ pageProbes.set(powerPreference, probe);
328
330
  void probe.then((result) => {
329
- if ('failure' in result && pageProbe === probe)
330
- pageProbe = undefined;
331
+ if ('failure' in result && pageProbes.get(powerPreference) === probe)
332
+ pageProbes.delete(powerPreference);
331
333
  });
332
334
  return probe;
333
335
  }
334
- /** Drops the kept answer, as after a lost GPU, so that the next start probes again. */
336
+ /** Drops the kept answers, as after a lost GPU, so that the next start probes again. */
335
337
  export function forgetWorkerProbe() {
336
- pageProbe = undefined;
338
+ pageProbes.clear();
337
339
  }
338
- /** Runs one probe worker, which must answer within `timeoutMs` of its script's start. */
339
- function probeWorkerOnce(timeoutMs) {
340
+ /**
341
+ * Runs one probe worker on the GPU that `powerPreference` picks, which must answer within
342
+ * `timeoutMs` of its script's start.
343
+ */
344
+ function probeWorkerOnce(timeoutMs, powerPreference) {
340
345
  return new Promise((resolve) => {
341
346
  let worker;
342
347
  try {
@@ -364,6 +369,8 @@ function probeWorkerOnce(timeoutMs) {
364
369
  failure: 'failed-to-start',
365
370
  error: message || 'the probe worker failed to start',
366
371
  }));
372
+ // The worker reads this once its script runs, and probes then.
373
+ worker.postMessage({ powerPreference });
367
374
  });
368
375
  }
369
376
  /**
@@ -372,7 +379,14 @@ function probeWorkerOnce(timeoutMs) {
372
379
  * reports WebGL2 without `WEBGL_multi_draw`, as the ?multidraw=off switch asks.
373
380
  */
374
381
  export async function probeCapabilities(powerPreference, hints = readDeviceHints(), multiDraw = true) {
375
- const [webgpu, worker] = await Promise.all([probeWebGPU(powerPreference), pageWorkerProbe()]);
382
+ const pending = Promise.all([
383
+ probeWebGPU(powerPreference),
384
+ pageWorkerProbe(WORKER_PROBE_TIMEOUTS_MS, powerPreference),
385
+ ]);
386
+ // The WebGL2 test blocks this thread, so it runs while the adapter request and the probe worker
387
+ // are under way.
388
+ const webgl2 = probeWebGL2(powerPreference, multiDraw);
389
+ const [webgpu, worker] = await pending;
376
390
  // The probe worker measures the draw paths on a device of its own, which the render worker's
377
391
  // device answers the same way for the browser and the driver.
378
392
  const probed = 'directDraws' in worker && webgpu.available;
@@ -389,7 +403,7 @@ export async function probeCapabilities(powerPreference, hints = readDeviceHints
389
403
  transferControlToOffscreen: typeof HTMLCanvasElement === 'function' &&
390
404
  'transferControlToOffscreen' in HTMLCanvasElement.prototype,
391
405
  webgpu: { ...webgpu, directDraws, drawPath },
392
- webgl2: probeWebGL2(powerPreference, multiDraw),
406
+ webgl2,
393
407
  worker,
394
408
  };
395
409
  }
@@ -9,6 +9,16 @@ export declare const STORED_CHECK_MS: number;
9
9
  * larger canvas has more pixels to fill, and a smaller one may hold a heavier preset.
10
10
  */
11
11
  export declare const STORED_CHECK_AREA_RATIO = 1.25;
12
+ /**
13
+ * True when a check's rounds end it: its last round held the target, or measured Low, which has no
14
+ * lighter preset. A check that lowered the preset after its last round has not ended.
15
+ */
16
+ export declare function checkEnded(check: Pick<PresetCheck, 'targetFps' | 'rounds'>): boolean;
17
+ /**
18
+ * The preset that a check's rounds leave the engine at: the last round's preset when the check
19
+ * ended there, or else the one that the check lowered to after the last round missed its target.
20
+ */
21
+ export declare function checkedPreset(check: Pick<PresetCheck, 'from' | 'targetFps' | 'rounds'>): QualityPreset;
12
22
  /**
13
23
  * The facts that a check's result depends on, apart from the canvas size, as one text: the check's
14
24
  * rules, the GPU path and the preset that the check starts from, the frame rate cap, the highest
@@ -18,7 +28,8 @@ export declare const STORED_CHECK_AREA_RATIO = 1.25;
18
28
  export declare function checkConditions(report: CapabilityReport, tier: Tier, from: QualityPreset, fps: number | undefined, maxTargetFps: number): string;
19
29
  /**
20
30
  * The stored result that applies to a start under `conditions` with a canvas of `area` CSS
21
- * pixels at `now`, as a reused check, or undefined when none does.
31
+ * pixels at `now`, as a reused check, or undefined when none does. A check that has not ended
32
+ * gives its rounds so far, which the start's own check goes on from (`checkEnded`).
22
33
  */
23
34
  export declare function reusableCheck(text: string | null, conditions: string, area: number, now: number): PresetCheck | undefined;
24
35
  /** The stored preset check of one sketch, for one start of it. */
@@ -35,7 +46,8 @@ export declare class CheckStore {
35
46
  /** The stored result that applies to this start, or undefined. */
36
47
  read(now?: number): PresetCheck | undefined;
37
48
  /**
38
- * Stores the result of a check that this start measured, when it measured against at least the
49
+ * Stores what a check of this start measured: its result once it ended, and its rounds so far
50
+ * each time it lowers the preset. It stores them when they were measured against at least the
39
51
  * target that the check starts from under the highest target `maxTargetFps`.
40
52
  */
41
53
  save(check: PresetCheck, maxTargetFps: number, now?: number): void;
@@ -1,15 +1,18 @@
1
1
  // The stored preset check: the result of each sketch's last preset check, kept in the page's
2
2
  // localStorage, so that a later start of the sketch in the same browser on the same device takes
3
3
  // the checked preset without measuring again. On a tablet the check takes about a second for each
4
- // preset that it measures, and the page's loading screen waits for it. A stored result applies only
5
- // to a start that would check the same preset with the same rules, on a GPU and display that report
6
- // the same facts, at a canvas size close to the measured one, within a week of the measurement. A
7
- // result measured against a target below the one that the engine starts from, as on a display in a
8
- // power-saving mode, is not stored. The highest target that the page allows is one of the facts, so
9
- // a result never applies to a start that defends another rate. Storage that cannot be read or written counts as empty. The GPU's names only tell
10
- // one GPU from another here; the engine never decides anything from what they say.
11
- import { CHECK_GRACE_MS, CHECK_HOLD_SHARE, CHECK_MAX_FPS, CHECK_UPLOAD_WAIT_MS, CHECK_WINDOW_MS, checkTargetFps, } from '../quality/check.js';
12
- import { QUALITY_PRESETS } from '../quality/presets.js';
4
+ // preset that it measures. A stored result applies only to a start that would check the same
5
+ // preset with the same rules, on a GPU and display that report the same facts, at a canvas size
6
+ // close to the measured one, within a week of the measurement. The store also keeps the rounds of
7
+ // a check that has not ended yet, each time the check lowers the preset, so a page that closes
8
+ // during the check loses no round: the next start begins at the lighter preset, and its own check
9
+ // goes on from there. A result measured against a target below the one that the engine starts
10
+ // from, as on a display in a power-saving mode, is not stored. The highest target that the page
11
+ // allows is one of the facts, so a result never applies to a start that defends another rate.
12
+ // Storage that cannot be read or written counts as empty. The GPU's names only tell one GPU from
13
+ // another here; the engine never decides anything from what they say.
14
+ import { CHECK_GRACE_MS, CHECK_HOLD_SHARE, CHECK_MAX_FPS, CHECK_UPLOAD_WAIT_MS, CHECK_WINDOW_MS, checkTargetFps, holdsTarget, } from '../quality/check.js';
15
+ import { presetAfterMiss, QUALITY_PRESETS } from '../quality/presets.js';
13
16
  import { pageStorage } from './start-marker.js';
14
17
  /** How long a stored check result applies, in ms: a week. */
15
18
  export const STORED_CHECK_MS = 7 * 24 * 60 * 60 * 1000;
@@ -19,6 +22,24 @@ export const STORED_CHECK_MS = 7 * 24 * 60 * 60 * 1000;
19
22
  */
20
23
  export const STORED_CHECK_AREA_RATIO = 1.25;
21
24
  const KEY_PREFIX = 'null3d.check:';
25
+ /**
26
+ * True when a check's rounds end it: its last round held the target, or measured Low, which has no
27
+ * lighter preset. A check that lowered the preset after its last round has not ended.
28
+ */
29
+ export function checkEnded(check) {
30
+ const last = check.rounds.at(-1);
31
+ return last !== undefined && (last.preset === 'low' || holdsTarget(last, check.targetFps));
32
+ }
33
+ /**
34
+ * The preset that a check's rounds leave the engine at: the last round's preset when the check
35
+ * ended there, or else the one that the check lowered to after the last round missed its target.
36
+ */
37
+ export function checkedPreset(check) {
38
+ const last = check.rounds.at(-1);
39
+ if (!last)
40
+ return check.from;
41
+ return checkEnded(check) ? last.preset : presetAfterMiss(last, check.targetFps);
42
+ }
22
43
  const isPreset = (value) => QUALITY_PRESETS.includes(value);
23
44
  const isRound = (round) => round !== null &&
24
45
  isPreset(round.preset) &&
@@ -81,7 +102,8 @@ export function checkConditions(report, tier, from, fps, maxTargetFps) {
81
102
  }
82
103
  /**
83
104
  * The stored result that applies to a start under `conditions` with a canvas of `area` CSS
84
- * pixels at `now`, as a reused check, or undefined when none does.
105
+ * pixels at `now`, as a reused check, or undefined when none does. A check that has not ended
106
+ * gives its rounds so far, which the start's own check goes on from (`checkEnded`).
85
107
  */
86
108
  export function reusableCheck(text, conditions, area, now) {
87
109
  const stored = parseStored(text);
@@ -123,7 +145,8 @@ export class CheckStore {
123
145
  }
124
146
  }
125
147
  /**
126
- * Stores the result of a check that this start measured, when it measured against at least the
148
+ * Stores what a check of this start measured: its result once it ended, and its rounds so far
149
+ * each time it lowers the preset. It stores them when they were measured against at least the
127
150
  * target that the check starts from under the highest target `maxTargetFps`.
128
151
  */
129
152
  save(check, maxTargetFps, now = Date.now()) {
@@ -2,8 +2,9 @@ import type { StatsOverlayOptions, StatsRequest } from '../debug/stats-options.j
2
2
  import { EngineError } from '../errors/engine-error.js';
3
3
  import { type ShaderFeature } from '../generated/shader-features.js';
4
4
  import type { DrawPathReason } from '../gpu/webgpu/draw-path-probe.js';
5
- import { type PresetCheck, type TargetFps } from '../quality/check.js';
5
+ import { type PresetCheck, type PresetCheckTiming, type TargetFps } from '../quality/check.js';
6
6
  import { type QualityPreset } from '../quality/presets.js';
7
+ import type { GpuErrorKind } from '../render/loss.js';
7
8
  import type { Tier } from '../render/renderer.js';
8
9
  import type { ReplayResult } from '../shared/recording.js';
9
10
  import type { QualityUpdate } from '../sketch/quality.js';
@@ -32,6 +33,15 @@ export interface EngineOptions {
32
33
  canvas: HTMLCanvasElement;
33
34
  /** The sketch module, which runs in the sketch worker; `new URL('./sketch.ts', import.meta.url)`. */
34
35
  sketch: URL | string;
36
+ /**
37
+ * Start data for the sketch, which its setup reads as `ctx.data`: the state that the page knows
38
+ * before the scene starts, such as the section that the address names, a saved color mode or a
39
+ * level number. It reaches the setup before the first frame, also in hold mode, where no message
40
+ * can. It takes plain JSON data: objects, arrays, strings, finite numbers, booleans and null, up
41
+ * to 64 KiB as JSON. Another value fails with E1213. A recording keeps it, and a replay gives
42
+ * the sketch the recorded data.
43
+ */
44
+ sketchData?: unknown;
35
45
  /**
36
46
  * The quality preset: `auto`, the default, lets the engine choose one for the device, and
37
47
  * `low`, `medium`, `high` or `ultra` names one. The GPU path caps it: WebGL2 and WebGPU's
@@ -48,6 +58,18 @@ export interface EngineOptions {
48
58
  * E1213.
49
59
  */
50
60
  targetFps?: TargetFps;
61
+ /**
62
+ * When the preset check measures, on a start where the engine checks the preset that it chose.
63
+ * With `during-play`, the default, the scene shows at its first frame: `createEngine` resolves
64
+ * once the setup has run, and `engine.firstFrame` once the GPU has finished the first frame. The
65
+ * check then measures the first frames of play, a lighter preset applies in front of the viewer,
66
+ * and `engine.presetChecked` resolves once the check has ended. With `before-play`, the check
67
+ * measures the scene that the setup built before the sketch's update runs, and `createEngine`
68
+ * resolves after it, so a loading screen hides the check and any change of preset. A start that
69
+ * takes the stored result of an earlier check, or that runs no check, plays at once either way.
70
+ * Another value fails with E1213. The `?preset-check=` switch wins over it.
71
+ */
72
+ presetCheck?: PresetCheckTiming;
51
73
  /**
52
74
  * Cap for the device pixel ratio, a number from 0.5 up. Without it, the quality preset sets the
53
75
  * cap. `ctx.quality.set` changes it during play.
@@ -112,8 +134,8 @@ export interface EngineOptions {
112
134
  * shaded once, for its nearest surface. It saves GPU time in scenes where objects hide many
113
135
  * others and shading costs much, and costs a second pass over the objects' vertices. Without
114
136
  * it, the quality preset decides: every preset draws the prepass on WebGL2, and none on WebGPU.
115
- * The prepass stays fixed while the engine runs, and the `?prepass=on` or `?prepass=off`
116
- * switch wins over this option. Another value fails with E1213.
137
+ * A sketch can change it during play with `quality.set`, and the `?prepass=on` or
138
+ * `?prepass=off` switch wins over this option. Another value fails with E1213.
117
139
  */
118
140
  depthPrepass?: boolean;
119
141
  /**
@@ -175,7 +197,8 @@ export interface EngineOptions {
175
197
  * one more copy of each image in memory. False frees each copy once no frame reads it, and such
176
198
  * a texture draws with its color alone until the sketch gives it texels again. Without this
177
199
  * option, a phone and a tablet keep copies and a desktop does not, because a phone or a tablet
178
- * is likeliest to lose its GPU.
200
+ * is likeliest to lose its GPU. With copies, the engine also gives its GPU back while the browser
201
+ * keeps the page in its back/forward cache, and starts a new device when the page shows again.
179
202
  */
180
203
  keepTextureCopies?: boolean;
181
204
  /**
@@ -186,8 +209,8 @@ export interface EngineOptions {
186
209
  transparent?: boolean;
187
210
  /**
188
211
  * False draws the scene into 8-bit color, where each material's shader applies the output
189
- * transform, instead of HDR color, which the final pass tone maps. Both paths honour a
190
- * material's `toneMapped: false`, and the 8-bit path also honours it on a blended surface. The
212
+ * transform, instead of HDR color, which the final pass tone maps. Both paths honor a
213
+ * material's `toneMapped: false`, and the 8-bit path also honors it on a blended surface. The
191
214
  * default lets the engine pick the path from the device, which draws HDR color wherever it
192
215
  * can. The `?hdr=off` switch takes the 8-bit path too.
193
216
  */
@@ -248,7 +271,9 @@ export interface EngineOptions {
248
271
  * Called as the start reaches each stage, in this order: `core-download` as the engine core's
249
272
  * file downloads, with the bytes that have arrived; `core` once the engine core is compiled and
250
273
  * the GPU paths are tested; `sketch` once the sketch's setup has run; and `first-frame` once the
251
- * GPU has finished the first frame. Before `core`, `core-download` reports the core file's bytes,
274
+ * GPU has finished the first frame after the setup. The preset check does not hold up either
275
+ * stage, unless the `presetCheck` option is `before-play`: `sketch` then comes after the check
276
+ * too. Before `core`, `core-download` reports the core file's bytes,
252
277
  * and `memory-wait` comes when the browser has refused the engine's memory for 10 seconds. The
253
278
  * engine then tries for about 35 seconds more before it fails with E1109. `progress` gives a
254
279
  * stage's figures while it has some: the bytes of a download, measured against the length that
@@ -323,8 +348,8 @@ export interface EngineOptions {
323
348
  * lets light through to its other side,
324
349
  * `'subsurface'` with the first material with a `subsurfaceRadius` while the subsurface blur has
325
350
  * taps, `'coat_sheen'` with the first material with a clear coat or a sheen, `'weighted'` with
326
- * the first material of the `weighted` blending, and `'occlusion'` with the first opaque object that
327
- * may hide others while GPU occlusion culling runs on WebGPU. WebGPU morphs in the skinning pass, so there
351
+ * the first material of the `weighted` blending, and `'occlusion'` with the first opaque
352
+ * material while GPU occlusion culling runs on WebGPU. WebGPU morphs in the skinning pass, so there
328
353
  * `'morph'` loads the skinning shaders, and WebGL2 has no `'occlusion'` shaders to load. Listed
329
354
  * features download beside the engine's own
330
355
  * shaders, so the start waits only for the largest. The shaders that two or more listed features
@@ -460,16 +485,20 @@ export interface EngineMode {
460
485
  /** The sketch time in seconds that hold mode holds the sketch at, or null for a live engine. */
461
486
  hold: number | null;
462
487
  /**
463
- * The quality preset that the engine runs. The preset check can lower it before `createEngine`
464
- * resolves, and `ctx.quality.setPreset` in the sketch changes it later.
488
+ * The quality preset that the engine runs now. The preset check can lower it while it runs:
489
+ * during the first frames of play, or before `createEngine` resolves with the `presetCheck`
490
+ * option's `before-play`. `ctx.quality.setPreset` in the sketch changes it later. Once
491
+ * `engine.presetChecked` has resolved, it holds the preset that the check chose.
465
492
  */
466
493
  preset: QualityPreset;
467
494
  /**
468
- * What the preset check measured, or null when no check ran. The engine checks the preset when
469
- * it chose it from the device: after the first frame, it measures the frame rate of the scene
470
- * that the setup built, and lowers the preset until one holds the target. A later start of the
471
- * sketch in the same browser on the same device takes the stored result instead, and starts at
472
- * its preset. `reused` is then true.
495
+ * What the preset check measured, or null while the check runs, and when no check ran or the
496
+ * sketch chose its own preset first. The engine checks the preset when it chose it from the
497
+ * device: after the first frame, it measures the frame rate of the scene, and lowers the preset
498
+ * until one holds the target. A later start of the sketch in the same browser on the same
499
+ * device takes the stored result instead, and starts at its preset. `reused` is then true. A
500
+ * start after a check that never ended starts at the preset that the check had lowered to, and
501
+ * its own check goes on from there, with the earlier rounds first.
473
502
  */
474
503
  presetCheck: PresetCheck | null;
475
504
  /**
@@ -519,10 +548,21 @@ export interface Engine {
519
548
  /** How the engine runs on this device. */
520
549
  readonly mode: EngineMode;
521
550
  /**
522
- * Resolves once the GPU has finished the first frame, so it is on screen: the moment to remove
523
- * a loading screen. It never resolves when the engine is destroyed first.
551
+ * Resolves once the GPU has finished the first frame after the setup, so it is on screen: the
552
+ * moment to remove a loading screen. It rejects when the engine stops drawing first, with the
553
+ * failure that ended its frames, such as E1404 when the thread that draws fails at its first
554
+ * frame. A destroy before the first frame rejects it with E1420. A page that never waits for it
555
+ * gets no unhandled rejection.
524
556
  */
525
557
  readonly firstFrame: Promise<void>;
558
+ /**
559
+ * Resolves once the preset check has ended, so `mode.preset` holds the preset that the check
560
+ * chose and `mode.presetCheck` what it measured. It has resolved when `createEngine` resolves
561
+ * where no check runs: for a preset that the page names, a stored result, Low, and hold mode,
562
+ * and with the `presetCheck` option's `before-play`. When the engine stops drawing first, it
563
+ * resolves then, and `mode.presetCheck` stays null.
564
+ */
565
+ readonly presetChecked: Promise<void>;
526
566
  /** The HTML elements that follow the labels the sketch tracks with `ui.trackLabel`. */
527
567
  readonly labels: EngineLabels;
528
568
  /**
@@ -549,11 +589,12 @@ export interface Engine {
549
589
  * not carry on with a new device (E1302), or an engine thread failed (E1404). A custom shader's
550
590
  * builds that a pipeline needs and that did not download fail the thread that draws with E1424.
551
591
  * After E1404 or E1424 the engine draws no new frames: destroy it and start a new one. On WebGPU,
552
- * the GPU can also run out of memory (E1304) or reject the engine's work (E1305), and the engine
553
- * draws on without the objects that failed. The engine reports each failure once. A failure that
554
- * no handler listened for when the engine reported it reaches the first handler that listens, so
555
- * a failure that the app could not hear yet still arrives, and the engine also logs it to the
556
- * console. A failure that ends the frames reaches these handlers before `onStop`'s. Returns a
592
+ * the GPU can also run out of memory (E1304) or reject the engine's work (E1305). On either GPU
593
+ * path, its driver can refuse to build a pipeline that draws objects of the scene twice (E1307).
594
+ * After these three the engine draws on without the objects that failed. The engine reports each
595
+ * failure once. A failure that no handler listened for when the engine reported it reaches the
596
+ * first handler that listens, so a failure that the app could not hear yet still arrives, and the
597
+ * engine also logs it to the console. A failure that ends the frames reaches these handlers before `onStop`'s. Returns a
557
598
  * function that removes the handler.
558
599
  */
559
600
  onFailure(handler: (error: EngineError) => void): () => void;
@@ -598,12 +639,22 @@ export interface Engine {
598
639
  */
599
640
  measure(seconds: number, options?: MeasureOptions): Promise<FrameMetrics>;
600
641
  /**
601
- * Shows an overlay of figures over the top-right corner of the canvas, or hides it with
642
+ * Runs an inspection call against the live scene, for the in-page inspector and the MCP server:
643
+ * `objects`, `object`, `setObject`, `setMaterial`, `stats`, `errors`, `graph`, `setQuality`,
644
+ * `highlight` and `info`, with the arguments that [Debugging](../../guides/debugging.md#the-in-page-inspector)
645
+ * lists. The call runs between frames, in the thread that runs the sketch, and its value is
646
+ * JSON-safe. The page answers `capture` itself, with `{ png, bytes }`: the PNG image of the next
647
+ * frame as base64 text, and its size in bytes. The method exists only in a development build, which is the build that carries the channel; a
648
+ * release build leaves it out, so code that uses it must check for it first.
649
+ */
650
+ inspect?(call: string, args?: unknown): Promise<unknown>;
651
+ /**
652
+ * Shows an overlay of figures over a right-hand corner of the canvas, or hides it with
602
653
  * `false`: the GPU path, the frame rates, CPU time per frame of each thread, GPU time, draw
603
654
  * calls, triangles and objects drawn, memory, and the page thread's long tasks and input delay.
604
655
  * Its header is a button with the frame rate, which shows and hides the other figures. Options
605
- * pick whether the overlay starts collapsed to its header; a call on a shown overlay changes
606
- * the options it names. The page draws the overlay and updates it a few times a second, and its
656
+ * pick whether the overlay starts collapsed to its header, and its corner: the top right by
657
+ * default, or the bottom right. A call on a shown overlay changes the options it names. The page draws the overlay and updates it a few times a second, and its
607
658
  * code downloads at the first call. While the other figures show, the engine times one frame in
608
659
  * eleven on the GPU and reads back the counts of the objects that the GPU culls, which costs a
609
660
  * little GPU time. The sketch's `debug.stats` shows and hides the same overlay, and the last
@@ -699,6 +750,13 @@ export interface Engine {
699
750
  * the page to wait with no end.
700
751
  */
701
752
  export declare const WORKER_REPLY_LIMIT_MS = 600000;
753
+ /**
754
+ * How long a copy of a worker whose script did not load may take to report its first reply. A
755
+ * script that loads reports in about a second on the slowest machines that run the tests, so a
756
+ * copy that has sent nothing by this time never ran: the page fails the start with E1405 rather
757
+ * than waiting for a worker that may never speak.
758
+ */
759
+ export declare const RETRY_REPLY_MS = 10000;
702
760
  interface TierChoice {
703
761
  tier: Tier;
704
762
  forceCompat: boolean;
@@ -724,9 +782,11 @@ interface WorkerEvents {
724
782
  sketchError(error: Error): void;
725
783
  /**
726
784
  * A failure of a thread. It ends a start that is still under way, unless `endsStart` is false:
727
- * the engine then runs on without the thread.
785
+ * the engine then runs on without the thread. It ends hold mode's read-back of its frame too,
786
+ * unless `endsHold` is false: the frames never needed the thread, such as a job worker that did
787
+ * not start.
728
788
  */
729
- failure(error: EngineError, endsStart?: boolean): void;
789
+ failure(error: EngineError, endsStart?: boolean, endsHold?: boolean): void;
730
790
  /** The quality preset and settings after a change, and the preset check's result. */
731
791
  quality(update: QualityUpdate): void;
732
792
  /** The sketch asked to show or hide the stats overlay, or to change its options. */
@@ -743,12 +803,15 @@ interface WorkerEvents {
743
803
  recording?(bytes: Uint8Array): void;
744
804
  /** What a replay gave, after the sketch thread ran the recording's frames. */
745
805
  replay?(result: ReplayResult): void;
806
+ /** The pipeline list of the pipelines that the first frame built, which the page stores. */
807
+ pipelineList?(list: Uint32Array): void;
746
808
  }
747
809
  /**
748
- * The error of a GPU that ran out of memory (E1304) or rejected a command (E1305), on `thread`, such
749
- * as "the render worker".
810
+ * The error of a GPU that ran out of memory (E1304), rejected a command (E1305), or whose driver
811
+ * could not build a pipeline of the scene's objects (E1307), on `thread`, such as "the render
812
+ * worker". `message` names the pipeline for E1307.
750
813
  */
751
- export declare function gpuFailure(thread: string, outOfMemory: boolean, message: string): EngineError;
814
+ export declare function gpuFailure(thread: string, kind: GpuErrorKind, message: string): EngineError;
752
815
  /**
753
816
  * A worker whose replies are routed: events to the page's handlers, answers to the oldest request.
754
817
  * A failure that a started worker reports, or that ends it, reaches the page as E1404, or with its
@@ -767,6 +830,12 @@ export declare class EngineWorker {
767
830
  */
768
831
  private readonly restart?;
769
832
  private readonly waiting;
833
+ /**
834
+ * The inspection calls that wait for their answers, by their id. A production build never makes
835
+ * one, so the map is made at the first call.
836
+ */
837
+ private inspectWaiters;
838
+ private nextInspect;
770
839
  private readyPromise;
771
840
  private readonly stoppedPromise;
772
841
  private worker;
@@ -780,6 +849,8 @@ export declare class EngineWorker {
780
849
  private scriptLoaded;
781
850
  /** True once the page replaced a worker whose script did not load. */
782
851
  private retried;
852
+ /** Clears the wait for the replacement worker's first reply, or undefined once it has one. */
853
+ private retryTimer;
783
854
  /**
784
855
  * The messages that the page sent before the worker reported that its script loaded. A worker
785
856
  * that has not run its script cannot take them, so they wait here: a copy that replaces a
@@ -810,6 +881,14 @@ export declare class EngineWorker {
810
881
  * shows which file failed.
811
882
  */
812
883
  private startFailure;
884
+ /**
885
+ * What the page reports when the copy that replaced a worker whose script did not load has sent
886
+ * nothing within the wait. The first failure named the script; the copy's silence names it too,
887
+ * so a wrong path stays visible and a stall is not read as a wrong path.
888
+ */
889
+ private stalledFailure;
890
+ /** Ends the wait for a replacement worker's first reply, once one arrives or the worker fails. */
891
+ private heardReply;
813
892
  /**
814
893
  * Drops the handlers that reach this engine, so a worker that the page keeps, such as a drawing
815
894
  * worker parked with its canvas, holds none of the engine or its shared memory alive.
@@ -845,6 +924,13 @@ export declare class EngineWorker {
845
924
  stopped(): Promise<void>;
846
925
  /** Stops the worker, and fails each request that still waits for its answer. */
847
926
  terminate(): void;
927
+ /**
928
+ * Runs a development build's inspection call in this worker, and waits for its answer. The
929
+ * worker answers with the value of the call, or why it failed.
930
+ */
931
+ inspect(call: string, args?: unknown): Promise<unknown>;
932
+ /** Gives an inspection call its answer. */
933
+ private answerInspect;
848
934
  /**
849
935
  * Sends a request and waits for the worker's answer, which ends with a failure once the answer
850
936
  * has taken longer than the wait's limit. The request keeps its place in the queue, so an answer