@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
@@ -14,7 +14,7 @@ summary: "Every export of the Geometry API, from the engine's doc comments."
14
14
 
15
15
  Class `ArcCurve`, which extends `EllipseCurve`.
16
16
 
17
- A 2D circle or part of one, like three.js's `ArcCurve`: an `EllipseCurve` with one radius.
17
+ A 2D circle or part of one: an `EllipseCurve` with one radius.
18
18
 
19
19
  ## `BoxOptions`
20
20
 
@@ -59,7 +59,7 @@ Options for `geometry.capsule`: a cylinder with a half sphere on each end. The c
59
59
 
60
60
  Class `CatmullRomCurve3`, which extends `Curve`.
61
61
 
62
- A smooth 3D curve through a list of points, like three.js's `CatmullRomCurve3`.
62
+ A smooth 3D curve through a list of points.
63
63
 
64
64
  | Member | Description |
65
65
  | --- | --- |
@@ -110,7 +110,7 @@ Options for `geometry.cone`. The cone stands on the Y axis, centered on its orig
110
110
 
111
111
  Class `CubicBezierCurve`, which extends `Curve`.
112
112
 
113
- A 2D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` and `v2`, like three.js's `CubicBezierCurve`.
113
+ A 2D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` and `v2`.
114
114
 
115
115
  | Member | Description |
116
116
  | --- | --- |
@@ -124,7 +124,7 @@ A 2D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` an
124
124
 
125
125
  Class `CubicBezierCurve3`, which extends `Curve`.
126
126
 
127
- A 3D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` and `v2`, like three.js's `CubicBezierCurve3`.
127
+ A 3D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` and `v2`.
128
128
 
129
129
  | Member | Description |
130
130
  | --- | --- |
@@ -138,7 +138,7 @@ A 3D cubic Bézier curve from `v0` to `v3`, shaped by the control points `v1` an
138
138
 
139
139
  Class `Curve`.
140
140
 
141
- The base class of all curves, like three.js's `Curve`. A subclass gives `getPoint`. The class adds sampling by arc length, tangents and, for 3D curves, Frenet frames. `Point` is the type of the curve's points. It is `[number, number]` for a 2D curve and `[number, number, number]` for a 3D curve.
141
+ The base class of all curves. A subclass gives `getPoint`. The class adds sampling by arc length, tangents and, for 3D curves, Frenet frames. `Point` is the type of the curve's points. It is `[number, number]` for a 2D curve and `[number, number, number]` for a 3D curve.
142
142
 
143
143
  | Member | Description |
144
144
  | --- | --- |
@@ -155,13 +155,13 @@ The base class of all curves, like three.js's `Curve`. A subclass gives `getPoin
155
155
  | `getUtoTmapping(u: number, distance: number \| null = null): number` | The `t` that lies at the fraction `u` of the curve's length. A truthy `distance` gives the length from the start in place of `u`. |
156
156
  | `getTangent(t: number, out?: Point): Point` | The unit direction of the curve at `t`, from two points a small step apart. Writes into `out` when given. |
157
157
  | `getTangentAt(u: number, out?: Point): Point` | The unit direction at the fraction `u` of the curve's length. Writes into `out` when given. |
158
- | `computeFrenetFrames(segments: number, closed = false): FrenetFrames` | The Frenet frames of a 3D curve at `segments + 1` points spaced along its length, as three.js computes them for tubes and extrusions. A closed curve gets a twist spread over its length, so the last frame matches the first. |
158
+ | `computeFrenetFrames(segments: number, closed = false): FrenetFrames` | The Frenet frames of a 3D curve at `segments + 1` points spaced along its length, which `tube` and `extrude` follow. A closed curve gets a twist spread over its length, so the last frame matches the first. |
159
159
 
160
160
  ## `CurvePath`
161
161
 
162
162
  Class `CurvePath`, which extends `Curve`.
163
163
 
164
- A list of curves joined end to end and treated as one curve, like three.js's `CurvePath`. Its `t` runs over the whole path by length.
164
+ A list of curves joined end to end and treated as one curve. Its `t` runs over the whole path by length.
165
165
 
166
166
  | Member | Description |
167
167
  | --- | --- |
@@ -170,7 +170,7 @@ A list of curves joined end to end and treated as one curve, like three.js's `Cu
170
170
  | `cacheLengths: number[] \| null` | The lengths that `getCurveLengths` measured last, or null before the first call. |
171
171
  | `add(curve: Curve<Point>): void` | Adds a curve to the end of the path. |
172
172
  | `closePath(): this` | Adds a straight line from the path's end to its start, when they differ. |
173
- | `getPoint(t: number, out?: Point): Point` | The point at `t` over the whole path by length. Writes into `out` when given. Throws a `RangeError` when `t` is above 1 or the path is empty, where three.js returns null. |
173
+ | `getPoint(t: number, out?: Point): Point` | The point at `t` over the whole path by length. Writes into `out` when given. Throws a `RangeError` when `t` is above 1 or the path is empty. |
174
174
  | `getLength(): number` | The path's length: the sum of its curves' lengths. |
175
175
  | `updateArcLengths(): void` | Measures the path again. Call it after a curve's points change. |
176
176
  | `getCurveLengths(): number[]` | The length from the start of the path to the end of each curve. The path keeps the list while the number of curves stays the same. |
@@ -200,13 +200,13 @@ Options for `geometry.cylinder`. The cylinder stands on the Y axis, centered on
200
200
  function dodecahedron(options: PolyhedronShapeOptions = {}): GeneratedArrays
201
201
  ```
202
202
 
203
- The arrays of a dodecahedron, like three.js's `DodecahedronGeometry`. The mesh has no indices.
203
+ The arrays of a dodecahedron. The mesh has no indices.
204
204
 
205
205
  ## `EllipseCurve`
206
206
 
207
207
  Class `EllipseCurve`, which extends `Curve`.
208
208
 
209
- A 2D ellipse or part of one, like three.js's `EllipseCurve`. Angles are in radians, measured from the positive x axis.
209
+ A 2D ellipse or part of one. Angles are in radians, measured from the positive x axis.
210
210
 
211
211
  | Member | Description |
212
212
  | --- | --- |
@@ -226,17 +226,17 @@ A 2D ellipse or part of one, like three.js's `EllipseCurve`. Angles are in radia
226
226
  function extrude(options: ExtrudeOptions = {}): GeneratedArrays
227
227
  ```
228
228
 
229
- The arrays of an extruded shape, like three.js's `ExtrudeGeometry`. The mesh has no indices: each three vertices in a row make a triangle. Its normals are flat, one per face. three.js puts the caps in one group and the side walls in another, so each can take its own material. Here they form one mesh, caps first. A material per group needs two meshes.
229
+ The arrays of an extruded shape. The mesh has no indices: each three vertices in a row make a triangle. Its normals are flat, one per face. The caps and the side walls form one mesh, caps first. To give each its own material, make two meshes.
230
230
 
