@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/math
3
3
  title: "Math helpers: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Math helpers API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -30,6 +29,8 @@ Colors as linear RGB in plain arrays of three numbers, from hex colors, sRGB com
30
29
  function createMath(functions: MathFunctions): MathHelpers
31
30
  ```
32
31
 
32
+ Import from `@null3d/engine/math`.
33
+
33
34
  The math helpers that need a sine, a cosine, an arc cosine or an exponential, built on the four functions given: `quat.setAxisAngle`, `fromEuler`, `rotateX`, `rotateY`, `rotateZ` and `slerp`, `vec3.angle` and `math.damp`. Each does the same arithmetic as the main entry's helper of its name, which uses the browser's `Math`. Pass an exact math library's functions, and a deterministic simulation gets the same bits on every JavaScript engine. Call it once, outside per-frame code: it allocates the helpers. Throws E1213 when one of the four is not a function.
34
35
 
35
36
  ## `EulerOrder`
@@ -91,6 +92,8 @@ Number helpers, such as `math.clamp` and `math.damp`, and a random generator tha
91
92
 
92
93
  Interface `MathFunctions`.
93
94
 
95
+ Import from `@null3d/engine/math`.
96
+
94
97
  The four functions that `createMath` builds its helpers on, each taking and giving radians where it takes an angle. An exact math library that gives the same bits on every JavaScript engine has them, under these names or others. The helpers call each one as a plain function, with no `this`.
95
98
 
96
99
  | Member | Description |
@@ -104,6 +107,8 @@ The four functions that `createMath` builds its helpers on, each taking and givi
104
107
 
105
108
  Interface `MathHelpers`.
106
109
 
110
+ Import from `@null3d/engine/math`.
111
+
107
112
  The helpers that `createMath` returns, grouped and named as the main entry's namespaces group and name them.
108
113
 
109
114
  | Member | Description |
@@ -116,6 +121,8 @@ The helpers that `createMath` returns, grouped and named as the main entry's nam
116
121
 
117
122
  Interface `NumberHelpers`.
118
123
 
124
+ Import from `@null3d/engine/math`.
125
+
119
126
  The number helper that `createMath` builds, with the same arguments and arithmetic as `math.damp`.
120
127
 
121
128
  | Member | Description |
@@ -152,6 +159,8 @@ Rotations as quaternions (x, y, z, w) in plain arrays, with angles in radians: `
152
159
 
153
160
  Interface `QuatHelpers`.
154
161
 
162
+ Import from `@null3d/engine/math`.
163
+
155
164
  The quaternion helpers that `createMath` builds: the ones that turn by an angle. Each takes the same arguments as the `quat` helper of its name, and does the same arithmetic with the functions that `createMath` got.
156
165
 
157
166
  | Member | Description |
