@null3d/engine 0.0.0 → 0.1.1

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 (517) hide show
  1. package/README.md +109 -0
  2. package/THIRD-PARTY-NOTICES.txt +0 -1
  3. package/dist/wasm/single/null3d.js +25 -10
  4. package/dist/wasm/single/null3d_bg.wasm +0 -0
  5. package/dist/wasm/threaded/null3d.js +25 -10
  6. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  7. package/docs/api/animation.md +114 -86
  8. package/docs/api/assets.md +135 -49
  9. package/docs/api/cameras.md +45 -12
  10. package/docs/api/controls.md +88 -62
  11. package/docs/api/debug.md +116 -41
  12. package/docs/api/engine.md +117 -35
  13. package/docs/api/feature-draws.md +23 -17
  14. package/docs/api/feature-effects.md +11 -11
  15. package/docs/api/feature-instances.md +70 -19
  16. package/docs/api/features.md +77 -47
  17. package/docs/api/geometry.md +132 -82
  18. package/docs/api/grass.md +55 -13
  19. package/docs/api/impostors.md +175 -22
  20. package/docs/api/input.md +24 -18
  21. package/docs/api/lights.md +78 -51
  22. package/docs/api/lines.md +41 -33
  23. package/docs/api/materials.md +248 -121
  24. package/docs/api/math.md +12 -13
  25. package/docs/api/objects.md +47 -22
  26. package/docs/api/page.md +58 -7
  27. package/docs/api/particles.md +33 -20
  28. package/docs/api/points.md +19 -31
  29. package/docs/api/post.md +75 -42
  30. package/docs/api/quality.md +42 -17
  31. package/docs/api/raycast.md +65 -51
  32. package/docs/api/reference/animation.md +10 -11
  33. package/docs/api/reference/assets.md +25 -22
  34. package/docs/api/reference/cameras.md +8 -4
  35. package/docs/api/reference/controls.md +134 -25
  36. package/docs/api/reference/debug.md +81 -14
  37. package/docs/api/reference/engine.md +58 -17
  38. package/docs/api/reference/feature-draws.md +3 -4
  39. package/docs/api/reference/feature-effects.md +2 -3
  40. package/docs/api/reference/feature-instances.md +5 -4
  41. package/docs/api/reference/features.md +7 -4
  42. package/docs/api/reference/geometry.md +287 -97
  43. package/docs/api/reference/grass.md +63 -3
  44. package/docs/api/reference/impostors.md +208 -13
  45. package/docs/api/reference/input.md +4 -5
  46. package/docs/api/reference/lights.md +13 -12
  47. package/docs/api/reference/lines.md +10 -11
  48. package/docs/api/reference/materials.md +54 -53
  49. package/docs/api/reference/math.md +35 -24
  50. package/docs/api/reference/objects.md +11 -12
  51. package/docs/api/reference/particles.md +31 -6
  52. package/docs/api/reference/points.md +6 -7
  53. package/docs/api/reference/post.md +21 -20
  54. package/docs/api/reference/quality.md +8 -5
  55. package/docs/api/reference/raycast.md +7 -8
  56. package/docs/api/reference/render.md +5 -4
  57. package/docs/api/reference/scene.md +52 -30
  58. package/docs/api/reference/sketch.md +15 -11
  59. package/docs/api/reference/sound.md +234 -0
  60. package/docs/api/reference/splats.md +42 -3
  61. package/docs/api/reference/sprites.md +7 -8
  62. package/docs/api/reference/tasks.md +16 -3
  63. package/docs/api/reference/terrain.md +27 -5
  64. package/docs/api/reference/textures.md +5 -6
  65. package/docs/api/reference/three-compat.md +18 -7
  66. package/docs/api/reference/time.md +1 -2
  67. package/docs/api/reference/ui.md +12 -9
  68. package/docs/api/reference/vertex-draws.md +5 -6
  69. package/docs/api/reference/water.md +153 -9
  70. package/docs/api/reference/wind.md +17 -4
  71. package/docs/api/render.md +73 -29
  72. package/docs/api/scene.md +164 -60
  73. package/docs/api/sketch.md +102 -15
  74. package/docs/api/sound.md +205 -0
  75. package/docs/api/splats.md +46 -12
  76. package/docs/api/sprites.md +10 -24
  77. package/docs/api/tasks.md +33 -24
  78. package/docs/api/terrain.md +42 -22
  79. package/docs/api/textures.md +68 -19
  80. package/docs/api/three-compat.md +15 -7
  81. package/docs/api/time.md +3 -5
  82. package/docs/api/ui.md +19 -23
  83. package/docs/api/vertex-draws.md +13 -12
  84. package/docs/api/water.md +262 -35
  85. package/docs/api/wind.md +63 -17
  86. package/docs/cli/null3d.md +177 -27
  87. package/docs/concepts/architecture.md +73 -27
  88. package/docs/concepts/assets.md +57 -33
  89. package/docs/concepts/backends.md +69 -27
  90. package/docs/concepts/color-management.md +54 -36
  91. package/docs/concepts/culling.md +68 -47
  92. package/docs/concepts/handles.md +14 -5
  93. package/docs/concepts/instances.md +74 -25
  94. package/docs/concepts/large-worlds.md +18 -8
  95. package/docs/concepts/lighting.md +155 -87
  96. package/docs/concepts/lod.md +126 -44
  97. package/docs/concepts/materials.md +58 -27
  98. package/docs/concepts/particle-buffer.md +48 -35
  99. package/docs/concepts/post-processing.md +84 -43
  100. package/docs/concepts/quality-preset-tables.md +56 -52
  101. package/docs/concepts/quality-presets.md +164 -52
  102. package/docs/concepts/render-graph.md +69 -29
  103. package/docs/concepts/render-layers.md +11 -21
  104. package/docs/concepts/shadows.md +105 -52
  105. package/docs/concepts/static-dynamic.md +22 -7
  106. package/docs/cookbook/index.md +164 -120
  107. package/docs/data/threejs-mapping.json +362 -367
  108. package/docs/errors/E1101.md +23 -5
  109. package/docs/errors/E1102.md +11 -3
  110. package/docs/errors/E1103.md +11 -3
  111. package/docs/errors/E1104.md +11 -3
  112. package/docs/errors/E1105.md +13 -5
  113. package/docs/errors/E1106.md +11 -3
  114. package/docs/errors/E1107.md +15 -5
  115. package/docs/errors/E1108.md +11 -3
  116. package/docs/errors/E1109.md +32 -6
  117. package/docs/errors/E1110.md +23 -5
  118. package/docs/errors/E1111.md +11 -3
  119. package/docs/errors/E1112.md +11 -3
  120. package/docs/errors/E1203.md +12 -4
  121. package/docs/errors/E1204.md +11 -3
  122. package/docs/errors/E1205.md +11 -3
  123. package/docs/errors/E1206.md +28 -6
  124. package/docs/errors/E1207.md +11 -3
  125. package/docs/errors/E1208.md +12 -3
  126. package/docs/errors/E1209.md +11 -3
  127. package/docs/errors/E1213.md +27 -5
  128. package/docs/errors/E1214.md +14 -6
  129. package/docs/errors/E1215.md +31 -6
  130. package/docs/errors/E1216.md +31 -6
  131. package/docs/errors/E1217.md +29 -6
  132. package/docs/errors/E1218.md +22 -6
  133. package/docs/errors/E1219.md +11 -3
  134. package/docs/errors/E1220.md +24 -5
  135. package/docs/errors/E1221.md +24 -5
  136. package/docs/errors/E1222.md +11 -3
  137. package/docs/errors/E1223.md +39 -6
  138. package/docs/errors/E1224.md +11 -3
  139. package/docs/errors/E1225.md +11 -3
  140. package/docs/errors/E1301.md +11 -3
  141. package/docs/errors/E1302.md +11 -3
  142. package/docs/errors/E1303.md +11 -3
  143. package/docs/errors/E1304.md +11 -3
  144. package/docs/errors/E1305.md +13 -3
  145. package/docs/errors/E1306.md +11 -3
  146. package/docs/errors/E1307.md +40 -0
  147. package/docs/errors/E1401.md +11 -3
  148. package/docs/errors/E1402.md +13 -5
  149. package/docs/errors/E1403.md +11 -3
  150. package/docs/errors/E1404.md +13 -3
  151. package/docs/errors/E1405.md +15 -4
  152. package/docs/errors/E1406.md +31 -5
  153. package/docs/errors/E1407.md +11 -3
  154. package/docs/errors/E1408.md +11 -3
  155. package/docs/errors/E1409.md +11 -3
  156. package/docs/errors/E1410.md +13 -5
  157. package/docs/errors/E1411.md +11 -3
  158. package/docs/errors/E1412.md +29 -6
  159. package/docs/errors/E1413.md +11 -3
  160. package/docs/errors/E1414.md +11 -3
  161. package/docs/errors/E1415.md +11 -3
  162. package/docs/errors/E1416.md +27 -6
  163. package/docs/errors/E1417.md +11 -3
  164. package/docs/errors/E1418.md +12 -3
  165. package/docs/errors/E1419.md +13 -5
  166. package/docs/errors/E1420.md +14 -6
  167. package/docs/errors/E1421.md +11 -3
  168. package/docs/errors/E1422.md +12 -3
  169. package/docs/errors/E1423.md +12 -3
  170. package/docs/errors/E1424.md +24 -5
  171. package/docs/errors/E1425.md +11 -3
  172. package/docs/errors/E1426.md +11 -3
  173. package/docs/errors/E1430.md +11 -3
  174. package/docs/errors/E1431.md +11 -3
  175. package/docs/errors/E1432.md +11 -3
  176. package/docs/errors/E1433.md +11 -3
  177. package/docs/errors/E1434.md +15 -6
  178. package/docs/errors/E1435.md +11 -3
  179. package/docs/errors/E1436.md +11 -3
  180. package/docs/errors/E1437.md +14 -6
  181. package/docs/errors/E1501.md +41 -6
  182. package/docs/errors/E1502.md +13 -3
  183. package/docs/errors/E1503.md +11 -3
  184. package/docs/errors/E1504.md +11 -3
  185. package/docs/errors/E1505.md +23 -5
  186. package/docs/errors/E1506.md +11 -3
  187. package/docs/errors/index.md +54 -30
  188. package/docs/getting-started/cdn.md +32 -10
  189. package/docs/getting-started/first-scene.md +21 -13
  190. package/docs/getting-started/hosting.md +152 -63
  191. package/docs/getting-started/install.md +44 -28
  192. package/docs/getting-started/network-use.md +33 -15
  193. package/docs/getting-started/project-structure.md +33 -12
  194. package/docs/getting-started/third-party-notices.md +12 -14
  195. package/docs/guides/accessibility.md +5 -5
  196. package/docs/guides/add-ons.md +86 -15
  197. package/docs/guides/agents.md +16 -9
  198. package/docs/guides/assets-pipeline.md +259 -82
  199. package/docs/guides/audio.md +115 -128
  200. package/docs/guides/baked-light-data.md +44 -23
  201. package/docs/guides/car-paint.md +38 -32
  202. package/docs/guides/content-pages.md +63 -35
  203. package/docs/guides/custom-passes.md +65 -22
  204. package/docs/guides/custom-shaders.md +59 -39
  205. package/docs/guides/debugging.md +74 -10
  206. package/docs/guides/deploying.md +85 -6
  207. package/docs/guides/deterministic-simulation.md +24 -17
  208. package/docs/guides/first-use-shaders.md +83 -45
  209. package/docs/guides/lens-kit.md +29 -26
  210. package/docs/guides/loading-screens.md +132 -47
  211. package/docs/guides/multiple-views.md +63 -13
  212. package/docs/guides/performance.md +192 -38
  213. package/docs/guides/phones.md +78 -15
  214. package/docs/guides/physics.md +7 -11
  215. package/docs/guides/screens.md +47 -33
  216. package/docs/guides/start-time.md +363 -0
  217. package/docs/guides/testing.md +152 -95
  218. package/docs/guides/ui-overlays.md +19 -14
  219. package/docs/guides/video-textures.md +14 -13
  220. package/docs/images/api/animation/character.webp +0 -0
  221. package/docs/images/api/animation/look-at-ring.webp +0 -0
  222. package/docs/images/api/animation/morph-tulips.webp +0 -0
  223. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  224. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  225. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  226. package/docs/images/api/debug/debug-shapes.webp +0 -0
  227. package/docs/images/api/debug/levels-view.webp +0 -0
  228. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  229. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  230. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  231. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  232. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  233. package/docs/images/api/geometry/generators.webp +0 -0
  234. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  235. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  236. package/docs/images/api/grass/grass-grove.webp +0 -0
  237. package/docs/images/api/grass/grass-presets.webp +0 -0
  238. package/docs/images/api/grass/grass-shadow.webp +0 -0
  239. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  240. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  241. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  242. package/docs/images/api/lights/spot-cookies.webp +0 -0
  243. package/docs/images/api/lines/lines-lit.webp +0 -0
  244. package/docs/images/api/lines/lines-widths.webp +0 -0
  245. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  246. package/docs/images/api/materials/decals.webp +0 -0
  247. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  248. package/docs/images/api/materials/relief.webp +0 -0
  249. package/docs/images/api/materials/shader-inputs.webp +0 -0
  250. package/docs/images/api/materials/standard-grid.webp +0 -0
  251. package/docs/images/api/materials/subsurface.webp +0 -0
  252. package/docs/images/api/materials/translucency.webp +0 -0
  253. package/docs/images/api/objects/objects-turntable.webp +0 -0
  254. package/docs/images/api/particles/campfire.webp +0 -0
  255. package/docs/images/api/points/galaxy.webp +0 -0
  256. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  257. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  258. package/docs/images/api/render/reflection-mirror.webp +0 -0
  259. package/docs/images/api/render/security-camera.webp +0 -0
  260. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  261. package/docs/images/api/sound/sound-demo.webp +0 -0
  262. package/docs/images/api/splats/splats-demo.webp +0 -0
  263. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  264. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  265. package/docs/images/api/textures/canvas-screen.webp +0 -0
  266. package/docs/images/api/textures/mipmaps.webp +0 -0
  267. package/docs/images/api/vertex-draws/rain.webp +0 -0
  268. package/docs/images/api/water/ocean.webp +0 -0
  269. package/docs/images/api/water/water-demo.webp +0 -0
  270. package/docs/images/api/water/water-rain.webp +0 -0
  271. package/docs/images/api/water/waterfall.webp +0 -0
  272. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  273. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  274. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  275. package/docs/images/concepts/instances/instances.webp +0 -0
  276. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  277. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  278. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  279. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  280. package/docs/images/concepts/lighting/environment.webp +0 -0
  281. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  282. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  283. package/docs/images/concepts/lod/forest.webp +0 -0
  284. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  285. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  286. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  287. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  288. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  289. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  290. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  291. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  292. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  293. package/docs/images/cookbook/index/picking.webp +0 -0
  294. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  295. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  296. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  297. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  298. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  299. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  300. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  301. package/docs/images/index/showcase-island.webp +0 -0
  302. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  303. package/docs/images/shaders/builtins/builtins.webp +0 -0
  304. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  305. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  306. package/docs/images/shots.json +2231 -0
  307. package/docs/index.md +18 -23
  308. package/docs/moves.json +1 -0
  309. package/docs/nav.json +300 -0
  310. package/docs/pages.md +230 -209
  311. package/docs/porting/react-three-fiber.md +225 -6
  312. package/docs/porting/threejs-loop-and-threads.md +217 -7
  313. package/docs/porting/threejs-mapping.md +1249 -233
  314. package/docs/porting/threejs-materials.md +218 -6
  315. package/docs/porting/threejs-overview.md +240 -7
  316. package/docs/porting/threejs-postprocessing.md +4 -8
  317. package/docs/porting/threejs-shaders.md +301 -6
  318. package/docs/porting/threejs-unsupported.md +83 -7
  319. package/docs/porting/verification.md +178 -6
  320. package/docs/shaders/builtins.md +15 -4
  321. package/docs/shaders/library.md +72 -45
  322. package/docs/shaders/surface-functions.md +59 -23
  323. package/docs/shaders/wgsl-rules.md +12 -5
  324. package/lib/debug/channel.d.ts +103 -0
  325. package/lib/debug/channel.js +269 -0
  326. package/lib/debug/debug.d.ts +11 -9
  327. package/lib/debug/draw.d.ts +11 -2
  328. package/lib/debug/draw.js +57 -6
  329. package/lib/debug/inspector.d.ts +60 -0
  330. package/lib/debug/inspector.js +475 -0
  331. package/lib/debug/overlay-look.d.ts +6 -0
  332. package/lib/debug/overlay-look.js +29 -7
  333. package/lib/debug/overlay.js +15 -11
  334. package/lib/debug/stats-options.d.ts +13 -0
  335. package/lib/debug/stats-panel.d.ts +22 -7
  336. package/lib/debug/stats-panel.js +80 -13
  337. package/lib/debug/stats.d.ts +2 -3
  338. package/lib/errors/codes.d.ts +17 -3
  339. package/lib/errors/codes.js +117 -105
  340. package/lib/errors/engine-error.js +25 -10
  341. package/lib/errors/fixes.d.ts +1 -0
  342. package/lib/errors/fixes.js +20 -19
  343. package/lib/generated/core.d.ts +1 -1
  344. package/lib/generated/core.js +1 -1
  345. package/lib/gpu/early-builds.d.ts +68 -0
  346. package/lib/gpu/early-builds.js +158 -0
  347. package/lib/gpu/pipeline-name.d.ts +6 -0
  348. package/lib/gpu/pipeline-name.js +23 -0
  349. package/lib/gpu/variants.d.ts +8 -2
  350. package/lib/gpu/variants.js +39 -7
  351. package/lib/gpu/webgl2/backend.d.ts +63 -2
  352. package/lib/gpu/webgl2/backend.js +226 -8
  353. package/lib/gpu/webgl2/programs.d.ts +18 -0
  354. package/lib/gpu/webgl2/programs.js +5 -2
  355. package/lib/gpu/webgpu/backend.d.ts +89 -2
  356. package/lib/gpu/webgpu/backend.js +255 -8
  357. package/lib/gpu/webgpu/pipelines.d.ts +13 -0
  358. package/lib/gpu/webgpu/pipelines.js +28 -14
  359. package/lib/index.d.ts +7 -5
  360. package/lib/index.js +3 -2
  361. package/lib/math/color.d.ts +5 -5
  362. package/lib/math/color.js +5 -5
  363. package/lib/math/mat4.d.ts +6 -12
  364. package/lib/math/mat4.js +6 -12
  365. package/lib/math/namespaces/quat.d.ts +3 -3
  366. package/lib/math/namespaces/quat.js +3 -3
  367. package/lib/math/quat.d.ts +8 -12
  368. package/lib/math/quat.js +8 -12
  369. package/lib/math/random.d.ts +2 -3
  370. package/lib/math/random.js +2 -3
  371. package/lib/math/types.d.ts +4 -4
  372. package/lib/math/vec3.d.ts +3 -6
  373. package/lib/math/vec3.js +3 -6
  374. package/lib/page/capabilities.d.ts +8 -8
  375. package/lib/page/capabilities.js +39 -25
  376. package/lib/page/check-store.d.ts +14 -2
  377. package/lib/page/check-store.js +34 -11
  378. package/lib/page/engine.d.ts +117 -31
  379. package/lib/page/engine.js +438 -99
  380. package/lib/page/first-frame.d.ts +16 -0
  381. package/lib/page/first-frame.js +35 -0
  382. package/lib/page/frame-stats.d.ts +34 -1
  383. package/lib/page/frame-stats.js +15 -0
  384. package/lib/page/label-loop.d.ts +7 -3
  385. package/lib/page/label-loop.js +26 -14
  386. package/lib/page/labels.d.ts +3 -3
  387. package/lib/page/pipeline-store.d.ts +25 -0
  388. package/lib/page/pipeline-store.js +84 -0
  389. package/lib/page/start-marker.d.ts +4 -1
  390. package/lib/page/start-marker.js +5 -2
  391. package/lib/page/stats-switch.js +2 -0
  392. package/lib/page/switches.d.ts +38 -6
  393. package/lib/page/switches.js +29 -5
  394. package/lib/quality/check.d.ts +24 -3
  395. package/lib/quality/check.js +21 -7
  396. package/lib/quality/chooser.d.ts +6 -0
  397. package/lib/quality/chooser.js +8 -0
  398. package/lib/quality/governor.d.ts +98 -6
  399. package/lib/quality/governor.js +250 -20
  400. package/lib/quality/preset-docs.d.ts +16 -1
  401. package/lib/quality/preset-docs.js +3 -0
  402. package/lib/quality/presets.d.ts +84 -7
  403. package/lib/quality/presets.js +94 -2
  404. package/lib/render/draw.d.ts +3 -2
  405. package/lib/render/draw.js +15 -5
  406. package/lib/render/load-draw.d.ts +7 -5
  407. package/lib/render/load-draw.js +7 -5
  408. package/lib/render/loss.d.ts +28 -10
  409. package/lib/render/loss.js +50 -22
  410. package/lib/render/recovery.d.ts +20 -0
  411. package/lib/render/recovery.js +44 -4
  412. package/lib/render/renderer.d.ts +85 -9
  413. package/lib/render/renderer.js +181 -42
  414. package/lib/render/scene-renderer.d.ts +19 -1
  415. package/lib/render/scene-renderer.js +25 -1
  416. package/lib/render/webgl2-renderers.js +8 -5
  417. package/lib/render/webgpu-renderers.js +5 -4
  418. package/lib/scene/animation.d.ts +28 -32
  419. package/lib/scene/animation.js +12 -15
  420. package/lib/scene/assets.d.ts +61 -86
  421. package/lib/scene/assets.js +103 -236
  422. package/lib/scene/background.d.ts +14 -18
  423. package/lib/scene/background.js +5 -2
  424. package/lib/scene/baked-light.d.ts +2 -2
  425. package/lib/scene/color.d.ts +3 -3
  426. package/lib/scene/downloads.d.ts +2 -0
  427. package/lib/scene/downloads.js +371 -0
  428. package/lib/scene/environment.d.ts +7 -7
  429. package/lib/scene/environment.js +1 -1
  430. package/lib/scene/fake-call-values.js +3 -3
  431. package/lib/scene/fog.d.ts +11 -4
  432. package/lib/scene/fog.js +8 -2
  433. package/lib/scene/frame-cameras.d.ts +35 -4
  434. package/lib/scene/frame-cameras.js +86 -10
  435. package/lib/scene/gltf.d.ts +33 -3
  436. package/lib/scene/gltf.js +78 -49
  437. package/lib/scene/grading.d.ts +2 -2
  438. package/lib/scene/grading.js +3 -3
  439. package/lib/scene/ktx2.d.ts +9 -1
  440. package/lib/scene/ktx2.js +3 -2
  441. package/lib/scene/level-rule.d.ts +121 -0
  442. package/lib/scene/level-rule.js +130 -0
  443. package/lib/scene/lines.d.ts +13 -17
  444. package/lib/scene/lines.js +3 -3
  445. package/lib/scene/lut.d.ts +1 -2
  446. package/lib/scene/lut.js +1 -2
  447. package/lib/scene/particles.d.ts +7 -3
  448. package/lib/scene/particles.js +3 -1
  449. package/lib/scene/picks.d.ts +2 -2
  450. package/lib/scene/pointer-events.d.ts +4 -7
  451. package/lib/scene/post.d.ts +39 -43
  452. package/lib/scene/post.js +4 -1
  453. package/lib/scene/prefab.d.ts +7 -8
  454. package/lib/scene/prefab.js +7 -8
  455. package/lib/scene/property-animation.d.ts +1 -1
  456. package/lib/scene/property-animation.js +1 -1
  457. package/lib/scene/queries.d.ts +7 -13
  458. package/lib/scene/resources.d.ts +238 -261
  459. package/lib/scene/resources.js +179 -81
  460. package/lib/scene/scene.d.ts +167 -120
  461. package/lib/scene/scene.js +243 -103
  462. package/lib/scene/serial-loads.d.ts +29 -0
  463. package/lib/scene/serial-loads.js +68 -0
  464. package/lib/scene/shader-preloads.d.ts +34 -0
  465. package/lib/scene/shader-preloads.js +38 -0
  466. package/lib/scene/sprites.d.ts +14 -17
  467. package/lib/scene/sprites.js +5 -6
  468. package/lib/scene/textures.d.ts +11 -12
  469. package/lib/scene/textures.js +9 -10
  470. package/lib/scene/time-of-day.d.ts +11 -7
  471. package/lib/scene/time-of-day.js +11 -8
  472. package/lib/scene/vertex-draws.d.ts +5 -4
  473. package/lib/scene/vertex-draws.js +7 -5
  474. package/lib/shader-artifact.json +1 -0
  475. package/lib/shared/core.d.ts +5 -0
  476. package/lib/shared/core.js +1 -0
  477. package/lib/shared/import-once.d.ts +6 -0
  478. package/lib/shared/import-once.js +19 -0
  479. package/lib/shared/labels.d.ts +5 -2
  480. package/lib/shared/labels.js +5 -2
  481. package/lib/shared/metrics.d.ts +38 -0
  482. package/lib/shared/metrics.js +62 -1
  483. package/lib/shared/permutation-words.d.ts +2 -0
  484. package/lib/shared/permutation-words.js +8 -0
  485. package/lib/shared/recording.d.ts +13 -5
  486. package/lib/shared/recording.js +31 -10
  487. package/lib/shared/run-task.js +7 -1
  488. package/lib/shared/sketch-data.d.ts +9 -0
  489. package/lib/shared/sketch-data.js +57 -0
  490. package/lib/shared/task-pending.d.ts +12 -0
  491. package/lib/shared/task-pending.js +61 -1
  492. package/lib/shared/tasks.js +79 -32
  493. package/lib/shared/version.d.ts +17 -1
  494. package/lib/shared/version.js +19 -1
  495. package/lib/shared/wasm.d.ts +12 -4
  496. package/lib/shared/wasm.js +50 -27
  497. package/lib/shared/worker-start.d.ts +7 -0
  498. package/lib/shared/worker-start.js +27 -0
  499. package/lib/sketch/define-sketch.d.ts +51 -7
  500. package/lib/sketch/define-sketch.js +2 -1
  501. package/lib/sketch/input.d.ts +2 -2
  502. package/lib/sketch/preset-check.d.ts +20 -6
  503. package/lib/sketch/preset-check.js +42 -17
  504. package/lib/sketch/quality.d.ts +69 -11
  505. package/lib/sketch/quality.js +54 -13
  506. package/lib/sketch/runner.d.ts +80 -9
  507. package/lib/sketch/runner.js +390 -52
  508. package/lib/sketch/ui.d.ts +5 -8
  509. package/lib/sketch/ui.js +4 -2
  510. package/lib/stats.d.ts +1 -0
  511. package/lib/workers/probe-worker.d.ts +5 -0
  512. package/lib/workers/probe-worker.js +13 -4
  513. package/lib/workers/protocol.d.ts +71 -13
  514. package/lib/workers/protocol.js +4 -0
  515. package/lib/workers/render-worker.js +29 -5
  516. package/lib/workers/sketch-worker.js +108 -16
  517. package/package.json +2 -2
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/lights
3
3
  title: "Lights: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Lights API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -24,13 +23,15 @@ Options for `scene.createAmbientLight`.