231
231
  ## `ExtrudeOptions`
232
232
 
233
233
  Interface `ExtrudeOptions`.
234
234
 
235
- Options for `extrude`, with the names and defaults of three.js's `ExtrudeGeometry`.
235
+ Options for `extrude`.
236
236
 
237
237
  | Member | Description |
238
238
  | --- | --- |
239
- | `shapes?: Shape \| readonly Shape[]` | One shape or a list of shapes. The default is three.js's square with corners at x and y of 0.5 and -0.5. |
239
+ | `shapes?: Shape \| readonly Shape[]` | One shape or a list of shapes. The default is a square with corners at x and y of 0.5 and -0.5. |
240
240
  | `curveSegments?: number` | The number of points along each curve of a shape. The default is 12. |
241
241
  | `steps?: number` | The number of steps along the depth or the path. The default is 1. |
242
242
  | `depth?: number` | How far the shape moves along +Z. The default is 1. A path sets the length instead. |
@@ -264,20 +264,20 @@ The frames along a 3D curve that `computeFrenetFrames` returns: one tangent, nor
264
264
 
265
265
  Interface `GeneratedArrays`.
266
266
 
267
- The arrays that a generator returns, ready for `geometry.fromArrays`. Each array holds the values of vertex 0, then vertex 1, and so on, as three.js's `BufferGeometry` keeps its attributes.
267
+ The arrays that a generator returns, ready for `geometry.fromArrays`. Each array holds the values of vertex 0, then vertex 1, and so on.
268
268
 
269
269
  | Member | Description |
270
270
  | --- | --- |
271
- | `positions: Float32Array` | Three numbers per vertex: x, y and z. Like three.js's `position` attribute. |
272
- | `normals: Float32Array` | Three numbers per vertex: the unit normal. Like three.js's `normal` attribute. |
273
- | `uvs: Float32Array` | Two numbers per vertex: u and v. Like three.js's `uv` attribute. |
274
- | `indices?: Uint16Array \| Uint32Array` | Three vertex indices per triangle. The array holds 32-bit indices when an index reaches 65535, as three.js's `setIndex` chooses, and 16-bit indices otherwise. Absent when each three vertices in a row make a triangle. |
271
+ | `positions: Float32Array` | Three numbers per vertex: x, y and z. |
272
+ | `normals: Float32Array` | Three numbers per vertex: the unit normal. |
273
+ | `uvs: Float32Array` | Two numbers per vertex: u and v. |
274
+ | `indices?: Uint16Array \| Uint32Array` | Three vertex indices per triangle. The array holds 32-bit indices when an index reaches 65535, and 16-bit indices otherwise. Absent when each three vertices in a row make a triangle. |
275
275
 
276
276
  ## `Geometry`
277
277
 
278
278
  Class `Geometry`.
279
279
 
280
- Mesh generators with the parameters and defaults of three.js's geometry classes, and meshes from arrays.
280
+ Mesh generators for common shapes, and meshes from arrays.
281
281
 
282
282
  | Member | Description |
283
283
  | --- | --- |
@@ -285,16 +285,16 @@ Mesh generators with the parameters and defaults of three.js's geometry classes,
285
285
  | `readonly automaticLevelTriangles: number` | The triangles from which a mesh made in code plans its levels of detail, the first time the scene draws it, unless its options say `levels: false`. A smaller mesh drawn a few times costs little at any distance, and each level adds draw work to every pipeline that draws it. |
286
286
  | `readonly automaticDrawnTriangles: number` | The triangles of the copies that the scene draws, together, from which a smaller mesh of at least `automaticCopyTriangles` triangles plans its levels too, as a batch of pebbles does. |
287
287
  | `readonly automaticCopyTriangles: number` | The fewest triangles of a mesh that plans its levels because of its copies. |
288
- | `box(options: BoxOptions = {}): MeshGeometry` | A box, like three.js's `BoxGeometry`. |
289
- | `sphere(options: SphereOptions = {}): MeshGeometry` | A sphere, like three.js's `SphereGeometry`. |
290
- | `plane(options: PlaneOptions = {}): MeshGeometry` | A flat rectangle, like three.js's `PlaneGeometry`. |
291
- | `cylinder(options: CylinderOptions = {}): MeshGeometry` | A cylinder, like three.js's `CylinderGeometry`. |
292
- | `cone(options: ConeOptions = {}): MeshGeometry` | A cone, like three.js's `ConeGeometry`: a cylinder whose top is a point. |
293
- | `torus(options: TorusOptions = {}): MeshGeometry` | A torus, like three.js's `TorusGeometry`. |
294
- | `capsule(options: CapsuleOptions = {}): MeshGeometry` | A capsule, like three.js's `CapsuleGeometry`. |
295
- | `circle(options: CircleOptions = {}): MeshGeometry` | A flat circle, like three.js's `CircleGeometry`. |
296
- | `ring(options: RingOptions = {}): MeshGeometry` | A flat ring, like three.js's `RingGeometry`. |
297
- | `fromArrays(arrays: MeshArrays): MeshGeometry` | A mesh from arrays of vertex attributes and triangle indices, like three.js's `BufferGeometry` with `setAttribute` and `setIndex`. The mesh keeps the attributes it gets, each in the type of number it came in, and meshes whose attributes have the same types share GPU buffers. A mesh can have any number of vertices. Throws E1206 when an array's length does not fit the vertex count, when its attribute does not take its type of number, when an index names no vertex, for a value that is not a finite number, and for morph targets whose arrays do not fit the vertices or whose lists hold different numbers of targets. |
288
+ | `box(options: BoxOptions = {}): MeshGeometry` | A box, centered on its origin. |
289
+ | `sphere(options: SphereOptions = {}): MeshGeometry` | A sphere with its poles on the Y axis, or a part of one. |
290
+ | `plane(options: PlaneOptions = {}): MeshGeometry` | A flat rectangle in the XY plane that faces +Z. |
291
+ | `cylinder(options: CylinderOptions = {}): MeshGeometry` | A cylinder on the Y axis, closed at each end unless `openEnded` is true. |
292
+ | `cone(options: ConeOptions = {}): MeshGeometry` | A cone on the Y axis: a cylinder whose top is a point. |
293
+ | `torus(options: TorusOptions = {}): MeshGeometry` | A torus: a tube bent into a ring around the Z axis. |
294
+ | `capsule(options: CapsuleOptions = {}): MeshGeometry` | A capsule: a cylinder on the Y axis with a half sphere on each end. |
295
+ | `circle(options: CircleOptions = {}): MeshGeometry` | A flat circle in the XY plane that faces +Z, or a slice of one. |
296
+ | `ring(options: RingOptions = {}): MeshGeometry` | A flat ring: a disc with a hole, in the XY plane, that faces +Z. |
297
+ | `fromArrays(arrays: MeshArrays): MeshGeometry` | A mesh from arrays of vertex attributes and triangle indices. The mesh keeps the attributes it gets, each in the type of number it came in, and meshes whose attributes have the same types share GPU buffers. A mesh can have any number of vertices. Throws E1206 when an array's length does not fit the vertex count, when its attribute does not take its type of number, when an index names no vertex, for a value that is not a finite number, and for morph targets whose arrays do not fit the vertices or whose lists hold different numbers of targets. |
298
298
 