@@ -214,6 +223,8 @@ Vectors (x, y, z) in plain arrays, in the style of gl-matrix: `vec3.add(out, a,
214
223
 
215
224
  Interface `Vec3Helpers`.
216
225
 
226
+ Import from `@null3d/engine/math`.
227
+
217
228
  The vector helper that `createMath` builds, with the same arguments and arithmetic as `vec3.angle`.
218
229
 
219
230
  | Member | Description |
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/objects
3
3
  title: "Objects and transforms: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Objects and transforms API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -35,7 +34,7 @@ A drawn object: a mesh and a material.
35
34
  | `setOutlined(outlined: boolean): void` | Draws an outline around the mesh, or stops. The outline shows while `post.set({ outline })` turns outlines on, and every outlined mesh takes its settings. The default is false. A change rebuilds the engine's tables of what it draws, as a new material does. |
36
35
  | `setOccluder(occluder: boolean): void` | Makes the mesh block the view, or keeps it from blocking. On WebGL2, while the `softwareOcclusion` quality setting is on, the job workers draw each blocker into a small depth buffer every frame, and the engine skips every object that lies wholly behind the blockers. Only meshes marked true block there, and the meshes of a model file that the asset tool gave blockers. Mark large, solid meshes that hide much of the scene, such as buildings and walls, whose mesh has at most 4,096 triangles. A mesh that the asset tool gave a blocker draws that blocker instead, a few boxes inside the mesh, whatever the mesh's own size. A blocker's mesh must lie inside what the object draws, as the object's own mesh does. On WebGPU, while the `gpuOcclusion` setting is on, every opaque mesh may block without a mark: the GPU draws the depth of those that showed in the last frame and look large on the screen, and skips every object wholly behind them. False keeps the mesh from blocking there too. Objects that blend, cut holes with an alpha mask or use a custom material never block, whatever this says, nor do skinned ones on WebGL2. A change needs no rebuild of the engine's tables. |
37
36
  | `setRenderOrder(order: number): void` | Sets the order in which the mesh draws among blended objects, lower first. Objects of one order draw farthest first. The default is 0. The engine orders opaque and masked objects itself. |
38
- | `setLevelBias(bias: number): void` | Raises or lowers the threshold that picks this mesh's levels of detail, as Godot's `lod_bias` does. A bias above 1 makes every switch happen nearer, so the object draws coarser levels. A bias below 1 keeps its detail, which a hero object wants. The bias multiplies the threshold of the level switches and of the distance at which the object hides, so both move by the same factor. The default is 1. The object's mesh needs levels (`setLevels`). A change rebuilds the engine's tables of what it draws, as a new material does. Throws E1108 for a bias that is not a number above 0. |
37
+ | `setLevelBias(bias: number): void` | Raises or lowers the threshold that picks this mesh's levels of detail, as the inverse of Godot's `lod_bias`: a Godot bias of 2 is about a null3D bias of 0.5. A bias above 1 makes every switch happen nearer, so the object draws coarser levels. A bias below 1 keeps its detail, which a hero object wants. The bias multiplies the threshold of the level switches and of the distance at which the object hides, so both move by the same factor. The default is 1. The object's mesh needs levels (`setLevels`). A change rebuilds the engine's tables of what it draws, as a new material does. Throws E1108 for a bias that is not a number above 0. |
39
38
  | `setDrawRange(start: number, end: number): void` | Sets the distances between which the mesh draws, as Godot's visibility range and Bevy's `VisibilityRange` do: nothing nearer than `start`, which is 0 for none, and nothing past `end`, which is `Infinity` for none. Each edge fades over a short band, so a mesh that fades in or out does not pop. A mesh whose bounds leave the range costs no draw at all. The default draws at every distance. The `lodFade` quality setting turns the bands off on Low. Throws E1108 for a range that is not two numbers with 0 <= start < end. |
40
39
  | `setFrustumCulled(culled: boolean): void` | With false, the engine draws the mesh even where its bounds are out of view. The default is true. For vertices that a shader moves, larger bounds from `setBounds` cost less. |
41
40
 
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/particles
3
3
  title: "Particles (@null3d/particles): API reference"
4
- status: generated
5
- since: "0.2"
4
+ generated: true
6
5
  summary: "Every export of the Particles (@null3d/particles) API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -16,6 +15,8 @@ summary: "Every export of the Particles (@null3d/particles) API, from the engine
16
15
  function createParticles(context: SketchContext, options: ParticleSystemOptions): Promise<ParticleSystem>
17
16
  ```
18
17
 
18
+ Import from `@null3d/particles`.
19
+
19
20
  Makes a particle system in the sketch's scene: an emitter, and the engine's particle buffer that it fills. Call the system's `update()` once per frame in `onLateUpdate`. The first system downloads the engine's particle code. Throws E1108 for a capacity out of range, and E1406 when the particle code does not download.
20
21
 
21
22
  ## `EmitterShape`
@@ -29,13 +30,19 @@ type EmitterShape =
29
30
  | { type: 'disc'; radius: number; };
30
31
  ```
31
32
 
32
- Where an emitter's particles are born, in its own space, and which way they set off. A `point` emits at the emitter, along `direction`. A `sphere` emits inside a ball of `radius`, or on its surface with `surface`, and sends particles outward. A `cone` emits on a disc of `radius` across the emitter's +y axis. It sends particles up within `angle` radians of that axis, as a fountain or a flame does. A `box` emits inside a box of `size`, centered on the emitter, along `direction`. A `disc` emits on a disc of `radius` across the +y axis, along `direction`.
33
+ Import from `@null3d/particles`.
34
+
35
+ Where an emitter's particles are born, in its own space, and which way they set off. A `point` emits at the emitter, along `direction`. A `sphere` emits inside a ball of `radius`, or on its surface with `surface`, and sends particles outward.
36
+
37
+ A `cone` emits on a disc of `radius` across the emitter's +y axis. It sends particles up within `angle` radians of that axis, as a fountain or a flame does. A `box` emits inside a box of `size`, centered on the emitter, along `direction`. A `disc` emits on a disc of `radius` across the +y axis, along `direction`.
33
38
 
34
39
  ## `ParticleBuffer`
35
40
 
36
41
  Class `ParticleBuffer`.
37
42
 
38
- A particle buffer: a scene object that draws a quad for each live particle record. The particles add-on's emitters write records into it. Write a particle's record once, when it is born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it and changes its look as it ages, as the buffer's values say. It stops drawing the particle at the end of its lifetime. Once per frame, write the buffer's time and the records the GPU reads into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's calls allocate nothing.
43
+ A particle buffer: a scene object that draws a quad for each live particle record. The particles add-on's emitters write records into it. Write a particle's record once, when it is born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it and changes its look as it ages, as the buffer's values say. It stops drawing the particle at the end of its lifetime.
44
+
45
+ Once per frame, write the buffer's time and the records the GPU reads into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's calls allocate nothing.
39
46
 
40
47
  | Member | Description |
41
48
  | --- | --- |
@@ -76,6 +83,8 @@ Options of `scene.createParticleBuffer`.
76
83
 
77
84
  Interface `ParticleBurst`.
78
85
 
86
+ Import from `@null3d/particles`.
87
+
79
88
  A burst: `count` particles at once, at `time` seconds after the system starts, then every `interval` seconds, `cycles` times in all.
80
89
 
81
90
  | Member | Description |
@@ -130,7 +139,9 @@ type ParticleEmitterShape =
130
139
  | { type: 'disc'; radius: number; };
131
140
  ```
