@null3d/engine 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/dist/wasm/single/null3d.js +10 -8
  2. package/dist/wasm/single/null3d_bg.wasm +0 -0
  3. package/dist/wasm/threaded/null3d.js +10 -8
  4. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  5. package/docs/api/animation.md +96 -24
  6. package/docs/api/assets.md +99 -29
  7. package/docs/api/cameras.md +38 -7
  8. package/docs/api/controls.md +47 -23
  9. package/docs/api/debug.md +105 -35
  10. package/docs/api/engine.md +108 -32
  11. package/docs/api/feature-draws.md +21 -15
  12. package/docs/api/feature-effects.md +8 -8
  13. package/docs/api/feature-instances.md +68 -17
  14. package/docs/api/features.md +68 -37
  15. package/docs/api/geometry.md +83 -14
  16. package/docs/api/grass.md +55 -13
  17. package/docs/api/impostors.md +92 -50
  18. package/docs/api/input.md +22 -9
  19. package/docs/api/lights.md +67 -16
  20. package/docs/api/lines.md +38 -13
  21. package/docs/api/materials.md +187 -59
  22. package/docs/api/math.md +6 -6
  23. package/docs/api/objects.md +40 -15
  24. package/docs/api/page.md +58 -7
  25. package/docs/api/particles.md +36 -11
  26. package/docs/api/points.md +18 -8
  27. package/docs/api/post.md +57 -23
  28. package/docs/api/quality.md +36 -16
  29. package/docs/api/raycast.md +57 -24
  30. package/docs/api/reference/animation.md +1 -2
  31. package/docs/api/reference/assets.md +7 -4
  32. package/docs/api/reference/cameras.md +3 -2
  33. package/docs/api/reference/controls.md +59 -2
  34. package/docs/api/reference/debug.md +58 -6
  35. package/docs/api/reference/engine.md +39 -10
  36. package/docs/api/reference/feature-draws.md +3 -4
  37. package/docs/api/reference/feature-effects.md +2 -3
  38. package/docs/api/reference/feature-instances.md +5 -4
  39. package/docs/api/reference/features.md +7 -4
  40. package/docs/api/reference/geometry.md +132 -21
  41. package/docs/api/reference/grass.md +62 -2
  42. package/docs/api/reference/impostors.md +120 -16
  43. package/docs/api/reference/input.md +1 -2
  44. package/docs/api/reference/lights.md +4 -3
  45. package/docs/api/reference/lines.md +3 -4
  46. package/docs/api/reference/materials.md +7 -6
  47. package/docs/api/reference/math.md +13 -2
  48. package/docs/api/reference/objects.md +2 -3
  49. package/docs/api/reference/particles.md +31 -6
  50. package/docs/api/reference/points.md +2 -3
  51. package/docs/api/reference/post.md +4 -3
  52. package/docs/api/reference/quality.md +1 -2
  53. package/docs/api/reference/raycast.md +1 -2
  54. package/docs/api/reference/render.md +4 -3
  55. package/docs/api/reference/scene.md +24 -5
  56. package/docs/api/reference/sketch.md +11 -11
  57. package/docs/api/reference/sound.md +33 -2
  58. package/docs/api/reference/splats.md +42 -3
  59. package/docs/api/reference/sprites.md +2 -3
  60. package/docs/api/reference/tasks.md +16 -3
  61. package/docs/api/reference/terrain.md +26 -5
  62. package/docs/api/reference/textures.md +1 -2
  63. package/docs/api/reference/three-compat.md +18 -7
  64. package/docs/api/reference/time.md +1 -2
  65. package/docs/api/reference/ui.md +10 -7
  66. package/docs/api/reference/vertex-draws.md +2 -3
  67. package/docs/api/reference/water.md +78 -5
  68. package/docs/api/reference/wind.md +15 -2
  69. package/docs/api/render.md +67 -25
  70. package/docs/api/scene.md +129 -36
  71. package/docs/api/sketch.md +45 -19
  72. package/docs/api/sound.md +48 -12
  73. package/docs/api/splats.md +42 -15
  74. package/docs/api/sprites.md +8 -6
  75. package/docs/api/tasks.md +31 -22
  76. package/docs/api/terrain.md +44 -12
  77. package/docs/api/textures.md +61 -12
  78. package/docs/api/three-compat.md +15 -7
  79. package/docs/api/time.md +3 -5
  80. package/docs/api/ui.md +18 -10
  81. package/docs/api/vertex-draws.md +13 -12
  82. package/docs/api/water.md +111 -67
  83. package/docs/api/wind.md +61 -15
  84. package/docs/cli/null3d.md +90 -15
  85. package/docs/concepts/architecture.md +69 -23
  86. package/docs/concepts/assets.md +57 -16
  87. package/docs/concepts/backends.md +65 -25
  88. package/docs/concepts/color-management.md +42 -13
  89. package/docs/concepts/culling.md +68 -47
  90. package/docs/concepts/handles.md +14 -5
  91. package/docs/concepts/instances.md +72 -23
  92. package/docs/concepts/large-worlds.md +17 -7
  93. package/docs/concepts/lighting.md +117 -44
  94. package/docs/concepts/lod.md +128 -33
  95. package/docs/concepts/materials.md +43 -12
  96. package/docs/concepts/particle-buffer.md +48 -35
  97. package/docs/concepts/post-processing.md +77 -14
  98. package/docs/concepts/quality-preset-tables.md +3 -2
  99. package/docs/concepts/quality-presets.md +122 -39
  100. package/docs/concepts/render-graph.md +56 -21
  101. package/docs/concepts/render-layers.md +9 -5
  102. package/docs/concepts/shadows.md +96 -25
  103. package/docs/concepts/static-dynamic.md +22 -7
  104. package/docs/cookbook/index.md +163 -119
  105. package/docs/data/threejs-mapping.json +301 -340
  106. package/docs/errors/E1101.md +23 -5
  107. package/docs/errors/E1102.md +11 -3
  108. package/docs/errors/E1103.md +11 -3
  109. package/docs/errors/E1104.md +11 -3
  110. package/docs/errors/E1105.md +13 -5
  111. package/docs/errors/E1106.md +11 -3
  112. package/docs/errors/E1107.md +15 -5
  113. package/docs/errors/E1108.md +11 -3
  114. package/docs/errors/E1109.md +32 -6
  115. package/docs/errors/E1110.md +23 -5
  116. package/docs/errors/E1111.md +11 -3
  117. package/docs/errors/E1112.md +11 -3
  118. package/docs/errors/E1203.md +12 -4
  119. package/docs/errors/E1204.md +11 -3
  120. package/docs/errors/E1205.md +11 -3
  121. package/docs/errors/E1206.md +28 -6
  122. package/docs/errors/E1207.md +11 -3
  123. package/docs/errors/E1208.md +12 -3
  124. package/docs/errors/E1209.md +11 -3
  125. package/docs/errors/E1213.md +27 -5
  126. package/docs/errors/E1214.md +11 -3
  127. package/docs/errors/E1215.md +31 -6
  128. package/docs/errors/E1216.md +31 -6
  129. package/docs/errors/E1217.md +29 -6
  130. package/docs/errors/E1218.md +22 -6
  131. package/docs/errors/E1219.md +11 -3
  132. package/docs/errors/E1220.md +24 -5
  133. package/docs/errors/E1221.md +24 -5
  134. package/docs/errors/E1222.md +11 -3
  135. package/docs/errors/E1223.md +39 -6
  136. package/docs/errors/E1224.md +11 -3
  137. package/docs/errors/E1225.md +11 -3
  138. package/docs/errors/E1301.md +11 -3
  139. package/docs/errors/E1302.md +11 -3
  140. package/docs/errors/E1303.md +11 -3
  141. package/docs/errors/E1304.md +11 -3
  142. package/docs/errors/E1305.md +13 -3
  143. package/docs/errors/E1306.md +11 -3
  144. package/docs/errors/E1307.md +23 -6
  145. package/docs/errors/E1401.md +11 -3
  146. package/docs/errors/E1402.md +13 -5
  147. package/docs/errors/E1403.md +11 -3
  148. package/docs/errors/E1404.md +13 -3
  149. package/docs/errors/E1405.md +15 -4
  150. package/docs/errors/E1406.md +31 -5
  151. package/docs/errors/E1407.md +11 -3
  152. package/docs/errors/E1408.md +11 -3
  153. package/docs/errors/E1409.md +11 -3
  154. package/docs/errors/E1410.md +13 -5
  155. package/docs/errors/E1411.md +11 -3
  156. package/docs/errors/E1412.md +29 -6
  157. package/docs/errors/E1413.md +11 -3
  158. package/docs/errors/E1414.md +11 -3
  159. package/docs/errors/E1415.md +11 -3
  160. package/docs/errors/E1416.md +27 -6
  161. package/docs/errors/E1417.md +11 -3
  162. package/docs/errors/E1418.md +12 -3
  163. package/docs/errors/E1419.md +13 -5
  164. package/docs/errors/E1420.md +11 -3
  165. package/docs/errors/E1421.md +11 -3
  166. package/docs/errors/E1422.md +12 -3
  167. package/docs/errors/E1423.md +12 -3
  168. package/docs/errors/E1424.md +24 -5
  169. package/docs/errors/E1425.md +11 -3
  170. package/docs/errors/E1426.md +11 -3
  171. package/docs/errors/E1430.md +11 -3
  172. package/docs/errors/E1431.md +11 -3
  173. package/docs/errors/E1432.md +11 -3
  174. package/docs/errors/E1433.md +11 -3
  175. package/docs/errors/E1434.md +15 -6
  176. package/docs/errors/E1435.md +11 -3
  177. package/docs/errors/E1436.md +11 -3
  178. package/docs/errors/E1437.md +14 -6
  179. package/docs/errors/E1501.md +41 -6
  180. package/docs/errors/E1502.md +13 -3
  181. package/docs/errors/E1503.md +11 -3
  182. package/docs/errors/E1504.md +11 -3
  183. package/docs/errors/E1505.md +23 -5
  184. package/docs/errors/E1506.md +11 -3
  185. package/docs/errors/index.md +52 -29
  186. package/docs/getting-started/cdn.md +15 -9
  187. package/docs/getting-started/first-scene.md +20 -12
  188. package/docs/getting-started/hosting.md +111 -63
  189. package/docs/getting-started/install.md +39 -24
  190. package/docs/getting-started/network-use.md +31 -21
  191. package/docs/getting-started/project-structure.md +20 -8
  192. package/docs/getting-started/third-party-notices.md +6 -10
  193. package/docs/guides/accessibility.md +4 -4
  194. package/docs/guides/add-ons.md +83 -13
  195. package/docs/guides/agents.md +2 -6
  196. package/docs/guides/assets-pipeline.md +248 -72
  197. package/docs/guides/audio.md +17 -15
  198. package/docs/guides/baked-light-data.md +44 -23
  199. package/docs/guides/car-paint.md +37 -31
  200. package/docs/guides/content-pages.md +53 -29
  201. package/docs/guides/custom-passes.md +59 -17
  202. package/docs/guides/custom-shaders.md +54 -37
  203. package/docs/guides/debugging.md +31 -41
  204. package/docs/guides/deploying.md +6 -27
  205. package/docs/guides/deterministic-simulation.md +23 -16
  206. package/docs/guides/first-use-shaders.md +83 -45
  207. package/docs/guides/lens-kit.md +29 -26
  208. package/docs/guides/loading-screens.md +70 -30
  209. package/docs/guides/multiple-views.md +22 -11
  210. package/docs/guides/performance.md +188 -37
  211. package/docs/guides/phones.md +71 -19
  212. package/docs/guides/physics.md +6 -10
  213. package/docs/guides/screens.md +41 -29
  214. package/docs/guides/start-time.md +120 -85
  215. package/docs/guides/testing.md +137 -98
  216. package/docs/guides/ui-overlays.md +17 -12
  217. package/docs/guides/video-textures.md +14 -13
  218. package/docs/images/api/animation/character.webp +0 -0
  219. package/docs/images/api/animation/look-at-ring.webp +0 -0
  220. package/docs/images/api/animation/morph-tulips.webp +0 -0
  221. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  222. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  223. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  224. package/docs/images/api/debug/debug-shapes.webp +0 -0
  225. package/docs/images/api/debug/levels-view.webp +0 -0
  226. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  227. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  228. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  229. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  230. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  231. package/docs/images/api/geometry/generators.webp +0 -0
  232. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  233. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  234. package/docs/images/api/grass/grass-grove.webp +0 -0
  235. package/docs/images/api/grass/grass-presets.webp +0 -0
  236. package/docs/images/api/grass/grass-shadow.webp +0 -0
  237. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  238. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  239. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  240. package/docs/images/api/lights/spot-cookies.webp +0 -0
  241. package/docs/images/api/lines/lines-lit.webp +0 -0
  242. package/docs/images/api/lines/lines-widths.webp +0 -0
  243. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  244. package/docs/images/api/materials/decals.webp +0 -0
  245. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  246. package/docs/images/api/materials/relief.webp +0 -0
  247. package/docs/images/api/materials/shader-inputs.webp +0 -0
  248. package/docs/images/api/materials/standard-grid.webp +0 -0
  249. package/docs/images/api/materials/subsurface.webp +0 -0
  250. package/docs/images/api/materials/translucency.webp +0 -0
  251. package/docs/images/api/objects/objects-turntable.webp +0 -0
  252. package/docs/images/api/particles/campfire.webp +0 -0
  253. package/docs/images/api/points/galaxy.webp +0 -0
  254. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  255. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  256. package/docs/images/api/render/reflection-mirror.webp +0 -0
  257. package/docs/images/api/render/security-camera.webp +0 -0
  258. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  259. package/docs/images/api/sound/sound-demo.webp +0 -0
  260. package/docs/images/api/splats/splats-demo.webp +0 -0
  261. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  262. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  263. package/docs/images/api/textures/canvas-screen.webp +0 -0
  264. package/docs/images/api/textures/mipmaps.webp +0 -0
  265. package/docs/images/api/vertex-draws/rain.webp +0 -0
  266. package/docs/images/api/water/ocean.webp +0 -0
  267. package/docs/images/api/water/water-demo.webp +0 -0
  268. package/docs/images/api/water/water-rain.webp +0 -0
  269. package/docs/images/api/water/waterfall.webp +0 -0
  270. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  271. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  272. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  273. package/docs/images/concepts/instances/instances.webp +0 -0
  274. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  275. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  276. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  277. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  278. package/docs/images/concepts/lighting/environment.webp +0 -0
  279. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  280. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  281. package/docs/images/concepts/lod/forest.webp +0 -0
  282. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  283. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  284. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  285. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  286. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  287. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  288. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  289. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  290. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  291. package/docs/images/cookbook/index/picking.webp +0 -0
  292. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  293. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  294. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  295. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  296. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  297. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  298. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  299. package/docs/images/index/showcase-island.webp +0 -0
  300. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  301. package/docs/images/shaders/builtins/builtins.webp +0 -0
  302. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  303. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  304. package/docs/images/shots.json +2231 -0
  305. package/docs/index.md +14 -23
  306. package/docs/moves.json +1 -0
  307. package/docs/nav.json +300 -0
  308. package/docs/pages.md +230 -212
  309. package/docs/porting/react-three-fiber.md +2 -6
  310. package/docs/porting/threejs-loop-and-threads.md +1 -5
  311. package/docs/porting/threejs-mapping.md +1248 -234
  312. package/docs/porting/threejs-materials.md +10 -5
  313. package/docs/porting/threejs-overview.md +26 -6
  314. package/docs/porting/threejs-postprocessing.md +2 -6
  315. package/docs/porting/threejs-shaders.md +16 -14
  316. package/docs/porting/threejs-unsupported.md +6 -6
  317. package/docs/porting/verification.md +0 -4
  318. package/docs/shaders/builtins.md +15 -4
  319. package/docs/shaders/library.md +9 -6
  320. package/docs/shaders/surface-functions.md +51 -16
  321. package/docs/shaders/wgsl-rules.md +12 -5
  322. package/lib/debug/debug.d.ts +2 -2
  323. package/lib/debug/draw.d.ts +2 -2
  324. package/lib/debug/draw.js +8 -4
  325. package/lib/debug/overlay-look.d.ts +6 -0
  326. package/lib/debug/overlay-look.js +29 -7
  327. package/lib/debug/overlay.js +15 -11
  328. package/lib/debug/stats-options.d.ts +13 -0
  329. package/lib/debug/stats-panel.d.ts +21 -6
  330. package/lib/debug/stats-panel.js +80 -13
  331. package/lib/errors/codes.d.ts +17 -3
  332. package/lib/errors/codes.js +111 -105
  333. package/lib/errors/fixes.js +18 -18
  334. package/lib/gpu/variants.d.ts +8 -2
  335. package/lib/gpu/variants.js +39 -7
  336. package/lib/gpu/webgl2/programs.js +1 -1
  337. package/lib/gpu/webgpu/pipelines.js +13 -13
  338. package/lib/index.d.ts +1 -1
  339. package/lib/page/capabilities.d.ts +1 -1
  340. package/lib/page/engine.d.ts +14 -5
  341. package/lib/page/engine.js +18 -2
  342. package/lib/page/label-loop.js +9 -4
  343. package/lib/page/stats-switch.js +2 -0
  344. package/lib/page/switches.d.ts +6 -4
  345. package/lib/page/switches.js +20 -4
  346. package/lib/scene/baked-light.d.ts +2 -2
  347. package/lib/scene/fake-call-values.js +2 -2
  348. package/lib/scene/frame-cameras.d.ts +16 -4
  349. package/lib/scene/frame-cameras.js +28 -10
  350. package/lib/scene/gltf.d.ts +1 -1
  351. package/lib/scene/level-rule.d.ts +6 -5
  352. package/lib/scene/level-rule.js +2 -2
  353. package/lib/scene/particles.d.ts +7 -3
  354. package/lib/scene/particles.js +3 -1
  355. package/lib/scene/post.d.ts +3 -2
  356. package/lib/scene/resources.d.ts +15 -9
  357. package/lib/scene/scene.d.ts +18 -2
  358. package/lib/scene/scene.js +47 -5
  359. package/lib/scene/time-of-day.d.ts +10 -5
  360. package/lib/scene/time-of-day.js +11 -7
  361. package/lib/shader-artifact.json +1 -1
  362. package/lib/shared/labels.d.ts +5 -2
  363. package/lib/shared/labels.js +5 -2
  364. package/lib/shared/permutation-words.d.ts +2 -0
  365. package/lib/shared/permutation-words.js +8 -0
  366. package/lib/shared/recording.d.ts +13 -5
  367. package/lib/shared/recording.js +31 -10
  368. package/lib/shared/sketch-data.d.ts +9 -0
  369. package/lib/shared/sketch-data.js +57 -0
  370. package/lib/shared/version.d.ts +1 -1
  371. package/lib/shared/version.js +1 -1
  372. package/lib/sketch/define-sketch.d.ts +16 -7
  373. package/lib/sketch/define-sketch.js +2 -1
  374. package/lib/sketch/runner.d.ts +4 -0
  375. package/lib/sketch/runner.js +5 -0
  376. package/lib/sketch/ui.js +4 -2
  377. package/lib/stats.d.ts +1 -0
  378. package/lib/workers/protocol.d.ts +10 -0
  379. package/lib/workers/render-worker.js +4 -1
  380. package/lib/workers/sketch-worker.js +4 -1
  381. package/package.json +1 -1
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/controls
3
3
  title: "Controls (@null3d/controls): API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Controls (@null3d/controls) API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -16,6 +15,8 @@ summary: "Every export of the Controls (@null3d/controls) API, from the engine's
