@null3d/engine 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (517) hide show
  1. package/README.md +109 -0
  2. package/THIRD-PARTY-NOTICES.txt +0 -1
  3. package/dist/wasm/single/null3d.js +25 -10
  4. package/dist/wasm/single/null3d_bg.wasm +0 -0
  5. package/dist/wasm/threaded/null3d.js +25 -10
  6. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  7. package/docs/api/animation.md +114 -86
  8. package/docs/api/assets.md +135 -49
  9. package/docs/api/cameras.md +45 -12
  10. package/docs/api/controls.md +88 -62
  11. package/docs/api/debug.md +116 -41
  12. package/docs/api/engine.md +117 -35
  13. package/docs/api/feature-draws.md +23 -17
  14. package/docs/api/feature-effects.md +11 -11
  15. package/docs/api/feature-instances.md +70 -19
  16. package/docs/api/features.md +77 -47
  17. package/docs/api/geometry.md +132 -82
  18. package/docs/api/grass.md +55 -13
  19. package/docs/api/impostors.md +175 -22
  20. package/docs/api/input.md +24 -18
  21. package/docs/api/lights.md +78 -51
  22. package/docs/api/lines.md +41 -33
  23. package/docs/api/materials.md +248 -121
  24. package/docs/api/math.md +12 -13
  25. package/docs/api/objects.md +47 -22
  26. package/docs/api/page.md +58 -7
  27. package/docs/api/particles.md +33 -20
  28. package/docs/api/points.md +19 -31
  29. package/docs/api/post.md +75 -42
  30. package/docs/api/quality.md +42 -17
  31. package/docs/api/raycast.md +65 -51
  32. package/docs/api/reference/animation.md +10 -11
  33. package/docs/api/reference/assets.md +25 -22
  34. package/docs/api/reference/cameras.md +8 -4
  35. package/docs/api/reference/controls.md +134 -25
  36. package/docs/api/reference/debug.md +81 -14
  37. package/docs/api/reference/engine.md +58 -17
  38. package/docs/api/reference/feature-draws.md +3 -4
  39. package/docs/api/reference/feature-effects.md +2 -3
  40. package/docs/api/reference/feature-instances.md +5 -4
  41. package/docs/api/reference/features.md +7 -4
  42. package/docs/api/reference/geometry.md +287 -97
  43. package/docs/api/reference/grass.md +63 -3
  44. package/docs/api/reference/impostors.md +208 -13
  45. package/docs/api/reference/input.md +4 -5
  46. package/docs/api/reference/lights.md +13 -12
  47. package/docs/api/reference/lines.md +10 -11
  48. package/docs/api/reference/materials.md +54 -53
  49. package/docs/api/reference/math.md +35 -24
  50. package/docs/api/reference/objects.md +11 -12
  51. package/docs/api/reference/particles.md +31 -6
  52. package/docs/api/reference/points.md +6 -7
  53. package/docs/api/reference/post.md +21 -20
  54. package/docs/api/reference/quality.md +8 -5
  55. package/docs/api/reference/raycast.md +7 -8
  56. package/docs/api/reference/render.md +5 -4
  57. package/docs/api/reference/scene.md +52 -30
  58. package/docs/api/reference/sketch.md +15 -11
  59. package/docs/api/reference/sound.md +234 -0
  60. package/docs/api/reference/splats.md +42 -3
  61. package/docs/api/reference/sprites.md +7 -8
  62. package/docs/api/reference/tasks.md +16 -3
  63. package/docs/api/reference/terrain.md +27 -5
  64. package/docs/api/reference/textures.md +5 -6
  65. package/docs/api/reference/three-compat.md +18 -7
  66. package/docs/api/reference/time.md +1 -2
  67. package/docs/api/reference/ui.md +12 -9
  68. package/docs/api/reference/vertex-draws.md +5 -6
  69. package/docs/api/reference/water.md +153 -9
  70. package/docs/api/reference/wind.md +17 -4
  71. package/docs/api/render.md +73 -29
  72. package/docs/api/scene.md +164 -60
  73. package/docs/api/sketch.md +102 -15
  74. package/docs/api/sound.md +205 -0
  75. package/docs/api/splats.md +46 -12
  76. package/docs/api/sprites.md +10 -24
  77. package/docs/api/tasks.md +33 -24
  78. package/docs/api/terrain.md +42 -22
  79. package/docs/api/textures.md +68 -19
  80. package/docs/api/three-compat.md +15 -7
  81. package/docs/api/time.md +3 -5
  82. package/docs/api/ui.md +19 -23
  83. package/docs/api/vertex-draws.md +13 -12
  84. package/docs/api/water.md +262 -35
  85. package/docs/api/wind.md +63 -17
  86. package/docs/cli/null3d.md +177 -27
  87. package/docs/concepts/architecture.md +73 -27
  88. package/docs/concepts/assets.md +57 -33
  89. package/docs/concepts/backends.md +69 -27
  90. package/docs/concepts/color-management.md +54 -36
  91. package/docs/concepts/culling.md +68 -47
  92. package/docs/concepts/handles.md +14 -5
  93. package/docs/concepts/instances.md +74 -25
  94. package/docs/concepts/large-worlds.md +18 -8
  95. package/docs/concepts/lighting.md +155 -87
  96. package/docs/concepts/lod.md +126 -44
  97. package/docs/concepts/materials.md +58 -27
  98. package/docs/concepts/particle-buffer.md +48 -35
  99. package/docs/concepts/post-processing.md +84 -43
  100. package/docs/concepts/quality-preset-tables.md +56 -52
  101. package/docs/concepts/quality-presets.md +164 -52
  102. package/docs/concepts/render-graph.md +69 -29
  103. package/docs/concepts/render-layers.md +11 -21
  104. package/docs/concepts/shadows.md +105 -52
  105. package/docs/concepts/static-dynamic.md +22 -7
  106. package/docs/cookbook/index.md +164 -120
  107. package/docs/data/threejs-mapping.json +362 -367
  108. package/docs/errors/E1101.md +23 -5
  109. package/docs/errors/E1102.md +11 -3
  110. package/docs/errors/E1103.md +11 -3
  111. package/docs/errors/E1104.md +11 -3
  112. package/docs/errors/E1105.md +13 -5
  113. package/docs/errors/E1106.md +11 -3
  114. package/docs/errors/E1107.md +15 -5
  115. package/docs/errors/E1108.md +11 -3
  116. package/docs/errors/E1109.md +32 -6
  117. package/docs/errors/E1110.md +23 -5
  118. package/docs/errors/E1111.md +11 -3
  119. package/docs/errors/E1112.md +11 -3
  120. package/docs/errors/E1203.md +12 -4
  121. package/docs/errors/E1204.md +11 -3
  122. package/docs/errors/E1205.md +11 -3
  123. package/docs/errors/E1206.md +28 -6
  124. package/docs/errors/E1207.md +11 -3
  125. package/docs/errors/E1208.md +12 -3
  126. package/docs/errors/E1209.md +11 -3
  127. package/docs/errors/E1213.md +27 -5
  128. package/docs/errors/E1214.md +14 -6
  129. package/docs/errors/E1215.md +31 -6
  130. package/docs/errors/E1216.md +31 -6
  131. package/docs/errors/E1217.md +29 -6
  132. package/docs/errors/E1218.md +22 -6
  133. package/docs/errors/E1219.md +11 -3
  134. package/docs/errors/E1220.md +24 -5
  135. package/docs/errors/E1221.md +24 -5
  136. package/docs/errors/E1222.md +11 -3
  137. package/docs/errors/E1223.md +39 -6
  138. package/docs/errors/E1224.md +11 -3
  139. package/docs/errors/E1225.md +11 -3
  140. package/docs/errors/E1301.md +11 -3
  141. package/docs/errors/E1302.md +11 -3
  142. package/docs/errors/E1303.md +11 -3
  143. package/docs/errors/E1304.md +11 -3
  144. package/docs/errors/E1305.md +13 -3
  145. package/docs/errors/E1306.md +11 -3
  146. package/docs/errors/E1307.md +40 -0
  147. package/docs/errors/E1401.md +11 -3
  148. package/docs/errors/E1402.md +13 -5
  149. package/docs/errors/E1403.md +11 -3
  150. package/docs/errors/E1404.md +13 -3
  151. package/docs/errors/E1405.md +15 -4
  152. package/docs/errors/E1406.md +31 -5
  153. package/docs/errors/E1407.md +11 -3
  154. package/docs/errors/E1408.md +11 -3
  155. package/docs/errors/E1409.md +11 -3
  156. package/docs/errors/E1410.md +13 -5
  157. package/docs/errors/E1411.md +11 -3
  158. package/docs/errors/E1412.md +29 -6
  159. package/docs/errors/E1413.md +11 -3
  160. package/docs/errors/E1414.md +11 -3
  161. package/docs/errors/E1415.md +11 -3
  162. package/docs/errors/E1416.md +27 -6
  163. package/docs/errors/E1417.md +11 -3
  164. package/docs/errors/E1418.md +12 -3
  165. package/docs/errors/E1419.md +13 -5
  166. package/docs/errors/E1420.md +14 -6
  167. package/docs/errors/E1421.md +11 -3
  168. package/docs/errors/E1422.md +12 -3
  169. package/docs/errors/E1423.md +12 -3
  170. package/docs/errors/E1424.md +24 -5
  171. package/docs/errors/E1425.md +11 -3
  172. package/docs/errors/E1426.md +11 -3
  173. package/docs/errors/E1430.md +11 -3
  174. package/docs/errors/E1431.md +11 -3
  175. package/docs/errors/E1432.md +11 -3
  176. package/docs/errors/E1433.md +11 -3
  177. package/docs/errors/E1434.md +15 -6
  178. package/docs/errors/E1435.md +11 -3
  179. package/docs/errors/E1436.md +11 -3
  180. package/docs/errors/E1437.md +14 -6
  181. package/docs/errors/E1501.md +41 -6
  182. package/docs/errors/E1502.md +13 -3
  183. package/docs/errors/E1503.md +11 -3
  184. package/docs/errors/E1504.md +11 -3
  185. package/docs/errors/E1505.md +23 -5
  186. package/docs/errors/E1506.md +11 -3
  187. package/docs/errors/index.md +54 -30
  188. package/docs/getting-started/cdn.md +32 -10
  189. package/docs/getting-started/first-scene.md +21 -13
  190. package/docs/getting-started/hosting.md +152 -63
  191. package/docs/getting-started/install.md +44 -28
  192. package/docs/getting-started/network-use.md +33 -15
  193. package/docs/getting-started/project-structure.md +33 -12
  194. package/docs/getting-started/third-party-notices.md +12 -14
  195. package/docs/guides/accessibility.md +5 -5
  196. package/docs/guides/add-ons.md +86 -15
  197. package/docs/guides/agents.md +16 -9
  198. package/docs/guides/assets-pipeline.md +259 -82
  199. package/docs/guides/audio.md +115 -128
  200. package/docs/guides/baked-light-data.md +44 -23
  201. package/docs/guides/car-paint.md +38 -32
  202. package/docs/guides/content-pages.md +63 -35
  203. package/docs/guides/custom-passes.md +65 -22
  204. package/docs/guides/custom-shaders.md +59 -39
  205. package/docs/guides/debugging.md +74 -10
  206. package/docs/guides/deploying.md +85 -6
  207. package/docs/guides/deterministic-simulation.md +24 -17
  208. package/docs/guides/first-use-shaders.md +83 -45
  209. package/docs/guides/lens-kit.md +29 -26
  210. package/docs/guides/loading-screens.md +132 -47
  211. package/docs/guides/multiple-views.md +63 -13
  212. package/docs/guides/performance.md +192 -38
  213. package/docs/guides/phones.md +78 -15
  214. package/docs/guides/physics.md +7 -11
  215. package/docs/guides/screens.md +47 -33
  216. package/docs/guides/start-time.md +363 -0
  217. package/docs/guides/testing.md +152 -95
  218. package/docs/guides/ui-overlays.md +19 -14
  219. package/docs/guides/video-textures.md +14 -13
  220. package/docs/images/api/animation/character.webp +0 -0
  221. package/docs/images/api/animation/look-at-ring.webp +0 -0
  222. package/docs/images/api/animation/morph-tulips.webp +0 -0
  223. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  224. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  225. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  226. package/docs/images/api/debug/debug-shapes.webp +0 -0
  227. package/docs/images/api/debug/levels-view.webp +0 -0
  228. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  229. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  230. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  231. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  232. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  233. package/docs/images/api/geometry/generators.webp +0 -0
  234. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  235. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  236. package/docs/images/api/grass/grass-grove.webp +0 -0
  237. package/docs/images/api/grass/grass-presets.webp +0 -0
  238. package/docs/images/api/grass/grass-shadow.webp +0 -0
  239. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  240. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  241. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  242. package/docs/images/api/lights/spot-cookies.webp +0 -0
  243. package/docs/images/api/lines/lines-lit.webp +0 -0
  244. package/docs/images/api/lines/lines-widths.webp +0 -0
  245. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  246. package/docs/images/api/materials/decals.webp +0 -0
  247. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  248. package/docs/images/api/materials/relief.webp +0 -0
  249. package/docs/images/api/materials/shader-inputs.webp +0 -0
  250. package/docs/images/api/materials/standard-grid.webp +0 -0
  251. package/docs/images/api/materials/subsurface.webp +0 -0
  252. package/docs/images/api/materials/translucency.webp +0 -0
  253. package/docs/images/api/objects/objects-turntable.webp +0 -0
  254. package/docs/images/api/particles/campfire.webp +0 -0
  255. package/docs/images/api/points/galaxy.webp +0 -0
  256. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  257. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  258. package/docs/images/api/render/reflection-mirror.webp +0 -0
  259. package/docs/images/api/render/security-camera.webp +0 -0
  260. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  261. package/docs/images/api/sound/sound-demo.webp +0 -0
  262. package/docs/images/api/splats/splats-demo.webp +0 -0
  263. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  264. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  265. package/docs/images/api/textures/canvas-screen.webp +0 -0
  266. package/docs/images/api/textures/mipmaps.webp +0 -0
  267. package/docs/images/api/vertex-draws/rain.webp +0 -0
  268. package/docs/images/api/water/ocean.webp +0 -0
  269. package/docs/images/api/water/water-demo.webp +0 -0
  270. package/docs/images/api/water/water-rain.webp +0 -0
  271. package/docs/images/api/water/waterfall.webp +0 -0
  272. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  273. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  274. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  275. package/docs/images/concepts/instances/instances.webp +0 -0
  276. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  277. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  278. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  279. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  280. package/docs/images/concepts/lighting/environment.webp +0 -0
  281. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  282. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  283. package/docs/images/concepts/lod/forest.webp +0 -0
  284. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  285. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  286. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  287. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  288. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  289. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  290. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  291. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  292. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  293. package/docs/images/cookbook/index/picking.webp +0 -0
  294. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  295. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  296. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  297. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  298. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  299. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  300. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  301. package/docs/images/index/showcase-island.webp +0 -0
  302. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  303. package/docs/images/shaders/builtins/builtins.webp +0 -0
  304. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  305. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  306. package/docs/images/shots.json +2231 -0
  307. package/docs/index.md +18 -23
  308. package/docs/moves.json +1 -0
  309. package/docs/nav.json +300 -0
  310. package/docs/pages.md +230 -209
  311. package/docs/porting/react-three-fiber.md +225 -6
  312. package/docs/porting/threejs-loop-and-threads.md +217 -7
  313. package/docs/porting/threejs-mapping.md +1249 -233
  314. package/docs/porting/threejs-materials.md +218 -6
  315. package/docs/porting/threejs-overview.md +240 -7
  316. package/docs/porting/threejs-postprocessing.md +4 -8
  317. package/docs/porting/threejs-shaders.md +301 -6
  318. package/docs/porting/threejs-unsupported.md +83 -7
  319. package/docs/porting/verification.md +178 -6
  320. package/docs/shaders/builtins.md +15 -4
  321. package/docs/shaders/library.md +72 -45
  322. package/docs/shaders/surface-functions.md +59 -23
  323. package/docs/shaders/wgsl-rules.md +12 -5
  324. package/lib/debug/channel.d.ts +103 -0
  325. package/lib/debug/channel.js +269 -0
  326. package/lib/debug/debug.d.ts +11 -9
  327. package/lib/debug/draw.d.ts +11 -2
  328. package/lib/debug/draw.js +57 -6
  329. package/lib/debug/inspector.d.ts +60 -0
  330. package/lib/debug/inspector.js +475 -0
  331. package/lib/debug/overlay-look.d.ts +6 -0
  332. package/lib/debug/overlay-look.js +29 -7
  333. package/lib/debug/overlay.js +15 -11
  334. package/lib/debug/stats-options.d.ts +13 -0
  335. package/lib/debug/stats-panel.d.ts +22 -7
  336. package/lib/debug/stats-panel.js +80 -13
  337. package/lib/debug/stats.d.ts +2 -3
  338. package/lib/errors/codes.d.ts +17 -3
  339. package/lib/errors/codes.js +117 -105
  340. package/lib/errors/engine-error.js +25 -10
  341. package/lib/errors/fixes.d.ts +1 -0
  342. package/lib/errors/fixes.js +20 -19
  343. package/lib/generated/core.d.ts +1 -1
  344. package/lib/generated/core.js +1 -1
  345. package/lib/gpu/early-builds.d.ts +68 -0
  346. package/lib/gpu/early-builds.js +158 -0
  347. package/lib/gpu/pipeline-name.d.ts +6 -0
  348. package/lib/gpu/pipeline-name.js +23 -0
  349. package/lib/gpu/variants.d.ts +8 -2
  350. package/lib/gpu/variants.js +39 -7
  351. package/lib/gpu/webgl2/backend.d.ts +63 -2
  352. package/lib/gpu/webgl2/backend.js +226 -8
  353. package/lib/gpu/webgl2/programs.d.ts +18 -0
  354. package/lib/gpu/webgl2/programs.js +5 -2
  355. package/lib/gpu/webgpu/backend.d.ts +89 -2
  356. package/lib/gpu/webgpu/backend.js +255 -8
  357. package/lib/gpu/webgpu/pipelines.d.ts +13 -0
  358. package/lib/gpu/webgpu/pipelines.js +28 -14
  359. package/lib/index.d.ts +7 -5
  360. package/lib/index.js +3 -2
  361. package/lib/math/color.d.ts +5 -5
  362. package/lib/math/color.js +5 -5
  363. package/lib/math/mat4.d.ts +6 -12
  364. package/lib/math/mat4.js +6 -12
  365. package/lib/math/namespaces/quat.d.ts +3 -3
  366. package/lib/math/namespaces/quat.js +3 -3
  367. package/lib/math/quat.d.ts +8 -12
  368. package/lib/math/quat.js +8 -12
  369. package/lib/math/random.d.ts +2 -3
  370. package/lib/math/random.js +2 -3
  371. package/lib/math/types.d.ts +4 -4
  372. package/lib/math/vec3.d.ts +3 -6
  373. package/lib/math/vec3.js +3 -6
  374. package/lib/page/capabilities.d.ts +8 -8
  375. package/lib/page/capabilities.js +39 -25
  376. package/lib/page/check-store.d.ts +14 -2
  377. package/lib/page/check-store.js +34 -11
  378. package/lib/page/engine.d.ts +117 -31
  379. package/lib/page/engine.js +438 -99
  380. package/lib/page/first-frame.d.ts +16 -0
  381. package/lib/page/first-frame.js +35 -0
  382. package/lib/page/frame-stats.d.ts +34 -1
  383. package/lib/page/frame-stats.js +15 -0
  384. package/lib/page/label-loop.d.ts +7 -3
  385. package/lib/page/label-loop.js +26 -14
  386. package/lib/page/labels.d.ts +3 -3
  387. package/lib/page/pipeline-store.d.ts +25 -0
  388. package/lib/page/pipeline-store.js +84 -0
  389. package/lib/page/start-marker.d.ts +4 -1
  390. package/lib/page/start-marker.js +5 -2
  391. package/lib/page/stats-switch.js +2 -0
  392. package/lib/page/switches.d.ts +38 -6
  393. package/lib/page/switches.js +29 -5
  394. package/lib/quality/check.d.ts +24 -3
  395. package/lib/quality/check.js +21 -7
  396. package/lib/quality/chooser.d.ts +6 -0
  397. package/lib/quality/chooser.js +8 -0
  398. package/lib/quality/governor.d.ts +98 -6
  399. package/lib/quality/governor.js +250 -20
  400. package/lib/quality/preset-docs.d.ts +16 -1
  401. package/lib/quality/preset-docs.js +3 -0
  402. package/lib/quality/presets.d.ts +84 -7
  403. package/lib/quality/presets.js +94 -2
  404. package/lib/render/draw.d.ts +3 -2
  405. package/lib/render/draw.js +15 -5
  406. package/lib/render/load-draw.d.ts +7 -5
  407. package/lib/render/load-draw.js +7 -5
  408. package/lib/render/loss.d.ts +28 -10
  409. package/lib/render/loss.js +50 -22
  410. package/lib/render/recovery.d.ts +20 -0
  411. package/lib/render/recovery.js +44 -4
  412. package/lib/render/renderer.d.ts +85 -9
  413. package/lib/render/renderer.js +181 -42
  414. package/lib/render/scene-renderer.d.ts +19 -1
  415. package/lib/render/scene-renderer.js +25 -1
  416. package/lib/render/webgl2-renderers.js +8 -5
  417. package/lib/render/webgpu-renderers.js +5 -4
  418. package/lib/scene/animation.d.ts +28 -32
  419. package/lib/scene/animation.js +12 -15
  420. package/lib/scene/assets.d.ts +61 -86
  421. package/lib/scene/assets.js +103 -236
  422. package/lib/scene/background.d.ts +14 -18
  423. package/lib/scene/background.js +5 -2
  424. package/lib/scene/baked-light.d.ts +2 -2
  425. package/lib/scene/color.d.ts +3 -3
  426. package/lib/scene/downloads.d.ts +2 -0
  427. package/lib/scene/downloads.js +371 -0
  428. package/lib/scene/environment.d.ts +7 -7
  429. package/lib/scene/environment.js +1 -1
  430. package/lib/scene/fake-call-values.js +3 -3
  431. package/lib/scene/fog.d.ts +11 -4
  432. package/lib/scene/fog.js +8 -2
  433. package/lib/scene/frame-cameras.d.ts +35 -4
  434. package/lib/scene/frame-cameras.js +86 -10
  435. package/lib/scene/gltf.d.ts +33 -3
  436. package/lib/scene/gltf.js +78 -49
  437. package/lib/scene/grading.d.ts +2 -2
  438. package/lib/scene/grading.js +3 -3
  439. package/lib/scene/ktx2.d.ts +9 -1
  440. package/lib/scene/ktx2.js +3 -2
  441. package/lib/scene/level-rule.d.ts +121 -0
  442. package/lib/scene/level-rule.js +130 -0
  443. package/lib/scene/lines.d.ts +13 -17
  444. package/lib/scene/lines.js +3 -3
  445. package/lib/scene/lut.d.ts +1 -2
  446. package/lib/scene/lut.js +1 -2
  447. package/lib/scene/particles.d.ts +7 -3
  448. package/lib/scene/particles.js +3 -1
  449. package/lib/scene/picks.d.ts +2 -2
  450. package/lib/scene/pointer-events.d.ts +4 -7
  451. package/lib/scene/post.d.ts +39 -43
  452. package/lib/scene/post.js +4 -1
  453. package/lib/scene/prefab.d.ts +7 -8
  454. package/lib/scene/prefab.js +7 -8
  455. package/lib/scene/property-animation.d.ts +1 -1
  456. package/lib/scene/property-animation.js +1 -1
  457. package/lib/scene/queries.d.ts +7 -13
  458. package/lib/scene/resources.d.ts +238 -261
  459. package/lib/scene/resources.js +179 -81
  460. package/lib/scene/scene.d.ts +167 -120
  461. package/lib/scene/scene.js +243 -103
  462. package/lib/scene/serial-loads.d.ts +29 -0
  463. package/lib/scene/serial-loads.js +68 -0
  464. package/lib/scene/shader-preloads.d.ts +34 -0
  465. package/lib/scene/shader-preloads.js +38 -0
  466. package/lib/scene/sprites.d.ts +14 -17
  467. package/lib/scene/sprites.js +5 -6
  468. package/lib/scene/textures.d.ts +11 -12
  469. package/lib/scene/textures.js +9 -10
  470. package/lib/scene/time-of-day.d.ts +11 -7
  471. package/lib/scene/time-of-day.js +11 -8
  472. package/lib/scene/vertex-draws.d.ts +5 -4
  473. package/lib/scene/vertex-draws.js +7 -5
  474. package/lib/shader-artifact.json +1 -0
  475. package/lib/shared/core.d.ts +5 -0
  476. package/lib/shared/core.js +1 -0
  477. package/lib/shared/import-once.d.ts +6 -0
  478. package/lib/shared/import-once.js +19 -0
  479. package/lib/shared/labels.d.ts +5 -2
  480. package/lib/shared/labels.js +5 -2
  481. package/lib/shared/metrics.d.ts +38 -0
  482. package/lib/shared/metrics.js +62 -1
  483. package/lib/shared/permutation-words.d.ts +2 -0
  484. package/lib/shared/permutation-words.js +8 -0
  485. package/lib/shared/recording.d.ts +13 -5
  486. package/lib/shared/recording.js +31 -10
  487. package/lib/shared/run-task.js +7 -1
  488. package/lib/shared/sketch-data.d.ts +9 -0
  489. package/lib/shared/sketch-data.js +57 -0
  490. package/lib/shared/task-pending.d.ts +12 -0
  491. package/lib/shared/task-pending.js +61 -1
  492. package/lib/shared/tasks.js +79 -32
  493. package/lib/shared/version.d.ts +17 -1
  494. package/lib/shared/version.js +19 -1
  495. package/lib/shared/wasm.d.ts +12 -4
  496. package/lib/shared/wasm.js +50 -27
  497. package/lib/shared/worker-start.d.ts +7 -0
  498. package/lib/shared/worker-start.js +27 -0
  499. package/lib/sketch/define-sketch.d.ts +51 -7
  500. package/lib/sketch/define-sketch.js +2 -1
  501. package/lib/sketch/input.d.ts +2 -2
  502. package/lib/sketch/preset-check.d.ts +20 -6
  503. package/lib/sketch/preset-check.js +42 -17
  504. package/lib/sketch/quality.d.ts +69 -11
  505. package/lib/sketch/quality.js +54 -13
  506. package/lib/sketch/runner.d.ts +80 -9
  507. package/lib/sketch/runner.js +390 -52
  508. package/lib/sketch/ui.d.ts +5 -8
  509. package/lib/sketch/ui.js +4 -2
  510. package/lib/stats.d.ts +1 -0
  511. package/lib/workers/probe-worker.d.ts +5 -0
  512. package/lib/workers/probe-worker.js +13 -4
  513. package/lib/workers/protocol.d.ts +71 -13
  514. package/lib/workers/protocol.js +4 -0
  515. package/lib/workers/render-worker.js +29 -5
  516. package/lib/workers/sketch-worker.js +108 -16
  517. package/package.json +2 -2