24
23
 
25
24
  | Member | Description |
26
25
  | --- | --- |
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. |
26
+ | `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
27
 
29
28
  ## `DirectionalLight`
30
29
 
31
30
  Class `DirectionalLight`, which extends `Light`.
32
31
 
33
- Light from one direction, like sunlight. It travels along the light's -Z axis, which `setDirection`, `lookAt` and the light's parents turn. Its position does not matter. Up to four directional lights light surfaces at once. The first one created casts the shadows, when `castShadows` is on, and up to three more light as fill and rim lights, without shadows. A fifth directional light gives no light.
32
+ Light from one direction, like sunlight. It travels along the light's -Z axis, which `setDirection`, `lookAt` and the light's parents turn. Its position does not matter.
33
+
34
+ Up to four directional lights light surfaces at once. The first one created casts the shadows, when `castShadows` is on, and up to three more light as fill and rim lights, without shadows. A fifth directional light gives no light.
34
35
 
35
36
  | Member | Description |
36
37
  | --- | --- |
@@ -47,7 +48,7 @@ Options for `scene.createDirectionalLight`.
47
48
 
48
49
  | Member | Description |
49
50
  | --- | --- |
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. |
51
+ | `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
52
  | `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
53
  | `castShadows?: boolean` | True makes the light cast shadows, like `setCastShadows(true)`. The default is false. The first directional light created casts them. |
53
54
  | `shadow?: DirectionalShadowOptions` | How the light's shadows draw, like `setShadow`. Each setting has a default. |
@@ -68,7 +69,7 @@ The shadows of a directional light. The camera's view splits into cascades by di
68
69
  | `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
