@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
@@ -18,11 +18,11 @@ Colors as linear RGB in plain arrays of three numbers, from hex colors, sRGB com
18
18
 
19
19
  | Member | Description |
20
20
  | --- | --- |
21
- | `srgbToLinear(c: number): number` | An sRGB component from 0 to 1 as a linear one, as three.js's `SRGBToLinear`. |
22
- | `linearToSrgb(c: number): number` | A linear component from 0 to 1 as an sRGB one, as three.js's `LinearToSRGB`. |
21
+ | `srgbToLinear(c: number): number` | An sRGB component from 0 to 1 as a linear one, by the sRGB standard's curve. |
22
+ | `linearToSrgb(c: number): number` | A linear component from 0 to 1 as an sRGB one, by the sRGB standard's curve. |
23
23
  | `fromSrgb<T extends Vec3Like>(out: T, r: number, g: number, b: number): T` | Linear RGB from three sRGB components from 0 to 1, such as a color picker gives. |
24
24
  | `fromHex<T extends Vec3Like>(out: T, hex: string \| number): T` | Linear RGB from an sRGB hex color: a string such as `'#ff8800'` or `'#f80'`, or a number such as `0xff8800`. It throws E1204 for anything else. |
25
- | `fromHsl<T extends Vec3Like>(out: T, h: number, s: number, l: number): T` | RGB from a hue, a saturation and a lightness, each from 0 to 1, as three.js's `setHSL`. Like three.js, it takes the result as linear RGB, so the same values give the same color in both engines. |
25
+ | `fromHsl<T extends Vec3Like>(out: T, h: number, s: number, l: number): T` | Linear RGB from a hue, a saturation and a lightness, each from 0 to 1. The hue wraps around, and the saturation and lightness stop at 0 and 1. It takes the result of the HSL formula as linear RGB as it is, with no sRGB conversion. |
26
26
 
27
27
  ## `createMath`
28
28
 
@@ -38,7 +38,7 @@ The math helpers that need a sine, a cosine, an arc cosine or an exponential, bu
38
38
  type EulerOrder = 'XYZ' | 'YXZ' | 'ZXY' | 'ZYX' | 'YZX' | 'XZY';
39
39
  ```
40
40
 
41
- The axis order of Euler angles, with three.js's names. `'XYZ'` turns an object about its own X axis, then its Y axis, then its Z axis.
41
+ The axis order of Euler angles. `'XYZ'` turns an object about its own X axis, then its Y axis, then its Z axis.
42
42
 
43
43
  ## `mat4`
44
44
 
@@ -51,10 +51,10 @@ Namespace `mat4`.
51
51
  | `create(): number[]` | A new identity matrix. It allocates, so create matrices once, outside per-frame code. |
52
52
  | `identity<T extends Mat4Like>(out: T): T` | Sets `out` to the identity matrix, which changes nothing. |
53
53
  | `copy<T extends Mat4Like>(out: T, a: Mat4Like): T` | Copies `a` into `out`. |
54
- | `multiply<T extends Mat4Like>(out: T, a: Mat4Like, b: Mat4Like): T` | The product of `a` and `b`, as three.js's `multiplyMatrices`. It transforms a point by `b` first, then by `a`. |
55
- | `invert<T extends Mat4Like>(out: T, a: Mat4Like): T` | The inverse of `a`, which undoes it, as three.js's `invert`. A matrix that has no inverse gives all zeros. |
56
- | `compose<T extends Mat4Like>(out: T, position: Vec3Like, rotation: QuatLike, scale: Vec3Like): T` | The matrix that scales by `scale`, then turns by the quaternion `rotation`, then moves by `position`, as three.js's `compose`. |
57
- | `decompose(position: Vec3Like, rotation: QuatLike, scale: Vec3Like, m: Mat4Like): void` | Splits the matrix `m` into the position, rotation and scale that `compose` joins, as three.js's `decompose`, and writes them into the first three arrays. A matrix that mirrors space gives a negative X scale. A matrix that flattens space gives no rotation and a scale of 1. |
54
+ | `multiply<T extends Mat4Like>(out: T, a: Mat4Like, b: Mat4Like): T` | The product of `a` and `b`. It transforms a point by `b` first, then by `a`. |
55
+ | `invert<T extends Mat4Like>(out: T, a: Mat4Like): T` | The inverse of `a`, which undoes it. A matrix that has no inverse gives all zeros. |
56
+ | `compose<T extends Mat4Like>(out: T, position: Vec3Like, rotation: QuatLike, scale: Vec3Like): T` | The matrix that scales by `scale`, then turns by the quaternion `rotation`, then moves by `position`. |
57
+ | `decompose(position: Vec3Like, rotation: QuatLike, scale: Vec3Like, m: Mat4Like): void` | Splits the matrix `m` into the position, rotation and scale that `compose` joins, and writes them into the first three arrays. A matrix that mirrors space gives a negative X scale. A matrix that flattens space gives no rotation and a scale of 1. |
58
58
 
59
59
  ## `Mat4Like`
60
60
 
@@ -62,13 +62,13 @@ Namespace `mat4`.
62
62
  type Mat4Like = { [index: number]: number; };
63
63
  ```
64
64
 
65
- A 4 by 4 matrix in an array of 16 numbers, stored column by column, as three.js and WebGPU store matrices. Elements 12, 13 and 14 hold the translation.
65
+ A 4 by 4 matrix in an array of 16 numbers, stored column by column, as WebGPU stores matrices. Elements 12, 13 and 14 hold the translation.
66
66
 
67
67
  ## `math`
68
68
 
69
69
  Namespace `math`.
70
70
 
71
- Number helpers with three.js's names, such as `math.clamp` and `math.damp`, and a random generator that a sketch can seed and that hold mode seeds.
71
+ Number helpers, such as `math.clamp` and `math.damp`, and a random generator that a sketch can seed and that hold mode seeds.
72
72
 
73
73
  | Member | Description |
74
74
  | --- | --- |
@@ -81,8 +81,8 @@ Number helpers with three.js's names, such as `math.clamp` and `math.damp`, and
81
81
  | `degToRad(degrees: number): number` | An angle in degrees as radians. |
82
82
  | `radToDeg(radians: number): number` | An angle in radians as degrees. |
83
83
  | `euclideanModulo(n: number, m: number): number` | The remainder of `n` divided by `m`, with the sign of `m`. For example, -1 modulo 3 is 2. |
84
- | `random(): number` | The next random number, from 0 up to but not including 1. Each thread has one generator, which starts from an unpredictable seed. Hold mode seeds it, so a sketch that draws its numbers from it draws the same frame on every run. The generator is mulberry32, as in three.js's `seededRandom`. |
85
- | `seed(value: number): void` | Starts `random` again from a seed, an integer. The same seed always gives the same numbers: `math.seed(s)` followed by `math.random()` gives what three.js's `seededRandom(s)` gives. |
84
+ | `random(): number` | The next random number, from 0 up to but not including 1. Each thread has one generator, which starts from an unpredictable seed. Hold mode seeds it, so a sketch that draws its numbers from it draws the same frame on every run. The generator is mulberry32. |
85
+ | `seed(value: number): void` | Starts `random` again from a seed, an integer. The same seed always gives the same numbers. |
86
86
  | `randFloat(low: number, high: number): number` | A random number from `low` up to but not including `high`. |
87
87
  | `randInt(low: number, high: number): number` | A random integer from `low` to `high`, both included. |
88
88
  | `randFloatSpread(range: number): number` | A random number from `-range / 2` to `range / 2`. |