@@ -0,0 +1,130 @@
1
+ // The engine's rule for a mesh's levels of detail, as a sketch reads it: the distance at which one
2
+ // of a part's levels switches in, the distances at which a view measures a part's bounds, and the
3
+ // level that a distance picks. The core picks the level of every source that a frame draws by this
4
+ // rule (`crates/null3d-core/src/levels.rs`), so a scene that budgets its triangles asks the same
5
+ // rule instead of copying it. A copy is a shadow of the core and drifts from it as soon as the
6
+ // core's figures change.
7
+ //
8
+ // A level's switch measure is its error, a hand-set distance, or the share of the render's height
9
+ // that the bounds cover. An error is the largest distance between the level's surface and the base
10
+ // mesh's, in the units of the base mesh's positions. The switch distance follows:
11
+ //
12
+ // ```text
13
+ // error: error × scale × factor / bias
14
+ // distance: distance × scale / bias
15
+ // coverage: radius × P[1][1] / (coverage × bias)
16
+ // ```
17
+ //
18
+ // `scale` is the largest axis scale of the source's world matrix and `factor` is the render height
19
+ // in pixels times the projection's `P[1][1]`, over twice the threshold in pixels. A level given by
20
+ // its error is compared with a distance halfway into the bounds, so a large mesh keeps its fine
21
+ // levels until its near side shows them; a level given by a distance or by a coverage, and a
22
+ // distance band, compare the distance to the bounds' nearest point.
23
+ /**
24
+ * The smallest distance that the rule measures, in meters: a camera inside the bounds reads it.
25
+ *
26
+ * @category api/geometry
27
+ */
28
+ export const LEAST_LEVEL_DISTANCE = 1e-3;
29
+ /** The share of the bounds' radius that an error's distance takes off the distance to the center. */
30
+ const ERROR_RADIUS_SHARE = 0.5;
31
+ /** The multiple of the distance to the nearest point that caps an error's distance. */
32
+ const ERROR_NEAREST_SHARE = 2;
33
+ /** The projection's `P[1][1]` for a perspective view of `fov` degrees, which a coverage reads. */
34
+ function projection(fov) {
35
+ return Math.abs(1 / Math.tan((fov * Math.PI) / 360));
36
+ }
37
+ /** The factor that turns a level's error into a switch distance: height × `P[1][1]` / (2 × threshold). */
38
+ function factor(view) {
39
+ const threshold = view.threshold ?? 1;
40
+ return threshold > 0 && view.height > 0
41
+ ? (view.height * projection(view.fov)) / (2 * threshold)
42
+ : 0;
43
+ }
44
+ /** The source's threshold bias, and 1 for a bias that is not above 0. */
45
+ function bias(view) {
46
+ const value = view.bias ?? 1;
47
+ return value > 0 ? value : 1;
48
+ }
49
+ /** The distance at which a level switches in, given the view's factor and bias. */
50
+ function switchDistance(view, levelFactor, level, scale, radius) {
51
+ if ('error' in level)
52
+ return (level.error * scale * levelFactor) / bias(view);
53
+ if ('distance' in level)
54
+ return (level.distance * scale) / bias(view);
55
+ const p11 = projection(view.fov);
56
+ return level.coverage > 0 && p11 > 0
57
+ ? (radius * p11) / (level.coverage * bias(view))
58
+ : Number.POSITIVE_INFINITY;
59
+ }
60
+ /**
61
+ * The distance at which one of a part's levels switches in.
62
+ *
63
+ * An error switches where it covers the view's threshold in pixels; a distance at its own figure,
64
+ * scaled by the source; and a coverage where the bounds' radius covers that share of the render
65
+ * height. A bias above 1 divides every result, so the level switches nearer.
66
+ *
67
+ * @param view The view that measures the level.
68
+ * @param level The level's switch measure.
69
+ * @param scale The largest axis scale of the source's world matrix.
70
+ * @param radius The radius of the source's world bounds, in meters, which a coverage reads.
71
+ * @returns The distance in meters at which the level draws, or `Infinity` for a coverage that is
72
+ * not above 0.
73
+ * @category api/geometry
74
+ */
75
+ export function levelSwitchDistance(view, level, scale, radius = 0) {
76
+ return switchDistance(view, factor(view), level, scale, radius);
77
+ }
78
+ /**
79
+ * Both distances that a view's rule compares for a source's bounds. An error measures to a point
80
+ * halfway into the sphere, capped at twice the distance to its nearest point, so a camera beside a
81
+ * large mesh measures the surface below it. A distance or a coverage, and a distance band, measure
82
+ * to the nearest point. Both are at least `LEAST_LEVEL_DISTANCE`. An orthographic view compares an
83
+ * error at a distance of 1, since its pixels do not shrink with distance, and keeps the nearest
84
+ * point for the other measures.
85
+ *
86
+ * @param view The view that measures the source.
87
+ * @param bounds The source's bounds, with the center relative to the camera.
88
+ * @returns The two distances, in meters.
89
+ * @category api/geometry
90
+ */
91
+ export function levelDistances(view, bounds) {
92
+ const [x, y, z] = bounds.centre;
93
+ const length = Math.hypot(x, y, z);
94
+ const nearest = (radius) => Math.max(length - radius, LEAST_LEVEL_DISTANCE);
95
+ const camera = nearest(bounds.radius);
96
+ const error = view.orthographic
97
+ ? 1
98
+ : Math.min(nearest(ERROR_RADIUS_SHARE * bounds.radius), ERROR_NEAREST_SHARE * nearest(bounds.radius));
99
+ return { camera, error };
100
+ }
101
+ /**
102
+ * The level of detail that a source draws: 0 for the base mesh, 1 for the first lower level, and so
103
+ * on, as `setLevels` takes them. The level is the last one whose switch distance lies under the
104
+ * distance, which is how the core's culling picks every source. This gives the level alone, not
105
+ * whether the source draws at all: a bound that covers fewer pixels than the threshold is hidden,
106
+ * and a draw range hides a source outside it.
107
+ *
108
+ * @param view The view that measures the levels.
109
+ * @param levels The lower levels, from the finest to the coarsest.
110
+ * @param scale The largest axis scale of the source's world matrix.
111
+ * @param radius The radius of the source's world bounds, in meters, which a coverage reads.
112
+ * @param distance A distance, which both measures read as a camera does, or the two distances that
113
+ * `levelDistances` gives.
114
+ * @returns The level's index among the base mesh and `levels`.
115
+ * @category api/geometry
116
+ */
117
+ export function levelAt(view, levels, scale, radius, distance) {
118
+ const levelFactor = factor(view);
119
+ if (!(levelFactor > 0) || levels.length === 0)
120
+ return 0;
121
+ const at = typeof distance === 'number' ? { camera: distance, error: distance } : distance;
122
+ let level = 0;
123
+ for (const measure of levels) {
124
+ const compare = 'error' in measure ? at.error : at.camera;
125
+ if (!(switchDistance(view, levelFactor, measure, scale, radius) < compare))
126
+ break;
127
+ level++;
128
+ }
129
+ return level;
130
+ }
@@ -3,17 +3,16 @@ import type { ObjectEventHandler, ObjectEventType, PointerRows } from './pointer
3
3
  import type { Blending, Geometry, MaterialFeatures, MaterialOptions, Materials, MeshGeometry, StandardValues } from './resources.js';