299
299
  ## `icosahedron`
300
300
 
@@ -302,7 +302,7 @@ Mesh generators with the parameters and defaults of three.js's geometry classes,
302
302
  function icosahedron(options: PolyhedronShapeOptions = {}): GeneratedArrays
303
303
  ```
304
304
 
305
- The arrays of an icosahedron, like three.js's `IcosahedronGeometry`. The mesh has no indices.
305
+ The arrays of an icosahedron. The mesh has no indices.
306
306
 
307
307
  ## `IntegerArray`
308
308
 
@@ -318,21 +318,67 @@ The integer typed arrays that vertex attributes take: 8-bit and 16-bit, signed a
318
318
  function lathe(options: LatheOptions = {}): GeneratedArrays
319
319
  ```
320
320
 
321
- The arrays of a lathe, like three.js's `LatheGeometry`. The mesh has indices.
321
+ The arrays of a lathe: a profile of points turned around the Y axis. The mesh has indices.
322
322
 
323
323
  ## `LatheOptions`
324
324
 
325
325
  Interface `LatheOptions`.
326
326
 
327
- Options for `lathe`, with the names and defaults of three.js's `LatheGeometry`.
327
+ Options for `lathe`.
328
328
 
329
329
  | Member | Description |
330
330
  | --- | --- |
331
- | `points?: readonly Vec2Like[]` | The profile: points (x, y), where x is the distance from the Y axis and must be 0 or more. The default is three.js's diamond: (0, -0.5), (0.5, 0) and (0, 0.5). |
331
+ | `points?: readonly Vec2Like[]` | The profile: points (x, y), where x is the distance from the Y axis and must be 0 or more. The default is a diamond: (0, -0.5), (0.5, 0) and (0, 0.5). |
332
332
  | `segments?: number` | The number of segments around the axis, rounded down. The default is 12. |
333
333
  | `phiStart?: number` | The start angle in radians. The default is 0. |
334
334
  | `phiLength?: number` | The angle the lathe turns through, in radians, clamped to 0 to 2π. The default is 2π. |
335
335
 
336
+ ## `LEAST_LEVEL_DISTANCE`
337
+
338
+ ```ts
339
+ const LEAST_LEVEL_DISTANCE: 0.001
340
+ ```
341
+
342
+ The smallest distance that the rule measures, in meters: a camera inside the bounds reads it.
343
+
344
+ ## `levelAt`
345
+
346
+ ```ts
347
+ function levelAt(view: LevelView, levels: readonly LevelSwitch[], scale: number, radius: number, distance: number | LevelDistances): number
348
+ ```
349
+
350
+ The level of detail that a source draws: 0 for the base mesh, 1 for the first lower level, and so on, as `setLevels` takes them. The level is the last one whose switch distance lies under the distance, which is how the core's culling picks every source. This gives the level alone, not whether the source draws at all: a bound that covers fewer pixels than the threshold is hidden, and a draw range hides a source outside it.
351
+
352
+ ## `LevelBounds`
353
+
354
+ Interface `LevelBounds`.
355
+
356
+ A source's world bounds about the camera: the centre of its bounding sphere relative to the camera, and the sphere's radius.
357
+
358
+ | Member | Description |
359
+ | --- | --- |
360
+ | `readonly centre: readonly [number, number, number]` | The bounding sphere's centre, relative to the camera. |
361
+ | `readonly radius: number` | The bounding sphere's radius, in meters. |
362
+
363
+ ## `levelDistances`
364
+
365
+ ```ts
366
+ function levelDistances(view: LevelView, bounds: LevelBounds): LevelDistances
367
+ ```
368
+
369
+ Both distances that a view's rule compares for a source's bounds. An error measures to a point halfway into the sphere, capped at twice the distance to its nearest point, so a camera beside a large mesh measures the surface below it. A distance or a coverage, and a distance band, measure to the nearest point. Both are at least `LEAST_LEVEL_DISTANCE`. An orthographic view compares an error at a distance of 1, since its pixels do not shrink with distance, and keeps the nearest point for the other measures.
370
+
371
+ ## `LevelDistances`
372
+
373
+ Interface `LevelDistances`.
374
+
375
+ The two distances that the rule compares for a source's bounds. A level given by its error reads `error`, and a level given by a distance or by a coverage, a draw range and the rule that hides a small bound read `camera`.
376
+
377
+ | Member | Description |
378
+ | --- | --- |
379
+ | `readonly camera: number` | The distance to the nearest point of the bounds, which a distance or a coverage compares. |
380
+ | `readonly error: number` | The distance at which an error is compared, which a level given by its error compares. |
381
+
336
382
  ## `LevelsOption`
337
383
 