70
  | `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
71
  | `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. |
72
+ | `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
73
 
73
74
  ## `HemisphereLight`
74
75
 
@@ -91,7 +92,7 @@ Options for `scene.createHemisphereLight`.
91
92
  | `skyColor?: ColorInput` | The color of the light from above. The default is white. |
92
93
  | `groundColor?: ColorInput` | The color of the light from below. The default is white. |
93
94
  | `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. |
95
+ | `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
96
 
96
97
  ## `Light`
97
98
 
@@ -126,7 +127,7 @@ Options every light takes, besides the options of every node.
126
127
  | Member | Description |
127
128
  | --- | --- |
128
129
  | `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. |
130
+ | `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
131
 
131
132
  ## `LightShadowOptions`
132
133
 
@@ -138,7 +139,7 @@ The shadows of a point or spot light. A spot light draws its casters' depth into
138
139
  | --- | --- |
139
140
  | `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
141
  | `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. |
142
+ | `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
143
 
143
144
  ## `PointLight`
144
145
 
@@ -161,7 +162,7 @@ Options for `scene.createPointLight`.
161
162
 
162
163
  | Member | Description |
163
164
  | --- | --- |
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. |
165
+ | `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
166
  | `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
167
  | `decay?: number` | How fast the light fades with distance, at least 0. The default, 2, is the physical rate. |