4
4
  import type { Vec3 } from './scene.js';
5
5
  /**
6
- * Which points each segment joins. With `segments`, each pair of points makes a segment, like
7
- * three.js's `LineSegments`. With `strip`, every point joins the next, like `Line` and `Line2`. With
8
- * `loop`, the last point also joins the first, like `LineLoop`.
6
+ * Which points each segment joins. With `segments`, each pair of points makes a segment. With
7
+ * `strip`, every point joins the next. With `loop`, the last point also joins the first.
9
8
  *
10
9
  * @category api/lines
11
10
  */
12
11
  export type LineMode = 'segments' | 'strip' | 'loop';
13
12
  /**
14
13
  * The values of a line batch's material, which `lines.material.set` changes at any time. The dash
15
- * values act on dashed lines, as three.js's `LineMaterial` takes them. The metalness, roughness and
16
- * emissive values act on lit lines, as a standard material takes them.
14
+ * values act on dashed lines. The metalness, roughness and emissive values act on lit lines, as a
15
+ * standard material takes them.
17
16
  *
18
17
  * @category api/lines
19
18
  */
@@ -51,22 +50,19 @@ export interface LineOptions extends LineValues, Pick<MaterialFeatures, 'fog' |
51
50
  colors?: ArrayLike<number>;