338
384
  ```ts
@@ -341,11 +387,44 @@ type LevelsOption = boolean | BuildLevelsOptions | 'pieces';
341
387
 
342
388
  The levels of detail that a mesh made in code plans on its own. By default it plans them the first time the scene draws it, when it holds `geometry.automaticLevelTriangles` triangles or more, or when it holds at least `geometry.automaticCopyTriangles` triangles and its copies hold `geometry.automaticDrawnTriangles` together; `false` plans none, and `true` or options plan them when the mesh is made, at any size. `'pieces'` plans no lower levels, and sorts a mesh of 32,768 triangles or more into pieces by space at its first draw, as a merged far cell or a large ground whose levels come from elsewhere gains from.
343
389
 
390
+ ## `LevelSwitch`
391
+
392
+ ```ts
393
+ type LevelSwitch =
394
+ | { readonly error: number; }
395
+ | { readonly distance: number; }
396
+ | { readonly coverage: number; };
397
+ ```
398
+
399
+ One of a mesh's lower levels and the measure that sets its switch: give exactly one. The fields have the meanings that `MeshLevel` gives them.
400
+
401
+ ## `levelSwitchDistance`
402
+
403
+ ```ts
404
+ function levelSwitchDistance(view: LevelView, level: LevelSwitch, scale: number, radius = 0): number
405
+ ```
406
+
407
+ The distance at which one of a part's levels switches in. An error switches where it covers the view's threshold in pixels; a distance at its own figure, scaled by the source; and a coverage where the bounds' radius covers that share of the render height. A bias above 1 divides every result, so the level switches nearer.
408
+
409
+ ## `LevelView`
410
+
411
+ Interface `LevelView`.
412
+
413
+ A view that measures levels of detail: the height it renders, its vertical field of view, and the threshold under which a coarser level draws.
414
+
415
+ | Member | Description |
416
+ | --- | --- |
417
+ | `readonly height: number` | The render height in pixels. |
418
+ | `readonly fov: number` | The vertical field of view in degrees, between 0 and 180. |
419
+ | `readonly threshold?: number` | The largest change, in pixels, that a coarser level may make to the picture. The default is 1, the setting of the presets that High and above draw. A larger threshold draws coarser levels from nearer. |
420
+ | `readonly orthographic?: boolean` | True for an orthographic camera, whose pixels do not shrink with distance. The default is false. An orthographic view compares a level's error at a distance of 1, so the source's scale alone picks the level. |
421
+ | `readonly bias?: number` | The source's threshold bias, as Godot's `lod_bias`: above 1 switches every level nearer, so coarser levels draw, and below 1 keeps its detail. The default is 1. |
422
+
344
423
  ## `LineCurve`
345
424
 
346
425
  Class `LineCurve`, which extends `Curve`.
347
426
 
348
- A straight 2D line from `v1` to `v2`, like three.js's `LineCurve`.
427
+ A straight 2D line from `v1` to `v2`.
349
428
 
350
429
  | Member | Description |
351
430
  | --- | --- |
@@ -360,7 +439,7 @@ A straight 2D line from `v1` to `v2`, like three.js's `LineCurve`.
360
439
 
361
440
  Class `LineCurve3`, which extends `Curve`.
362
441
 
363
- A straight 3D line from `v1` to `v2`, like three.js's `LineCurve3`.
442
+ A straight 3D line from `v1` to `v2`.
364
443
 
365
444
  | Member | Description |
366
445
  | --- | --- |
@@ -375,22 +454,22 @@ A straight 3D line from `v1` to `v2`, like three.js's `LineCurve3`.
375
454
 
376
455
  Interface `MeshArrays`.
377
456
 
378
- The arrays of a mesh for `geometry.fromArrays`. Each array holds its values for vertex 0, then vertex 1, and so on, as three.js's `BufferGeometry` keeps its attributes. The engine copies them. An attribute can come as 32-bit floats, or as the 8-bit and 16-bit integers that glTF's `KHR_mesh_quantization` allows for it. The mesh keeps that type on the GPU. Smaller types take less memory and upload faster. Integer positions keep their own scale, so give the object the scale that turns them into meters, as a glTF node does. Meshes share GPU buffers with the meshes whose attributes have the same types.
457
+ The arrays of a mesh for `geometry.fromArrays`. Each array holds its values for vertex 0, then vertex 1, and so on. The engine copies them. An attribute can come as 32-bit floats, or as the 8-bit and 16-bit integers that glTF's `KHR_mesh_quantization` allows for it. The mesh keeps that type on the GPU. Smaller types take less memory and upload faster. Integer positions keep their own scale, so give the object the scale that turns them into meters, as a glTF node does. Meshes share GPU buffers with the meshes whose attributes have the same types.
379
458
 
380
459
  | Member | Description |
381
460
  | --- | --- |
382
- | `positions: VertexValues` | Three numbers per vertex: x, y and z. Like three.js's `position` attribute. Takes floats, or 8-bit or 16-bit integers, normalized or plain. |
383
- | `normals?: VertexValues` | Three numbers per vertex: a direction of length 1 away from the surface. Like three.js's `normal` attribute. Pass normals, or set `computeNormals` instead. Takes floats, or an `Int8Array` or `Int16Array`, whose integers read as fractions from -1 to 1. |
384
- | `uvs?: VertexValues` | Texture coordinates: two numbers per vertex, u and v. Like three.js's `uv` attribute. Takes floats, or 8-bit or 16-bit integers, normalized or plain. |
385
- | `uvs1?: VertexValues` | A second set of texture coordinates, two numbers per vertex, such as those of a light map. Like three.js's `uv1` attribute. Takes the same types as `uvs`. |
386
- | `colors?: VertexValues` | Linear colors, three numbers per vertex from 0 to 1, or four with alpha. Like three.js's `color` attribute. Takes floats, or a `Uint8Array` or `Uint16Array`, whose integers read as fractions from 0 to 1. |
387
- | `tangents?: VertexValues` | Four numbers per vertex: the direction in which u grows along the surface, then 1 or -1 for the direction in which v grows. Like three.js's `tangent` attribute. Takes the same types as `normals`. |
388
- | `joints?: VertexValues` | The joints that move each vertex of a skinned mesh: four joint indices per vertex, in a `Uint8Array`, a `Uint16Array` or a plain array. Like three.js's `skinIndex` attribute. Give `weights` with them. |
389
- | `weights?: VertexValues` | How much each of a vertex's four joints moves it: four numbers per vertex, which add up to 1. Like three.js's `skinWeight` attribute. Takes floats, or a `Uint8Array` or `Uint16Array`, whose integers read as fractions from 0 to 1. |
461
+ | `positions: VertexValues` | Three numbers per vertex: x, y and z. Takes floats, or 8-bit or 16-bit integers, normalized or plain. |
462
+ | `normals?: VertexValues` | Three numbers per vertex: a direction of length 1 away from the surface. Pass normals, or set `computeNormals` instead. Takes floats, or an `Int8Array` or `Int16Array`, whose integers read as fractions from -1 to 1. |
463
+ | `uvs?: VertexValues` | Texture coordinates: two numbers per vertex, u and v. Takes floats, or 8-bit or 16-bit integers, normalized or plain. |
464
+ | `uvs1?: VertexValues` | A second set of texture coordinates, two numbers per vertex, such as those of a light map. Takes the same types as `uvs`. |
465
+ | `colors?: VertexValues` | Linear colors, three numbers per vertex from 0 to 1, or four with alpha. Takes floats, or a `Uint8Array` or `Uint16Array`, whose integers read as fractions from 0 to 1. |
466
+ | `tangents?: VertexValues` | Four numbers per vertex: the direction in which u grows along the surface, then 1 or -1 for the direction in which v grows. Takes the same types as `normals`. |
467
+ | `joints?: VertexValues` | The joints that move each vertex of a skinned mesh: four joint indices per vertex, in a `Uint8Array`, a `Uint16Array` or a plain array. Give `weights` with them. |
468
+ | `weights?: VertexValues` | How much each of a vertex's four joints moves it: four numbers per vertex, which add up to 1. Takes floats, or a `Uint8Array` or `Uint16Array`, whose integers read as fractions from 0 to 1. |
390
469
  | `targets?: VertexValues` | Four numbers per vertex for a shape that a custom material moves between levels of detail: the position that the vertex takes at the next coarser level, and that level's error in meters. The material's `vertexOffset` reads them as `input.vertexRecord`. Takes floats. The vertex record also holds a morphed mesh's morph data, so a mesh takes `targets` or `morphTargets`, never both. |
391
- | `indices?: Uint16Array \| Uint32Array \| readonly number[]` | Three vertex indices per triangle, counter-clockwise when you look at its front. 16-bit and 32-bit indices both work. Without indices, each three vertices in a row make a triangle. Like three.js's `setIndex`. |
392
- | `computeNormals?: boolean` | Computes the normals from the triangles, as three.js's `computeVertexNormals` does: each vertex gets the average of its triangles' normals, weighted by their areas. |
393
- | `computeTangents?: boolean` | Computes the tangents from the positions, the normals and `uvs`, as three.js's `computeTangents` does, on the job workers. |
470
+ | `indices?: Uint16Array \| Uint32Array \| readonly number[]` | Three vertex indices per triangle, counter-clockwise when you look at its front. 16-bit and 32-bit indices both work. Without indices, each three vertices in a row make a triangle. |
471
+ | `computeNormals?: boolean` | Computes the normals from the triangles: each vertex gets the average of its triangles' normals, weighted by their areas. |
472
+ | `computeTangents?: boolean` | Computes the tangents on the job workers, from the positions, the normals and `uvs`, with Eric Lengyel's method. |
394
473
  | `morphTargets?: MorphTargets` | The mesh's morph targets: shapes that each object of the mesh blends in by its own weights. The engine keeps, for each vertex, only the targets that move it. |
395
474
  | `levels?: LevelsOption` | The levels of detail that the mesh plans on its own, on the job workers, as `mesh.buildLevels` plans them. By default it plans them the first time the scene draws it, when it holds `geometry.automaticLevelTriangles` triangles or more, or when it holds at least `geometry.automaticCopyTriangles` triangles and its copies hold `geometry.automaticDrawnTriangles` together. A mesh with joints, morph targets or `targets` plans none, and neither does one that lies flat or that a material with moving vertices draws. `false` plans none: give it to a mesh whose shape a shader moves, or whose levels you set by hand. `true` plans them when the mesh is made, at any size, and options such as `{ cards: true }` plan them with those options. `'pieces'` plans no levels, and sorts a mesh of 32,768 triangles or more into pieces by space at its first draw. |
396
475
 
@@ -404,12 +483,12 @@ A mesh the engine can draw: its id in the engine core, its bounding radius, and
404
483
  | --- | --- |
405
484
  | `readonly radius: number` | The distance from the mesh's bounding center (`center`) to its farthest vertex, at rest. |
406
485
  | `readonly morphTargets: number` | How many morph targets the mesh has. 0 for a mesh without any. |
407
- | `readonly morphTargetNames: readonly string[]` | The morph targets' names, by target, or none when the mesh's arrays named none. Like three.js's `morphTargetDictionary`, turned around. `mesh.setMorphWeight` takes a name too. |
486
+ | `readonly morphTargetNames: readonly string[]` | The morph targets' names, in target order, or none when the mesh's arrays named none. `mesh.setMorphWeight` takes a name too. |
408
487
  | `readonly center: readonly [number, number, number]` | The center of the box around the mesh's vertices at rest, in the mesh's own space. The mesh's bounding sphere lies around it with `radius`, and culling tests that sphere. A mesh whose positions start at a corner, as quantized glTF files store them, has its center away from the origin. |
409
- | `destroy(): void` | Destroys the mesh, like three.js's `geometry.dispose()`. The engine frees its GPU memory and its other data at once, and later meshes take its room. Destroy the objects and instance batches that use it first, in the same frame or before. Its lower levels go with it, since a level draws its base's vertices. Throws E1111 while one still uses it, and E1101 for a mesh that is destroyed already. Later calls that pass the mesh throw E1101. |
410
- | `updateVertices(name: UpdatableAttribute, values: Float32Array \| IntegerArray \| readonly number[], start = 0, count?: number): void` | Writes new values into one attribute of the mesh's vertices, like setting three.js's `attribute.needsUpdate` after a change. `values` holds the attribute's values of every vertex, in the array type the mesh was made with, as `geometry.fromArrays` takes them. Only vertices `start` to `start + count - 1` change, which the next frame uploads. The defaults update every vertex. Colors take three or four values per vertex: three keep each vertex's alpha. The mesh keeps the bounding sphere it was made with, so give objects that draw vertices outside it bounds with `setBounds`. The four-number vertex record takes updates as `targets`. Joints, weights, and a mesh with joints or morph targets take no updates. A level that draws its base mesh's vertices writes them, so the base and every level of it draw the new values. The levels that `buildLevels` or the automatic default planned measured the old shape, so the first update takes them away, and the mesh plans no automatic levels again; `buildLevels` plans them for the new shape. Throws E1206 for values that do not fit the mesh, and E1101 for a destroyed mesh. Allocates nothing, so a call in every frame makes no garbage. |
488
+ | `destroy(): void` | Destroys the mesh. The engine frees its GPU memory and its other data at once, and later meshes take its room. Destroy the objects and instance batches that use it first, in the same frame or before. Its lower levels go with it, since a level draws its base's vertices. Throws E1111 while one still uses it, and E1101 for a mesh that is destroyed already. Later calls that pass the mesh throw E1101. |
489
+ | `updateVertices(name: UpdatableAttribute, values: Float32Array \| IntegerArray \| readonly number[], start = 0, count?: number): void` | Writes new values into one attribute of the mesh's vertices. `values` holds the attribute's values of every vertex, in the array type the mesh was made with, as `geometry.fromArrays` takes them. Only vertices `start` to `start + count - 1` change, which the next frame uploads. The defaults update every vertex. Colors take three or four values per vertex: three keep each vertex's alpha. The mesh keeps the bounding sphere it was made with, so give objects that draw vertices outside it bounds with `setBounds`. The four-number vertex record takes updates as `targets`. Joints, weights, and a mesh with joints or morph targets take no updates. A level that draws its base mesh's vertices writes them, so the base and every level of it draw the new values. The levels that `buildLevels` or the automatic default planned measured the old shape, so the first update takes them away, and the mesh plans no automatic levels again; `buildLevels` plans them for the new shape. Throws E1206 for values that do not fit the mesh, and E1101 for a destroyed mesh. Allocates nothing, so a call in every frame makes no garbage. |
411
490
  | `readonly levels: readonly MeshLevel[]` | The mesh's lower levels of detail, from the most detailed down, as `setLevels` gave them. A destroyed level takes every level away, as the engine does. |
412
- | `setLevels(levels: readonly MeshLevel[], options: MeshLevelOptions = {}): void` | Gives the mesh lower levels of detail, from the most detailed down, like three.js's `LOD.addLevel`. A mesh takes at most 15 lower levels. Every object and instance batch that draws the mesh then picks one level per frame. It draws the coarsest level whose error covers fewer pixels on the screen than the `lodThreshold` quality setting. A level may name a material of its own, so a far level shades more cheaply; a level without one draws with the level before's material. A bound that covers fewer pixels than the threshold draws nothing, so the mesh's last level holds no geometry. The shadow maps pick their own levels, by each map's texel size, so a caster's shadow shows the detail that the map can hold. An empty list takes the levels away. Morphed objects, and materials that blend or let light through, draw the base mesh. A skinned object draws a level while the level names the base mesh's own vertices. Destroying a level's mesh takes every level away. Levels set here win over the ones that `buildLevels` or the automatic default plans: a plan that runs ends, and the planned levels go. Throws E1221 for levels the mesh cannot take, and E1101 for a destroyed mesh. |
491
+ | `setLevels(levels: readonly MeshLevel[], options: MeshLevelOptions = {}): void` | Gives the mesh lower levels of detail, from the most detailed down. A mesh takes at most 15 lower levels. Every object and instance batch that draws the mesh then picks one level per frame. It draws the coarsest level whose error covers fewer pixels on the screen than the `lodThreshold` quality setting. A level may name a material of its own, so a far level shades more cheaply; a level without one draws with the level before's material. A bound that covers fewer pixels than the threshold draws nothing, so the mesh's last level holds no geometry. The shadow maps pick their own levels, by each map's texel size, so a caster's shadow shows the detail that the map can hold. An empty list takes the levels away. Morphed objects, and materials that blend or let light through, draw the base mesh. A skinned object draws a level while the level names the base mesh's own vertices. Destroying a level's mesh takes every level away. Levels set here win over the ones that `buildLevels` or the automatic default plans: a plan that runs ends, and the planned levels go. Throws E1221 for levels the mesh cannot take, and E1101 for a destroyed mesh. |
413
492
  | `buildLevels(options: BuildLevelsOptions = {}): Promise<readonly MeshLevel[]>` | Plans the mesh's levels of detail on the job workers, as the asset tool's `--lod` plans a file's, and gives them to the mesh when they arrive, between two frames. Each level about halves the triangles of the level above, down to a few dozen, and stores the largest distance between its surface and the mesh's as its error, so it switches in at once where that distance covers less than the `lodThreshold` setting's pixels. The levels name the mesh's own vertices, in their own order, so they cost indices alone: the mesh keeps its vertices and triangles as they are. A mesh that the engine split into parts, past 65,535 vertices, shares them part by part, and copies only the vertices of the triangles that cross from one part to another. A large mesh spreads the work over frames. The engine reads one part of it in each frame for the plan. It makes one level in each frame when the plan is done, and gives the scene the whole set once, so the scene's draw tables rebuild once. The mesh draws its full shape until the levels arrive, and every object and instance batch that draws it then picks its level. The mesh and each level of 32,768 triangles or more also get 8 to 16 pieces, which each copy skips where they lie outside the view or face away. A smaller list that many copies draw gets a piece for each way it faces where its triangles face a few ways, as a building's walls do. A mesh that one object draws, or a smaller mesh, gets its own pieces over a sorted copy of its indices, in the frame after the last level; copies of a large mesh keep their levels' pieces alone. A mesh made in code plans its levels on its own the first time the scene draws it, when it holds `geometry.automaticLevelTriangles` triangles or more, or when it holds at least `geometry.automaticCopyTriangles` triangles and its copies hold `geometry.automaticDrawnTriangles` together. Call this to plan another mesh's, to plan again after `updateVertices`, or to await the levels of a plan that runs: a call while a plan with the same options runs returns that plan's promise. `setLevels` wins over a plan, and `updateVertices` takes the planned levels away. The promise resolves with the mesh's levels, which stay as they were when the planner finds no level worth making, and when `setLevels`, `updateVertices` or `destroy` ends the plan first. It rejects with E1221 for a mesh with joints, morph targets or a vertex record, whose shape poses or moves, and with E1406 when the planner does not download. The planner downloads with the first mesh that plans: meshoptimizer's simplifier, about 23 KB. Throws E1101 for a destroyed mesh. |
414
493
 
415
494
  ## `MeshLevel`
@@ -436,20 +515,20 @@ Options for `mesh.setLevels`.
436
515
  | Member | Description |
437
516
  | --- | --- |
438
517
  | `fade?: boolean` | True to hand over between two levels in a short band past each switch distance, where a dither pattern shares the pixels between them, so a switch does not pop. False to switch at once. The default is true. A level's own `fade` overrides it. A level with a measured error fades too once the governor raises the threshold above about one and a half pixels, where its switch shows. |
439
- | `fov?: number` | The vertical field of view, in degrees, that checks the order of the levels when the mesh takes them. Each frame compares a level's error or coverage with the field of view of the view that draws it, so this option moves no switch. The default is 50, three.js's default for a perspective camera. |
518
+ | `fov?: number` | The vertical field of view, in degrees, that checks the order of the levels when the mesh takes them. Each frame compares a level's error or coverage with the field of view of the view that draws it, so this option moves no switch. The default is 50, a perspective camera's default. |
440
519
 
441
520
  ## `MorphTargets`
442
521
 
443
522
  Interface `MorphTargets`.
444
523
 
445
- A mesh's morph targets, like three.js's `morphAttributes` with `morphTargetsRelative` set, as glTF stores them. Each list holds one array per target, of three numbers per vertex, or for colors as many as the mesh's `colors` hold. They say how far the target moves the vertex's position, normal, tangent or color at weight 1. Every list has the same number of targets, from 1 to 256. A mesh's targets move its vertices by their weights, which each object sets with `setMorphWeight`, and clips animate.
524
+ A mesh's morph targets, as glTF stores them. Each list holds one array per target, of three numbers per vertex, or for colors as many as the mesh's `colors` hold. They say how far the target moves the vertex's position, normal, tangent or color at weight 1. Every list has the same number of targets, from 1 to 256. A mesh's targets move its vertices by their weights, which each object sets with `setMorphWeight`, and clips animate.
446
525
 
447
526
  | Member | Description |
448
527
  | --- | --- |
449
- | `positions?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it moves each position. Like `morphAttributes.position`. |
450
- | `normals?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it turns each normal. Like `morphAttributes.normal`. |
451
- | `tangents?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it turns each tangent's direction: three numbers per vertex, as glTF gives them. three.js does not morph tangents. |
452
- | `colors?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it changes each vertex color: three or four numbers per vertex, as many as the mesh's `colors` hold, in linear color. Like `morphAttributes.color`. A morphed color is clamped to the range 0 to 1, as the glTF specification asks. Needs `colors`. |
528
+ | `positions?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it moves each position. |
529
+ | `normals?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it turns each normal. |
530
+ | `tangents?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it turns each tangent's direction: three numbers per vertex, as glTF gives them. |
531
+ | `colors?: readonly (Float32Array \| readonly number[])[]` | For each target, how far it changes each vertex color: three or four numbers per vertex, as many as the mesh's `colors` hold, in linear color. A morphed color is clamped to the range 0 to 1, as the glTF specification asks. Needs `colors`. |
453
532
  | `names?: readonly string[]` | The targets' names, one per target, which `setMorphWeight` takes in place of numbers. |
