@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
@@ -93,13 +93,81 @@ function frameDirection(frame: number, atlas: OctahedralAtlas, out: [number, num
93
93
 
94
94
  The direction that the view of a cell was drawn from: the center of the octahedron's cell, as a unit direction. `impostorFrame` of the result gives `frame` again.
95
95
 
96
+ ## `HAND_OVER_GROUPS`
97
+
98
+ ```ts
99
+ const HAND_OVER_GROUPS: 4
100
+ ```
101
+
102
+ The groups that a plant's trees hand over in, and how far either side of the plant's switch distance the groups' switches spread, as a share of it. The groups are what keeps one frame from taking every tree's mesh at once: a tree's own swap is as it was, but the trees around it swap a little before or after it, so a view loses one group's cards a frame instead of all of them.
103
+
104
+ ## `HAND_OVER_SPREAD`
105
+
106
+ ```ts
107
+ const HAND_OVER_SPREAD: 0.06
108
+ ```
109
+
110
+ The share of the hand-over distance that the groups' switches spread either side of it, so the first group swaps a little early and the last a little late and the change is spread over a short stretch of travel rather than landing in one frame.
111
+
112
+ ## `handOverCards`
113
+
114
+ ```ts
115
+ function handOverCards(cards: InstanceBatch, earliestSwitch: number): void
116
+ ```
117
+
118
+ Starts a batch of cards early enough that they stand at full coverage before the earliest mesh group that hands over to them begins to thin. Write the cards' turns and sizes before this call.
119
+
120
+ ## `handOverMeshes`
121
+
122
+ ```ts
123
+ function handOverMeshes(meshes: InstanceBatch, switchDistance: number, start = 0): void
124
+ ```
125
+
126
+ Draws a group of near meshes from `start` up to its switch distance, where the engine dithers the range's far edge out.
127
+
128
+ ## `handOverSwitches`
129
+
130
+ ```ts
131
+ function handOverSwitches(switchDistance: number, count = HAND_OVER_GROUPS, spread = HAND_OVER_SPREAD): number[]
132
+ ```
133
+
134
+ The switch distances of `count` groups, spread evenly either side of `switchDistance`: the first group hands over earliest and the last latest, and their mean is the switch distance itself. A group draws its meshes up to its own distance, so a camera crossing the plant's hand-over meets one group's switch after another.
135
+
96
136
  ## `handOverToCards`
97
137
 
98
138
  ```ts
99
139
  function handOverToCards(meshes: InstanceBatch, cards: InstanceBatch, switchDistance: number, start = 0): void
100
140
  ```
101
141
 
102
- Hands a batch of near meshes over to their far cards. The meshes draw up to `switchDistance`, and the engine dithers the last few per cent of that range out. The cards start early enough that their own dithered edge ends before the meshes' edge begins to thin. So each pixel that a mesh drops shows its card at full coverage, and the background never shows through. Write the cards' turns and sizes before this call, and call it at setup.
142
+ Hands one group of near meshes over to its far cards. The meshes draw up to `switchDistance`, and the cards start early enough that their own dithered edge ends before the meshes' edge begins to thin. So each pixel that a mesh drops shows its card at full coverage, and the background never shows through. Write the cards' turns and sizes before this call, and call it at setup. A plant that hands over in groups calls `handOverCards` once with the earliest group's switch, so the cards stand behind every group, and `handOverMeshes` once for each group's own distance.
143
+
144
+ ## `IMPOSTOR_FILE_FORMAT`
145
+
146
+ ```ts
147
+ const IMPOSTOR_FILE_FORMAT: 'null3d-impostor'
148
+ ```
149
+
150
+ The `format` field of an impostor atlas file.
151
+
152
+ ## `ImpostorAtlasFile`
153
+
154
+ Interface `ImpostorAtlasFile`.
155
+
156
+ What an impostor atlas file holds: the bake's grid and figures, and the names of its two images.
157
+
158
+ | Member | Description |
159
+ | --- | --- |
160
+ | `readonly format: typeof IMPOSTOR_FILE_FORMAT` | Always `"null3d-impostor"`. |
161
+ | `readonly version: number` | The format's version: 1. |
162
+ | `readonly atlas: OctahedralAtlas` | The cells across and down. |
163
+ | `readonly texels: number` | The texels on each side of a cell. |
164
+ | `readonly color: string` | The colour atlas's PNG file, next to this file: sRGB colour, with the coverage in alpha. |
165
+ | `readonly surface: string` | The surface atlas's PNG file, next to this file: linear normals, depth and coverage. |
166
+ | `readonly size: readonly [number, number]` | The card's width and height at scale 1, as the bake's `size`. |
167
+ | `readonly room: number` | How much taller a view's picture is than the card's height, as the bake's `room`. |
168
+ | `readonly depth: number` | The object's depth along a view, in world units, as the bake's `depth`. |
169
+ | `readonly min: readonly [number, number, number]` | The object's bounds in its own frame: the smallest corner. |
170
+ | `readonly max: readonly [number, number, number]` | The object's bounds in its own frame: the largest corner. |
103
171
 
104
172
  ## `ImpostorBake`
105
173
 
@@ -225,6 +293,29 @@ Options of `createImpostors`: the atlases, the cards and their look.
225
293
  | `readonly receiveShadows?: boolean` | True makes the shadows of other objects fall on the cards. The default is false. |
226
294
  | `readonly castsStill?: boolean` | True keeps the cards' casters in place while the sun stands still, so a far shadow cascade stays cached. The default is true, which suits a card that turns to the eye of each pass. A scene that turns a card whose batch casts from frame to frame moves its caster while the light stands still, and the far cascades then keep a stale shadow: pass false for such a scene. |
227
295
 
296
+ ## `LoadedImpostorAtlas`
297
+
298
+ Interface `LoadedImpostorAtlas`.
299
+
300
+ A baked atlas that `loadImpostorAtlas` loaded: the fields that `createImpostors` takes from a bake, so a sketch spreads it into the options.
301
+
302
+ | Member | Description |
303
+ | --- | --- |
304
+ | `readonly color: Texture` | The colour atlas, in sRGB, with no mipmaps. |
305
+ | `readonly surface: Texture` | The surface atlas, linear, with no mipmaps. |
306
+ | `readonly atlas: OctahedralAtlas` | The cells across and down. |
307
+ | `readonly size: readonly [number, number]` | The card's width and height at scale 1. |
308
+ | `readonly room: number` | How much taller a view's picture is than the card's height. |
309
+ | `readonly depth: number` | The object's depth along a view, in world units. |
310
+
311
+ ## `loadImpostorAtlas`
312
+
313
+ ```ts
314
+ function loadImpostorAtlas(assets: Pick<Assets, 'loadJson' | 'loadTexture'>, url: string | URL): Promise<LoadedImpostorAtlas>
315
+ ```
316
+
317
+ Loads an impostor atlas file that `bunx @null3d/cli assets impostor` wrote, with its two images. The images load from the JSON file's folder. The result holds the fields that `createImpostors` takes from a bake: ```ts const pine = await loadImpostorAtlas(assets, 'pine-impostor.json'); const trees = createImpostors({ scene, materials, geometry }, { ...pine, positions, alphaMode: 'mask' }); ```
318
+
228
319
  ## `mergeFarGeometry`
229
320
 
230
321
  ```ts
@@ -53,7 +53,7 @@ The main pointer: the mouse, a pen, or the first finger that touches the canvas.
53
53
  | `readonly dy: number` | Movement down since the previous frame, in CSS pixels. |
54
54
  | `readonly dragDx: number` | The part of `dx` made while a button was held: a drag. Movement before a press or after a release in the same frame does not count. |
55
55
  | `readonly dragDy: number` | The part of `dy` made while a button was held: a drag. |
56
- | `readonly wheel: number` | The wheel's scroll since the previous frame, in pixels: positive where a page would scroll down. A wheel that scrolls by lines counts 16 pixels a line, and one that scrolls by pages counts 100 a page, as three.js's controls count them. Scroll that follows a release of the pointer waits for the next frame, so a frame's scroll never comes after the end of its drag. |
56
+ | `readonly wheel: number` | The wheel's scroll since the previous frame, in pixels: positive where a page would scroll down. A wheel that scrolls by lines counts 16 pixels a line, and one that scrolls by pages counts 100 a page. Scroll that follows a release of the pointer waits for the next frame, so a frame's scroll never comes after the end of its drag. |
57
57
  | `readonly pinch: number` | The part of `wheel` that came from a pinch on a trackpad: positive as the fingers close. Browsers send a pinch as wheel scroll that holds the Control key's flag while no Control key is down. |
58
58
  | `readonly isTouch: boolean` | True when the pointer is a finger on a touch screen. |
59
59
  | `readonly locked: boolean` | True while the canvas holds the pointer lock, which `engine.requestPointerLock()` asks for on the page. The browser then hides the pointer and keeps it still: `x` and `y` stay where the lock began, `dx` and `dy` give the mouse's movement, and objects take no pointer events. |
@@ -108,8 +108,8 @@ A pointer event on an object, which the handlers of `object.on` take. The engine
108
108
  | `readonly point: Vec3Like` | Where the ray hits `object`, in world space. |
109
109
  | `readonly normal: Vec3Like` | The unit normal of the hit triangle in world space, on the side that faces the camera. A hit on a sprite or a point faces the camera; on a line, it points back along the ray. |
110
110
  | `readonly distance: number` | The distance from the ray's origin to the hit, in meters. |
111
- | `readonly triangle: number` | The index of the hit triangle in its mesh, as three.js's `faceIndex`, or -1 for a sprite, a point or a line. |
112
- | `readonly uv: Vec2Like` | Where on the surface the ray hit, as the first texture coordinates of the hit triangle blended across its three corners, as three.js's `intersection.uv`. Read `hasUv` first: the numbers mean nothing when it is false. An in-world screen turns a click into a texel of its image with these, without working out where the surface lies in space. |
111
+ | `readonly triangle: number` | The index of the hit triangle in its mesh, or -1 for a sprite, a point or a line. |
112
+ | `readonly uv: Vec2Like` | Where on the surface the ray hit, as the first texture coordinates of the hit triangle blended across its three corners. Read `hasUv` first: the numbers mean nothing when it is false. An in-world screen turns a click into a texel of its image with these, without working out where the surface lies in space. |
113
113
  | `readonly hasUv: boolean` | True when the hit triangle's mesh has a first texture coordinate set, so `uv` holds where on the surface the ray hit. False for a hit on a sprite, a point or a line, and for a mesh with no such coordinates. |
114
114
  | `readonly ray: Ray` | The ray from the camera through the pointer, from the frame that was on screen at the event. |
115
115
  | `readonly x: number` | The pointer's distance from the canvas's left edge in CSS pixels. |
@@ -24,7 +24,7 @@ Options for `scene.createAmbientLight`.
24
24
 
25
25
  | Member | Description |
26
26
  | --- | --- |
27
- | `intensityUnit?: 'lux'` | The unit of the intensity: `'lux'`, the light that reaches every surface. It is three.js's unit too, so the intensity stays as it is. |
27
+ | `intensityUnit?: 'lux'` | The unit of the intensity: `'lux'`, the light that reaches every surface. The intensity is in lux already, so it stays as it is. |
28
28
 
29
29
  ## `DirectionalLight`
30
30
 
@@ -47,7 +47,7 @@ Options for `scene.createDirectionalLight`.
47
47
 
48
48
  | Member | Description |
49
49
  | --- | --- |
50
- | `intensityUnit?: 'lux'` | The unit of the intensity: `'lux'`, the light that reaches a surface facing the light, such as 100,000 for direct sunlight. It is three.js's unit too, so the intensity stays as it is. |
50
+ | `intensityUnit?: 'lux'` | The unit of the intensity: `'lux'`, the light that reaches a surface facing the light, such as 100,000 for direct sunlight. The intensity is in lux already, so it stays as it is. |
51
51
  | `direction?: Vec3` | The direction the light travels, relative to the parent. The default, (0, -1, 0), points straight down. It sets the light's rotation, so it wins over `rotation`. |
52
52
  | `castShadows?: boolean` | True makes the light cast shadows, like `setCastShadows(true)`. The default is false. The first directional light created casts them. |
53
53
  | `shadow?: DirectionalShadowOptions` | How the light's shadows draw, like `setShadow`. Each setting has a default. |
@@ -68,7 +68,7 @@ The shadows of a directional light. The camera's view splits into cascades by di
68
68
  | `contactDistance?: number` | How far contact shadows reach from each surface toward the light, in meters, at least 0. They are short shadows found in the camera's depth, which show where small objects touch the ground: stones, feet, wheels, crates. 0 turns them off for this light. The quality preset's `contactShadowSteps` decides whether they draw. The default is 0.3. |
69
69
  | `hero?: Object3D \| null` | An object whose shadow the light draws into a tile of its own, at a much finer scale than the cascades, or `null` for none. The tile fits the object's bounds along the light, and surfaces near the object read it in place of the coarser cascades, so a car, a character or a product keeps a sharp shadow. The object must cast shadows. The tile takes a layer of the shadow atlas, which the point and spot lights share, and every layer of the atlas takes the tile's size. The default is none. |
70
70
  | `heroTileSize?: 1024 \| 2048 \| 4096` | Texels on each side of the hero's tile: 1,024, 2,048 or 4,096. The default is the quality preset's `heroTileSize`. The tile's texels are finer as the number grows. A larger object needs a larger number to keep the ratio of its shadow's detail to the cascades'. The atlas holds the tile, so a larger number takes more memory for every tile of the atlas, and a hero that moves draws the larger tile again in every frame. |
71
- | `intensity?: number` | How much of the light's shadow it draws, from 0 for none to 1, the default, for all of it. The shader mixes each shadow lookup toward full light by the rest, as three.js's `LightShadow.intensity` does. |
71
+ | `intensity?: number` | How much of the light's shadow it draws, from 0 for none to 1, the default, for all of it. The shader mixes each shadow lookup toward full light by the rest, so a change needs no new shader. |
72
72
 
73
73
  ## `HemisphereLight`
74
74
 
@@ -91,7 +91,7 @@ Options for `scene.createHemisphereLight`.
91
91
  | `skyColor?: ColorInput` | The color of the light from above. The default is white. |
92
92
  | `groundColor?: ColorInput` | The color of the light from below. The default is white. |
93
93
  | `intensity?: number` | A factor that scales both colors. The default is 1. |
94
- | `intensityUnit?: 'lux'` | The unit of the intensity: `'lux'`, the light that reaches a surface. It is three.js's unit too, so the intensity stays as it is. |
94
+ | `intensityUnit?: 'lux'` | The unit of the intensity: `'lux'`, the light that reaches a surface. The intensity is in lux already, so it stays as it is. |
95
95
 
96
96
  ## `Light`
97
97
 
@@ -126,7 +126,7 @@ Options every light takes, besides the options of every node.
126
126
  | Member | Description |
127
127
  | --- | --- |
128
128
  | `color?: ColorInput` | The light's color. The default is white. |
129
- | `intensity?: number` | A factor that scales the color, in three.js's units unless the options name another unit. The default is 1. |
129
+ | `intensity?: number` | A factor that scales the color: lux for directional and ambient lights, candela for point and spot lights, and nits for rectangle and tube lights, unless the options name another unit. The default is 1. |
130
130
 
131
131
  ## `LightShadowOptions`
132
132
 
@@ -138,7 +138,7 @@ The shadows of a point or spot light. A spot light draws its casters' depth into
138
138
  | --- | --- |
139
139
  | `bias?: number` | How far each receiving surface moves toward the light before its shadow test, in meters, at least 0. One texel of the light's tile at the surface's distance caps it. A surface takes this times the tangent of its angle to the light, up to twice it. Raise it when surfaces show stripes of shadow on themselves. The default is 0.01. |
140
140
  | `normalBias?: number` | How far each receiving surface moves along its normal before its shadow test, in meters, at least 0. One texel of the light's tile at the surface's distance caps it. A surface takes this times the sine of its angle to the light. The default is 0.02. |
141
- | `intensity?: number` | How much of the light's shadow it draws, from 0 for none to 1, the default, for all of it. The shader mixes each shadow lookup toward full light by the rest, as three.js's `LightShadow.intensity` does. |
141
+ | `intensity?: number` | How much of the light's shadow it draws, from 0 for none to 1, the default, for all of it. The shader mixes each shadow lookup toward full light by the rest, so a change needs no new shader. |
142
142
 
143
143
  ## `PointLight`
144
144
 
@@ -161,7 +161,7 @@ Options for `scene.createPointLight`.
161
161
 
162
162
  | Member | Description |
163
163
  | --- | --- |
164
- | `intensityUnit?: 'lumen'` | The unit of the intensity and of `setIntensity`: `'lumen'`, the light's whole output, such as 800 for a 60 W bulb. The engine divides it by 4π for a point light, and by π for a spot light at any cone angle, as three.js's `power` and Filament do. Without it, the intensity is in candela, three.js's unit. |
164
+ | `intensityUnit?: 'lumen'` | The unit of the intensity and of `setIntensity`: `'lumen'`, the light's whole output, such as 800 for a 60 W bulb. The engine divides it by 4π for a point light, and by π for a spot light at any cone angle, as Filament does. Without it, the intensity is in candela. |
165
165
  | `range: number` | The distance in meters where the light ends, above 0. Every point light needs one, because the engine finds the lights near each surface by their ranges. |
166
166
  | `decay?: number` | How fast the light fades with distance, at least 0. The default, 2, is the physical rate. |
167
167
  | `castShadows?: boolean` | True makes the light cast shadows, like `setCastShadows(true)`. The default is false. Point lights cast them where the quality preset's `pointLightShadows` is on, as on High and Ultra. |
@@ -171,7 +171,7 @@ Options for `scene.createPointLight`.
171
171
 
172
172
  Class `RectAreaLight`, which extends `Light`.
173
173
 
174
- Light from a rectangle of even brightness, such as a window, a screen or a studio panel. Its light leaves the side that its -Z axis points to, and ends at its range. Surfaces show its whole shape in their highlights, and soft light near it, as three.js's `RectAreaLight` gives. Its intensity is the rectangle's brightness in nits, three.js's unit. It casts no shadows.
174
+ Light from a rectangle of even brightness, such as a window, a screen or a studio panel. Its light leaves the side that its -Z axis points to, and ends at its range. Surfaces show its whole shape in their highlights, and soft light near it. Its intensity is the rectangle's brightness in nits. It casts no shadows.
175
175
 
176
176
  | Member | Description |
177
177
  | --- | --- |
@@ -208,7 +208,7 @@ Light from a point in a cone, which fades with distance and ends at its range. T
208
208
  | `setDecay(decay: number): void` | Sets how fast the light fades with distance, at least 0: 2 is the physical rate. |
209
209
  | `setAngle(angle: number): void` | Sets the angle in radians from the light's direction to the edge of its cone: up to π/2. |
210
210
  | `setPenumbra(penumbra: number): void` | Sets the part of the cone, from 0 to 1, over which the light fades out toward the edge. |
211
- | `setMap(map: LightImagePixels \| Texture \| null): void` | Projects a picture over the light's cone, such as a window frame, a gobo pattern or a projected photograph, or `null` to go back to one color. The color and intensity tint it. The picture fills the square around the cone: a circle in its middle lands on the cone's edge, where the light ends. The picture's top row lies along the world's up, as three.js aims a spot light's map. The engine keeps the picture's detail up to 512 texels a side, so a small gobo costs less memory than a detailed photograph. Give sRGB pixels, or a texture that the engine copies once: a texture larger than 512 texels a side is reduced, and one that changes every frame, such as a video's or a render pass's, throws E1112, because the copy would show a single frame. A surface far from the light shows the picture blurred. Up to 32 lights show pictures at once, and rectangle and spot lights share those places. A new picture takes up to a few tens of milliseconds, so set it at setup or now and then, not in every frame. |
211
+ | `setMap(map: LightImagePixels \| Texture \| null): void` | Projects a picture over the light's cone, such as a window frame, a gobo pattern or a projected photograph, or `null` to go back to one color. The color and intensity tint it. The picture fills the square around the cone: a circle in its middle lands on the cone's edge, where the light ends. The picture's top row lies along the world's up, so rolling the light about its own axis leaves the picture as it is. The engine keeps the picture's detail up to 512 texels a side, so a small gobo costs less memory than a detailed photograph. Give sRGB pixels, or a texture that the engine copies once: a texture larger than 512 texels a side is reduced, and one that changes every frame, such as a video's or a render pass's, throws E1112, because the copy would show a single frame. A surface far from the light shows the picture blurred. Up to 32 lights show pictures at once, and rectangle and spot lights share those places. A new picture takes up to a few tens of milliseconds, so set it at setup or now and then, not in every frame. |
212
212
  | `destroy(): void` | Removes the light at the next frame, and frees its picture's place. |
213
213
  | `setDirection(x: number, y: number, z: number): void` | Turns the light so that its light travels along (x, y, z), relative to its parent. |
214
214
  | `setCastShadows(cast: boolean): void` | Makes the light cast shadows, or stop. The default is false. The quality preset's `shadowTiles` caps the lights that cast them at once: the lights that look largest from the camera cast them first. |
@@ -14,7 +14,7 @@ summary: "Every export of the Lines API, from the engine's doc comments."
14
14
 
15
15
  Class `LineBatch`.
16
16
 
17
- Lines of any width: segments between points, each drawn as a quad with round ends that faces the camera, like three.js's `Line2`. Write points straight into the typed arrays, as for an instance batch. A dynamic batch updates every segment every frame, and a static batch updates the segments of the points you mark dirty.
17
+ Lines of any width: segments between points, each drawn as a quad with round ends that faces the camera. Write points straight into the typed arrays, as for an instance batch. A dynamic batch updates every segment every frame, and a static batch updates the segments of the points you mark dirty.
18
18
 
19
19
  | Member | Description |
20
20
  | --- | --- |
@@ -47,7 +47,7 @@ A line batch's material: its color and opacity, as a material's `set` takes them
47
47
  type LineMode = 'segments' | 'strip' | 'loop';
48
48
  ```
49
49
 
50
- Which points each segment joins. With `segments`, each pair of points makes a segment, like three.js's `LineSegments`. With `strip`, every point joins the next, like `Line` and `Line2`. With `loop`, the last point also joins the first, like `LineLoop`.
50
+ Which points each segment joins. With `segments`, each pair of points makes a segment. With `strip`, every point joins the next. With `loop`, the last point also joins the first.
51
51
 
52
52
  ## `LineOptions`
53
53
 
@@ -61,20 +61,20 @@ Options of `scene.createLines`. The look of the lines takes the options of an un
61
61
  | `positions: ArrayLike<number>` | The points: 3 numbers each. Their number is the batch's capacity, which never changes, and `lines.positions` holds them after the call. |
62
62
  | `colors?: ArrayLike<number>` | Linear RGB colors, 3 numbers per point, which multiply `color`. A segment takes the color of each end and blends from one to the other. The default is white. |
63
63
  | `mode?: LineMode` | Which points each segment joins. The default is `strip`. |
64
- | `width?: number` | The width of the lines: CSS pixels, or world units with `worldUnits`. The default is 1, as three.js's `linewidth`. |
65
- | `worldUnits?: boolean` | True gives the width in world units, so far lines look thinner, as three.js's `worldUnits` does. False gives it in CSS pixels. The default is false. |
64
+ | `width?: number` | The width of the lines: CSS pixels, or world units with `worldUnits`. The default is 1. |
65
+ | `worldUnits?: boolean` | True gives the width in world units, so far lines look thinner. False gives it in CSS pixels, so every line keeps its width on screen. The default is false. |
66
66
  | `dashed?: boolean` | Draws the lines as dashes, which `dashSize`, `gapSize` and the other dash values shape. |
67
- | `lit?: boolean` | Lights the lines as a standard material lights a surface that faces the camera: the sun, the point and spot lights and the ambient light shade them. False draws the color as it is, as three.js's line materials do. The default is false. |
67
+ | `lit?: boolean` | Lights the lines as a standard material lights a surface that faces the camera: the sun, the point and spot lights and the ambient light shade them. False draws the color as it is, whatever the lights. The default is false. |
68
68
  | `dynamic?: boolean` | Every point updates and uploads every frame; a static batch updates points marked dirty only. |
69
69
  | `layers?: number` | The layers every segment is on, as a 32-bit mask. The default, 1, is layer 0. |
70
70
  | `origin?: Vec3` | The point that every point's position is relative to, as an instance batch's `origin`. The default is (0, 0, 0). Lines near it keep the precision of 32-bit floats at any distance from the world's origin. |
71
- | `alphaMode?: 'opaque' \| 'blend'` | How the lines use their opacity. The default is `opaque`, as three.js's lines are. |
71
+ | `alphaMode?: 'opaque' \| 'blend'` | How the lines use their opacity. The default is `opaque`. |
72
72
 
73
73
  ## `LineValues`
74
74
 
75
75
  Interface `LineValues`, which extends `Omit`, `Pick`.
76
76
 
77
- The values of a line batch's material, which `lines.material.set` changes at any time. The dash values act on dashed lines, as three.js's `LineMaterial` takes them. The metalness, roughness and emissive values act on lit lines, as a standard material takes them.
77
+ The values of a line batch's material, which `lines.material.set` changes at any time. The dash values act on dashed lines. The metalness, roughness and emissive values act on lit lines, as a standard material takes them.
78
78
 
79
79
  | Member | Description |
80
80
  | --- | --- |
@@ -16,7 +16,7 @@ summary: "Every export of the Materials API, from the engine's doc comments."
16
16
  type AlphaMode = 'opaque' | 'mask' | 'hash' | 'blend';
17
17
  ```
18
18
 
19
- How a material uses its alpha: its opacity, times its base color map's alpha, and times its mesh's vertex alpha with `vertexColors`. The `opaque` mode ignores the alpha. The `mask` mode draws nothing where the alpha falls below `alphaCutoff`, and draws the rest opaque, as three.js's `alphaTest` does. The `hash` mode draws each point of the surface opaque or not at all, by a pattern that stays on the mesh. The alpha then sets how much of the surface draws, as three.js's `alphaHash` does. The `blend` mode blends the surface over what lies behind it, as three.js's `transparent: true` does. Blended objects draw after the opaque ones, farthest first.
19
+ How a material uses its alpha: its opacity, times its base color map's alpha, and times its mesh's vertex alpha with `vertexColors`. The `opaque` mode ignores the alpha. The `mask` mode draws nothing where the alpha falls below `alphaCutoff`, and draws the rest opaque. The `hash` mode draws each point of the surface opaque or not at all, by a pattern that stays on the mesh. The alpha then sets how much of the surface draws. The `blend` mode blends the surface over what lies behind it. Blended objects draw after the opaque ones, farthest first.
20
20
 
21
21
  ## `Blending`
22
22
 
@@ -24,7 +24,7 @@ How a material uses its alpha: its opacity, times its base color map's alpha, an
24
24
  type Blending = 'normal' | 'additive' | 'multiply' | 'weighted';
25
25
  ```
26
26
 
27
- How a blended surface meets what lies behind it. The `normal` blending covers it as far as the alpha says. The `additive` blending adds the surface's light, for glows and fire. The `multiply` blending tints it, for stains and tinted glass. The `weighted` blending covers it as `normal` does, but blends the surfaces of this blending in any order, by a weighted average, as three.js's `OITPassNode` does. Use it for smoke, dense particles and many overlapping panes, where sorting by object leaves surfaces in the wrong order.
27
+ How a blended surface meets what lies behind it. The `normal` blending covers it as far as the alpha says. The `additive` blending adds the surface's light, for glows and fire. The `multiply` blending tints it, for stains and tinted glass. The `weighted` blending covers it as `normal` does, but blends the surfaces of this blending in any order, by a weighted average. Use it for smoke, dense particles and many overlapping panes, where sorting by object leaves surfaces in the wrong order.
28
28
 
29
29
  ## `ColorInput`
30
30
 
@@ -32,7 +32,7 @@ How a blended surface meets what lies behind it. The `normal` blending covers it
32
32
  type ColorInput = string | number | readonly [number, number, number];
33
33
  ```
34
34
 
35
- A color: a hex string such as `'#4a8cff'` or `'#48f'`, a number such as `0x4a8cff`, or three linear components from 0 to 1, such as `[1, 0.26, 0.05]`. Hex values are sRGB, as on the web and in three.js, and the engine converts them to linear values. The color helpers, such as `color.fromHsl`, give linear components.
35
+ A color: a hex string such as `'#4a8cff'` or `'#48f'`, a number such as `0x4a8cff`, or three linear components from 0 to 1, such as `[1, 0.26, 0.05]`. Hex values are sRGB, as on the web, and the engine converts them to linear values. The color helpers, such as `color.fromHsl`, give linear components.
36
36
 
37
37
  ## `CompiledWgsl`
38
38
 
@@ -66,12 +66,12 @@ The values of a decal material, which `set` changes at any time: the standard ma
66
66
 
67
67
  Interface `DepthBias`.
68
68
 
69
- A depth bias, as three.js's polygon offset gives. It moves a surface's depth, so a decal on a wall wins the depth test and does not fight with the wall. Negative values pull the surface toward the camera, as in three.js.
69
+ A depth bias. It moves a surface's depth before the depth test, so a decal on a wall wins the depth test and does not fight with the wall. Negative values pull the surface toward the camera.
70
70
 
71
71
  | Member | Description |
72
72
  | --- | --- |
73
- | `constant?: number` | Steps of the depth buffer's smallest difference, as three.js's `polygonOffsetUnits`. A fraction rounds to the nearest whole number, as WebGPU takes it. The default is 0. |
74
- | `slopeScale?: number` | A factor of how steeply the surface's depth changes across the screen, as three.js's `polygonOffsetFactor`. The default is 0. |
73
+ | `constant?: number` | Steps of the depth buffer's smallest difference. A fraction rounds to the nearest whole number, as WebGPU takes it. The default is 0. |
74
+ | `slopeScale?: number` | A factor of how steeply the surface's depth changes across the screen. The default is 0. |
75
75
 
76
76
  ## `MapUvTransforms`
77
77
 
@@ -91,7 +91,7 @@ A material: how the surfaces of the objects that use it look. `Values` are the o
91
91
  | --- | --- |
92
92
  | `set(options: Values): void` | Changes the values that it gets and keeps the others. Every object that uses the material changes with it. Set up a material with it, and with `setUniform` change the values that a frame changes: a value that changes in every frame crosses the `setUniform` call itself, where this call reads it from a field of the options object, and a field that holds a fraction holds a copy of it of its own. Throws E1101 once the material is destroyed. |
93
93
  | `setUniform<Name extends keyof Values & string>(name: Name, value: NonNullable<Values[Name]>): void` | Changes one value by name, and keeps the others: a number, such as `roughness`, `opacity` or `emissiveIntensity`, or a color, such as `color`, `emissive` or `sheenColor`. It allocates nothing, so a sketch can change a value in every frame. Every object that uses the material changes with it. Throws E1101 once the material is destroyed, and E1216 for a name that it does not take: a value that takes more than one parameter, as the texture transform, the normal scales, the angle fade and the index of refraction do, goes through `set`. |
94
- | `destroy(): void` | Destroys the material, like three.js's `material.dispose()`. Objects and instance batches that still use it draw nothing until `setMaterial` gives them another material. Once no object uses it, its place in the engine's table of materials goes to the next material. When the last material of a custom material's WGSL goes, the engine frees that WGSL's pipelines. The material's textures stay, so destroy them apart. Later calls on the material, and calls that pass it, throw E1101. |
94
+ | `destroy(): void` | Destroys the material. Objects and instance batches that still use it draw nothing until `setMaterial` gives them another material. Once no object uses it, its place in the engine's table of materials goes to the next material. When the last material of a custom material's WGSL goes, the engine frees that WGSL's pipelines. The material's textures stay, so destroy them apart. Later calls on the material, and calls that pass it, throw E1101. |
95
95
 
96
96
  ## `MaterialFeatures`
97
97
 
@@ -104,16 +104,16 @@ The options that choose how a material's shader and pipeline draw it. They are f
104
104
  | `doubleSided?: boolean` | Draws both faces of each triangle. Back faces light as if they faced the camera. The default is false. |
105
105
  | `vertexColors?: boolean` | Multiplies the base color by the mesh's vertex colors, and the alpha by their alpha, on meshes that have them. The default is false. |
106
106
  | `fog?: boolean` | Takes the scene's fog. False keeps the material's color at every distance. The default is true. |
107
- | `toneMapped?: boolean` | Keeps the color as the display shows it, as three.js's `toneMapped: false` does. The tone curve leaves it alone: the 8-bit path decides that in the shader of the material's own build, and the HDR path's final pass reads a mask of these surfaces and skips the curve where one draws. A blended surface keeps the curve on the HDR path, since a blended pixel mixes two surfaces. The vignette and the sRGB encoding still apply, and the exposure already scales the material's colors, so the color shows brighter than the same color tone mapped. The default is true. |
107
+ | `toneMapped?: boolean` | False keeps the color as the display shows it. The tone curve leaves it alone: the 8-bit path decides that in the shader of the material's own build, and the HDR path's final pass reads a mask of these surfaces and skips the curve where one draws. A blended surface keeps the curve on the HDR path, since a blended pixel mixes two surfaces. The vignette and the sRGB encoding still apply, and the exposure already scales the material's colors, so the color shows brighter than the same color tone mapped. The default is true. |
108
108
  | `alphaMode?: AlphaMode` | How the material uses its alpha. The default is `opaque`. |
109
- | `alphaToCoverage?: boolean` | With the `mask` alpha mode, smooths the cut edges with MSAA, as three.js's `alphaToCoverage` does: the alpha fades over about one pixel above `alphaCutoff`, and covers that share of the pixel. Without MSAA the mask cuts as without it. False gives three.js's hard cut edges of `alphaTest`. A custom material takes it where its WGSL sets or reads the surface's `alpha`, and a development build throws E1217 otherwise. The default is true. |
110
- | `forceSinglePass?: boolean` | With the `blend` alpha mode and `doubleSided`, draws both faces in one draw, in the mesh's order, as three.js's `forceSinglePass` does. By default such a surface draws its back faces first and then its front faces, so its near side always covers its far side. The default is false. |
109
+ | `alphaToCoverage?: boolean` | With the `mask` alpha mode, smooths the cut edges with MSAA: the alpha fades over about one pixel above `alphaCutoff`, and covers that share of the pixel. Without MSAA the mask cuts as without it. False gives hard cut edges. A custom material takes it where its WGSL sets or reads the surface's `alpha`, and a development build throws E1217 otherwise. The default is true. |
110
+ | `forceSinglePass?: boolean` | With the `blend` alpha mode and `doubleSided`, draws both faces in one draw, in the mesh's order. By default such a surface draws its back faces first and then its front faces, so its near side always covers its far side. The default is false. |
111
111
  | `blending?: Blending` | With the `blend` alpha mode, how the surface meets what lies behind it. The default is `normal`. |
112
112
  | `depthWrite?: boolean` | False to write no depth, so the surface hides nothing behind it. The default is true. |
113
- | `depthTest?: boolean` | False to draw the surface whatever lies in front of it. It then writes no depth either, as in three.js's WebGL renderer. The default is true. |
114
- | `colorWrite?: boolean` | False to write no color, so the surface shows nothing itself and hides what lies behind it by the depth it writes, as three.js's `colorWrite: false` does. Its objects draw before the opaque objects that write color, so nothing behind it shows through. With the `mask` or `hash` alpha mode, the parts that the alpha drops write no depth either, so the surface cuts a shape out of the space it holds. A blended surface keeps its place among the blended objects, which `setRenderOrder` orders. The default is true. |
115
- | `depthBias?: DepthBias` | Moves the surface's depth, as three.js's polygon offset does. The default is no bias. |
116
- | `wireframe?: boolean` | Draws the edges of each triangle as lines one pixel wide, with the material's own shading, as three.js's `wireframe` does. Edges that two triangles share draw twice. Its shadows draw lines too. Flat shading and bump maps have no effect on it. The default is false. |
113
+ | `depthTest?: boolean` | False to draw the surface whatever lies in front of it. It then writes no depth either. The default is true. |
114
+ | `colorWrite?: boolean` | False to write no color, so the surface shows nothing itself and hides what lies behind it by the depth it writes. Its objects draw before the opaque objects that write color, so nothing behind it shows through. With the `mask` or `hash` alpha mode, the parts that the alpha drops write no depth either, so the surface cuts a shape out of the space it holds. A blended surface keeps its place among the blended objects, which `setRenderOrder` orders. The default is true. |
115
+ | `depthBias?: DepthBias` | Moves the surface's depth before the depth test. The default is no bias. |
116
+ | `wireframe?: boolean` | Draws the edges of each triangle as lines one pixel wide, with the material's own shading. Edges that two triangles share draw twice. Its shadows draw lines too. Flat shading and bump maps have no effect on it. The default is false. |
117
117
 
118
118
  ## `MaterialOptions`
119
119
 
@@ -131,14 +131,14 @@ Options every material takes.
131
131
 
132
132
  Class `Materials`.
133
133
 
134
- Material factories. The standard material follows glTF's metallic-roughness model and shades with the formulas of three.js's `MeshStandardMaterial`. The unlit material shows its color as three.js's `MeshBasicMaterial` does. The shadow-catcher material shows only the main directional light's shadows, as three.js's `ShadowMaterial`.
134
+ Material factories. The standard material follows glTF's metallic-roughness model and shades with Lambert diffuse light and a GGX highlight. The unlit material shows its color whatever the lights. The shadow-catcher material shows only the main directional light's shadows.
135
135
 
136
136
  | Member | Description |
137
137
  | --- | --- |
138
- | `standard(options: StandardOptions = {}): Material<StandardValues>` | A lit material with glTF's metallic-roughness model, like three.js's `MeshStandardMaterial`. |
139
- | `decal(options: DecalOptions = {}): Material<DecalValues>` | A decal's material: the standard material, projected onto every opaque surface inside the box of each object that it draws, as three.js's `DecalGeometry` places a decal. Give it to a mesh of `geometry.box()`: the object's position, rotation and scale place the box, and the material's maps stretch over the box's x and y sides, seen along its z axis. The surfaces inside take its color, roughness, metalness, normal map and emissive light, lit by the scene's lights, and blend with them as far as its alpha says. A decal draws after the opaque objects, and marks no blended surface. It casts no shadow. |
140
- | `unlit(options: UnlitOptions = {}): Material<UnlitValues>` | A material that ignores lights and shows its color unlit, like three.js's `MeshBasicMaterial`. The exposure and the tone mapping still apply to it, as three.js applies them to that material. |
141
- | `shadowCatcher(options: ShadowCatcherOptions = {}): Material<ShadowCatcherValues>` | A material that draws only the shadows that fall on it, as three.js's `ShadowMaterial`: its `color` where the main directional light's shadow falls, and nothing where the light reaches it, at `opacity`. The mesh must receive shadows (`setReceiveShadows(true)`), as three.js's `receiveShadow` must be set. Every shadow that falls on the surface comes from the main directional light; point and spot lights cast none onto it. The default color is black, as three.js's. The material blends, so it draws in the transparent pass after the opaque objects, and the scene's fog leaves it alone. It takes no texture maps. |
138
+ | `standard(options: StandardOptions = {}): Material<StandardValues>` | A lit material with glTF's metallic-roughness model. |
139
+ | `decal(options: DecalOptions = {}): Material<DecalValues>` | A decal's material: the standard material, projected onto every opaque surface inside the box of each object that it draws. Give it to a mesh of `geometry.box()`: the object's position, rotation and scale place the box, and the material's maps stretch over the box's x and y sides, seen along its z axis. The surfaces inside take its color, roughness, metalness, normal map and emissive light, lit by the scene's lights, and blend with them as far as its alpha says. A decal draws after the opaque objects, and marks no blended surface. It casts no shadow. |
140
+ | `unlit(options: UnlitOptions = {}): Material<UnlitValues>` | A material that ignores lights and shows its color unlit. The exposure and the tone mapping still apply to it. |
141
+ | `shadowCatcher(options: ShadowCatcherOptions = {}): Material<ShadowCatcherValues>` | A material that draws only the shadows that fall on it: its `color` where the main directional light's shadow falls, and nothing where the light reaches it, at `opacity`. The mesh must receive shadows (`setReceiveShadows(true)`). Every shadow that falls on the surface comes from the main directional light; point and spot lights cast none onto it. The default color is black. The material blends, so it draws in the transparent pass after the opaque objects, and the scene's fog leaves it alone. It takes no texture maps. |
142
142
  | `shader<const Wgsl extends string \| CompiledWgsl>(options: ShaderOptions<Wgsl>): Material<ShaderValues<Wgsl>>` | A custom material: the standard material with a surface function in WGSL, which changes how each pixel of the surface looks before the engine lights it, or a full shader of your own. It takes every option of `materials.standard` but the texture maps, the first values of the uniforms that its WGSL declares, and the textures that its WGSL samples, a texture of several layers among them for a declaration of a texture array. `set` changes the standard values and the uniforms. Meshes need texture coordinates to draw with a surface function, and the attributes that a full shader reads. Throws E1215 for WGSL that the null3D Vite plugin did not compile, and for a whole shader whose `@vertex` entry point takes no `InstanceIn`. Throws E1216 for a uniform or a texture that the WGSL does not declare, for a value of the wrong kind, and for a uniform named as a standard value, such as `color`. A development build throws E1217 for the `hash` alpha mode and for `alphaToCoverage` where the WGSL never sets or reads the surface's `alpha`: only WGSL that does has the builds that cut the material's shape, and its shadow caster and motion build test that alpha. It also throws E1217 for `transmission` where the WGSL never sets the surface's `transmission`, and for `diffuseTransmission` where it never names the surface's `diffuseTransmission` or `diffuseTransmissionColor`: only WGSL that does has the builds that let light through. When TypeScript can see the WGSL, a wrong name or a value of the wrong kind also fails the type check. |
143
143
 
144
144
  ## `ShaderOptions`
@@ -152,7 +152,7 @@ Options of `materials.shader`: the material's WGSL, the first values of its unif
152
152
  | `wgsl: Wgsl` | The material's WGSL, compiled by the null3D Vite plugin. It declares `fn surface(input: SurfaceInput) -> Surface`, which the engine calls for each pixel, and which can start from `defaultSurface(input)`. The engine lights the surface that it returns. It can declare `struct Uniforms`, whose fields the surface function reads from `material`, `fn vertexOffset`, which moves the mesh's vertices, and `fn lobe(input: LobeInput) -> vec3f`, which adds specular for the main light beside the base lobe. A full shader has a `@vertex` entry point that takes an `InstanceIn`, and a `@fragment` one, instead. Materials made from the same WGSL share their shader. |
153
153
  | `uniforms?: NoInfer<[keyof UniformValues<Wgsl>] extends [never] ? { readonly [name: string]: never; } : UniformValues<Wgsl>>` | The first value of each uniform, by name. A uniform without one starts at 0. When TypeScript can see the WGSL's uniforms, a name that the WGSL does not declare fails the type check, and WGSL without uniforms takes none. |
154
154
  | `textures?: NoInfer<TextureValues<Wgsl>>` | The texture of each `var name: texture_2d<f32>;` or `var name: texture_2d_array<f32>;` that the WGSL declares, by name. The WGSL samples a 2D texture as `textureSample(name, nameSampler, uv)`, with the sampler of the texture's `wrap` and `filter` options, and a texture array as `textureSample(name, nameSampler, uv, layer)`, where it picks the layer of a texture of several layers. A texture samples as white until its image is on the GPU, and a declared texture without one stays white. The textures are fixed when the material is created. When TypeScript can see the WGSL, a name that it does not declare fails the type check. |
155
- | `sceneInputs?: readonly SceneInput[]` | The scene inputs that the material's surface function reads. Today that is `'sceneDepth'`: the WGSL calls `sceneDepth(uv)` or `sceneDistance(uv)`, and the engine binds the copy of the opaque scene's depth. A material that declares it draws after that copy exists, so it reads it in the transparent pass; a surface that draws earlier reads 0, the far plane. A material that declares it takes at most seven textures of its own: its maps' group gives up one slot, so that the copy fits the fragment stage beside the maps under WebGPU's limit of sixteen sampled textures. The engine checks that the declaration and the WGSL agree. |
155
+ | `sceneInputs?: readonly SceneInput[]` | The scene inputs that the material's surface function reads. Today that is `'sceneDepth'`: the WGSL calls `sceneDepth(uv)` or `sceneDistance(uv)`, and the engine binds the copy of the opaque scene's depth. A material that declares it draws after that copy exists, so it reads it in the transparent pass; a surface that draws earlier reads 0, the far plane. A material that declares it samples at most six textures of its own, as every custom material does. Its maps' group gives the copy a slot that those textures leave free, under WebGPU's limit of sixteen sampled textures in the fragment stage. The engine checks that the declaration and the WGSL agree. |
156
156
  | `castsStill?: boolean` | True when the vertex offset follows the view that draws the object and nothing else moves it, as a card that turns toward the camera does. A caster that only shadow passes draw then holds the shadow that the light's layer drew until the light turns, so the far shadow cascades stay cached. Leave it out for an offset that moves with time, such as wind: the shadow of such a caster follows it in every frame, and a far cascade must draw again for each one. |
157
157
  | `swayDistance?: number` | How far from the camera the vertex offset moves, in meters, for an offset that fades out with distance such as wind. The material's WGSL fades its offset to nothing by this distance, and the engine counts a caster of the material as moving only while its bounding sphere reaches within it, so a far shadow cascade that only the sway reaches keeps the layer it holds. Zero, the default, moves the offset at every distance, as an offset that follows time alone does. |
158
158
 
@@ -168,7 +168,7 @@ The values of a custom material, which `set` changes at any time: the standard v
168
168
 
169
169
  Interface `ShadowCatcherOptions`, which extends `ShadowCatcherValues`.
170
170
 
171
- Options of `materials.shadowCatcher`, a material that draws only the shadows that fall on it, as three.js's `ShadowMaterial`.
171
+ Options of `materials.shadowCatcher`, a material that draws only the shadows that fall on it.
172
172
 
173
173
  | Member | Description |
174
174
  | --- | --- |
@@ -190,8 +190,8 @@ The options of `materials.standard` besides its texture maps. Custom materials t
190
190
  | Member | Description |
191
191
  | --- | --- |
192
192
  | `flatShading?: boolean` | Lights each triangle with one normal, the normal of its face, so the mesh looks faceted. It is fixed when the material is created. The default is false. |
193
- | `lightMapOffset?: readonly [number, number]` | Where a light map's texture coordinates start, as three.js's `texture.offset`. A bake places each light map on a mesh with its own scale and offset, apart from the other maps. It takes two numbers, and needs a `lightMap`. The default leaves the coordinates alone. |
194
- | `lightMapRepeat?: readonly [number, number]` | How a light map's texture coordinates stretch, as three.js's `texture.repeat`. It takes two numbers, and needs a `lightMap`. The default is `[1, 1]`. |
193
+ | `lightMapOffset?: readonly [number, number]` | Where a light map's texture coordinates start: the engine adds it to the coordinates after `lightMapRepeat` scales them. A bake places each light map on a mesh with its own scale and offset, apart from the other maps. It takes two numbers, and needs a `lightMap`. The default leaves the coordinates alone. |
194
+ | `lightMapRepeat?: readonly [number, number]` | How a light map's texture coordinates stretch: the engine multiplies the coordinates by it. It takes two numbers, and needs a `lightMap`. The default is `[1, 1]`. |
195
195
  | `lightMapDecode?: 'srgb' \| 'rgbm'` | How the engine reads the light map's texels: `srgb` (the default) takes the texture as sRGB color, which the sampler turns linear, or `rgbm` multiplies each texel's color by its alpha times 8 and then decodes it as sRGB, as Needle's viewer reads its light maps. With `rgbm`, give a texture in linear color, whose raw bytes the shader decodes. It needs a `lightMap`. |
196
196
  | `lightMapDirection?: Texture` | The direction of the light that a directional light map stores at each texel, in linear color: red, green and blue map the direction's x, y and z from -1 to 1. A normal map then bends the light that the bake stored, instead of lighting it evenly. Give the texture that `assets.loadLightMap` returns beside the radiance: the engine reads the direction through the light map's own texture binding, so both must have one size, format and color space, as `loadLightMap` makes them. Needs a `lightMap`. |
197
197
  | `contactShadows?: boolean` | Takes the main directional light's contact shadows. False leaves them off this surface, which keeps the shadow map's shadows. Set it on thin surfaces that crowd together or sway, such as grass blades and leaf cards: the contact shadows take each blade for a solid wall, so they darken such surfaces and flicker as they move. The surfaces under them keep their contact shadows. It is fixed when the material is created. The default is true. |
@@ -207,8 +207,8 @@ The texture maps of a standard material. They are fixed when the material is cre
207
207
  | `map?: Texture` | The base color map, in sRGB. Its color multiplies `color`. |
208
208
  | `metalnessRoughnessMap?: Texture` | Roughness in green and metalness in blue, as glTF packs them, in linear color. They multiply `roughness` and `metalness`. |
209
209
  | `normalMap?: Texture` | Normals in tangent space, in linear color, which `normalScale` scales. |
210
- | `bumpMap?: Texture` | Heights in red, in linear color, which bend the normals as three.js's bump map does, by `bumpScale`. A normal map wins over it, as in three.js, and so does a wireframe. |
211
- | `displacementMap?: Texture` | Heights in red, in linear color, which move each vertex along its normal by `displacementScale` and `displacementBias`, as three.js's displacement map does. Shadows and the depth prepass follow the moved vertices, and culling grows each object's bounds to hold them. Without a normal or bump map, the map's slope also bends the normals, so the light follows the new shape, which three.js does not do. The vertex shader reads the map at its full size, so the mesh needs vertices about as dense as the detail it should show. Raycasts, outlines and debug views see the mesh before it moves. |
210
+ | `bumpMap?: Texture` | Heights in red, in linear color, which bend the normals by the change of the height from one pixel to the next, times `bumpScale`. A normal map wins over it, and so does a wireframe. |
211
+ | `displacementMap?: Texture` | Heights in red, in linear color, which move each vertex along its normal by `displacementScale` and `displacementBias`. Shadows and the depth prepass follow the moved vertices, and culling grows each object's bounds to hold them. Without a normal or bump map, the map's slope also bends the normals, so the light follows the new shape. The vertex shader reads the map at its full size, so the mesh needs vertices about as dense as the detail it should show. Raycasts, outlines and debug views see the mesh before it moves. |
212
212
  | `parallax?: boolean` | With a `displacementMap`, also shifts where each pixel reads the maps, by parallax occlusion mapping: relief finer than the mesh's vertices hides and shows the surface behind it as the view turns. It costs a dozen or more texture reads per pixel, so the quality presets may turn it off. Only opaque and masked surfaces take it. The default is false. |
213
213
  | `aoMap?: Texture` | Ambient occlusion in red, in linear color, which darkens ambient light. |
214
214
  | `emissiveMap?: Texture` | The emissive color map, in sRGB. Its color multiplies `emissive`. |
@@ -247,36 +247,36 @@ The values of a standard material, which `set` changes at any time.
247
247
  | `emissive?: ColorInput` | The color the surface gives off without any light, in the forms that `color` takes. The default is black, which gives off nothing. |
248
248
  | `emissiveIntensity?: number` | The factor of the emissive color: 0 or more. The default is 1. |
249
249
  | `normalScale?: readonly [number, number]` | How strongly the normal map bends normals along u and along v. The default is `[1, 1]`, and negative values flip a direction. |
250
- | `bumpScale?: number` | How strongly the bump map bends normals, as three.js's `bumpScale`: the change of its red channel from one pixel to the next times this. Negative values turn bumps into dents. The default is 1. |
251
- | `displacementScale?: number` | How far the displacement map's white moves each vertex along its normal, in the mesh's units, as three.js's `displacementScale`. The default is 1. |
252
- | `displacementBias?: number` | How far the displacement map moves every vertex along its normal, added to its texel's share of `displacementScale`, in the mesh's units, as three.js's `displacementBias`. The default is 0. |
250
+ | `bumpScale?: number` | How strongly the bump map bends normals: the change of its red channel from one pixel to the next times this. Negative values turn bumps into dents. The default is 1. |
251
+ | `displacementScale?: number` | How far the displacement map's white moves each vertex along its normal, in the mesh's units. The default is 1. |
252
+ | `displacementBias?: number` | How far the displacement map moves every vertex along its normal, added to its texel's share of `displacementScale`, in the mesh's units. The default is 0. |
253
253
  | `aoMapIntensity?: number` | How much the occlusion map darkens ambient light, from 0 to 1. The default is 1. |
254
254
  | `lightMapIntensity?: number` | The factor of the light map's light: 0 or more. The default is 1. |
255
- | `ior?: number` | The index of refraction of the surface's non-metallic part, 1 or more, as three.js's `MeshPhysicalMaterial.ior`. It sets how much light the surface reflects when seen head on: `((ior - 1) / (ior + 1))^2`. The default is 1.5, which reflects 4%, as glTF's metallic-roughness model does. |
256
- | `specularIntensity?: number` | The strength of the specular reflection of the surface's non-metallic part, from 0 to 1, as three.js's `specularIntensity`. It scales the reflection at every angle, so 0 leaves only diffuse light. Metals ignore it. The default is 1. |
257
- | `specularColor?: ColorInput` | The color that tints the specular reflection of the surface's non-metallic part when seen head on, as three.js's `specularColor`. At grazing angles the reflection stays white, and metals ignore it. It takes the forms that `color` takes, and its three linear components may also exceed 1, as glTF allows, to reflect more than the index of refraction gives, up to all the light. The default is white. |
258
- | `envIntensity?: number` | The factor of the scene environment's light on the surface, 0 or more, as three.js's `envMapIntensity`. It multiplies the intensity that `scene.setEnvironment` gives. The default is 1. |
255
+ | `ior?: number` | The index of refraction of the surface's non-metallic part, 1 or more. It sets how much light the surface reflects when seen head on: `((ior - 1) / (ior + 1))^2`. The default is 1.5, which reflects 4%, as glTF's metallic-roughness model does. |
256
+ | `specularIntensity?: number` | The strength of the specular reflection of the surface's non-metallic part, from 0 to 1. It scales the reflection at every angle, so 0 leaves only diffuse light. Metals ignore it. The default is 1. |
257
+ | `specularColor?: ColorInput` | The color that tints the specular reflection of the surface's non-metallic part when seen head on. At grazing angles the reflection stays white, and metals ignore it. It takes the forms that `color` takes, and its three linear components may also exceed 1, as glTF allows, to reflect more than the index of refraction gives, up to all the light. The default is white. |
258
+ | `envIntensity?: number` | The factor of the scene environment's light on the surface, 0 or more. It multiplies the intensity that `scene.setEnvironment` gives. The default is 1. |
259
259
  | `uvTransform?: UvTransform` | Where the maps sit on the texture coordinates. The default leaves them as they are. |
260
260
  | `mapUvTransforms?: MapUvTransforms` | Each map's own transform, for the maps whose transform differs from `uvTransform`. A file keeps one transform for each of its textures, so the loader places each map with its own. |
261
- | `transmission?: number` | How much of the light behind the surface passes through it, from 0 to 1, for glass and clear water, as three.js's `MeshPhysicalMaterial.transmission`. That share of the diffuse light becomes the light from behind, and the reflections stay. Roughness blurs what shows through. Give it when you create the material, even as 0, to change it later. A material created without it lets no light through. Such a material draws after the opaque objects, with the blended ones, and only opaque objects show through it. It takes the `opaque`, `mask` or `blend` alpha mode. A mask decides which pixels draw, and the light from behind fills the pixels that remain, as three.js's `alphaTest` does. The default is 0. |
262
- | `thickness?: number` | The thickness of the volume under the surface, in the mesh's own units, 0 or more, as three.js's `thickness`. Light that passes through bends by `ior` over this distance, and the volume's color absorbs part of it. 0 is a thin wall, which bends no light. The default is 0. |
263
- | `attenuationColor?: ColorInput` | The color that white light takes after it travels `attenuationDistance` through the volume, as three.js's `attenuationColor`, in the forms that `color` takes. The default is white, which absorbs nothing. |
264
- | `attenuationDistance?: number` | The distance in world units over which light in the volume takes `attenuationColor`, above 0, as three.js's `attenuationDistance`. `Infinity` absorbs nothing. The default is `Infinity`. |
265
- | `dispersion?: number` | The strength of the volume's dispersion, 0 or more, as three.js's `MeshPhysicalMaterial.dispersion` and glTF's `KHR_materials_dispersion`: 20 divided by the Abbe number, so a diamond's 0.36 is weak and rutile's 2.04 is strong. The light from behind bends by a slightly different index of refraction for each color, so a prism or a gem separates it into colors at its edges. 0 bends every color alike. It shows only with `transmission`, and the default is 0. |
261
+ | `transmission?: number` | How much of the light behind the surface passes through it, from 0 to 1, for glass and clear water. That share of the diffuse light becomes the light from behind, and the reflections stay. Roughness blurs what shows through. Give it when you create the material, even as 0, to change it later. A material created without it lets no light through. Such a material draws after the opaque objects, with the blended ones, and only opaque objects show through it. It takes the `opaque`, `mask` or `blend` alpha mode. A mask decides which pixels draw, and the light from behind fills the pixels that remain. The default is 0. |
262
+ | `thickness?: number` | The thickness of the volume under the surface, in the mesh's own units, 0 or more. Light that passes through bends by `ior` over this distance, and the volume's color absorbs part of it. 0 is a thin wall, which bends no light. The default is 0. |
263
+ | `attenuationColor?: ColorInput` | The color that white light takes after it travels `attenuationDistance` through the volume, in the forms that `color` takes. The default is white, which absorbs nothing. |
264
+ | `attenuationDistance?: number` | The distance in world units over which light in the volume takes `attenuationColor`, above 0. `Infinity` absorbs nothing. The default is `Infinity`. |
265
+ | `dispersion?: number` | The strength of the volume's dispersion, 0 or more, as glTF's `KHR_materials_dispersion` gives it: 20 divided by the Abbe number, so a diamond's 0.36 is weak and rutile's 2.04 is strong. The light from behind bends by a slightly different index of refraction for each color, so a prism or a gem separates it into colors at its edges. 0 bends every color alike. It shows only with `transmission`, and the default is 0. |
266
266
  | `diffuseTransmission?: number` | How much of the surface's diffuse light passes through it to its other side, from 0 to 1, as glTF's `KHR_materials_diffuse_transmission` gives it. Light that reaches the back, such as the sun behind a leaf, a petal or an ear, then shows on the front through `diffuseTransmissionColor`, and the front keeps the rest of its diffuse light. Shadows fall on that light too. Give it when you create the material, even as 0, to change it later. A material created without it lets no light through to its other side. Over `thickness`, the volume's `attenuationColor` tints the light. `transmission` wins where a material has both. The default is 0. |
267
267
  | `diffuseTransmissionColor?: ColorInput` | The color that tints the light that passes through to the surface's other side, in the forms that `color` takes. The base color does not tint it, as glTF says, so give a leaf its green here. The default is white. |
268
268
  | `subsurfaceRadius?: number` | How far light spreads under the surface before it leaves it, in world units taken as meters, 0 or more, as in skin, wax or marble. The subsurface blur spreads the surface's diffuse light over this distance, so the edges of its shadows and the detail of its maps soften, and its highlights stay sharp. Skin takes about 0.01. Give it when you create the material, even as 0, to change it later. A material created without it draws no blur. The blur draws on the High and Ultra quality presets, where the quality setting `subsurfaceSamples` gives it taps, on the HDR path. Materials that blend or let light through take none. The default is 0. |
269
269
  | `subsurfaceColor?: ColorInput` | How far each color channel's light spreads, as a share of `subsurfaceRadius`, in the forms that `color` takes: each linear channel is its share. Skin's red light spreads furthest, so it takes about `[1, 0.4, 0.25]`. The default is white, which spreads every channel as far. |
270
- | `clearcoat?: number` | How much of a clear coat covers the surface, from 0 to 1, as three.js's `MeshPhysicalMaterial.clearcoat`: a thin, shiny layer, as on car paint, varnish or a wet stone, with its own highlights and reflection. It dims what lies below it where it reflects light. Give it, or another option of a clear coat or a sheen, when you create the material, to change it later. The default is 0. |
271
- | `clearcoatRoughness?: number` | How rough the clear coat is, from 0 (a mirror) to 1, as three.js's `clearcoatRoughness`. The default is 0. |
272
- | `clearcoatNormalScale?: readonly [number, number]` | How strongly the coat normal map bends the coat's normals along u and along v, as three.js's `clearcoatNormalScale`. The default is `[1, 1]`, and negative values flip a direction. |
273
- | `sheenColor?: ColorInput` | The color of a sheen, the soft glow at grazing angles of velvet, cloth and fuzz, as three.js's `sheenColor`, in the forms that `color` takes. three.js's `sheen` multiplies it; here the color alone sets the sheen. Black gives none. Give it, or another option of a clear coat or a sheen, when you create the material, to change it later. The default is black. |
274
- | `sheenRoughness?: number` | How rough the sheen is, from 0 to 1, as three.js's `sheenRoughness`: rougher sheens spread wider. The default is 1. |
275
- | `iridescence?: number` | How much a thin film above the surface tints its reflection, from 0 to 1, as three.js's `iridescence`: soap bubbles, oil and beetle shells show the colors of the film's thickness. Give it, or another option of iridescence, when you create the material, to change it later. The default is 0. |
276
- | `iridescenceIor?: number` | The thin film's index of refraction, 1 or more, as three.js's `iridescenceIOR`: 1 makes the film reflect as the surface does, and a value near 2 shows its colors most strongly. The default is 1.3. |
277
- | `iridescenceThicknessRange?: readonly [number, number]` | The thinnest and thickest parts of the film, in nanometers, as three.js's `iridescenceThicknessRange`: the map's green channel mixes between them. The default is `[100, 400]`. |
278
- | `anisotropy?: number` | How far the specular reflection stretches along one direction of the surface, from 0 (round) to 1, as three.js's `anisotropy`: brushed metal shows a highlight across its grooves rather than around. A material with a map takes the stretch's direction from the mesh's tangents or from the map's coordinates; a material without one takes a frame square to the surface. Give it, or `anisotropyRotation`, when you create the material, to change it later. The default is 0. |
279
- | `anisotropyRotation?: number` | The direction along which the reflection stretches, in radians from the surface's tangent, as three.js's `anisotropyRotation`. The default is 0. |
270
+ | `clearcoat?: number` | How much of a clear coat covers the surface, from 0 to 1: a thin, shiny layer, as on car paint, varnish or a wet stone, with its own highlights and reflection. It dims what lies below it where it reflects light. Give it, or another option of a clear coat or a sheen, when you create the material, to change it later. The default is 0. |
271
+ | `clearcoatRoughness?: number` | How rough the clear coat is, from 0 (a mirror) to 1. The default is 0. |
272
+ | `clearcoatNormalScale?: readonly [number, number]` | How strongly the coat normal map bends the coat's normals along u and along v. The default is `[1, 1]`, and negative values flip a direction. |
273
+ | `sheenColor?: ColorInput` | The color of a sheen, the soft glow at grazing angles of velvet, cloth and fuzz, in the forms that `color` takes. The color alone sets the sheen's strength, so black gives none. Give it, or another option of a clear coat or a sheen, when you create the material, to change it later. The default is black. |
274
+ | `sheenRoughness?: number` | How rough the sheen is, from 0 to 1: rougher sheens spread wider. The default is 1. |
275
+ | `iridescence?: number` | How much a thin film above the surface tints its reflection, from 0 to 1: soap bubbles, oil and beetle shells show the colors of the film's thickness. Give it, or another option of iridescence, when you create the material, to change it later. The default is 0. |
276
+ | `iridescenceIor?: number` | The thin film's index of refraction, 1 or more: 1 makes the film reflect as the surface does, and a value near 2 shows its colors most strongly. The default is 1.3. |
277
+ | `iridescenceThicknessRange?: readonly [number, number]` | The thinnest and thickest parts of the film, in nanometers: the map's green channel mixes between them. The default is `[100, 400]`. |
278
+ | `anisotropy?: number` | How far the specular reflection stretches along one direction of the surface, from 0 (round) to 1: brushed metal shows a highlight across its grooves rather than around. A material with a map takes the stretch's direction from the mesh's tangents or from the map's coordinates; a material without one takes a frame square to the surface. Give it, or `anisotropyRotation`, when you create the material, to change it later. The default is 0. |
279
+ | `anisotropyRotation?: number` | The direction along which the reflection stretches, in radians from the surface's tangent. The default is 0. |
280
280
 
281
281
  ## `TextureValues`
282
282
 
@@ -350,7 +350,7 @@ The values of an unlit material, which `set` changes at any time.
350
350
 
351
351
  Interface `UvTransform`.
352
352
 
353
- Where a material's maps sit on the texture coordinates, as three.js's texture `offset`, `repeat` and `rotation` place a texture, with its `center` at the coordinates' origin. A transform that leaves a value out takes its default.
353
+ Where a material's maps sit on the texture coordinates. The engine turns the coordinates by `rotation` about their origin, scales them by `repeat`, and then adds `offset`: u' = repeat.u × (u cos r + v sin r) + offset.u, and v' = repeat.v × (v cos r − u sin r) + offset.v. A transform that leaves a value out takes its default.
354
354
 
355
355
  | Member | Description |
356
356
  | --- | --- |