52
51
  /** Which points each segment joins. The default is `strip`. */
53
52
  mode?: LineMode;
54
- /**
55
- * The width of the lines: CSS pixels, or world units with `worldUnits`. The default is 1, as
56
- * three.js's `linewidth`.
57
- */
53
+ /** The width of the lines: CSS pixels, or world units with `worldUnits`. The default is 1. */
58
54
  width?: number;
59
55
  /**
60
- * True gives the width in world units, so far lines look thinner, as three.js's `worldUnits`
61
- * does. False gives it in CSS pixels. The default is false.
56
+ * True gives the width in world units, so far lines look thinner. False gives it in CSS pixels,
57
+ * so every line keeps its width on screen. The default is false.
62
58
  */
63
59
  worldUnits?: boolean;
64
60
  /** Draws the lines as dashes, which `dashSize`, `gapSize` and the other dash values shape. */
65
61
  dashed?: boolean;
66
62
  /**
67
63
  * Lights the lines as a standard material lights a surface that faces the camera: the sun, the
68
- * point and spot lights and the ambient light shade them. False draws the color as it is, as
69
- * three.js's line materials do. The default is false.
64
+ * point and spot lights and the ambient light shade them. False draws the color as it is,
65
+ * whatever the lights. The default is false.
70
66
  */