454
533
 
455
534
  ## `octahedron`
@@ -458,13 +537,13 @@ A mesh's morph targets, like three.js's `morphAttributes` with `morphTargetsRela
458
537
  function octahedron(options: PolyhedronShapeOptions = {}): GeneratedArrays
459
538
  ```
460
539
 
461
- The arrays of an octahedron, like three.js's `OctahedronGeometry`. The mesh has no indices.
540
+ The arrays of an octahedron. The mesh has no indices.
462
541
 
463
542
  ## `Path`
464
543
 
465
544
  Class `Path`, which extends `CurvePath`.
466
545
 
467
- A 2D path drawn with commands like a canvas's, such as `moveTo`, `lineTo` and `bezierCurveTo`, like three.js's `Path`. Each command adds a curve that starts at the current point.
546
+ A 2D path drawn with commands like a canvas's, such as `moveTo`, `lineTo` and `bezierCurveTo`. Each command adds a curve that starts at the current point.
468
547
 
469
548
  | Member | Description |
470
549
  | --- | --- |
@@ -499,13 +578,13 @@ Options for `geometry.plane`. The plane lies in the XY plane, centered on its or
499
578
  function polyhedron(options: PolyhedronOptions = {}): GeneratedArrays
500
579
  ```
501
580
 
502
- The arrays of a polyhedron, like three.js's `PolyhedronGeometry`. The mesh has no indices: each three vertices in a row make a triangle.
581
+ The arrays of a polyhedron from your own corners and faces, with its vertices on a sphere. The mesh has no indices: each three vertices in a row make a triangle.
503
582
 
504
583
  ## `PolyhedronOptions`
505
584
 
506
585
  Interface `PolyhedronOptions`.
507
586
 
508
- Options for `polyhedron`, with the names and defaults of three.js's `PolyhedronGeometry`.
587
+ Options for `polyhedron`.
509
588
 
510
589
  | Member | Description |
511
590
  | --- | --- |
@@ -518,7 +597,7 @@ Options for `polyhedron`, with the names and defaults of three.js's `PolyhedronG
518
597
 