132
141
 
133
- Where an emitter's particles are born, in its own space, and which way they set off. A `point` emits at the emitter, along `direction`. A `sphere` emits inside a ball of `radius`, or on its surface with `surface`, and sends particles outward. A `cone` emits on a disc of `radius` across the emitter's +y axis. It sends particles up within `angle` radians of that axis. A `box` emits inside a box of `size`, centered on the emitter, along `direction`. A `disc` emits on a disc of `radius` across the +y axis, along `direction`.
142
+ Where an emitter's particles are born, in its own space, and which way they set off. A `point` emits at the emitter, along `direction`. A `sphere` emits inside a ball of `radius`, or on its surface with `surface`, and sends particles outward.
143
+
144
+ A `cone` emits on a disc of `radius` across the emitter's +y axis. It sends particles up within `angle` radians of that axis. A `box` emits inside a box of `size`, centered on the emitter, along `direction`. A `disc` emits on a disc of `radius` across the +y axis, along `direction`.
134
145
 
135
146
  ## `ParticleEmitterSub`
136
147
 
@@ -227,12 +238,16 @@ How the particles of a buffer move: closed-form motion that the GPU works out at
227
238
  type ParticleRange = number | readonly [number, number];
228
239
  ```
229
240
 
241
+ Import from `@null3d/particles`.
242
+
230
243
  A number, or the smallest and the largest of a random number.
231
244
 
232
245
  ## `ParticleSystem`
233
246
 
234
247
  Class `ParticleSystem`.
235
248
 
249
+ Import from `@null3d/particles`.
250
+
236
251
  A particle system: an emitter that fills a particle buffer. `createParticles` makes one. Call `update()` once per frame, in `onLateUpdate`, where objects' world places are the frame's.
237
252
 
238
253
  | Member | Description |
@@ -249,7 +264,9 @@ A particle system: an emitter that fills a particle buffer. `createParticles` ma
249
264
 
250
265
  ## `ParticleSystemOptions`
251
266
 
252
- Interface `ParticleSystemOptions`, which extends `Omit`.
267
+ Interface `ParticleSystemOptions`, which extends `Omit<ParticleBufferOptions, 'capacity'>`.
268
+
269
+ Import from `@null3d/particles`.
253
270
 
254
271
  Options of `createParticles`: the emitter, then the engine's particle buffer options, which give the motion and the look.
255
272
 
@@ -277,6 +294,8 @@ Options of `createParticles`: the emitter, then the engine's particle buffer opt
277
294
 
278
295
  Interface `ParticleTexture`.
279
296
 
297
+ Import from `@null3d/particles`.
298
+
280
299
  A particle texture made in code, and its flipbook, which `createParticles` takes in its options: `{ ...particleTextures.smoke(textures), ... }`.
281
300
 
282
301
  | Member | Description |
@@ -288,6 +307,8 @@ A particle texture made in code, and its flipbook, which `createParticles` takes
288
307
 
289
308
  Interface `ParticleTextureOptions`.
290
309
 
310
+ Import from `@null3d/particles`.
311
+
291
312
  Options of the particle textures made in code.
292
313
 
293
314
  | Member | Description |
@@ -301,6 +322,8 @@ Options of the particle textures made in code.
301
322
  const particleTextures: { glow(textures: Textures, options?: ParticleTextureOptions): ParticleTexture; spark(textures: Textures, options?: ParticleTextureOptions): ParticleTexture; smoke(textures: Textures, options?: ParticleTextureOptions): ParticleTexture; flame(textures: Textures, options?: ParticleTextureOptions): ParticleTexture; rain(textures: Textures, options?: ParticleTextureOptions): ParticleTexture; leaves(textures: Textures, options?: ParticleTextureOptions): ParticleTexture; }
302
323
  ```
303
324
 
