@null3d/engine 0.0.0 → 0.1.0

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 (311) hide show
  1. package/README.md +109 -0
  2. package/THIRD-PARTY-NOTICES.txt +0 -1
  3. package/dist/wasm/single/null3d.js +19 -6
  4. package/dist/wasm/single/null3d_bg.wasm +0 -0
  5. package/dist/wasm/threaded/null3d.js +19 -6
  6. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  7. package/docs/api/animation.md +23 -67
  8. package/docs/api/assets.md +42 -26
  9. package/docs/api/cameras.md +8 -6
  10. package/docs/api/controls.md +46 -44
  11. package/docs/api/debug.md +13 -8
  12. package/docs/api/engine.md +17 -11
  13. package/docs/api/feature-draws.md +3 -3
  14. package/docs/api/feature-effects.md +3 -3
  15. package/docs/api/feature-instances.md +2 -2
  16. package/docs/api/features.md +14 -15
  17. package/docs/api/geometry.md +56 -75
  18. package/docs/api/grass.md +1 -1
  19. package/docs/api/impostors.md +120 -9
  20. package/docs/api/input.md +4 -11
  21. package/docs/api/lights.md +14 -38
  22. package/docs/api/lines.md +8 -25
  23. package/docs/api/materials.md +69 -70
  24. package/docs/api/math.md +6 -7
  25. package/docs/api/objects.md +13 -13
  26. package/docs/api/particles.md +2 -14
  27. package/docs/api/points.md +3 -25
  28. package/docs/api/post.md +22 -23
  29. package/docs/api/quality.md +11 -6
  30. package/docs/api/raycast.md +13 -32
  31. package/docs/api/reference/animation.md +9 -9
  32. package/docs/api/reference/assets.md +18 -18
  33. package/docs/api/reference/cameras.md +5 -2
  34. package/docs/api/reference/controls.md +75 -23
  35. package/docs/api/reference/debug.md +23 -8
  36. package/docs/api/reference/engine.md +22 -10
  37. package/docs/api/reference/geometry.md +161 -82
  38. package/docs/api/reference/grass.md +1 -1
  39. package/docs/api/reference/impostors.md +92 -1
  40. package/docs/api/reference/input.md +3 -3
  41. package/docs/api/reference/lights.md +9 -9
  42. package/docs/api/reference/lines.md +7 -7
  43. package/docs/api/reference/materials.md +48 -48
  44. package/docs/api/reference/math.md +22 -22
  45. package/docs/api/reference/objects.md +9 -9
  46. package/docs/api/reference/points.md +4 -4
  47. package/docs/api/reference/post.md +18 -18
  48. package/docs/api/reference/quality.md +7 -3
  49. package/docs/api/reference/raycast.md +6 -6
  50. package/docs/api/reference/render.md +2 -2
  51. package/docs/api/reference/scene.md +29 -26
  52. package/docs/api/reference/sketch.md +4 -0
  53. package/docs/api/reference/sound.md +203 -0
  54. package/docs/api/reference/sprites.md +5 -5
  55. package/docs/api/reference/terrain.md +2 -1
  56. package/docs/api/reference/textures.md +4 -4
  57. package/docs/api/reference/ui.md +3 -3
  58. package/docs/api/reference/vertex-draws.md +3 -3
  59. package/docs/api/reference/water.md +77 -6
  60. package/docs/api/reference/wind.md +2 -2
  61. package/docs/api/render.md +12 -10
  62. package/docs/api/scene.md +40 -29
  63. package/docs/api/sketch.md +64 -3
  64. package/docs/api/sound.md +169 -0
  65. package/docs/api/splats.md +7 -0
  66. package/docs/api/sprites.md +4 -20
  67. package/docs/api/tasks.md +2 -2
  68. package/docs/api/terrain.md +2 -14
  69. package/docs/api/textures.md +9 -9
  70. package/docs/api/ui.md +3 -15
  71. package/docs/api/water.md +198 -15
  72. package/docs/api/wind.md +5 -5
  73. package/docs/cli/null3d.md +93 -18
  74. package/docs/concepts/architecture.md +10 -10
  75. package/docs/concepts/assets.md +2 -19
  76. package/docs/concepts/backends.md +7 -5
  77. package/docs/concepts/color-management.md +15 -26
  78. package/docs/concepts/culling.md +1 -1
  79. package/docs/concepts/instances.md +5 -5
  80. package/docs/concepts/large-worlds.md +1 -1
  81. package/docs/concepts/lighting.md +50 -55
  82. package/docs/concepts/lod.md +2 -15
  83. package/docs/concepts/materials.md +16 -16
  84. package/docs/concepts/post-processing.md +7 -29
  85. package/docs/concepts/quality-preset-tables.md +53 -50
  86. package/docs/concepts/quality-presets.md +56 -27
  87. package/docs/concepts/render-graph.md +19 -14
  88. package/docs/concepts/render-layers.md +3 -17
  89. package/docs/concepts/shadows.md +10 -28
  90. package/docs/concepts/static-dynamic.md +2 -2
  91. package/docs/cookbook/index.md +1 -1
  92. package/docs/data/threejs-mapping.json +136 -102
  93. package/docs/errors/E1214.md +3 -3
  94. package/docs/errors/E1307.md +23 -0
  95. package/docs/errors/E1420.md +3 -3
  96. package/docs/errors/index.md +3 -2
  97. package/docs/getting-started/cdn.md +17 -1
  98. package/docs/getting-started/first-scene.md +1 -1
  99. package/docs/getting-started/hosting.md +50 -9
  100. package/docs/getting-started/install.md +8 -7
  101. package/docs/getting-started/network-use.md +10 -2
  102. package/docs/getting-started/project-structure.md +15 -6
  103. package/docs/getting-started/third-party-notices.md +8 -6
  104. package/docs/guides/accessibility.md +1 -1
  105. package/docs/guides/add-ons.md +3 -2
  106. package/docs/guides/agents.md +16 -5
  107. package/docs/guides/assets-pipeline.md +13 -12
  108. package/docs/guides/audio.md +109 -124
  109. package/docs/guides/car-paint.md +1 -1
  110. package/docs/guides/content-pages.md +10 -6
  111. package/docs/guides/custom-passes.md +9 -8
  112. package/docs/guides/custom-shaders.md +6 -3
  113. package/docs/guides/debugging.md +78 -4
  114. package/docs/guides/deploying.md +105 -5
  115. package/docs/guides/deterministic-simulation.md +1 -1
  116. package/docs/guides/first-use-shaders.md +4 -4
  117. package/docs/guides/loading-screens.md +78 -33
  118. package/docs/guides/multiple-views.md +41 -2
  119. package/docs/guides/performance.md +6 -3
  120. package/docs/guides/phones.md +12 -1
  121. package/docs/guides/physics.md +1 -1
  122. package/docs/guides/screens.md +7 -5
  123. package/docs/guides/start-time.md +328 -0
  124. package/docs/guides/testing.md +23 -5
  125. package/docs/guides/ui-overlays.md +3 -3
  126. package/docs/index.md +12 -8
  127. package/docs/pages.md +26 -23
  128. package/docs/porting/react-three-fiber.md +228 -5
  129. package/docs/porting/threejs-loop-and-threads.md +220 -6
  130. package/docs/porting/threejs-mapping.md +86 -84
  131. package/docs/porting/threejs-materials.md +212 -5
  132. package/docs/porting/threejs-overview.md +218 -5
  133. package/docs/porting/threejs-postprocessing.md +2 -2
  134. package/docs/porting/threejs-shaders.md +298 -5
  135. package/docs/porting/threejs-unsupported.md +82 -6
  136. package/docs/porting/verification.md +181 -5
  137. package/docs/shaders/builtins.md +1 -1
  138. package/docs/shaders/library.md +63 -39
  139. package/docs/shaders/surface-functions.md +11 -10
  140. package/docs/shaders/wgsl-rules.md +1 -1
  141. package/lib/debug/channel.d.ts +103 -0
  142. package/lib/debug/channel.js +269 -0
  143. package/lib/debug/debug.d.ts +9 -7
  144. package/lib/debug/draw.d.ts +9 -0
  145. package/lib/debug/draw.js +49 -2
  146. package/lib/debug/inspector.d.ts +60 -0
  147. package/lib/debug/inspector.js +475 -0
  148. package/lib/debug/stats-panel.d.ts +1 -1
  149. package/lib/debug/stats.d.ts +2 -3
  150. package/lib/errors/codes.js +8 -2
  151. package/lib/errors/engine-error.js +25 -10
  152. package/lib/errors/fixes.d.ts +1 -0
  153. package/lib/errors/fixes.js +3 -2
  154. package/lib/generated/core.d.ts +1 -1
  155. package/lib/generated/core.js +1 -1
  156. package/lib/gpu/early-builds.d.ts +68 -0
  157. package/lib/gpu/early-builds.js +158 -0
  158. package/lib/gpu/pipeline-name.d.ts +6 -0
  159. package/lib/gpu/pipeline-name.js +23 -0
  160. package/lib/gpu/webgl2/backend.d.ts +63 -2
  161. package/lib/gpu/webgl2/backend.js +226 -8
  162. package/lib/gpu/webgl2/programs.d.ts +18 -0
  163. package/lib/gpu/webgl2/programs.js +4 -1
  164. package/lib/gpu/webgpu/backend.d.ts +89 -2
  165. package/lib/gpu/webgpu/backend.js +255 -8
  166. package/lib/gpu/webgpu/pipelines.d.ts +13 -0
  167. package/lib/gpu/webgpu/pipelines.js +15 -1
  168. package/lib/index.d.ts +6 -4
  169. package/lib/index.js +3 -2
  170. package/lib/math/color.d.ts +5 -5
  171. package/lib/math/color.js +5 -5
  172. package/lib/math/mat4.d.ts +6 -12
  173. package/lib/math/mat4.js +6 -12
  174. package/lib/math/namespaces/quat.d.ts +3 -3
  175. package/lib/math/namespaces/quat.js +3 -3
  176. package/lib/math/quat.d.ts +8 -12
  177. package/lib/math/quat.js +8 -12
  178. package/lib/math/random.d.ts +2 -3
  179. package/lib/math/random.js +2 -3
  180. package/lib/math/types.d.ts +4 -4
  181. package/lib/math/vec3.d.ts +3 -6
  182. package/lib/math/vec3.js +3 -6
  183. package/lib/page/capabilities.d.ts +7 -7
  184. package/lib/page/capabilities.js +39 -25
  185. package/lib/page/check-store.d.ts +14 -2
  186. package/lib/page/check-store.js +34 -11
  187. package/lib/page/engine.d.ts +103 -26
  188. package/lib/page/engine.js +420 -97
  189. package/lib/page/first-frame.d.ts +16 -0
  190. package/lib/page/first-frame.js +35 -0
  191. package/lib/page/frame-stats.d.ts +34 -1
  192. package/lib/page/frame-stats.js +15 -0
  193. package/lib/page/label-loop.d.ts +7 -3
  194. package/lib/page/label-loop.js +17 -10
  195. package/lib/page/labels.d.ts +3 -3
  196. package/lib/page/pipeline-store.d.ts +25 -0
  197. package/lib/page/pipeline-store.js +84 -0
  198. package/lib/page/start-marker.d.ts +4 -1
  199. package/lib/page/start-marker.js +5 -2
  200. package/lib/page/switches.d.ts +32 -2
  201. package/lib/page/switches.js +9 -1
  202. package/lib/quality/check.d.ts +24 -3
  203. package/lib/quality/check.js +21 -7
  204. package/lib/quality/chooser.d.ts +6 -0
  205. package/lib/quality/chooser.js +8 -0
  206. package/lib/quality/governor.d.ts +98 -6
  207. package/lib/quality/governor.js +250 -20
  208. package/lib/quality/preset-docs.d.ts +16 -1
  209. package/lib/quality/preset-docs.js +3 -0
  210. package/lib/quality/presets.d.ts +84 -7
  211. package/lib/quality/presets.js +94 -2
  212. package/lib/render/draw.d.ts +3 -2
  213. package/lib/render/draw.js +15 -5
  214. package/lib/render/load-draw.d.ts +7 -5
  215. package/lib/render/load-draw.js +7 -5
  216. package/lib/render/loss.d.ts +28 -10
  217. package/lib/render/loss.js +50 -22
  218. package/lib/render/recovery.d.ts +20 -0
  219. package/lib/render/recovery.js +44 -4
  220. package/lib/render/renderer.d.ts +85 -9
  221. package/lib/render/renderer.js +181 -42
  222. package/lib/render/scene-renderer.d.ts +19 -1
  223. package/lib/render/scene-renderer.js +25 -1
  224. package/lib/render/webgl2-renderers.js +8 -5
  225. package/lib/render/webgpu-renderers.js +5 -4
  226. package/lib/scene/animation.d.ts +28 -32
  227. package/lib/scene/animation.js +12 -15
  228. package/lib/scene/assets.d.ts +61 -86
  229. package/lib/scene/assets.js +103 -236
  230. package/lib/scene/background.d.ts +14 -18
  231. package/lib/scene/background.js +5 -2
  232. package/lib/scene/color.d.ts +3 -3
  233. package/lib/scene/downloads.d.ts +2 -0
  234. package/lib/scene/downloads.js +371 -0
  235. package/lib/scene/environment.d.ts +7 -7
  236. package/lib/scene/environment.js +1 -1
  237. package/lib/scene/fake-call-values.js +1 -1
  238. package/lib/scene/fog.d.ts +11 -4
  239. package/lib/scene/fog.js +8 -2
  240. package/lib/scene/frame-cameras.d.ts +19 -0
  241. package/lib/scene/frame-cameras.js +58 -0
  242. package/lib/scene/gltf.d.ts +32 -2
  243. package/lib/scene/gltf.js +78 -49
  244. package/lib/scene/grading.d.ts +2 -2
  245. package/lib/scene/grading.js +3 -3
  246. package/lib/scene/ktx2.d.ts +9 -1
  247. package/lib/scene/ktx2.js +3 -2
  248. package/lib/scene/level-rule.d.ts +120 -0
  249. package/lib/scene/level-rule.js +130 -0
  250. package/lib/scene/lines.d.ts +13 -17
  251. package/lib/scene/lines.js +3 -3
  252. package/lib/scene/lut.d.ts +1 -2
  253. package/lib/scene/lut.js +1 -2
  254. package/lib/scene/picks.d.ts +2 -2
  255. package/lib/scene/pointer-events.d.ts +4 -7
  256. package/lib/scene/post.d.ts +38 -43
  257. package/lib/scene/post.js +4 -1
  258. package/lib/scene/prefab.d.ts +7 -8
  259. package/lib/scene/prefab.js +7 -8
  260. package/lib/scene/property-animation.d.ts +1 -1
  261. package/lib/scene/property-animation.js +1 -1
  262. package/lib/scene/queries.d.ts +7 -13
  263. package/lib/scene/resources.d.ts +225 -254
  264. package/lib/scene/resources.js +179 -81
  265. package/lib/scene/scene.d.ts +149 -118
  266. package/lib/scene/scene.js +196 -98
  267. package/lib/scene/serial-loads.d.ts +29 -0
  268. package/lib/scene/serial-loads.js +68 -0
  269. package/lib/scene/shader-preloads.d.ts +34 -0
  270. package/lib/scene/shader-preloads.js +38 -0
  271. package/lib/scene/sprites.d.ts +14 -17
  272. package/lib/scene/sprites.js +5 -6
  273. package/lib/scene/textures.d.ts +11 -12
  274. package/lib/scene/textures.js +9 -10
  275. package/lib/scene/time-of-day.d.ts +3 -4
  276. package/lib/scene/time-of-day.js +2 -3
  277. package/lib/scene/vertex-draws.d.ts +5 -4
  278. package/lib/scene/vertex-draws.js +7 -5
  279. package/lib/shader-artifact.json +1 -0
  280. package/lib/shared/core.d.ts +5 -0
  281. package/lib/shared/core.js +1 -0
  282. package/lib/shared/import-once.d.ts +6 -0
  283. package/lib/shared/import-once.js +19 -0
  284. package/lib/shared/metrics.d.ts +38 -0
  285. package/lib/shared/metrics.js +62 -1
  286. package/lib/shared/run-task.js +7 -1
  287. package/lib/shared/task-pending.d.ts +12 -0
  288. package/lib/shared/task-pending.js +61 -1
  289. package/lib/shared/tasks.js +79 -32
  290. package/lib/shared/version.d.ts +17 -1
  291. package/lib/shared/version.js +19 -1
  292. package/lib/shared/wasm.d.ts +12 -4
  293. package/lib/shared/wasm.js +50 -27
  294. package/lib/shared/worker-start.d.ts +7 -0
  295. package/lib/shared/worker-start.js +27 -0
  296. package/lib/sketch/define-sketch.d.ts +35 -0
  297. package/lib/sketch/input.d.ts +2 -2
  298. package/lib/sketch/preset-check.d.ts +20 -6
  299. package/lib/sketch/preset-check.js +42 -17
  300. package/lib/sketch/quality.d.ts +69 -11
  301. package/lib/sketch/quality.js +54 -13
  302. package/lib/sketch/runner.d.ts +76 -9
  303. package/lib/sketch/runner.js +385 -52
  304. package/lib/sketch/ui.d.ts +5 -8
  305. package/lib/workers/probe-worker.d.ts +5 -0
  306. package/lib/workers/probe-worker.js +13 -4
  307. package/lib/workers/protocol.d.ts +61 -13
  308. package/lib/workers/protocol.js +4 -0
  309. package/lib/workers/render-worker.js +25 -4
  310. package/lib/workers/sketch-worker.js +104 -15
  311. package/package.json +2 -2
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
  */