71
67
  lit?: boolean;
72
68
  /** Every point updates and uploads every frame; a static batch updates points marked dirty only. */
@@ -79,7 +75,7 @@ export interface LineOptions extends LineValues, Pick<MaterialFeatures, 'fog' |
79
75
  * the world's origin.
80
76
  */
81
77
  origin?: Vec3;
82
- /** How the lines use their opacity. The default is `opaque`, as three.js's lines are. */
78
+ /** How the lines use their opacity. The default is `opaque`. */
83
79
  alphaMode?: 'opaque' | 'blend';
84
80
  }
85
81
  /** What a line batch's segment mesh and material are made with: the engine's objects. */
@@ -134,9 +130,9 @@ export interface LineBatchRows extends PointerRows {
134
130
  }
135
131
  /**
136
132
  * Lines of any width: segments between points, each drawn as a quad with round ends that faces the
137
- * camera, like three.js's `Line2`. Write points straight into the typed arrays, as for an instance
138
- * batch. A dynamic batch updates every segment every frame, and a static batch updates the segments
139
- * of the points you mark dirty.
133
+ * camera. Write points straight into the typed arrays, as for an instance batch. A dynamic batch
134
+ * updates every segment every frame, and a static batch updates the segments of the points you
135
+ * mark dirty.
140
136
  *
141
137
  * @category api/lines
142
138
  */