16
15
  function createDragControls(context: SketchContext, camera: PerspectiveCamera | OrthographicCamera, objects: Object3D[], options: DragControlsOptions = {}): DragControls
17
16
  ```
18
17
 
18
+ Import from `@null3d/controls`.
19
+
19
20
  Creates drag controls. A press on one of `objects` drags it over a plane that faces the camera, and the right button or an option turns it instead. `controls.update(dt)` reads the input once per frame in `onUpdate`, and `controls.dragging` names the object that the pointer holds. Pass the sketch's context first, as the other controls take it.
20
21
 
21
22
  ## `createFirstPersonControls`
@@ -24,6 +25,8 @@ Creates drag controls. A press on one of `objects` drags it over a plane that fa
24
25
  function createFirstPersonControls(ctx: SketchContext, camera: PerspectiveCamera | OrthographicCamera, options: FirstPersonControlsOptions = {}): FirstPersonControls
25
26
  ```
26
27
 
28
+ Import from `@null3d/controls`.
29
+
27
30
  Creates first-person controls. Keys walk, and a drag looks around. While the page holds the pointer lock, which `engine.requestPointerLock()` asks for, the mouse turns the view. Call `controls.update(dt)` once per frame in `onUpdate`.
28
31
 
29
32
  ## `createFlyControls`