519
598
  Interface `PolyhedronShapeOptions`.
520
599
 
521
- Options for the named polyhedra, such as `icosahedron`, with three.js's names and defaults.
600
+ Options for the named polyhedra, such as `icosahedron`.
522
601
 
523
602
  | Member | Description |
524
603
  | --- | --- |
@@ -529,7 +608,7 @@ Options for the named polyhedra, such as `icosahedron`, with three.js's names an
529
608
 
530
609
  Class `QuadraticBezierCurve`, which extends `Curve`.
531
610
 
532
- A 2D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point `v1`, like three.js's `QuadraticBezierCurve`.
611
+ A 2D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point `v1`.
533
612
 
534
613
  | Member | Description |
535
614
  | --- | --- |
@@ -542,7 +621,7 @@ A 2D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point
542
621
 
543
622
  Class `QuadraticBezierCurve3`, which extends `Curve`.
544
623
 
545
- A 3D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point `v1`, like three.js's `QuadraticBezierCurve3`.
624
+ A 3D quadratic Bézier curve from `v0` to `v2`, pulled toward the control point `v1`.
546
625
 
547
626
  | Member | Description |
548
627
  | --- | --- |
@@ -572,13 +651,13 @@ Options for `geometry.ring`: a flat disc with a hole. The ring lies in the XY pl
572
651
  function shape(options: ShapeOptions = {}): GeneratedArrays