@@ -136,9 +136,9 @@ export function lineParts({ geometry, materials }, core, mesh, options, checks,
136
136
  const NO_POINTS = { positions: new Float32Array(0), colors: new Float32Array(0) };
137
137
  /**
138
138
  * Lines of any width: segments between points, each drawn as a quad with round ends that faces the
139
- * camera, like three.js's `Line2`. Write points straight into the typed arrays, as for an instance
140
- * batch. A dynamic batch updates every segment every frame, and a static batch updates the segments
141
- * of the points you mark dirty.
139
+ * camera. Write points straight into the typed arrays, as for an instance batch. A dynamic batch
140
+ * updates every segment every frame, and a static batch updates the segments of the points you
141
+ * mark dirty.
142
142
  *
143
143
  * @category api/lines
144
144
  */
@@ -30,8 +30,7 @@ export interface LutData {
30
30
  /**
31
31
  * A color grading table, which `assets.loadLut` loads from a file and `assets.lutFromData` makes
32
32
  * from numbers. It is a 3D texture that maps each color of the picture to its graded color. Give
33
- * it to `post.set({ lut })`, which applies it to every pixel after the tone mapping, as three.js's
34
- * `LUTPass` does.
33
+ * it to `post.set({ lut })`, which applies it to every pixel after the tone mapping.
35
34
  *
36
35
  * @category api/assets
37
36
  */
package/lib/scene/lut.js CHANGED
@@ -4,8 +4,7 @@
4
4
  /**
5
5
  * A color grading table, which `assets.loadLut` loads from a file and `assets.lutFromData` makes
6
6
  * from numbers. It is a 3D texture that maps each color of the picture to its graded color. Give
7
- * it to `post.set({ lut })`, which applies it to every pixel after the tone mapping, as three.js's
8
- * `LUTPass` does.
7
+ * it to `post.set({ lut })`, which applies it to every pixel after the tone mapping.
9
8
  *
10
9
  * @category api/assets
11
10
  */
@@ -198,8 +198,10 @@ export interface ParticleBufferOptions extends ParticleValues {
198
198
  /**
199
199
  * Where an emitter's particles are born, in its own space, and which way they set off. A `point`
200
200
  * emits at the emitter, along `direction`. A `sphere` emits inside a ball of `radius`, or on its
201
- * surface with `surface`, and sends particles outward. A `cone` emits on a disc of `radius` across
202
- * the emitter's +y axis. It sends particles up within `angle` radians of that axis. A `box` emits
201
+ * surface with `surface`, and sends particles outward.
202
+ *
203
+ * A `cone` emits on a disc of `radius` across the emitter's +y axis. It sends particles up within
204
+ * `angle` radians of that axis. A `box` emits
203
205
  * inside a box of `size`, centered on the emitter, along `direction`. A `disc` emits on a disc of
204
206
  * `radius` across the +y axis, along `direction`.
205
207
  *
@@ -294,7 +296,9 @@ export interface ParticleEmitterOptions {
294
296
  * particles add-on's emitters write records into it. Write a particle's record once, when it is
295
297
  * born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it
296
298
  * and changes its look as it ages, as the buffer's values say. It stops drawing the particle at
297
- * the end of its lifetime. Once per frame, write the buffer's time and the records the GPU reads
299
+ * the end of its lifetime.
300
+ *
301
+ * Once per frame, write the buffer's time and the records the GPU reads
298
302
  * into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's
299
303
  * calls allocate nothing.
300
304
  *
@@ -202,7 +202,9 @@ const NO_FLOAT64 = new Float64Array(0);
202
202
  * particles add-on's emitters write records into it. Write a particle's record once, when it is
203
203
  * born, with `write`, or write a frame's births in one call with `writeRecords`. The GPU moves it
204
204
  * and changes its look as it ages, as the buffer's values say. It stops drawing the particle at
205
- * the end of its lifetime. Once per frame, write the buffer's time and the records the GPU reads
205
+ * the end of its lifetime.
206
+ *
207
+ * Once per frame, write the buffer's time and the records the GPU reads
206
208
  * into `frame`, and call `commit`. Every call takes typed arrays and whole numbers, so a frame's
207
209
  * calls allocate nothing.
208
210
  *
@@ -14,8 +14,8 @@ export interface PickHit {
14
14
  instance: number;
15
15
  /**
16
16
  * Where on the surface the pixel landed, as the first texture coordinates of the hit triangle
17
- * blended across its three corners, as three.js's `intersection.uv`. Read `hasUv` first: the
18
- * numbers mean nothing when it is false.
17
+ * blended across its three corners. Read `hasUv` first: the numbers mean nothing when it is
18
+ * false.
19
19
  */
20
20
  uv?: Vec2Like;
21
21
  /**
@@ -40,16 +40,13 @@ export interface ObjectPointerEvent {
40
40
  readonly normal: Vec3Like;
41
41
  /** The distance from the ray's origin to the hit, in meters. */
42
42
  readonly distance: number;
43
- /**
44
- * The index of the hit triangle in its mesh, as three.js's `faceIndex`, or -1 for a sprite, a
45
- * point or a line.
46
- */
43
+ /** The index of the hit triangle in its mesh, or -1 for a sprite, a point or a line. */
47
44
  readonly triangle: number;
48
45
  /**
49
46
  * Where on the surface the ray hit, as the first texture coordinates of the hit triangle
50
- * blended across its three corners, as three.js's `intersection.uv`. Read `hasUv` first: the
51
- * numbers mean nothing when it is false. An in-world screen turns a click into a texel of its
52
- * image with these, without working out where the surface lies in space.
47
+ * blended across its three corners. Read `hasUv` first: the numbers mean nothing when it is
48
+ * false. An in-world screen turns a click into a texel of its image with these, without working
49
+ * out where the surface lies in space.
53
50
  */
54
51
  readonly uv: Vec2Like;
55
52
  /**
@@ -13,11 +13,13 @@ import { ShaderTemplates } from './shader-templates.js';
13
13
  import type { UniformValues } from './wgsl-uniforms.js';
14
14
  export type { GradingSettings, SplitToningSettings, WhiteBalanceSettings, } from './grading.js';
15
15
  /**
16
- * How the engine maps the scene's high dynamic range color to the screen. Three curves use
17
- * three.js's formulas: `AgXToneMapping` (`'agx'`), `NeutralToneMapping` (`'neutral'`) and
18
- * `ACESFilmicToneMapping` (`'aces'`). `'agx-punchy'` is AgX with Filament's punchy look, which adds
19
- * contrast and color. `'aces'` serves ports of three.js scenes that set it. The value `'none'`
20
- * clips the exposed color at 1, as `LinearToneMapping` does.
16
+ * How the engine maps the scene's high dynamic range color to the screen. The `'agx'` curve is
17
+ * AgX, the curve of Blender and Filament. The `'agx-punchy'` curve is AgX with Filament's punchy
18
+ * look, which adds contrast and color. The `'neutral'` curve is Khronos PBR Neutral, which keeps
19
+ * base colors as they are until they near white. The `'aces'` curve is a fit of the ACES filmic
20
+ * curve, which first scales the color by 1 / 0.6 and shifts the hues of bright colors.
21
+ *
22
+ * The value `'none'` clips the exposed color at 1.
21
23
  *
22
24
  * @category api/post
23
25
  */
@@ -39,9 +41,9 @@ export type ToneCurve = CompiledWgsl | `${string}toneCurve${string}`;
39
41
  export declare function exposureOfEv100(ev100: number): number;
40
42
  /**
41
43
  * How bloom's glow meets the scene's color. The `'mix'` blend moves each pixel's color toward the
42
- * glow by the intensity, which keeps the image's total light. The `'add'` blend adds the glow, as
43
- * three.js's `UnrealBloomPass` does. The `'screen'` blend screens it, as pmndrs's `BloomEffect`
44
- * does.
44
+ * glow by the intensity, which keeps the image's total light. The `'add'` blend adds the glow, so
45
+ * the image gains light. The `'screen'` blend screens it, so the glow adds less where the scene is
46
+ * already bright.
45
47
  *
46
48
  * @category api/post
47
49
  */
@@ -82,7 +84,7 @@ export interface BloomSettings {
82
84
  weights?: readonly number[];
83
85
  }
84
86
  /**
85
- * Ambient occlusion's settings, with the meanings of three.js's `GTAOPass`. A setting that a call
87
+ * Ambient occlusion's settings, for ground-truth ambient occlusion (GTAO). A setting that a call
86
88
  * leaves out keeps its value.
87
89
  *
88
90
  * @category api/post
@@ -90,7 +92,7 @@ export interface BloomSettings {
90
92
  export interface AoSettings {
91
93
  /**
92
94
  * How far from a surface the search for what hides it reaches, in world units: 0 or more, and
93
- * 0.25 by default, as `GTAOPass`'s `radius`.
95
+ * 0.25 by default.
94
96
  */
95
97
  radius?: number;
96
98
  /**
@@ -105,8 +107,7 @@ export interface AoSettings {
105
107
  */
106
108
  distanceExponent?: number;
107
109
  /**
108
- * From 0 to 1: how much less the farther steps of the search count. It is 1 by default, as
109
- * `GTAOPass`'s `distanceFallOff`.
110
+ * From 0 to 1: how much less the farther steps of the search count. It is 1 by default.
110
111
  */
111
112
  distanceFalloff?: number;
112
113
  /** The power that the occlusion is raised to: 0 or more, and 1 by default. Above 1 it darkens. */
@@ -117,33 +118,31 @@ export interface AoSettings {
117
118
  */
118
119
  samples?: number;
119
120
  /**
120
- * From 0 to 1: how much of the occlusion reaches the ambient light. It is 1 by default, as
121
- * `GTAOPass`'s `blendIntensity`.
121
+ * From 0 to 1: how much of the occlusion reaches the ambient light. It is 1 by default.
122
122
  */
123
123
  intensity?: number;
124
124
  }
125
125
  /**
126
- * Screen-space reflections' settings, with the meanings of three.js's `SSRPass`. A setting that a
127
- * call leaves out keeps its value.
126
+ * Screen-space reflections' settings. A setting that a call leaves out keeps its value.
128
127
  *
129
128
  * @category api/post
130
129
  */
131
130
  export interface SsrSettings {
132
131
  /**
133
132
  * From 0 to 1: how much of the environment's reflection the screen's reflection replaces where
134
- * a ray hits, and 1 by default, as `SSRPass`'s `opacity`. The material's Fresnel term, metalness
135
- * and specular values still weigh the reflection.
133
+ * a ray hits, and 1 by default. The material's Fresnel term, metalness and specular values
134
+ * still weigh the reflection.
136
135
  */
137
136
  intensity?: number;
138
137
  /**
139
- * How far a reflected ray travels, in world units: above 0, and 100 by default, as `SSRPass`'s
140
- * `maxDistance`. Reflections fade out over the last fifth of it.
138
+ * How far a reflected ray travels, in world units: above 0, and 100 by default. Reflections
139
+ * fade out over the last fifth of it.
141
140
  */
142
141
  maxDistance?: number;
143
142
  /**
144
- * How far behind a surface on the screen a ray may pass and still hit it, in world units: 0 or
145
- * more, and 0.5 by default, as `SSRPass`'s `thickness`. Thin objects need a small value, or
146
- * objects behind them reflect as if they were solid.
143
+ * How far behind a surface on the screen a ray may pass and still hit it, in world units. It is
144
+ * 0 or more, and 0.5 by default. Thin objects need a small value, or objects behind them
145
+ * reflect as if they were solid.
147
146
  */
148
147
  thickness?: number;
149
148
  /**
@@ -316,23 +315,22 @@ export interface PostSettings {
316
315
  /**
317
316
  * How the engine maps high dynamic range color to the screen: a built-in curve's name, or a
318
317
  * custom tone curve's WGSL. The default is `'agx-punchy'`, which keeps the hues of bright colors
319
- * on their way to white and keeps the picture's contrast. three.js uses no tone mapping by
320
- * default, so a port of a three.js scene without it sets `'none'`. A custom curve needs HDR
321
- * color, as bloom does; on a device without an HDR target the built-in curve stays.
318
+ * on their way to white and keeps the picture's contrast. A custom curve needs HDR color, as
319
+ * bloom does; on a device without an HDR target the built-in curve stays.
322
320
  */
323
321
  toneMapping?: ToneMapping | ToneCurve;
324
322
  /**
325
- * Scales the scene's color before the tone mapping, as three.js's `toneMappingExposure` does:
326
- * 2 is one stop brighter, and 0.5 one stop darker. It is 0 or more, and 1 by default. With
327
- * `ev100`, it scales the camera's exposure, as exposure compensation does.
323
+ * Scales the scene's color before the tone mapping: 2 is one stop brighter, and 0.5 one stop
324
+ * darker. It is 0 or more, and 1 by default. With `ev100`, it scales the camera's exposure, as
325
+ * exposure compensation does.
328
326
  */
329
327
  exposure?: number;
330
328
  /**
331
329
  * The camera's exposure value at ISO 100, for lights in real units: 15 suits a sunny day lit by
332
330
  * a sun of 100,000 lux, 12 an overcast day, and 7 a lit room. It scales the scene's color by
333
331
  * 1 / (1.2 × 2^ev100), as Filament and Bevy do, so each step up is one stop darker. It is a
334
- * number from -20 to 30, and `false`, the default, turns it off, which leaves three.js's
335
- * units.
332
+ * number from -20 to 30. The default, `false`, turns it off, for scenes whose lights have small
333
+ * intensities, such as a sun of 3.
336
334
  */
337
335
  ev100?: number | false;
338
336
  /**
@@ -343,21 +341,20 @@ export interface PostSettings {
343
341
  bloom?: BloomSettings | false;
344
342
  /**
345
343
  * Ambient occlusion: darkens the ambient light where nearby surfaces hide a surface from the
346
- * sky, as three.js's `GTAOPass` finds it. It darkens only the light that comes from all around,
347
- * where `GTAOPass` darkens the whole image. Settings turn it on, `{}` with the values it had,
348
- * and `false` turns it off. It is off by default, and draws only where the quality setting
349
- * `aoScale` is above 0.
344
+ * sky, found with ground-truth ambient occlusion (GTAO). It darkens only the light that comes
345
+ * from all around, so direct light keeps its strength. Settings turn it on, `{}` with the
346
+ * values it had, and `false` turns it off. It is off by default, and draws only where the
347
+ * quality setting `aoScale` is above 0.
350
348
  */
351
349
  ao?: AoSettings | false;
352
350
  /**
353
351
  * A color grading table from `assets.loadLut` or `assets.lutFromData`, which maps each pixel's
354
- * color after the tone mapping, as three.js's `LUTPass` does. `false` turns it off. It is off
355
- * by default.
352
+ * color after the tone mapping. `false` turns it off. It is off by default.
356
353
  */
357
354
  lut?: Lut | false;
358
355
  /**
359
- * The share of the table's color in each pixel, from 0 for none to 1 for all of it, as
360
- * `LUTPass`'s `intensity`. It is 1 by default.
356
+ * The share of the table's color in each pixel, from 0 for none to 1 for all of it. It is 1 by
357
+ * default.
361
358
  */
362
359
  lutIntensity?: number;
363
360
  /**
@@ -380,10 +377,9 @@ export interface PostSettings {
380
377
  outline?: OutlineSettings | false;
381
378
  /**
382
379
  * Depth of field: blurs what lies in front of and behind the focus distance, as a camera lens
383
- * does, with the near and far fields apart, as three.js's `BokehPass` intends. It runs after
384
- * the custom effects and before bloom. Settings turn it on, `{}` with the values it had, and
385
- * `false` turns it off. It is off by default, and draws only where the quality setting
386
- * `dofSamples` is above 0.
380
+ * does. The near and far fields blur apart. It runs after the custom effects and before bloom.
381
+ * Settings turn it on, `{}` with the values it had, and `false` turns it off. It is off by
382
+ * default, and draws only where the quality setting `dofSamples` is above 0.
387
383
  */
388
384
  dof?: DofSettings | false;
389
385
  /**
package/lib/scene/post.js CHANGED
@@ -15,6 +15,7 @@ import { EngineError } from '../errors/engine-error.js';
15
15
  import { reasonOf } from '../errors/message.js';
16
16
  import * as C from '../generated/core.js';
17
17
  import { hexValue, invalidColor } from '../math/hex.js';
18
+ import { importOnce } from '../shared/import-once.js';
18
19
  import { writeLinearColor } from './color.js';
19
20
  import { EffectChain } from './effects.js';
20
21
  import { Lut } from './lut.js';
@@ -911,13 +912,15 @@ function checkGrading(grading) {
911
912
  checkRange('grading.splitToning.balance', split.balance, -1, 1);
912
913
  checkRange('grading.splitToning.strength', split.strength, 0, 1);
913
914
  }
915
+ /** The full-screen feature adapter's module, shared by every call that waits for it. */
916
+ const featureEffectCode = importOnce(() => import('./feature-effects.js'));
914
917
  /**
915
918
  * The full-screen feature adapter, which loads at the first call that places a feature, so a page
916
919
  * that places none downloads none of it. Throws E1406 when its code does not download.
917
920
  */
918
921
  async function loadFeatureEffects(call) {
919
922
  try {
920
- return await import('./feature-effects.js');
923
+ return await featureEffectCode();
921
924
  }
922
925
  catch (error) {
923
926
  throw new EngineError('E1406', `the feature effect code did not download for ${call}(): ${reasonOf(error)}.`);
@@ -90,14 +90,13 @@ export declare class Prefab {
90
90
  readonly textures: readonly Texture[];
91
91
  private destroyed;
92
92
  /**
93
- * Destroys the model, like calling three.js's `dispose()` on each geometry, material and
94
- * texture of a loaded glTF scene. It frees the GPU memory and the engine data of every mesh,
95
- * material and texture that the load made, and of its skeleton and animation clips. Destroy
96
- * the copies that `scene.instantiate` and `scene.createInstances` made first, and the objects
97
- * that use one of its meshes or materials, in the same frame or before. Throws E1111 while one
98
- * still does, and E1101 for a model that is destroyed already. Materials of your own that map
99
- * one of the model's textures draw with their colors alone afterwards. Later calls that pass
100
- * the model throw E1101.
93
+ * Destroys the model. It frees the GPU memory and the engine data of every mesh, material and
94
+ * texture that the load made, and of its skeleton and animation clips. Destroy the copies that
95
+ * `scene.instantiate` and `scene.createInstances` made first, and the objects that use one of
96
+ * its meshes or materials, in the same frame or before. Throws E1111 while one still does, and
97
+ * E1101 for a model that is destroyed already. Materials of your own that map one of the
98
+ * model's textures draw with their colors alone afterwards. Later calls that pass the model
99
+ * throw E1101.
101
100
  */
102
101
  destroy(): void;
103
102
  /** The names of the model's clips, which a copy's animator plays. */
@@ -67,14 +67,13 @@ export class Prefab {
67
67
  this.properties = properties;
68
68
  }
69
69
  /**
70
- * Destroys the model, like calling three.js's `dispose()` on each geometry, material and
71
- * texture of a loaded glTF scene. It frees the GPU memory and the engine data of every mesh,
72
- * material and texture that the load made, and of its skeleton and animation clips. Destroy
73
- * the copies that `scene.instantiate` and `scene.createInstances` made first, and the objects
74
- * that use one of its meshes or materials, in the same frame or before. Throws E1111 while one
75
- * still does, and E1101 for a model that is destroyed already. Materials of your own that map
76
- * one of the model's textures draw with their colors alone afterwards. Later calls that pass
77
- * the model throw E1101.
70
+ * Destroys the model. It frees the GPU memory and the engine data of every mesh, material and
71
+ * texture that the load made, and of its skeleton and animation clips. Destroy the copies that
72
+ * `scene.instantiate` and `scene.createInstances` made first, and the objects that use one of
73
+ * its meshes or materials, in the same frame or before. Throws E1111 while one still does, and
74
+ * E1101 for a model that is destroyed already. Materials of your own that map one of the
75
+ * model's textures draw with their colors alone afterwards. Later calls that pass the model
76
+ * throw E1101.
78
77
  */
79
78
  destroy() {
80
79
  const call = 'prefab.destroy';
@@ -144,7 +144,7 @@ export declare class PropertyAnimation {
144
144
  get loop(): boolean;
145
145
  /** The rate of the animation's time: 1 plays it as made, and a negative rate plays it backward. */
146
146
  get speed(): number;
147
- /** Sets the animation's time in seconds, as three.js's `action.time` does. */
147
+ /** Sets the animation's time in seconds. */
148
148
  setTime(seconds: number): void;
149
149
  /** Starts or stops the time, without changing the value that the target holds. */
150
150
  setPaused(paused: boolean): void;
@@ -220,7 +220,7 @@ export class PropertyAnimation {
220
220
  get speed() {
221
221
  return this.rate;
222
222
  }
223
- /** Sets the animation's time in seconds, as three.js's `action.time` does. */
223
+ /** Sets the animation's time in seconds. */
224
224
  setTime(seconds) {
225
225
  this.seconds = seconds;
226
226
  }
@@ -12,8 +12,7 @@ import type { PointBatch, SpriteBatch } from './sprites.js';
12
12
  export interface QueryOptions {
13
13
  /**
14
14
  * The layers to test, as a 32-bit mask like `Object3D.setLayers` takes. A query tests an object
15
- * when their masks share a layer. The default is layer 0 alone, as for a camera and for
16
- * three.js's `Raycaster`.
15
+ * when their masks share a layer. The default is layer 0 alone, as for a camera.
17
16
  */
18
17
  layers?: number;
19
18
  }
@@ -27,14 +26,12 @@ export interface RaycastOptions extends QueryOptions {
27
26
  maxDistance?: number;
28
27
  /**
29
28
  * When set, a ray hits a point that it passes within this many meters of, whatever the point's
30
- * size, as three.js's `Raycaster.params.Points.threshold` does. By default a ray hits the
31
- * square that a point draws.
29
+ * size. By default a ray hits the square that a point draws.
32
30
  */
33
31
  pointThreshold?: number;
34
32
  /**
35
33
  * When set, a ray hits a line that it passes within this many meters of, whatever the line's
36
- * width, as three.js's `Raycaster.params.Line.threshold` does. By default a ray hits a line
37
- * within half its width.
34
+ * width. By default a ray hits a line within half its width.
38
35
  */
39
36
  lineThreshold?: number;
40
37
  }
@@ -74,16 +71,13 @@ export interface RaycastHit extends OverlapHit {
74
71
  normal: Vec3Like;
75
72
  /** The distance from the ray's origin to the hit, in meters. */
76
73
  distance: number;
77
- /**
78
- * The index of the hit triangle in its mesh, as three.js's `faceIndex`, or -1 for a sprite, a
79
- * point or a line.
80
- */
74
+ /** The index of the hit triangle in its mesh, or -1 for a sprite, a point or a line. */
81
75
  triangle: number;
82
76
  /**
83
77
  * Where on the surface the ray hit, as the first texture coordinates of the hit triangle
84
- * blended across its three corners, as three.js's `intersection.uv`. Give the hit object an
85
- * array of two numbers, as it has arrays for `point` and `normal`, and every raycast fills it.
86
- * Read `hasUv` first: the numbers mean nothing when it is false.
78
+ * blended across its three corners. Give the hit object an array of two numbers, as it has
79
+ * arrays for `point` and `normal`, and every raycast fills it. Read `hasUv` first: the numbers
80
+ * mean nothing when it is false.
87
81
  */
88
82
  uv?: Vec2Like;
89
83
  /**