167
168
  | `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 +172,7 @@ Options for `scene.createPointLight`.
171
172
 
172
173
  Class `RectAreaLight`, which extends `Light`.
173
174
 
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.
175
+ 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
176
 
176
177
  | Member | Description |
177
178
  | --- | --- |
@@ -208,7 +209,7 @@ Light from a point in a cone, which fades with distance and ends at its range. T
208
209
  | `setDecay(decay: number): void` | Sets how fast the light fades with distance, at least 0: 2 is the physical rate. |
209
210
  | `setAngle(angle: number): void` | Sets the angle in radians from the light's direction to the edge of its cone: up to π/2. |
210
211
  | `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. |
212
+ | `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
213
  | `destroy(): void` | Removes the light at the next frame, and frees its picture's place. |
213
214
  | `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
215
  | `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. |
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/lines
3
3
  title: "Lines: API reference"
4
- status: generated
5
- since: "0.2"
4
+ generated: true
6
5
  summary: "Every export of the Lines API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -14,7 +13,7 @@ summary: "Every export of the Lines API, from the engine's doc comments."
14
13
 
15
14
  Class `LineBatch`.
16
15
 
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.
16
+ 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
17
 
19
18
  | Member | Description |
20
19
  | --- | --- |
@@ -47,11 +46,11 @@ A line batch's material: its color and opacity, as a material's `set` takes them
47
46
  type LineMode = 'segments' | 'strip' | 'loop';
48
47
  ```