325
+ Import from `@null3d/particles`.
326
+
304
327
  Particle textures made in code. Each takes the sketch's `textures` and returns a texture with its flipbook.
305
328
 
306
329
  ## `ParticleValues`
@@ -326,6 +349,8 @@ A field of air that a buffer's particles sample: a texture of the air, the box t
326
349
 
327
350
  Interface `SubEmitter`.
328
351
 
352
+ Import from `@null3d/particles`.
353
+
329
354
  A sub-emitter: another system that bursts where a particle of this system dies or first meets the ground. A firework's rocket bursts into sparks this way, and a raindrop splashes.
330
355
 
331
356
  | Member | Description |
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/points
3
3
  title: "Points: API reference"
4
- status: generated
5
- since: "0.2"
4
+ generated: true
6
5
  summary: "Every export of the Points API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -32,7 +31,7 @@ Many points: squares that face the camera, all of one size, each with its own po
32
31
 
33
32
  ## `PointOptions`
34
33
 
35
- Interface `PointOptions`, which extends `PointValues`, `Omit`.
34
+ Interface `PointOptions`, which extends `PointValues`, `Omit<MaterialFeatures, 'doubleSided' | 'vertexColors'>`.
36
35
 
37
36
  Options of `scene.createPoints`. The look of the points takes the options of an unlit material. Points are opaque by default.
38
37
 
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/post
3
3
  title: "Post-processing API: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Post-processing API API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -217,7 +216,9 @@ A custom tone curve: WGSL that declares `fn toneCurve(color: vec3f) -> vec3f`, c
217
216
  type ToneMapping = 'agx' | 'agx-punchy' | 'neutral' | 'aces' | 'none';
218
217
  ```
219
218
 
220
- How the engine maps the scene's high dynamic range color to the screen. The `'agx'` curve is AgX, the curve of Blender and Filament. The `'agx-punchy'` curve is AgX with Filament's punchy look, which adds contrast and color. The `'neutral'` curve is Khronos PBR Neutral, which keeps base colors as they are until they near white. The `'aces'` curve is a fit of the ACES filmic curve, which first scales the color by 1 / 0.6 and shifts the hues of bright colors. The value `'none'` clips the exposed color at 1.
219
+ How the engine maps the scene's high dynamic range color to the screen. The `'agx'` curve is AgX, the curve of Blender and Filament. The `'agx-punchy'` curve is AgX with Filament's punchy look, which adds contrast and color. The `'neutral'` curve is Khronos PBR Neutral, which keeps base colors as they are until they near white. The `'aces'` curve is a fit of the ACES filmic curve, which first scales the color by 1 / 0.6 and shifts the hues of bright colors.
220
+
221
+ The value `'none'` clips the exposed color at 1.
221
222
 
222
223
  ## `VignetteSettings`
223
224
 
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/quality
3
3
  title: "Quality API: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Quality API API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/raycast
3
3
  title: "Raycasting and spatial queries: API reference"
4
- status: generated
5
- since: "0.2"
4
+ generated: true
6
5
  summary: "Every export of the Raycasting and spatial queries API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/render
3
3
  title: "Render graph API: API reference"
4
- status: generated
5
- since: "0.2"
4
+ generated: true
6
5
  summary: "Every export of the Render graph API API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -40,7 +39,9 @@ The format of a compute pass's storage texture. `'rgba16float'` holds HDR color,
40
39
 
41
40
  Interface `ComputePassOptions`.
42
41
 
43
- Options of `render.addPass` for a compute pass, which runs a compiled compute shader over a storage texture of its own. The texture is the description's output, which `textures.fromPass` gives to materials, effects and other passes: they sample it in the frame that the pass writes it, and the render graph orders the pass before them. A compute pass runs on WebGPU. On WebGL2 it runs its fragment form when the options give one, and the call throws otherwise. The shader declares `@group(0) @binding(0) var<uniform>` for the pass's block and `@group(0) @binding(1) var` for its storage texture, which it reads as an array of one layer, and the textures of `textures` at group 1, as a custom material's maps bind. The block holds the render size, the clock, the inverse of the camera's projection, eight vectors of `values`, and the target's size.
42
+ Options of `render.addPass` for a compute pass, which runs a compiled compute shader over a storage texture of its own. The texture is the description's output, which `textures.fromPass` gives to materials, effects and other passes: they sample it in the frame that the pass writes it, and the render graph orders the pass before them. A compute pass runs on WebGPU. On WebGL2 it runs its fragment form when the options give one, and the call throws otherwise.
43
+
44
+ The shader declares `@group(0) @binding(0) var<uniform>` for the pass's block and `@group(0) @binding(1) var` for its storage texture, which it reads as an array of one layer, and the textures of `textures` at group 1, as a custom material's maps bind. The block holds the render size, the clock, the inverse of the camera's projection, eight vectors of `values`, and the target's size.
44
45
 
45
46
  | Member | Description |
46
47
  | --- | --- |
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/scene
3
3
  title: "Scene: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Scene API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -112,7 +111,11 @@ One chunk's rows, in the order that a coarser level keeps: its count, and its ar
112
111
 
113
112
  Class `ChunkRowWriter`.
114
113
 
115
- Packs chunked rows into an instance batch's rows. Store each chunk once with [`write`], then call [`pack`] with one chosen count for each slot. The pack writes the chosen prefix of each chunk, in slot order, and sets the batch's active count. The batch must own its rows' transforms. A batch that reads another batch's rows, such as a part of a model, or a sprite or line batch, takes no chunked rows: a pack on one writes nothing and keeps its active count. The writer keeps one plan array in the engine's memory, so a frame's pack allocates nothing once the slot count is set.
114
+ Packs chunked rows into an instance batch's rows. Store each chunk once with [`write`], then call [`pack`] with one chosen count for each slot. The pack writes the chosen prefix of each chunk, in slot order, and sets the batch's active count.
115
+
116
+ The batch must own its rows' transforms. A batch that reads another batch's rows, such as a part of a model, or a sprite or line batch, takes no chunked rows: a pack on one writes nothing and keeps its active count.
117
+
118
+ The writer keeps one plan array in the engine's memory, so a frame's pack allocates nothing once the slot count is set.
116
119
 
117
120
  | Member | Description |
118
121
  | --- | --- |
@@ -489,7 +492,23 @@ The settings of the analytic sky, the Preetham daylight model with a sun disc an
489
492
  function timeOfDay(time: number | TimeOfDayPreset, options: TimeOfDayOptions = {}, out: TimeOfDay = emptyTimeOfDay()): TimeOfDay
490
493
  ```