573
652
  ```
574
653
 
575
- The arrays of flat shapes, like three.js's `ShapeGeometry`. The mesh has indices, and all its normals point along +Z. three.js gives each shape of a list a group of its own. Here the shapes form one mesh, so a material per shape needs one `shape` call per shape.
654
+ The arrays of flat shapes. The mesh has indices, and all its normals point along +Z. The shapes of a list form one mesh, so a material per shape needs one `shape` call per shape.
576
655
 
577
656
  ## `Shape`
578
657
 
579
658
  Class `Shape`, which extends `Path`.
580
659
 
581
- A closed 2D outline with optional holes, like three.js's `Shape`. The `shape` and `extrude` generators fill it.
660
+ A closed 2D outline with optional holes. The `shape` and `extrude` generators fill it.
582
661
 
583
662
  | Member | Description |
584
663
  | --- | --- |
@@ -600,24 +679,24 @@ The levels of detail that a generator's mesh plans on its own, as `MeshArrays.le
600
679
 
601
680
  Interface `ShapeOptions`.
602
681
 
603
- Options for `shape`, with the names and defaults of three.js's `ShapeGeometry`.
682
+ Options for `shape`.
604
683
 
605
684
  | Member | Description |
606
685
  | --- | --- |
607
- | `shapes?: Shape \| readonly Shape[]` | One shape or a list of shapes. The default is three.js's triangle with corners (0, 0.5), (-0.5, -0.5) and (0.5, -0.5). |
686
+ | `shapes?: Shape \| readonly Shape[]` | One shape or a list of shapes. The default is a triangle with corners (0, 0.5), (-0.5, -0.5) and (0.5, -0.5). |
608
687
  | `curveSegments?: number` | The number of points along each curve of a shape. The default is 12. |
609
688
 
610
689
  ## `ShapeUtils`
611
690
 
612
691
  Namespace `ShapeUtils`.
613
692
 
614
- Helpers for 2D outlines, like three.js's `ShapeUtils`: `ShapeUtils.area`, `ShapeUtils.isClockWise` and `ShapeUtils.triangulateShape`.
693
+ Helpers for 2D outlines: `ShapeUtils.area`, `ShapeUtils.isClockWise` and `ShapeUtils.triangulateShape`.
615
694
 
616
695
  | Member | Description |
617
696
  | --- | --- |
618
697
  | `area(contour: readonly Vec2Like[]): number` | The signed area of a closed outline. It is negative when the points run clockwise. |
619
698
  | `isClockWise(pts: readonly Vec2Like[]): boolean` | True when the points of a closed outline run clockwise. |
620
- | `triangulateShape(contour: Vec2Like[], holes: Vec2Like[][]): [number, number, number][]` | Cuts an outline with holes into triangles. It returns three point indices per triangle. The outline's points come first, then each hole's in turn. When the last point of a list repeats its first, it removes that last point, as three.js does. So the lists it takes can shrink. |
699
+ | `triangulateShape(contour: Vec2Like[], holes: Vec2Like[][]): [number, number, number][]` | Cuts an outline with holes into triangles. It returns three point indices per triangle. The outline's points come first, then each hole's in turn. When the last point of a list repeats its first, it removes that last point. So the lists it takes can shrink. |
621
700
 
622
701
  ## `SphereOptions`
623
702
 
@@ -639,7 +718,7 @@ Options for `geometry.sphere`. The sphere is centered on its origin, with its po
639
718
 
640
719
  Class `SplineCurve`, which extends `Curve`.
641
720
 
642
- A smooth 2D curve through a list of points, like three.js's `SplineCurve`. It uses Catmull-Rom interpolation.
721
+ A smooth 2D curve through a list of points. It uses Catmull-Rom interpolation.
643
722
 
644
723
  | Member | Description |
645
724
  | --- | --- |
@@ -652,7 +731,7 @@ A smooth 2D curve through a list of points, like three.js's `SplineCurve`. It us
652
731
  function tetrahedron(options: PolyhedronShapeOptions = {}): GeneratedArrays