49
48
 
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`.
49
+ 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
50
 
52
51
  ## `LineOptions`
53
52
 
54
- Interface `LineOptions`, which extends `LineValues`, `Pick`.
53
+ Interface `LineOptions`, which extends `LineValues`, `Pick<MaterialFeatures, 'fog' | 'depthWrite' | 'depthTest' | 'depthBias'>`.
55
54
 
56
55
  Options of `scene.createLines`. The look of the lines takes the options of an unlit material.
57
56
 
@@ -61,20 +60,20 @@ Options of `scene.createLines`. The look of the lines takes the options of an un
61
60
  | `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
61
  | `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
62
  | `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. |
63
+ | `width?: number` | The width of the lines: CSS pixels, or world units with `worldUnits`. The default is 1. |
64
+ | `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
65
  | `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. |
66
+ | `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
67
  | `dynamic?: boolean` | Every point updates and uploads every frame; a static batch updates points marked dirty only. |
69
68
  | `layers?: number` | The layers every segment is on, as a 32-bit mask. The default, 1, is layer 0. |
70
69
  | `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. |
70
+ | `alphaMode?: 'opaque' \| 'blend'` | How the lines use their opacity. The default is `opaque`. |
72
71
 
73
72
  ## `LineValues`
74
73
 
75
- Interface `LineValues`, which extends `Omit`, `Pick`.
74
+ Interface `LineValues`, which extends `Omit<MaterialOptions, 'alphaCutoff'>`, `Pick<StandardValues, 'metalness' | 'roughness' | 'emissive' | 'emissiveIntensity'>`.
76
75
 
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.
76
+ 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
77
 