491
494
 
492
- Works out the settings of a time of day: an hour from 0 to 24, or a named preset. The sun rises at 6, stands highest at 12 and sets at 18. After sunset the sky dims to a deep blue, and then to a navy night sky lit from the moon's place, and the moon takes over as the main light. Each value comes from the model of the sky that the background draws, so the fog fades into the sky's horizon. Throws a `RangeError` for an hour that is not a finite number, or an unknown preset. Give it `out`, an object of a previous call, and it writes the new settings into that object: a day cycle then allocates nothing, so a sketch can move the time in every frame. `bun run bench:allocation --time-of-day` checks that. Without it the call makes a new object. `emptyTimeOfDay()` makes the first one to pass. ```ts const day = emptyTimeOfDay(); timeOfDay('goldenHour', {}, day); scene.setBackground({ sky: day.sky }, { intensity: day.skyIntensity }); scene.setEnvironment(skyLight, { intensity: day.skyIntensity }); sun.setDirection(...day.light.direction); sun.setColor(day.light.color); sun.setIntensity(day.light.intensity); scene.setFog({ color: day.fog.color, density: 0.01, sunGlow: day.fog.sunGlow }); post.set({ exposure: day.exposure }); ```
495
+ Works out the settings of a time of day: an hour from 0 to 24, or a named preset. The sun rises at 6, stands highest at 12 and sets at 18. After sunset the sky dims to a deep blue, and then to a navy night sky lit from the moon's place, and the moon takes over as the main light.
496
+
497
+ Each value comes from the model of the sky that the background draws, so the fog takes that sky's horizon color by day and its average at dusk. With the physical model it takes the sky's mean light by day and through dusk, then the moon sky's horizon light at night. Throws a `RangeError` for an hour that is not a finite number, or an unknown preset.
498
+
499
+ Give it `out`, an object of a previous call, and it writes the new settings into that object: a day cycle then allocates nothing, so a sketch can move the time in every frame. `bun run bench:allocation --time-of-day` checks that. Without it the call makes a new object. `emptyTimeOfDay()` makes the first one to pass.
500
+
501
+ ```ts
502
+ const day = emptyTimeOfDay();
503
+ timeOfDay('goldenHour', {}, day);
504
+ scene.setBackground({ sky: day.sky }, { intensity: day.skyIntensity });
505
+ scene.setEnvironment(skyLight, { intensity: day.skyIntensity });
506
+ sun.setDirection(...day.light.direction);
507
+ sun.setColor(day.light.color);
508
+ sun.setIntensity(day.light.intensity);
509
+ scene.setFog({ color: day.fog.color, density: 0.01, sunGlow: day.fog.sunGlow });
510
+ post.set({ exposure: day.exposure });
511
+ ```
493
512
 
494
513
  ## `TimeOfDay`
495
514
 