@@ -131,20 +131,20 @@ Rotations as quaternions (x, y, z, w) in plain arrays, with angles in radians: `
131
131
  | Member | Description |
132
132
  | --- | --- |
133
133
  | `setAxisAngle<T extends QuatLike>(out: T, axis: Vec3Like, rad: number): T` | The rotation of `rad` radians about `axis`, a vector of length 1. |
134
- | `fromEuler<T extends QuatLike>(out: T, x: number, y: number, z: number, order?: EulerOrder): T` | The rotation of Euler angles in radians, applied in `order`, `'XYZ'` by default, as three.js's `setFromEuler`. gl-matrix's `fromEuler` takes degrees, but this one takes radians. |
134
+ | `fromEuler<T extends QuatLike>(out: T, x: number, y: number, z: number, order?: EulerOrder): T` | The rotation of Euler angles in radians, applied in `order`, `'XYZ'` by default. gl-matrix's `fromEuler` takes degrees, but this one takes radians. |
135
135
  | `rotateX<T extends QuatLike>(out: T, a: QuatLike, rad: number): T` | Turns the rotation `a` by `rad` radians about its own X axis. |
136
136
  | `rotateY<T extends QuatLike>(out: T, a: QuatLike, rad: number): T` | Turns the rotation `a` by `rad` radians about its own Y axis. |
137
137
  | `rotateZ<T extends QuatLike>(out: T, a: QuatLike, rad: number): T` | Turns the rotation `a` by `rad` radians about its own Z axis. |
138
- | `slerp<T extends QuatLike>(out: T, a: QuatLike, b: QuatLike, t: number): T` | The rotation a fraction `t` of the way from `a` to `b` along the shortest arc, turning at an even speed, as three.js's `slerp`. |
138
+ | `slerp<T extends QuatLike>(out: T, a: QuatLike, b: QuatLike, t: number): T` | The rotation a fraction `t` of the way from `a` to `b` along the shortest arc, turning at an even speed. |
139
139
  | `create(): [number, number, number, number]` | A new quaternion (0, 0, 0, 1), which turns nothing. It allocates, so create quaternions once, outside per-frame code. |
140
140
  | `set<T extends QuatLike>(out: T, x: number, y: number, z: number, w: number): T` | Sets the components of `out`. |
141
141
  | `copy<T extends QuatLike>(out: T, a: QuatLike): T` | Copies `a` into `out`. |
142
142
  | `identity<T extends QuatLike>(out: T): T` | Sets `out` to (0, 0, 0, 1), which turns nothing. |
143
- | `fromMat4<T extends QuatLike>(out: T, m: Mat4Like): T` | The rotation of the matrix `m`, whose upper 3 by 3 part must hold no scale, as three.js's `setFromRotationMatrix`. To read the rotation of a matrix with scale, use `mat4.decompose`. |
144
- | `lookAt<T extends QuatLike>(out: T, eye: Vec3Like, target: Vec3Like, up?: Vec3Like): T` | The rotation that turns an object at `eye` so that its +Z axis points at `target`, with its +Y axis as close to `up` as it can be, or to +Y without `up`. A mesh looks at a point this way, in null3D and in three.js. Cameras and lights look down their -Z axis instead: for them, swap `eye` and `target`. |
145
- | `rotationTo<T extends QuatLike>(out: T, a: Vec3Like, b: Vec3Like): T` | The shortest rotation that turns the direction `a` onto the direction `b`, as three.js's `setFromUnitVectors`. Both vectors must have length 1. |
146
- | `multiply<T extends QuatLike>(out: T, a: QuatLike, b: QuatLike): T` | The product of `a` and `b`, as three.js's `multiplyQuaternions`. It turns a vector by `b` first, then by `a`. |
147
- | `invert<T extends QuatLike>(out: T, a: QuatLike): T` | The rotation that undoes `a`, a quaternion of length 1, as three.js's `invert`. |
143
+ | `fromMat4<T extends QuatLike>(out: T, m: Mat4Like): T` | The rotation of the matrix `m`, whose upper 3 by 3 part must hold no scale. To read the rotation of a matrix with scale, use `mat4.decompose`. |
144
+ | `lookAt<T extends QuatLike>(out: T, eye: Vec3Like, target: Vec3Like, up?: Vec3Like): T` | The rotation that turns an object at `eye` so that its +Z axis points at `target`, with its +Y axis as close to `up` as it can be, or to +Y without `up`. A mesh's `lookAt` turns it this way. Cameras and lights look down their -Z axis instead: for them, swap `eye` and `target`. |
145
+ | `rotationTo<T extends QuatLike>(out: T, a: Vec3Like, b: Vec3Like): T` | The shortest rotation that turns the direction `a` onto the direction `b`. Both vectors must have length 1. |
146
+ | `multiply<T extends QuatLike>(out: T, a: QuatLike, b: QuatLike): T` | The product of `a` and `b`. It turns a vector by `b` first, then by `a`. |
147
+ | `invert<T extends QuatLike>(out: T, a: QuatLike): T` | The rotation that undoes `a`, a quaternion of length 1. |
148
148
  | `normalize<T extends QuatLike>(out: T, a: QuatLike): T` | Scales `a` to length 1. A zero quaternion becomes (0, 0, 0, 1). |
149
149
  | `dot(a: QuatLike, b: QuatLike): number` | The dot product of `a` and `b`. |
150
150
 
@@ -195,7 +195,7 @@ Vectors (x, y, z) in plain arrays, in the style of gl-matrix: `vec3.add(out, a,
195
195
  | `sub<T extends Vec3Like>(out: T, a: Vec3Like, b: Vec3Like): T` | Subtracts `b` from `a`. |
196
196
  | `multiply<T extends Vec3Like>(out: T, a: Vec3Like, b: Vec3Like): T` | Multiplies `a` and `b` component by component. |
197
197
  | `scale<T extends Vec3Like>(out: T, a: Vec3Like, s: number): T` | Multiplies `a` by the number `s`. |
198
- | `scaleAndAdd<T extends Vec3Like>(out: T, a: Vec3Like, b: Vec3Like, s: number): T` | Adds `b` times the number `s` to `a`, as three.js's `addScaledVector`. |
198
+ | `scaleAndAdd<T extends Vec3Like>(out: T, a: Vec3Like, b: Vec3Like, s: number): T` | Adds `b` times the number `s` to `a`. |
199
199
  | `negate<T extends Vec3Like>(out: T, a: Vec3Like): T` | Reverses the direction of `a`. |
200
200
  | `dot(a: Vec3Like, b: Vec3Like): number` | The dot product of `a` and `b`. |
201
201
  | `cross<T extends Vec3Like>(out: T, a: Vec3Like, b: Vec3Like): T` | The cross product of `a` and `b`: a vector at right angles to both. |
@@ -207,8 +207,8 @@ Vectors (x, y, z) in plain arrays, in the style of gl-matrix: `vec3.add(out, a,
207
207
  | `lerp<T extends Vec3Like>(out: T, a: Vec3Like, b: Vec3Like, t: number): T` | The point a fraction `t` of the way from `a` to `b`. |
208
208
  | `min<T extends Vec3Like>(out: T, a: Vec3Like, b: Vec3Like): T` | The smaller of `a` and `b` on each axis. |
209
209
  | `max<T extends Vec3Like>(out: T, a: Vec3Like, b: Vec3Like): T` | The larger of `a` and `b` on each axis. |
210
- | `transformQuat<T extends Vec3Like>(out: T, a: Vec3Like, q: QuatLike): T` | Turns `a` by the rotation `q`, a quaternion of length 1, as three.js's `applyQuaternion`. |
211
- | `transformMat4<T extends Vec3Like>(out: T, a: Vec3Like, m: Mat4Like): T` | Transforms the point `a` by the matrix `m`, with the perspective divide, as three.js's `applyMatrix4`. |
210
+ | `transformQuat<T extends Vec3Like>(out: T, a: Vec3Like, q: QuatLike): T` | Turns `a` by the rotation `q`, a quaternion of length 1. |
211
+ | `transformMat4<T extends Vec3Like>(out: T, a: Vec3Like, m: Mat4Like): T` | Transforms the point `a` by the matrix `m`, with the perspective divide. |
212
212
 
213
213
  ## `Vec3Helpers`
214
214
 
@@ -25,19 +25,19 @@ A drawn object: a mesh and a material.
25
25
  | Member | Description |
26
26
  | --- | --- |
27
27
  | `readonly shaderId: number` | The number that a custom material's WGSL reads as `object.id` for this mesh. No other live mesh or batch has it. Pass it to a uniform to pick out this mesh in a shader. It is 0 once the mesh is destroyed. |
28
- | `setMorphWeight(target: number \| string, weight: number): void` | Sets how far the mesh moves toward one of its morph targets, from the next frame: 0 keeps the target's shape out, 1 adds all of it, and other numbers scale it. Like setting three.js's `morphTargetInfluences[target]`. `target` is the target's number, from 0, or its name. A clip that animates the weight blends its own value with this one while it plays, as three.js's mixer does, and this one holds when no clip moves it. A WebGL2 device draws a preset's count of each mesh's largest weights (the `morphTargets` quality setting). Throws E1218 for a target that the mesh does not have, and E1203 for a weight that is not a finite number. |
28
+ | `setMorphWeight(target: number \| string, weight: number): void` | Sets how far the mesh moves toward one of its morph targets, from the next frame: 0 keeps the target's shape out, 1 adds all of it, and other numbers scale it. `target` is the target's number, from 0, or its name. A clip that animates the weight blends its own value with this one while it plays, and this one holds when no clip moves it. A WebGL2 device draws a preset's count of each mesh's largest weights (the `morphTargets` quality setting). Throws E1218 for a target that the mesh does not have, and E1203 for a weight that is not a finite number. |
29
29
  | `getMorphWeight(target: number \| string): number` | The weight of one of the mesh's morph targets, as `setMorphWeight` or the model's file set it, without what a playing clip adds. Throws E1218 for a target that the mesh does not have. |
30
30
  | `destroy(): void` | Removes the object at the next frame, and frees its morph weights. Its children become roots. |
31
31
  | `setMaterial(material: Material): void` | Changes the material from the next frame. |
32
32
  | `setMesh(mesh: MeshGeometry): void` | Changes the shape from the next frame. The mesh's bounds replace the object's, so call `setBounds` again after this when the object needs bounds of its own. |
33
- | `setCastShadows(cast: boolean): void` | Makes the mesh cast the shadows of a directional light, or stop. The default is false. A change rebuilds the engine's tables of what it draws, as a new material does. |
33
+ | `setCastShadows(cast: boolean): void` | Makes the mesh cast the shadows of the lights that cast them, or stop. The default is false. A change rebuilds the engine's tables of what it draws, as a new material does. |
34
34
  | `setReceiveShadows(receive: boolean): void` | Makes shadows fall on the mesh, or stop. The default is false. Unlit materials show no shadows. A change rebuilds the engine's tables of what it draws, as a new material does. |
35
- | `setOutlined(outlined: boolean): void` | Draws an outline around the mesh, or stops, as adding it to three.js's `OutlinePass.selectedObjects` does. The outline shows while `post.set({ outline })` turns outlines on, and every outlined mesh takes its settings. The default is false. A change rebuilds the engine's tables of what it draws, as a new material does. |
35
+ | `setOutlined(outlined: boolean): void` | Draws an outline around the mesh, or stops. The outline shows while `post.set({ outline })` turns outlines on, and every outlined mesh takes its settings. The default is false. A change rebuilds the engine's tables of what it draws, as a new material does. |
36
36
  | `setOccluder(occluder: boolean): void` | Makes the mesh block the view, or keeps it from blocking. On WebGL2, while the `softwareOcclusion` quality setting is on, the job workers draw each blocker into a small depth buffer every frame, and the engine skips every object that lies wholly behind the blockers. Only meshes marked true block there, and the meshes of a model file that the asset tool gave blockers. Mark large, solid meshes that hide much of the scene, such as buildings and walls, whose mesh has at most 4,096 triangles. A mesh that the asset tool gave a blocker draws that blocker instead, a few boxes inside the mesh, whatever the mesh's own size. A blocker's mesh must lie inside what the object draws, as the object's own mesh does. On WebGPU, while the `gpuOcclusion` setting is on, every opaque mesh may block without a mark: the GPU draws the depth of those that showed in the last frame and look large on the screen, and skips every object wholly behind them. False keeps the mesh from blocking there too. Objects that blend, cut holes with an alpha mask or use a custom material never block, whatever this says, nor do skinned ones on WebGL2. A change needs no rebuild of the engine's tables. |
37
- | `setRenderOrder(order: number): void` | Sets the order in which the mesh draws among blended objects, lower first, as three.js's `renderOrder`. Objects of one order draw farthest first. The default is 0. The engine orders opaque and masked objects itself. |
37
+ | `setRenderOrder(order: number): void` | Sets the order in which the mesh draws among blended objects, lower first. Objects of one order draw farthest first. The default is 0. The engine orders opaque and masked objects itself. |
38
38
  | `setLevelBias(bias: number): void` | Raises or lowers the threshold that picks this mesh's levels of detail, as Godot's `lod_bias` does. A bias above 1 makes every switch happen nearer, so the object draws coarser levels. A bias below 1 keeps its detail, which a hero object wants. The bias multiplies the threshold of the level switches and of the distance at which the object hides, so both move by the same factor. The default is 1. The object's mesh needs levels (`setLevels`). A change rebuilds the engine's tables of what it draws, as a new material does. Throws E1108 for a bias that is not a number above 0. |
39
39
  | `setDrawRange(start: number, end: number): void` | Sets the distances between which the mesh draws, as Godot's visibility range and Bevy's `VisibilityRange` do: nothing nearer than `start`, which is 0 for none, and nothing past `end`, which is `Infinity` for none. Each edge fades over a short band, so a mesh that fades in or out does not pop. A mesh whose bounds leave the range costs no draw at all. The default draws at every distance. The `lodFade` quality setting turns the bands off on Low. Throws E1108 for a range that is not two numbers with 0 <= start < end. |
40
- | `setFrustumCulled(culled: boolean): void` | With false, the engine draws the mesh even where its bounds are out of view, as three.js's `frustumCulled = false` does. The default is true. For vertices that a shader moves, larger bounds from `setBounds` cost less. |
40
+ | `setFrustumCulled(culled: boolean): void` | With false, the engine draws the mesh even where its bounds are out of view. The default is true. For vertices that a shader moves, larger bounds from `setBounds` cost less. |
41
41
 
42
42
  ## `Object3D`
43
43
 
@@ -52,18 +52,18 @@ A node in the scene: position, rotation and scale, a parent, visibility.
52
52
  | `setPosition(x: number, y: number, z: number): void` | Sets the position relative to the parent. |
53
53
  | `setPose(position: Vec3Like, rotation?: QuatLike): void` | Sets the position and, when `rotation` is given, the rotation (a quaternion, x y z w), each from an array of numbers. A caller that keeps a pose in arrays of its own writes it this way: passing an array crosses the call without a number, where a number passed to a setter that the browser does not inline becomes an object of its own. The controls write a camera's pose so in every frame. |
54
54
  | `setRotation(x: number, y: number, z: number, w: number): void` | Sets the rotation as a quaternion (x, y, z, w). |
55
- | `setRotationEuler(x: number, y: number, z: number, order: EulerOrder = 'XYZ'): void` | Sets the rotation from Euler angles in radians, with three.js's axis order names. |
55
+ | `setRotationEuler(x: number, y: number, z: number, order: EulerOrder = 'XYZ'): void` | Sets the rotation from Euler angles in radians, turned about the axes in `order`. |
56
56
  | `setScale(x: number, y: number, z: number): void` | Sets the scale on each axis. |
57
57
  | `lookAt(x: number, y: number, z: number): void` | Turns the object toward a point. It assumes the object's parents are not rotated. |
58
58
  | `rotateX(angle: number): void` | Turns the object by `angle` radians about its own X axis. |
59
59
  | `rotateY(angle: number): void` | Turns the object by `angle` radians about its own Y axis. |
60
60
  | `rotateZ(angle: number): void` | Turns the object by `angle` radians about its own Z axis. |
61
- | `translate(x: number, y: number, z: number): void` | Moves the object by (x, y, z) along its own axes, as three.js's `translateX`, `translateY` and `translateZ` do together. The object's rotation turns the vector, and its scale leaves it as it is, so `translate(0, 0, -1)` moves a camera 1 m forward. |
61
+ | `translate(x: number, y: number, z: number): void` | Moves the object by (x, y, z) along its own axes. The object's rotation turns the vector, and its scale leaves it as it is, so `translate(0, 0, -1)` moves a camera 1 m forward. |
62
62
  | `getPosition(out: Vec3Like): void` | Copies the position relative to the parent into `out`. |
63
63
  | `getRotation(out: QuatLike): void` | Copies the rotation relative to the parent into `out`, as a quaternion (x, y, z, w). |
64
64
  | `getWorldPosition(out: Vec3Like): void` | Copies the world position of the frame that last ran into `out`. |
65
65
  | `getWorldQuaternion(out: QuatLike): void` | Copies the world rotation of the frame that last ran into `out`, as a quaternion (x, y, z, w). It is the rotation part of the world matrix, which `mat4.decompose` splits off. |
66
- | `getWorldMatrix(out: Mat4Like): void` | Copies the world matrix of the frame that last ran into `out`: 16 numbers, column by column, as `mat4` and three.js's `matrixWorld` hold them. Its translation keeps full precision far from the origin when `out` is a plain array or a `Float64Array`. |
66
+ | `getWorldMatrix(out: Mat4Like): void` | Copies the world matrix of the frame that last ran into `out`: 16 numbers, column by column, as `mat4` holds them. Its translation keeps full precision far from the origin when `out` is a plain array or a `Float64Array`. |
67
67
  | `setParent(parent: Object3D \| null, options?: ParentOptions): void` | Moves the object under another, or to the root with null, from the next frame. By default it keeps its position, rotation and scale relative to the parent, so its place in the world changes with the new parent. With `keepWorld: true` it keeps its place in the world instead. |
68
68
  | `getParent(): Object3D \| null` | The object's parent, or null for a root object. A destroyed parent leaves the object a root object. |
69
69
  | `setVisible(visible: boolean): void` | Hides or shows the object and everything under it. |
@@ -84,7 +84,7 @@ Options for `setParent`.
84
84
 
85
85
  | Member | Description |
86
86
  | --- | --- |
87
- | `keepWorld?: boolean` | True keeps the object's place, rotation and size in the world, as three.js's `attach` does: the engine gives it the position, rotation and scale that do that under the new parent. The default, false, keeps the values relative to the parent, as three.js's `add` does. |
87
+ | `keepWorld?: boolean` | True keeps the object's place, rotation and size in the world: the engine gives it the position, rotation and scale that do that under the new parent. The default, false, keeps the values relative to the parent. |
88
88
 
89
89
  ## `Quat`
90
90
 
@@ -14,7 +14,7 @@ summary: "Every export of the Points API, from the engine's doc comments."
14
14
 
15
15
  Class `PointBatch`.
16
16
 
17
- Many points: squares that face the camera, all of one size, each with its own position and color, like three.js's `Points` with a `PointsMaterial`. Write points straight into the typed arrays, as for an instance batch. A dynamic batch updates every point every frame, and a static batch updates the points you mark dirty.
17
+ Many points: squares that face the camera, all of one size, each with its own position and color. Write points straight into the typed arrays, as for an instance batch. A dynamic batch updates every point every frame, and a static batch updates the points you mark dirty.
18
18
 
19
19
  | Member | Description |
20
20
  | --- | --- |
@@ -34,19 +34,19 @@ Many points: squares that face the camera, all of one size, each with its own po
34
34
 
35
35
  Interface `PointOptions`, which extends `PointValues`, `Omit`.
36
36
 
37
- Options of `scene.createPoints`. The look of the points takes the options of an unlit material. Points are opaque by default, as three.js's `PointsMaterial` is.
37
+ Options of `scene.createPoints`. The look of the points takes the options of an unlit material. Points are opaque by default.
38
38
 
39
39
  | Member | Description |
40
40
  | --- | --- |
41
41
  | `positions: ArrayLike<number>` | The points: 3 numbers each. Their number is the batch's capacity, which never changes, and `points.positions` holds them after the call. |
42
42
  | `colors?: ArrayLike<number>` | Linear colors that multiply `color`: 3 numbers per point (RGB), or 4 (RGBA). The default is white. |
43
43
  | `size?: number` | The width and height of every point: world units, or CSS pixels without size attenuation. The default is 1. |
44
- | `sizeAttenuation?: boolean` | True gives the size in world units, so far points look smaller. False gives it in CSS pixels, so every point keeps its size on screen, as three.js's `sizeAttenuation: false` does. The default is true. |
44
+ | `sizeAttenuation?: boolean` | True gives the size in world units, so far points look smaller. False gives it in CSS pixels, so every point keeps its size on screen. The default is true. |
45
45
  | `map?: Texture` | A color map, in sRGB, that each point shows whole and upright, and whose color multiplies the point's. It is fixed when the batch is created. |
46
46
  | `dynamic?: boolean` | Every point updates and uploads every frame; a static batch updates points marked dirty only. |
47
47
  | `layers?: number` | The layers every point is on, as a 32-bit mask. The default, 1, is layer 0. |
48
48
  | `origin?: Vec3` | The point that every point's position is relative to, as an instance batch's `origin`. The default is (0, 0, 0). Points near it keep the precision of 32-bit floats at any distance from the world's origin. |
49
- | `alphaMode?: MaterialFeatures['alphaMode']` | How the points use their alpha. The default is `opaque`, as three.js's points are. |
49
+ | `alphaMode?: MaterialFeatures['alphaMode']` | How the points use their alpha. The default is `opaque`. |
50
50
 
51
51
  ## `PointValues`
52
52
 
@@ -14,17 +14,17 @@ summary: "Every export of the Post-processing API API, from the engine's doc com
14
14
 
15
15
  Interface `AoSettings`.
16
16
 
17
- Ambient occlusion's settings, with the meanings of three.js's `GTAOPass`. A setting that a call leaves out keeps its value.
17
+ Ambient occlusion's settings, for ground-truth ambient occlusion (GTAO). A setting that a call leaves out keeps its value.
18
18
 
19
19
  | Member | Description |
20
20
  | --- | --- |
21
- | `radius?: number` | How far from a surface the search for what hides it reaches, in world units: 0 or more, and 0.25 by default, as `GTAOPass`'s `radius`. |
21
+ | `radius?: number` | How far from a surface the search for what hides it reaches, in world units: 0 or more, and 0.25 by default. |
22
22
  | `thickness?: number` | How far in front of a surface, along the view, an object still hides it, in world units: 0 or more, and 1 by default. Objects farther in front cast no occlusion, so a thin pole does not darken the wall far behind it. |
23
23
  | `distanceExponent?: number` | How the search's steps spread over the radius: 1 spreads them evenly, the default, and higher values gather them near the surface. It is above 0. |
24
- | `distanceFalloff?: number` | From 0 to 1: how much less the farther steps of the search count. It is 1 by default, as `GTAOPass`'s `distanceFallOff`. |
24
+ | `distanceFalloff?: number` | From 0 to 1: how much less the farther steps of the search count. It is 1 by default. |
25
25
  | `scale?: number` | The power that the occlusion is raised to: 0 or more, and 1 by default. Above 1 it darkens. |
26
26
  | `samples?: number` | The depth samples that each pixel's search reads: a whole number from 1 to 64, and 16 by default. Below 30 they spread over 3 directions, and from 30 over 5. |
27
- | `intensity?: number` | From 0 to 1: how much of the occlusion reaches the ambient light. It is 1 by default, as `GTAOPass`'s `blendIntensity`. |
27
+ | `intensity?: number` | From 0 to 1: how much of the occlusion reaches the ambient light. It is 1 by default. |
28
28
 
29
29
  ## `AutoExposureSettings`
30
30
 
@@ -49,7 +49,7 @@ Automatic exposure's settings. The engine meters the scene's brightness on the G
49
49
  type BloomBlend = 'mix' | 'add' | 'screen';
50
50
  ```
51
51
 
52
- How bloom's glow meets the scene's color. The `'mix'` blend moves each pixel's color toward the glow by the intensity, which keeps the image's total light. The `'add'` blend adds the glow, as three.js's `UnrealBloomPass` does. The `'screen'` blend screens it, as pmndrs's `BloomEffect` does.
52
+ How bloom's glow meets the scene's color. The `'mix'` blend moves each pixel's color toward the glow by the intensity, which keeps the image's total light. The `'add'` blend adds the glow, so the image gains light. The `'screen'` blend screens it, so the glow adds less where the scene is already bright.
53
53
 
54
54
  ## `BloomSettings`
55
55
 
@@ -116,7 +116,7 @@ How automatic exposure averages the scene's brightness. `'mean'` takes the weigh
116
116
 
117
117
  Interface `GradingSettings`.
118
118
 
119
- The grading controls that `post.set` takes: white balance, then lift, gamma and gain on each channel, then saturation, then split toning. A job worker bakes them into a table of 32 texels a side, which the final pass reads on every GPU path. A setting that a call leaves out keeps its value; `false` turns the grading off.
119
+ The grading controls that `post.set` takes: white balance, then saturation, then lift, gamma and gain on each channel, then split toning. A job worker bakes them into a table of 32 texels a side, which the final pass reads on every GPU path. A setting that a call leaves out keeps its value; `false` turns the grading off.
120
120
 
121
121
  | Member | Description |
122
122
  | --- | --- |
@@ -162,17 +162,17 @@ Settings for `post.set`. A setting that the call leaves out keeps its value.
162
162
 
163
163
  | Member | Description |
164
164
  | --- | --- |
165
- | `toneMapping?: ToneMapping \| ToneCurve` | How the engine maps high dynamic range color to the screen: a built-in curve's name, or a custom tone curve's WGSL. The default is `'agx-punchy'`, which keeps the hues of bright colors on their way to white and keeps the picture's contrast. three.js uses no tone mapping by default, so a port of a three.js scene without it sets `'none'`. A custom curve needs HDR color, as bloom does; on a device without an HDR target the built-in curve stays. |
166
- | `exposure?: number` | Scales the scene's color before the tone mapping, as three.js's `toneMappingExposure` does: 2 is one stop brighter, and 0.5 one stop darker. It is 0 or more, and 1 by default. With `ev100`, it scales the camera's exposure, as exposure compensation does. |
167
- | `ev100?: number \| false` | The camera's exposure value at ISO 100, for lights in real units: 15 suits a sunny day lit by a sun of 100,000 lux, 12 an overcast day, and 7 a lit room. It scales the scene's color by 1 / (1.2 × 2^ev100), as Filament and Bevy do, so each step up is one stop darker. It is a number from -20 to 30, and `false`, the default, turns it off, which leaves three.js's units. |
165
+ | `toneMapping?: ToneMapping \| ToneCurve` | How the engine maps high dynamic range color to the screen: a built-in curve's name, or a custom tone curve's WGSL. The default is `'agx-punchy'`, which keeps the hues of bright colors on their way to white and keeps the picture's contrast. A custom curve needs HDR color, as bloom does; on a device without an HDR target the built-in curve stays. |
166
+ | `exposure?: number` | Scales the scene's color before the tone mapping: 2 is one stop brighter, and 0.5 one stop darker. It is 0 or more, and 1 by default. With `ev100`, it scales the camera's exposure, as exposure compensation does. |
167
+ | `ev100?: number \| false` | The camera's exposure value at ISO 100, for lights in real units: 15 suits a sunny day lit by a sun of 100,000 lux, 12 an overcast day, and 7 a lit room. It scales the scene's color by 1 / (1.2 × 2^ev100), as Filament and Bevy do, so each step up is one stop darker. It is a number from -20 to 30. The default, `false`, turns it off, for scenes whose lights have small intensities, such as a sun of 3. |
168
168
  | `bloom?: BloomSettings \| false` | Light that spreads from the bright parts of the scene through a chain of blurred levels. Settings turn bloom on, `{}` with the values it had, and `false` turns it off. It is off by default. Its glow keeps its size as a share of the canvas at any pixel ratio and render scale. |
169
- | `ao?: AoSettings \| false` | Ambient occlusion: darkens the ambient light where nearby surfaces hide a surface from the sky, as three.js's `GTAOPass` finds it. It darkens only the light that comes from all around, where `GTAOPass` darkens the whole image. Settings turn it on, `{}` with the values it had, and `false` turns it off. It is off by default, and draws only where the quality setting `aoScale` is above 0. |
170
- | `lut?: Lut \| false` | A color grading table from `assets.loadLut` or `assets.lutFromData`, which maps each pixel's color after the tone mapping, as three.js's `LUTPass` does. `false` turns it off. It is off by default. |
171
- | `lutIntensity?: number` | The share of the table's color in each pixel, from 0 for none to 1 for all of it, as `LUTPass`'s `intensity`. It is 1 by default. |
169
+ | `ao?: AoSettings \| false` | Ambient occlusion: darkens the ambient light where nearby surfaces hide a surface from the sky, found with ground-truth ambient occlusion (GTAO). It darkens only the light that comes from all around, so direct light keeps its strength. Settings turn it on, `{}` with the values it had, and `false` turns it off. It is off by default, and draws only where the quality setting `aoScale` is above 0. |
170
+ | `lut?: Lut \| false` | A color grading table from `assets.loadLut` or `assets.lutFromData`, which maps each pixel's color after the tone mapping. `false` turns it off. It is off by default. |
171
+ | `lutIntensity?: number` | The share of the table's color in each pixel, from 0 for none to 1 for all of it. It is 1 by default. |
172
172
  | `grading?: GradingSettings \| false` | The grading controls: white balance, lift, gamma, gain, saturation and split toning, which a job worker bakes into a table of 32 texels a side. The final pass grades each pixel's display color with the table after the tone mapping, so changing a value costs no frame work. The picture shows the new grade once the worker has baked the table. Settings turn it on, `{}` with the values it had, and `false` turns it off. It is off by default. |
173
173
  | `vignette?: VignetteSettings \| false` | Darkens the picture toward its edges. Settings turn the vignette on, `{}` with the values it had, and `false` turns it off. It is off by default. |
174
174
  | `outline?: OutlineSettings \| false` | A sharp line around the objects that `setOutlined(true)` marks. Settings turn outlines on, `{}` with the values they had, and `false` turns them off. They are off by default. |
175
- | `dof?: DofSettings \| false` | Depth of field: blurs what lies in front of and behind the focus distance, as a camera lens does, with the near and far fields apart, as three.js's `BokehPass` intends. It runs after the custom effects and before bloom. Settings turn it on, `{}` with the values it had, and `false` turns it off. It is off by default, and draws only where the quality setting `dofSamples` is above 0. |
175
+ | `dof?: DofSettings \| false` | Depth of field: blurs what lies in front of and behind the focus distance, as a camera lens does. The near and far fields blur apart. It runs after the custom effects and before bloom. Settings turn it on, `{}` with the values it had, and `false` turns it off. It is off by default, and draws only where the quality setting `dofSamples` is above 0. |
176
176
  | `ssr?: SsrSettings \| false` | Screen-space reflections: shiny opaque surfaces reflect what the screen shows along their mirror direction, blurred by their roughness, in place of the environment's reflection. They fade into the environment's light where the screen holds no hit, as near its edges, so wet streets, polished floors and metal reflect the scene around them. Settings turn them on, `{}` with the values they had, and `false` turns them off. They are off by default, and draw only where the quality setting `ssrScale` is above 0. A planar reflection pass's reflection wins on its plane. |
177
177
  | `autoExposure?: AutoExposureSettings \| false` | Automatic exposure: the picture adapts to the scene's brightness over time, as an eye does, so a dark hall brightens after a sunny street. The engine meters each frame on the GPU, and the final pass multiplies the color by the adapted exposure before the tone mapping. The scene draws at the camera's `exposure` and `ev100`, and the eye adapts from there. Settings turn it on, `{}` with the values it had, and `false` turns it off. It is off by default. It needs HDR color, as bloom does. |
178
178
  | `sharpen?: number \| false` | Sharpens edges and fine detail: a share from 0 for none to 1 for the most, or `false` to turn it off. It is off by default, and 0.5 is a good start. The engine sharpens the display color after the tone mapping, so bright edges cannot gain rings the way sharpened light does. It draws at the whole canvas's render scale; below one, the upscale sharpens the image itself. See the post-processing concepts page. |
@@ -194,13 +194,13 @@ The colors that tint the shadows and the highlights, and where the split between
194
194
 
195
195
  Interface `SsrSettings`.
196
196
 
197
- Screen-space reflections' settings, with the meanings of three.js's `SSRPass`. A setting that a call leaves out keeps its value.
197
+ Screen-space reflections' settings. A setting that a call leaves out keeps its value.
198
198
 
199
199
  | Member | Description |
200
200
  | --- | --- |
201
- | `intensity?: number` | From 0 to 1: how much of the environment's reflection the screen's reflection replaces where a ray hits, and 1 by default, as `SSRPass`'s `opacity`. The material's Fresnel term, metalness and specular values still weigh the reflection. |
202
- | `maxDistance?: number` | How far a reflected ray travels, in world units: above 0, and 100 by default, as `SSRPass`'s `maxDistance`. Reflections fade out over the last fifth of it. |
203
- | `thickness?: number` | How far behind a surface on the screen a ray may pass and still hit it, in world units: 0 or more, and 0.5 by default, as `SSRPass`'s `thickness`. Thin objects need a small value, or objects behind them reflect as if they were solid. |
201
+ | `intensity?: number` | From 0 to 1: how much of the environment's reflection the screen's reflection replaces where a ray hits, and 1 by default. The material's Fresnel term, metalness and specular values still weigh the reflection. |
202
+ | `maxDistance?: number` | How far a reflected ray travels, in world units: above 0, and 100 by default. Reflections fade out over the last fifth of it. |
203
+ | `thickness?: number` | How far behind a surface on the screen a ray may pass and still hit it, in world units. It is 0 or more, and 0.5 by default. Thin objects need a small value, or objects behind them reflect as if they were solid. |
204
204
  | `maxRoughness?: number` | The roughest surface that shows screen-space reflections, from 0 to 1, and 0.5 by default. Rougher surfaces keep the environment's reflection. Reflections fade out from 70% of it, and blur more on rougher surfaces. |
205
205
 
206
206
  ## `ToneCurve`
@@ -217,7 +217,7 @@ A custom tone curve: WGSL that declares `fn toneCurve(color: vec3f) -> vec3f`, c
217
217
  type ToneMapping = 'agx' | 'agx-punchy' | 'neutral' | 'aces' | 'none';
218
218
  ```
219
219
 
220
- How the engine maps the scene's high dynamic range color to the screen. Three curves use three.js's formulas: `AgXToneMapping` (`'agx'`), `NeutralToneMapping` (`'neutral'`) and `ACESFilmicToneMapping` (`'aces'`). `'agx-punchy'` is AgX with Filament's punchy look, which adds contrast and color. `'aces'` serves ports of three.js scenes that set it. The value `'none'` clips the exposed color at 1, as `LinearToneMapping` does.
220
+ How the engine maps the scene's high dynamic range color to the screen. The `'agx'` curve is AgX, the curve of Blender and Filament. The `'agx-punchy'` curve is AgX with Filament's punchy look, which adds contrast and color. The `'neutral'` curve is Khronos PBR Neutral, which keeps base colors as they are until they near white. The `'aces'` curve is a fit of the ACES filmic curve, which first scales the color by 1 / 0.6 and shifts the hues of bright colors. The value `'none'` clips the exposed color at 1.
221
221
 
222
222
  ## `VignetteSettings`
223
223
 
@@ -49,7 +49,7 @@ What the preset check measured when the engine started, as `engine.mode.presetCh
49
49
  | `from: QualityPreset` | The preset that the engine chose from the device before the check. |
50
50
  | `targetFps: number` | The frame rate that each preset had to hold: the display's refresh rate, at most 60 or at most the page's `targetFps` option. |
51
51
  | `rounds: PresetCheckRound[]` | Each preset that the check measured, from `from` down. The last is the preset that the engine runs. |
52
- | `reused: boolean` | True when the engine took this result from an earlier start of the sketch in this browser on this device, and did not measure again. The engine stores each check's result for a week. |
52
+ | `reused: boolean` | True when the engine took this result from an earlier start of the sketch in this browser on this device, and did not measure again. The engine stores each check's result for a week. A check that went on from the rounds of an earlier start, whose check never ended, is false, and lists those rounds first. |
53
53
 
54
54
  ## `PresetCheckRound`
55
55
 
@@ -124,6 +124,7 @@ What the frame-budget governor has lowered, in `quality.governor`. It lowers a s
124
124
  | `readonly ssrScale: number` | The size of screen-space reflections' grid now: `settings.ssrScale`, or a quarter of the render size after the governor's step that follows ambient occlusion's while reflections draw. |
125
125
  | `readonly contactShadowSteps: number` | The steps of each search for the sun's contact shadows now: `settings.contactShadowSteps`, or the fewest after the governor's last step. |
126
126
  | `readonly farAnimationInterval: number` | The frames between two updates of a far character's pose now. It is `settings.farAnimationInterval`, or up to twice as long for each of the governor's last steps, at most every 4th frame. Give it to `animator.setUpdateInterval` for the characters that the camera sees from far. |
127
+ | `readonly lowest: boolean` | True while the lowest quality tier applies: the render scale's floor has fallen to a third, the sun's cast shadows and bloom are off, reflections draw at a quarter of the render size, and WebGL2 draws no depth prepass. The governor enters the tier when the scale has held at the preset's floor through its sustained window and the frames still miss. It leaves the tier when the frames keep room through the window that raises a step. |
127
128
 
128
129
  ## `QualityPreset`
129
130
 
@@ -152,7 +153,9 @@ The quality settings that a sketch reads and changes through `ctx.quality`. Each
152
153
  | `followMovingCasters: boolean` | True when a far shadow cascade draws in every frame while a dynamic object that casts shadows touches it, so moving shadows stay under their casters. False keeps each far cascade to its turns of `farCascadeInterval` frames: a moving shadow in a far cascade then trails its caster by up to that many frames less one, and the frames draw fewer shadow passes. The governor then leaves `farCascadeInterval` as set, so the trail never grows. Every preset turns it on. It changes during play. |
153
154
  | `farAnimationInterval: number` | How often a far character's pose updates: once in this many frames, from 1 to 4. Give it to `animator.setUpdateInterval` for the characters that the camera sees from far. Give 1 to the ones near it, so a crowd samples and skins less without a near character stepping. The governor raises it when frames take too long, after its shadow and effect steps and before its step of the volumetric fog. It changes during play. |
154
155
  | `shadowCascadeBlend: number` | The share of each shadow cascade's length, at its far end, over which its shadow blends into the next cascade's, from 0 to 0.5. The blend hides the line where a near cascade's sharper shadows hand over to a far cascade's softer ones. Pixels in the band read both cascades, so a wider band costs a little more. 0 hands over at once. It changes during play. |
156
+ | `castShadows: boolean` | True while the scene draws the sun's cast shadows, which a sketch gives its directional lights' `castShadows` option. Every preset starts it on. The lowest quality tier turns it off when the frames still miss with the render scale at the preset's floor. It changes during play. |
155
157
  | `bloomSize: 64 \| 128 \| 256 \| 512` | The texels on the short side of the largest level of bloom's chain: 64, 128, 256 or 512. A smaller value costs less and keeps the glow's size, with a softer core. The base never takes more than half the canvas's short side. It changes during play, which makes bloom's targets again. |
158
+ | `bloom: boolean` | True while the sketch draws bloom's glow, which it turns on through `post.set`. Every preset starts it on. The lowest quality tier turns it off when the frames still miss with the render scale at the preset's floor. It changes during play. |
156
159
  | `aoScale: 0 \| 0.25 \| 0.5` | The size of ambient occlusion's targets, as a share of the render size each way: 0.5, 0.25, or 0, which draws no ambient occlusion even when `post.set` turns it on. A smaller share costs less, with softer occlusion. It changes during play: 0.5 and 0.25 make no GPU object, and a change to or from 0 adds or removes ambient occlusion's passes. |
157
160
  | `contactShadowSteps: 0 \| 4 \| 8 \| 16` | The steps of each search for the sun's contact shadows: 4, 8 or 16, or 0, which draws none. More steps find thinner contacts and cost more. Contact shadows need a directional light that casts shadows, with a `contactDistance` above 0. They read the depth of a prepass, which they turn on where the preset leaves it off. It changes during play. |
158
161
  | `dofSamples: 0 \| 16 \| 22 \| 43 \| 71` | The taps of depth of field's gather: 16, 22, 43 or 71, or 0, which draws no depth of field even when `post.set` turns it on. More taps fill a wide blur more smoothly and cost more. It changes during play. |
@@ -169,9 +172,10 @@ The quality settings that a sketch reads and changes through `ctx.quality`. Each
169
172
  | `lodThreshold: number` | The error in pixels under which a mesh's coarser level of detail draws (see `mesh.setLevels`). Each object and instance row draws the coarsest level whose error covers fewer pixels than this on the screen, at the render scale. A larger number draws coarser levels nearer the camera, which costs less. 0 draws every mesh's base level. It takes a number from 0 to 16, and changes during play. |
170
173
  | `lodShadowThreshold: number` | The error in texels of a shadow map under which a shadow caster's coarser level of detail draws in that map. Each cascade and each spot or point light's tile picks the level in its own texels, whatever the camera's distance, so a shadow map that keeps its depth between draws stays right as the camera moves. A caster whose bounds cover fewer texels than this draws nothing in the map. A larger number draws coarser casters, which costs less. 0 draws every caster's base level. It takes a number from 0 to 16, and changes during play. |
171
174
  | `lodFade: boolean` | Whether a mesh's distance band, from `setDrawRange`, fades at each edge over a short band where a dither pattern drops a growing share of the pixels, so the mesh does not pop. False cuts each edge at once. A level of detail's own hand-over follows the level: a hand-set level fades whatever this setting, and a measured one switches at once until the governor raises the threshold above about one and a half pixels, where it fades. It changes during play. |
172
- | `physicalSky: boolean` | Whether `{ atmosphere }` backgrounds draw the physical sky from its tables. False draws three.js's analytic sky in its place, with the same sun, moon, air and clouds, matched to the physical sky's brightness, and keeps the haze on distant objects. It changes during play. |
175
+ | `physicalSky: boolean` | Whether `{ atmosphere }` backgrounds draw the physical sky from its tables. False draws the analytic `{ sky }` background in its place, with the same sun, moon, air and clouds, matched to the physical sky's brightness, and keeps the haze on distant objects. It changes during play. |
173
176
  | `cloudSteps: number` | The steps of each ray of the sky's volumetric cloud tier. Above 0 the sky draws volumetric clouds in place of the flat layer, from the same cloud settings, with this many steps along each ray; 0 draws the flat layer, as the lighter presets do. It changes during play. The noise field and the tier's shaders load at its first use. The sky's environment map marches at most 16 steps, and draws them only from a start above 0, because it picks its tier's shaders then. |
174
177
  | `governor: boolean` | Whether the frame-budget governor runs. When frames take too long, it lowers the settings one step at a time: a sketch's budget and the render scale in turn, a budget's step first, so a sketch's system scales down before the render scale reaches `minRenderScale`; once the scale is at its floor, the budgets' remaining steps come first. Then it raises `lodThreshold` up to four times while a mesh has levels of detail. Then it lowers how often far shadow cascades draw, the shadow filter, bloom's size while bloom is on, ambient occlusion's scale while it draws, the scale of screen-space reflections while they draw, the steps of contact shadows, how often far characters' poses update, and the volumetric fog's slices while it draws. It raises them again, in the reverse order, once frames have time to spare. `quality.governor` reports its steps. False keeps the render scale at `maxRenderScale` and the other settings as set, as benchmarks and captures need. It changes during play. |
178
+ | `governorLevels: boolean` | Whether the governor may raise `lodThreshold` as one of its steps, trading model detail for frames. True does, up to four doublings while a mesh has levels of detail. False leaves every model's level where its distance puts it, while the governor's other steps still run, so a model stays whole near the camera on a slow device. It changes during play. |
175
179
  | `antialias: 'none' \| 'fxaa' \| 'msaa'` | How the engine smooths the edges of what it draws: `msaa` draws 4 samples per pixel, `fxaa` smooths edges in the final pass, and `none` leaves them sharp. The mode is fixed when the engine starts: the page's `antialias` option of `createEngine` sets it, and `set` does not take it. |
176
180
  | `momentTransparency: boolean` | True to blend the camera's blended surfaces in the moment transparency layer, which needs no sort and is nearer an exact back-to-front blend than `blending: 'weighted'` is, and which draws those surfaces twice. The mode is fixed when the engine starts: the page's `momentTransparency` option of `createEngine` sets it, and `set` does not take it. |
177
181
  | `shadowCascades: number` | The cascades of a directional light's shadows, a whole number from 1 to 4, for each light whose `shadow` options name none. More cascades keep shadows sharp further from the camera, and each draws the shadow casters once more. The `shadowCascades` option of `createEngine` sets it, and `set` does not take it. |
@@ -180,7 +184,7 @@ The quality settings that a sketch reads and changes through `ctx.quality`. Each
180
184
  | `shadowTileSize: number` | Texels on each side of each tile of the shadow atlas: 256, 512, 1,024 or 2,048. Larger tiles give sharper shadows and take more memory, 4 bytes per texel. The `shadowTileSize` option of `createEngine` sets it, and `set` does not take it. |
181
185
  | `heroTileSize: number` | Texels on each side of the tile that holds a directional light's hero shadow, for each light whose `shadow` options name no `heroTileSize`: 1,024, 2,048 or 4,096. The tile is a layer of the shadow atlas, so every layer takes its size and a larger one takes more memory, 4 bytes per texel. The `heroTileSize` option of `createEngine` sets it, and `set` does not take it. |
182
186
  | `pointLightShadows: boolean` | True when point lights cast shadows. Each point light that casts them takes six tiles of the shadow atlas, one for each face of a cube around it, within `shadowTiles`. The `pointLightShadows` option of `createEngine` sets it, and `set` does not take it. |
183
- | `depthPrepass: boolean` | True when the engine draws the depth of the opaque objects before it shades them, so it shades each pixel once, for its nearest surface. Every preset turns it on for WebGL2 and off for WebGPU. The setting is fixed when the engine starts: the page's `depthPrepass` option of `createEngine` sets it, and `set` does not take it. |
187
+ | `depthPrepass: boolean` | True when the engine draws the depth of the opaque objects before it shades them, so it shades each pixel once, for its nearest surface. Every preset turns it on for WebGL2 and off for WebGPU. The page's `depthPrepass` option of `createEngine` gives its first value. It changes during play, and ambient occlusion, contact shadows, the bounce light and screen-space reflections still draw the prepass while they run, as they read its depth. |
184
188
  | `gpuOcclusion: boolean` | True when GPU occlusion culling runs on WebGPU: each camera view draws the depth of the opaque objects that showed in the last frame and look large on the screen, and skips every object that lies wholly behind them. `setOccluder(false)` keeps an object out of them. A check during play turns the extra passes off while they hide too little or make the GPU's frame longer, and on again when they pay. High and Ultra turn it on for desktops, and phones and tablets keep it off unless the page asks for it. The page's `gpuOcclusion` option of `createEngine` sets it, and `set` does not take it. It is always false on WebGL2, and when the depth prepass is on. |
185
189
  | `morphTargets: number` | The most morph target weights of each object that a WebGL2 device draws, a whole number from 1 to 256. Each object keeps the weights farthest from 0, and draws the others as 0. WebGPU draws every weight. The `morphTargets` option of `createEngine` sets it, and `set` does not take it. |
186
190
  | `softwareOcclusion: boolean` | True when software occlusion culling runs on WebGL2: each frame, the job workers draw the objects that `setOccluder(true)` marks into a small depth buffer, and the engine skips every object that lies wholly behind them. It costs the job workers time for each blocker, and saves drawing what they hide. Every preset leaves it off, and the `softwareOcclusion` option of `createEngine` turns it on. It changes during play. WebGPU ignores it. |
@@ -31,7 +31,7 @@ What a pick found: an object or the batch of a row, the row of an instance batch
31
31
  | --- | --- |
32
32
  | `object: QueryTarget` | The object or the batch of a row. |
33
33
  | `instance: number` | The row of a batch, or -1 for an object of the scene. |
34
- | `uv?: Vec2Like` | Where on the surface the pixel landed, as the first texture coordinates of the hit triangle blended across its three corners, as three.js's `intersection.uv`. Read `hasUv` first: the numbers mean nothing when it is false. |
34
+ | `uv?: Vec2Like` | Where on the surface the pixel landed, as the first texture coordinates of the hit triangle blended across its three corners. Read `hasUv` first: the numbers mean nothing when it is false. |
35
35
  | `hasUv?: boolean` | True when the picked surface has a first texture coordinate set, so `uv` holds where on the surface the pixel landed. False for a mesh that has no such coordinates, and when the ray that finds them met another source than the pick's. |
36
36
 
37
37
  ## `QueryOptions`
@@ -42,7 +42,7 @@ The options of every query.
42
42
 
43
43
  | Member | Description |
44
44
  | --- | --- |
45
- | `layers?: number` | The layers to test, as a 32-bit mask like `Object3D.setLayers` takes. A query tests an object when their masks share a layer. The default is layer 0 alone, as for a camera and for three.js's `Raycaster`. |
45
+ | `layers?: number` | The layers to test, as a 32-bit mask like `Object3D.setLayers` takes. A query tests an object when their masks share a layer. The default is layer 0 alone, as for a camera. |
46
46
 
47
47
  ## `QueryTarget`
48
48
 
@@ -77,8 +77,8 @@ A raycast's hit. Create one with `point` and `normal` arrays, and pass it to eac
77
77
  | `point: Vec3Like` | Where the ray hit, in world space. |
78
78
  | `normal: Vec3Like` | The unit normal of the hit triangle in world space, on the side that faces the ray. A hit on a sprite or a point faces the camera; on a line, or within a threshold, it points back along the ray. |
79
79
  | `distance: number` | The distance from the ray's origin to the hit, in meters. |
80
- | `triangle: number` | The index of the hit triangle in its mesh, as three.js's `faceIndex`, or -1 for a sprite, a point or a line. |
81
- | `uv?: Vec2Like` | Where on the surface the ray hit, as the first texture coordinates of the hit triangle blended across its three corners, as three.js's `intersection.uv`. Give the hit object an array of two numbers, as it has arrays for `point` and `normal`, and every raycast fills it. Read `hasUv` first: the numbers mean nothing when it is false. |
80
+ | `triangle: number` | The index of the hit triangle in its mesh, or -1 for a sprite, a point or a line. |
81
+ | `uv?: Vec2Like` | Where on the surface the ray hit, as the first texture coordinates of the hit triangle blended across its three corners. Give the hit object an array of two numbers, as it has arrays for `point` and `normal`, and every raycast fills it. Read `hasUv` first: the numbers mean nothing when it is false. |
82
82
  | `hasUv?: boolean` | True when the raycast found a triangle with a first texture coordinate set, so `uv` holds where on the surface the ray hit. False for a hit on a sprite, a point or a line, and for a mesh that has no such coordinates. Every raycast writes it. |
83
83
 
84
84
  ## `RaycastOptions`
@@ -90,5 +90,5 @@ The options of a raycast.
90
90
  | Member | Description |
91
91
  | --- | --- |
92
92
  | `maxDistance?: number` | The farthest hit, in meters from the ray's origin. The default is no limit. |
93
- | `pointThreshold?: number` | When set, a ray hits a point that it passes within this many meters of, whatever the point's size, as three.js's `Raycaster.params.Points.threshold` does. By default a ray hits the square that a point draws. |
94
- | `lineThreshold?: number` | When set, a ray hits a line that it passes within this many meters of, whatever the line's width, as three.js's `Raycaster.params.Line.threshold` does. By default a ray hits a line within half its width. |
93
+ | `pointThreshold?: number` | When set, a ray hits a point that it passes within this many meters of, whatever the point's size. By default a ray hits the square that a point draws. |
94
+ | `lineThreshold?: number` | When set, a ray hits a line that it passes within this many meters of, whatever the line's width. By default a ray hits a line within half its width. |
@@ -40,7 +40,7 @@ The format of a compute pass's storage texture. `'rgba16float'` holds HDR color,
40
40
 
41
41
  Interface `ComputePassOptions`.
42
42
 
43
- Options of `render.addPass` for a compute pass, which runs a compiled compute shader over a storage texture of its own. The texture is the description's output, which `textures.fromPass` gives to materials, effects and other passes: they sample it in the frame that the pass writes it, and the render graph orders the pass before them. A compute pass runs on WebGPU. On WebGL2 it runs its fragment form when the options give one, and the call throws otherwise. The shader declares `@group(0)
43
+ Options of `render.addPass` for a compute pass, which runs a compiled compute shader over a storage texture of its own. The texture is the description's output, which `textures.fromPass` gives to materials, effects and other passes: they sample it in the frame that the pass writes it, and the render graph orders the pass before them. A compute pass runs on WebGPU. On WebGL2 it runs its fragment form when the options give one, and the call throws otherwise. The shader declares `@group(0) @binding(0) var<uniform>` for the pass's block and `@group(0) @binding(1) var` for its storage texture, which it reads as an array of one layer, and the textures of `textures` at group 1, as a custom material's maps bind. The block holds the render size, the clock, the inverse of the camera's projection, eight vectors of `values`, and the target's size.
44
44
 
45
45
  | Member | Description |
46
46
  | --- | --- |
@@ -48,7 +48,7 @@ Options of `render.addPass` for a compute pass, which runs a compiled compute sh
48
48
  | `readonly description: FeatureDescription` | The feature description that places the pass: its frame point, its order band and order, and its single output, which names the texture that the pass writes. |
49
49
  | `readonly wgsl: Wgsl` | The compiled WGSL, whose `@compute` entry point fills the storage texture. |
50
50
  | `readonly format?: ComputeFormat` | The storage texture's format. The default is `'rgba16float'`. |
51
- | `readonly history?: boolean` | The pass keeps two states, and each run reads the state of the run before and writes the other. The texture holds the states as two ranges of layers: the first run's state, then the other's. Readers sample the state that the last run wrote by its layer, which `Texture.layer` gives once the pass is added. The shader reads the previous state from `@group(0) |
51
+ | `readonly history?: boolean` | The pass keeps two states, and each run reads the state of the run before and writes the other. The texture holds the states as two ranges of layers: the first run's state, then the other's. Readers sample the state that the last run wrote by its layer, which `Texture.layer` gives once the pass is added. The shader reads the previous state from `@group(0) @binding(2) var history: texture_2d_array<f32>;` at the layer `id.z` that it writes, and writes its own state through `@group(0) @binding(1)` at that layer. The fragment form reads the state of the run before as its input image, `input.color`. The call throws E1220 for a pass that fills an instance draw's buffers, and on WebGL2 without a fallback. |
52
52
  | `readonly layers?: number` | The array layers of each state: the texture has that many, or twice as many with `history`. A `'writes'` dispatch runs one workgroup along z for each layer, so the shader writes layer `id.z`. The default is 1. WebGL2's fragment form draws each layer in a pass of its own, up to 32, and the call throws E1220 past them. |
53
53
  | `readonly steps?: number` | The runs that a frame records, swapping the two states between them, so a 40-step pressure solve is one pass. It is 1 by default, and `render.setPassSteps` changes it. Zero runs keep the states that the frame before left. A pass without `history` runs once. |
54
54
  | `readonly workgroupSize?: ComputeWorkgroup` | The invocations along each axis of a workgroup. The default is the shader's `@workgroup_size`. Another value throws, so a pass cannot dispatch another grid. |