79
78
  | Member | Description |
80
79
  | --- | --- |
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: api/reference/materials
3
3
  title: "Materials: API reference"
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "Every export of the Materials API, from the engine's doc comments."
7
6
  ---
8
7
 
@@ -16,7 +15,9 @@ summary: "Every export of the Materials API, from the engine's doc comments."
16
15
  type AlphaMode = 'opaque' | 'mask' | 'hash' | 'blend';
17
16
  ```
18
17
 
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.
18
+ 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.
19
+
20
+ 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
21
 
21
22
  ## `Blending`
22
23
 
@@ -24,7 +25,7 @@ How a material uses its alpha: its opacity, times its base color map's alpha, an
24
25
  type Blending = 'normal' | 'additive' | 'multiply' | 'weighted';
25
26
  ```
26
27
 
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.
28
+ 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
29
 
29
30
  ## `ColorInput`
30
31
 
@@ -32,7 +33,7 @@ How a blended surface meets what lies behind it. The `normal` blending covers it
32
33
  type ColorInput = string | number | readonly [number, number, number];
33
34
  ```
34
35
 
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.
36
+ 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
37
 
37
38
  ## `CompiledWgsl`
38
39
 
@@ -47,13 +48,13 @@ WGSL that the null3D Vite plugin compiled: a template literal that a `wgsl` bloc
47
48
 
48
49
  ## `DecalOptions`
49
50
 
50
- Interface `DecalOptions`, which extends `DecalValues`, `Omit`.
51
+ Interface `DecalOptions`, which extends `DecalValues`, `Omit<StandardMaps, 'lightMap' | 'transmissionMap' | 'thicknessMap'>`.
51
52
 
52
53
  Options of `materials.decal`: its values and the standard material's maps, which the decal projects along its box. The light map is left out.
53
54
 
54
55
  ## `DecalValues`
55
56
 
56
- Interface `DecalValues`, which extends `Omit`.
57
+ Interface `DecalValues`, which extends `Omit<StandardValues, 'alphaCutoff' | 'lightMapIntensity' | 'transmission' | 'thickness' | 'dispersion' | 'attenuationColor' | 'attenuationDistance'>`.
57
58
 
58
59
  The values of a decal material, which `set` changes at any time: the standard material's values that a decal shows, and how the decal fades.
59
60
 
@@ -66,12 +67,12 @@ The values of a decal material, which `set` changes at any time: the standard ma
66
67
 
67
68
  Interface `DepthBias`.
68
69
 
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.
70
+ 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
71
 
71
72
  | Member | Description |
72
73
  | --- | --- |
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. |
74
+ | `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. |
75
+ | `slopeScale?: number` | A factor of how steeply the surface's depth changes across the screen. The default is 0. |
75
76
 