@@ -32,6 +35,8 @@ Creates first-person controls. Keys walk, and a drag looks around. While the pag
32
35
  function createFlyControls(ctx: SketchContext, camera: PerspectiveCamera | OrthographicCamera, options: FlyControlsOptions = {}): FlyControls
33
36
  ```
34
37
 
38
+ Import from `@null3d/controls`.
39
+
35
40
  Creates fly controls. W, A, S, D, R and F move the camera, the arrow keys turn it, Q and E roll it, and the pointer steers it. Call `controls.update(dt)` once per frame in `onUpdate`.
36
41
 
37
42
  ## `createMapControls`
@@ -40,6 +45,8 @@ Creates fly controls. W, A, S, D, R and F move the camera, the arrow keys turn i
40
45
  function createMapControls(ctx: SketchContext, camera: PerspectiveCamera | OrthographicCamera, options: OrbitControlsOptions = {}): MapControls
41
46
  ```
42
47
 
48
+ Import from `@null3d/controls`.
49
+
43
50
  Creates map controls. A left drag or one finger pans over the ground. The wheel, a pinch and a middle drag dolly the camera. A right drag or two fingers turn it. Call `controls.update(dt)` once per frame in `onUpdate`.
44
51
 
45
52
  ## `createOrbitControls`
@@ -48,6 +55,8 @@ Creates map controls. A left drag or one finger pans over the ground. The wheel,
48
55
  function createOrbitControls(ctx: SketchContext, camera: PerspectiveCamera | OrthographicCamera, options: OrbitControlsOptions = {}): OrbitControls
49
56
  ```
50
57
 
58
+ Import from `@null3d/controls`.
59
+
51
60
  Creates orbit controls. A left drag or one finger turns the camera around the target. The wheel, a pinch and a middle drag dolly it. A right drag or two fingers pan. Call `controls.update(dt)` once per frame in `onUpdate`.
52
61
 
53
62
  ## `createTransformControls`
@@ -56,6 +65,8 @@ Creates orbit controls. A left drag or one finger turns the camera around the ta
56
65
  function createTransformControls(context: SketchContext, camera: PerspectiveCamera | OrthographicCamera, options: TransformControlsOptions = {}): TransformControls
57
66
  ```
58
67
 
68
+ Import from `@null3d/controls`.
69
+
59
70
  Creates translate, rotate and scale gizmos for one object. `attach` picks the object, `setMode` picks what a drag does, and `controls.update(dt)` reads the input once per frame in `onUpdate`. A press on a handle begins the drag, and `controls.dragging` is true until the pointer comes up, so a sketch can leave its camera controls alone meanwhile.
60
71
 
61
72
  ## `DragAction`
@@ -64,12 +75,16 @@ Creates translate, rotate and scale gizmos for one object. `attach` picks the ob
64
75
  type DragAction = 'pan' | 'rotate';