@@ -504,7 +523,7 @@ The settings of one time of day, which `timeOfDay` works out. Apply them to the
504
523
  | `atmosphere: TimeOfDayAtmosphere` | The physical sky's settings for `scene.setBackground({ atmosphere })`: the real sun and its light, and at night the moon, which lights the air too, and the stars. Spread it into the scene's own settings, such as its clouds and `aerialPerspective`. |
505
524
  | `skyIntensity: number` | The factor of the sky's light for the background's and the environment's `intensity`. It dims the analytic sky after sunset, as its model alone keeps a glow. The physical sky dims by itself, so with the physical model it is 1. |
506
525
  | `light: { direction: [number, number, number]; color: [number, number, number]; intensity: number; }` | The main directional light: the sun while it is up, and the moon at night. `direction` points from the light into the scene, as `setDirection` takes it. `color` is linear. |
507
- | `fog: { color: [number, number, number]; sunGlow: number; }` | The fog's linear color, the sky's color along the horizon, and the glow toward the main light, for `scene.setFog`. |
526
+ | `fog: { color: [number, number, number]; sunGlow: number; }` | The fog's linear color and the glow toward the main light, for `scene.setFog`. With the analytic model the color is the sky's horizon by day and its average at dusk. With the physical model it is the sky's mean light by day and through dusk, then the moon sky's horizon light at night. |
508
527
  | `ambient: { color: [number, number, number]; intensity: number; }` | A linear ambient color and intensity of the sky's average light, for a scene that has no environment. A scene lit by the sky's environment needs no ambient light. |
509
528
  | `exposure: number` | The exposure for `post.set({ exposure })`, higher as the light dims. |
510
529
 
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/sketch
3
3
  title: "Sketch API: defineSketch and the context: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Sketch API: defineSketch and the context API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -13,10 +12,10 @@ summary: "Every export of the Sketch API: defineSketch and the context API, from
13
12
  ## `defineSketch`
14
13
 
15
14
  ```ts
16
- function defineSketch(setup: SketchSetup, options: SketchOptions = {}): SketchDefinition
15
+ function defineSketch<Data = unknown>(setup: SketchSetup<Data>, options: SketchOptions = {}): SketchDefinition<Data>
17
16
  ```
18
17
 
19
- Declares a sketch. In null3D, a 3D scene is called a sketch: a module that builds the scene and updates it every frame, in the sketch worker. The module must export the result as its default export. `options` sets the rate of the fixed steps.
18
+ Declares a sketch. In null3D, a 3D scene is called a sketch: a module that builds the scene and updates it every frame, in the sketch worker. The module must export the result as its default export. `options` sets the rate of the fixed steps. `Data` types the start data that the setup reads as `ctx.data`, such as `defineSketch<{ stop: string }>(...)`.
20
19
 
21
20
  ## `SketchCallbacks`
22
21
 
@@ -26,19 +25,20 @@ Callbacks a sketch returns from its setup function. In each frame the engine cal
26
25
 
27
26
  | Member | Description |
28
27
  | --- | --- |
29
- | `onFixedUpdate(step: number): void` | Runs at a fixed rate, 60 times per second of sketch time unless `defineSketch`'s options set another, with the step's length in seconds. A frame runs it once for each step that falls due since the previous frame, so 0 or more times, before `onUpdate`. After a slow frame, a frame runs at most 8 steps unless the options set another number, and drops the rest. Use it for simulation, such as physics, that must step the same at every frame rate. |
30
- | `onUpdate(dt: number): void` | Runs once per frame, before transforms, with the frame's step in seconds. The first frame, and the first after a pause or a hidden page, gets 0. No step is longer than a quarter second, so a very slow frame slows the sketch instead of jumping it. In hold mode, each frame after the first gets a fixed step of 1/60 second. |
31
- | `onLateUpdate(dt: number): void` | Runs once per frame after the engine updates transforms, and before it culls and draws, with the frame's step in seconds. World positions already hold the frame's changes, and the engine updates the objects that it moves before it draws the frame. A camera that follows an object here does not lag a frame behind it. |
32
- | `onDestroy(): void` | Runs once when the engine stops, on the sketch's thread, before its workers stop. Remove the timers, event listeners and message handlers that the sketch added outside the engine here. After it, every call to the engine fails with E1420. |
28
+ | `onFixedUpdate?(step: number): void` | Runs at a fixed rate, 60 times per second of sketch time unless `defineSketch`'s options set another, with the step's length in seconds. A frame runs it once for each step that falls due since the previous frame, so 0 or more times, before `onUpdate`. After a slow frame, a frame runs at most 8 steps unless the options set another number, and drops the rest. Use it for simulation, such as physics, that must step the same at every frame rate. |
29
+ | `onUpdate?(dt: number): void` | Runs once per frame, before transforms, with the frame's step in seconds. The first frame, and the first after a pause or a hidden page, gets 0. No step is longer than a quarter second, so a very slow frame slows the sketch instead of jumping it. In hold mode, each frame after the first gets a fixed step of 1/60 second. |
30
+ | `onLateUpdate?(dt: number): void` | Runs once per frame after the engine updates transforms, and before it culls and draws, with the frame's step in seconds. World positions already hold the frame's changes, and the engine updates the objects that it moves before it draws the frame. A camera that follows an object here does not lag a frame behind it. |
31
+ | `onDestroy?(): void` | Runs once when the engine stops, on the sketch's thread, before its workers stop. Remove the timers, event listeners and message handlers that the sketch added outside the engine here. After it, every call to the engine fails with E1420. |
33
32
 
