@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
@@ -8,7 +8,7 @@ summary: "createPoints; size attenuation; textures."
8
8
 
9
9
  # Points
10
10
 
11
- > Roadmap step 0.2, first released in null3D 0.1.0. The API is experimental, so it can still change between versions. Points do not cast or receive shadows, and overlap queries do not find them. Coding agents must not rely on either.
11
+ > Roadmap step 0.2, first released in null3D 0.1.0. The API is experimental, so it can still change between versions. Points do not cast or receive shadows, and overlap queries do not find them.
12
12
 
13
13
  ```mermaid
14
14
  flowchart LR
@@ -18,7 +18,7 @@ flowchart LR
18
18
  cull --> draw["One instanced draw<br/>of squares that face<br/>the camera"]
19
19
  ```
20
20
 
21
- A point cloud is many small squares that face the camera, all of one size, such as stars, dust, sparks or a scanned object. null3D draws each point as a square of two triangles, so points of any size draw the same on every GPU path. Each point is a row in the batch's typed arrays, with its own position and color. Sketch code writes the rows straight into engine memory, with no call per point, as it does for [instance batches](../concepts/instances.md).
21
+ A point cloud is many small squares that face the camera, all of one size, such as stars, dust, sparks or a scanned object. null3D draws each point as a square of two triangles, so points of any size draw the same on every GPU path. A point has no largest size, and it stays in view until its whole square leaves the screen. Each point is a row in the batch's typed arrays, with its own position and color. Sketch code writes the rows straight into engine memory, with no call per point, as it does for [instance batches](../concepts/instances.md).
22
22
 
23
23
  A batch is one draw for the GPU, whatever its size. Points are [sprites](sprites.md) of one size, with no rotation and no atlas. So the engine culls them, and sorts blended points back to front, as it does for sprites.
24
24
 
@@ -123,29 +123,7 @@ Raycasts hit a point where the ray crosses its square. The hit's `object` is the
123
123
 
124
124
  A batch costs about the same per point as an instance batch costs per row. The engine packs each point into the data that it keeps for an instance row. So points share the culling, sorting and drawing of instance batches. One batch of 100,000 points draws in one draw on WebGPU and WebGL2.
125
125
 
126
- Every point counts toward the device's limit of objects and instance rows, as an instance row does ([Instances and batching](../concepts/instances.md#limits)). Each point takes about 215 bytes of engine memory, so a cloud of a million points takes about 215 MB. Point batches count toward the limit of 256 instance batches.
127
-
128
- ## Compared with three.js
129
-
130
- | three.js | null3D |
131
- | --- | --- |
132
- | `new THREE.Points(geometry, new THREE.PointsMaterial({ size, color }))` | `scene.createPoints({ positions, size, color })` |
133
- | The geometry's `position` attribute | `positions` |
134
- | The geometry's `color` attribute with `vertexColors: true` | `colors` |
135
- | `material.size` with `sizeAttenuation: true` | `size` in world units: three.js's size times `tan(fov / 2)` |
136
- | `material.size` with `sizeAttenuation: false` | `size` with `sizeAttenuation: false`, in CSS pixels, as three.js gives it |
137
- | `material.map` | `map` |
138
- | `material.transparent` | `alphaMode: 'blend'` |
139
- | `material.alphaTest` | `alphaMode: 'mask'` with `alphaCutoff` |
140
-
141
- Most points look the same in both engines. These differ:
142
-
143
- - three.js's size attenuation scales a point by half the canvas's height over its depth. So its size in the world depends on the camera's field of view. A null3D size is in world units. Multiply a three.js size by `tan(fov / 2)`, with `fov` the vertical field of view, to keep the look. With an orthographic camera, three.js ignores size attenuation, so use `sizeAttenuation: false` with three.js's size.
144
- - WebGL draws a point only while its center is on the screen. So a large three.js point vanishes when its center leaves the edge. A null3D point stays until its whole square leaves the screen.
145
- - Each GPU sets a largest size for WebGL points, and the WebGL specification lets that limit be as low as 1 pixel. null3D points have no such limit. three.js's WebGPU renderer draws `Points` one pixel wide.
146
- - three.js draws the points of one cloud in their order. null3D sorts blended points back to front.
147
- - `alphaMap` has no counterpart yet.
148
- - three.js's `Raycaster` hits a point within `params.Points.threshold`, 1 meter by default, whatever its size. null3D hits each point's square, and the `pointThreshold` option gives three.js's test.
126
+ Every point counts toward the device's limit of objects and instance rows, as an instance row does ([Instances and batching](../concepts/instances.md#limits)). Each point takes about 215 bytes of engine memory, so a cloud of a million points takes about 215 MB. Point batches count toward the limit of 512 instance batches.
149
127
 
150
128
  ## API reference
151
129
 
package/docs/api/post.md CHANGED
@@ -8,7 +8,7 @@ summary: "post.set for tone mapping, exposure and a camera's EV100, automatic ex
8
8
 
9
9
  # Post-processing API
10
10
 
11
- > Roadmap step 0.1, first released in null3D 0.1.0. Step 0.2 adds automatic exposure, bloom, ambient occlusion, depth of field, outlines, color grading, the vignette, sharpening, custom effects, custom tone curves and still views. The API is experimental, so it can still change between versions.
11
+ > Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
12
12
 
13
13
  `ctx.post` holds the settings that the engine applies to the scene's color on its way to the canvas. They are the tone mapping, the exposure, automatic exposure, bloom, ambient occlusion, screen-space reflections, depth of field, outlines, a color grading table, the vignette, the sharpening and the sketch's own effects. [Color management](../concepts/color-management.md) explains how the first two fit into the frame. [The post-processing chain](../concepts/post-processing.md) explains how bloom, ambient occlusion, screen-space reflections, depth of field and sharpening do.
14
14
 