65
76
  ```
66
77
 
78
+ Import from `@null3d/controls`.
79
+
67
80
  What a held button or a finger does to a draggable object: drag it over a plane that faces the camera, or turn it about the camera's axes.
68
81
 
69
82
  ## `DragControls`
70
83
 
71
84
  Class `DragControls`.
72
85
 
86
+ Import from `@null3d/controls`.
87
+
73
88
  Drag controls: they drag the objects of a list over a plane that faces the camera, or turn them about the camera's axes. `createDragControls` makes them. Call `update(dt)` once per frame in `onUpdate`.
74
89
 
75
90
  | Member | Description |
@@ -91,6 +106,8 @@ Drag controls: they drag the objects of a list over a plane that faces the camer
91
106
 
92
107
  Interface `DragControlsOptions`.
93
108
 
109
+ Import from `@null3d/controls`.
110
+
94
111
  Options for `createDragControls`. The controls keep each option except `layers` as a property of the same name, which a sketch can change at any time.
95
112
 
96
113
  | Member | Description |
@@ -107,6 +124,8 @@ Options for `createDragControls`. The controls keep each option except `layers`
107
124
 
108
125
  Interface `DragMouseButtons`.
109
126
 
127
+ Import from `@null3d/controls`.
128
+
110
129
  The action of each mouse button. Null gives a button no action.
111
130
 
112
131
  | Member | Description |
@@ -119,6 +138,8 @@ The action of each mouse button. Null gives a button no action.
119
138
 
120
139
  Interface `DragTouchActions`.
121
140
 
141
+ Import from `@null3d/controls`.
142
+
122
143
  The action of one finger on the canvas.
123
144
 
124
145
  | Member | Description |
@@ -129,6 +150,8 @@ The action of one finger on the canvas.
129
150
 
130
151
  Class `FirstPersonControls`.
131
152
 
153
+ Import from `@null3d/controls`.
154
+
132
155
  First-person controls: keys walk the camera over the ground. The user looks around with a drag, or with the mouse while the pointer is locked. W, A, S and D or the arrow keys walk, and R and F move up and down. A left drag or one finger walks forward along the view, and a right drag or two fingers walk back. `createFirstPersonControls` makes them. Call `update` once per frame in `onUpdate`.
133
156
 
134
157
  | Member | Description |
@@ -159,6 +182,8 @@ First-person controls: keys walk the camera over the ground. The user looks arou
159
182
 
160
183
  Interface `FirstPersonControlsOptions`.
161
184
 
185
+ Import from `@null3d/controls`.
186
+
162
187
  Options for `createFirstPersonControls`. The controls keep each option as a property of the same name, which a sketch can change at any time.
163
188
 
164
189
  | Member | Description |
@@ -184,6 +209,8 @@ Options for `createFirstPersonControls`. The controls keep each option as a prop
184
209
 
185
210
  Class `FlyControls`.
186
211
 
212
+ Import from `@null3d/controls`.
213
+
187
214
  Fly controls: they move the camera in all directions and turn it about its own axes, as in a flight game. W, A, S and D move it forward, left, back and right, and R and F move it up and down. The arrow keys turn it, and Q and E roll it. The pointer steers: the farther it is from the canvas's middle, the faster the camera turns. `createFlyControls` makes them. Call `update` once per frame in `onUpdate`.
188
215
 
189
216
  | Member | Description |
@@ -199,6 +226,8 @@ Fly controls: they move the camera in all directions and turn it about its own a
199
226
 
200
227
  Interface `FlyControlsOptions`.
201
228
 
229
+ Import from `@null3d/controls`.
230
+
202
231
  Options for `createFlyControls`. The controls keep each option as a property of the same name, which a sketch can change at any time.
203
232
 
204
233
  | Member | Description |
@@ -215,6 +244,8 @@ Options for `createFlyControls`. The controls keep each option as a property of
215
244
  type GizmoAxis = 'X' | 'Y' | 'Z' | 'XY' | 'YZ' | 'XZ' | 'XYZ' | 'E';
216
245
  ```
217
246
 
247
+ Import from `@null3d/controls`.
248
+
218
249
  The handle that the user grabs: one axis, two axes for a plane handle, or all three for the center handle. The outer ring that turns about the view is `E`.
219
250
 
220
251
  ## `GizmoMode`
@@ -223,6 +254,8 @@ The handle that the user grabs: one axis, two axes for a plane handle, or all th
223
254
  type GizmoMode = 'translate' | 'rotate' | 'scale';
224
255
  ```
225
256
 
257
+ Import from `@null3d/controls`.
258
+
226
259
  What a drag does to the object: move it, turn it or scale it.
227
260
 
228
261
  ## `GizmoSpace`
@@ -231,12 +264,16 @@ What a drag does to the object: move it, turn it or scale it.
231
264
  type GizmoSpace = 'world' | 'local';
232
265
  ```
233
266
 
267
+ Import from `@null3d/controls`.
268
+
234
269
  The axes that a drag works along: the three axes of the world, or the object's own axes.
235
270
 
236
271
  ## `MapControls`
237
272
 
238
273
  Class `MapControls`, which extends `OrbitControls`.
239
274
 
275
+ Import from `@null3d/controls`.
276
+
240
277
  Map controls: orbit controls for a camera that looks down on a map. A left drag or one finger pans over the ground and keeps the point under the pointer there. A right drag or two fingers turn the camera. `createMapControls` makes them.
241
278
 
242
279
  ## `MouseAction`
@@ -245,12 +282,16 @@ Map controls: orbit controls for a camera that looks down on a map. A left drag
245
282
  type MouseAction = 'rotate' | 'dolly' | 'pan';
246
283
  ```
247
284
 
285
+ Import from `@null3d/controls`.
286
+
248
287
  What a held mouse button does: turn the camera around the target, dolly it toward the target, or pan the camera and the target together.
249
288
 
250
289
  ## `MouseButtons`
251
290
 
252
291
  Interface `MouseButtons`.
253
292
 
293
+ Import from `@null3d/controls`.
294
+
254
295
  The action of each mouse button. Null gives a button no action.
255
296
 
256
297
  | Member | Description |
@@ -265,12 +306,16 @@ The action of each mouse button. Null gives a button no action.
265
306
  type OneFingerAction = 'rotate' | 'pan';
266
307
  ```
267
308
 
309
+ Import from `@null3d/controls`.
310
+
268
311
  What one finger does.
269
312
 
270
313
  ## `OrbitControls`
271
314
 
272
315
  Class `OrbitControls`.
273
316
 
317
+ Import from `@null3d/controls`.
318
+
274
319
  Orbit controls: they turn a camera around a target point, dolly it toward the target, and pan both. They follow the sketch's pointer, wheel and touch input. `createOrbitControls` makes them. Call `update` once per frame in `onUpdate`.
275
320
 
276
321
  | Member | Description |
@@ -327,6 +372,8 @@ Orbit controls: they turn a camera around a target point, dolly it toward the ta
327
372
 
328
373
  Interface `OrbitControlsOptions`.
329
374
 
375
+ Import from `@null3d/controls`.
376
+
330
377
  Options for `createOrbitControls` and `createMapControls`. The controls keep each option as a property of the same name, which a sketch can change at any time.
331
378
 
332
379
  | Member | Description |
@@ -366,6 +413,8 @@ Options for `createOrbitControls` and `createMapControls`. The controls keep eac
366
413
 
367
414
  Interface `OrbitKeys`.
368
415
 
416
+ Import from `@null3d/controls`.
417
+
369
418
  The keys that pan the camera, and turn it while Shift, Control or Meta is down. Each is a `KeyboardEvent.code` name, such as `ArrowLeft`.
370
419
 
371
420
  | Member | Description |
@@ -379,6 +428,8 @@ The keys that pan the camera, and turn it while Shift, Control or Meta is down.
379
428
 
380
429
  Interface `TouchActions`.
381
430
 
431
+ Import from `@null3d/controls`.
432
+
382
433
  The action of one finger and of two fingers. Null gives no action.
383
434
 
384
435
  | Member | Description |
@@ -390,6 +441,8 @@ The action of one finger and of two fingers. Null gives no action.
390
441
 
391
442
  Class `TransformControls`.
392
443
 
444
+ Import from `@null3d/controls`.
445
+
393
446
  Translate, rotate and scale gizmos for one object. `createTransformControls` makes them, and `attach` picks the object. Call `update(dt)` once per frame in `onUpdate`.
394
447
 
395
448
  | Member | Description |
@@ -428,6 +481,8 @@ Translate, rotate and scale gizmos for one object. `createTransformControls` mak
428
481
 
429
482
  Interface `TransformControlsOptions`.
430
483
 
484
+ Import from `@null3d/controls`.
485
+
431
486
  Options for `createTransformControls`. The controls keep each option except `layers` and `pickLayers` as a property of the same name, which a sketch can change at any time.
432
487
 
433
488
  | Member | Description |
@@ -460,4 +515,6 @@ Options for `createTransformControls`. The controls keep each option except `lay
460
515
  type TwoFingerAction = 'dolly-pan' | 'dolly-rotate';
461
516
  ```
462
517
 
518
+ Import from `@null3d/controls`.
519
+
463
520
  What two fingers do: they dolly as they spread or close, and pan or rotate as they move together.
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/debug
3
3
  title: "Debug drawing and stats: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Debug drawing and stats API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -16,17 +15,21 @@ summary: "Every export of the Debug drawing and stats API, from the engine's doc
16
15
  function countPerSecond(intervalsMs: ArrayLike<number>, seconds = Math.floor(spanMs(intervalsMs) / 1000)): number[]