76
77
  ## `MapUvTransforms`
77
78
 
@@ -91,7 +92,7 @@ A material: how the surfaces of the objects that use it look. `Values` are the o
91
92
  | --- | --- |
92
93
  | `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
94
  | `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. |
95
+ | `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
96
 
96
97
  ## `MaterialFeatures`
97
98
 
@@ -104,16 +105,16 @@ The options that choose how a material's shader and pipeline draw it. They are f
104
105
  | `doubleSided?: boolean` | Draws both faces of each triangle. Back faces light as if they faced the camera. The default is false. |
105
106
  | `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
107
  | `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. |
108
+ | `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
109
  | `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. |
110
+ | `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. |
111
+ | `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
112
  | `blending?: Blending` | With the `blend` alpha mode, how the surface meets what lies behind it. The default is `normal`. |
112
113
  | `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. |
114
+ | `depthTest?: boolean` | False to draw the surface whatever lies in front of it. It then writes no depth either. The default is true. |
115
+ | `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. |
116
+ | `depthBias?: DepthBias` | Moves the surface's depth before the depth test. The default is no bias. |
117
+ | `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
118
 
118
119
  ## `MaterialOptions`
119
120
 
@@ -131,14 +132,14 @@ Options every material takes.
131
132
 
132
133
  Class `Materials`.
133
134
 
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`.
135
+ 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
136
 
136
137
  | Member | Description |
137
138
  | --- | --- |
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. |
139
+ | `standard(options: StandardOptions = {}): Material<StandardValues>` | A lit material with glTF's metallic-roughness model. |
140
+ | `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. |
141
+ | `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. |
142
+ | `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
143
  | `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
144
 
144
145
  ## `ShaderOptions`
@@ -152,7 +153,7 @@ Options of `materials.shader`: the material's WGSL, the first values of its unif
152
153
  | `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
154
  | `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
155
  | `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. |
156
+ | `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
157
  | `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