653
732
  ```
654
733
 
655
- The arrays of a tetrahedron, like three.js's `TetrahedronGeometry`. The mesh has no indices.
734
+ The arrays of a tetrahedron. The mesh has no indices.
656
735
 
657
736
  ## `torusKnot`
658
737
 
@@ -660,13 +739,13 @@ The arrays of a tetrahedron, like three.js's `TetrahedronGeometry`. The mesh has
660
739
  function torusKnot(options: TorusKnotOptions = {}): GeneratedArrays
661
740
  ```
662
741
 
663
- The arrays of a torus knot, like three.js's `TorusKnotGeometry`. The mesh has indices.
742
+ The arrays of a torus knot: a tube that winds around a torus. The mesh has indices.
664
743
 
665
744
  ## `TorusKnotOptions`
666
745
 
667
746
  Interface `TorusKnotOptions`.
668
747
 
669
- Options for `torusKnot`, with the names and defaults of three.js's `TorusKnotGeometry`.
748
+ Options for `torusKnot`.
670
749
 
671
750
  | Member | Description |
672
751
  | --- | --- |
@@ -699,17 +778,17 @@ Options for `geometry.torus`. The torus is centered on its origin, around the Z
699
778
  function tube(options: TubeOptions = {}): GeneratedArrays
700
779
  ```
701
780
 
702
- The arrays of a tube, like three.js's `TubeGeometry`. The mesh has indices.
781
+ The arrays of a tube along a 3D curve. The mesh has indices.
703
782
 
704
783
  ## `TubeOptions`
705
784
 
706
785
  Interface `TubeOptions`.
707
786
 
708
- Options for `tube`, with the names and defaults of three.js's `TubeGeometry`.
787
+ Options for `tube`.
709
788
 
710
789
  | Member | Description |
711
790
  | --- | --- |
712
- | `path?: Curve<[number, number, number]>` | The 3D curve that the tube follows. The default is three.js's quadratic Bézier curve from (-1, -1, 0) through the control point (-1, 1, 0) to (1, 1, 0). |
791
+ | `path?: Curve<[number, number, number]>` | The 3D curve that the tube follows. The default is a quadratic Bézier curve from (-1, -1, 0) through the control point (-1, 1, 0) to (1, 1, 0). |
713
792
  | `tubularSegments?: number` | The number of segments along the curve. The default is 64. |
714
793
  | `radius?: number` | The radius of the tube. The default is 1. |
715
794
  | `radialSegments?: number` | The number of segments around the tube. The default is 8. |
@@ -734,7 +813,7 @@ The vertex attributes that `mesh.updateVertices` writes, by their names in `Mesh
734
813
 
735
814
  Interface `UVGenerator`.
736
815
 
737
- Makes the texture coordinates of an extrusion's triangles, like the `UVGenerator` option of three.js's `ExtrudeGeometry`. Each method gets the positions made so far, three numbers per vertex, and the vertex numbers of one triangle or one side quad. three.js's methods also take the geometry first. These do not, as there is no geometry object.
816
+ Makes the texture coordinates of an extrusion's triangles, for the `UVGenerator` option of `extrude`. Each method gets the positions made so far, three numbers per vertex, and the vertex numbers of one triangle or one side quad.
738
817
 
739
818
  | Member | Description |
740
819
  | --- | --- |
@@ -747,18 +826,18 @@ Makes the texture coordinates of an extrusion's triangles, like the `UVGenerator
747
826
  type Vec2Like = { [index: number]: number; };
748
827
  ```
749
828
 
750
- A 2D vector (x, y) in an array: a tuple such as `[0, 1]`, a plain array or a typed array. Where three.js takes a `Vector2`, this package takes one of these and reads its first two elements.
829
+ A 2D vector (x, y) in an array: a tuple such as `[0, 1]`, a plain array or a typed array. The package reads its first two elements.
751
830
 
752
831
  ## `VertexArray`
753
832
 
754
833
  Interface `VertexArray`.
755
834
 
756
- One attribute's numbers with a note on how its integers read, like three.js's `BufferAttribute`, whose `array` and `normalized` fields it shares. Normalized integers read as fractions: from 0 to 1 when unsigned, and from -1 to 1 when signed. Plain integers read as whole numbers.
835
+ One attribute's numbers with a note on how its integers read. Normalized integers read as fractions: from 0 to 1 when unsigned, and from -1 to 1 when signed. Plain integers read as whole numbers.
757
836
 
758
837
  | Member | Description |
759
838
  | --- | --- |
760
839
  | `array: Float32Array \| IntegerArray \| readonly number[]` | The numbers, as `MeshArrays` takes them. |
761
- | `normalized?: boolean` | True when the integers are normalized. The default is false, as in three.js and glTF. It applies to positions and texture coordinates. The other attributes read integers one way only, so they refuse a value that says otherwise. |
840
+ | `normalized?: boolean` | True when the integers are normalized. The default is false, as in glTF. It applies to positions and texture coordinates. The other attributes read integers one way only, so they refuse a value that says otherwise. |
762
841
 
763
842
  ## `VertexValues`
764
843
 
@@ -774,4 +853,4 @@ The numbers of one vertex attribute: a typed array, a plain array of numbers, or
774
853
  const WorldUVGenerator: UVGenerator
775
854
  ```
776
855
 
777
- three.js's default texture coordinates for an extrusion. A cap vertex takes its x and y. A side wall vertex takes its x or its y, whichever changes more along the wall, and 1 minus its z.
856
+ The default texture coordinates for an extrusion. A cap vertex takes its x and y. A side wall vertex takes its x or its y, whichever changes more along the wall, and 1 minus its z.
@@ -79,7 +79,7 @@ What `createGrass` takes: the ground, the area, the count at the High preset, an
79
79
  | `readonly blades?: number` | The blades in each tuft. The default is 13. |
80
80
  | `readonly segments?: number` | The segments of each blade. The default is 3. |
81
81
  | `readonly shapes?: number` | The shapes of tuft, each one draw. The default is 1. |
82
- | `readonly where?: (x: number, z: number) => boolean` | Says whether grass grows at a point, for ground that holds a road or a wall. Without it, grass grows everywhere. |
82
+ | `readonly where?: (x: number, z: number) => boolean` | Says whether grass grows at a point, as `mask` does, for ground that holds a road or a wall. A tuft grows only where both allow it. Without either, the slope alone decides. |
83
83
  | `readonly color?: string` | The blades' color, which meets the ground's own at their roots. The default is a fresh green. |
84
84
  | `readonly blade?: GrassBladeShape` | The shape that every blade takes: its width along its length and the fold of its keel. Give a plant's own blade with the plant's own color, so the cover reads as the same grass where the plant stands in it. Without it each blade narrows to a point from its root. |
85
85
  | `readonly maxSlope?: number` | The steepest ground that a tuft grows on, as rise over run. The default is 0.6. |