17
16
  ```
18
17
 
18
+ Import from `@null3d/engine/stats`.
19
+
19
20
  Events in each whole second, from the intervals between them. An event falls in the second that the running sum of the intervals reaches at it. It counts the first `seconds` seconds, by default every second that has ended: the ones before the last event's second.
20
21
 
21
22
  ## `Debug`
22
23
 
23
24
  Interface `Debug`.
24
25
 
25
- Debug drawing and frame figures. The drawing calls draw lines that show where things are, such as bounds, directions and axes. Each draws for one frame only, so call it in `onUpdate` in every frame that needs the drawing. Lines are one pixel wide, and objects in front of them hide them. Colors take the same forms as material colors, and positions are in world space. The overlay of `stats` shows frame figures on the page, and `frameStats` gives the sketch the same figures. Only development builds draw. In a release build every drawing call does nothing, and the build holds none of the drawing code, apart from one traversal of the scene's objects whose meshes have levels, which the culling spheres read. The calls `stats` and `frameStats` work in every build.
26
+ Debug drawing and frame figures. The drawing calls draw lines that show where things are, such as bounds, directions and axes. Each draws for one frame only, so call it in `onUpdate` in every frame that needs the drawing. Lines are one pixel wide, and objects in front of them hide them. Colors take the same forms as material colors, and positions are in world space. The overlay of `stats` shows frame figures on the page, and `frameStats` gives the sketch the same figures.
27
+
28
+ Only development builds draw. In a release build every drawing call does nothing, and the build holds none of the drawing code, apart from one traversal of the scene's objects whose meshes have levels, which the culling spheres read. The calls `stats` and `frameStats` work in every build.
26
29
 
27
30
  | Member | Description |
28
31
  | --- | --- |
29
- | `stats(show?: boolean \| StatsOverlayOptions): void` | Shows an overlay of frame figures over the top-right corner of the canvas, or hides it with `false`: the GPU path, the quality preset, the render scale, the frame rates, CPU time per frame of each thread and phase, GPU time, draw calls, triangles and objects drawn, memory, and the page thread's long tasks and input delay. Its header is a button with the frame rate, which shows and hides the other figures. Options pick whether the overlay starts collapsed to its header. The page draws the overlay and updates it a few times a second. Its code downloads at the first call. The page's `engine.stats` shows and hides the same overlay, and the last call wins. Each call sends a message to the page, so call it when the choice changes, not in every frame. |
32
+ | `stats(show?: boolean \| StatsOverlayOptions): void` | Shows an overlay of frame figures over a right-hand corner of the canvas, or hides it with `false`: the GPU path, the quality preset, the render scale, the frame rates, CPU time per frame of each thread and phase, GPU time, draw calls, triangles and objects drawn, memory, and the page thread's long tasks and input delay. Its header is a button with the frame rate, which shows and hides the other figures. Options pick whether the overlay starts collapsed to its header, and its corner: the top right by default, or the bottom right. The page draws the overlay and updates it a few times a second. Its code downloads at the first call. The page's `engine.stats` shows and hides the same overlay, and the last call wins. Each call sends a message to the page, so call it when the choice changes, not in every frame. |
30
33
  | `frameStats(): FrameStats` | The figures that the stats overlay shows, for the sketch: means per frame over about the last half second. Call it each time you need figures, and read them from the object it returns. It allocates nothing, so a sketch can call it every frame. Its code downloads at the first call, so the figures are 0 until about half a second after that call. The first call also turns on the figures that the engine samples, for the engine's life: GPU time on one frame in eleven, the memory of textures and meshes, and on WebGPU the counts of the objects that the GPU culls. |
31
34
  | `view(view: DebugViewName): void` | Draws the whole scene with one debug shading in place of every material, from the next frame on, until the next call. `'lit'` draws the materials again. `'normals'` shows each surface's world-space normal as a color, and `'depth'` its distance from the camera as a gray, white at the near plane and black at the far plane. `'overdraw'` adds light for each surface that covers a pixel, so bright pixels cost the most shading. `'wireframe'` draws each triangle's edges in its material's color. `'shadows'` shows how much of the main directional light's shadow falls on each surface, as a gray: black in full shadow, white in full light. Surfaces that face away from the sun are black, and surfaces that receive no shadows are white. `'motion'` shows how far each pixel's surface moved on the screen since the last frame, the camera's move included: its direction as the hue, red to the right, and its length as the brightness, full at 16 pixels. A still pixel is black. `'levels'` gives each level of detail a color of its own and dithers two colors where two levels hand over in a fading band. A source that the size rule or a draw range hid draws at its base level in a striped marker color, so the view shows what the culling dropped. The other views clear to black. Debug views use no tone mapping. A view may also be the name that an add-on registers in its feature description. Only development builds draw them: in a release build the call does nothing. A view's first frame builds its pipelines, so objects can be missing for a few frames after a change. |
32
35
  | `cullingSpheres(show?: boolean): void` | Draws the bounding sphere that culling tests for each object whose mesh has levels of detail, from the next frame on, until the next call. It draws the first 128 such objects, so a forest of many copies does not fill the frame. Call it beside the `'levels'` view to see where each copy's culling sphere lies, and why the size rule hid one. Only development builds draw it. |
@@ -248,6 +251,8 @@ The page's own thread during a measurement: tasks that kept it busy for 50 ms or
248
251
 
249
252
  Class `MainThreadWindow`.
250
253
 
254
+ Import from `@null3d/engine/stats`.
255
+
251
256
  Watches the page's own thread in windows, one after another: its long tasks and its longest input delay. They come from the browser's long task and event timing entries, where the browser reports them.
252
257
 
253
258
  | Member | Description |
@@ -271,12 +276,16 @@ What a measurement reports beyond its own figures, when the page asks for it.
271
276
  function measurePageMemory(): Promise<MemoryMeasurement> | undefined
272
277
  ```
273
278
 
279
+ Import from `@null3d/engine/stats`.
280
+
274
281
  One measurement of the memory of the whole page and its workers, as the browser gives it: the page's request in flight, or a new one. Like the samples, it lets every engine's job workers run the measurement. Undefined where the browser offers no measurement, or after the page stopped asking because the browser left its first request unanswered.
275
282
 
276
283
  ## `MemoryMeasurement`
277
284
 
278
285
  Interface `MemoryMeasurement`.
279
286
 
287
+ Import from `@null3d/engine/stats`.
288
+
280
289
  What the browser's measurement of the page's memory, `performance.measureUserAgentSpecificMemory`, resolves with: the bytes of the whole page, and the bytes of each part, with the scope and the script address of the thread that the part belongs to.
281
290
 
282
291
  | Member | Description |
@@ -303,12 +312,16 @@ Memory figures of a measurement.
303
312
  function pageHeapBytes(): number | null
304
313
  ```
305
314
 
315
+ Import from `@null3d/engine/stats`.
316
+
306
317
  The JavaScript heap of the page's own thread in bytes, from `performance.memory`, or null where the browser does not have it.
307
318
 
308
319
  ## `PageMemory`
309
320
 
310
321
  Interface `PageMemory`.
311
322
 
323
+ Import from `@null3d/engine/stats`.
324
+
312
325
  The memory of the whole page and its workers, from the browser's own measurement, in `StatsMemory.page`.
313
326
 
314
327
  | Member | Description |
@@ -320,6 +333,8 @@ The memory of the whole page and its workers, from the browser's own measurement
320
333
 
321
334
  Class `PageMemorySampler`.
322
335
 
336
+ Import from `@null3d/engine/stats`.
337
+
323
338
  Samples the memory of the whole page and its workers, one measurement after another with a gap of a few seconds, where the browser offers the measurement. `page` holds the newest figures. At most one measurement is in flight on the page. When the browser leaves the first one unanswered for two minutes, the page asks no more, and `page` is null until an answer comes after all.
324
339
 
325
340
  | Member | Description |
@@ -336,6 +351,8 @@ Samples the memory of the whole page and its workers, one measurement after anot
336
351
  function percentiles(samples: ArrayLike<number>): Percentiles
337
352
  ```
338
353
 
354
+ Import from `@null3d/engine/stats`.
355
+
339
356
  The median, 95th and 99th percentiles and mean of per-frame samples. It sorts a copy, so call it outside frame code.
340
357
 
341
358
  ## `Percentiles`
@@ -376,6 +393,8 @@ A step of a frame that `engine.measure` times. The `update` step is the sketch's
376
393
  function ratePerSecond(intervalsMs: ArrayLike<number>): number | null
377
394
  ```
378
395
 
396
+ Import from `@null3d/engine/stats`.
397
+
379
398
  Events per second from the intervals between them: the count over the time they took, so a few long intervals lower the rate as much as they cost. Null without intervals.
380
399
 
381
400
  ## `SecondRates`
@@ -419,10 +438,20 @@ One engine thread's CPU time in a slow frame, and the phases that it spent the t
419
438
  | `busyMs: number` | The thread's busy time in the frame. |
420
439
  | `phases: { name: PhaseName; ms: number; }[]` | The phases that took time, in the order the engine's phases run. |
421
440
 
441
+ ## `StatsCorner`
442
+
443
+ ```ts
444
+ type StatsCorner = 'top-right' | 'bottom-right';
445
+ ```
446
+
447
+ The corner of the canvas that the stats overlay's header button sits in. At the top right the card opens under the button, and at the bottom right it opens above it.
448
+
422
449
  ## `StatsFigures`
423
450
 
424
451
  Interface `StatsFigures`.
425
452
 
453
+ Import from `@null3d/engine/stats`.
454
+
426
455
  The figures that the stats overlay shows, in the form that `statsText` lays out. Means per frame are over the last window of frames, about half a second.
427
456
 
428
457
  | Member | Description |
@@ -451,12 +480,16 @@ The figures that the stats overlay shows, in the form that `statsText` lays out.
451
480
  type StatsFrameMode = 'pipelined' | 'low' | 'single' | 'one-thread';
452
481
  ```