@@ -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,12 @@ 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. The value
21
+ * `'none'` clips the exposed color at 1.
21
22
  *
22
23
  * @category api/post
23
24
  */
@@ -39,9 +40,9 @@ export type ToneCurve = CompiledWgsl | `${string}toneCurve${string}`;
39
40
  export declare function exposureOfEv100(ev100: number): number;
40
41
  /**
41
42
  * 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.
43
+ * glow by the intensity, which keeps the image's total light. The `'add'` blend adds the glow, so
44
+ * the image gains light. The `'screen'` blend screens it, so the glow adds less where the scene is
45
+ * already bright.
45
46
  *
46
47
  * @category api/post
47
48
  */
@@ -82,7 +83,7 @@ export interface BloomSettings {
82
83
  weights?: readonly number[];
83
84
  }
84
85
  /**
85
- * Ambient occlusion's settings, with the meanings of three.js's `GTAOPass`. A setting that a call
86
+ * Ambient occlusion's settings, for ground-truth ambient occlusion (GTAO). A setting that a call
86
87
  * leaves out keeps its value.
87
88
  *
88
89
  * @category api/post
@@ -90,7 +91,7 @@ export interface BloomSettings {
90
91
  export interface AoSettings {
91
92
  /**
92
93
  * 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`.
94
+ * 0.25 by default.
94
95
  */