34
33
  ## `SketchContext`
35
34
 
36
35
  Interface `SketchContext`.
37
36
 
38
- What the engine passes to a sketch's setup function.
37
+ What the engine passes to a sketch's setup function. `Data` is the type of the start data that the page passes, which `defineSketch<Data>` names.
39
38
 
40
39
  | Member | Description |
41
40
  | --- | --- |
41
+ | `readonly data: Data \| undefined` | The start data that the page passed as `createEngine`'s `sketchData`, or undefined when it passed none. It is there from the start of the setup, before the first frame, also in hold mode. The sketch gets its own copy, so a change to it reaches neither the page nor a replay. A replay gives the data that the recording keeps. |
42
42
  | `scene: Scene` | Objects, cameras, lights and instance batches. |
43
43
  | `materials: Materials` | Material factories. |
44
44
  | `geometry: Geometry` | Mesh generators. |
@@ -63,7 +63,7 @@ A sketch, as `defineSketch` returns it.
63
63
 
64
64
  | Member | Description |
65
65
  | --- | --- |
66
- | `readonly setup: SketchSetup` | The setup function passed to `defineSketch`. |
66
+ | `readonly setup: SketchSetup<Data>` | The setup function passed to `defineSketch`. |
67
67
  | `readonly options: SketchOptions` | The options passed to `defineSketch`. |
68
68
 
69
69
  ## `SketchEngine`
@@ -107,7 +107,7 @@ The user's display preferences, which the page reads from the system and passes
107
107
  ## `SketchSetup`
108
108
 
109
109
  ```ts
110
- type SketchSetup = (context: SketchContext) => SketchCallbacks | undefined | Promise<SketchCallbacks | undefined>;
110
+ type SketchSetup<Data = unknown> = (context: SketchContext<Data>) => SketchCallbacks | undefined | Promise<SketchCallbacks | undefined>;
111
111
  ```
112
112
 
113
113
  A sketch's setup function. The engine calls it once, in the sketch worker, and it returns the sketch's callbacks, directly or through a promise.
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/sound
3
3
  title: "Sound (@null3d/sound): API reference"
4
- status: generated
5
- since: "0.3"
4
+ generated: true
6
5
  summary: "Every export of the Sound (@null3d/sound) API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -16,6 +15,8 @@ summary: "Every export of the Sound (@null3d/sound) API, from the engine's doc c
16
15
  function connectSound(engine: Engine, options: PageSoundOptions = {}): PageSound
17
16
  ```
18
17
 
18
+ Import from `@null3d/sound/page`.
19
+
19
20
  Connects the page to the sketch's sounds, which `createSound` makes in the sketch. Call it once, after `createEngine` resolves. Nothing plays until `start` runs in answer to a click, a tap or a key, or the user's first input with `startOnInput`.
20
21
 
21
22
  ## `createSound`
@@ -24,6 +25,8 @@ Connects the page to the sketch's sounds, which `createSound` makes in the sketc
24
25
  function createSound(ctx: SketchContext, options: SoundOptions): Sound
25
26
  ```
26
27
 
28
+ Import from `@null3d/sound`.
29
+
27
30
  Makes the sketch's sounds. Call it in the sketch's setup, and call `update` once a frame in `onLateUpdate`. The sounds play on the page once the page's half, `connectSound` from `@null3d/sound/page`, has started the audio. A sketch may make its sounds at any time; a sound made before the page connects plays once it does.
28
31
 
29
32
  ## `NAMESPACE`
@@ -32,12 +35,16 @@ Makes the sketch's sounds. Call it in the sketch's setup, and call `update` once
32
35
  const NAMESPACE: AddonNamespace