453
482
 
483
+ Import from `@null3d/engine/stats`.
484
+
454
485
  How the threads of a renderer share each frame's work, which a symbol before the target explains: `'pipelined'` and `'low'` are null3D's latency modes, `'single'` is null3D's single-thread build, and `'one-thread'` is a renderer that prepares and draws each frame on one thread.
455
486
 
456
487
  ## `StatsGpuStep`
457
488
 
458
489
  Interface `StatsGpuStep`.
459
490
 
491
+ Import from `@null3d/engine/stats`.
492
+
460
493
  One step of the frame's GPU work, in `StatsFigures.gpuSteps`.
461
494
 
462
495
  | Member | Description |
@@ -468,6 +501,8 @@ One step of the frame's GPU work, in `StatsFigures.gpuSteps`.
468
501
 
469
502
  Interface `StatsMainThread`.
470
503
 
504
+ Import from `@null3d/engine/stats`.
505
+
471
506
  The page's own thread over the last few seconds, in `StatsFigures.mainThread`.
472
507
 
473
508
  | Member | Description |
@@ -481,6 +516,8 @@ The page's own thread over the last few seconds, in `StatsFigures.mainThread`.
481
516
 
482
517
  Interface `StatsMemory`.
483
518
 
519
+ Import from `@null3d/engine/stats`.
520
+
484
521
  Memory figures in bytes, in `StatsFigures.memory`. Each is null where the page cannot know it, and the overlay then shows `n/a`.
485
522
 
486
523
  | Member | Description |
@@ -495,6 +532,8 @@ Memory figures in bytes, in `StatsFigures.memory`. Each is null where the page c
495
532
 
496
533
  Interface `StatsMemoryArea`.
497
534
 
535
+ Import from `@null3d/engine/stats`.
536
+
498
537
  One area of the memory register, in `StatsFigures.memoryAreas`.
499
538
 
500
539
  | Member | Description |
@@ -513,26 +552,32 @@ Options for the stats overlay, which `debug.stats`, `engine.stats` and the `stat
513
552
  | Member | Description |
514
553
  | --- | --- |
515
554
  | `collapsed?: boolean` | True shows only the overlay's header, a button with the frame rate. A click or the Enter or Space key on it shows and hides the other figures. The default is false: every figure shows. |
555
+ | `corner?: StatsCorner` | The corner of the canvas that the header button sits in. The default is `'top-right'`. At `'bottom-right'` the button sits at the bottom of the part of the canvas on screen, clear of a phone's home bar, and the card opens above it. |
516
556
 
517
557
  ## `StatsPanel`
518
558
 
519
559
  Class `StatsPanel`.
520
560
 
521
- The stats overlay's header and card over the top-right corner of a canvas, in the overlay's own look. The engine's overlay is one; a page that draws with another engine makes its own and fills it with its figures, so both show the same figures in the same place and look. The header's button opens and closes the card. Collapsed, the panel formats nothing but the frame rate.
561
+ Import from `@null3d/engine/stats`.
562
+
563
+ The stats overlay's header and card over the top-right or bottom-right corner of a canvas, in the overlay's own look. The engine's overlay is one; a page that draws with another engine makes its own and fills it with its figures, so both show the same figures in the same place and look. The header's button opens and closes the card. Collapsed, the panel formats nothing but the frame rate.
522
564
 
523
565
  | Member | Description |
524
566
  | --- | --- |
525
567
  | `readonly collapsed: boolean` | True while only the header shows. |
526
568
  | `setCollapsed(collapsed: boolean): void` | Opens or closes the card, and tells `onToggle` when that changes. |
569
+ | `setCorner(corner: StatsCorner): void` | Moves the panel to another corner of the canvas. |
527
570
  | `showRate(frames: number, fps: number, refreshHz: number, maxTargetFps = CHECK_MAX_FPS): void` | Shows the frame rate in the header: `frames` is 0 before the first window of frames ended. The rate is judged against null3D's target for the display's refresh rate, at most `maxTargetFps`. |
528
571
  | `update(figures: StatsFigures, frame: StatsPanelFrame): void` | Shows a set of figures in the card. It does nothing while the panel is collapsed. |
529
- | `follow(): void` | Keeps the panel on the canvas's top-right corner, and hides it while the canvas is off the page. Call it a few times a second, as the figures come. |
572
+ | `follow(): void` | Keeps the panel on its corner of the canvas and the card's height within the screen, and hides the panel while the canvas is off the page. Call it a few times a second, as the figures come. |
530
573
  | `remove(): void` | Takes the panel off the page. |
531
574
 
532
575
  ## `StatsPanelFrame`
533
576
 
534
577
  Interface `StatsPanelFrame`.
535
578
 
579
+ Import from `@null3d/engine/stats`.
580
+
536
581
  How a panel judges and lays out one set of figures, in `StatsPanel.update`.
537
582
 
538
583
  | Member | Description |
@@ -547,11 +592,14 @@ How a panel judges and lays out one set of figures, in `StatsPanel.update`.
547
592
 
548
593
  Interface `StatsPanelOptions`.
549
594
 
595
+ Import from `@null3d/engine/stats`.
596
+
550
597
  Options of a `StatsPanel`.
551
598
 
552
599
  | Member | Description |
553
600
  | --- | --- |
554
601
  | `collapsed?: boolean` | True starts the panel with only its header, a button with the frame rate. The default is false. |
602
+ | `corner?: StatsCorner` | The corner of the canvas that the header button sits in. The default is `'top-right'`. At `'bottom-right'` the button sits at the bottom of the part of the canvas on screen, clear of a phone's home bar, and the card opens above it. |
555
603
  | `onToggle?: (collapsed: boolean) => void` | Called when the panel opens or closes, with true for closed. A page samples its costly figures only while the panel is open. |
556
604
 
557
605
  ## `statsText`
@@ -560,12 +608,16 @@ Options of a `StatsPanel`.
560
608
  function statsText(figures: StatsFigures): string
561
609
  ```
562
610
 
611
+ Import from `@null3d/engine/stats`.
612
+
563
613
  The stats overlay's text for a set of figures: one figure group per line, in a fixed order. A figure that the page cannot know shows as `n/a`.
564
614
 
565
615
  ## `StatsThread`
566
616
 
567
617
  Interface `StatsThread`.
568
618
 
619
+ Import from `@null3d/engine/stats`.
620
+
569
621
  One thread's CPU time per frame, in `StatsFigures.threads`.
570
622
 
571
623
  | Member | Description |
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/engine
3
3
  title: "Page API: createEngine: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Page API: createEngine API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -37,6 +36,11 @@ function checkAddonVersion(name: string, version: string): void
37
36
 
38
37
  Checks that an add-on, built for `version` of the engine, runs against this engine's version, and throws E1432 when the two differ. An add-on calls it once, as its module loads, with its own package name and version. An add-on from another developer calls `checkPluginInterface` instead, with the range of plugin interface versions that it works with.
39
38
 
39
+ | Parameter | Description |
40
+ | --- | --- |
41
+ | `name` | The add-on's package name, such as `@null3d/controls`. |
42
+ | `version` | The add-on's version, which is the engine version it was built for. |
43
+
40
44
  ## `checkPluginInterface`
41
45
 
42
46
  ```ts
@@ -45,6 +49,11 @@ function checkPluginInterface(name: string, range: PluginInterfaceRange): void
45
49
 
46
50
  Checks that an add-on from another developer works with this engine's plugin interface, and throws E1433 when the declared range does not hold `PLUGIN_INTERFACE_VERSION`. The add-on calls it once, as its module loads, with its own package name and the range it was built for.
47
51
 
52
+ | Parameter | Description |
53
+ | --- | --- |
54
+ | `name` | The add-on's package name, such as `@acme/splats`. |
55
+ | `range` | The plugin interface versions that the add-on works with, both included. |
56
+
48
57
  ## `createEngine`
49
58
 
50
59
  ```ts
@@ -59,7 +68,9 @@ Starts the engine on the page. It tests the device, picks the build and the GPU
59
68
  type DepthMode = 'reversed' | 'reversed-gl' | 'standard';