158
  | `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
159
 
@@ -168,7 +169,7 @@ The values of a custom material, which `set` changes at any time: the standard v
168
169
 
169
170
  Interface `ShadowCatcherOptions`, which extends `ShadowCatcherValues`.
170
171
 
171
- Options of `materials.shadowCatcher`, a material that draws only the shadows that fall on it, as three.js's `ShadowMaterial`.
172
+ Options of `materials.shadowCatcher`, a material that draws only the shadows that fall on it.
172
173
 
173
174
  | Member | Description |
174
175
  | --- | --- |
@@ -190,8 +191,8 @@ The options of `materials.standard` besides its texture maps. Custom materials t
190
191
  | Member | Description |
191
192
  | --- | --- |
192
193
  | `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]`. |
194
+ | `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. |
195
+ | `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
196
  | `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
197
  | `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
198
  | `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 +208,8 @@ The texture maps of a standard material. They are fixed when the material is cre
207
208
  | `map?: Texture` | The base color map, in sRGB. Its color multiplies `color`. |
208
209
  | `metalnessRoughnessMap?: Texture` | Roughness in green and metalness in blue, as glTF packs them, in linear color. They multiply `roughness` and `metalness`. |
209
210
  | `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. |
211
+ | `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. |
212
+ | `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
213
  | `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
214
  | `aoMap?: Texture` | Ambient occlusion in red, in linear color, which darkens ambient light. |
214
215
  | `emissiveMap?: Texture` | The emissive color map, in sRGB. Its color multiplies `emissive`. |
@@ -218,7 +219,7 @@ The texture maps of a standard material. They are fixed when the material is cre
218
219
  | `diffuseTransmissionMap?: Texture` | The diffuse transmission in alpha, in linear color. Its alpha multiplies `diffuseTransmission`. Only a material created with `diffuseTransmission` takes it, and such a material takes no specular maps. |
219
220
  | `diffuseTransmissionColorMap?: Texture` | The diffuse transmission color, in sRGB. Its color multiplies `diffuseTransmissionColor`. Only a material created with `diffuseTransmission` takes it, and such a material takes no specular maps. |
220
221
  | `transmissionMap?: Texture` | The share of the light behind the surface that passes through it, in red, in linear color. Its red multiplies `transmission`. Only a material created with `transmission` takes it. It keeps a row slot of its own and samples the specular intensity map's texture array at its own layer, so a specular intensity map may draw beside it when the two textures share an array. A material with layers keeps it unless a layer map fills that slot: a clear coat's normal map and iridescence's thickness map do. |
221
- | `thicknessMap?: Texture` | The thickness of the volume under the surface, in green, in linear color. Its green multiplies `thickness`. Only a material created with `transmission` takes it. It keeps a row slot of its own and samples the specular color map's texture array at its own layer, so a specular color map may draw beside it when the two textures share an array. A material with layers keeps it unless a layer map fills that slot: the sheen's maps and an anisotropy map do. |
222
+ | `thicknessMap?: Texture` | The thickness of the volume under the surface, in green, in linear color. Its green multiplies `thickness`. Only a material created with `transmission` takes it. It keeps a row slot of its own and samples the specular color map's texture array at its own layer, so it takes no specular color map, whose sRGB texture never shares that array. A material with layers keeps it unless a layer map fills that slot: the sheen's maps and an anisotropy map do. |
222
223
  | `clearcoatMap?: Texture` | The clear coat in red, in linear color, which multiplies `clearcoat`. A material with a clear coat or a sheen takes no light map and no specular maps, since its layers' maps take their places. |
223
224
  | `clearcoatRoughnessMap?: Texture` | The clear coat's roughness in green, in linear color, which multiplies `clearcoatRoughness`. With `clearcoatMap`, it is the same texture, as glTF packs them. |
224
225
  | `clearcoatNormalMap?: Texture` | The clear coat's normals in tangent space, in linear color, which `clearcoatNormalScale` scales. |
@@ -247,36 +248,36 @@ The values of a standard material, which `set` changes at any time.
247
248
  | `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
249
  | `emissiveIntensity?: number` | The factor of the emissive color: 0 or more. The default is 1. |
249
250
  | `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. |
251
+ | `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. |
252
+ | `displacementScale?: number` | How far the displacement map's white moves each vertex along its normal, in the mesh's units. The default is 1. |
253
+ | `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
254
  | `aoMapIntensity?: number` | How much the occlusion map darkens ambient light, from 0 to 1. The default is 1. |
254
255
  | `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. |
256
+ | `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. |
257
+ | `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. |
258
+ | `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. |
259
+ | `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
260
  | `uvTransform?: UvTransform` | Where the maps sit on the texture coordinates. The default leaves them as they are. |
260
261
  | `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. |
262
+ | `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. |
263
+ | `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. |
264
+ | `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. |
265
+ | `attenuationDistance?: number` | The distance in world units over which light in the volume takes `attenuationColor`, above 0. `Infinity` absorbs nothing. The default is `Infinity`. |
266
+ | `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
267
  | `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
268
  | `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
269
  | `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
270
  | `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. |
271
+ | `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. |
272
+ | `clearcoatRoughness?: number` | How rough the clear coat is, from 0 (a mirror) to 1. The default is 0. |
273
+ | `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. |
274
+ | `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. |
275
+ | `sheenRoughness?: number` | How rough the sheen is, from 0 to 1: rougher sheens spread wider. The default is 1. |
276
+ | `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. |
277
+ | `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. |
278
+ | `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]`. |
279
+ | `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. |
280
+ | `anisotropyRotation?: number` | The direction along which the reflection stretches, in radians from the surface's tangent. The default is 0. |
280
281
 
281
282
  ## `TextureValues`
282
283
 
@@ -350,7 +351,7 @@ The values of an unlit material, which `set` changes at any time.
350
351
 
351
352
  Interface `UvTransform`.
352
353
 
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.
354
+ 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
355
 
355
356
  | Member | Description |
356
357
  | --- | --- |