@@ -29,16 +29,16 @@ export default defineSketch(({ post }) => {
29
29
  | `exposure` | A number from 0 up. 2 is one stop brighter, and 0.5 one stop darker. | 1 |
30
30
  | `ev100` | The camera's exposure value at ISO 100, for lights in real units: a number from -20 to 30, or `false` for none | `false` |
31
31
 
32
- - The curves use three.js's formulas: `'agx'` for `AgXToneMapping`, `'neutral'` for `NeutralToneMapping` and `'aces'` for `ACESFilmicToneMapping`. `'agx-punchy'` is AgX with Filament's punchy look, which adds contrast and color. three.js has no such curve.
33
- - `'aces'` serves ports of three.js scenes that set `ACESFilmicToneMapping`. It shifts the hues of bright colors, so new scenes use AgX.
34
- - `'none'` scales the color by the exposure and clips it at white, as three.js's `LinearToneMapping` does.
35
- - three.js uses no tone mapping by default. A port of a three.js scene without tone mapping sets `toneMapping: 'none'`.
36
- - A custom tone curve is WGSL that declares `fn toneCurve(color: vec3f) -> vec3f`, compiled by the null3D Vite plugin. [Custom effects](#custom-effects) shows one. `@null3d/three-compat` gives `ReinhardToneMapping` and `CineonToneMapping` as the `reinhard` and `cineon` curves ([three.js compatibility](three-compat.md)).
32
+ - `'agx'` is AgX, the curve of Blender and Filament. `'agx-punchy'` is AgX with Filament's punchy look, which adds contrast and color.
33
+ - `'neutral'` is Khronos PBR Neutral, which keeps base colors as they are until they near white.
34
+ - `'aces'` is a fit of the ACES filmic curve. It first scales the color by 1 / 0.6, for a bright viewing place. It shifts the hues of bright colors, so new scenes use AgX.
35
+ - `'none'` scales the color by the exposure and clips it at white.
36
+ - A custom tone curve is WGSL that declares `fn toneCurve(color: vec3f) -> vec3f`, compiled by the null3D Vite plugin. [Custom effects](#custom-effects) shows one. `@null3d/three-compat` adds the `reinhard` and `cineon` curves ([its API page](three-compat.md)).
37
37
  - The settings apply to the whole scene, the background included, from the next frame on. A setting that a call leaves out keeps its value.
38
38
 
39
39
  ## Lights in real units
40
40
 
41
- Most scenes and ports keep three.js's units, which need no camera setting. Lights in real units, such as a sun of 100,000 lux, need `ev100`: the exposure value of a camera at ISO 100. The units are on the [Lights](lights.md#color-intensity-and-units) page. Typical values are 15 for a sunny day, 12 for an overcast day and 7 for a lit room. Each step up is one stop darker. The engine scales the scene by 1 / (1.2 × 2^ev100), the formula of Filament, Bevy and Unity's HDRP. The `exposure` setting then scales that, as exposure compensation does. Setting `ev100: false` turns the camera off again.
41
+ Most scenes need no camera setting: their lights have small intensities, such as a sun of 3, and the exposure stays at 1. Lights in real units, such as a sun of 100,000 lux, need `ev100`: the exposure value of a camera at ISO 100. The units are on the [Lights](lights.md#color-intensity-and-units) page. Typical values are 15 for a sunny day, 12 for an overcast day and 7 for a lit room. Each step up is one stop darker. The engine scales the scene by 1 / (1.2 × 2^ev100), the formula of Filament, Bevy and Unity's HDRP. The `exposure` setting then scales that, as exposure compensation does. Setting `ev100: false` turns the camera off again.
42
42
 
43
43
  ```ts
44
44
  import { defineSketch } from '@null3d/engine';
@@ -51,7 +51,7 @@ export default defineSketch(({ scene, post }) => {
51
51
  });
52
52
  ```
53
53
 
54
- The engine multiplies the exposure into each light, the environment's light, the background color and the fog color. The shaders multiply it into emissive light and unlit colors. The tone mapping then works on values near 1, even with a sun of 100,000 lux. Otherwise its highlights would pass the largest value of the 16-bit float scene color. The picture is the one that an exposure at the end gives. Background and unlit colors take the exposure too. At EV100 15 they draw black unless their own values are in real units, as in three.js at the same exposure.
54
+ The engine multiplies the exposure into each light, the environment's light, the background color and the fog color. The shaders multiply it into emissive light and unlit colors. The tone mapping then works on values near 1, even with a sun of 100,000 lux. Otherwise its highlights would pass the largest value of the 16-bit float scene color. The picture is the one that an exposure at the end gives. Background and unlit colors take the exposure too. At EV100 15 they draw black unless their own values are in real units.
55
55
 
56
56
  ## Changing the exposure during play
57
57
 
@@ -134,7 +134,7 @@ export default defineSketch(({ post }) => {
134
134
  | `bloom.blend` | How the glow meets the scene's color: `'mix'`, `'add'` or `'screen'`. | `'mix'` |
135
135
  | `bloom.weights` | Each level's share of the glow, from the narrowest to the widest: up to 10 numbers from 0 up, not all 0. | Shares for 8 levels |
136
136
 
137
- - `'mix'` moves each pixel's color toward the glow, so the image keeps its total light. `'add'` adds the glow, as three.js's `UnrealBloomPass` does. `'screen'` screens it, as pmndrs's `BloomEffect` does.
137
+ - `'mix'` moves each pixel's color toward the glow, so the image keeps its 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.
138
138
  - At a threshold of 0, all light glows a little. At 1, only light brighter than white glows, such as an emissive material with an `emissiveIntensity` above 1.
139
139
  - Each level spreads light twice as far as the one before. The eighth spreads it over about a quarter of the canvas's shorter side, and the tenth over all of it. The engine divides the weights by their sum. Levels past the last one with a weight cost nothing.
140
140
  - The glow keeps its size as a share of the screen at any pixel ratio, render scale and orientation. The quality setting `bloomSize` sets how many texels the chain's largest level has, which trades the glow's detail for cost.
@@ -145,7 +145,7 @@ export default defineSketch(({ post }) => {
145
145
 
146
146
  ## Ambient occlusion
147
147
 
148
- Ambient occlusion darkens the ambient light in corners, in creases and under objects, with the meanings of three.js's `GTAOPass`. It is off by default.
148
+ Ambient occlusion darkens the ambient light in corners, in creases and under objects. It uses ground-truth ambient occlusion (GTAO), and it is off by default.
149
149
 
150
150
  ```ts
151
151
  import { defineSketch } from '@null3d/engine';
@@ -168,7 +168,7 @@ export default defineSketch(({ post, quality }) => {
168
168
  | `ao.samples` | The depth samples of each pixel's search: a whole number from 1 to 64. | 16 |
169
169
  | `ao.intensity` | How much of the occlusion reaches the ambient light: a number from 0 to 1. | 1 |
170
170
 
171
- - It darkens only the ambient light and the light that light maps add. `GTAOPass` darkens the whole image, direct light included.
171
+ - It darkens only the ambient light and the light that light maps add. Direct light keeps its strength in a corner.
172
172
  - It draws where the quality setting `aoScale` is above 0: on the High and Ultra presets, or after `quality.set({ aoScale })`. On Low and Medium, the presets of phones and tablets, the scale is 0.
173
173
  - It turns the depth prepass on while it draws. On a WebGL2 device without float render targets it stays off.
174
174
  - A setting that a call leaves out keeps its value, also while it is off. `post.set({ ao: {} })` turns it on with the values it had.
@@ -264,7 +264,7 @@ export default defineSketch(({ scene, geometry, materials, post }) => {
264
264
 
265
265
  ## Outlines
266
266
 
267
- Outlines draw a crisp line around the meshes that `setOutlined(true)` marks, as three.js's `OutlinePass` draws edges around its selected objects. They are off by default.
267
+ Outlines draw a crisp line around the meshes that `setOutlined(true)` marks. They are off by default.
268
268
 
269
269
  ```ts
270
270
  import { defineSketch } from '@null3d/engine';
@@ -291,21 +291,21 @@ export default defineSketch(({ scene, geometry, materials, post }) => {
291
291
  | `outline.width` | The line's width in CSS pixels, from 0 up. | 2 |
292
292
 
293
293
  - `mesh.setOutlined(true)` marks a mesh, and `setOutlined(false)` clears it. A model's copy from `scene.instantiate` has `setOutlined` too, which marks each of its meshes. Instance batches take no outline.
294
- - One outline style covers every outlined mesh. three.js needs one `OutlinePass` for each style, and null3D draws one.
294
+ - One outline style covers every outlined mesh, and one mask pass draws them all.
295
295
  - The exposure, the tone mapping and the vignette do not change the line's colors. The color grading table still applies, and the dither moves them by up to one 8-bit step.
296
296
  - The line is as wide as `width` says on every screen and at every render scale. The engine multiplies it by the device's pixel ratio.
297
297
  - Above about 4 pixels of the canvas, a part of a mesh thinner than the line can leave a gap between itself and its line.
298
298
  - The outline covers the mesh's whole shape. It ignores the holes that an alpha cutoff cuts, and the vertices that a custom material moves.
299
299
  - A setting that a call leaves out keeps its value, also while outlines are off. `post.set` allocates nothing. So a sketch can change the outline's color or width every frame.
300
300
  - Turning outlines on or off, and `setOutlined`, rebuild the engine's draw tables, as a new material does. Do it in response to a click, not in every frame.
301
- - A full-screen pass reads the outline's mask with `input: 'outlineMask'`, for a soft glow such as `OutlinePass` draws ([Custom passes](../guides/custom-passes.md#a-soft-outline-glow)). `width: 0` draws the mask without the line.
302
- - `@null3d/three-compat`'s `createOutlinePass` draws `OutlinePass`'s soft edge, glow and pulse from this mask, through five full-screen passes and an effect ([three.js compatibility](three-compat.md)).
301
+ - A full-screen pass reads the outline's mask with `input: 'outlineMask'`, for a soft glow ([Custom passes](../guides/custom-passes.md#a-soft-outline-glow)). `width: 0` draws the mask without the line.
302
+ - `createOutlinePass` from `@null3d/three-compat` draws a soft edge, a glow and a pulse from this mask, through five full-screen passes and an effect ([its API page](three-compat.md)).
303
303
 
304
304
  [The post-processing chain](../concepts/post-processing.md#outlines) explains how outlines draw and what they cost.
305
305
 
306
306
  ## Color grading
307
307
 
308
- A color grading table maps each color of the picture to a graded color, as three.js's `LUTPass` does. Load one from a `.cube` or a `.3dl` file with [`assets.loadLut`](assets.md#color-grading-tables), or make one from numbers with [`assets.lutFromData`](assets.md#tables-from-numbers). Then give it to `post.set`:
308
+ A color grading table maps each color of the picture to a graded color. Load one from a `.cube` or a `.3dl` file with [`assets.loadLut`](assets.md#color-grading-tables), or make one from numbers with [`assets.lutFromData`](assets.md#tables-from-numbers). Then give it to `post.set`:
309
309
 
310
310
  ```ts
311
311
  import { defineSketch } from '@null3d/engine';
@@ -320,10 +320,10 @@ export default defineSketch(async ({ assets, post }) => {
320
320
  | Setting | Values | Default |
321
321
  | --- | --- | --- |
322
322
  | `lut` | A table from `assets.loadLut` or `assets.lutFromData`, or `false` to turn grading off. | Off |
323
- | `lutIntensity` | The share of the table's color in each pixel, from 0 to 1, as `LUTPass`'s `intensity`. | 1 |
323
+ | `lutIntensity` | The share of the table's color in each pixel, from 0 to 1. | 1 |
324
324
 
325
- - The table grades each pixel after the tone mapping and the sRGB encoding, as `LUTPass` does after three.js's `OutputPass`. Tables made for sRGB display color, as most are, look as their authors made them.
326
- - The final pass reads the table with a linear filter between its texel centers, as `LUTPass` does. It maps the colors of a `.cube` file's domain onto the table, which `LUTPass` leaves out.
325
+ - The table grades each pixel after the tone mapping and the sRGB encoding. Tables made for sRGB display color, as most are, look as their authors made them.
326
+ - The final pass reads the table with a linear filter between its texel centers. It maps the colors of a `.cube` file's domain onto the table.
327
327
  - The table grades the picture from the first frame after its texels reach the GPU, usually the next one.
328
328
  - `lutIntensity` keeps its value while the table is off, and `post.set` allocates nothing, so a sketch can fade a grade in every frame.
329
329
 
@@ -387,9 +387,8 @@ post.set({ vignette: { intensity: 0.8, size: 1.2 } });
387
387
  | `vignette.falloff` | How fast the light falls from the center: the power of the falloff curve, above 0. Higher values darken more of the picture. | 2 |
388
388
  | `vignette.roundness` | The shape, from 0 to 1: 0 follows the canvas's shape, an ellipse on a wide canvas, and 1 is a circle. | 0 |
389
389
 
390
- - The vignette multiplies each pixel's light before the tone mapping. [The post-processing chain](../concepts/post-processing.md#color-grading-and-the-vignette) gives the rule, the engines it follows and the difference from three.js's `VignetteShader`.
390
+ - The vignette multiplies each pixel's light before the tone mapping. [The post-processing chain](../concepts/post-processing.md#color-grading-and-the-vignette) gives the rule and the engines it follows.
391
391
  - At a distance `d` from the center, in canvas widths and heights times `size`, the light is multiplied by `1 - intensity × (1 - (1 - d²)^falloff)`, and never by less than 0.
392
- - A port of three.js's `VignetteShader` sets `size` to its `offset` and `intensity` to its `darkness`. Under ACES the default falloff gives a close match. Under AgX, a port keeps `intensity` at 1 or less and sets `falloff` to 3. With a `darkness` below 1, three.js also lifts dark corners toward the gray, and null3D does not.
393
392
  - A setting that a call leaves out keeps its value, also while the vignette is off. `post.set({ vignette: {} })` turns it on with the values it had.
394
393
 
395
394
  Grading and the vignette draw on every GPU path, with HDR color or without it. Without HDR color, the scene's shaders darken their light by the vignette before their tone mapping. A plain background color then draws as a background, so the vignette darkens it too. Each table costs the final pass a few operations per pixel and one texture read. On a device that resolves its multisampled picture straight into the canvas, the table makes the final pass run, which reads the picture once more.
@@ -470,7 +469,7 @@ A view that holds still blends its frames into a sharper picture, then stops dra
470
469
 
471
470
  | Code | Cause |
472
471
  | --- | --- |
473
- | [E1213](../errors/E1213.md) | A ninth effect. A setting that this version does not have, such as three.js's vignette `offset` and `darkness`, a tone mapping that the engine does not know, or a bloom, ambient occlusion, depth of field, automatic exposure, outline, vignette or sharpening value other than settings, a number or `false`. An automatic exposure `metering` other than `'mean'` or `'percentile'`, `percentiles` that are not two numbers from 0 to 1 with the lower first, a `centerWeight` outside 0 to 1, a speed below 0, a `minEv`, `maxEv` or `compensation` outside -20 to 20, or a `minEv` above `maxEv`. A depth of field `focusDistance`, `aperture` or `focalLength` that is not above 0, a `maxBlur` outside 0 to 0.1, `blades` other than 0 or a whole number from 3 to 12, or a `focusPoint` that is not three finite numbers or `false`. Also a `lut` that is not a table from `assets.loadLut` or `assets.lutFromData`, a `grading` value out of its range, such as a white balance outside 1667 to 25000 kelvin, a lift channel outside -1 to 1, a gamma channel of 0 or below, a negative gain or saturation, or a split toning balance outside -1 to 1 or strength outside 0 to 1, or a value out of its range. These are an exposure, bloom intensity, threshold or knee, vignette intensity or size, or outline width below 0, a vignette falloff of 0 or below or a roundness above 1, a bloom blend other than `'mix'`, `'add'` or `'screen'`, bloom weights that are not 1 to 10 numbers of 0 or more, or that are all 0, a `lutIntensity` outside 0 to 1, a sharpening strength outside 0 to 1, an ambient occlusion value below 0 or its `distanceFalloff` or `intensity` above 1, a `distanceExponent` of 0, `samples` that are not a whole number from 1 to 64, or an `ev100` outside -20 to 30. |
472
+ | [E1213](../errors/E1213.md) | A ninth effect. A setting that this version does not have, a tone mapping that the engine does not know, or a bloom, ambient occlusion, depth of field, automatic exposure, outline, vignette or sharpening value other than settings, a number or `false`, or an `ssr` value other than settings or `false`. An automatic exposure `metering` other than `'mean'` or `'percentile'`, `percentiles` that are not two numbers from 0 to 1 with the lower first, a `centerWeight` outside 0 to 1, a speed below 0, a `minEv`, `maxEv` or `compensation` outside -20 to 20, or a `minEv` above `maxEv`. A depth of field `focusDistance`, `aperture` or `focalLength` that is not above 0, a `maxBlur` outside 0 to 0.1, `blades` other than 0 or a whole number from 3 to 12, or a `focusPoint` that is not three finite numbers or `false`. Also a `lut` that is not a table from `assets.loadLut` or `assets.lutFromData`, a `grading` value out of its range, such as a white balance outside 1667 to 25000 kelvin, a lift channel outside -1 to 1, a gamma channel of 0 or below, a negative gain or saturation, or a split toning balance outside -1 to 1 or strength outside 0 to 1, or a value out of its range. These are an exposure, bloom intensity, threshold or knee, vignette intensity or size, or outline width below 0, a vignette falloff of 0 or below or a roundness above 1, a bloom blend other than `'mix'`, `'add'` or `'screen'`, bloom weights that are not 1 to 10 numbers of 0 or more, or that are all 0, a `lutIntensity` outside 0 to 1, a sharpening strength outside 0 to 1, an ambient occlusion value below 0 or its `distanceFalloff` or `intensity` above 1, a `distanceExponent` of 0, `samples` that are not a whole number from 1 to 64, a screen-space reflection value below 0 or its `intensity` or `maxRoughness` above 1, an `ssr.maxDistance` of 0, or an `ev100` outside -20 to 30. |
474
473
  | [E1203](../errors/E1203.md) | A value that is not a finite number, such as NaN, or an effect's `order` that is not one. |
475
474
  | [E1204](../errors/E1204.md) | An outline color that is not a hex string, a hex number or three linear components from 0 to 1. |
476
475
  | [E1215](../errors/E1215.md) | An effect or a tone curve as WGSL that the null3D Vite plugin did not compile, or compiled WGSL of another kind. |
@@ -483,7 +482,7 @@ A view that holds still blends its frames into a sharper picture, then stops dra
483
482
  - [The post-processing chain](../concepts/post-processing.md): how bloom, ambient occlusion, depth of field, outlines, custom effects and still views work, and what they cost.
484
483
  - [Cameras](cameras.md#focal-length): `camera.setFocalLength`, the lens that depth of field takes.
485
484
  - [Custom passes](../guides/custom-passes.md): how to write custom effects and tone curves.
486
- - [three.js to null3D mapping](../porting/threejs-mapping.md): `renderer.toneMapping`, `toneMappingExposure`, `UnrealBloomPass`, `GTAOPass`, `BokehPass`, `OutlinePass`, `LUTPass`, `VignetteShader`, `SharpenNode` and `ShaderPass`. three.js has no grading controls; a null3D grade has no three.js twin.
485
+ - [three.js to null3D mapping](../porting/threejs-mapping.md): `renderer.toneMapping`, `toneMappingExposure`, `UnrealBloomPass`, `GTAOPass`, `BokehPass`, `OutlinePass`, `LUTPass`, `VignetteShader`, `SharpenNode` and `ShaderPass`.
487
486
  - [Quality presets](../concepts/quality-presets.md): `aoScale`, `dofSamples` and `exposureMeter` on each preset.
488
487
  - [Objects and transforms](objects.md#mesh-calls): `setOutlined`.
489
488
  - [Assets](assets.md): `assets.loadLut`, which loads color grading tables, and `assets.lutFromData`, which makes them from numbers.
@@ -8,7 +8,7 @@ summary: "quality.preset, quality.set, quality.setPreset, the preset check, the
8
8
 
9
9
  # Quality API
10
10
 
11
- > Roadmap step 0.1, first released in null3D 0.1.0. Step 0.2 adds `quality.setBudget`. The API is experimental, so it can still change between versions. `quality.set` takes every setting that changes during play, as [Settings](#settings) says. The others stay fixed while the engine runs. The settings that the preset table marks as planned are not built yet. Coding agents must not use them.
11
+ > Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions. `quality.set` takes every setting that changes during play, as [Settings](#settings) says. The others stay fixed while the engine runs.
12
12
 
13
13
  `ctx.quality` gives a sketch the quality preset that the engine runs and its settings. The sketch can change the settings that change during play, switch to another preset, and hear when either changes. [Quality presets](../concepts/quality-presets.md) explains how the engine chooses and checks the preset, and lists each preset's values.
14
14
 
@@ -30,11 +30,12 @@ export default defineSketch(({ quality, page }) => {
30
30
 
31
31
  ## Choosing the preset on the page
32
32
 
33
- The page names the preset with the `preset` option of `createEngine`, or leaves the choice to the engine with `auto`, the default. The engine reports the preset that it runs in `engine.mode.preset`, and what the preset check measured in `engine.mode.presetCheck`:
33
+ The page names the preset with the `preset` option of `createEngine`, or leaves the choice to the engine with `auto`, the default. The engine reports the preset that it runs in `engine.mode.preset`, and what the preset check measured in `engine.mode.presetCheck`. The check measures the first frames of play, so wait for `engine.presetChecked` before you read its choice:
34
34
 
35
35
  ```ts
36
36
  const engine = await createEngine({ canvas, sketch, preset: 'auto' });
37
37
  console.log(engine.mode.preset, engine.mode.crashedStarts, engine.mode.memoryMaximumMiB);
38
+ await engine.presetChecked;
38
39
  console.log(engine.mode.presetCheck); // { from: 'high', targetFps: 60, rounds: [...], reused: false }, or null
39
40
  ```
40
41
 
@@ -42,14 +43,18 @@ console.log(engine.mode.presetCheck); // { from: 'high', targetFps: 60, rounds:
42
43
  | --- | --- |
43
44
  | `preset: 'auto'` | The engine chooses the preset for the device, then checks it with the sketch's scene and lowers it where the GPU cannot hold the frame rate. |
44
45
  | `preset: 'low'` to `'ultra'` | Names the preset. The GPU path still caps it, and a crashed start lowers it. |
46
+ | `presetCheck: 'during-play'` or `'before-play'` | When the preset check measures: in the first frames of play, the default, or before play, with `createEngine` waiting for it: [The preset check](../concepts/quality-presets.md#the-preset-check). |
45
47
  | `targetFps: 'display'` or a whole number | The frame rate that the preset check and the governor defend. Without it, the display's refresh rate, at most 60. `'display'` defends the display's full rate, and a number caps the target at that rate: [The target frame rate](../concepts/quality-presets.md#the-target-frame-rate). |
46
48
  | `maxPixelRatio` | Replaces the preset's pixel ratio cap. |
47
49
  | `antialias: 'msaa'`, `'fxaa'` or `'none'` | Replaces the preset's anti-aliasing mode. |
48
- | `shadowCascades`, `shadowMapSize`, `shadowTiles`, `shadowTileSize`, `heroTileSize`, `pointLightShadows`, `depthPrepass`, `gpuOcclusion`, `morphTargets` | Replace the preset's values of these settings, which stay fixed while the engine runs. |
49
- | `softwareOcclusion`, `textureMemoryMiB` | Replace the preset's values of these settings. A sketch can change them during play. |
50
+ | `shadowCascades`, `shadowMapSize`, `shadowTiles`, `shadowTileSize`, `heroTileSize`, `pointLightShadows`, `momentTransparency`, `gpuOcclusion`, `morphTargets` | Replace the preset's values of these settings, which stay fixed while the engine runs. |
51
+ | `depthPrepass`, `cloudSteps`, `softwareOcclusion`, `textureMemoryMiB` | Replace the preset's values of these settings. A sketch can change them during play. |
50
52
  | `memory: { maximumMiB }` | Replaces the preset's memory maximum: [Page API](engine.md#memory). |
51
53
  | `?preset=low` to `?preset=ultra` | Fixes the preset for tests. It wins over the option, and the engine ignores earlier crashes and checks no preset. |
54
+ | `?tier=lowest` | Starts in the lowest quality tier for tests and devices. The render scale fixes at a third, and the sun's cast shadows and bloom go off. A reflection that names no scale of its own draws at a quarter of the render size, and WebGL2 also drops its depth prepass. The four presets keep their looks, and the governor enters the same tier when frames still miss at the preset's floor. |
55
+ | `?tier=off` | Keeps the governor out of the lowest quality tier, so a test reads the presets' own settings and looks on a slow machine. |
52
56
  | `?target-fps=display` or `?target-fps=90` | Sets the target frame rate. It wins over the `targetFps` option. |
57
+ | `?preset-check=during-play` or `?preset-check=before-play` | Sets when the preset check measures. It wins over the `presetCheck` option. |
53
58
 
54
59
  ## Settings
55
60
 
@@ -63,7 +68,7 @@ Most settings change during play. The preset tables' "Changes" column names the
63
68
 
64
69
  [GPU tiers and backends](../concepts/backends.md#color-and-anti-aliasing-on-each-tier) compares the anti-aliasing modes on each GPU path.
65
70
 
66
- `quality.set(settings)` changes the settings it gets and keeps the others. It takes the settings that change during play, applies them from the next frame on, and returns a promise that resolves at once. Another setting, or a value outside the setting's range, throws [E1213](../errors/E1213.md) and changes nothing. So does a `minRenderScale` above `maxRenderScale`, an option of `createEngine` with a value that its setting does not take, and a preset name that `createEngine` does not know. To move both ends of the render scale's range past each other, give both in one call.
71
+ `quality.set(settings)` changes the settings it gets and keeps the others. It takes the settings that change during play, applies them from the next frame on, and returns a promise that resolves at once. Another setting, or a value outside the setting's range, throws [E1213](../errors/E1213.md) and changes nothing. So does a `minRenderScale` above `maxRenderScale`, an option of `createEngine` with a value that its setting does not take, and a preset name that `createEngine` does not know. To move both ends of the render scale's range past each other, give both in one call. In the [lowest quality tier](../concepts/quality-presets.md#the-lowest-quality-tier), a `minRenderScale` above the tier's cap of the scale raises the cap to it instead. Only a `maxRenderScale` that the sketch set itself throws.
67
72
 
68
73
  ## Switching presets
69
74
 
@@ -94,7 +99,7 @@ console.log(quality.renderScale); // 0.75
94
99
 
95
100
  ## The frame-budget governor
96
101
 
97
- When frames take too long, the engine lowers a sketch's budgets and the render scale in turn, a budget's step first, until the render scale reaches its lowest. Then it lowers the levels of detail, the live shadow settings, bloom's size, ambient occlusion's scale and the scale of screen-space reflections. Then it lowers the steps of contact shadows and the far characters' update interval. It raises them again once frames have time to spare. [Quality presets](../concepts/quality-presets.md#the-frame-budget-governor) gives the order of the steps and the rules that drive them. `quality.settings` keeps the values that the preset and the sketch gave. `quality.governor` reports what the engine draws with now. [`QualityGovernor`](reference/quality.md#qualitygovernor) lists each of its members with the step that changes it.
102
+ When frames take too long, the engine lowers a sketch's budgets and the render scale in turn, a budget's step first, until the render scale reaches its lowest. Then it lowers the levels of detail, the live shadow settings, bloom's size, ambient occlusion's scale and the scale of screen-space reflections. Then it lowers the steps of contact shadows, the far characters' update interval and the slices of volumetric fog. It raises them again once frames have time to spare. When the frames still miss at the render scale's floor, it enters the [lowest quality tier](../concepts/quality-presets.md#the-lowest-quality-tier). [Quality presets](../concepts/quality-presets.md#the-frame-budget-governor) gives the order of the steps and the rules that drive them. `quality.settings` keeps the values that the preset and the sketch gave. `quality.governor` reports what the engine draws with now. [`QualityGovernor`](reference/quality.md#qualitygovernor) lists each of its members with the step that changes it.
98
103
 
99
104
  The `quality.onChange` handlers run after each of these steps. So a sketch can lighten its own work with the engine's:
100
105
 
@@ -18,7 +18,7 @@ flowchart LR
18
18
  test --> hits["Hits, written into<br/>your own objects"]
19
19
  ```
20
20
 
21
- A raycast finds where a ray meets the scene's objects. An overlap query finds the objects inside a sphere or a box. Every query tests the triangles of objects and instance rows, as three.js's `Raycaster` does. Raycasts also hit [sprites, points and lines](#sprites-points-and-lines) where they draw. The engine keeps a tree over the scene's objects and a tree over each mesh's triangles. So a query tests only the few triangles near it.
21
+ A raycast finds where a ray meets the scene's objects. An overlap query finds the objects inside a sphere or a box. Every query tests the triangles of objects and instance rows. Raycasts also hit [sprites, points and lines](#sprites-points-and-lines) where they draw. The engine keeps a tree over the scene's objects and a tree over each mesh's triangles. So a query tests only the few triangles near it.
22
22
 
23
23
  Queries run in the sketch, on the scene. They write their results into objects and arrays that you create once, so a query in every frame allocates nothing. `bun run bench:allocation --calls` checks it.
24
24
 
@@ -77,7 +77,7 @@ A ray starts at `origin` and runs along `direction`, which needs no unit length.
77
77
 
78
78
  `options` is `undefined` or an object with these optional fields:
79
79
 
80
- - `layers`: the layers to test, a 32-bit mask as `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`.
80
+ - `layers`: the layers to test, a 32-bit mask as `setLayers` takes. A query tests an object when their masks share a layer. The default is layer 0 alone, as for a camera.
81
81
  - `maxDistance`: the farthest hit in meters. The default is no limit.
82
82
  - `pointThreshold`: a distance in meters. When you set it, a ray hits a point that it passes within this distance of, whatever the point's size.
83
83
  - `lineThreshold`: a distance in meters. When you set it, a ray hits a line that it passes within this distance of, whatever the line's width.
@@ -91,8 +91,8 @@ A hit has these fields:
91
91
  | `point` | Where the ray hit, in world space |
92
92
  | `normal` | The unit normal of the hit triangle in world space, on the side that faces the ray's origin |
93
93
  | `distance` | The distance from the origin to the point, in meters |
94
- | `triangle` | The index of the hit triangle in its mesh, as three.js's `faceIndex`. -1 for a sprite, a point or a line |
95
- | `uv` | Where on the surface the ray hit, in the mesh's first texture coordinates, as three.js's `intersection.uv`. Give an array of two numbers, as you give `point`, and every raycast fills it. Read `hasUv` first |
94
+ | `triangle` | The index of the hit triangle in its mesh. -1 for a sprite, a point or a line |
95
+ | `uv` | Where on the surface the ray hit, in the mesh's first texture coordinates. Give an array of two numbers, as you give `point`, and every raycast fills it. Read `hasUv` first |
96
96
  | `hasUv` | True when the hit triangle's mesh has a first texture coordinate set, so `uv` gives where on the surface the ray hit. False for a hit on a sprite, a point or a line, and for a mesh with no such coordinates |
97
97
 
98
98
  `uv` holds where the ray crossed the surface. It blends the three corners' texture coordinates,
@@ -103,7 +103,7 @@ in-world screen turns a click into a pixel of its image.
103
103
 
104
104
  ## Rays from the pointer
105
105
 
106
- For clicks and hover on objects, `object.on('click', handler)` casts the ray itself. [Pointer events on objects](input.md#pointer-events-on-objects) describes it. For a ray of your own, such as one that tests only some layers, `camera.screenToRay(x, y, ray)` writes the ray through a point on the canvas. Pass `input.pointer.x` and `input.pointer.y`, and the ray comes from the frame that was on screen at the pointer's event.
106
+ For clicks and hover on objects, `object.on('click', handler)` casts the ray itself. [Pointer events on objects](input.md#pointer-events-on-objects) describes it. For a ray of your own, such as one that tests only some layers, `camera.screenToRay(x, y, ray)` writes the ray through a point on the canvas. Pass `input.pointer.x` and `input.pointer.y`, and the ray comes from the frame that was on screen at the pointer's event. Over a view from `scene.createView`, cast the ray with `view.screenToRay` instead, and `scene.viewAt(x, y)` finds that view ([Multiple views](../guides/multiple-views.md#picking-in-a-view)).
107
107
 
108
108
  ```ts
109
109
  const ray = { origin: vec3.create(), direction: vec3.create() }; // made once
@@ -152,7 +152,7 @@ The coordinates stay the mesh's own. A repeated texture reports values past 1, a
152
152
 
153
153
  A skinned or morphed character draws a different shape than the mesh that the ray tests. So does a custom material that moves its vertices in its shader. Their coordinates can therefore differ from the pose that the frame drew.
154
154
 
155
- The point is tested at the pixel that the camera draws, not at a projected triangle. A surface thinner than a pixel picks where its pixels are. A material with `alphaMode: 'mask'` picks by its mask. So a ray through a cut-out hole finds what lies behind the hole. The frame that records the pick draws it, so the camera of that frame answers. A camera that moves meanwhile can differ from the frame that the click saw.
155
+ The point is tested at the pixel that the camera draws, not at a projected triangle. A surface thinner than a pixel picks where its pixels are. An engine material with `alphaMode: 'mask'` picks by its mask. So a ray through a cut-out hole finds what lies behind the hole. The frame that records the pick draws it, so the camera of that frame answers. A camera that moves meanwhile can differ from the frame that the click saw.
156
156
 
157
157
  A pick finds these sources:
158
158
 
@@ -161,7 +161,7 @@ A pick finds these sources:
161
161
  - Each row of an instance batch, named by `object` and `instance`.
162
162
  - Skinned and morphed characters, as their last frame's pose places them.
163
163
 
164
- A scene with a source that the pick's id target cannot hold answers the whole pick with a raycast instead. That source is a whole shader of your own, a material with `blending` or `transmission`, or a sprite, point or line. The raycast tests triangles, so it ignores masks, and it uses the camera of the frame that last ran.
164
+ A scene with a source that the pick's id target cannot hold answers the whole pick with a raycast instead. Such a source is a custom material without a vertex offset, a masked custom material, or a material with `alphaMode: 'hash'`, `blending` or `transmission`. A sprite, point or line is one too. The raycast tests triangles, so it ignores masks, and it uses the camera of the frame that last ran.
165
165
 
166
166
  A pick before the first frame answers `null`. The engine has not drawn the camera yet, so no pixel of a frame shows anything.
167
167
 
@@ -191,7 +191,7 @@ An overlap query tests triangles. A long wall counts only where its surface reac
191
191
 
192
192
  ## Sprites, points and lines
193
193
 
194
- A ray hits [sprites](sprites.md), [points](points.md) and [lines](lines.md) where they draw, as three.js's `Raycaster` hits its `Sprite` and `Line2`:
194
+ A ray hits [sprites](sprites.md), [points](points.md) and [lines](lines.md) where they draw:
195
195
 
196
196
  | Row | A ray hits it |
197
197
  | --- | --- |
@@ -205,9 +205,9 @@ A hit's `instance` is the row: the sprite, the point, or the segment. Segment `i
205
205
 
206
206
  Sprites face the camera, and sizes in pixels depend on it. So these raycasts need a camera. `scene.raycast` and the other raycasts use the active camera. A pointer event's ray uses the camera of the frame on screen at the event. Without an active camera, rays miss sprites, points without `pointThreshold` and lines sized in pixels. A row sized in pixels is hit only between the camera's near and far planes, where the camera draws it.
207
207
 
208
- The hit on a sprite or a point's square is the point where the ray crosses it, and its normal faces the camera. A hit near a line, or near a point within a threshold, is the ray's closest point to it, as in three.js. Its distance is that point's distance along the ray, and its normal points back along the ray. A ray hits a dashed line in its gaps too, and a sprite or a point where its map is clear, as in three.js.
208
+ The hit on a sprite or a point's square is the point where the ray crosses it, and its normal faces the camera. A hit near a line, or near a point within a threshold, is the ray's closest point to it. Its distance is that point's distance along the ray, and its normal points back along the ray. A ray hits a dashed line in its gaps too, and a sprite or a point where its map is clear.
209
209
 
210
- `pointThreshold` and `lineThreshold` give the tests of three.js's `Raycaster.params.Points.threshold` and `Raycaster.params.Line.threshold`. Use them to port code that sets those, or to make small points and thin lines easier to click. three.js's default for both is 1 meter, whatever the sizes. null3D has no default threshold: without one, rays hit what draws.
210
+ `pointThreshold` and `lineThreshold` make small points and thin lines easier to click. Neither has a default: without one, rays hit what draws.
211
211
 
212
212
  ```ts
213
213
  // Each star is 3 pixels wide. A click within 0.5 m of a star selects it.
@@ -226,7 +226,7 @@ Overlap queries do not find sprites, points or lines.
226
226
  ## What queries test
227
227
 
228
228
  - Each object and instance row with a mesh, on the query's layers. Groups, cameras and lights have no mesh. Raycasts also test the sprites, points and line segments in use on the query's layers.
229
- - Each triangle as its material draws it: front faces only, or both faces for a material with `doubleSided: true`. three.js's `Raycaster` reads a material's `side` the same way.
229
+ - Each triangle as its material draws it: front faces only, or both faces for a material with `doubleSided: true`.
230
230
  - Shown objects only. A hidden object is never hit.
231
231
  - The positions of the last frame's update. A move, a new object or a destroy in your `onUpdate` counts from the next frame. In `onLateUpdate`, queries see this frame's positions, but rows of instance batches still have the last frame's positions.
232
232
  - Before the first frame, a query applies the objects that `setup` has created and their transforms. A bake that `setup` runs therefore sees the scene as `setup` has built it. Moves that `setup` makes after its first query count from the first frame.
@@ -258,31 +258,12 @@ The engine keeps two levels of trees, in its WebAssembly core.
258
258
 
259
259
  Each node of a tree has four children, so one SIMD instruction tests a ray against four boxes. A query walks the scene's trees to the objects whose boxes it meets. Then it moves the ray into each object's own space and walks that object's mesh tree. Each object's box comes from its mesh's box, so it holds every triangle.
260
260
 
261
+ Because a query walks these trees, a ray costs about the same in a large scene as in a small one. A three.js `Raycaster` tests each object's bounding sphere in turn, so its rays cost more as the scene grows.
262
+
261
263
  The trees hold sprites, points and line segments too. A row sized in pixels takes more room in the world the farther it lies from the camera. A threshold reaches past what a row draws. So when the query's layers hold such rows, the raycast grows each box of the trees as it walks them. A raycast on layers without them costs no more.
262
264
 
263
265
  The trees give the same hits as testing every triangle of every object in turn. Objects far from the origin, thousands of kilometers out, get the same precision as objects near it. The engine stores positions relative to grid cells, and each query moves its origin into each cell's frame in 64-bit numbers.
264
266
 
265
- ## Compared with three.js
266
-
267
- | three.js | null3D |
268
- | --- | --- |
269
- | `raycaster.setFromCamera(pointer, camera)` | `camera.screenToRay(input.pointer.x, input.pointer.y, ray)`, with the camera of the frame on screen at the pointer's event |
270
- | DOM listeners that raycast for clicks and hover | `object.on('click', handler)` and the other [pointer events on objects](input.md#pointer-events-on-objects) |
271
- | `raycaster.intersectObjects(scene.children, true)` | `scene.raycastAll(origin, direction, options, hits)` tests the whole scene |
272
- | `intersects[0]` | `scene.raycast(origin, direction, options, hit)` |
273
- | `raycaster.far` | `maxDistance` |
274
- | `raycaster.layers` | `options.layers`, with the same default: layer 0 alone |
275
- | `raycaster.params.Points.threshold` | `options.pointThreshold`, with no default: without it, a ray hits each point's square |
276
- | `raycaster.params.Line.threshold` | `options.lineThreshold`, with no default: without it, a ray hits each line within half its width, as `Line2` |
277
- | `raycaster.camera`, for sprites and `Line2` | The active camera, or the camera of the frame on screen at a pointer event |
278
- | `intersection.instanceId` | `hit.instance` |
279
- | `intersection.faceIndex` | `hit.triangle` |
280
- | `intersection.uv` | `hit.uv`, which `hit.hasUv` says whether to read |
281
- | `three-mesh-bvh` | Built in: delete its setup |
282
- | three.js has no pixel pick: its `Raycaster` tests triangles | `scene.pick(x, y)` tests the pixel that the image shows, through the GPU, and returns a promise |
283
-
284
- three.js tests hidden objects unless you filter them out; null3D never hits them. three.js gives a `Line`'s hit point on the line; null3D gives the point on the ray, as three.js does for `Line2`. three.js's `Line2` ignores `raycaster.far`; null3D's `maxDistance` limits every hit. three.js tests a skinned mesh's animated vertices; null3D tests its bind pose. three.js returns a new array of new objects for each raycast; null3D writes into the objects you pass. three.js tests each object's bounding sphere in turn, so a ray costs more as the scene grows. null3D walks its trees, so a ray costs about the same in a large scene.
285
-
286
267
  ## API reference
287
268
 
288
269
  [The API reference](reference/raycast.md) lists every export of this page with its type and description. The engine's doc comments make it.
@@ -43,8 +43,8 @@ Plays an animated object's clips. It fades between them, blends them in layers w
43
43
  | `readonly timeScale: number` | The rate of the object's animation time: 1 by default, 0 to pause every clip. |
44
44
  | `describe(): string` | The object, as error messages name it. |
45
45
  | `play(name: string, options?: PlayOptions): void` | Plays a clip. It fades in over `fade` seconds while the other clips of its layer fade out, or with no fade, takes over at once. With a `weight`, it joins the layer's other clips instead. A clip that already plays on the layer keeps its time and fades back in. A clip that played once and reached its end starts again. |
46
- | `crossFade(name: string, duration: number, options?: PlayOptions): void` | Fades to a clip over `duration` seconds while the layer's other clips fade out, as three.js's `crossFadeTo` does. It is `play(name, { ...options, fade: duration })`, but a clip with a weight still takes over. |
47
- | `setWeight(name: string, weight: number): void` | Sets the weight of a clip that plays, 0 or more, on every layer that plays it, as three.js's `setEffectiveWeight` does. A clip at weight 0 leaves the pose but keeps playing, so its time moves on. A fade multiplies the weight. It writes engine memory, so calling it every frame costs nothing. |
46
+ | `crossFade(name: string, duration: number, options?: PlayOptions): void` | Fades to a clip over `duration` seconds while the layer's other clips fade out, and samples them all while the fade runs. It is `play(name, { ...options, fade: duration })`, but it always cross-fades, whatever its `transition`, and a clip with a weight still takes over. |
47
+ | `setWeight(name: string, weight: number): void` | Sets the weight of a clip that plays, 0 or more, on every layer that plays it. A clip at weight 0 leaves the pose but keeps playing, so its time moves on. A fade multiplies the weight. It writes engine memory, so calling it every frame costs nothing. |
48
48
  | `playBlend(points: Readonly<Record<string, number>>, options?: BlendOptions): void` | Plays a 1D blend of clips. Each clip counts in full at its point, such as `{ idle: 0, walk: 1.4, run: 4 }` for a blend by speed. Between two points, the two clips around the blend value share it, and `setBlend` moves the value. The clips keep one phase: each clip's time moves at its length over the length of the blend's clips, averaged by their weights. A walk and a run of different lengths then keep their steps together. The layer's other clips fade out over `fade` seconds, as with `play`. |
49
49
  | `setBlend(value: number, layer = 0): void` | Sets the blend value of a layer's blend: the clip at that point counts in full, and a value between two points mixes the two clips around it. A value past the first or the last point gives that point's clip. It writes engine memory, so calling it every frame costs nothing. |
50
50
  | `stop(name?: string, options?: StopOptions): void` | Stops a clip on every layer, or with no name, every clip, fading out over `fade` seconds. |
@@ -54,8 +54,8 @@ Plays an animated object's clips. It fades between them, blends them in layers w
54
54
  | `readonly updateInterval: number` | The frames between two updates of the object's pose. The value 1, the default, updates it in every frame. A larger number samples and composes it once every that many frames, and holds the last pose in between. A far crowd then costs less on the job workers, and, where the skinning pass skips a held pose, on the GPU too. The object's clips keep their real speed. Each update covers the frames that it skipped. |
55
55
  | `setUpdateInterval(frames: number): void` | Sets the frames between two updates of the object's pose, a whole number from 1 to 64. The value 1, the default, updates the pose in every frame, which a character near the camera needs. A larger value leaves a far character in the pose of its last update for longer, which steps. Give a crowd's near characters 1 and its far ones more. It writes engine memory, so calling it every frame costs nothing. |
56
56
  | `joint(name: string): number` | The index of the joint named `name`, which the joint calls take in place of its name. Look it up once and keep it: an index skips the name lookup in each call. |
57
- | `setJointRotation(joint: number \| string, rotation: QuatLike, weight = 1): void` | Sets a joint's rotation relative to its parent, as a quaternion `[x, y, z, w]`, on top of the clips. The joint turns from its animated rotation toward this one by `weight`, from 0 to 1. At 1 it takes the rotation, as three.js's `bone.quaternion.copy` does after the mixer's update. The joints below it follow. The rotation holds in every frame until `clearJoint`, so call it again only to change it. It writes engine memory, so calling it every frame costs nothing. |
58
- | `addJointRotation(joint: number \| string, rotation: QuatLike, weight = 1): void` | Turns a joint by a rotation, a quaternion `[x, y, z, w]`, on top of its animated rotation, in the joint's own frame, as three.js's `bone.quaternion.multiply` does after the mixer's update. `weight`, from 0 to 1, scales the turn. A walking soldier then twists or leans while the clips move it. The turn holds in every frame until `clearJoint`, and calling it every frame costs nothing. |
57
+ | `setJointRotation(joint: number \| string, rotation: QuatLike, weight = 1): void` | Sets a joint's rotation relative to its parent, as a quaternion `[x, y, z, w]`, on top of the clips. The joint turns from its animated rotation toward this one by `weight`, from 0 to 1. At 1 it takes the rotation. The joints below it follow. The rotation holds in every frame until `clearJoint`, so call it again only to change it. It writes engine memory, so calling it every frame costs nothing. |
58
+ | `addJointRotation(joint: number \| string, rotation: QuatLike, weight = 1): void` | Turns a joint by a rotation, a quaternion `[x, y, z, w]`, on top of its animated rotation, in the joint's own frame. `weight`, from 0 to 1, scales the turn. A walking soldier then twists or leans while the clips move it. The turn holds in every frame until `clearJoint`, and calling it every frame costs nothing. |
59
59
  | `clearJoint(joint: number \| string): void` | Removes the rotations that `setJointRotation` and `addJointRotation` gave a joint. |
60
60
  | `lookAt(target: Vec3Like \| null, options?: LookAtOptions, weight = 1): void` | Turns a chain of joints, such as the spine, neck and head, so that the last one aims at `target`, a point in the world. The engine aims again in each frame from the pose that the clips and the joint rotations give, until `lookAt(null)` stops it. So a soldier keeps its rifle on a target while it walks. `weight`, from 0 to 1, blends the turn with the animated pose. Call it every frame to follow a moving point. The options hold until a call gives others, and a frozen options object is read once, so the call allocates nothing. |
61
61
  | `onEvent(name: string, handler: AnimationEventHandler): () => void` | Calls `handler` for each event named `name` that a playing clip reaches: an event in the clip's data, 'loop' when a repeating clip starts again, or 'finished' when a clip that plays once reaches its end. Handlers run on the sketch's thread at the start of the next frame's update, before `onFixedUpdate` and `onUpdate`. Returns a function that removes the handler. |
@@ -100,10 +100,10 @@ How `Animator.play` plays a clip. A play reads a frozen object once, so a game t
100
100
  | `loop?: boolean` | True, the default, repeats the clip. False plays it once and holds its last frame. |
101
101
  | `speed?: number` | The rate of the clip's time. 1, the default, plays it as made, and 2 twice as fast. A negative rate plays it backward from its end. |
102
102
  | `layer?: number` | The layer, a whole number from 0, the default, to 3. Each layer above 0 replaces the pose of the layers below by its weight, on the joints of its mask. |
103
- | `additive?: boolean` | True adds the clip's change from its first frame to the pose of the layers, as three.js's additive clips do. A breathing or aiming clip then plays on top of a walk. An additive play replaces only the additive clips of its layer, and a plain play only the plain ones. |
104
- | `time?: number` | Seconds into the clip at which it starts, as three.js's `action.time` sets it. A repeating clip wraps the time into its length, and a clip that plays once holds it within its length. Without it, a clip starts at its first frame, and a clip that already plays keeps its time. |
105
- | `weight?: number` | The clip's own weight, 0 or more, as three.js's `setEffectiveWeight` sets it. A play with a weight joins the other clips of its layer instead of fading them out, so a walk at 0.3 and a run at 0.7 blend. A fade multiplies the weight. Without it, a clip that starts takes 1, and a clip that already plays keeps its weight. |
106
- | `transition?: 'blend' \| 'inertial'` | How a play with a `fade` switches what its layer plays. `'blend'`, the default, cross-fades the layer's old clips with the new one, as three.js's `crossFadeTo` does, and samples both while the fade runs. `'inertial'` samples only the new clip: the pose the layer leaves continues on its path and eases into the new clip, which keeps feet from sliding through a mixed gait. It needs a fade above 0, no `weight`, and a clip already playing on the layer, whose pose it carries on from. A play of a clip that already plays on the layer keeps that clip's time and fades it back in instead, so it is no inertial switch. `crossFade` always cross-fades, so a port of `crossFadeTo` shows the blend that three.js shows. |
103
+ | `additive?: boolean` | True adds the clip's change from its first frame to the pose of the layers. A breathing or aiming clip then plays on top of a walk. An additive play replaces only the additive clips of its layer, and a plain play only the plain ones. |
104
+ | `time?: number` | Seconds into the clip at which it starts. A repeating clip wraps the time into its length, and a clip that plays once holds it within its length. Without it, a clip starts at its first frame, and a clip that already plays keeps its time. |
105
+ | `weight?: number` | The clip's own weight, 0 or more. A play with a weight joins the other clips of its layer instead of fading them out, so a walk at 0.3 and a run at 0.7 blend. A fade multiplies the weight. Without it, a clip that starts takes 1, and a clip that already plays keeps its weight. |
106
+ | `transition?: 'blend' \| 'inertial'` | How a play with a `fade` switches what its layer plays. `'blend'`, the default, cross-fades the layer's old clips with the new one, and samples both while the fade runs. `'inertial'` samples only the new clip: the pose the layer leaves continues on its path and eases into the new clip, which keeps feet from sliding through a mixed gait. It needs a fade above 0, no `weight`, and a clip already playing on the layer, whose pose it carries on from. A play of a clip that already plays on the layer keeps that clip's time and fades it back in instead, so it is no inertial switch. `crossFade` always cross-fades. |
107
107
 
108
108
  ## `PropertyAnimation`
109
109
 
@@ -117,7 +117,7 @@ One property's keyframes, playing. `scene.animateProperty` returns one: the engi
117
117
  | `readonly playing: boolean` | True while the animation runs. |
118
118
  | `readonly loop: boolean` | True when the animation repeats, and false when it holds its last key. |
119
119
  | `readonly speed: number` | The rate of the animation's time: 1 plays it as made, and a negative rate plays it backward. |
120
- | `setTime(seconds: number): void` | Sets the animation's time in seconds, as three.js's `action.time` does. |
120
+ | `setTime(seconds: number): void` | Sets the animation's time in seconds. |
121
121
  | `setPaused(paused: boolean): void` | Starts or stops the time, without changing the value that the target holds. |
122
122
  | `setLoop(loop: boolean): void` | Repeats the animation, or makes it hold its last key at its end. |
123
123
  | `setSpeed(speed: number): void` | Sets the rate of the animation's time: 1 plays it as made, and 2 twice as fast. A negative rate plays it backward. |