60
69
  ```
61
70
 
62
- How the GPU path stores depth. In `reversed` depth, the near plane stores 1 and the far plane 0, in a 32-bit float depth buffer. That keeps depth precise far from the camera. WebGPU always draws it. WebGL2 draws it where the browser has the `EXT_clip_control` extension, which gives WebGL2 the depth range from 0 to 1 that WebGPU has. The `reversed-gl` mode keeps the same order, but in WebGL2's own depth range from -1 to 1, which loses most of the precision. In `standard` depth, the near plane stores 0 and the far plane 1.
71
+ How the GPU path stores depth. In `reversed` depth, the near plane stores 1 and the far plane 0, in a 32-bit float depth buffer. That keeps depth precise far from the camera.
72
+
73
+ WebGPU always draws it. WebGL2 draws it where the browser has the `EXT_clip_control` extension, which gives WebGL2 the depth range from 0 to 1 that WebGPU has. The `reversed-gl` mode keeps the same order, but in WebGL2's own depth range from -1 to 1, which loses most of the precision. In `standard` depth, the near plane stores 0 and the far plane 1.
63
74
 
64
75
  ## `DrawPathReason`
65
76
 
@@ -75,7 +86,19 @@ type DrawPathReason =
75
86
  | 'webgl2';
76
87
  ```
77
88
 
78
- Why WebGPU draws on the path that the engine takes, in `engine.capabilities.drawPath`: - `probe-faster`: the start-up probe ran on an Apple GPU in WebKit and measured direct draws to be clearly faster, so the engine draws directly. - `probe-not-faster`: the probe ran there, and direct draws were not clearly faster. - `probe-failed`: the probe ran there and could not measure, as when the device was too slow or was lost. - `not-apple-gpu-in-webkit`: the device is not an Apple GPU in Safari or in a browser on iPhone or iPad. The probe did not run, and the engine draws indirectly. - `software-renderer`: the browser draws on the CPU. The probe did not run. - `no-probe`: the worker's WebGPU check gave no answer. - `forced`: `?direct=on` or `?direct=off` chose the path. - `webgl2`: the engine draws with WebGL2, which always draws directly.
89
+ Why WebGPU draws on the path that the engine takes, in `engine.capabilities.drawPath`:
90
+
91
+ - `probe-faster`: the start-up probe ran on an Apple GPU in WebKit and measured direct draws to
92
+ be clearly faster, so the engine draws directly.
93
+ - `probe-not-faster`: the probe ran there, and direct draws were not clearly faster.
94
+ - `probe-failed`: the probe ran there and could not measure, as when the device was too slow or
95
+ was lost.
96
+ - `not-apple-gpu-in-webkit`: the device is not an Apple GPU in Safari or in a browser on iPhone
97
+ or iPad. The probe did not run, and the engine draws indirectly.
98
+ - `software-renderer`: the browser draws on the CPU. The probe did not run.
99
+ - `no-probe`: the worker's WebGPU check gave no answer.
100
+ - `forced`: `?direct=on` or `?direct=off` chose the path.
101
+ - `webgl2`: the engine draws with WebGL2, which always draws directly.
79
102
 
80
103
  ## `Engine`
81
104
 
@@ -101,8 +124,8 @@ A running engine, as `createEngine` returns it.
101
124
  | `detach(): void` | Takes the canvas off the page and pauses the engine. The engine keeps its threads, its GPU resources and the scene, and stops reading input. Use it when a single-page app leaves the view that shows the canvas, and `attach` when the view comes back. |
102
125
  | `attach(container: Element): void` | Puts the canvas at the end of `container` and resumes the engine where it stopped, unless `setPaused(true)` paused it. |
103
126
  | `measure(seconds: number, options?: MeasureOptions): Promise<FrameMetrics>` | Measures the running engine for a number of seconds, then returns CPU time per frame by thread and phase, GPU time, frame intervals, uploads, draw calls, memory and load time. The first call downloads the code that turns the frame records into these figures. `slowMs` adds the frames whose interval broke that many milliseconds, each with the frame's own GPU parts. |