95
96
  radius?: number;
96
97
  /**
@@ -105,8 +106,7 @@ export interface AoSettings {
105
106
  */
106
107
  distanceExponent?: number;
107
108
  /**
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`.
109
+ * From 0 to 1: how much less the farther steps of the search count. It is 1 by default.
110
110
  */
111
111
  distanceFalloff?: number;
112
112
  /** The power that the occlusion is raised to: 0 or more, and 1 by default. Above 1 it darkens. */
@@ -117,33 +117,31 @@ export interface AoSettings {
117
117
  */
118
118
  samples?: number;
119
119
  /**
120
- * From 0 to 1: how much of the occlusion reaches the ambient light. It is 1 by default, as
121
- * `GTAOPass`'s `blendIntensity`.
120
+ * From 0 to 1: how much of the occlusion reaches the ambient light. It is 1 by default.
122
121
  */
123
122
  intensity?: number;
124
123
  }
125
124
  /**
126
- * Screen-space reflections' settings, with the meanings of three.js's `SSRPass`. A setting that a
127
- * call leaves out keeps its value.
125
+ * Screen-space reflections' settings. A setting that a call leaves out keeps its value.
128
126
  *
129
127
  * @category api/post
130
128
  */
131
129
  export interface SsrSettings {
132
130
  /**
133
131
  * 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.
132
+ * a ray hits, and 1 by default. The material's Fresnel term, metalness and specular values
133
+ * still weigh the reflection.
136
134
  */
137
135
  intensity?: number;
138
136
  /**
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.
137
+ * How far a reflected ray travels, in world units: above 0, and 100 by default. Reflections
138
+ * fade out over the last fifth of it.
141
139
  */
142
140
  maxDistance?: number;
143
141
  /**
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.
142
+ * How far behind a surface on the screen a ray may pass and still hit it, in world units. It is
143
+ * 0 or more, and 0.5 by default. Thin objects need a small value, or objects behind them
144
+ * reflect as if they were solid.
147
145
  */
148
146
  thickness?: number;
149
147
  /**
@@ -316,23 +314,22 @@ export interface PostSettings {
316
314
  /**
317
315
  * How the engine maps high dynamic range color to the screen: a built-in curve's name, or a
318
316
  * 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.
317
+ * on their way to white and keeps the picture's contrast. A custom curve needs HDR color, as
318
+ * bloom does; on a device without an HDR target the built-in curve stays.
322
319
  */
323
320
  toneMapping?: ToneMapping | ToneCurve;
324
321
  /**
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.
322
+ * Scales the scene's color before the tone mapping: 2 is one stop brighter, and 0.5 one stop
323
+ * darker. It is 0 or more, and 1 by default. With `ev100`, it scales the camera's exposure, as
324
+ * exposure compensation does.
328
325
  */
329
326
  exposure?: number;
330
327
  /**
331
328
  * The camera's exposure value at ISO 100, for lights in real units: 15 suits a sunny day lit by
332
329
  * a sun of 100,000 lux, 12 an overcast day, and 7 a lit room. It scales the scene's color by
333
330
  * 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.
331
+ * number from -20 to 30. The default, `false`, turns it off, for scenes whose lights have small
332
+ * intensities, such as a sun of 3.
336
333
  */
337
334
  ev100?: number | false;
338
335
  /**
@@ -343,21 +340,20 @@ export interface PostSettings {
343
340
  bloom?: BloomSettings | false;
344
341
  /**
345
342
  * 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.
343
+ * sky, found with ground-truth ambient occlusion (GTAO). It darkens only the light that comes
344
+ * from all around, so direct light keeps its strength. Settings turn it on, `{}` with the
345
+ * values it had, and `false` turns it off. It is off by default, and draws only where the
346
+ * quality setting `aoScale` is above 0.
350
347
  */
351
348
  ao?: AoSettings | false;
352
349
  /**
353
350
  * 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.
351
+ * color after the tone mapping. `false` turns it off. It is off by default.
356
352
  */
357
353
  lut?: Lut | false;
358
354
  /**
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.
355
+ * The share of the table's color in each pixel, from 0 for none to 1 for all of it. It is 1 by
356
+ * default.
361
357
  */
362
358
  lutIntensity?: number;
363
359
  /**
@@ -380,10 +376,9 @@ export interface PostSettings {
380
376
  outline?: OutlineSettings | false;
381
377
  /**
382
378
  * 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.
379
+ * does. The near and far fields blur apart. It runs after the custom effects and before bloom.
380
+ * Settings turn it on, `{}` with the values it had, and `false` turns it off. It is off by
381
+ * default, and draws only where the quality setting `dofSamples` is above 0.
387
382
  */
388
383
  dof?: DofSettings | false;
389
384
  /**
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
  /**