33
36
  ```
34
37
 
38
+ Import from `@null3d/sound`.
39
+
35
40
  The add-on's names, claimed once as the sketch loads: its name, its package and its error codes.
36
41
 
37
42
  ## `PageSound`
38
43
 
39
44
  Interface `PageSound`.
40
45
 
46
+ Import from `@null3d/sound/page`.
47
+
41
48
  The page's half of the sound, as `connectSound` makes it.
42
49
 
43
50
  | Member | Description |
@@ -53,6 +60,8 @@ The page's half of the sound, as `connectSound` makes it.
53
60
 
54
61
  Interface `PageSoundOptions`.
55
62
 
63
+ Import from `@null3d/sound/page`.
64
+
56
65
  Options for `connectSound`.
57
66
 
58
67
  | Member | Description |
@@ -64,6 +73,8 @@ Options for `connectSound`.
64
73
 
65
74
  Interface `Sound`.
66
75
 
76
+ Import from `@null3d/sound`.
77
+
67
78
  The sketch's sounds, as `createSound` makes them.
68
79
 
69
80
  | Member | Description |
@@ -80,6 +91,8 @@ The sketch's sounds, as `createSound` makes them.
80
91
 
81
92
  Interface `SoundGroup`.
82
93
 
94
+ Import from `@null3d/sound`.
95
+
83
96
  Many sounds that play one file, such as the engines of the cars in a street, as `sound.group` makes it. Its arrays are views of the table, which a sketch may also write in bulk. They belong to the group until `destroy`: after it, the group's emitters may serve another sound, so a sketch drops the arrays with the group.
84
97
 
85
98
  | Member | Description |
@@ -99,6 +112,8 @@ Many sounds that play one file, such as the engines of the cars in a street, as
99
112
 
100
113
  Interface `SoundGroupOptions`, which extends `SoundPlacement`.
101
114
 
115
+ Import from `@null3d/sound`.
116
+
102
117
  Options for `sound.group`.
103
118
 
104
119
  | Member | Description |
@@ -111,6 +126,8 @@ Options for `sound.group`.
111
126
 
112
127
  Interface `SoundListener`.
113
128
 
129
+ Import from `@null3d/sound`.
130
+
114
131
  The object that hears the sounds, usually the active camera. The add-on reads its place and turn in the world once a frame. A camera looks down its own -Z axis, and so does the listener.
115
132
 
116
133
  | Member | Description |
@@ -122,6 +139,8 @@ The object that hears the sounds, usually the active camera. The add-on reads it
122
139
 
123
140
  Interface `SoundLoop`.
124
141
 
142
+ Import from `@null3d/sound`.
143
+
125
144
  A sound that plays its file over and over, as `sound.loop` makes it.
126
145
 
127
146
  | Member | Description |
@@ -136,6 +155,8 @@ A sound that plays its file over and over, as `sound.loop` makes it.
136
155
 
137
156
  Interface `SoundLoopOptions`, which extends `SoundPlacement`.
138
157
 
158
+ Import from `@null3d/sound`.
159
+
139
160
  Options for `sound.loop`.
140
161
 
141
162
  | Member | Description |
@@ -151,6 +172,8 @@ Options for `sound.loop`.
151
172
 
152
173
  Interface `SoundOptions`.
153
174
 
175
+ Import from `@null3d/sound`.
176
+
154
177
  Options for `createSound`.
155
178
 
156
179
  | Member | Description |
@@ -163,6 +186,8 @@ Options for `createSound`.
163
186
 
164
187
  Interface `SoundPlacement`.
165
188
 
189
+ Import from `@null3d/sound`.
190
+
166
191
  How a sound falls off with distance. A sound with neither distance keeps the level that the sketch gives it wherever the listener stands.
167
192
 
168
193
  | Member | Description |
@@ -175,6 +200,8 @@ How a sound falls off with distance. A sound with neither distance keeps the lev
175
200
 
176
201
  Interface `SoundShot`.
177
202
 
203
+ Import from `@null3d/sound`.
204
+
178
205
  A sound that plays its file once for each call, such as thunder or a door, as `sound.shot` makes it.
179
206
 
180
207
  | Member | Description |
@@ -186,6 +213,8 @@ A sound that plays its file once for each call, such as thunder or a door, as `s
186
213
 
187
214
  Interface `SoundShotOptions`, which extends `SoundPlacement`.
188
215
 
216
+ Import from `@null3d/sound`.
217
+
189
218
  Options for `sound.shot`.
190
219
 
191
220
  | Member | Description |
@@ -200,4 +229,6 @@ Options for `sound.shot`.
200
229
  type SoundState = 'off' | 'starting' | 'on' | 'paused' | 'interrupted' | 'stopped';
201
230
  ```
202
231
 
232
+ Import from `@null3d/sound/page`.
233
+
203
234
  Where the page's sound stands: not started, starting, playing, paused while the engine is paused or the page is hidden, interrupted while the browser holds the audio, as an iPhone does during a call, or stopped for good. An interrupted sound resumes at the user's next input, or when the page shows again.