104
- | `inspect(call: string, args?: unknown): Promise<unknown>` | Runs an inspection call against the live scene, for the in-page inspector and the MCP server: `objects`, `object`, `setObject`, `setMaterial`, `stats`, `errors`, `graph`, `setQuality`, `highlight` and `info`, with the arguments that [Debugging](../../guides/debugging.md#the-in-page-inspector) lists. The call runs between frames, in the thread that runs the sketch, and its value is JSON-safe. The page answers `capture` itself, with `{ png, bytes }`: the PNG image of the next 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 release build leaves it out, so code that uses it must check for it first. |
105
- | `stats(show?: boolean \| StatsOverlayOptions): void` | Shows an overlay of figures over the top-right corner of the canvas, or hides it with `false`: the GPU path, the frame rates, CPU time per frame of each thread, GPU time, draw calls, triangles and objects drawn, memory, and the page thread's long tasks and input delay. Its header is a button with the frame rate, which shows and hides the other figures. Options pick whether the overlay starts collapsed to its header; 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 code downloads at the first call. While the other figures show, the engine times one frame in eleven on the GPU and reads back the counts of the objects that the GPU culls, which costs a little GPU time. The sketch's `debug.stats` shows and hides the same overlay, and the last call wins. |
127
+ | `inspect?(call: string, args?: unknown): Promise<unknown>` | Runs an inspection call against the live scene, for the in-page inspector and the MCP server: `objects`, `object`, `setObject`, `setMaterial`, `stats`, `errors`, `graph`, `setQuality`, `highlight` and `info`, with the arguments that [Debugging](../../guides/debugging.md#the-in-page-inspector) lists. The call runs between frames, in the thread that runs the sketch, and its value is JSON-safe. The page answers `capture` itself, with `{ png, bytes }`: the PNG image of the next 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 release build leaves it out, so code that uses it must check for it first. |
128
+ | `stats(show?: boolean \| StatsOverlayOptions): void` | Shows an overlay of figures over a right-hand corner of the canvas, or hides it with `false`: the GPU path, the frame rates, CPU time per frame of each thread, GPU time, draw calls, triangles and objects drawn, memory, and the page thread's long tasks and input delay. Its header is a button with the frame rate, which shows and hides the other figures. Options pick whether the overlay starts collapsed to its header, and its corner: the top right by 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 code downloads at the first call. While the other figures show, the engine times one frame in eleven on the GPU and reads back the counts of the objects that the GPU culls, which costs a little GPU time. The sketch's `debug.stats` shows and hides the same overlay, and the last call wins. |
106
129
  | `capture(): Promise<Blob>` | Resolves with an image of the next frame that the engine draws, as a PNG file. The thread that draws reads the frame back and encodes it, so the page's thread does no work for it when a worker draws. In hold mode it is an image of the held frame, whose pixels the page keeps, so the GPU draws nothing for it. While the engine is paused, the image shows the frame on the canvas. A hidden page draws no frames, so its image comes once the page shows again. When no new frame comes within a second or two, as after a sketch error, the image shows the frame drawn last. Fails with E1414 once the engine has stopped, when the thread that draws gives no answer within the engine's wait, or when that thread could not read the frame back, with the cause that the GPU gave, such as a lost device or too little memory. |
107
130
  | `captureFrame(): Promise<{ width: number; height: number; pixels: Uint8Array; frame: number; }>` | Resolves with the pixels of the next frame that the engine draws, as RGBA8 rows, top row first, for tests. The thread that draws waits until its frame loop has taken a new frame, then draws that frame again offscreen and reads it back, so captures back to back give newer frames even where each readback holds that thread up. `frame` is the sketch frame that the capture drew: a capture that follows a scene change can hold the frame recorded before it, and a test that measures frames aligns them by this number. In hold mode, and while the engine is paused, it returns the frame on the canvas. A hidden page draws no frames, so its pixels come once the page shows again. When no new frame comes within a second or two, as after a sketch error, it returns the frame drawn last. It fails when the thread that draws gives no answer within the engine's wait, rather than waiting with no end. |
108
131
  | `saveRecording(): Promise<Uint8Array \| undefined>` | Resolves with the recording of the session so far, or undefined when the page does not record one. A page records with the `?record` switch, which also puts a save button on the page. The file holds each frame's step and the input that the sketch read in it, from the session's first frame, so a `?replay` of it draws the same frames. Its format is the engine's own; save it to a file and open `?replay=<file>` to run it. Recording seeds the sketch thread's random numbers, so a recorded session draws the same frames when it replays. |
@@ -172,6 +195,7 @@ Options for `createEngine`.
172
195
  | --- | --- |
173
196
  | `canvas: HTMLCanvasElement` | The canvas to draw into, sized by CSS. On a canvas that no CSS sizes, the engine sets the CSS width and height that it shows when the engine starts. One engine draws on a canvas at a time: a start on the canvas of an engine that is stopping, or still starting and then destroyed, waits for that engine to stop. A canvas whose engine runs on fails with E1419. |
174
197
  | `sketch: URL \| string` | The sketch module, which runs in the sketch worker; `new URL('./sketch.ts', import.meta.url)`. |
198
+ | `sketchData?: unknown` | Start data for the sketch, which its setup reads as `ctx.data`: the state that the page knows before the scene starts, such as the section that the address names, a saved color mode or a level number. It reaches the setup before the first frame, also in hold mode, where no message can. It takes plain JSON data: objects, arrays, strings, finite numbers, booleans and null, up to 64 KiB as JSON. Another value fails with E1213. A recording keeps it, and a replay gives the sketch the recorded data. |
175
199
  | `preset?: 'auto' \| QualityPreset` | The quality preset: `auto`, the default, lets the engine choose one for the device, and `low`, `medium`, `high` or `ultra` names one. The GPU path caps it: WebGL2 and WebGPU's compatibility mode run at most `medium`. After a start that crashed the tab, the engine starts a preset lower. Another value fails with E1213. The `?preset=` switch wins over it. |
176
200
  | `targetFps?: TargetFps` | The frame rate that the engine defends: the preset check and the quality governor lower the quality when frames fall below it. Without it, the target is the display's refresh rate, at most 60. `display` targets the display's full rate, such as 120 or 144 for a game on a fast display. A whole number from 1 up caps the target at that rate. The engine draws at the display's rate in every case. The `?target-fps=` switch wins over it. Another value fails with E1213. |
177
201
  | `presetCheck?: PresetCheckTiming` | When the preset check measures, on a start where the engine checks the preset that it chose. With `during-play`, the default, the scene shows at its first frame: `createEngine` resolves once the setup has run, and `engine.firstFrame` once the GPU has finished the first frame. The check then measures the first frames of play, a lighter preset applies in front of the viewer, and `engine.presetChecked` resolves once the check has ended. With `before-play`, the check measures the scene that the setup built before the sketch's update runs, and `createEngine` resolves after it, so a loading screen hides the check and any change of preset. A start that takes the stored result of an earlier check, or that runs no check, plays at once either way. Another value fails with E1213. The `?preset-check=` switch wins over it. |
@@ -195,7 +219,7 @@ Options for `createEngine`.
195
219
  | `textureMemoryMiB?: number` | The GPU memory in MiB that textures may take, a whole number from 64 to 16,384. Past it, the engine drops the largest mip levels of textures from files, and loads them again once room returns. Without it, the quality preset sets it: 256, 512, 1,024 or 2,048 from Low to Ultra, and at most 1,008 on phones and tablets. A sketch can change it during play with `quality.set`. Another value fails with E1213. |
196
220
  | `keepTextureCopies?: boolean` | True keeps the engine's copy of each texture's texels after their upload, so a texture that maps an image draws with its map again after the browser takes the GPU away. It costs about one more copy of each image in memory. False frees each copy once no frame reads it, and such a texture draws with its color alone until the sketch gives it texels again. Without this option, a phone and a tablet keep copies and a desktop does not, because a phone or a tablet is likeliest to lose its GPU. With copies, the engine also gives its GPU back while the browser keeps the page in its back/forward cache, and starts a new device when the page shows again. |
197
221
  | `transparent?: boolean` | True for a see-through canvas: the page shows through wherever no object draws, until the sketch sets a background color. The canvas holds premultiplied alpha, as a browser composites it. The default is false, an opaque canvas. |
198
- | `hdr?: boolean` | False draws the scene into 8-bit color, where each material's shader applies the output transform, instead of HDR color, which the final pass tone maps. Both paths honour a material's `toneMapped: false`, and the 8-bit path also honours it on a blended surface. The default lets the engine pick the path from the device, which draws HDR color wherever it can. The `?hdr=off` switch takes the 8-bit path too. |
222
+ | `hdr?: boolean` | False draws the scene into 8-bit color, where each material's shader applies the output transform, instead of HDR color, which the final pass tone maps. Both paths honor a material's `toneMapped: false`, and the 8-bit path also honors it on a blended surface. The default lets the engine pick the path from the device, which draws HDR color wherever it can. The `?hdr=off` switch takes the 8-bit path too. |
199
223
  | `largeWorld?: boolean` | True for scenes that reach far beyond a city, such as a planet. Object positions then keep the precision of JavaScript's numbers at any distance from the origin: 0.03 mm or better. Without it, positions are 32-bit floats, which move in steps of 6 cm at 1,000 km from the origin and 0.5 m at the Earth's radius. It costs 12 bytes of memory per object and a little work in each position setter. The default is false. Instance batches need no mode: give each one an `origin` near its rows. |
200
224
  | `sketchThread?: SketchThread` | The thread that runs the sketch's code and the engine core: `worker`, the default, or `main` for the page's main thread, where the sketch can reach the DOM. Use `main` for apps that work mostly with the DOM, and for debugging. The render worker still draws in pipelined mode, and the page draws in low-latency mode. The sketch's frames then share the page's thread with the page's own work, so each can slow the other. The single-threaded build always runs the sketch on the page's thread. The `?sketch-thread=` switch wins over this option. |
201
225
  | `memory?: { maximumMiB: number; }` | The engine's memory. `maximumMiB` sets the most memory that the engine's threads share, in MiB: a whole number from 256 to 4096, 1024 by default. Another value fails with E1409. The browser reserves address space for the whole maximum when the engine starts. So a larger maximum leaves less room for other engines and WebAssembly modules on the page. Ask for more only when a scene needs it. The single-threaded build's memory is not shared, so this option does not change it. The `?memory=<MiB>` switch wins over it. |
@@ -458,7 +482,12 @@ Reads the device hints on the page's main thread, which workers cannot: they hav
458
482
  type RenderFallback = WorkerProbeFailure['failure'] | 'no-surface';
459
483
  ```
460
484
 
461
- Why the engine draws on the page's thread when its options asked a worker to draw: - `no-answer`: the probe worker, and a second one after it, gave no answer within their time limits. A stalled GPU call or a very busy machine causes this. - `failed-to-start`: the probe worker's script failed to load or run. - `no-surface`: a worker cannot draw with the GPU path here, as the browser offers no context of it for an `OffscreenCanvas` in a worker.
485
+ Why the engine draws on the page's thread when its options asked a worker to draw:
486
+ - `no-answer`: the probe worker, and a second one after it, gave no answer within their time
487
+ limits. A stalled GPU call or a very busy machine causes this.
488
+ - `failed-to-start`: the probe worker's script failed to load or run.
489
+ - `no-surface`: a worker cannot draw with the GPU path here, as the browser offers no context of
490
+ it for an `OffscreenCanvas` in a worker.
462
491
 
463
492
  ## `ReplayResult`
464
493
 
@@ -561,7 +590,7 @@ The GPU path the engine draws with: core WebGPU, WebGPU in compatibility mode on
561
590
  ## `VERSION`
562
591
 
563
592
  ```ts
564
- const VERSION: '0.1.0'
593
+ const VERSION: '0.1.1'
565
594
  ```
566
595
 
567
596
  The engine version, which the WebAssembly core and this package always share.
@@ -615,7 +644,7 @@ What the browser's WebGPU offers, in `CapabilityReport.webgpu`.
615
644
  | `wgslLanguageFeatures: string[]` | The WGSL language features the browser supports, sorted. |
616
645
  | `preferredCanvasFormat: string \| null` | The canvas texture format the browser prefers, or null without WebGPU. |
617
646
  | `transientAttachments: boolean` | True when the browser's WebGPU has the transient attachment texture usage (Chrome 146 and later). A render target with it can stay in a tile-based GPU's own memory. The engine gives it to the targets that live within one render pass, such as the multisampled color and depth. |
618
- | `directDraws: boolean` | True when the start-up probe measured the device drawing a bucket faster with direct draws than with the engine's indirect draws, so the engine draws directly. The probe runs on a worker's device, and only on an Apple GPU in WebKit, whose validation of each indirect draw the direct path removes (D-174). False on WebGL2. |
647
+ | `directDraws: boolean` | True when the start-up probe measured the device drawing a bucket faster with direct draws than with the engine's indirect draws, so the engine draws directly. The probe runs on a worker's device, and only on an Apple GPU in WebKit, whose validation of each indirect draw the direct path removes. False on WebGL2. |
619
648
  | `drawPath: DrawPathReason` | Why the probe chose that draw path, or why it did not measure. |
620
649
  | `adapterInfo: { vendor: string; architecture: string; device: string; description: string; } \| null` | Reported for the record. The engine reads no meaning from it, and only compares it with an earlier start's, to tell whether a stored preset check came from the same GPU. |
621
650
  | `error?: string` | Why the probe failed, when it did. |