@null3d/engine 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1357) hide show
  1. package/LICENSE-APACHE +176 -0
  2. package/LICENSE-MIT +21 -0
  3. package/README.md +108 -2
  4. package/THIRD-PARTY-NOTICES.txt +637 -0
  5. package/dist/wasm/single/null3d.js +3972 -0
  6. package/dist/wasm/single/null3d_bg.wasm +0 -0
  7. package/dist/wasm/threaded/null3d.js +3988 -0
  8. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  9. package/docs/api/animation.md +492 -0
  10. package/docs/api/assets.md +400 -0
  11. package/docs/api/cameras.md +161 -0
  12. package/docs/api/controls.md +319 -0
  13. package/docs/api/debug.md +450 -0
  14. package/docs/api/engine.md +254 -0
  15. package/docs/api/feature-draws.md +172 -0
  16. package/docs/api/feature-effects.md +137 -0
  17. package/docs/api/feature-instances.md +154 -0
  18. package/docs/api/features.md +323 -0
  19. package/docs/api/geometry.md +307 -0
  20. package/docs/api/grass.md +114 -0
  21. package/docs/api/impostors.md +274 -0
  22. package/docs/api/input.md +238 -0
  23. package/docs/api/lights.md +266 -0
  24. package/docs/api/lines.md +163 -0
  25. package/docs/api/materials.md +875 -0
  26. package/docs/api/math.md +129 -0
  27. package/docs/api/objects.md +155 -0
  28. package/docs/api/page.md +97 -0
  29. package/docs/api/particles.md +205 -0
  30. package/docs/api/points.md +130 -0
  31. package/docs/api/post.md +494 -0
  32. package/docs/api/quality.md +200 -0
  33. package/docs/api/raycast.md +269 -0
  34. package/docs/api/reference/animation.md +158 -0
  35. package/docs/api/reference/assets.md +335 -0
  36. package/docs/api/reference/cameras.md +138 -0
  37. package/docs/api/reference/controls.md +463 -0
  38. package/docs/api/reference/debug.md +586 -0
  39. package/docs/api/reference/engine.md +647 -0
  40. package/docs/api/reference/feature-draws.md +94 -0
  41. package/docs/api/reference/feature-effects.md +32 -0
  42. package/docs/api/reference/feature-instances.md +63 -0
  43. package/docs/api/reference/features.md +361 -0
  44. package/docs/api/reference/geometry.md +856 -0
  45. package/docs/api/reference/grass.md +131 -0
  46. package/docs/api/reference/impostors.md +368 -0
  47. package/docs/api/reference/input.md +121 -0
  48. package/docs/api/reference/lights.md +257 -0
  49. package/docs/api/reference/lines.md +84 -0
  50. package/docs/api/reference/materials.md +375 -0
  51. package/docs/api/reference/math.md +229 -0
  52. package/docs/api/reference/objects.md +103 -0
  53. package/docs/api/reference/particles.md +336 -0
  54. package/docs/api/reference/points.md +57 -0
  55. package/docs/api/reference/post.md +244 -0
  56. package/docs/api/reference/quality.md +213 -0
  57. package/docs/api/reference/raycast.md +94 -0
  58. package/docs/api/reference/render.md +238 -0
  59. package/docs/api/reference/scene.md +543 -0
  60. package/docs/api/reference/sketch.md +125 -0
  61. package/docs/api/reference/sound.md +203 -0
  62. package/docs/api/reference/splats.md +214 -0
  63. package/docs/api/reference/sprites.md +71 -0
  64. package/docs/api/reference/tasks.md +92 -0
  65. package/docs/api/reference/terrain.md +161 -0
  66. package/docs/api/reference/textures.md +153 -0
  67. package/docs/api/reference/three-compat.md +60 -0
  68. package/docs/api/reference/time.md +25 -0
  69. package/docs/api/reference/ui.md +52 -0
  70. package/docs/api/reference/vertex-draws.md +55 -0
  71. package/docs/api/reference/water.md +430 -0
  72. package/docs/api/reference/wind.md +106 -0
  73. package/docs/api/render.md +499 -0
  74. package/docs/api/scene.md +606 -0
  75. package/docs/api/sketch.md +231 -0
  76. package/docs/api/sound.md +169 -0
  77. package/docs/api/splats.md +264 -0
  78. package/docs/api/sprites.md +169 -0
  79. package/docs/api/tasks.md +106 -0
  80. package/docs/api/terrain.md +118 -0
  81. package/docs/api/textures.md +272 -0
  82. package/docs/api/three-compat.md +102 -0
  83. package/docs/api/time.md +134 -0
  84. package/docs/api/ui.md +134 -0
  85. package/docs/api/vertex-draws.md +171 -0
  86. package/docs/api/water.md +486 -0
  87. package/docs/api/wind.md +375 -0
  88. package/docs/cli/null3d.md +603 -0
  89. package/docs/concepts/architecture.md +174 -0
  90. package/docs/concepts/assets.md +128 -0
  91. package/docs/concepts/backends.md +197 -0
  92. package/docs/concepts/color-management.md +134 -0
  93. package/docs/concepts/culling.md +227 -0
  94. package/docs/concepts/handles.md +93 -0
  95. package/docs/concepts/instances.md +285 -0
  96. package/docs/concepts/large-worlds.md +126 -0
  97. package/docs/concepts/lighting.md +587 -0
  98. package/docs/concepts/lod.md +241 -0
  99. package/docs/concepts/materials.md +128 -0
  100. package/docs/concepts/particle-buffer.md +201 -0
  101. package/docs/concepts/post-processing.md +420 -0
  102. package/docs/concepts/quality-preset-tables.md +94 -0
  103. package/docs/concepts/quality-presets.md +341 -0
  104. package/docs/concepts/render-graph.md +222 -0
  105. package/docs/concepts/render-layers.md +111 -0
  106. package/docs/concepts/shadows.md +448 -0
  107. package/docs/concepts/static-dynamic.md +113 -0
  108. package/docs/cookbook/index.md +664 -0
  109. package/docs/data/threejs-mapping.json +2152 -0
  110. package/docs/errors/E1101.md +23 -0
  111. package/docs/errors/E1102.md +23 -0
  112. package/docs/errors/E1103.md +23 -0
  113. package/docs/errors/E1104.md +23 -0
  114. package/docs/errors/E1105.md +23 -0
  115. package/docs/errors/E1106.md +23 -0
  116. package/docs/errors/E1107.md +23 -0
  117. package/docs/errors/E1108.md +23 -0
  118. package/docs/errors/E1109.md +23 -0
  119. package/docs/errors/E1110.md +23 -0
  120. package/docs/errors/E1111.md +23 -0
  121. package/docs/errors/E1112.md +23 -0
  122. package/docs/errors/E1203.md +23 -0
  123. package/docs/errors/E1204.md +23 -0
  124. package/docs/errors/E1205.md +23 -0
  125. package/docs/errors/E1206.md +23 -0
  126. package/docs/errors/E1207.md +23 -0
  127. package/docs/errors/E1208.md +23 -0
  128. package/docs/errors/E1209.md +23 -0
  129. package/docs/errors/E1213.md +23 -0
  130. package/docs/errors/E1214.md +23 -0
  131. package/docs/errors/E1215.md +23 -0
  132. package/docs/errors/E1216.md +23 -0
  133. package/docs/errors/E1217.md +23 -0
  134. package/docs/errors/E1218.md +23 -0
  135. package/docs/errors/E1219.md +23 -0
  136. package/docs/errors/E1220.md +23 -0
  137. package/docs/errors/E1221.md +23 -0
  138. package/docs/errors/E1222.md +23 -0
  139. package/docs/errors/E1223.md +23 -0
  140. package/docs/errors/E1224.md +23 -0
  141. package/docs/errors/E1225.md +23 -0
  142. package/docs/errors/E1301.md +23 -0
  143. package/docs/errors/E1302.md +23 -0
  144. package/docs/errors/E1303.md +23 -0
  145. package/docs/errors/E1304.md +23 -0
  146. package/docs/errors/E1305.md +23 -0
  147. package/docs/errors/E1306.md +23 -0
  148. package/docs/errors/E1307.md +23 -0
  149. package/docs/errors/E1401.md +23 -0
  150. package/docs/errors/E1402.md +23 -0
  151. package/docs/errors/E1403.md +23 -0
  152. package/docs/errors/E1404.md +23 -0
  153. package/docs/errors/E1405.md +23 -0
  154. package/docs/errors/E1406.md +23 -0
  155. package/docs/errors/E1407.md +23 -0
  156. package/docs/errors/E1408.md +23 -0
  157. package/docs/errors/E1409.md +23 -0
  158. package/docs/errors/E1410.md +23 -0
  159. package/docs/errors/E1411.md +23 -0
  160. package/docs/errors/E1412.md +23 -0
  161. package/docs/errors/E1413.md +23 -0
  162. package/docs/errors/E1414.md +23 -0
  163. package/docs/errors/E1415.md +23 -0
  164. package/docs/errors/E1416.md +23 -0
  165. package/docs/errors/E1417.md +23 -0
  166. package/docs/errors/E1418.md +23 -0
  167. package/docs/errors/E1419.md +23 -0
  168. package/docs/errors/E1420.md +23 -0
  169. package/docs/errors/E1421.md +23 -0
  170. package/docs/errors/E1422.md +23 -0
  171. package/docs/errors/E1423.md +23 -0
  172. package/docs/errors/E1424.md +23 -0
  173. package/docs/errors/E1425.md +23 -0
  174. package/docs/errors/E1426.md +23 -0
  175. package/docs/errors/E1430.md +23 -0
  176. package/docs/errors/E1431.md +23 -0
  177. package/docs/errors/E1432.md +23 -0
  178. package/docs/errors/E1433.md +23 -0
  179. package/docs/errors/E1434.md +23 -0
  180. package/docs/errors/E1435.md +23 -0
  181. package/docs/errors/E1436.md +23 -0
  182. package/docs/errors/E1437.md +23 -0
  183. package/docs/errors/E1501.md +23 -0
  184. package/docs/errors/E1502.md +23 -0
  185. package/docs/errors/E1503.md +23 -0
  186. package/docs/errors/E1504.md +23 -0
  187. package/docs/errors/E1505.md +23 -0
  188. package/docs/errors/E1506.md +23 -0
  189. package/docs/errors/index.md +93 -0
  190. package/docs/getting-started/cdn.md +235 -0
  191. package/docs/getting-started/first-scene.md +129 -0
  192. package/docs/getting-started/hosting.md +400 -0
  193. package/docs/getting-started/install.md +112 -0
  194. package/docs/getting-started/network-use.md +96 -0
  195. package/docs/getting-started/project-structure.md +78 -0
  196. package/docs/getting-started/third-party-notices.md +94 -0
  197. package/docs/guides/accessibility.md +96 -0
  198. package/docs/guides/add-ons.md +160 -0
  199. package/docs/guides/agents.md +77 -0
  200. package/docs/guides/assets-pipeline.md +505 -0
  201. package/docs/guides/audio.md +148 -0
  202. package/docs/guides/baked-light-data.md +176 -0
  203. package/docs/guides/car-paint.md +121 -0
  204. package/docs/guides/content-pages.md +238 -0
  205. package/docs/guides/custom-passes.md +586 -0
  206. package/docs/guides/custom-shaders.md +293 -0
  207. package/docs/guides/debugging.md +236 -0
  208. package/docs/guides/deploying.md +115 -0
  209. package/docs/guides/deterministic-simulation.md +226 -0
  210. package/docs/guides/first-use-shaders.md +57 -0
  211. package/docs/guides/lens-kit.md +134 -0
  212. package/docs/guides/loading-screens.md +263 -0
  213. package/docs/guides/multiple-views.md +122 -0
  214. package/docs/guides/performance.md +405 -0
  215. package/docs/guides/phones.md +138 -0
  216. package/docs/guides/physics.md +202 -0
  217. package/docs/guides/screens.md +125 -0
  218. package/docs/guides/start-time.md +328 -0
  219. package/docs/guides/testing.md +245 -0
  220. package/docs/guides/ui-overlays.md +182 -0
  221. package/docs/guides/video-textures.md +110 -0
  222. package/docs/index.md +49 -0
  223. package/docs/pages.md +242 -0
  224. package/docs/porting/react-three-fiber.md +238 -0
  225. package/docs/porting/threejs-loop-and-threads.md +229 -0
  226. package/docs/porting/threejs-mapping.md +297 -0
  227. package/docs/porting/threejs-materials.md +222 -0
  228. package/docs/porting/threejs-overview.md +228 -0
  229. package/docs/porting/threejs-postprocessing.md +256 -0
  230. package/docs/porting/threejs-shaders.md +308 -0
  231. package/docs/porting/threejs-unsupported.md +91 -0
  232. package/docs/porting/verification.md +191 -0
  233. package/docs/shaders/builtins.md +129 -0
  234. package/docs/shaders/library.md +1374 -0
  235. package/docs/shaders/surface-functions.md +626 -0
  236. package/docs/shaders/wgsl-rules.md +126 -0
  237. package/levels/pieces.d.ts +178 -0
  238. package/levels/pieces.js +759 -0
  239. package/levels/planner.d.ts +126 -0
  240. package/levels/planner.js +682 -0
  241. package/lib/debug/channel.d.ts +103 -0
  242. package/lib/debug/channel.js +269 -0
  243. package/lib/debug/debug.d.ts +180 -0
  244. package/lib/debug/debug.js +4 -0
  245. package/lib/debug/draw.d.ts +146 -0
  246. package/lib/debug/draw.js +719 -0
  247. package/lib/debug/frame-target.d.ts +11 -0
  248. package/lib/debug/frame-target.js +31 -0
  249. package/lib/debug/inspector.d.ts +60 -0
  250. package/lib/debug/inspector.js +475 -0
  251. package/lib/debug/overlay-look.d.ts +162 -0
  252. package/lib/debug/overlay-look.js +1365 -0
  253. package/lib/debug/overlay.d.ts +68 -0
  254. package/lib/debug/overlay.js +195 -0
  255. package/lib/debug/page-meters.d.ts +139 -0
  256. package/lib/debug/page-meters.js +267 -0
  257. package/lib/debug/sketch-debug.d.ts +41 -0
  258. package/lib/debug/sketch-debug.js +86 -0
  259. package/lib/debug/stats-options.d.ts +15 -0
  260. package/lib/debug/stats-options.js +3 -0
  261. package/lib/debug/stats-panel.d.ts +94 -0
  262. package/lib/debug/stats-panel.js +123 -0
  263. package/lib/debug/stats-text.d.ts +169 -0
  264. package/lib/debug/stats-text.js +126 -0
  265. package/lib/debug/stats.d.ts +195 -0
  266. package/lib/debug/stats.js +252 -0
  267. package/lib/debug/view-names.d.ts +15 -0
  268. package/lib/debug/view-names.js +22 -0
  269. package/lib/errors/checks.d.ts +24 -0
  270. package/lib/errors/checks.js +38 -0
  271. package/lib/errors/codes.d.ts +15 -0
  272. package/lib/errors/codes.js +489 -0
  273. package/lib/errors/core-failure.d.ts +19 -0
  274. package/lib/errors/core-failure.js +127 -0
  275. package/lib/errors/engine-error-core.d.ts +21 -0
  276. package/lib/errors/engine-error-core.js +39 -0
  277. package/lib/errors/engine-error.d.ts +38 -0
  278. package/lib/errors/engine-error.js +132 -0
  279. package/lib/errors/fixes.d.ts +89 -0
  280. package/lib/errors/fixes.js +86 -0
  281. package/lib/errors/message.d.ts +4 -0
  282. package/lib/errors/message.js +10 -0
  283. package/lib/generated/core.d.ts +657 -0
  284. package/lib/generated/core.js +659 -0
  285. package/lib/generated/gpu.d.ts +412 -0
  286. package/lib/generated/gpu.js +414 -0
  287. package/lib/generated/shader-features.d.ts +8 -0
  288. package/lib/generated/shader-permutations.d.ts +6 -0
  289. package/lib/generated/shader-permutations.js +9 -0
  290. package/lib/generated/shaders-environment-glsl.d.ts +11 -0
  291. package/lib/generated/shaders-environment-wgsl.d.ts +11 -0
  292. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-coverage-half.d.ts +3 -0
  293. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-coverage.d.ts +3 -0
  294. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-displacement-half.d.ts +3 -0
  295. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-displacement.d.ts +3 -0
  296. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-hash-half.d.ts +3 -0
  297. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-hash.d.ts +3 -0
  298. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-lod-fade-half.d.ts +3 -0
  299. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-lod-fade.d.ts +3 -0
  300. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-morph-half.d.ts +3 -0
  301. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-morph.d.ts +3 -0
  302. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-row-values-half.d.ts +3 -0
  303. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-row-values.d.ts +3 -0
  304. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-skinning-half.d.ts +3 -0
  305. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-skinning.d.ts +3 -0
  306. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-transmission-half.d.ts +3 -0
  307. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-transmission.d.ts +3 -0
  308. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-weighted-half.d.ts +3 -0
  309. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-and-weighted.d.ts +3 -0
  310. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen-half.d.ts +3 -0
  311. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coat-sheen.d.ts +3 -0
  312. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-displacement-half.d.ts +3 -0
  313. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-displacement.d.ts +3 -0
  314. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-lod-fade-half.d.ts +3 -0
  315. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-lod-fade.d.ts +3 -0
  316. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-morph-half.d.ts +3 -0
  317. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-morph.d.ts +3 -0
  318. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-row-values-half.d.ts +3 -0
  319. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-row-values.d.ts +3 -0
  320. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-skinning-half.d.ts +3 -0
  321. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-skinning.d.ts +3 -0
  322. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-translucency-half.d.ts +3 -0
  323. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-translucency.d.ts +3 -0
  324. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-transmission-half.d.ts +3 -0
  325. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-and-transmission.d.ts +3 -0
  326. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage-half.d.ts +3 -0
  327. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-coverage.d.ts +3 -0
  328. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-hash-half.d.ts +3 -0
  329. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-hash.d.ts +3 -0
  330. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-morph-half.d.ts +3 -0
  331. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-morph.d.ts +3 -0
  332. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-row-values-half.d.ts +3 -0
  333. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-row-values.d.ts +3 -0
  334. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-skinning-half.d.ts +3 -0
  335. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-skinning.d.ts +3 -0
  336. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-translucency-half.d.ts +3 -0
  337. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-translucency.d.ts +3 -0
  338. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-transmission-half.d.ts +3 -0
  339. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-transmission.d.ts +3 -0
  340. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-weighted-half.d.ts +3 -0
  341. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-and-weighted.d.ts +3 -0
  342. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement-half.d.ts +3 -0
  343. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-displacement.d.ts +3 -0
  344. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash-and-morph-half.d.ts +3 -0
  345. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash-and-morph.d.ts +3 -0
  346. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash-and-row-values-half.d.ts +3 -0
  347. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash-and-row-values.d.ts +3 -0
  348. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash-and-skinning-half.d.ts +3 -0
  349. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash-and-skinning.d.ts +3 -0
  350. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash-and-translucency-half.d.ts +3 -0
  351. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash-and-translucency.d.ts +3 -0
  352. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash-half.d.ts +3 -0
  353. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-hash.d.ts +3 -0
  354. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-lod-fade-and-row-values-half.d.ts +3 -0
  355. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-lod-fade-and-row-values.d.ts +3 -0
  356. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-lod-fade-and-translucency-half.d.ts +3 -0
  357. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-lod-fade-and-translucency.d.ts +3 -0
  358. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-lod-fade-half.d.ts +3 -0
  359. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-lod-fade.d.ts +3 -0
  360. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph-and-skinning-half.d.ts +3 -0
  361. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph-and-skinning.d.ts +3 -0
  362. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph-and-translucency-half.d.ts +3 -0
  363. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph-and-translucency.d.ts +3 -0
  364. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph-and-transmission-half.d.ts +3 -0
  365. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph-and-transmission.d.ts +3 -0
  366. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph-and-weighted-half.d.ts +3 -0
  367. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph-and-weighted.d.ts +3 -0
  368. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph-half.d.ts +3 -0
  369. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-morph.d.ts +3 -0
  370. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-row-values-and-translucency-half.d.ts +3 -0
  371. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-row-values-and-translucency.d.ts +3 -0
  372. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-row-values-and-weighted-half.d.ts +3 -0
  373. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-row-values-and-weighted.d.ts +3 -0
  374. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-row-values-half.d.ts +3 -0
  375. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-row-values.d.ts +3 -0
  376. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-skinning-and-translucency-half.d.ts +3 -0
  377. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-skinning-and-translucency.d.ts +3 -0
  378. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-skinning-and-transmission-half.d.ts +3 -0
  379. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-skinning-and-transmission.d.ts +3 -0
  380. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-skinning-and-weighted-half.d.ts +3 -0
  381. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-skinning-and-weighted.d.ts +3 -0
  382. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-skinning-half.d.ts +3 -0
  383. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-skinning.d.ts +3 -0
  384. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-translucency-half.d.ts +3 -0
  385. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-translucency.d.ts +3 -0
  386. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-transmission-half.d.ts +3 -0
  387. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-transmission.d.ts +3 -0
  388. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-weighted-half.d.ts +3 -0
  389. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-and-weighted.d.ts +3 -0
  390. package/lib/generated/shaders-glsl-combos-area-lights-and-bump-half.d.ts +3 -0
  391. package/lib/generated/shaders-glsl-combos-area-lights-and-bump.d.ts +3 -0
  392. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-displacement-half.d.ts +3 -0
  393. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-displacement.d.ts +3 -0
  394. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-lod-fade-half.d.ts +3 -0
  395. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-lod-fade.d.ts +3 -0
  396. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-morph-half.d.ts +3 -0
  397. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-morph.d.ts +3 -0
  398. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-row-values-half.d.ts +3 -0
  399. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-row-values.d.ts +3 -0
  400. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-skinning-half.d.ts +3 -0
  401. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-skinning.d.ts +3 -0
  402. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-transmission-half.d.ts +3 -0
  403. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-and-transmission.d.ts +3 -0
  404. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage-half.d.ts +3 -0
  405. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-coverage.d.ts +3 -0
  406. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-hash-half.d.ts +3 -0
  407. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-hash.d.ts +3 -0
  408. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-morph-half.d.ts +3 -0
  409. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-morph.d.ts +3 -0
  410. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-row-values-half.d.ts +3 -0
  411. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-row-values.d.ts +3 -0
  412. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-skinning-half.d.ts +3 -0
  413. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-skinning.d.ts +3 -0
  414. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-transmission-half.d.ts +3 -0
  415. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-transmission.d.ts +3 -0
  416. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-weighted-half.d.ts +3 -0
  417. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-and-weighted.d.ts +3 -0
  418. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement-half.d.ts +3 -0
  419. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-displacement.d.ts +3 -0
  420. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-hash-and-morph-half.d.ts +3 -0
  421. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-hash-and-morph.d.ts +3 -0
  422. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-hash-and-row-values-half.d.ts +3 -0
  423. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-hash-and-row-values.d.ts +3 -0
  424. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-hash-and-skinning-half.d.ts +3 -0
  425. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-hash-and-skinning.d.ts +3 -0
  426. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-hash-half.d.ts +3 -0
  427. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-hash.d.ts +3 -0
  428. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-lod-fade-and-row-values-half.d.ts +3 -0
  429. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-lod-fade-and-row-values.d.ts +3 -0
  430. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-lod-fade-half.d.ts +3 -0
  431. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-lod-fade.d.ts +3 -0
  432. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-morph-and-skinning-half.d.ts +3 -0
  433. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-morph-and-skinning.d.ts +3 -0
  434. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-morph-and-transmission-half.d.ts +3 -0
  435. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-morph-and-transmission.d.ts +3 -0
  436. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-morph-and-weighted-half.d.ts +3 -0
  437. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-morph-and-weighted.d.ts +3 -0
  438. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-morph-half.d.ts +3 -0
  439. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-morph.d.ts +3 -0
  440. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-row-values-and-weighted-half.d.ts +3 -0
  441. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-row-values-and-weighted.d.ts +3 -0
  442. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-row-values-half.d.ts +3 -0
  443. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-row-values.d.ts +3 -0
  444. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-skinning-and-transmission-half.d.ts +3 -0
  445. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-skinning-and-transmission.d.ts +3 -0
  446. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-skinning-and-weighted-half.d.ts +3 -0
  447. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-skinning-and-weighted.d.ts +3 -0
  448. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-skinning-half.d.ts +3 -0
  449. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-skinning.d.ts +3 -0
  450. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-transmission-half.d.ts +3 -0
  451. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-transmission.d.ts +3 -0
  452. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-weighted-half.d.ts +3 -0
  453. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-and-weighted.d.ts +3 -0
  454. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen-half.d.ts +3 -0
  455. package/lib/generated/shaders-glsl-combos-area-lights-and-coat-sheen.d.ts +3 -0
  456. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-morph-half.d.ts +3 -0
  457. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-morph.d.ts +3 -0
  458. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-row-values-half.d.ts +3 -0
  459. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-row-values.d.ts +3 -0
  460. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-skinning-half.d.ts +3 -0
  461. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-skinning.d.ts +3 -0
  462. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-translucency-half.d.ts +3 -0
  463. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-translucency.d.ts +3 -0
  464. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-transmission-half.d.ts +3 -0
  465. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-and-transmission.d.ts +3 -0
  466. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement-half.d.ts +3 -0
  467. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-displacement.d.ts +3 -0
  468. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-lod-fade-and-row-values-half.d.ts +3 -0
  469. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-lod-fade-and-row-values.d.ts +3 -0
  470. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-lod-fade-and-translucency-half.d.ts +3 -0
  471. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-lod-fade-and-translucency.d.ts +3 -0
  472. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-lod-fade-half.d.ts +3 -0
  473. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-lod-fade.d.ts +3 -0
  474. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-morph-and-skinning-half.d.ts +3 -0
  475. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-morph-and-skinning.d.ts +3 -0
  476. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-morph-and-translucency-half.d.ts +3 -0
  477. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-morph-and-translucency.d.ts +3 -0
  478. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-morph-and-transmission-half.d.ts +3 -0
  479. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-morph-and-transmission.d.ts +3 -0
  480. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-morph-half.d.ts +3 -0
  481. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-morph.d.ts +3 -0
  482. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-row-values-and-translucency-half.d.ts +3 -0
  483. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-row-values-and-translucency.d.ts +3 -0
  484. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-row-values-half.d.ts +3 -0
  485. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-row-values.d.ts +3 -0
  486. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-skinning-and-translucency-half.d.ts +3 -0
  487. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-skinning-and-translucency.d.ts +3 -0
  488. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-skinning-and-transmission-half.d.ts +3 -0
  489. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-skinning-and-transmission.d.ts +3 -0
  490. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-skinning-half.d.ts +3 -0
  491. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-skinning.d.ts +3 -0
  492. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-translucency-half.d.ts +3 -0
  493. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-translucency.d.ts +3 -0
  494. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-transmission-half.d.ts +3 -0
  495. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-and-transmission.d.ts +3 -0
  496. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage-half.d.ts +3 -0
  497. package/lib/generated/shaders-glsl-combos-area-lights-and-coverage.d.ts +3 -0
  498. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash-and-morph-half.d.ts +3 -0
  499. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash-and-morph.d.ts +3 -0
  500. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash-and-row-values-half.d.ts +3 -0
  501. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash-and-row-values.d.ts +3 -0
  502. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash-and-skinning-half.d.ts +3 -0
  503. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash-and-skinning.d.ts +3 -0
  504. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash-and-translucency-half.d.ts +3 -0
  505. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash-and-translucency.d.ts +3 -0
  506. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash-half.d.ts +3 -0
  507. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-hash.d.ts +3 -0
  508. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment-and-morph-half.d.ts +3 -0
  509. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment-and-morph.d.ts +3 -0
  510. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment-and-row-values-half.d.ts +3 -0
  511. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment-and-row-values.d.ts +3 -0
  512. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment-and-skinning-half.d.ts +3 -0
  513. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment-and-skinning.d.ts +3 -0
  514. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment-and-translucency-half.d.ts +3 -0
  515. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment-and-translucency.d.ts +3 -0
  516. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment-half.d.ts +3 -0
  517. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-moment.d.ts +3 -0
  518. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph-and-skinning-half.d.ts +3 -0
  519. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph-and-skinning.d.ts +3 -0
  520. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph-and-translucency-half.d.ts +3 -0
  521. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph-and-translucency.d.ts +3 -0
  522. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph-and-transmission-half.d.ts +3 -0
  523. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph-and-transmission.d.ts +3 -0
  524. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph-and-weighted-half.d.ts +3 -0
  525. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph-and-weighted.d.ts +3 -0
  526. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph-half.d.ts +3 -0
  527. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-morph.d.ts +3 -0
  528. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-row-values-and-translucency-half.d.ts +3 -0
  529. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-row-values-and-translucency.d.ts +3 -0
  530. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-row-values-and-weighted-half.d.ts +3 -0
  531. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-row-values-and-weighted.d.ts +3 -0
  532. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-row-values-half.d.ts +3 -0
  533. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-row-values.d.ts +3 -0
  534. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-skinning-and-translucency-half.d.ts +3 -0
  535. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-skinning-and-translucency.d.ts +3 -0
  536. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-skinning-and-transmission-half.d.ts +3 -0
  537. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-skinning-and-transmission.d.ts +3 -0
  538. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-skinning-and-weighted-half.d.ts +3 -0
  539. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-skinning-and-weighted.d.ts +3 -0
  540. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-skinning-half.d.ts +3 -0
  541. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-skinning.d.ts +3 -0
  542. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-translucency-half.d.ts +3 -0
  543. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-translucency.d.ts +3 -0
  544. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-transmission-half.d.ts +3 -0
  545. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-transmission.d.ts +3 -0
  546. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-weighted-half.d.ts +3 -0
  547. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-and-weighted.d.ts +3 -0
  548. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement-half.d.ts +3 -0
  549. package/lib/generated/shaders-glsl-combos-area-lights-and-displacement.d.ts +3 -0
  550. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-morph-and-skinning-half.d.ts +3 -0
  551. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-morph-and-skinning.d.ts +3 -0
  552. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-morph-and-translucency-half.d.ts +3 -0
  553. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-morph-and-translucency.d.ts +3 -0
  554. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-morph-half.d.ts +3 -0
  555. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-morph.d.ts +3 -0
  556. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-row-values-and-translucency-half.d.ts +3 -0
  557. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-row-values-and-translucency.d.ts +3 -0
  558. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-row-values-half.d.ts +3 -0
  559. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-row-values.d.ts +3 -0
  560. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-skinning-and-translucency-half.d.ts +3 -0
  561. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-skinning-and-translucency.d.ts +3 -0
  562. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-skinning-half.d.ts +3 -0
  563. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-skinning.d.ts +3 -0
  564. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-translucency-half.d.ts +3 -0
  565. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-and-translucency.d.ts +3 -0
  566. package/lib/generated/shaders-glsl-combos-area-lights-and-hash-half.d.ts +3 -0
  567. package/lib/generated/shaders-glsl-combos-area-lights-and-hash.d.ts +3 -0
  568. package/lib/generated/shaders-glsl-combos-area-lights-and-lines.d.ts +3 -0
  569. package/lib/generated/shaders-glsl-combos-area-lights-and-lod-fade-and-row-values-and-translucency-half.d.ts +3 -0
  570. package/lib/generated/shaders-glsl-combos-area-lights-and-lod-fade-and-row-values-and-translucency.d.ts +3 -0
  571. package/lib/generated/shaders-glsl-combos-area-lights-and-lod-fade-and-row-values-half.d.ts +3 -0
  572. package/lib/generated/shaders-glsl-combos-area-lights-and-lod-fade-and-row-values.d.ts +3 -0
  573. package/lib/generated/shaders-glsl-combos-area-lights-and-lod-fade-and-translucency-half.d.ts +3 -0
  574. package/lib/generated/shaders-glsl-combos-area-lights-and-lod-fade-and-translucency.d.ts +3 -0
  575. package/lib/generated/shaders-glsl-combos-area-lights-and-lod-fade-half.d.ts +3 -0
  576. package/lib/generated/shaders-glsl-combos-area-lights-and-lod-fade.d.ts +3 -0
  577. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-morph-and-skinning-half.d.ts +3 -0
  578. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-morph-and-skinning.d.ts +3 -0
  579. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-morph-and-translucency-half.d.ts +3 -0
  580. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-morph-and-translucency.d.ts +3 -0
  581. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-morph-half.d.ts +3 -0
  582. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-morph.d.ts +3 -0
  583. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-row-values-and-translucency-half.d.ts +3 -0
  584. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-row-values-and-translucency.d.ts +3 -0
  585. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-row-values-half.d.ts +3 -0
  586. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-row-values.d.ts +3 -0
  587. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-skinning-and-translucency-half.d.ts +3 -0
  588. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-skinning-and-translucency.d.ts +3 -0
  589. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-skinning-half.d.ts +3 -0
  590. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-skinning.d.ts +3 -0
  591. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-translucency-half.d.ts +3 -0
  592. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-and-translucency.d.ts +3 -0
  593. package/lib/generated/shaders-glsl-combos-area-lights-and-moment-half.d.ts +3 -0
  594. package/lib/generated/shaders-glsl-combos-area-lights-and-moment.d.ts +3 -0
  595. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-skinning-and-translucency-half.d.ts +3 -0
  596. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-skinning-and-translucency.d.ts +3 -0
  597. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-skinning-and-transmission-half.d.ts +3 -0
  598. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-skinning-and-transmission.d.ts +3 -0
  599. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-skinning-and-weighted-half.d.ts +3 -0
  600. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-skinning-and-weighted.d.ts +3 -0
  601. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-skinning-half.d.ts +3 -0
  602. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-skinning.d.ts +3 -0
  603. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-translucency-half.d.ts +3 -0
  604. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-translucency.d.ts +3 -0
  605. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-transmission-half.d.ts +3 -0
  606. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-transmission.d.ts +3 -0
  607. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-weighted-half.d.ts +3 -0
  608. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-and-weighted.d.ts +3 -0
  609. package/lib/generated/shaders-glsl-combos-area-lights-and-morph-half.d.ts +3 -0
  610. package/lib/generated/shaders-glsl-combos-area-lights-and-morph.d.ts +3 -0
  611. package/lib/generated/shaders-glsl-combos-area-lights-and-row-values-and-translucency-half.d.ts +3 -0
  612. package/lib/generated/shaders-glsl-combos-area-lights-and-row-values-and-translucency.d.ts +3 -0
  613. package/lib/generated/shaders-glsl-combos-area-lights-and-row-values-and-weighted-half.d.ts +3 -0
  614. package/lib/generated/shaders-glsl-combos-area-lights-and-row-values-and-weighted.d.ts +3 -0
  615. package/lib/generated/shaders-glsl-combos-area-lights-and-row-values-half.d.ts +3 -0
  616. package/lib/generated/shaders-glsl-combos-area-lights-and-row-values.d.ts +3 -0
  617. package/lib/generated/shaders-glsl-combos-area-lights-and-skinning-and-translucency-half.d.ts +3 -0
  618. package/lib/generated/shaders-glsl-combos-area-lights-and-skinning-and-translucency.d.ts +3 -0
  619. package/lib/generated/shaders-glsl-combos-area-lights-and-skinning-and-transmission-half.d.ts +3 -0
  620. package/lib/generated/shaders-glsl-combos-area-lights-and-skinning-and-transmission.d.ts +3 -0
  621. package/lib/generated/shaders-glsl-combos-area-lights-and-skinning-and-weighted-half.d.ts +3 -0
  622. package/lib/generated/shaders-glsl-combos-area-lights-and-skinning-and-weighted.d.ts +3 -0
  623. package/lib/generated/shaders-glsl-combos-area-lights-and-skinning-half.d.ts +3 -0
  624. package/lib/generated/shaders-glsl-combos-area-lights-and-skinning.d.ts +3 -0
  625. package/lib/generated/shaders-glsl-combos-area-lights-and-translucency-half.d.ts +3 -0
  626. package/lib/generated/shaders-glsl-combos-area-lights-and-translucency.d.ts +3 -0
  627. package/lib/generated/shaders-glsl-combos-area-lights-and-transmission-half.d.ts +3 -0
  628. package/lib/generated/shaders-glsl-combos-area-lights-and-transmission.d.ts +3 -0
  629. package/lib/generated/shaders-glsl-combos-area-lights-and-weighted-half.d.ts +3 -0
  630. package/lib/generated/shaders-glsl-combos-area-lights-and-weighted.d.ts +3 -0
  631. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-coverage-half.d.ts +3 -0
  632. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-coverage.d.ts +3 -0
  633. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-displacement-half.d.ts +3 -0
  634. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-displacement.d.ts +3 -0
  635. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-hash-half.d.ts +3 -0
  636. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-hash.d.ts +3 -0
  637. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-lod-fade-half.d.ts +3 -0
  638. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-lod-fade.d.ts +3 -0
  639. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-morph-half.d.ts +3 -0
  640. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-morph.d.ts +3 -0
  641. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-row-values-half.d.ts +3 -0
  642. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-row-values.d.ts +3 -0
  643. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-skinning-half.d.ts +3 -0
  644. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-skinning.d.ts +3 -0
  645. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-transmission-half.d.ts +3 -0
  646. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-transmission.d.ts +3 -0
  647. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-weighted-half.d.ts +3 -0
  648. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-and-weighted.d.ts +3 -0
  649. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen-half.d.ts +3 -0
  650. package/lib/generated/shaders-glsl-combos-bump-and-coat-sheen.d.ts +3 -0
  651. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-displacement-half.d.ts +3 -0
  652. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-displacement.d.ts +3 -0
  653. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-lod-fade-half.d.ts +3 -0
  654. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-lod-fade.d.ts +3 -0
  655. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-morph-half.d.ts +3 -0
  656. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-morph.d.ts +3 -0
  657. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-row-values-half.d.ts +3 -0
  658. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-row-values.d.ts +3 -0
  659. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-skinning-half.d.ts +3 -0
  660. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-skinning.d.ts +3 -0
  661. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-translucency-half.d.ts +3 -0
  662. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-translucency.d.ts +3 -0
  663. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-transmission-half.d.ts +3 -0
  664. package/lib/generated/shaders-glsl-combos-bump-and-coverage-and-transmission.d.ts +3 -0
  665. package/lib/generated/shaders-glsl-combos-bump-and-coverage-half.d.ts +3 -0
  666. package/lib/generated/shaders-glsl-combos-bump-and-coverage.d.ts +3 -0
  667. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-hash-half.d.ts +3 -0
  668. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-hash.d.ts +3 -0
  669. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-morph-half.d.ts +3 -0
  670. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-morph.d.ts +3 -0
  671. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-row-values-half.d.ts +3 -0
  672. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-row-values.d.ts +3 -0
  673. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-skinning-half.d.ts +3 -0
  674. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-skinning.d.ts +3 -0
  675. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-translucency-half.d.ts +3 -0
  676. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-translucency.d.ts +3 -0
  677. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-transmission-half.d.ts +3 -0
  678. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-transmission.d.ts +3 -0
  679. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-weighted-half.d.ts +3 -0
  680. package/lib/generated/shaders-glsl-combos-bump-and-displacement-and-weighted.d.ts +3 -0
  681. package/lib/generated/shaders-glsl-combos-bump-and-displacement-half.d.ts +3 -0
  682. package/lib/generated/shaders-glsl-combos-bump-and-displacement.d.ts +3 -0
  683. package/lib/generated/shaders-glsl-combos-bump-and-hash-and-morph-half.d.ts +3 -0
  684. package/lib/generated/shaders-glsl-combos-bump-and-hash-and-morph.d.ts +3 -0
  685. package/lib/generated/shaders-glsl-combos-bump-and-hash-and-row-values-half.d.ts +3 -0
  686. package/lib/generated/shaders-glsl-combos-bump-and-hash-and-row-values.d.ts +3 -0
  687. package/lib/generated/shaders-glsl-combos-bump-and-hash-and-skinning-half.d.ts +3 -0
  688. package/lib/generated/shaders-glsl-combos-bump-and-hash-and-skinning.d.ts +3 -0
  689. package/lib/generated/shaders-glsl-combos-bump-and-hash-and-translucency-half.d.ts +3 -0
  690. package/lib/generated/shaders-glsl-combos-bump-and-hash-and-translucency.d.ts +3 -0
  691. package/lib/generated/shaders-glsl-combos-bump-and-hash-half.d.ts +3 -0
  692. package/lib/generated/shaders-glsl-combos-bump-and-hash.d.ts +3 -0
  693. package/lib/generated/shaders-glsl-combos-bump-and-lod-fade-and-row-values-half.d.ts +3 -0
  694. package/lib/generated/shaders-glsl-combos-bump-and-lod-fade-and-row-values.d.ts +3 -0
  695. package/lib/generated/shaders-glsl-combos-bump-and-lod-fade-and-translucency-half.d.ts +3 -0
  696. package/lib/generated/shaders-glsl-combos-bump-and-lod-fade-and-translucency.d.ts +3 -0
  697. package/lib/generated/shaders-glsl-combos-bump-and-lod-fade-half.d.ts +3 -0
  698. package/lib/generated/shaders-glsl-combos-bump-and-lod-fade.d.ts +3 -0
  699. package/lib/generated/shaders-glsl-combos-bump-and-morph-and-skinning-half.d.ts +3 -0
  700. package/lib/generated/shaders-glsl-combos-bump-and-morph-and-skinning.d.ts +3 -0
  701. package/lib/generated/shaders-glsl-combos-bump-and-morph-and-translucency-half.d.ts +3 -0
  702. package/lib/generated/shaders-glsl-combos-bump-and-morph-and-translucency.d.ts +3 -0
  703. package/lib/generated/shaders-glsl-combos-bump-and-morph-and-transmission-half.d.ts +3 -0
  704. package/lib/generated/shaders-glsl-combos-bump-and-morph-and-transmission.d.ts +3 -0
  705. package/lib/generated/shaders-glsl-combos-bump-and-morph-and-weighted-half.d.ts +3 -0
  706. package/lib/generated/shaders-glsl-combos-bump-and-morph-and-weighted.d.ts +3 -0
  707. package/lib/generated/shaders-glsl-combos-bump-and-morph-half.d.ts +3 -0
  708. package/lib/generated/shaders-glsl-combos-bump-and-morph.d.ts +3 -0
  709. package/lib/generated/shaders-glsl-combos-bump-and-row-values-and-translucency-half.d.ts +3 -0
  710. package/lib/generated/shaders-glsl-combos-bump-and-row-values-and-translucency.d.ts +3 -0
  711. package/lib/generated/shaders-glsl-combos-bump-and-row-values-and-weighted-half.d.ts +3 -0
  712. package/lib/generated/shaders-glsl-combos-bump-and-row-values-and-weighted.d.ts +3 -0
  713. package/lib/generated/shaders-glsl-combos-bump-and-row-values-half.d.ts +3 -0
  714. package/lib/generated/shaders-glsl-combos-bump-and-row-values.d.ts +3 -0
  715. package/lib/generated/shaders-glsl-combos-bump-and-skinning-and-translucency-half.d.ts +3 -0
  716. package/lib/generated/shaders-glsl-combos-bump-and-skinning-and-translucency.d.ts +3 -0
  717. package/lib/generated/shaders-glsl-combos-bump-and-skinning-and-transmission-half.d.ts +3 -0
  718. package/lib/generated/shaders-glsl-combos-bump-and-skinning-and-transmission.d.ts +3 -0
  719. package/lib/generated/shaders-glsl-combos-bump-and-skinning-and-weighted-half.d.ts +3 -0
  720. package/lib/generated/shaders-glsl-combos-bump-and-skinning-and-weighted.d.ts +3 -0
  721. package/lib/generated/shaders-glsl-combos-bump-and-skinning-half.d.ts +3 -0
  722. package/lib/generated/shaders-glsl-combos-bump-and-skinning.d.ts +3 -0
  723. package/lib/generated/shaders-glsl-combos-bump-and-translucency-half.d.ts +3 -0
  724. package/lib/generated/shaders-glsl-combos-bump-and-translucency.d.ts +3 -0
  725. package/lib/generated/shaders-glsl-combos-bump-and-transmission-half.d.ts +3 -0
  726. package/lib/generated/shaders-glsl-combos-bump-and-transmission.d.ts +3 -0
  727. package/lib/generated/shaders-glsl-combos-bump-and-weighted-half.d.ts +3 -0
  728. package/lib/generated/shaders-glsl-combos-bump-and-weighted.d.ts +3 -0
  729. package/lib/generated/shaders-glsl-combos-coat-sheen-and-coverage-half.d.ts +3 -0
  730. package/lib/generated/shaders-glsl-combos-coat-sheen-and-coverage.d.ts +3 -0
  731. package/lib/generated/shaders-glsl-combos-coat-sheen-and-displacement-half.d.ts +3 -0
  732. package/lib/generated/shaders-glsl-combos-coat-sheen-and-displacement.d.ts +3 -0
  733. package/lib/generated/shaders-glsl-combos-coat-sheen-and-hash-half.d.ts +3 -0
  734. package/lib/generated/shaders-glsl-combos-coat-sheen-and-hash.d.ts +3 -0
  735. package/lib/generated/shaders-glsl-combos-coat-sheen-and-lod-fade-half.d.ts +3 -0
  736. package/lib/generated/shaders-glsl-combos-coat-sheen-and-lod-fade.d.ts +3 -0
  737. package/lib/generated/shaders-glsl-combos-coat-sheen-and-morph-half.d.ts +3 -0
  738. package/lib/generated/shaders-glsl-combos-coat-sheen-and-morph.d.ts +3 -0
  739. package/lib/generated/shaders-glsl-combos-coat-sheen-and-row-values-half.d.ts +3 -0
  740. package/lib/generated/shaders-glsl-combos-coat-sheen-and-row-values.d.ts +3 -0
  741. package/lib/generated/shaders-glsl-combos-coat-sheen-and-skinning-half.d.ts +3 -0
  742. package/lib/generated/shaders-glsl-combos-coat-sheen-and-skinning.d.ts +3 -0
  743. package/lib/generated/shaders-glsl-combos-coat-sheen-and-transmission-half.d.ts +3 -0
  744. package/lib/generated/shaders-glsl-combos-coat-sheen-and-transmission.d.ts +3 -0
  745. package/lib/generated/shaders-glsl-combos-coat-sheen-and-weighted-half.d.ts +3 -0
  746. package/lib/generated/shaders-glsl-combos-coat-sheen-and-weighted.d.ts +3 -0
  747. package/lib/generated/shaders-glsl-combos-coverage-half.d.ts +3 -0
  748. package/lib/generated/shaders-glsl-combos-coverage.d.ts +3 -0
  749. package/lib/generated/shaders-glsl-combos-cutout.d.ts +3 -0
  750. package/lib/generated/shaders-glsl-combos-decals-half.d.ts +3 -0
  751. package/lib/generated/shaders-glsl-combos-decals.d.ts +3 -0
  752. package/lib/generated/shaders-glsl-combos-displacement-half.d.ts +3 -0
  753. package/lib/generated/shaders-glsl-combos-displacement.d.ts +3 -0
  754. package/lib/generated/shaders-glsl-combos-hash-half.d.ts +3 -0
  755. package/lib/generated/shaders-glsl-combos-hash.d.ts +3 -0
  756. package/lib/generated/shaders-glsl-combos-lod-fade-half.d.ts +3 -0
  757. package/lib/generated/shaders-glsl-combos-lod-fade.d.ts +3 -0
  758. package/lib/generated/shaders-glsl-combos-moment-half.d.ts +3 -0
  759. package/lib/generated/shaders-glsl-combos-moment.d.ts +3 -0
  760. package/lib/generated/shaders-glsl-combos-morph-half.d.ts +3 -0
  761. package/lib/generated/shaders-glsl-combos-morph.d.ts +3 -0
  762. package/lib/generated/shaders-glsl-combos-motion.d.ts +3 -0
  763. package/lib/generated/shaders-glsl-combos-picking.d.ts +3 -0
  764. package/lib/generated/shaders-glsl-combos-probe-grid-half.d.ts +3 -0
  765. package/lib/generated/shaders-glsl-combos-probe-grid.d.ts +3 -0
  766. package/lib/generated/shaders-glsl-combos-row-values-half.d.ts +3 -0
  767. package/lib/generated/shaders-glsl-combos-row-values.d.ts +3 -0
  768. package/lib/generated/shaders-glsl-combos-skinning-half.d.ts +3 -0
  769. package/lib/generated/shaders-glsl-combos-skinning.d.ts +3 -0
  770. package/lib/generated/shaders-glsl-combos-sprites.d.ts +3 -0
  771. package/lib/generated/shaders-glsl-combos-subsurface-half.d.ts +3 -0
  772. package/lib/generated/shaders-glsl-combos-subsurface.d.ts +3 -0
  773. package/lib/generated/shaders-probe-glsl.d.ts +11 -0
  774. package/lib/generated/shaders-probe-wgsl.d.ts +11 -0
  775. package/lib/generated/shaders-sky-volume-env-glsl.d.ts +11 -0
  776. package/lib/generated/shaders-sky-volume-env-wgsl.d.ts +11 -0
  777. package/lib/generated/shaders-sky-volume-panorama-glsl.d.ts +11 -0
  778. package/lib/generated/shaders-sky-volume-panorama-wgsl.d.ts +11 -0
  779. package/lib/generated/shaders-wgsl-combos-area-lights-and-bump-half.d.ts +3 -0
  780. package/lib/generated/shaders-wgsl-combos-area-lights-and-bump.d.ts +3 -0
  781. package/lib/generated/shaders-wgsl-combos-area-lights-and-coat-sheen-half.d.ts +3 -0
  782. package/lib/generated/shaders-wgsl-combos-area-lights-and-coat-sheen.d.ts +3 -0
  783. package/lib/generated/shaders-wgsl-combos-area-lights-and-coverage-half.d.ts +3 -0
  784. package/lib/generated/shaders-wgsl-combos-area-lights-and-coverage.d.ts +3 -0
  785. package/lib/generated/shaders-wgsl-combos-area-lights-and-displacement-half.d.ts +3 -0
  786. package/lib/generated/shaders-wgsl-combos-area-lights-and-displacement.d.ts +3 -0
  787. package/lib/generated/shaders-wgsl-combos-area-lights-and-hash-half.d.ts +3 -0
  788. package/lib/generated/shaders-wgsl-combos-area-lights-and-hash.d.ts +3 -0
  789. package/lib/generated/shaders-wgsl-combos-area-lights-and-instance-index-half.d.ts +3 -0
  790. package/lib/generated/shaders-wgsl-combos-area-lights-and-instance-index.d.ts +3 -0
  791. package/lib/generated/shaders-wgsl-combos-area-lights-and-lines.d.ts +3 -0
  792. package/lib/generated/shaders-wgsl-combos-area-lights-and-lod-fade-half.d.ts +3 -0
  793. package/lib/generated/shaders-wgsl-combos-area-lights-and-lod-fade.d.ts +3 -0
  794. package/lib/generated/shaders-wgsl-combos-area-lights-and-moment-half.d.ts +3 -0
  795. package/lib/generated/shaders-wgsl-combos-area-lights-and-moment.d.ts +3 -0
  796. package/lib/generated/shaders-wgsl-combos-area-lights-and-row-values-half.d.ts +3 -0
  797. package/lib/generated/shaders-wgsl-combos-area-lights-and-row-values.d.ts +3 -0
  798. package/lib/generated/shaders-wgsl-combos-area-lights-and-skinning-half.d.ts +3 -0
  799. package/lib/generated/shaders-wgsl-combos-area-lights-and-skinning.d.ts +3 -0
  800. package/lib/generated/shaders-wgsl-combos-area-lights-and-translucency-half.d.ts +3 -0
  801. package/lib/generated/shaders-wgsl-combos-area-lights-and-translucency.d.ts +3 -0
  802. package/lib/generated/shaders-wgsl-combos-area-lights-and-transmission-half.d.ts +3 -0
  803. package/lib/generated/shaders-wgsl-combos-area-lights-and-transmission.d.ts +3 -0
  804. package/lib/generated/shaders-wgsl-combos-area-lights-and-weighted-half.d.ts +3 -0
  805. package/lib/generated/shaders-wgsl-combos-area-lights-and-weighted.d.ts +3 -0
  806. package/lib/generated/shaders-wgsl-combos-bump-half.d.ts +3 -0
  807. package/lib/generated/shaders-wgsl-combos-bump.d.ts +3 -0
  808. package/lib/generated/shaders-wgsl-combos-coat-sheen-half.d.ts +3 -0
  809. package/lib/generated/shaders-wgsl-combos-coat-sheen.d.ts +3 -0
  810. package/lib/generated/shaders-wgsl-combos-coverage-half.d.ts +3 -0
  811. package/lib/generated/shaders-wgsl-combos-coverage.d.ts +3 -0
  812. package/lib/generated/shaders-wgsl-combos-cutout.d.ts +3 -0
  813. package/lib/generated/shaders-wgsl-combos-decals-half.d.ts +3 -0
  814. package/lib/generated/shaders-wgsl-combos-decals.d.ts +3 -0
  815. package/lib/generated/shaders-wgsl-combos-displacement-half.d.ts +3 -0
  816. package/lib/generated/shaders-wgsl-combos-displacement.d.ts +3 -0
  817. package/lib/generated/shaders-wgsl-combos-hash-half.d.ts +3 -0
  818. package/lib/generated/shaders-wgsl-combos-hash.d.ts +3 -0
  819. package/lib/generated/shaders-wgsl-combos-instance-index-half.d.ts +3 -0
  820. package/lib/generated/shaders-wgsl-combos-instance-index.d.ts +3 -0
  821. package/lib/generated/shaders-wgsl-combos-lod-fade-half.d.ts +3 -0
  822. package/lib/generated/shaders-wgsl-combos-lod-fade.d.ts +3 -0
  823. package/lib/generated/shaders-wgsl-combos-moment-half.d.ts +3 -0
  824. package/lib/generated/shaders-wgsl-combos-moment.d.ts +3 -0
  825. package/lib/generated/shaders-wgsl-combos-motion.d.ts +3 -0
  826. package/lib/generated/shaders-wgsl-combos-picking.d.ts +3 -0
  827. package/lib/generated/shaders-wgsl-combos-probe-grid-half.d.ts +3 -0
  828. package/lib/generated/shaders-wgsl-combos-probe-grid.d.ts +3 -0
  829. package/lib/generated/shaders-wgsl-combos-row-values-half.d.ts +3 -0
  830. package/lib/generated/shaders-wgsl-combos-row-values.d.ts +3 -0
  831. package/lib/generated/shaders-wgsl-combos-skinning-half.d.ts +3 -0
  832. package/lib/generated/shaders-wgsl-combos-skinning.d.ts +3 -0
  833. package/lib/generated/shaders-wgsl-combos-sprites.d.ts +3 -0
  834. package/lib/generated/shaders-wgsl-combos-subsurface-half.d.ts +3 -0
  835. package/lib/generated/shaders-wgsl-combos-subsurface.d.ts +3 -0
  836. package/lib/generated/shaders.d.ts +1146 -0
  837. package/lib/gpu/canvas-release.d.ts +20 -0
  838. package/lib/gpu/canvas-release.js +67 -0
  839. package/lib/gpu/completion.d.ts +35 -0
  840. package/lib/gpu/completion.js +256 -0
  841. package/lib/gpu/device-shaders.d.ts +69 -0
  842. package/lib/gpu/device-shaders.js +177 -0
  843. package/lib/gpu/early-builds.d.ts +68 -0
  844. package/lib/gpu/early-builds.js +158 -0
  845. package/lib/gpu/effect-join.d.ts +83 -0
  846. package/lib/gpu/effect-join.js +134 -0
  847. package/lib/gpu/effect-joiner.d.ts +14 -0
  848. package/lib/gpu/effect-joiner.js +165 -0
  849. package/lib/gpu/environment-steps.d.ts +135 -0
  850. package/lib/gpu/environment-steps.js +210 -0
  851. package/lib/gpu/environment-words.d.ts +14 -0
  852. package/lib/gpu/environment-words.js +19 -0
  853. package/lib/gpu/environment.d.ts +4 -0
  854. package/lib/gpu/environment.js +8 -0
  855. package/lib/gpu/float-bits.d.ts +2 -0
  856. package/lib/gpu/float-bits.js +9 -0
  857. package/lib/gpu/line-vertices.d.ts +1 -0
  858. package/lib/gpu/line-vertices.js +14 -0
  859. package/lib/gpu/memory.d.ts +19 -0
  860. package/lib/gpu/memory.js +50 -0
  861. package/lib/gpu/particle-records.d.ts +1 -0
  862. package/lib/gpu/particle-records.js +15 -0
  863. package/lib/gpu/pipeline-name.d.ts +6 -0
  864. package/lib/gpu/pipeline-name.js +23 -0
  865. package/lib/gpu/probe-steps.d.ts +22 -0
  866. package/lib/gpu/probe-steps.js +43 -0
  867. package/lib/gpu/readback.d.ts +32 -0
  868. package/lib/gpu/readback.js +163 -0
  869. package/lib/gpu/variants.d.ts +16 -0
  870. package/lib/gpu/variants.js +67 -0
  871. package/lib/gpu/vertex-format.d.ts +46 -0
  872. package/lib/gpu/vertex-format.js +111 -0
  873. package/lib/gpu/webgl2/backend.d.ts +714 -0
  874. package/lib/gpu/webgl2/backend.js +2964 -0
  875. package/lib/gpu/webgl2/call-timing.d.ts +34 -0
  876. package/lib/gpu/webgl2/call-timing.js +143 -0
  877. package/lib/gpu/webgl2/context.d.ts +31 -0
  878. package/lib/gpu/webgl2/context.js +111 -0
  879. package/lib/gpu/webgl2/depth.d.ts +25 -0
  880. package/lib/gpu/webgl2/depth.js +30 -0
  881. package/lib/gpu/webgl2/environment.d.ts +65 -0
  882. package/lib/gpu/webgl2/environment.js +572 -0
  883. package/lib/gpu/webgl2/gpu-timer.d.ts +25 -0
  884. package/lib/gpu/webgl2/gpu-timer.js +93 -0
  885. package/lib/gpu/webgl2/probes.d.ts +38 -0
  886. package/lib/gpu/webgl2/probes.js +117 -0
  887. package/lib/gpu/webgl2/programs.d.ts +238 -0
  888. package/lib/gpu/webgl2/programs.js +487 -0
  889. package/lib/gpu/webgpu/backend.d.ts +460 -0
  890. package/lib/gpu/webgpu/backend.js +1812 -0
  891. package/lib/gpu/webgpu/buffer-reads.d.ts +42 -0
  892. package/lib/gpu/webgpu/buffer-reads.js +95 -0
  893. package/lib/gpu/webgpu/culled-counts.d.ts +79 -0
  894. package/lib/gpu/webgpu/culled-counts.js +259 -0
  895. package/lib/gpu/webgpu/draw-path-probe.d.ts +37 -0
  896. package/lib/gpu/webgpu/draw-path-probe.js +187 -0
  897. package/lib/gpu/webgpu/environment.d.ts +36 -0
  898. package/lib/gpu/webgpu/environment.js +735 -0
  899. package/lib/gpu/webgpu/first-pass.d.ts +13 -0
  900. package/lib/gpu/webgpu/first-pass.js +61 -0
  901. package/lib/gpu/webgpu/gpu-timer.d.ts +67 -0
  902. package/lib/gpu/webgpu/gpu-timer.js +328 -0
  903. package/lib/gpu/webgpu/indirect-arguments.d.ts +42 -0
  904. package/lib/gpu/webgpu/indirect-arguments.js +156 -0
  905. package/lib/gpu/webgpu/pipelines.d.ts +264 -0
  906. package/lib/gpu/webgpu/pipelines.js +2013 -0
  907. package/lib/gpu/webgpu/probes.d.ts +27 -0
  908. package/lib/gpu/webgpu/probes.js +190 -0
  909. package/lib/gpu/webgpu/reusable.d.ts +74 -0
  910. package/lib/gpu/webgpu/reusable.js +212 -0
  911. package/lib/gpu/webgpu/staging.d.ts +79 -0
  912. package/lib/gpu/webgpu/staging.js +238 -0
  913. package/lib/gpu/webgpu/upload-routes.d.ts +55 -0
  914. package/lib/gpu/webgpu/upload-routes.js +128 -0
  915. package/lib/index.d.ts +121 -0
  916. package/lib/index.js +54 -0
  917. package/lib/math/color.d.ts +18 -0
  918. package/lib/math/color.js +71 -0
  919. package/lib/math/create-math.d.ts +101 -0
  920. package/lib/math/create-math.js +207 -0
  921. package/lib/math/hex.d.ts +8 -0
  922. package/lib/math/hex.js +38 -0
  923. package/lib/math/index.d.ts +2 -0
  924. package/lib/math/index.js +11 -0
  925. package/lib/math/mat4.d.ts +22 -0
  926. package/lib/math/mat4.js +206 -0
  927. package/lib/math/math.d.ts +16 -0
  928. package/lib/math/math.js +42 -0
  929. package/lib/math/namespaces/math.d.ts +7 -0
  930. package/lib/math/namespaces/math.js +14 -0
  931. package/lib/math/namespaces/quat.d.ts +20 -0
  932. package/lib/math/namespaces/quat.js +30 -0
  933. package/lib/math/namespaces/vec3.d.ts +4 -0
  934. package/lib/math/namespaces/vec3.js +8 -0
  935. package/lib/math/quat.d.ts +36 -0
  936. package/lib/math/quat.js +224 -0
  937. package/lib/math/random.d.ts +16 -0
  938. package/lib/math/random.js +57 -0
  939. package/lib/math/types.d.ts +43 -0
  940. package/lib/math/types.js +4 -0
  941. package/lib/math/vec3.d.ts +43 -0
  942. package/lib/math/vec3.js +187 -0
  943. package/lib/page/abortable.d.ts +2 -0
  944. package/lib/page/abortable.js +19 -0
  945. package/lib/page/browser-check.d.ts +8 -0
  946. package/lib/page/browser-check.js +23 -0
  947. package/lib/page/canvas-watch.d.ts +34 -0
  948. package/lib/page/canvas-watch.js +141 -0
  949. package/lib/page/capabilities.d.ts +201 -0
  950. package/lib/page/capabilities.js +409 -0
  951. package/lib/page/check-store.d.ts +54 -0
  952. package/lib/page/check-store.js +169 -0
  953. package/lib/page/display.d.ts +2 -0
  954. package/lib/page/display.js +25 -0
  955. package/lib/page/early-core.d.ts +1 -0
  956. package/lib/page/early-core.js +23 -0
  957. package/lib/page/engine.d.ts +942 -0
  958. package/lib/page/engine.js +2459 -0
  959. package/lib/page/first-frame.d.ts +16 -0
  960. package/lib/page/first-frame.js +35 -0
  961. package/lib/page/frame-stats.d.ts +402 -0
  962. package/lib/page/frame-stats.js +389 -0
  963. package/lib/page/gamepads.d.ts +37 -0
  964. package/lib/page/gamepads.js +123 -0
  965. package/lib/page/held-input.d.ts +19 -0
  966. package/lib/page/held-input.js +54 -0
  967. package/lib/page/hold.d.ts +186 -0
  968. package/lib/page/hold.js +49 -0
  969. package/lib/page/input-ring.d.ts +13 -0
  970. package/lib/page/input-ring.js +25 -0
  971. package/lib/page/input.d.ts +6 -0
  972. package/lib/page/input.js +159 -0
  973. package/lib/page/isolation-check.d.ts +14 -0
  974. package/lib/page/isolation-check.js +21 -0
  975. package/lib/page/label-loop.d.ts +80 -0
  976. package/lib/page/label-loop.js +417 -0
  977. package/lib/page/labels.d.ts +56 -0
  978. package/lib/page/labels.js +102 -0
  979. package/lib/page/limits.d.ts +321 -0
  980. package/lib/page/limits.js +323 -0
  981. package/lib/page/loader.d.ts +78 -0
  982. package/lib/page/loader.js +149 -0
  983. package/lib/page/main-thread.d.ts +10 -0
  984. package/lib/page/main-thread.js +41 -0
  985. package/lib/page/memory-pool.d.ts +26 -0
  986. package/lib/page/memory-pool.js +69 -0
  987. package/lib/page/ownership.d.ts +65 -0
  988. package/lib/page/ownership.js +166 -0
  989. package/lib/page/permutation-recording.d.ts +26 -0
  990. package/lib/page/permutation-recording.js +32 -0
  991. package/lib/page/pipeline-store.d.ts +25 -0
  992. package/lib/page/pipeline-store.js +84 -0
  993. package/lib/page/pointer-lock.d.ts +14 -0
  994. package/lib/page/pointer-lock.js +60 -0
  995. package/lib/page/preferences.d.ts +2 -0
  996. package/lib/page/preferences.js +11 -0
  997. package/lib/page/record-button.d.ts +5 -0
  998. package/lib/page/record-button.js +60 -0
  999. package/lib/page/start-marker.d.ts +47 -0
  1000. package/lib/page/start-marker.js +119 -0
  1001. package/lib/page/stats-switch.d.ts +16 -0
  1002. package/lib/page/stats-switch.js +38 -0
  1003. package/lib/page/stop-jobs.d.ts +37 -0
  1004. package/lib/page/stop-jobs.js +87 -0
  1005. package/lib/page/switches.d.ts +347 -0
  1006. package/lib/page/switches.js +150 -0
  1007. package/lib/page/videos.d.ts +70 -0
  1008. package/lib/page/videos.js +244 -0
  1009. package/lib/quality/budget.d.ts +14 -0
  1010. package/lib/quality/budget.js +25 -0
  1011. package/lib/quality/check.d.ts +119 -0
  1012. package/lib/quality/check.js +84 -0
  1013. package/lib/quality/chooser.d.ts +98 -0
  1014. package/lib/quality/chooser.js +108 -0
  1015. package/lib/quality/device-hints.d.ts +8 -0
  1016. package/lib/quality/device-hints.js +18 -0
  1017. package/lib/quality/governor.d.ts +571 -0
  1018. package/lib/quality/governor.js +1293 -0
  1019. package/lib/quality/preset-docs.d.ts +402 -0
  1020. package/lib/quality/preset-docs.js +179 -0
  1021. package/lib/quality/presets.d.ts +821 -0
  1022. package/lib/quality/presets.js +678 -0
  1023. package/lib/render/direct-loop.d.ts +4 -0
  1024. package/lib/render/direct-loop.js +52 -0
  1025. package/lib/render/draw.d.ts +66 -0
  1026. package/lib/render/draw.js +111 -0
  1027. package/lib/render/load-draw.d.ts +12 -0
  1028. package/lib/render/load-draw.js +18 -0
  1029. package/lib/render/loop.d.ts +241 -0
  1030. package/lib/render/loop.js +566 -0
  1031. package/lib/render/loss.d.ts +53 -0
  1032. package/lib/render/loss.js +127 -0
  1033. package/lib/render/pacer.d.ts +24 -0
  1034. package/lib/render/pacer.js +51 -0
  1035. package/lib/render/recovery.d.ts +82 -0
  1036. package/lib/render/recovery.js +160 -0
  1037. package/lib/render/refresh.d.ts +38 -0
  1038. package/lib/render/refresh.js +111 -0
  1039. package/lib/render/renderer.d.ts +192 -0
  1040. package/lib/render/renderer.js +295 -0
  1041. package/lib/render/scene-renderer.d.ts +135 -0
  1042. package/lib/render/scene-renderer.js +216 -0
  1043. package/lib/render/shader-salt.d.ts +5 -0
  1044. package/lib/render/shader-salt.js +31 -0
  1045. package/lib/render/webgl2-renderers.d.ts +11 -0
  1046. package/lib/render/webgl2-renderers.js +227 -0
  1047. package/lib/render/webgpu-renderers.d.ts +10 -0
  1048. package/lib/render/webgpu-renderers.js +254 -0
  1049. package/lib/scene/addon-debug-views.d.ts +30 -0
  1050. package/lib/scene/addon-debug-views.js +63 -0
  1051. package/lib/scene/animation.d.ts +547 -0
  1052. package/lib/scene/animation.js +1425 -0
  1053. package/lib/scene/area-light-tables.d.ts +32 -0
  1054. package/lib/scene/area-light-tables.js +89 -0
  1055. package/lib/scene/assets.d.ts +375 -0
  1056. package/lib/scene/assets.js +736 -0
  1057. package/lib/scene/background.d.ts +238 -0
  1058. package/lib/scene/background.js +470 -0
  1059. package/lib/scene/baked-light.d.ts +60 -0
  1060. package/lib/scene/baked-light.js +300 -0
  1061. package/lib/scene/builtin-environments.d.ts +36 -0
  1062. package/lib/scene/builtin-environments.js +43 -0
  1063. package/lib/scene/chunk-rows.d.ts +81 -0
  1064. package/lib/scene/chunk-rows.js +146 -0
  1065. package/lib/scene/color.d.ts +22 -0
  1066. package/lib/scene/color.js +45 -0
  1067. package/lib/scene/derived-cache.d.ts +139 -0
  1068. package/lib/scene/derived-cache.js +547 -0
  1069. package/lib/scene/downloads.d.ts +2 -0
  1070. package/lib/scene/downloads.js +371 -0
  1071. package/lib/scene/effects.d.ts +193 -0
  1072. package/lib/scene/effects.js +476 -0
  1073. package/lib/scene/environment-file.d.ts +22 -0
  1074. package/lib/scene/environment-file.js +81 -0
  1075. package/lib/scene/environment.d.ts +57 -0
  1076. package/lib/scene/environment.js +131 -0
  1077. package/lib/scene/fake-call-values.d.ts +8 -0
  1078. package/lib/scene/fake-call-values.js +51 -0
  1079. package/lib/scene/feature-draws.d.ts +169 -0
  1080. package/lib/scene/feature-draws.js +269 -0
  1081. package/lib/scene/feature-effects.d.ts +42 -0
  1082. package/lib/scene/feature-effects.js +155 -0
  1083. package/lib/scene/feature-host.d.ts +129 -0
  1084. package/lib/scene/feature-host.js +299 -0
  1085. package/lib/scene/feature-instances.d.ts +130 -0
  1086. package/lib/scene/feature-instances.js +326 -0
  1087. package/lib/scene/features.d.ts +412 -0
  1088. package/lib/scene/features.js +550 -0
  1089. package/lib/scene/file-limits.d.ts +70 -0
  1090. package/lib/scene/file-limits.js +224 -0
  1091. package/lib/scene/fog.d.ts +101 -0
  1092. package/lib/scene/fog.js +148 -0
  1093. package/lib/scene/frame-cameras.d.ts +175 -0
  1094. package/lib/scene/frame-cameras.js +492 -0
  1095. package/lib/scene/gltf-animation.d.ts +129 -0
  1096. package/lib/scene/gltf-animation.js +887 -0
  1097. package/lib/scene/gltf-draco.d.ts +9 -0
  1098. package/lib/scene/gltf-draco.js +224 -0
  1099. package/lib/scene/gltf-extensions.d.ts +31 -0
  1100. package/lib/scene/gltf-extensions.js +92 -0
  1101. package/lib/scene/gltf-json.d.ts +49 -0
  1102. package/lib/scene/gltf-json.js +94 -0
  1103. package/lib/scene/gltf-math.d.ts +16 -0
  1104. package/lib/scene/gltf-math.js +129 -0
  1105. package/lib/scene/gltf-meshopt.d.ts +3 -0
  1106. package/lib/scene/gltf-meshopt.js +48 -0
  1107. package/lib/scene/gltf-parse.d.ts +600 -0
  1108. package/lib/scene/gltf-parse.js +1854 -0
  1109. package/lib/scene/gltf.d.ts +189 -0
  1110. package/lib/scene/gltf.js +1589 -0
  1111. package/lib/scene/grade-table.d.ts +9 -0
  1112. package/lib/scene/grade-table.js +23 -0
  1113. package/lib/scene/grade-task.d.ts +12 -0
  1114. package/lib/scene/grade-task.js +11 -0
  1115. package/lib/scene/grading.d.ts +110 -0
  1116. package/lib/scene/grading.js +142 -0
  1117. package/lib/scene/half-float.d.ts +4 -0
  1118. package/lib/scene/half-float.js +42 -0
  1119. package/lib/scene/ktx2-cache.d.ts +32 -0
  1120. package/lib/scene/ktx2-cache.js +62 -0
  1121. package/lib/scene/ktx2-file.d.ts +57 -0
  1122. package/lib/scene/ktx2-file.js +207 -0
  1123. package/lib/scene/ktx2-transcode.d.ts +15 -0
  1124. package/lib/scene/ktx2-transcode.js +94 -0
  1125. package/lib/scene/ktx2.d.ts +42 -0
  1126. package/lib/scene/ktx2.js +179 -0
  1127. package/lib/scene/lens.d.ts +61 -0
  1128. package/lib/scene/lens.js +101 -0
  1129. package/lib/scene/level-meshopt.d.ts +20 -0
  1130. package/lib/scene/level-meshopt.js +122 -0
  1131. package/lib/scene/level-pieces.d.ts +24 -0
  1132. package/lib/scene/level-pieces.js +138 -0
  1133. package/lib/scene/level-rule.d.ts +120 -0
  1134. package/lib/scene/level-rule.js +130 -0
  1135. package/lib/scene/level-words.d.ts +19 -0
  1136. package/lib/scene/level-words.js +34 -0
  1137. package/lib/scene/levels-task.d.ts +51 -0
  1138. package/lib/scene/levels-task.js +132 -0
  1139. package/lib/scene/light-images.d.ts +36 -0
  1140. package/lib/scene/light-images.js +88 -0
  1141. package/lib/scene/light-probes.d.ts +240 -0
  1142. package/lib/scene/light-probes.js +644 -0
  1143. package/lib/scene/lines.d.ts +188 -0
  1144. package/lib/scene/lines.js +257 -0
  1145. package/lib/scene/lut-files.d.ts +41 -0
  1146. package/lib/scene/lut-files.js +399 -0
  1147. package/lib/scene/lut.d.ts +55 -0
  1148. package/lib/scene/lut.js +47 -0
  1149. package/lib/scene/memory.d.ts +72 -0
  1150. package/lib/scene/memory.js +159 -0
  1151. package/lib/scene/mesh-arrays.d.ts +110 -0
  1152. package/lib/scene/mesh-arrays.js +701 -0
  1153. package/lib/scene/mesh-levels.d.ts +10 -0
  1154. package/lib/scene/mesh-levels.js +52 -0
  1155. package/lib/scene/namespaces.d.ts +125 -0
  1156. package/lib/scene/namespaces.js +313 -0
  1157. package/lib/scene/panorama-files.d.ts +71 -0
  1158. package/lib/scene/panorama-files.js +1103 -0
  1159. package/lib/scene/panorama.d.ts +23 -0
  1160. package/lib/scene/panorama.js +108 -0
  1161. package/lib/scene/particles.d.ts +452 -0
  1162. package/lib/scene/particles.js +814 -0
  1163. package/lib/scene/pass-reads.d.ts +70 -0
  1164. package/lib/scene/pass-reads.js +220 -0
  1165. package/lib/scene/picks.d.ts +69 -0
  1166. package/lib/scene/picks.js +208 -0
  1167. package/lib/scene/pointer-events.d.ts +202 -0
  1168. package/lib/scene/pointer-events.js +500 -0
  1169. package/lib/scene/post.d.ts +567 -0
  1170. package/lib/scene/post.js +928 -0
  1171. package/lib/scene/prefab.d.ts +109 -0
  1172. package/lib/scene/prefab.js +166 -0
  1173. package/lib/scene/probes.d.ts +71 -0
  1174. package/lib/scene/probes.js +169 -0
  1175. package/lib/scene/property-animation.d.ts +160 -0
  1176. package/lib/scene/property-animation.js +276 -0
  1177. package/lib/scene/queries.d.ts +176 -0
  1178. package/lib/scene/queries.js +393 -0
  1179. package/lib/scene/render.d.ts +487 -0
  1180. package/lib/scene/render.js +829 -0
  1181. package/lib/scene/resources.d.ts +1598 -0
  1182. package/lib/scene/resources.js +2843 -0
  1183. package/lib/scene/rotation.d.ts +6 -0
  1184. package/lib/scene/rotation.js +12 -0
  1185. package/lib/scene/scene.d.ts +1858 -0
  1186. package/lib/scene/scene.js +4680 -0
  1187. package/lib/scene/serial-loads.d.ts +29 -0
  1188. package/lib/scene/serial-loads.js +68 -0
  1189. package/lib/scene/shader-preloads.d.ts +74 -0
  1190. package/lib/scene/shader-preloads.js +116 -0
  1191. package/lib/scene/shader-templates.d.ts +60 -0
  1192. package/lib/scene/shader-templates.js +156 -0
  1193. package/lib/scene/sprites.d.ts +262 -0
  1194. package/lib/scene/sprites.js +292 -0
  1195. package/lib/scene/stale-calls-scenario.d.ts +20 -0
  1196. package/lib/scene/stale-calls-scenario.js +175 -0
  1197. package/lib/scene/textures.d.ts +323 -0
  1198. package/lib/scene/textures.js +953 -0
  1199. package/lib/scene/time-of-day.d.ts +145 -0
  1200. package/lib/scene/time-of-day.js +644 -0
  1201. package/lib/scene/unmarked-writes.d.ts +118 -0
  1202. package/lib/scene/unmarked-writes.js +283 -0
  1203. package/lib/scene/unread-extensions-scenario.d.ts +6 -0
  1204. package/lib/scene/unread-extensions-scenario.js +26 -0
  1205. package/lib/scene/vertex-draws.d.ts +82 -0
  1206. package/lib/scene/vertex-draws.js +85 -0
  1207. package/lib/scene/wgsl-uniforms.d.ts +167 -0
  1208. package/lib/scene/wgsl-uniforms.js +12 -0
  1209. package/lib/shader-artifact.json +1 -0
  1210. package/lib/shared/await-later.d.ts +5 -0
  1211. package/lib/shared/await-later.js +10 -0
  1212. package/lib/shared/control.d.ts +94 -0
  1213. package/lib/shared/control.js +150 -0
  1214. package/lib/shared/core-sources.d.ts +2 -0
  1215. package/lib/shared/core-sources.js +7 -0
  1216. package/lib/shared/core.d.ts +1254 -0
  1217. package/lib/shared/core.js +381 -0
  1218. package/lib/shared/counter.d.ts +52 -0
  1219. package/lib/shared/counter.js +55 -0
  1220. package/lib/shared/dev.d.ts +8 -0
  1221. package/lib/shared/dev.js +13 -0
  1222. package/lib/shared/feature-stats.d.ts +16 -0
  1223. package/lib/shared/feature-stats.js +27 -0
  1224. package/lib/shared/frame-image.d.ts +13 -0
  1225. package/lib/shared/frame-image.js +32 -0
  1226. package/lib/shared/gpu-clock.d.ts +14 -0
  1227. package/lib/shared/gpu-clock.js +38 -0
  1228. package/lib/shared/gpu-counter.d.ts +12 -0
  1229. package/lib/shared/gpu-counter.js +15 -0
  1230. package/lib/shared/gpu-scope.d.ts +14 -0
  1231. package/lib/shared/gpu-scope.js +104 -0
  1232. package/lib/shared/helper-workers.d.ts +4 -0
  1233. package/lib/shared/helper-workers.js +23 -0
  1234. package/lib/shared/images.d.ts +255 -0
  1235. package/lib/shared/images.js +450 -0
  1236. package/lib/shared/import-once.d.ts +6 -0
  1237. package/lib/shared/import-once.js +19 -0
  1238. package/lib/shared/key-codes.d.ts +2 -0
  1239. package/lib/shared/key-codes.js +69 -0
  1240. package/lib/shared/labels.d.ts +94 -0
  1241. package/lib/shared/labels.js +172 -0
  1242. package/lib/shared/memory-area.d.ts +6 -0
  1243. package/lib/shared/memory-area.js +21 -0
  1244. package/lib/shared/memory-figure.d.ts +14 -0
  1245. package/lib/shared/memory-figure.js +18 -0
  1246. package/lib/shared/memory-views.d.ts +48 -0
  1247. package/lib/shared/memory-views.js +90 -0
  1248. package/lib/shared/metrics.d.ts +353 -0
  1249. package/lib/shared/metrics.js +799 -0
  1250. package/lib/shared/page-measurement.d.ts +9 -0
  1251. package/lib/shared/page-measurement.js +37 -0
  1252. package/lib/shared/phase.d.ts +17 -0
  1253. package/lib/shared/phase.js +20 -0
  1254. package/lib/shared/policy.d.ts +20 -0
  1255. package/lib/shared/policy.js +46 -0
  1256. package/lib/shared/recording.d.ts +100 -0
  1257. package/lib/shared/recording.js +378 -0
  1258. package/lib/shared/role.d.ts +10 -0
  1259. package/lib/shared/role.js +13 -0
  1260. package/lib/shared/run-task.d.ts +39 -0
  1261. package/lib/shared/run-task.js +69 -0
  1262. package/lib/shared/slot.d.ts +218 -0
  1263. package/lib/shared/slot.js +221 -0
  1264. package/lib/shared/software.d.ts +24 -0
  1265. package/lib/shared/software.js +22 -0
  1266. package/lib/shared/stats.d.ts +62 -0
  1267. package/lib/shared/stats.js +86 -0
  1268. package/lib/shared/task-failure.d.ts +24 -0
  1269. package/lib/shared/task-failure.js +36 -0
  1270. package/lib/shared/task-host.d.ts +42 -0
  1271. package/lib/shared/task-host.js +60 -0
  1272. package/lib/shared/task-load-error.d.ts +10 -0
  1273. package/lib/shared/task-load-error.js +13 -0
  1274. package/lib/shared/task-modules.d.ts +2 -0
  1275. package/lib/shared/task-modules.js +8 -0
  1276. package/lib/shared/task-pending.d.ts +24 -0
  1277. package/lib/shared/task-pending.js +101 -0
  1278. package/lib/shared/tasks.d.ts +54 -0
  1279. package/lib/shared/tasks.js +426 -0
  1280. package/lib/shared/tier.d.ts +7 -0
  1281. package/lib/shared/tier.js +3 -0
  1282. package/lib/shared/version.d.ts +72 -0
  1283. package/lib/shared/version.js +103 -0
  1284. package/lib/shared/videos.d.ts +15 -0
  1285. package/lib/shared/videos.js +11 -0
  1286. package/lib/shared/wake.d.ts +38 -0
  1287. package/lib/shared/wake.js +76 -0
  1288. package/lib/shared/wasm-limits.d.ts +13 -0
  1289. package/lib/shared/wasm-limits.js +75 -0
  1290. package/lib/shared/wasm.d.ts +34 -0
  1291. package/lib/shared/wasm.js +151 -0
  1292. package/lib/shared/webkit.d.ts +33 -0
  1293. package/lib/shared/webkit.js +59 -0
  1294. package/lib/shared/wgsl-updates.d.ts +9 -0
  1295. package/lib/shared/wgsl-updates.js +8 -0
  1296. package/lib/shared/worker-start.d.ts +56 -0
  1297. package/lib/shared/worker-start.js +186 -0
  1298. package/lib/sketch/clock.d.ts +61 -0
  1299. package/lib/sketch/clock.js +98 -0
  1300. package/lib/sketch/define-sketch.d.ts +269 -0
  1301. package/lib/sketch/define-sketch.js +103 -0
  1302. package/lib/sketch/input-off-scenario.d.ts +7 -0
  1303. package/lib/sketch/input-off-scenario.js +24 -0
  1304. package/lib/sketch/input-off.d.ts +16 -0
  1305. package/lib/sketch/input-off.js +38 -0
  1306. package/lib/sketch/input.d.ts +243 -0
  1307. package/lib/sketch/input.js +554 -0
  1308. package/lib/sketch/preset-check.d.ts +42 -0
  1309. package/lib/sketch/preset-check.js +120 -0
  1310. package/lib/sketch/quality.d.ts +392 -0
  1311. package/lib/sketch/quality.js +355 -0
  1312. package/lib/sketch/random.d.ts +13 -0
  1313. package/lib/sketch/random.js +25 -0
  1314. package/lib/sketch/runner.d.ts +574 -0
  1315. package/lib/sketch/runner.js +2159 -0
  1316. package/lib/sketch/ui.d.ts +94 -0
  1317. package/lib/sketch/ui.js +391 -0
  1318. package/lib/stats.d.ts +4 -0
  1319. package/lib/stats.js +8 -0
  1320. package/lib/workers/drawing-host.d.ts +24 -0
  1321. package/lib/workers/drawing-host.js +48 -0
  1322. package/lib/workers/gltf-worker.d.ts +35 -0
  1323. package/lib/workers/gltf-worker.js +210 -0
  1324. package/lib/workers/job-worker.d.ts +1 -0
  1325. package/lib/workers/job-worker.js +102 -0
  1326. package/lib/workers/panorama-worker.d.ts +15 -0
  1327. package/lib/workers/panorama-worker.js +21 -0
  1328. package/lib/workers/probe-worker.d.ts +34 -0
  1329. package/lib/workers/probe-worker.js +58 -0
  1330. package/lib/workers/protocol.d.ts +377 -0
  1331. package/lib/workers/protocol.js +57 -0
  1332. package/lib/workers/render-worker.d.ts +1 -0
  1333. package/lib/workers/render-worker.js +103 -0
  1334. package/lib/workers/sketch-worker.d.ts +1 -0
  1335. package/lib/workers/sketch-worker.js +295 -0
  1336. package/lib/workers/task-worker.d.ts +1 -0
  1337. package/lib/workers/task-worker.js +5 -0
  1338. package/lib/workers/tasks.d.ts +65 -0
  1339. package/lib/workers/tasks.js +85 -0
  1340. package/package.json +106 -5
  1341. package/vendor/basis/LICENSE +201 -0
  1342. package/vendor/basis/LICENSE-zstd +30 -0
  1343. package/vendor/basis/NOTICE +15 -0
  1344. package/vendor/basis/basis_transcoder.d.mts +36 -0
  1345. package/vendor/basis/basis_transcoder.mjs +2 -0
  1346. package/vendor/basis/basis_transcoder.wasm +0 -0
  1347. package/vendor/draco/LICENSE +252 -0
  1348. package/vendor/draco/draco_decoder_gltf.wasm +0 -0
  1349. package/vendor/draco/draco_wasm_wrapper_gltf.d.ts +71 -0
  1350. package/vendor/draco/draco_wasm_wrapper_gltf.js +116 -0
  1351. package/vendor/ltc/LICENSE +31 -0
  1352. package/vendor/ltc/area-light-tables.bin +0 -0
  1353. package/vendor/meshopt/LICENSE.md +21 -0
  1354. package/vendor/meshopt/meshopt_clusterizer.wasm +0 -0
  1355. package/vendor/meshopt/meshopt_decoder.wasm +0 -0
  1356. package/vendor/meshopt/meshopt_encoder.wasm +0 -0
  1357. package/vendor/meshopt/meshopt_simplifier.wasm +0 -0
@@ -0,0 +1,2843 @@
1
+ // Meshes and materials, created through `ctx.geometry` and `ctx.materials`. Each is created once
2
+ // and shared by any number of objects and instance batches.
3
+ import { DEV } from '../errors/checks.js';
4
+ import { EngineError } from '../errors/engine-error.js';
5
+ import { LEVEL_SWITCH_COVERAGE, LEVEL_SWITCH_DISTANCE, LEVEL_SWITCH_ERROR, LEVELS_MAX, MAP_ROW_SLOT_ANISOTROPY, MAP_ROW_SLOT_BUMP, MAP_ROW_SLOT_COAT, MAP_ROW_SLOT_COAT_NORMAL, MAP_ROW_SLOT_COAT_ROUGHNESS, MAP_ROW_SLOT_DISPLACEMENT, MAP_ROW_SLOT_IRIDESCENCE, MAP_ROW_SLOT_IRIDESCENCE_THICKNESS, MAP_ROW_SLOT_SHEEN_COLOR, MAP_ROW_SLOT_SHEEN_ROUGHNESS, MAP_ROW_SLOT_THICKNESS, MAP_ROW_SLOT_TRANSMISSION, MAP_SLOT_ANISOTROPY, MAP_SLOT_BASE_COLOR, MAP_SLOT_BUMP, MAP_SLOT_COAT, MAP_SLOT_COAT_NORMAL, MAP_SLOT_COAT_ROUGHNESS, MAP_SLOT_DIFFUSE_TRANSMISSION, MAP_SLOT_DIFFUSE_TRANSMISSION_COLOR, MAP_SLOT_DISPLACEMENT, MAP_SLOT_EMISSIVE, MAP_SLOT_IRIDESCENCE, MAP_SLOT_IRIDESCENCE_THICKNESS, MAP_SLOT_LIGHT, MAP_SLOT_LIGHT_MAP_DIRECTION, MAP_SLOT_METAL_ROUGH, MAP_SLOT_NORMAL, MAP_SLOT_OCCLUSION, MAP_SLOT_SHEEN_COLOR, MAP_SLOT_SHEEN_ROUGHNESS, MAP_SLOT_SPECULAR_COLOR, MAP_SLOT_SPECULAR_INTENSITY, MAP_SLOT_THICKNESS, MAP_SLOT_TRANSMISSION, MATERIAL_FEATURE_ADDITIVE, MATERIAL_FEATURE_ALPHA_HASH, MATERIAL_FEATURE_ALPHA_MASK, MATERIAL_FEATURE_ALPHA_TO_COVERAGE, MATERIAL_FEATURE_ANISOTROPY, MATERIAL_FEATURE_BLEND, MATERIAL_FEATURE_CASTER_COVERAGE, MATERIAL_FEATURE_COAT_SHEEN, MATERIAL_FEATURE_DECAL, MATERIAL_FEATURE_DOUBLE_SIDED, MATERIAL_FEATURE_FLAT_SHADING, MATERIAL_FEATURE_IRIDESCENCE, MATERIAL_FEATURE_LIGHT_MAP_RGBM, MATERIAL_FEATURE_MOVING_VERTICES, MATERIAL_FEATURE_MULTIPLY, MATERIAL_FEATURE_NO_COLOR_WRITE, MATERIAL_FEATURE_NO_CONTACT_SHADOWS, MATERIAL_FEATURE_NO_DEPTH_TEST, MATERIAL_FEATURE_NO_DEPTH_WRITE, MATERIAL_FEATURE_NO_FOG, MATERIAL_FEATURE_NO_TONE_MAP, MATERIAL_FEATURE_PARALLAX, MATERIAL_FEATURE_SCENE_DEPTH, MATERIAL_FEATURE_SHADOW_CATCHER, MATERIAL_FEATURE_SINGLE_PASS, MATERIAL_FEATURE_STILL_CASTER, MATERIAL_FEATURE_SUBSURFACE, MATERIAL_FEATURE_TRANSLUCENCY, MATERIAL_FEATURE_TRANSMISSION, MATERIAL_FEATURE_VERTEX_COLORS, MATERIAL_FEATURE_WEIGHTED, MATERIAL_FEATURE_WIREFRAME, MATERIAL_PARAM_ALPHA_CUTOFF, MATERIAL_PARAM_ANISOTROPY, MATERIAL_PARAM_ANISOTROPY_ROTATION, MATERIAL_PARAM_ATTENUATION_COLOR, MATERIAL_PARAM_ATTENUATION_DISTANCE, MATERIAL_PARAM_CLEARCOAT, MATERIAL_PARAM_CLEARCOAT_NORMAL_SCALE, MATERIAL_PARAM_CLEARCOAT_ROUGHNESS, MATERIAL_PARAM_COLOR, MATERIAL_PARAM_DECAL_EDGE_FADE, MATERIAL_PARAM_DECAL_FADE_END, MATERIAL_PARAM_DECAL_FADE_START, MATERIAL_PARAM_DIFFUSE_TRANSMISSION, MATERIAL_PARAM_DIFFUSE_TRANSMISSION_COLOR, MATERIAL_PARAM_DISPERSION, MATERIAL_PARAM_EMISSIVE, MATERIAL_PARAM_EMISSIVE_INTENSITY, MATERIAL_PARAM_ENV_INTENSITY, MATERIAL_PARAM_IOR, MATERIAL_PARAM_IRIDESCENCE, MATERIAL_PARAM_IRIDESCENCE_IOR, MATERIAL_PARAM_IRIDESCENCE_THICKNESS_MAX, MATERIAL_PARAM_IRIDESCENCE_THICKNESS_MIN, MATERIAL_PARAM_LIGHT_MAP_INTENSITY, MATERIAL_PARAM_LIGHT_MAP_OFFSET, MATERIAL_PARAM_LIGHT_MAP_SCALE, MATERIAL_PARAM_MAP_UV, MATERIAL_PARAM_MAP_UV_STRIDE, MATERIAL_PARAM_METALNESS, MATERIAL_PARAM_NORMAL_SCALE, MATERIAL_PARAM_OCCLUSION_STRENGTH, MATERIAL_PARAM_OPACITY, MATERIAL_PARAM_REFLECTANCE, MATERIAL_PARAM_ROUGHNESS, MATERIAL_PARAM_SHEEN_COLOR, MATERIAL_PARAM_SHEEN_ROUGHNESS, MATERIAL_PARAM_SPECULAR_COLOR, MATERIAL_PARAM_SPECULAR_INTENSITY, MATERIAL_PARAM_SUBSURFACE_COLOR, MATERIAL_PARAM_SUBSURFACE_RADIUS, MATERIAL_PARAM_THICKNESS, MATERIAL_PARAM_TRANSMISSION, MATERIAL_PARAM_UV_U, MATERIAL_PARAM_UV_V, SHADING_CUSTOM_ATTRIBUTE_SHIFT, SHADING_CUSTOM_BASE_COLOR, SHADING_CUSTOM_CASTER, SHADING_CUSTOM_OBJECT_IDS, SHADING_CUSTOM_ROW_VALUES, SHADING_CUSTOM_TEXTURE_SHIFT, SHADING_CUSTOM_TRANSMISSION, SHADING_LIT, SHADING_TEXCOORDS, SHADING_UNLIT, SHADING_UNLIT_MAP, SHAPE_BOX, SHAPE_CAPSULE, SHAPE_CIRCLE, SHAPE_CYLINDER, SHAPE_PLANE, SHAPE_RING, SHAPE_SPHERE, SHAPE_TORUS, } from '../generated/core.js';
6
+ import { PERMUTATION_CASTER, PERMUTATION_COAT_SHEEN, PERMUTATION_MOTION, PERMUTATION_ROW_VALUES, PERMUTATION_TRANSLUCENCY, PERMUTATION_TRANSMISSION, SIZE_MAP_ROWS, } from '../generated/gpu.js';
7
+ import { linearToSrgb } from '../math/color.js';
8
+ import { planEnded, planStarted, planTurn } from '../shared/task-pending.js';
9
+ import { linearColor, writeLinearColor } from './color.js';
10
+ import { arraysProblem, floatPositions, MOVING_VERTEX_BITS, meshFromArrays, meshFromLevel, meshFromLevelCopy, meshFromSplitLevel, morphTargetCount, readPlanningPart, replaceMeshIndices, setMeshPieceList, setMeshPieces, updateVertices, valuesOf, } from './mesh-arrays.js';
11
+ import { ShaderPreloads } from './shader-preloads.js';
12
+ import { ShaderTemplates } from './shader-templates.js';
13
+ import { Texture } from './textures.js';
14
+ /**
15
+ * How long a mesh waits for the next frame before it hands over its next planned level anyway, in
16
+ * ms: a page whose frames stop, as a hidden tab's do, still gets its levels.
17
+ */
18
+ const LEVEL_FRAME_WAIT_MS = 250;
19
+ /** How often a mesh looks for the next frame while it hands over its planned levels, in ms. */
20
+ const LEVEL_FRAME_POLL_MS = 2;
21
+ /** The screen height in pixels at which the engine orders a mesh's levels when it takes them. */
22
+ const LEVEL_REFERENCE_HEIGHT = 1080;
23
+ /** The field of view in degrees at which the engine orders a mesh's levels when it takes them. */
24
+ const LEVEL_REFERENCE_FOV = 50;
25
+ /** The most lower levels a mesh takes: the core's levels, less the base mesh. */
26
+ const MAX_LOWER_LEVELS = LEVELS_MAX - 1;
27
+ /**
28
+ * A mesh made in code with at least this many triangles plans its levels the first time the scene
29
+ * draws it, unless its options say `levels: false`. A smaller mesh drawn a few times costs little
30
+ * at any distance, and each level adds draw buckets to every pipeline that draws the mesh.
31
+ */
32
+ export const AUTOMATIC_LEVEL_TRIANGLES = 4096;
33
+ /**
34
+ * A smaller mesh of at least `AUTOMATIC_COPY_TRIANGLES` triangles plans its levels once the copies
35
+ * that the scene draws of it hold this many triangles together, as a batch of pebbles does.
36
+ */
37
+ export const AUTOMATIC_DRAWN_TRIANGLES = 65_536;
38
+ /** The fewest triangles of a mesh that plans its levels because of its copies. */
39
+ export const AUTOMATIC_COPY_TRIANGLES = 256;
40
+ /**
41
+ * The least error of a planned level, as a share of the mesh's longest side. A level that the
42
+ * simplifier finds exact, as on a flat surface, still gives the switch a distance above 0.
43
+ */
44
+ const LEAST_LEVEL_ERROR = 1e-6;
45
+ /** Each planned level's error is at least this many times the error of the level before it. */
46
+ const LEVEL_ERROR_GROWTH = 1.5;
47
+ /**
48
+ * @internal The fewest triangles of a list that gets pieces: the pieces planner's own
49
+ * `PIECE_LIST_MIN_TRIANGLES`, which a test keeps equal, here so the sketch's thread reads it
50
+ * without the planner's code.
51
+ */
52
+ export const PIECES_MIN_TRIANGLES = 32_768;
53
+ /**
54
+ * @internal The fewest triangles of a smaller mesh that plans facing pieces, and the fewest that
55
+ * its copies hold together: the pieces planner's own `FACING_LIST_MIN_TRIANGLES` and
56
+ * `FACING_DRAWN_MIN_TRIANGLES`, which a test keeps equal, here so the sketch's thread reads them
57
+ * without the planner's code.
58
+ */
59
+ export const FACING_PIECES_MIN_TRIANGLES = 1024;
60
+ export const FACING_PIECES_DRAWN_TRIANGLES = 65_536;
61
+ /**
62
+ * @internal True when `copies` copies of a list of `triangles` triangles pay for its facing pieces:
63
+ * the pieces planner's own `facingPiecesPay`, which a test keeps equal, here so the sketch's thread
64
+ * reads it without the planner's code.
65
+ */
66
+ export const facingCopiesPay = (triangles, copies) => triangles >= FACING_PIECES_MIN_TRIANGLES &&
67
+ triangles < PIECES_MIN_TRIANGLES &&
68
+ triangles * copies >= FACING_PIECES_DRAWN_TRIANGLES;
69
+ /** The triangles that pieces hold together. */
70
+ const piecesTriangles = (pieces) => pieces.triangles.reduce((sum, count) => sum + count, 0);
71
+ /** The level planner's start, which loads with the first mesh that plans its levels. */
72
+ let plannerModule;
73
+ /** The level planner's start, imported once. Throws E1406 when it does not download. */
74
+ function levelPlanner(call) {
75
+ plannerModule ??= import('./mesh-levels.js').catch((error) => {
76
+ plannerModule = undefined;
77
+ throw new EngineError('E1406', `the level planner did not download for ${call}(): ${error instanceof Error ? error.message : String(error)}.`);
78
+ });
79
+ return plannerModule;
80
+ }
81
+ /** The engine's coded error, which the level planner's start makes its failures with. */
82
+ const levelsError = (code, message) => new EngineError(code, message);
83
+ /**
84
+ * A mesh the engine can draw: its id in the engine core, its bounding radius, and its morph
85
+ * targets.
86
+ *
87
+ * @category api/geometry
88
+ */
89
+ export class MeshGeometry {
90
+ radius;
91
+ core;
92
+ morphTargets;
93
+ morphTargetNames;
94
+ maker;
95
+ /** The engine core's id, or 0 once the mesh is destroyed. */
96
+ liveId;
97
+ /** The mesh's lower levels of detail, as `setLevels` gave them. */
98
+ lowerLevels = [];
99
+ /** The vertex count and format, read from the engine core at the first update. */
100
+ layout;
101
+ /** The level meshes that the planner made, which the mesh owns and frees with its levels. */
102
+ built = [];
103
+ /** True when the planned levels came from the automatic default. */
104
+ builtAutomatically = false;
105
+ /** The plan that runs, if any. */
106
+ planning;
107
+ /** Counts the plans and the changes that end one, so a plan that a later call ended changes nothing. */
108
+ plans = 0;
109
+ /**
110
+ * True once the mesh takes no automatic levels: its options said `levels: false`, its vertices
111
+ * changed, or a material that moves its vertices draws it.
112
+ */
113
+ automaticOff = false;
114
+ /** The most triangles that the mesh holds, as it was made, for the automatic default. */
115
+ automaticTriangles = 0;
116
+ /** The copies that the scene has drawn of the mesh, for the automatic default. */
117
+ copies = 0;
118
+ /** True while the mesh waits for its first draw to sort its pieces alone (`levels: 'pieces'`). */
119
+ piecesOnly = false;
120
+ /**
121
+ * True once the mesh plans its own facing pieces with no levels: a mesh whose levels come from
122
+ * a file or were set by hand.
123
+ */
124
+ handPieces = false;
125
+ /** True for a mesh that a file made, whose levels and pieces come from the file. */
126
+ fromFile = false;
127
+ /** True when the file holds pieces of the mesh's list. */
128
+ filePieces = false;
129
+ /**
130
+ * The pieces that a file holds of the mesh's smaller list, which wait until the scene's copies
131
+ * of the mesh, or of the base whose level it is, hold enough triangles to pay for them.
132
+ */
133
+ heldPieces;
134
+ /** @internal */
135
+ constructor(id,
136
+ /** The distance from the mesh's bounding center (`center`) to its farthest vertex, at rest. */
137
+ radius,
138
+ /** @internal */ core,
139
+ /** How many morph targets the mesh has. 0 for a mesh without any. */
140
+ morphTargets = 0,
141
+ /**
142
+ * The morph targets' names, in target order, or none when the mesh's arrays named none.
143
+ * `mesh.setMorphWeight` takes a name too.
144
+ */
145
+ morphTargetNames = [],
146
+ /** The geometry that made the mesh, whose scene says which objects use it. */
147
+ maker) {
148
+ this.radius = radius;
149
+ this.core = core;
150
+ this.morphTargets = morphTargets;
151
+ this.morphTargetNames = morphTargetNames;
152
+ this.maker = maker;
153
+ this.liveId = id;
154
+ }
155
+ /**
156
+ * The center of the box around the mesh's vertices at rest, in the mesh's own space. The mesh's
157
+ * bounding sphere lies around it with `radius`, and culling tests that sphere. A mesh whose
158
+ * positions start at a corner, as quantized glTF files store them, has its center away from the
159
+ * origin.
160
+ */
161
+ get center() {
162
+ if (this.boundsCenter === undefined) {
163
+ const { glue } = this.core;
164
+ const id = this.id;
165
+ this.boundsCenter = [glue.meshCenter(id, 0), glue.meshCenter(id, 1), glue.meshCenter(id, 2)];
166
+ }
167
+ return this.boundsCenter;
168
+ }
169
+ boundsCenter;
170
+ /** @internal The engine core's id. Throws E1101 once the mesh is destroyed. */
171
+ get id() {
172
+ if (this.liveId === 0)
173
+ throw new EngineError('E1101', 'a call used a mesh after its destroy().');
174
+ return this.liveId;
175
+ }
176
+ /** @internal True until `destroy` runs. */
177
+ get live() {
178
+ return this.liveId !== 0;
179
+ }
180
+ /**
181
+ * Destroys the mesh. The engine frees its GPU memory and its other data at once, and later
182
+ * meshes take its room. Destroy the objects and instance batches that use it first, in the same
183
+ * frame or before. Its lower levels go with it, since a level draws its base's vertices. Throws
184
+ * E1111 while one still uses it, and E1101 for a mesh that is destroyed already. Later calls
185
+ * that pass the mesh throw E1101.
186
+ */
187
+ destroy() {
188
+ const call = 'mesh.destroy';
189
+ // A level draws its base mesh's vertices, so the base takes it along. A level that the
190
+ // sketch destroyed itself is gone already.
191
+ const meshes = [
192
+ this,
193
+ ...this.lowerLevels.filter((level) => level.mesh.live).map((level) => level.mesh),
194
+ ];
195
+ const user = this.maker?.users?.userOf(new Set(meshes));
196
+ if (user)
197
+ throw new EngineError('E1111', `${call}() was called on a mesh that ${user} still uses. Destroy the objects and instance batches that use it first.`);
198
+ this.plans++;
199
+ destroyMeshes(this.core, meshes, call);
200
+ }
201
+ /**
202
+ * Writes new values into one attribute of the mesh's vertices. `values` holds the attribute's
203
+ * values of every vertex, in the array type the mesh was made with, as `geometry.fromArrays`
204
+ * takes them. Only vertices `start` to `start + count - 1` change, which the next frame uploads.
205
+ * The defaults update every vertex. Colors take three or four values per vertex: three keep each
206
+ * vertex's alpha. The mesh keeps the bounding sphere it was made with, so give objects that draw
207
+ * vertices outside it bounds with `setBounds`. The four-number vertex record takes updates as
208
+ * `targets`. Joints, weights, and a mesh with joints or morph targets take no updates. A level
209
+ * that draws its base mesh's vertices writes them, so the base and every level of it draw the new
210
+ * values. The levels that `buildLevels` or the automatic default planned measured the old shape,
211
+ * so the first update takes them away, and the mesh plans no automatic levels again;
212
+ * `buildLevels` plans them for the new shape. Throws E1206 for values that do not fit the mesh,
213
+ * and E1101 for a destroyed mesh. Allocates nothing, so a call in every frame makes no garbage.
214
+ */
215
+ updateVertices(name, values, start = 0, count) {
216
+ const call = 'mesh.updateVertices';
217
+ const id = this.id;
218
+ if (!this.automaticOff || this.built.length > 0 || this.planning) {
219
+ this.automaticOff = true;
220
+ this.dropBuilt(call);
221
+ }
222
+ let layout = this.layout;
223
+ if (layout === undefined) {
224
+ const { glue } = this.core;
225
+ layout = {
226
+ count: glue.meshVertexCount(id),
227
+ format: glue.meshFormat(id),
228
+ posed: this.morphTargets > 0,
229
+ };
230
+ this.layout = layout;
231
+ }
232
+ const vertices = count ?? layout.count - start;
233
+ updateVertices(this.core, id, layout, name, values, start, vertices, call);
234
+ }
235
+ /** @internal Marks the mesh destroyed, once the engine core freed it. */
236
+ ended() {
237
+ this.liveId = 0;
238
+ this.lowerLevels = [];
239
+ this.built = [];
240
+ this.planning = undefined;
241
+ }
242
+ /**
243
+ * The mesh's lower levels of detail, from the most detailed down, as `setLevels` gave them. A
244
+ * destroyed level takes every level away, as the engine does.
245
+ */
246
+ get levels() {
247
+ if (!this.lowerLevels.every((level) => level.mesh.live))
248
+ this.lowerLevels = [];
249
+ return this.lowerLevels;
250
+ }
251
+ /**
252
+ * Gives the mesh lower levels of detail, from the most detailed down. A mesh takes at most 15
253
+ * lower levels. Every object and instance batch that draws the mesh then picks one level per
254
+ * frame. It draws the coarsest level whose error covers fewer pixels on the screen than the
255
+ * `lodThreshold` quality setting. A level may name a material of its own, so a far level shades
256
+ * more cheaply; a level without one draws with the level before's material. A bound that covers
257
+ * fewer pixels than the threshold draws nothing, so the mesh's last level holds no geometry. The
258
+ * shadow maps pick their own levels, by each map's texel size, so a caster's shadow shows the
259
+ * detail that the map can hold. An empty list takes the levels away. Morphed objects, and
260
+ * materials that blend or let light through, draw the base mesh. A skinned object draws a level
261
+ * while the level names the base mesh's own vertices. Destroying a level's mesh takes every level
262
+ * away. Levels set here win over the ones that `buildLevels` or the automatic default plans: a
263
+ * plan that runs ends, and the planned levels go. Throws E1221 for levels the mesh cannot take,
264
+ * and E1101 for a destroyed mesh.
265
+ */
266
+ setLevels(levels, options = {}) {
267
+ const call = 'mesh.setLevels';
268
+ this.applyLevels(levels, options, call);
269
+ // Levels set by hand win over planned ones: a plan that runs ends, and the planned meshes
270
+ // that the new levels leave out go.
271
+ this.plans++;
272
+ this.planning = undefined;
273
+ this.freeBuilt(call);
274
+ }
275
+ /**
276
+ * Plans the mesh's levels of detail on the job workers, as the asset tool's `--lod` plans a
277
+ * file's, and gives them to the mesh when they arrive, between two frames. Each level about
278
+ * halves the triangles of the level above, down to a few dozen, and stores the largest distance
279
+ * between its surface and the mesh's as its error, so it switches in at once where that
280
+ * distance covers less than the `lodThreshold` setting's pixels. The levels name the mesh's own
281
+ * vertices, in their own order, so they cost indices alone: the mesh keeps its vertices and
282
+ * triangles as they are. A mesh that the engine split into parts, past 65,535 vertices, shares
283
+ * them part by part, and copies only the vertices of the triangles that cross from one part to
284
+ * another. A large mesh spreads the work over frames. The engine reads one part of it in each
285
+ * frame for the plan. It makes one level in each frame when the plan is done, and gives the
286
+ * scene the whole set once, so the scene's draw tables rebuild once. The mesh draws its full
287
+ * shape until the levels arrive, and every object and instance batch that draws it then picks
288
+ * its level. The mesh and each level of 32,768 triangles or more
289
+ * also get 8 to 16 pieces, which each copy skips where they lie outside the view or face away.
290
+ * A smaller list that many copies draw gets a piece for each way it faces where its triangles
291
+ * face a few ways, as a building's walls do. A mesh that one object draws, or a smaller mesh,
292
+ * gets its own pieces over a sorted copy of its indices, in the frame after the last level;
293
+ * copies of a large mesh keep their levels' pieces alone.
294
+ *
295
+ * A mesh made in code plans its levels on its own the first time the scene draws it, when it
296
+ * holds `geometry.automaticLevelTriangles` triangles or more, or when it holds at least
297
+ * `geometry.automaticCopyTriangles` triangles and its copies hold
298
+ * `geometry.automaticDrawnTriangles` together. Call this to plan another mesh's, to plan again
299
+ * after `updateVertices`, or to await the levels of a plan that runs: a call while a plan with
300
+ * the same options runs returns that plan's promise. `setLevels` wins over a plan, and
301
+ * `updateVertices` takes the planned levels away. The promise resolves with the mesh's levels, which stay as they were when the
302
+ * planner finds no level worth making, and when `setLevels`, `updateVertices` or `destroy` ends
303
+ * the plan first. It rejects with E1221 for a mesh with joints, morph targets or a vertex
304
+ * record, whose shape poses or moves, and with E1406 when the planner does not download. The
305
+ * planner downloads with the first mesh that plans: meshoptimizer's simplifier, about 23 KB.
306
+ * Throws E1101 for a destroyed mesh.
307
+ */
308
+ buildLevels(options = {}) {
309
+ return this.plan(options.cards ?? false, false, 'mesh.buildLevels');
310
+ }
311
+ /**
312
+ * @internal Sets up the mesh's levels as its options ask when it is made: `false` plans none,
313
+ * `true` or options plan them now, and the default waits for the scene to draw the mesh.
314
+ * `triangles` is the most triangles that the mesh may hold, which spares a small mesh the read
315
+ * of its vertices. A failure keeps the full mesh, with a warning in development.
316
+ */
317
+ startLevels(option, triangles, call) {
318
+ this.automaticTriangles = triangles;
319
+ if (option === false || option === 'pieces')
320
+ this.automaticOff = true;
321
+ this.piecesOnly = option === 'pieces' && triangles >= PIECES_MIN_TRIANGLES;
322
+ if (option === undefined || option === false || option === 'pieces')
323
+ return;
324
+ this.planQuietly(typeof option === 'object' && option.cards === true, false, call);
325
+ }
326
+ /** Starts a plan whose failure keeps the full mesh, with a warning in development. */
327
+ planQuietly(cards, automatic, call) {
328
+ this.plan(cards, automatic, call).catch((error) => {
329
+ if (DEV)
330
+ console.warn(`${call}() left a mesh that draws its full shape at every distance: its levels of detail did not plan. ${error instanceof Error ? error.message : String(error)}`);
331
+ });
332
+ }
333
+ /**
334
+ * Starts a plan of the mesh's levels, or returns the one that runs with the same options. With
335
+ * `piecesOnly`, the plan makes no lower levels and sorts the mesh into pieces alone, by space
336
+ * alone with `spacePieces`.
337
+ */
338
+ plan(cards, automatic, call, piecesOnly = false, spacePieces = piecesOnly) {
339
+ const id = this.id;
340
+ const { core } = this;
341
+ const format = core.glue.meshFormat(id);
342
+ if (this.morphTargets > 0 || format & MOVING_VERTEX_BITS)
343
+ return Promise.reject(new EngineError('E1221', `${call}() got a mesh with joints, morph targets or a vertex record, whose shape poses or moves. Give such a mesh levels with setLevels.`));
344
+ const running = this.planning;
345
+ if (running && running.cards === cards)
346
+ return running.promise;
347
+ const plan = ++this.plans;
348
+ const entry = { promise: Promise.resolve(this.levels), cards, automatic };
349
+ // The mesh is read from the core one part a frame, between two frames, so no frame reads a
350
+ // large mesh whole, nor the frame that made it. The plan starts once the planner has loaded
351
+ // and the parts are in, unless a call such as setLevels has ended it by then, and its levels
352
+ // arrive with the task's answer, between two frames. The plan counts as a task from now
353
+ // until its levels are in, so a held frame draws them.
354
+ const counted = planStarted(`a mesh of ${this.automaticTriangles.toLocaleString('en-US')} triangles (${call})`);
355
+ entry.promise = (async () => {
356
+ try {
357
+ let read;
358
+ for (let part = 0; part < (read?.parts ?? 1); part++) {
359
+ await this.nextFrame();
360
+ if (plan !== this.plans || !this.live)
361
+ return this.levels;
362
+ read = readPlanningPart(core, this.id, part, call, read);
363
+ }
364
+ const { words, parts, masks } = read;
365
+ if (automatic) {
366
+ this.automaticTriangles = words[1] / 3;
367
+ if (!this.automaticWanted()) {
368
+ this.planning = undefined;
369
+ return this.levels;
370
+ }
371
+ }
372
+ const planner = await levelPlanner(call);
373
+ if (plan !== this.plans)
374
+ return this.levels;
375
+ const output = await planner.planLevels({
376
+ words: words.buffer,
377
+ cards: cards && floatPositions(format),
378
+ maxLevels: piecesOnly ? 0 : MAX_LOWER_LEVELS,
379
+ skipFlat: automatic,
380
+ spacePieces,
381
+ parts,
382
+ copies: this.copies,
383
+ // The mesh's own pieces draw a sorted copy of its indices. A mesh that one
384
+ // object draws, such as a ground around the camera, draws its base wherever
385
+ // the camera is near, so the copy pays; copies of a large mesh draw their base
386
+ // only when near, and their levels' pieces cost no copy. The task also plans
387
+ // the own pieces of a list under the pieces' floor, whose copy costs little.
388
+ basePieces: piecesOnly || this.copies <= 1,
389
+ ...(masks && { masks: masks.buffer }),
390
+ }, call, levelsError);
391
+ // Hold mode hands the plans' levels over in the order the plans started.
392
+ await planTurn(counted);
393
+ return await this.takePlan(output, plan, entry, call);
394
+ }
395
+ catch (error) {
396
+ if (plan === this.plans)
397
+ this.planning = undefined;
398
+ throw error;
399
+ }
400
+ finally {
401
+ planEnded(counted);
402
+ }
403
+ })();
404
+ this.planning = entry;
405
+ return entry.promise;
406
+ }
407
+ /**
408
+ * Gives the mesh the levels that a plan made, unless a later call ended the plan, or the plan
409
+ * was the automatic default's and the mesh has refused automatic levels or holds levels set by
410
+ * hand since. The plan makes one level a frame, so that no frame takes the work of every level
411
+ * of a large mesh. It gives the set to the scene once, when the plan ends. The scene's draw
412
+ * tables then rebuild once, however many levels the plan made. Hold mode takes them all at once.
413
+ */
414
+ async takePlan(output, plan, entry, call) {
415
+ const ended = () => plan !== this.plans || !this.live;
416
+ if (ended())
417
+ return this.levels;
418
+ const handSet = this.lowerLevels.length > 0 && this.built.length === 0;
419
+ if (entry.automatic && (this.automaticOff || handSet)) {
420
+ this.planning = undefined;
421
+ return this.levels;
422
+ }
423
+ const planned = output.levels;
424
+ const least = output.side * LEAST_LEVEL_ERROR;
425
+ let before = 0;
426
+ const errors = planned.map((level) => {
427
+ const error = Math.max(level.error, least, before * LEVEL_ERROR_GROWTH);
428
+ before = error;
429
+ return error;
430
+ });
431
+ const old = this.built;
432
+ const made = [];
433
+ try {
434
+ for (let k = planned.length - 1; k >= 0; k--) {
435
+ if (made.length > 0)
436
+ await this.nextFrame();
437
+ if (ended()) {
438
+ this.freeMeshes(made, call);
439
+ return this.levels;
440
+ }
441
+ made.unshift(this.levelMesh(planned[k], call));
442
+ }
443
+ // One hand-over for the whole set: the scene rebuilds its draw tables once, and each
444
+ // level's mesh still arrives in its own frame.
445
+ if (made.length > 0) {
446
+ this.applyLevels(made.map((mesh, j) => ({
447
+ mesh,
448
+ error: errors[j],
449
+ fade: false,
450
+ measured: true,
451
+ })), {}, call);
452
+ this.built = made.slice();
453
+ this.builtAutomatically = entry.automatic;
454
+ this.freeMeshes(old, call);
455
+ }
456
+ }
457
+ catch (error) {
458
+ // The plan's levels that the scene does not name yet go with it.
459
+ this.freeMeshes(made, call);
460
+ throw error;
461
+ }
462
+ // The mesh's own pieces come last, in a frame of their own, since the copy of a large list
463
+ // takes as long as a level's. They take the place of the pieces of an earlier plan.
464
+ const { pieces } = output;
465
+ if (pieces) {
466
+ if (made.length > 0)
467
+ await this.nextFrame();
468
+ if (ended())
469
+ return this.levels;
470
+ setMeshPieceList(this.core, this.id, pieces, call);
471
+ }
472
+ this.planning = undefined;
473
+ return this.levels;
474
+ }
475
+ /**
476
+ * Resolves once the sketch has run another frame, or after a short wait where frames stop.
477
+ * Hold mode resolves at once, since its held frame waits for the plan.
478
+ */
479
+ async nextFrame() {
480
+ const pace = this.maker?.users?.pace;
481
+ if (!pace || pace.held)
482
+ return;
483
+ const frame = pace.frame;
484
+ const until = performance.now() + LEVEL_FRAME_WAIT_MS;
485
+ while (pace.frame === frame && performance.now() < until)
486
+ await new Promise((resolve) => setTimeout(resolve, LEVEL_FRAME_POLL_MS));
487
+ }
488
+ /**
489
+ * A planned level's mesh: one that draws this mesh's vertices with the level's triangles, part
490
+ * by part where the mesh is split into parts, or a copy of the vertices that it draws where the
491
+ * level moved them, as a level of cards does.
492
+ */
493
+ levelMesh(level, call) {
494
+ const { core } = this;
495
+ const base = this.id;
496
+ const { indices, positions, pieces } = level;
497
+ // A level of cards moves its vertices, so it copies them. Another level shares the mesh's,
498
+ // part by part where the engine split the mesh, and a large one takes its pieces.
499
+ let id = positions ? meshFromLevelCopy(core, base, indices, call) : undefined;
500
+ id ??= meshFromLevel(core, base, indices, call);
501
+ if (id === undefined)
502
+ id = meshFromSplitLevel(core, base, indices, call, pieces);
503
+ else if (pieces)
504
+ setMeshPieces(core, id, pieces, call);
505
+ const mesh = new MeshGeometry(id, core.glue.meshRadius(id), core, 0, [], this.maker);
506
+ if (positions) {
507
+ // The copy holds each vertex once, in the order that the triangles first name it.
508
+ const placed = new Float32Array(core.glue.meshVertexCount(id) * 3);
509
+ const seen = new Set();
510
+ let at = 0;
511
+ for (const index of indices) {
512
+ if (seen.has(index))
513
+ continue;
514
+ seen.add(index);
515
+ placed.set(positions.subarray(index * 3, index * 3 + 3), at);
516
+ at += 3;
517
+ }
518
+ mesh.updateVertices('positions', placed);
519
+ }
520
+ return mesh;
521
+ }
522
+ /**
523
+ * @internal Notes that the scene draws `copies` more copies of the mesh with `material`, and
524
+ * plans the mesh's levels as the automatic default asks: once the mesh holds
525
+ * `AUTOMATIC_LEVEL_TRIANGLES` triangles, or it holds at least `AUTOMATIC_COPY_TRIANGLES` triangles and its copies hold
526
+ * `AUTOMATIC_DRAWN_TRIANGLES` together. A flat mesh, whose shape a shader may give it, plans none, and neither does a mesh
527
+ * that only materials that blend or let light through draw, which draw the base level alone.
528
+ * A material that moves the
529
+ * vertices in its shader draws another shape than the one that the levels simplify, so the mesh
530
+ * takes no automatic levels from then on, and drops the ones it has.
531
+ */
532
+ drawnWith(material, copies, call) {
533
+ // Copies count toward the levels and the pieces where their material draws the mesh's own
534
+ // shape in buckets: one that moves the vertices draws another shape, and one that blends or
535
+ // lets light through draws the base level whole and sorted.
536
+ const counted = !material.shapesVertices && !material.wholeOnly;
537
+ if (counted)
538
+ this.copies += copies;
539
+ // A mesh that asked for pieces alone sorts them at its first such draw.
540
+ if (this.piecesOnly && counted) {
541
+ this.piecesOnly = false;
542
+ this.planPiecesQuietly(true, call);
543
+ }
544
+ // A file's held pieces wait only for the copies: the view's frustum test culls them however
545
+ // the material draws. A material that draws both faces plans none of its own, since a cone
546
+ // would drop none of them.
547
+ if (counted)
548
+ this.facingPiecesFor(call, !material.facesBoth);
549
+ if (this.automaticOff)
550
+ return;
551
+ if (material.shapesVertices) {
552
+ this.automaticOff = true;
553
+ if (this.builtAutomatically || this.planning?.automatic)
554
+ this.dropBuilt(call);
555
+ return;
556
+ }
557
+ // A material that draws the base level alone leaves the copies' detail as it is; a draw with
558
+ // another material later plans the levels.
559
+ if (material.wholeOnly)
560
+ return;
561
+ const handSet = this.lowerLevels.length > 0 && this.built.length === 0;
562
+ if (handSet || this.planning || this.built.length > 0 || !this.automaticWanted())
563
+ return;
564
+ if (this.morphTargets > 0 || this.core.glue.meshFormat(this.id) & MOVING_VERTEX_BITS) {
565
+ this.automaticOff = true;
566
+ return;
567
+ }
568
+ this.planQuietly(false, true, call);
569
+ }
570
+ /**
571
+ * Gives the mesh and its levels the pieces that pay once its copies hold enough triangles
572
+ * together: those that a file holds of a smaller list, and the facing pieces that a mesh sorts
573
+ * for itself, as a town's copies of a house's walls have. The pieces that a file holds of a
574
+ * smaller list wait for that, so few copies draw the list whole with no draw more. A mesh whose
575
+ * levels come from a file, or were set by hand, plans no levels, and its copies draw its base
576
+ * list out to where its lower levels switch in: where the file holds no pieces of that list, it
577
+ * plans them on the job workers, over a sorted copy of its indices. A mesh with joints, morph
578
+ * targets or a vertex record plans none, and neither does one with `levels: false`. A material
579
+ * that draws both faces takes the pieces that a file holds, which the view's frustum test culls;
580
+ * it plans none of its own, which a cone would not drop.
581
+ */
582
+ facingPiecesFor(call, planFacing) {
583
+ for (const mesh of [this, ...this.lowerLevels.map((level) => level.mesh)]) {
584
+ const held = mesh.heldPieces;
585
+ if (!held || !mesh.live || !facingCopiesPay(piecesTriangles(held), this.copies))
586
+ continue;
587
+ mesh.heldPieces = undefined;
588
+ setMeshPieces(this.core, mesh.id, held, call);
589
+ }
590
+ if (!planFacing)
591
+ return;
592
+ const handSet = this.lowerLevels.length > 0 && this.built.length === 0;
593
+ const own = this.fromFile ? !this.filePieces : handSet && !this.automaticOff;
594
+ if (!own ||
595
+ this.planning ||
596
+ this.handPieces ||
597
+ !facingCopiesPay(this.automaticTriangles, this.copies) ||
598
+ this.morphTargets > 0 ||
599
+ this.core.glue.meshFormat(this.id) & MOVING_VERTEX_BITS)
600
+ return;
601
+ this.handPieces = true;
602
+ this.planPiecesQuietly(false, call);
603
+ }
604
+ /**
605
+ * @internal Marks a mesh that a file made, and takes the pieces that the file holds of its
606
+ * list, if any: a large list's at once, and a smaller list's once the scene's copies pay for
607
+ * them. A list that the pieces do not fit draws whole.
608
+ */
609
+ fromFileWith(pieces, call) {
610
+ this.fromFile = true;
611
+ if (!pieces)
612
+ return;
613
+ this.filePieces = true;
614
+ if (piecesTriangles(pieces) >= PIECES_MIN_TRIANGLES)
615
+ setMeshPieces(this.core, this.id, pieces, call);
616
+ else
617
+ this.heldPieces = pieces;
618
+ }
619
+ /**
620
+ * Starts a plan of the mesh's pieces alone, by space alone with `space`, whose failure leaves
621
+ * the mesh without pieces, with a warning in development.
622
+ */
623
+ planPiecesQuietly(space, call) {
624
+ this.plan(false, false, call, true, space).catch((error) => {
625
+ if (DEV)
626
+ console.warn(`${call}() left a mesh without pieces: they did not plan. ${error instanceof Error ? error.message : String(error)}`);
627
+ });
628
+ }
629
+ /** True when the mesh's triangles, or those of its copies, ask for automatic levels. */
630
+ automaticWanted() {
631
+ const triangles = this.automaticTriangles;
632
+ return (triangles >= AUTOMATIC_LEVEL_TRIANGLES ||
633
+ (triangles >= AUTOMATIC_COPY_TRIANGLES &&
634
+ triangles * this.copies >= AUTOMATIC_DRAWN_TRIANGLES));
635
+ }
636
+ /** Takes the planned levels away and ends a plan that runs. Levels set by hand stay. */
637
+ dropBuilt(call) {
638
+ this.plans++;
639
+ this.planning = undefined;
640
+ const built = this.built;
641
+ if (built.length === 0)
642
+ return;
643
+ this.applyLevels(this.lowerLevels.filter((level) => !built.includes(level.mesh)), {}, call);
644
+ this.freeBuilt(call);
645
+ }
646
+ /** Frees the planned level meshes that the mesh's levels no longer name. */
647
+ freeBuilt(call) {
648
+ const old = this.built;
649
+ if (old.length === 0)
650
+ return;
651
+ this.built = old.filter((mesh) => this.lowerLevels.some((level) => level.mesh === mesh));
652
+ this.freeMeshes(old, call);
653
+ }
654
+ /**
655
+ * Frees those of `meshes` that are live and that the mesh's levels do not name, unless an
656
+ * object or a batch draws one.
657
+ */
658
+ freeMeshes(meshes, call) {
659
+ const gone = meshes.filter((mesh) => mesh.live && !this.lowerLevels.some((level) => level.mesh === mesh));
660
+ if (gone.length === 0 || this.maker?.users?.userOf(new Set(gone)))
661
+ return;
662
+ destroyMeshes(this.core, gone, call);
663
+ }
664
+ /** Checks levels and gives them to the core, as `setLevels` takes them. */
665
+ applyLevels(levels, options, call) {
666
+ const id = this.id;
667
+ const fov = options.fov ?? LEVEL_REFERENCE_FOV;
668
+ if (levels.length > MAX_LOWER_LEVELS)
669
+ throw new EngineError('E1221', `${call}() got ${levels.length} levels. A mesh takes at most ${MAX_LOWER_LEVELS}.`);
670
+ if (!(fov > 0 && fov < 180))
671
+ throw new EngineError('E1221', `${call}() got a fov of ${fov}, not between 0 and 180.`);
672
+ // The reference view turns every measure into the distance at which its level switches, so
673
+ // that the levels of one set compare with each other.
674
+ const p11 = 1 / Math.tan((fov * Math.PI) / 360);
675
+ const radius = this.radius;
676
+ const defaultFade = options.fade ?? true;
677
+ let fades = 0;
678
+ let measured = 0;
679
+ let before = 0;
680
+ const values = [];
681
+ const switches = [];
682
+ for (const [k, level] of levels.entries()) {
683
+ const { error, distance, coverage } = level;
684
+ const given = [error, distance, coverage].filter((value) => value !== undefined);
685
+ if (given.length !== 1)
686
+ throw new EngineError('E1221', `${call}() got level ${k + 1} with ${given.length === 0 ? 'none of an error, a distance and a coverage' : 'more than one of an error, a distance and a coverage'}. Give one of them.`);
687
+ if (level.mesh.core !== this.core || level.mesh === this)
688
+ throw new EngineError('E1221', `${call}() got level ${k + 1} with ${level.mesh === this ? 'the base mesh itself' : 'a mesh from another engine'}.`);
689
+ const value = given[0];
690
+ if (!(Number.isFinite(value) && value > 0))
691
+ throw new EngineError('E1221', `${call}() got ${error !== undefined ? `an error of ${error}` : distance !== undefined ? `a distance of ${distance}` : `a coverage of ${coverage}`} for level ${k + 1}, not a number above 0.`);
692
+ const switchValue = error !== undefined
693
+ ? LEVEL_SWITCH_ERROR
694
+ : distance !== undefined
695
+ ? LEVEL_SWITCH_DISTANCE
696
+ : LEVEL_SWITCH_COVERAGE;
697
+ // The distance at which the level switches on the reference view, which grows from
698
+ // level to level.
699
+ const at = switchValue === LEVEL_SWITCH_ERROR
700
+ ? (value * LEVEL_REFERENCE_HEIGHT * p11) / 2
701
+ : switchValue === LEVEL_SWITCH_DISTANCE
702
+ ? value
703
+ : (radius * p11) / value;
704
+ if (k > 0 && at <= before)
705
+ throw new EngineError('E1221', `${call}() got level ${k + 1} with a switch at ${at.toFixed(3)} m, not past the ${before.toFixed(3)} m of level ${k}. The switch distances grow from level to level.`);
706
+ before = at;
707
+ values.push(value);
708
+ switches.push(switchValue);
709
+ if (level.fade ?? defaultFade)
710
+ fades |= 1 << (k + 1);
711
+ if (level.measured)
712
+ measured |= 1 << (k + 1);
713
+ }
714
+ const count = levels.length;
715
+ const ids = levels.map((level) => level.mesh.id);
716
+ const materials = levels.map((level, k) => {
717
+ const { material } = level;
718
+ if (!material)
719
+ return 0;
720
+ if (!material.live)
721
+ throw new EngineError('E1221', `${call}() got level ${k + 1} with a material that is destroyed.`);
722
+ if (material.core !== this.core)
723
+ throw new EngineError('E1221', `${call}() got level ${k + 1} with a material from another engine.`);
724
+ return material.id;
725
+ });
726
+ const at = this.core.checkGrowth(this.core.glue.meshArrays(4 * count), call);
727
+ this.core.u32(at, count).set(ids);
728
+ this.core.f32(at + 4 * count, count).set(values);
729
+ this.core.u32(at + 8 * count, count).set(switches);
730
+ this.core.u32(at + 12 * count, count).set(materials);
731
+ // The low half of the word names the fading levels and the high half the measured ones.
732
+ this.core.check(this.core.glue.setMeshLevels(id, count, (fades | (measured << 16)) >>> 0), call, 'a mesh', true);
733
+ this.lowerLevels = levels.map((level) => ({ ...level }));
734
+ }
735
+ /**
736
+ * @internal Gives the mesh the triangles `indices` in place of the ones it draws, which name its
737
+ * own vertices. A staged level uses it to make its base the finer level as it arrives, so the
738
+ * objects that draw the base draw the new geometry at once. Returns false when the mesh cannot
739
+ * take another triangle list. It changes nothing else about the mesh: its vertices, bounds and
740
+ * levels stay.
741
+ */
742
+ replaceTriangles(indices) {
743
+ return replaceMeshIndices(this.core, this.id, indices, 'mesh.replaceTriangles');
744
+ }
745
+ }
746
+ /**
747
+ * @internal Frees live meshes in the engine core in one pass, which no object or batch uses any
748
+ * more, and marks them destroyed. The meshes that stay move once for all of them.
749
+ */
750
+ export function destroyMeshes(core, meshes, call) {
751
+ if (meshes.length === 0)
752
+ return;
753
+ const ids = meshes.map((mesh) => mesh.id);
754
+ const at = core.checkGrowth(core.glue.meshArrays(ids.length), call);
755
+ core.u32(at, ids.length).set(ids);
756
+ core.check(core.glue.destroyMeshes(meshes.length), call, 'a mesh', true);
757
+ for (const mesh of meshes)
758
+ mesh.ended();
759
+ }
760
+ const TAU = Math.PI * 2;
761
+ // Each generator's options with their defaults, in the order of the arguments of the three.js
762
+ // class's constructor, which is the order the engine core reads them in.
763
+ const BOX = {
764
+ width: 1,
765
+ height: 1,
766
+ depth: 1,
767
+ widthSegments: 1,
768
+ heightSegments: 1,
769
+ depthSegments: 1,
770
+ };
771
+ const SPHERE = {
772
+ radius: 1,
773
+ widthSegments: 32,
774
+ heightSegments: 16,
775
+ phiStart: 0,
776
+ phiLength: TAU,
777
+ thetaStart: 0,
778
+ thetaLength: Math.PI,
779
+ };
780
+ const PLANE = {
781
+ width: 1,
782
+ height: 1,
783
+ widthSegments: 1,
784
+ heightSegments: 1,
785
+ };
786
+ const CYLINDER = {
787
+ radiusTop: 1,
788
+ radiusBottom: 1,
789
+ height: 1,
790
+ radialSegments: 32,
791
+ heightSegments: 1,
792
+ openEnded: false,
793
+ thetaStart: 0,
794
+ thetaLength: TAU,
795
+ };
796
+ const CONE = {
797
+ radius: 1,
798
+ height: 1,
799
+ radialSegments: 32,
800
+ heightSegments: 1,
801
+ openEnded: false,
802
+ thetaStart: 0,
803
+ thetaLength: TAU,
804
+ };
805
+ const TORUS = {
806
+ radius: 1,
807
+ tube: 0.4,
808
+ radialSegments: 12,
809
+ tubularSegments: 48,
810
+ arc: TAU,
811
+ thetaStart: 0,
812
+ thetaLength: TAU,
813
+ };
814
+ const CAPSULE = {
815
+ radius: 1,
816
+ height: 1,
817
+ capSegments: 4,
818
+ radialSegments: 8,
819
+ heightSegments: 1,
820
+ };
821
+ const CIRCLE = {
822
+ radius: 1,
823
+ segments: 32,
824
+ thetaStart: 0,
825
+ thetaLength: TAU,
826
+ };
827
+ const RING = {
828
+ innerRadius: 0.5,
829
+ outerRadius: 1,
830
+ thetaSegments: 32,
831
+ phiSegments: 1,
832
+ thetaStart: 0,
833
+ thetaLength: TAU,
834
+ };
835
+ /**
836
+ * Mesh generators for common shapes, and meshes from arrays.
837
+ *
838
+ * @category api/geometry
839
+ */
840
+ export class Geometry {
841
+ core;
842
+ /** @internal The scene, which says which objects use a mesh that a destroy names. */
843
+ users;
844
+ constructor(core) {
845
+ this.core = core;
846
+ }
847
+ /**
848
+ * The GPU bytes that every mesh holds: the shared vertex and index buffers, which keep room to
849
+ * grow, and the texture of morph target deltas. It counts what the frames made so far, so it
850
+ * grows once a frame draws a new mesh. Destroyed meshes give their room to later ones, so a
851
+ * scene that loads and destroys the same models keeps the same figure.
852
+ */
853
+ get memoryBytes() {
854
+ return this.core.glue.meshMemoryBytes();
855
+ }
856
+ /**
857
+ * The triangles from which a mesh made in code plans its levels of detail, the first time the
858
+ * scene draws it, unless its options say `levels: false`. A smaller mesh drawn a few times
859
+ * costs little at any distance, and each level adds draw work to every pipeline that draws it.
860
+ */
861
+ get automaticLevelTriangles() {
862
+ return AUTOMATIC_LEVEL_TRIANGLES;
863
+ }
864
+ /**
865
+ * The triangles of the copies that the scene draws, together, from which a smaller mesh of at
866
+ * least `automaticCopyTriangles` triangles plans its levels too, as a batch of pebbles does.
867
+ */
868
+ get automaticDrawnTriangles() {
869
+ return AUTOMATIC_DRAWN_TRIANGLES;
870
+ }
871
+ /** The fewest triangles of a mesh that plans its levels because of its copies. */
872
+ get automaticCopyTriangles() {
873
+ return AUTOMATIC_COPY_TRIANGLES;
874
+ }
875
+ /**
876
+ * @internal Frees live meshes that no object or batch uses any more, in one pass, as a model's
877
+ * destroy does.
878
+ */
879
+ destroyMeshes(meshes, call) {
880
+ destroyMeshes(this.core, meshes, call);
881
+ }
882
+ mesh(id, call, levels) {
883
+ this.core.checkGrowth(id, call);
884
+ const mesh = new MeshGeometry(id, this.core.glue.meshRadius(id), this.core, 0, [], this);
885
+ // A generator's grid makes at most about two triangles a vertex; the plan reads the count.
886
+ mesh.startLevels(levels, 2 * this.core.glue.meshVertexCount(id), call);
887
+ return mesh;
888
+ }
889
+ /**
890
+ * A generator's mesh: each option, or its default, in the order of the three.js class's
891
+ * arguments, after the numbers in `first`. Throws E1203 for an option that is not a finite
892
+ * number.
893
+ */
894
+ shape(shape, call, options, defaults, ...first) {
895
+ for (const name in defaults) {
896
+ const key = name;
897
+ const given = options[name];
898
+ const value = Number(given ?? defaults[key]);
899
+ if (DEV && !Number.isFinite(value))
900
+ throw new EngineError('E1203', `${call}() got ${given} for ${name}.`);
901
+ first.push(value);
902
+ }
903
+ const [a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0] = first;
904
+ return this.mesh(this.core.glue.createShapeMesh(shape, a, b, c, d, e, f, g, h), call, options.levels);
905
+ }
906
+ /** A box, centered on its origin. */
907
+ box(options = {}) {
908
+ return this.shape(SHAPE_BOX, 'geometry.box', options, BOX);
909
+ }
910
+ /** A sphere with its poles on the Y axis, or a part of one. */
911
+ sphere(options = {}) {
912
+ return this.shape(SHAPE_SPHERE, 'geometry.sphere', options, SPHERE);
913
+ }
914
+ /** A flat rectangle in the XY plane that faces +Z. */
915
+ plane(options = {}) {
916
+ return this.shape(SHAPE_PLANE, 'geometry.plane', options, PLANE);
917
+ }
918
+ /** A cylinder on the Y axis, closed at each end unless `openEnded` is true. */
919
+ cylinder(options = {}) {
920
+ return this.shape(SHAPE_CYLINDER, 'geometry.cylinder', options, CYLINDER);
921
+ }
922
+ /** A cone on the Y axis: a cylinder whose top is a point. */
923
+ cone(options = {}) {
924
+ return this.shape(SHAPE_CYLINDER, 'geometry.cone', options, CONE, 0);
925
+ }
926
+ /** A torus: a tube bent into a ring around the Z axis. */
927
+ torus(options = {}) {
928
+ return this.shape(SHAPE_TORUS, 'geometry.torus', options, TORUS);
929
+ }
930
+ /** A capsule: a cylinder on the Y axis with a half sphere on each end. */
931
+ capsule(options = {}) {
932
+ return this.shape(SHAPE_CAPSULE, 'geometry.capsule', options, CAPSULE);
933
+ }
934
+ /** A flat circle in the XY plane that faces +Z, or a slice of one. */
935
+ circle(options = {}) {
936
+ return this.shape(SHAPE_CIRCLE, 'geometry.circle', options, CIRCLE);
937
+ }
938
+ /** A flat ring: a disc with a hole, in the XY plane, that faces +Z. */
939
+ ring(options = {}) {
940
+ return this.shape(SHAPE_RING, 'geometry.ring', options, RING);
941
+ }
942
+ /**
943
+ * A mesh from arrays of vertex attributes and triangle indices. The mesh keeps the attributes it
944
+ * gets, each in the type of number it came in, and meshes whose attributes have the same types
945
+ * share GPU buffers. A mesh can have any number of vertices. Throws E1206 when an array's length
946
+ * does not fit the vertex count, when its attribute does not take its type of number, when an
947
+ * index names no vertex, for a value that is not a finite number, and for morph targets whose
948
+ * arrays do not fit the vertices or whose lists hold different numbers of targets.
949
+ */
950
+ fromArrays(arrays) {
951
+ const call = 'geometry.fromArrays';
952
+ const problem = arraysProblem(arrays);
953
+ if (problem)
954
+ throw new EngineError('E1206', `${call}() ${problem}`);
955
+ const id = meshFromArrays(this.core, arrays, call);
956
+ this.core.checkGrowth(id, call);
957
+ const { morphTargets } = arrays;
958
+ const mesh = new MeshGeometry(id, this.core.glue.meshRadius(id), this.core, morphTargetCount(morphTargets), morphTargets?.names?.slice() ?? [], this);
959
+ const corners = arrays.indices?.length ?? valuesOf(arrays.positions).array.length / 3;
960
+ mesh.startLevels(arrays.levels, corners / 3, call);
961
+ return mesh;
962
+ }
963
+ /**
964
+ * @internal A level that draws `base`'s vertices with the given triangles, or undefined when the
965
+ * engine cannot share them and the caller gives the level its own arrays. Files whose levels
966
+ * keep the base's vertex streams load every level this way, so a level costs indices alone.
967
+ */
968
+ fromLevel(base, indices) {
969
+ const call = 'geometry.fromLevel';
970
+ const id = meshFromLevel(this.core, base.id, indices, call);
971
+ if (id === undefined)
972
+ return undefined;
973
+ return new MeshGeometry(id, this.core.glue.meshRadius(id), this.core, 0, [], this);
974
+ }
975
+ }
976
+ /**
977
+ * What the thread that draws builds a custom material's pipelines from. Its builds come on first
978
+ * use, unless the compiled WGSL holds them, as a hot update's does.
979
+ */
980
+ function customShader(compiled) {
981
+ return {
982
+ variants: compiled.variants,
983
+ locations: compiled.locations,
984
+ textures: compiled.textures.length,
985
+ ...(compiled.meshless === true && { meshless: true }),
986
+ ...(compiled.sceneDepth === true && { sceneDepth: true }),
987
+ ...(compiled.functions.includes('coverage') && { coverage: true }),
988
+ ...(compiled.alpha === true && { alpha: true }),
989
+ ...(compiled.builds && { builds: true }),
990
+ };
991
+ }
992
+ /** True when one of a custom material's builds has any of the permutation bits of `bits`. */
993
+ function builds(compiled, bits) {
994
+ if (compiled.permutations !== undefined)
995
+ return (compiled.permutations & bits) !== 0;
996
+ return Object.values(compiled.variants).some((v) => v.permutation & bits);
997
+ }
998
+ /** True when a custom material's WGSL has the builds that let light through. */
999
+ function lets(compiled) {
1000
+ return builds(compiled, PERMUTATION_TRANSMISSION);
1001
+ }
1002
+ /** Each value that is a number, and the most it takes, or none above 0. */
1003
+ const RANGED = [
1004
+ ['opacity', 1],
1005
+ ['alphaCutoff', 1],
1006
+ ['metalness', 1],
1007
+ ['roughness', 1],
1008
+ ['emissiveIntensity', Number.POSITIVE_INFINITY],
1009
+ ['aoMapIntensity', 1],
1010
+ ['lightMapIntensity', Number.POSITIVE_INFINITY],
1011
+ ['specularIntensity', 1],
1012
+ ['envIntensity', Number.POSITIVE_INFINITY],
1013
+ ['transmission', 1],
1014
+ ['thickness', Number.POSITIVE_INFINITY],
1015
+ ['dispersion', Number.POSITIVE_INFINITY],
1016
+ ['diffuseTransmission', 1],
1017
+ ['subsurfaceRadius', Number.POSITIVE_INFINITY],
1018
+ ['clearcoat', 1],
1019
+ ['clearcoatRoughness', 1],
1020
+ ['sheenRoughness', 1],
1021
+ ['iridescence', 1],
1022
+ ['anisotropy', 1],
1023
+ ['edgeFade', 1],
1024
+ ];
1025
+ /** The highest value that each ranged value takes, by its name. */
1026
+ const ONE_VALUE_MAX = new Map(RANGED);
1027
+ /** Each whole-number value's name, in `RANGED`'s order, for the development checks. */
1028
+ const RANGED_NAMES = [
1029
+ 'opacity',
1030
+ 'alpha cutoff',
1031
+ 'metalness',
1032
+ 'roughness',
1033
+ 'emissive intensity',
1034
+ 'aoMapIntensity',
1035
+ 'lightMapIntensity',
1036
+ 'specularIntensity',
1037
+ 'envIntensity',
1038
+ 'transmission',
1039
+ 'thickness',
1040
+ 'dispersion',
1041
+ 'diffuseTransmission',
1042
+ 'subsurfaceRadius',
1043
+ 'clearcoat',
1044
+ 'clearcoatRoughness',
1045
+ 'sheenRoughness',
1046
+ 'iridescence',
1047
+ 'anisotropy',
1048
+ 'edgeFade',
1049
+ ];
1050
+ /** The core's slot of each map option. */
1051
+ const MAP_OPTIONS = [
1052
+ ['map', MAP_SLOT_BASE_COLOR],
1053
+ ['metalnessRoughnessMap', MAP_SLOT_METAL_ROUGH],
1054
+ ['normalMap', MAP_SLOT_NORMAL],
1055
+ ['aoMap', MAP_SLOT_OCCLUSION],
1056
+ ['emissiveMap', MAP_SLOT_EMISSIVE],
1057
+ ['lightMap', MAP_SLOT_LIGHT],
1058
+ ['specularIntensityMap', MAP_SLOT_SPECULAR_INTENSITY],
1059
+ ['specularColorMap', MAP_SLOT_SPECULAR_COLOR],
1060
+ ['diffuseTransmissionMap', MAP_SLOT_DIFFUSE_TRANSMISSION],
1061
+ ['diffuseTransmissionColorMap', MAP_SLOT_DIFFUSE_TRANSMISSION_COLOR],
1062
+ ['transmissionMap', MAP_SLOT_TRANSMISSION],
1063
+ ['thicknessMap', MAP_SLOT_THICKNESS],
1064
+ ['clearcoatMap', MAP_SLOT_COAT],
1065
+ ['clearcoatRoughnessMap', MAP_SLOT_COAT_ROUGHNESS],
1066
+ ['clearcoatNormalMap', MAP_SLOT_COAT_NORMAL],
1067
+ ['sheenColorMap', MAP_SLOT_SHEEN_COLOR],
1068
+ ['sheenRoughnessMap', MAP_SLOT_SHEEN_ROUGHNESS],
1069
+ ['iridescenceMap', MAP_SLOT_IRIDESCENCE],
1070
+ ['iridescenceThicknessMap', MAP_SLOT_IRIDESCENCE_THICKNESS],
1071
+ ['anisotropyMap', MAP_SLOT_ANISOTROPY],
1072
+ ];
1073
+ /**
1074
+ * The row slot that holds the texture of each map whose core slot is not a row slot: a layer map
1075
+ * keeps its texture in one of the light and specular slots, the transmission and thickness maps
1076
+ * keep row slots after them, and a bump or displacement map in the normal map's slot. The row keeps
1077
+ * a texture coordinate transform for each row slot, so a map's transform goes to its own slot.
1078
+ */
1079
+ const MAP_ROW_SLOTS = new Map([
1080
+ [MAP_SLOT_COAT, MAP_ROW_SLOT_COAT],
1081
+ [MAP_SLOT_COAT_ROUGHNESS, MAP_ROW_SLOT_COAT_ROUGHNESS],
1082
+ [MAP_SLOT_COAT_NORMAL, MAP_ROW_SLOT_COAT_NORMAL],
1083
+ [MAP_SLOT_SHEEN_COLOR, MAP_ROW_SLOT_SHEEN_COLOR],
1084
+ [MAP_SLOT_SHEEN_ROUGHNESS, MAP_ROW_SLOT_SHEEN_ROUGHNESS],
1085
+ [MAP_SLOT_IRIDESCENCE, MAP_ROW_SLOT_IRIDESCENCE],
1086
+ [MAP_SLOT_IRIDESCENCE_THICKNESS, MAP_ROW_SLOT_IRIDESCENCE_THICKNESS],
1087
+ [MAP_SLOT_ANISOTROPY, MAP_ROW_SLOT_ANISOTROPY],
1088
+ [MAP_SLOT_TRANSMISSION, MAP_ROW_SLOT_TRANSMISSION],
1089
+ [MAP_SLOT_THICKNESS, MAP_ROW_SLOT_THICKNESS],
1090
+ [MAP_SLOT_BUMP, MAP_ROW_SLOT_BUMP],
1091
+ [MAP_SLOT_DISPLACEMENT, MAP_ROW_SLOT_DISPLACEMENT],
1092
+ ]);
1093
+ /** The row slot that holds a map's texture, whose transform places it. */
1094
+ function mapRowSlot(slot) {
1095
+ return MAP_ROW_SLOTS.get(slot) ?? slot;
1096
+ }
1097
+ /**
1098
+ * The map that fills each row slot of `options`, by the rules that choose which maps draw. The row
1099
+ * keeps one transform for each slot, so only a map that the material keeps may place it: a map
1100
+ * that a production build leaves out places nothing, and a normal map wins over a bump map. A
1101
+ * displacement map places the normal map's slot where no other map does, since its vertex stage
1102
+ * reads that slot's transform even where no texture fills it.
1103
+ *
1104
+ * @internal
1105
+ */
1106
+ export function slotOwners(options, features, layered) {
1107
+ const owners = new Array(MAP_SLOT_COUNT).fill(undefined);
1108
+ for (const [key, slot] of MAP_OPTIONS) {
1109
+ if (!options[key])
1110
+ continue;
1111
+ if (skipsMap(key, features) || skipsTransmissionMap(options, key))
1112
+ continue;
1113
+ if (layered && skipsLayerMap(options, key))
1114
+ continue;
1115
+ // A map that fills a slot leaves the map before it in the list out, as the map writes do.
1116
+ owners[mapRowSlot(slot)] = key;
1117
+ }
1118
+ const height = mapRowSlot(MAP_SLOT_NORMAL);
1119
+ if (owners[height] === undefined) {
1120
+ // The bump map takes the normal map's slot where the normal map leaves it, and a
1121
+ // displacement map reads that slot where neither takes it.
1122
+ if (bumps(options))
1123
+ owners[height] = 'bumpMap';
1124
+ else if (options.displacementMap)
1125
+ owners[height] = 'displacementMap';
1126
+ }
1127
+ return owners;
1128
+ }
1129
+ /** Writes each row slot's transform from the map that fills it, and none from a map left out. */
1130
+ function writeMapUvTransforms(core, id, transforms, owners, call) {
1131
+ if (transforms === undefined || owners === undefined)
1132
+ return;
1133
+ for (let slot = 0; slot < owners.length; slot++) {
1134
+ const key = owners[slot];
1135
+ if (key === undefined)
1136
+ continue;
1137
+ const transform = transforms[key];
1138
+ if (transform !== undefined)
1139
+ writeUvTransform(core, id, slot, transform, call);
1140
+ }
1141
+ }
1142
+ /** The maps that share their slots with the diffuse transmission maps. */
1143
+ const SPECULAR_MAPS = new Set([
1144
+ 'specularIntensityMap',
1145
+ 'specularColorMap',
1146
+ ]);
1147
+ /** The maps that only a material that lets light through to its other side takes. */
1148
+ const TRANSLUCENCY_MAPS = new Set([
1149
+ 'diffuseTransmissionMap',
1150
+ 'diffuseTransmissionColorMap',
1151
+ ]);
1152
+ /**
1153
+ * The maps that share their slots with the specular maps, of a material that lets light through:
1154
+ * the slots of the one hold the maps of the other.
1155
+ */
1156
+ const TRANSMISSION_MAPS = new Set([
1157
+ 'transmissionMap',
1158
+ 'thicknessMap',
1159
+ ]);
1160
+ /**
1161
+ * True when a map option does not fit a material with `features`: the diffuse transmission maps
1162
+ * without diffuse transmission, and the specular maps with it, which would take the same slots.
1163
+ */
1164
+ function skipsMap(key, features) {
1165
+ const translucent = (features & MATERIAL_FEATURE_TRANSLUCENCY) !== 0;
1166
+ return translucent ? SPECULAR_MAPS.has(key) : TRANSLUCENCY_MAPS.has(key);
1167
+ }
1168
+ /**
1169
+ * True for a transmission or thickness map that a material leaves out, because it gives no
1170
+ * transmission or lets light through to its other side: each of those takes the specular maps'
1171
+ * slots. A material may keep the specular maps beside these two. Development builds refuse these
1172
+ * with E1217 instead.
1173
+ */
1174
+ function skipsTransmissionMap(options, key) {
1175
+ if (!TRANSMISSION_MAPS.has(key))
1176
+ return false;
1177
+ return options.transmission === undefined || options.diffuseTransmission !== undefined;
1178
+ }
1179
+ /** The values of a clear coat, a sheen, iridescence or anisotropy, any of which gives a material its layers. */
1180
+ const LAYER_VALUES = [
1181
+ 'clearcoat',
1182
+ 'clearcoatRoughness',
1183
+ 'clearcoatNormalScale',
1184
+ 'sheenColor',
1185
+ 'sheenRoughness',
1186
+ 'iridescence',
1187
+ 'iridescenceIor',
1188
+ 'iridescenceThicknessRange',
1189
+ 'anisotropy',
1190
+ 'anisotropyRotation',
1191
+ ];
1192
+ /** The maps of a clear coat and a sheen. */
1193
+ const LAYER_MAPS = [
1194
+ 'clearcoatMap',
1195
+ 'clearcoatRoughnessMap',
1196
+ 'clearcoatNormalMap',
1197
+ 'sheenColorMap',
1198
+ 'sheenRoughnessMap',
1199
+ 'iridescenceMap',
1200
+ 'iridescenceThicknessMap',
1201
+ 'anisotropyMap',
1202
+ ];
1203
+ /** The layer maps that hold a clear coat or a sheen. */
1204
+ const COAT_SHEEN_MAPS = [
1205
+ 'clearcoatMap',
1206
+ 'clearcoatRoughnessMap',
1207
+ 'clearcoatNormalMap',
1208
+ 'sheenColorMap',
1209
+ 'sheenRoughnessMap',
1210
+ ];
1211
+ /** The layer maps that hold iridescence. */
1212
+ const IRIDESCENCE_MAPS = [
1213
+ 'iridescenceMap',
1214
+ 'iridescenceThicknessMap',
1215
+ ];
1216
+ /** The layer maps that fill the specular intensity map's slot, which a transmission map takes. */
1217
+ const SPECULAR_INTENSITY_LAYER_MAPS = [
1218
+ 'clearcoatNormalMap',
1219
+ 'iridescenceThicknessMap',
1220
+ ];
1221
+ /** The layer maps that fill the specular color map's slot, which a thickness map takes. */
1222
+ const SPECULAR_COLOR_LAYER_MAPS = [
1223
+ 'sheenColorMap',
1224
+ 'sheenRoughnessMap',
1225
+ 'anisotropyMap',
1226
+ ];
1227
+ /**
1228
+ * The layer map that fills the texture array that a transmission or a thickness map samples, or
1229
+ * none: the transmission map samples the specular intensity slot's array and the thickness map the
1230
+ * specular color slot's. A material with layers may keep the two maps beside the one layer map of
1231
+ * the light map's slot, so this names the clash that remains.
1232
+ */
1233
+ function volumeSlotOwner(options, key) {
1234
+ const owners = key === 'transmissionMap'
1235
+ ? SPECULAR_INTENSITY_LAYER_MAPS
1236
+ : key === 'thicknessMap'
1237
+ ? SPECULAR_COLOR_LAYER_MAPS
1238
+ : undefined;
1239
+ return owners?.find((owner) => options[owner] !== undefined);
1240
+ }
1241
+ /** True when `options` give any map of `keys`. */
1242
+ function takesAnyMap(options, keys) {
1243
+ return keys.some((key) => options[key] !== undefined);
1244
+ }
1245
+ /** True when `options` give the material a thin film above its surface. */
1246
+ function takesIridescence(options) {
1247
+ return (options.iridescence !== undefined ||
1248
+ options.iridescenceIor !== undefined ||
1249
+ options.iridescenceThicknessRange !== undefined ||
1250
+ options.iridescenceMap !== undefined ||
1251
+ options.iridescenceThicknessMap !== undefined);
1252
+ }
1253
+ /** True when `options` give the material a stretched specular lobe. */
1254
+ function takesAnisotropy(options) {
1255
+ return (options.anisotropy !== undefined ||
1256
+ options.anisotropyRotation !== undefined ||
1257
+ options.anisotropyMap !== undefined);
1258
+ }
1259
+ /**
1260
+ * True for a map that a layered material leaves out, which development builds refuse with E1217:
1261
+ * a map whose slot another layer's maps take, and the second map of a pair that is not the texture
1262
+ * of the first. A material takes its layer maps from one family: the coat's and the sheen's, or
1263
+ * iridescence's and the anisotropy's. Production builds skip the check, so the material draws
1264
+ * without the map rather than read it as another layer's.
1265
+ */
1266
+ function skipsLayerMap(options, key) {
1267
+ if (key === 'lightMap' || SPECULAR_MAPS.has(key) || TRANSLUCENCY_MAPS.has(key))
1268
+ return true;
1269
+ // A transmission map takes the specular intensity map's slot and a thickness map the specular
1270
+ // color map's, so each stays out only where a layer map fills that slot.
1271
+ if (TRANSMISSION_MAPS.has(key))
1272
+ return volumeSlotOwner(options, key) !== undefined;
1273
+ if (key === 'clearcoatRoughnessMap')
1274
+ return !!options.clearcoatMap && options.clearcoatMap !== options.clearcoatRoughnessMap;
1275
+ if (key === 'sheenRoughnessMap')
1276
+ return !!options.sheenColorMap && options.sheenColorMap !== options.sheenRoughnessMap;
1277
+ if (takesAnyMap(options, COAT_SHEEN_MAPS))
1278
+ return IRIDESCENCE_MAPS.includes(key) || key === 'anisotropyMap';
1279
+ return false;
1280
+ }
1281
+ /** True when `options` give the material layers above its base. */
1282
+ function hasLayers(options) {
1283
+ return (LAYER_VALUES.some((key) => options[key] !== undefined) ||
1284
+ LAYER_MAPS.some((key) => options[key] !== undefined));
1285
+ }
1286
+ /** Throws E1108 for a pair or a transform with a number that is not finite. */
1287
+ function checkNumbers(values, call) {
1288
+ const { normalScale, clearcoatNormalScale, uvTransform, bumpScale, displacementScale, displacementBias, } = values;
1289
+ const numbers = [
1290
+ ...(normalScale ?? []),
1291
+ ...(clearcoatNormalScale ?? []),
1292
+ ...(uvTransform?.offset ?? []),
1293
+ ...(uvTransform?.repeat ?? []),
1294
+ uvTransform?.rotation ?? 0,
1295
+ bumpScale ?? 0,
1296
+ displacementScale ?? 0,
1297
+ displacementBias ?? 0,
1298
+ ];
1299
+ for (const transform of Object.values(values.mapUvTransforms ?? {}))
1300
+ if (transform !== undefined)
1301
+ numbers.push(...(transform.offset ?? []), ...(transform.repeat ?? []), transform.rotation ?? 0);
1302
+ if (!numbers.every(Number.isFinite))
1303
+ throw new EngineError('E1108', `${call}() got a normalScale, clearcoatNormalScale, uvTransform, mapUvTransforms, bumpScale, displacementScale or displacementBias that is not finite.`);
1304
+ }
1305
+ /** Throws E1108 for each number of `values` outside its range. Call it inside `if (DEV)`. */
1306
+ function checkValues(values, call) {
1307
+ checkNumbers(values, call);
1308
+ const { ior, attenuationDistance: distance, angleFade } = values;
1309
+ const { iridescenceIor, iridescenceThicknessRange, anisotropyRotation } = values;
1310
+ if (iridescenceIor !== undefined &&
1311
+ !(iridescenceIor >= 1 && iridescenceIor < Number.POSITIVE_INFINITY))
1312
+ throw new EngineError('E1108', `${call}() got the iridescenceIor ${iridescenceIor}; it takes a finite 1 or more.`);
1313
+ if (iridescenceThicknessRange !== undefined &&
1314
+ !(iridescenceThicknessRange.length === 2 &&
1315
+ iridescenceThicknessRange[0] >= 0 &&
1316
+ iridescenceThicknessRange[0] <= iridescenceThicknessRange[1] &&
1317
+ Number.isFinite(iridescenceThicknessRange[1])))
1318
+ throw new EngineError('E1108', `${call}() got the iridescenceThicknessRange ${JSON.stringify(iridescenceThicknessRange)}; it takes two thicknesses in nanometers, the first no larger than the second.`);
1319
+ if (anisotropyRotation !== undefined && !Number.isFinite(anisotropyRotation))
1320
+ throw new EngineError('E1108', `${call}() got the anisotropyRotation ${anisotropyRotation}; it takes a finite number of radians.`);
1321
+ if (angleFade !== undefined &&
1322
+ !(angleFade.length === 2 &&
1323
+ angleFade[0] >= 0 &&
1324
+ angleFade[0] <= angleFade[1] &&
1325
+ angleFade[1] <= Math.PI))
1326
+ throw new EngineError('E1108', `${call}() got the angleFade ${JSON.stringify(angleFade)}; it takes two angles from 0 to π, the first no larger than the second.`);
1327
+ if (ior !== undefined && !(ior >= 1 && ior < Number.POSITIVE_INFINITY))
1328
+ throw new EngineError('E1108', `${call}() got the ior ${ior}; it takes a finite 1 or more.`);
1329
+ if (distance !== undefined && !(distance > 0))
1330
+ throw new EngineError('E1108', `${call}() got the attenuationDistance ${distance}; it takes more than 0, or Infinity.`);
1331
+ for (let k = 0; k < RANGED.length; k++) {
1332
+ const [key, most] = RANGED[k];
1333
+ const value = values[key];
1334
+ if (value === undefined)
1335
+ continue;
1336
+ if (!(value >= 0 && value <= most)) {
1337
+ const name = RANGED_NAMES[k];
1338
+ throw new EngineError('E1108', most === 1
1339
+ ? `${call}() got the ${name} ${value}, outside 0 to 1.`
1340
+ : `${call}() got the ${name} ${value}; it takes 0 or more.`);
1341
+ }
1342
+ }
1343
+ }
1344
+ /**
1345
+ * Writes the numbers of `values` that are set, and the linear colors that are given, into the
1346
+ * core's row of material `id`. Every value was checked and every color converted before, so a
1347
+ * call that throws changes nothing. Each number option is read once, by its name, only from an
1348
+ * object that holds it, and goes to the core through its call values. A fraction read by a key
1349
+ * that changes, read where some objects lack it and the read gives `undefined`, or passed as an
1350
+ * argument to a call that the browser does not inline, would each make a number object.
1351
+ */
1352
+ function writeValues(core, id, call, values, color, emissive, specular, attenuation, through, scatter, sheen) {
1353
+ if (color)
1354
+ sendColor(core, id, MATERIAL_PARAM_COLOR, color, call);
1355
+ if (emissive)
1356
+ sendColor(core, id, MATERIAL_PARAM_EMISSIVE, emissive, call);
1357
+ if (specular)
1358
+ sendColor(core, id, MATERIAL_PARAM_SPECULAR_COLOR, specular, call);
1359
+ if (attenuation)
1360
+ sendColor(core, id, MATERIAL_PARAM_ATTENUATION_COLOR, attenuation, call);
1361
+ if (through)
1362
+ sendColor(core, id, MATERIAL_PARAM_DIFFUSE_TRANSMISSION_COLOR, through, call);
1363
+ if (scatter)
1364
+ sendColor(core, id, MATERIAL_PARAM_SUBSURFACE_COLOR, scatter, call);
1365
+ if (sheen)
1366
+ sendColor(core, id, MATERIAL_PARAM_SHEEN_COLOR, sheen, call);
1367
+ const numbers = core.callValues();
1368
+ const { normalScale, clearcoatNormalScale, uvTransform, angleFade } = values;
1369
+ if ('opacity' in values) {
1370
+ const value = values.opacity;
1371
+ if (value !== undefined) {
1372
+ numbers[0] = value;
1373
+ sendValue(core, id, MATERIAL_PARAM_OPACITY, call);
1374
+ }
1375
+ }
1376
+ if ('alphaCutoff' in values) {
1377
+ const value = values.alphaCutoff;
1378
+ if (value !== undefined) {
1379
+ numbers[0] = value;
1380
+ sendValue(core, id, MATERIAL_PARAM_ALPHA_CUTOFF, call);
1381
+ }
1382
+ }
1383
+ if ('metalness' in values) {
1384
+ const value = values.metalness;
1385
+ if (value !== undefined) {
1386
+ numbers[0] = value;
1387
+ sendValue(core, id, MATERIAL_PARAM_METALNESS, call);
1388
+ }
1389
+ }
1390
+ if ('roughness' in values) {
1391
+ const value = values.roughness;
1392
+ if (value !== undefined) {
1393
+ numbers[0] = value;
1394
+ sendValue(core, id, MATERIAL_PARAM_ROUGHNESS, call);
1395
+ }
1396
+ }
1397
+ if ('emissiveIntensity' in values) {
1398
+ const value = values.emissiveIntensity;
1399
+ if (value !== undefined) {
1400
+ numbers[0] = value;
1401
+ sendValue(core, id, MATERIAL_PARAM_EMISSIVE_INTENSITY, call);
1402
+ }
1403
+ }
1404
+ if ('aoMapIntensity' in values) {
1405
+ const value = values.aoMapIntensity;
1406
+ if (value !== undefined) {
1407
+ numbers[0] = value;
1408
+ sendValue(core, id, MATERIAL_PARAM_OCCLUSION_STRENGTH, call);
1409
+ }
1410
+ }
1411
+ if ('lightMapIntensity' in values) {
1412
+ const value = values.lightMapIntensity;
1413
+ if (value !== undefined) {
1414
+ numbers[0] = value;
1415
+ sendValue(core, id, MATERIAL_PARAM_LIGHT_MAP_INTENSITY, call);
1416
+ }
1417
+ }
1418
+ if ('specularIntensity' in values) {
1419
+ const value = values.specularIntensity;
1420
+ if (value !== undefined) {
1421
+ numbers[0] = value;
1422
+ sendValue(core, id, MATERIAL_PARAM_SPECULAR_INTENSITY, call);
1423
+ }
1424
+ }
1425
+ if ('envIntensity' in values) {
1426
+ const value = values.envIntensity;
1427
+ if (value !== undefined) {
1428
+ numbers[0] = value;
1429
+ sendValue(core, id, MATERIAL_PARAM_ENV_INTENSITY, call);
1430
+ }
1431
+ }
1432
+ if ('transmission' in values) {
1433
+ const value = values.transmission;
1434
+ if (value !== undefined) {
1435
+ numbers[0] = value;
1436
+ sendValue(core, id, MATERIAL_PARAM_TRANSMISSION, call);
1437
+ }
1438
+ }
1439
+ if ('thickness' in values) {
1440
+ const value = values.thickness;
1441
+ if (value !== undefined) {
1442
+ numbers[0] = value;
1443
+ sendValue(core, id, MATERIAL_PARAM_THICKNESS, call);
1444
+ }
1445
+ }
1446
+ if ('dispersion' in values) {
1447
+ const value = values.dispersion;
1448
+ if (value !== undefined) {
1449
+ numbers[0] = value;
1450
+ sendValue(core, id, MATERIAL_PARAM_DISPERSION, call);
1451
+ }
1452
+ }
1453
+ if ('diffuseTransmission' in values) {
1454
+ const value = values.diffuseTransmission;
1455
+ if (value !== undefined) {
1456
+ numbers[0] = value;
1457
+ sendValue(core, id, MATERIAL_PARAM_DIFFUSE_TRANSMISSION, call);
1458
+ }
1459
+ }
1460
+ if ('subsurfaceRadius' in values) {
1461
+ const value = values.subsurfaceRadius;
1462
+ if (value !== undefined) {
1463
+ numbers[0] = value;
1464
+ sendValue(core, id, MATERIAL_PARAM_SUBSURFACE_RADIUS, call);
1465
+ }
1466
+ }
1467
+ if ('clearcoat' in values) {
1468
+ const value = values.clearcoat;
1469
+ if (value !== undefined) {
1470
+ numbers[0] = value;
1471
+ sendValue(core, id, MATERIAL_PARAM_CLEARCOAT, call);
1472
+ }
1473
+ }
1474
+ if ('clearcoatRoughness' in values) {
1475
+ const value = values.clearcoatRoughness;
1476
+ if (value !== undefined) {
1477
+ numbers[0] = value;
1478
+ sendValue(core, id, MATERIAL_PARAM_CLEARCOAT_ROUGHNESS, call);
1479
+ }
1480
+ }
1481
+ if ('sheenRoughness' in values) {
1482
+ const value = values.sheenRoughness;
1483
+ if (value !== undefined) {
1484
+ numbers[0] = value;
1485
+ sendValue(core, id, MATERIAL_PARAM_SHEEN_ROUGHNESS, call);
1486
+ }
1487
+ }
1488
+ if ('iridescence' in values) {
1489
+ const value = values.iridescence;
1490
+ if (value !== undefined) {
1491
+ numbers[0] = value;
1492
+ sendValue(core, id, MATERIAL_PARAM_IRIDESCENCE, call);
1493
+ }
1494
+ }
1495
+ if ('iridescenceIor' in values) {
1496
+ const value = values.iridescenceIor;
1497
+ if (value !== undefined) {
1498
+ numbers[0] = value;
1499
+ sendValue(core, id, MATERIAL_PARAM_IRIDESCENCE_IOR, call);
1500
+ }
1501
+ }
1502
+ if ('anisotropy' in values) {
1503
+ const value = values.anisotropy;
1504
+ if (value !== undefined) {
1505
+ numbers[0] = value;
1506
+ sendValue(core, id, MATERIAL_PARAM_ANISOTROPY, call);
1507
+ }
1508
+ }
1509
+ if ('anisotropyRotation' in values) {
1510
+ const value = values.anisotropyRotation;
1511
+ if (value !== undefined) {
1512
+ numbers[0] = value;
1513
+ sendValue(core, id, MATERIAL_PARAM_ANISOTROPY_ROTATION, call);
1514
+ }
1515
+ }
1516
+ // The film's thickness at each end of its map's green channel.
1517
+ const thickness = values
1518
+ .iridescenceThicknessRange;
1519
+ if (thickness) {
1520
+ numbers[0] = thickness[0];
1521
+ sendValue(core, id, MATERIAL_PARAM_IRIDESCENCE_THICKNESS_MIN, call);
1522
+ numbers[0] = thickness[1];
1523
+ sendValue(core, id, MATERIAL_PARAM_IRIDESCENCE_THICKNESS_MAX, call);
1524
+ }
1525
+ if ('edgeFade' in values) {
1526
+ const value = values.edgeFade;
1527
+ if (value !== undefined) {
1528
+ numbers[0] = value;
1529
+ sendValue(core, id, MATERIAL_PARAM_DECAL_EDGE_FADE, call);
1530
+ }
1531
+ }
1532
+ // A decal's fade from its direction: the cosines of the two angles the material carries.
1533
+ if (angleFade) {
1534
+ numbers[0] = Math.cos(angleFade[0]);
1535
+ sendValue(core, id, MATERIAL_PARAM_DECAL_FADE_START, call);
1536
+ numbers[0] = Math.cos(angleFade[1]);
1537
+ sendValue(core, id, MATERIAL_PARAM_DECAL_FADE_END, call);
1538
+ }
1539
+ if ('ior' in values) {
1540
+ const ior = values.ior;
1541
+ if (ior !== undefined) {
1542
+ numbers[0] = reflectance(ior);
1543
+ sendValue(core, id, MATERIAL_PARAM_REFLECTANCE, call);
1544
+ numbers[0] = ior;
1545
+ sendValue(core, id, MATERIAL_PARAM_IOR, call);
1546
+ }
1547
+ }
1548
+ // The core keeps 0 for a volume that absorbs nothing.
1549
+ if ('attenuationDistance' in values) {
1550
+ const distance = values.attenuationDistance;
1551
+ if (distance !== undefined) {
1552
+ numbers[0] = distance < Infinity ? distance : 0;
1553
+ sendValue(core, id, MATERIAL_PARAM_ATTENUATION_DISTANCE, call);
1554
+ }
1555
+ }
1556
+ if (normalScale) {
1557
+ numbers[0] = normalScale[0];
1558
+ numbers[1] = normalScale[1];
1559
+ sendValue(core, id, MATERIAL_PARAM_NORMAL_SCALE, call);
1560
+ }
1561
+ if (clearcoatNormalScale) {
1562
+ numbers[0] = clearcoatNormalScale[0];
1563
+ numbers[1] = clearcoatNormalScale[1];
1564
+ sendValue(core, id, MATERIAL_PARAM_CLEARCOAT_NORMAL_SCALE, call);
1565
+ }
1566
+ if (uvTransform) {
1567
+ for (let slot = 0; slot < MAP_SLOT_COUNT; slot++)
1568
+ writeUvTransform(core, id, slot, uvTransform, call);
1569
+ }
1570
+ }
1571
+ /** The map row slots that a material's row keeps a transform for, from the base color map's at 0. */
1572
+ const MAP_SLOT_COUNT = SIZE_MAP_ROWS;
1573
+ /** The floats between the two rows of one map's transform in a material's row. */
1574
+ const UV_ROW_STRIDE = 4;
1575
+ /** Numbers that one map's recorded transform takes: its offset, its scale and its turn. */
1576
+ const UV_VALUES_LENGTH = 5;
1577
+ /**
1578
+ * Writes where material `id`'s map in `slot` sits on the texture coordinates, as three.js's texture
1579
+ * matrix with its center at the origin, by rows. It allocates nothing.
1580
+ */
1581
+ function writeUvMatrix(core, id, slot, offsetU, offsetV, scaleU, scaleV, rotation, call) {
1582
+ const numbers = core.callValues();
1583
+ const c = Math.cos(rotation);
1584
+ const s = Math.sin(rotation);
1585
+ // The base color map's two rows sit with the values that every shader reads, and the other
1586
+ // slots' pairs sit in the row's block of map transforms, 4 floats apart.
1587
+ const u = slot === 0
1588
+ ? MATERIAL_PARAM_UV_U
1589
+ : MATERIAL_PARAM_MAP_UV + (slot - 1) * MATERIAL_PARAM_MAP_UV_STRIDE;
1590
+ const v = slot === 0 ? MATERIAL_PARAM_UV_V : u + UV_ROW_STRIDE;
1591
+ numbers[0] = scaleU * c;
1592
+ numbers[1] = scaleU * s;
1593
+ numbers[2] = offsetU;
1594
+ sendValue(core, id, u, call);
1595
+ numbers[0] = -scaleV * s;
1596
+ numbers[1] = scaleV * c;
1597
+ numbers[2] = offsetV;
1598
+ sendValue(core, id, v, call);
1599
+ }
1600
+ /** Writes `transform`, with the defaults of the values that it leaves out, to map `slot`'s rows. */
1601
+ function writeUvTransform(core, id, slot, transform, call) {
1602
+ const { offset, repeat, rotation = 0 } = transform;
1603
+ writeUvMatrix(core, id, slot, offset ? offset[0] : 0, offset ? offset[1] : 0, repeat ? repeat[0] : 1, repeat ? repeat[1] : 1, rotation, call);
1604
+ }
1605
+ /** Sets material `id`'s value `param` to the core's call values. */
1606
+ function sendValue(core, id, param, call) {
1607
+ core.check(core.glue.setMaterialValue(id, param), call, undefined, true);
1608
+ }
1609
+ /**
1610
+ * The core's parameter of each standard value that `setUniform` writes by name: the numbers and the
1611
+ * colors that a sketch changes in every frame. A value that takes more than one parameter, as the
1612
+ * texture transform, the normal scales, the angle fade and the index of refraction do, goes through
1613
+ * `set`.
1614
+ */
1615
+ const ONE_VALUE_PARAMS = new Map([
1616
+ ['color', MATERIAL_PARAM_COLOR],
1617
+ ['emissive', MATERIAL_PARAM_EMISSIVE],
1618
+ ['specularColor', MATERIAL_PARAM_SPECULAR_COLOR],
1619
+ ['attenuationColor', MATERIAL_PARAM_ATTENUATION_COLOR],
1620
+ ['sheenColor', MATERIAL_PARAM_SHEEN_COLOR],
1621
+ ['opacity', MATERIAL_PARAM_OPACITY],
1622
+ ['alphaCutoff', MATERIAL_PARAM_ALPHA_CUTOFF],
1623
+ ['metalness', MATERIAL_PARAM_METALNESS],
1624
+ ['roughness', MATERIAL_PARAM_ROUGHNESS],
1625
+ ['emissiveIntensity', MATERIAL_PARAM_EMISSIVE_INTENSITY],
1626
+ ['aoMapIntensity', MATERIAL_PARAM_OCCLUSION_STRENGTH],
1627
+ ['lightMapIntensity', MATERIAL_PARAM_LIGHT_MAP_INTENSITY],
1628
+ ['specularIntensity', MATERIAL_PARAM_SPECULAR_INTENSITY],
1629
+ ['envIntensity', MATERIAL_PARAM_ENV_INTENSITY],
1630
+ ['transmission', MATERIAL_PARAM_TRANSMISSION],
1631
+ ['thickness', MATERIAL_PARAM_THICKNESS],
1632
+ ['dispersion', MATERIAL_PARAM_DISPERSION],
1633
+ ['diffuseTransmission', MATERIAL_PARAM_DIFFUSE_TRANSMISSION],
1634
+ ['subsurfaceRadius', MATERIAL_PARAM_SUBSURFACE_RADIUS],
1635
+ ['clearcoat', MATERIAL_PARAM_CLEARCOAT],
1636
+ ['clearcoatRoughness', MATERIAL_PARAM_CLEARCOAT_ROUGHNESS],
1637
+ ['sheenRoughness', MATERIAL_PARAM_SHEEN_ROUGHNESS],
1638
+ ['iridescence', MATERIAL_PARAM_IRIDESCENCE],
1639
+ ['iridescenceIor', MATERIAL_PARAM_IRIDESCENCE_IOR],
1640
+ ['anisotropy', MATERIAL_PARAM_ANISOTROPY],
1641
+ ['anisotropyRotation', MATERIAL_PARAM_ANISOTROPY_ROTATION],
1642
+ ['edgeFade', MATERIAL_PARAM_DECAL_EDGE_FADE],
1643
+ ]);
1644
+ /** The values of `ONE_VALUE_PARAMS` that take a color; every other takes a number. */
1645
+ const COLOR_VALUES = new Set([
1646
+ 'color',
1647
+ 'emissive',
1648
+ 'specularColor',
1649
+ 'attenuationColor',
1650
+ 'sheenColor',
1651
+ ]);
1652
+ /**
1653
+ * The material values that take a pair of numbers: where the maps sit on the texture coordinates.
1654
+ * Every map of a material shares the transform, so a pair moves them all.
1655
+ */
1656
+ const UV_VALUES = new Set(['uvOffset', 'uvScale']);
1657
+ /**
1658
+ * Numbers per key that a material value takes: 3 for a color, 2 for the maps' offset or scale, 1
1659
+ * for a number, and 0 for a name that the value has none. It reads the tables that `setUniform`
1660
+ * uses, so a name that it takes is a name that `setUniform` takes.
1661
+ *
1662
+ * @internal
1663
+ */
1664
+ export function materialValueComponents(name) {
1665
+ if (UV_VALUES.has(name))
1666
+ return 2;
1667
+ if (!ONE_VALUE_PARAMS.has(name))
1668
+ return 0;
1669
+ return COLOR_VALUES.has(name) ? 3 : 1;
1670
+ }
1671
+ /** The name that messages give `setUniform`, from a material's `set` call string. */
1672
+ function setUniformCall(call) {
1673
+ return call.replace(/\.set$/, '.setUniform');
1674
+ }
1675
+ /**
1676
+ * Writes one standard value of material `id` by name, through the core's call values. It allocates
1677
+ * nothing: the value crosses the call, where `set` reads it from a field of an options object.
1678
+ * Throws E1216 for a name or a value that `setUniform` does not take, and, in a development build,
1679
+ * E1203 or E1108 for a number that the value does not take.
1680
+ */
1681
+ function writeOneValue(core, id, call, name, value) {
1682
+ const param = ONE_VALUE_PARAMS.get(name);
1683
+ if (param === undefined)
1684
+ throw new EngineError('E1216', `${call}() got ${name}, which it does not take: a number or a color that set() takes on its own, such as roughness or color, or a uniform of a custom material's WGSL.`);
1685
+ if (COLOR_VALUES.has(name)) {
1686
+ sendColor(core, id, param, writeLinearColor(core.callValues(), value, call), call);
1687
+ return;
1688
+ }
1689
+ if (DEV) {
1690
+ if (typeof value !== 'number' || !Number.isFinite(value))
1691
+ throw new EngineError('E1203', `${call}() got ${String(value)} for ${name}, which takes a finite number.`);
1692
+ for (let k = 0; k < RANGED.length; k++) {
1693
+ const [key, most] = RANGED[k];
1694
+ if (key !== name)
1695
+ continue;
1696
+ if (value < 0 || value > most) {
1697
+ const label = RANGED_NAMES[k];
1698
+ throw new EngineError('E1108', most === 1
1699
+ ? `${call}() got the ${label} ${value}, outside 0 to 1.`
1700
+ : `${call}() got the ${label} ${value}; it takes 0 or more.`);
1701
+ }
1702
+ break;
1703
+ }
1704
+ }
1705
+ core.callValues()[0] = value;
1706
+ sendValue(core, id, param, call);
1707
+ }
1708
+ /** Sets material `id`'s color `param` to a linear color. */
1709
+ function sendColor(core, id, param, color, call) {
1710
+ core.callValues().set(color);
1711
+ sendValue(core, id, param, call);
1712
+ }
1713
+ /**
1714
+ * The arrays that a material's color options convert into: the color, the emissive color, the
1715
+ * specular color, the attenuation color, the diffuse transmission color, the scatter color and the
1716
+ * sheen color, then a uniform's color while it is checked. Each call converts its colors before it
1717
+ * writes any, and nothing reads them after the call, so the calls share them and converting a
1718
+ * color allocates nothing.
1719
+ */
1720
+ const COLOR = new Float64Array(3);
1721
+ const EMISSIVE = new Float64Array(3);
1722
+ const SPECULAR = new Float64Array(3);
1723
+ const ATTENUATION = new Float64Array(3);
1724
+ const THROUGH = new Float64Array(3);
1725
+ const SCATTER = new Float64Array(3);
1726
+ const SHEEN = new Float64Array(3);
1727
+ const UNIFORM_COLOR = new Float64Array(3);
1728
+ /** The linear value of a color option in `out`, or none when it is not set. */
1729
+ function linearOrNone(color, call, out) {
1730
+ return color === undefined ? undefined : writeLinearColor(out, color, call);
1731
+ }
1732
+ /** A linear RGB color as an sRGB hex string, for the inspector's color fields. */
1733
+ function hexOf(linear) {
1734
+ let value = 0;
1735
+ for (let k = 0; k < 3; k++) {
1736
+ const channel = Math.min(1, Math.max(0, linear[k]));
1737
+ value = (value << 8) | Math.round(linearToSrgb(channel) * 255);
1738
+ }
1739
+ return `#${value.toString(16).padStart(6, '0')}`;
1740
+ }
1741
+ /** The numbers that a material's inspector shows, in the order of its record. */
1742
+ const INSPECTOR_NUMBERS = [
1743
+ 'opacity',
1744
+ 'metalness',
1745
+ 'roughness',
1746
+ 'emissiveIntensity',
1747
+ 'ior',
1748
+ 'specularIntensity',
1749
+ 'envIntensity',
1750
+ ];
1751
+ /** The value of each of those numbers where a material's options leave it out. */
1752
+ const INSPECTOR_DEFAULTS = [1, 0, 1, 1, 1.5, 1, 1];
1753
+ /**
1754
+ * The linear value of a specular color option in `out`, or none when it is not set. Its three
1755
+ * linear components may exceed 1, as glTF's specular color factor may.
1756
+ */
1757
+ function specularOrNone(color, call) {
1758
+ if (Array.isArray(color) && color.length === 3) {
1759
+ const r = color[0];
1760
+ const g = color[1];
1761
+ const b = color[2];
1762
+ if (r >= 0 && r < Infinity && g >= 0 && g < Infinity && b >= 0 && b < Infinity) {
1763
+ SPECULAR[0] = r;
1764
+ SPECULAR[1] = g;
1765
+ SPECULAR[2] = b;
1766
+ return SPECULAR;
1767
+ }
1768
+ }
1769
+ return linearOrNone(color, call, SPECULAR);
1770
+ }
1771
+ /**
1772
+ * The dielectric reflectance at normal incidence of a surface with index of refraction `ior`, by
1773
+ * the Fresnel equations, as three.js's physical material computes it.
1774
+ */
1775
+ function reflectance(ior) {
1776
+ return ((ior - 1) / (ior + 1)) ** 2;
1777
+ }
1778
+ /** The alpha modes, each with the core's feature bit that draws it. */
1779
+ const ALPHA_MODES = {
1780
+ opaque: 0,
1781
+ mask: MATERIAL_FEATURE_ALPHA_MASK,
1782
+ hash: MATERIAL_FEATURE_ALPHA_MASK | MATERIAL_FEATURE_ALPHA_HASH,
1783
+ blend: MATERIAL_FEATURE_BLEND,
1784
+ };
1785
+ /** The blendings, each with the core's feature bit that draws it. */
1786
+ const BLENDINGS = {
1787
+ normal: 0,
1788
+ additive: MATERIAL_FEATURE_ADDITIVE,
1789
+ multiply: MATERIAL_FEATURE_MULTIPLY,
1790
+ weighted: MATERIAL_FEATURE_WEIGHTED,
1791
+ };
1792
+ /**
1793
+ * Throws E1217 for an option that fixes the material's pipeline but takes no such value, and
1794
+ * E1203 for a depth bias that is not a finite number. Call it inside `if (DEV)`.
1795
+ */
1796
+ function checkFeatures(options, call) {
1797
+ const { alphaMode, blending, depthBias, transmission } = options;
1798
+ const features = featureBits(options);
1799
+ for (const [name, pair] of [
1800
+ ['lightMapOffset', options.lightMapOffset],
1801
+ ['lightMapRepeat', options.lightMapRepeat],
1802
+ ]) {
1803
+ if (pair === undefined)
1804
+ continue;
1805
+ if (!(pair.length === 2 && pair.every(Number.isFinite)))
1806
+ throw new EngineError('E1108', `${call}() got the ${name} ${JSON.stringify(pair)}; it takes two finite numbers.`);
1807
+ }
1808
+ for (const [name, given] of [
1809
+ ['lightMapDirection', options.lightMapDirection !== undefined],
1810
+ ['lightMapOffset', options.lightMapOffset !== undefined],
1811
+ ['lightMapRepeat', options.lightMapRepeat !== undefined],
1812
+ ['lightMapDecode', options.lightMapDecode !== undefined],
1813
+ ]) {
1814
+ if (given && options.lightMap === undefined)
1815
+ throw new EngineError('E1217', `${call}() got ${name} without lightMap; it sets how the engine reads a light map that the material does not have. Give the material a lightMap.`);
1816
+ }
1817
+ if (options.lightMapDecode !== undefined &&
1818
+ options.lightMapDecode !== 'srgb' &&
1819
+ options.lightMapDecode !== 'rgbm')
1820
+ throw new EngineError('E1217', `${call}() got the lightMapDecode ${JSON.stringify(options.lightMapDecode)}; it takes 'srgb' or 'rgbm'.`);
1821
+ for (const key of ['transmissionMap', 'thicknessMap']) {
1822
+ if (options[key] === undefined)
1823
+ continue;
1824
+ if (transmission === undefined)
1825
+ throw new EngineError('E1217', `${call}() got ${key} without transmission; give transmission, even as 0, to create a material that lets light through.`);
1826
+ if (options.diffuseTransmission !== undefined)
1827
+ throw new EngineError('E1217', `${call}() got ${key} with diffuseTransmission; a material that lets light through to its other side keeps its diffuse transmission maps in the same slots. Give the material one kind of map or the other.`);
1828
+ // A thickness map samples the specular color map's texture array, and an sRGB texture never
1829
+ // shares an array with a linear one, so the two cannot draw together.
1830
+ if (key === 'thicknessMap' && options.specularColorMap !== undefined)
1831
+ throw new EngineError('E1217', `${call}() got thicknessMap with specularColorMap; the thickness map samples the specular color map's texture array, and an sRGB texture never shares an array with a linear one. Give the material one map of that slot or the other.`);
1832
+ }
1833
+ for (const [key] of MAP_OPTIONS)
1834
+ if (options[key] && skipsMap(key, features))
1835
+ throw new EngineError('E1217', SPECULAR_MAPS.has(key)
1836
+ ? `${call}() got ${key} with diffuseTransmission; a material that lets light through to its other side keeps its diffuse transmission maps in the specular maps' place, so it takes no specular maps.`
1837
+ : `${call}() got ${key} without diffuseTransmission; give diffuseTransmission, even as 0, to create a material that takes it.`);
1838
+ if (options.diffuseTransmission !== undefined && hasLayers(options))
1839
+ throw new EngineError('E1217', `${call}() got diffuseTransmission with a clear coat or a sheen; a layered material lets no light through to its other side, since the layers' maps take the places of its maps. Use a material without layers.`);
1840
+ if (options.diffuseTransmission !== undefined && blending === 'weighted')
1841
+ throw new EngineError('E1217', `${call}() got diffuseTransmission with the 'weighted' blending; a material of the weighted blending lets no light through to its other side. Give it the 'normal' blending.`);
1842
+ if (hasLayers(options))
1843
+ checkLayerMaps(options, call);
1844
+ if (options.parallax && !options.displacementMap)
1845
+ throw new EngineError('E1217', `${call}() got parallax without a displacementMap; parallax reads the displacement map's heights.`);
1846
+ if (options.parallax &&
1847
+ (alphaMode === 'blend' ||
1848
+ transmission !== undefined ||
1849
+ options.diffuseTransmission !== undefined))
1850
+ throw new EngineError('E1217', `${call}() got parallax with ${transmission !== undefined ? 'transmission' : options.diffuseTransmission !== undefined ? 'diffuseTransmission' : "the alpha mode 'blend'"}; parallax takes an opaque or masked surface. Leave parallax out to keep the displacement alone.`);
1851
+ if (transmission !== undefined && alphaMode === 'hash')
1852
+ throw new EngineError('E1217', `${call}() got transmission with the alpha mode 'hash'; a material that lets light through takes 'opaque', 'mask' or 'blend'.`);
1853
+ if (transmission !== undefined && blending === 'weighted')
1854
+ throw new EngineError('E1217', `${call}() got transmission with the 'weighted' blending; a material that lets light through draws back to front. Give it the 'normal' blending.`);
1855
+ if (alphaMode !== undefined && !Object.hasOwn(ALPHA_MODES, alphaMode))
1856
+ throw new EngineError('E1217', `${call}() got the alpha mode ${JSON.stringify(alphaMode)}; it takes 'opaque', 'mask', 'hash' or 'blend'.`);
1857
+ if (blending !== undefined && !Object.hasOwn(BLENDINGS, blending))
1858
+ throw new EngineError('E1217', `${call}() got the blending ${JSON.stringify(blending)}; it takes 'normal', 'additive', 'multiply' or 'weighted'.`);
1859
+ for (const key of ['constant', 'slopeScale']) {
1860
+ const value = depthBias?.[key] ?? 0;
1861
+ if (!Number.isFinite(value))
1862
+ throw new EngineError('E1203', `${call}() got ${value} for depthBias.${key}.`);
1863
+ }
1864
+ }
1865
+ /**
1866
+ * Throws E1217 for a layered material with a map whose slot its layers take, for a transmission
1867
+ * or a thickness map beside the layer map of its own slot, and for a pair of layer maps that glTF
1868
+ * packs into one texture but that are two. Call it inside `if (DEV)`.
1869
+ */
1870
+ function checkLayerMaps(options, call) {
1871
+ const sharedSlot = options.lightMap !== undefined
1872
+ ? 'lightMap'
1873
+ : options.specularIntensityMap !== undefined
1874
+ ? 'specularIntensityMap'
1875
+ : options.specularColorMap !== undefined
1876
+ ? 'specularColorMap'
1877
+ : undefined;
1878
+ if (sharedSlot)
1879
+ throw new EngineError('E1217', `${call}() got ${sharedSlot} with a clear coat, a sheen, iridescence or anisotropy, whose maps take its place. Bake its light or specular values into the other maps, or use a material without layers.`);
1880
+ // The transmission and thickness maps sample the specular slots' texture arrays, which a layer
1881
+ // map fills only when the material gives one of that slot: the light map's slot stays free for
1882
+ // its layer map beside them.
1883
+ for (const key of TRANSMISSION_MAPS) {
1884
+ if (options[key] === undefined)
1885
+ continue;
1886
+ const owner = volumeSlotOwner(options, key);
1887
+ if (owner)
1888
+ throw new EngineError('E1217', `${call}() got ${key} with ${owner}, which fills the array that it samples. Give the material one map of that slot or the other.`);
1889
+ }
1890
+ for (const [first, second, packed] of [
1891
+ ['clearcoatMap', 'clearcoatRoughnessMap', 'the roughness in the green of the clear coat map'],
1892
+ ['sheenColorMap', 'sheenRoughnessMap', 'the roughness in the alpha of the sheen color map'],
1893
+ ]) {
1894
+ const a = options[first];
1895
+ const b = options[second];
1896
+ if (a && b && a !== b)
1897
+ throw new EngineError('E1217', `${call}() got a ${first} and a ${second} that are two textures. Give one texture for both, with ${packed}, as glTF packs them.`);
1898
+ }
1899
+ // A material's maps come from one family of layers, since the maps of each take the same slots.
1900
+ // The layers' values may mix freely: the row says which family's maps the slots hold.
1901
+ if (takesAnyMap(options, COAT_SHEEN_MAPS)) {
1902
+ const clash = (options.iridescenceMap !== undefined && 'iridescenceMap') ||
1903
+ (options.iridescenceThicknessMap !== undefined && 'iridescenceThicknessMap') ||
1904
+ (options.anisotropyMap !== undefined && 'anisotropyMap') ||
1905
+ '';
1906
+ if (clash)
1907
+ throw new EngineError('E1217', `${call}() got ${clash} with the maps of a clear coat or a sheen, which take the same slots. Give a material either the coat's and the sheen's maps, or iridescence's and the anisotropy's, and keep the other layers' values alone.`);
1908
+ }
1909
+ }
1910
+ /** True when a standard material's bump map draws: no normal map or wireframe takes its place. */
1911
+ const bumps = (options) => !!options.bumpMap && !options.normalMap && !options.wireframe;
1912
+ /** The core's feature bits of `options`. */
1913
+ function featureBits(options) {
1914
+ return ((options.doubleSided ? MATERIAL_FEATURE_DOUBLE_SIDED : 0) |
1915
+ (options.vertexColors ? MATERIAL_FEATURE_VERTEX_COLORS : 0) |
1916
+ (options.flatShading ? MATERIAL_FEATURE_FLAT_SHADING : 0) |
1917
+ ALPHA_MODES[options.alphaMode ?? 'opaque'] |
1918
+ BLENDINGS[options.blending ?? 'normal'] |
1919
+ (options.depthWrite === false ? MATERIAL_FEATURE_NO_DEPTH_WRITE : 0) |
1920
+ (options.depthTest === false ? MATERIAL_FEATURE_NO_DEPTH_TEST : 0) |
1921
+ (options.colorWrite === false ? MATERIAL_FEATURE_NO_COLOR_WRITE : 0) |
1922
+ (options.fog === false ? MATERIAL_FEATURE_NO_FOG : 0) |
1923
+ (options.toneMapped === false ? MATERIAL_FEATURE_NO_TONE_MAP : 0) |
1924
+ (options.contactShadows === false ? MATERIAL_FEATURE_NO_CONTACT_SHADOWS : 0) |
1925
+ (options.alphaMode === 'mask' && options.alphaToCoverage !== false
1926
+ ? MATERIAL_FEATURE_ALPHA_TO_COVERAGE
1927
+ : 0) |
1928
+ (options.forceSinglePass ? MATERIAL_FEATURE_SINGLE_PASS : 0) |
1929
+ (options.transmission !== undefined ? MATERIAL_FEATURE_TRANSMISSION : 0) |
1930
+ (options.diffuseTransmission !== undefined ? MATERIAL_FEATURE_TRANSLUCENCY : 0) |
1931
+ (options.subsurfaceRadius !== undefined ? MATERIAL_FEATURE_SUBSURFACE : 0) |
1932
+ (hasLayers(options) ? MATERIAL_FEATURE_COAT_SHEEN : 0) |
1933
+ (takesIridescence(options) ? MATERIAL_FEATURE_IRIDESCENCE : 0) |
1934
+ (takesAnisotropy(options) ? MATERIAL_FEATURE_ANISOTROPY : 0) |
1935
+ (options.wireframe ? MATERIAL_FEATURE_WIREFRAME : 0) |
1936
+ (options.parallax ? MATERIAL_FEATURE_PARALLAX : 0) |
1937
+ (options.lightMapDecode === 'rgbm' ? MATERIAL_FEATURE_LIGHT_MAP_RGBM : 0));
1938
+ }
1939
+ /** The scene inputs that a material or a feature may declare. */
1940
+ const SCENE_INPUTS = [
1941
+ 'sceneColor',
1942
+ 'sceneDepth',
1943
+ 'normals',
1944
+ 'motionVectors',
1945
+ ];
1946
+ /**
1947
+ * The most textures a material that reads the scene's depth takes: the 6 that the shader compiler
1948
+ * gives every custom material. Its maps' group leaves the last slot free in any case, so the frame
1949
+ * group's eight sampled textures, the maps' and the copy stay within the sixteen that WebGPU's
1950
+ * fragment stage allows.
1951
+ */
1952
+ const MAX_SCENE_DEPTH_TEXTURES = 6;
1953
+ /**
1954
+ * Checks the scene inputs that a custom material declares against the ones its WGSL reads. Today
1955
+ * the engine binds the copy of the opaque scene's depth alone; a feature declares the other scene
1956
+ * resources in its reads, which the render graph orders.
1957
+ */
1958
+ function checkSceneInputs(declared, sceneDepth, textures, call) {
1959
+ const seen = new Set();
1960
+ for (const input of declared) {
1961
+ if (!SCENE_INPUTS.includes(input))
1962
+ throw new EngineError('E1217', `${call}() got the scene input ${JSON.stringify(input)}; it takes 'sceneColor', 'sceneDepth', 'normals' or 'motionVectors'.`);
1963
+ if (seen.has(input))
1964
+ throw new EngineError('E1217', `${call}() got the scene input '${input}' twice in sceneInputs; give each one once.`);
1965
+ seen.add(input);
1966
+ if (input !== 'sceneDepth')
1967
+ throw new EngineError('E1217', `${call}() got the scene input '${input}', which custom materials do not read yet. Read the scene's depth with 'sceneDepth', or declare '${input}' in a feature's reads.`);
1968
+ }
1969
+ const wantsDepth = seen.has('sceneDepth');
1970
+ if (wantsDepth && !sceneDepth)
1971
+ throw new EngineError('E1217', `${call}() got the scene input 'sceneDepth', but its WGSL never calls sceneDepth or sceneDistance. Read it in fn surface, such as let behind = sceneDistance(uv).`);
1972
+ if (sceneDepth && !wantsDepth)
1973
+ throw new EngineError('E1217', `${call}() got WGSL that reads the scene's depth, but sceneInputs does not declare it. Add sceneInputs: ['sceneDepth'].`);
1974
+ if (sceneDepth && textures > MAX_SCENE_DEPTH_TEXTURES)
1975
+ throw new EngineError('E1217', `${call}() got WGSL that reads the scene's depth and declares ${textures} textures. A material that reads the depth takes at most ${MAX_SCENE_DEPTH_TEXTURES}, as every custom material does. Drop ${textures - MAX_SCENE_DEPTH_TEXTURES} of the textures, or read the depth another way.`);
1976
+ }
1977
+ /** The numbers each type of uniform takes. */
1978
+ const UNIFORM_FLOATS = {
1979
+ f32: 1,
1980
+ i32: 1,
1981
+ u32: 1,
1982
+ vec2f: 2,
1983
+ vec3f: 3,
1984
+ vec4f: 4,
1985
+ };
1986
+ /** The values that `set` changes on every standard material, which no uniform may be named. */
1987
+ const STANDARD_VALUES = new Set([
1988
+ 'color',
1989
+ 'emissive',
1990
+ 'specularColor',
1991
+ 'ior',
1992
+ 'attenuationColor',
1993
+ 'attenuationDistance',
1994
+ 'diffuseTransmissionColor',
1995
+ 'subsurfaceColor',
1996
+ 'sheenColor',
1997
+ 'clearcoatNormalScale',
1998
+ 'bumpScale',
1999
+ 'displacementScale',
2000
+ 'displacementBias',
2001
+ ...RANGED.map(([key]) => key),
2002
+ ]);
2003
+ /**
2004
+ * True for a plain number that a uniform of `type` takes on its own: any finite number for a float
2005
+ * type, a whole one for an integer type. A type that holds several numbers takes an array, or a
2006
+ * `vec3f` a color, so a single number is not enough for it.
2007
+ */
2008
+ function numberFits(type, value) {
2009
+ return UNIFORM_FLOATS[type] === 1 && (type === 'f32' || Number.isInteger(value));
2010
+ }
2011
+ /**
2012
+ * Throws E1216 for a value of another kind than `uniform` takes: a number, a whole number for an
2013
+ * integer, or an array of as many numbers as the type holds. A `vec3f` takes an sRGB color too,
2014
+ * which converts to linear. It allocates nothing.
2015
+ */
2016
+ function checkUniform(uniform, value, call) {
2017
+ const { type } = uniform;
2018
+ if (type === 'vec3f' && !Array.isArray(value)) {
2019
+ writeLinearColor(UNIFORM_COLOR, value, call);
2020
+ return;
2021
+ }
2022
+ const count = UNIFORM_FLOATS[type];
2023
+ if (typeof value === 'number') {
2024
+ if (Number.isFinite(value) && numberFits(type, value))
2025
+ return;
2026
+ }
2027
+ else if (Array.isArray(value)) {
2028
+ let fits = value.length === count;
2029
+ for (let k = 0; fits && k < count; k++) {
2030
+ const number = value[k];
2031
+ fits = typeof number === 'number' && Number.isFinite(number);
2032
+ }
2033
+ if (fits && (type === 'f32' || type.startsWith('vec') || Number.isInteger(value[0])))
2034
+ return;
2035
+ }
2036
+ const takes = count === 1
2037
+ ? type === 'f32'
2038
+ ? 'a number'
2039
+ : 'a whole number'
2040
+ : `an array of ${count} numbers${count === 3 ? ', or a color' : ''}`;
2041
+ throw new EngineError('E1216', `${call}() got ${JSON.stringify(value)} for the ${type} uniform ${uniform.name}; it takes ${takes}.`);
2042
+ }
2043
+ /** True for a standard value that `set` writes itself, which the uniform writes skip. */
2044
+ function isStandard(name, call) {
2045
+ return STANDARD_VALUES.has(name) && call.endsWith('.set');
2046
+ }
2047
+ /**
2048
+ * Checks each uniform of `values`, so a caller can check every value before it writes any. `set`
2049
+ * calls skip the standard values, which `set` writes itself. Throws E1216 for a name that is not
2050
+ * a uniform, and for a value of another kind.
2051
+ */
2052
+ function checkUniforms(uniforms, values, call) {
2053
+ for (const name in values) {
2054
+ if (isStandard(name, call))
2055
+ continue;
2056
+ const value = values[name];
2057
+ if (value === undefined)
2058
+ continue;
2059
+ const uniform = uniforms.get(name);
2060
+ if (!uniform) {
2061
+ const names = [...uniforms.keys()].join(', ') || 'none';
2062
+ throw new EngineError('E1216', `${call}() got ${name}, which is not a uniform of the material's WGSL. Its uniforms: ${names}.`);
2063
+ }
2064
+ checkUniform(uniform, value, call);
2065
+ }
2066
+ }
2067
+ /**
2068
+ * Writes the uniforms of `values`, which `checkUniforms` checked, into material `id`'s row of
2069
+ * custom values, through the core's call values. It allocates nothing: a color converts into the
2070
+ * call values too.
2071
+ */
2072
+ /**
2073
+ * Writes one uniform into material `id`'s row of custom values, through the core's call values,
2074
+ * which `checkUniform` checked. It allocates nothing: a color converts into the call values too.
2075
+ */
2076
+ function writeUniform(core, id, uniform, value, call) {
2077
+ const numbers = core.callValues();
2078
+ const count = UNIFORM_FLOATS[uniform.type];
2079
+ if (typeof value === 'number')
2080
+ numbers[0] = value;
2081
+ else if (Array.isArray(value))
2082
+ for (let k = 0; k < count; k++)
2083
+ numbers[k] = value[k];
2084
+ else
2085
+ writeLinearColor(numbers, value, call);
2086
+ core.check(core.glue.setMaterialValues(id, uniform.offset, count), call, undefined, true);
2087
+ }
2088
+ function writeUniforms(core, id, uniforms, values, call) {
2089
+ const numbers = core.callValues();
2090
+ for (const name in values) {
2091
+ if (isStandard(name, call))
2092
+ continue;
2093
+ const value = values[name];
2094
+ if (value === undefined)
2095
+ continue;
2096
+ const uniform = uniforms.get(name);
2097
+ const count = UNIFORM_FLOATS[uniform.type];
2098
+ if (typeof value === 'number')
2099
+ numbers[0] = value;
2100
+ else if (Array.isArray(value))
2101
+ for (let k = 0; k < count; k++)
2102
+ numbers[k] = value[k];
2103
+ else
2104
+ writeLinearColor(numbers, value, call);
2105
+ core.check(core.glue.setMaterialValues(id, uniform.offset, count), call, undefined, true);
2106
+ }
2107
+ }
2108
+ /**
2109
+ * The texture of each slot that a custom material's or effect's WGSL declares, from its `textures`
2110
+ * option, with none where the option gives none. A slot that the WGSL declares as
2111
+ * `texture_2d_array<f32>` takes a texture of one or more layers, whose layers the WGSL picks; a
2112
+ * slot that it declares as `texture_2d<f32>` takes a texture of one layer. Throws E1216 for a name
2113
+ * that the WGSL does not declare, and for a value that is not a texture of the layers that the
2114
+ * slot takes.
2115
+ */
2116
+ export function textureSlots(declared, given, call) {
2117
+ const slots = declared.map(() => undefined);
2118
+ for (const name in given) {
2119
+ const value = given[name];
2120
+ if (value === undefined)
2121
+ continue;
2122
+ const slot = declared.findIndex((texture) => texture.name === name);
2123
+ if (slot < 0) {
2124
+ const names = declared.map((texture) => texture.name).join(', ') || 'none';
2125
+ throw new EngineError('E1216', `${call}() got the texture ${name}, which the WGSL does not declare. Its textures: ${names}.`);
2126
+ }
2127
+ const array = declared[slot]?.array === true;
2128
+ if (!(value instanceof Texture))
2129
+ throw new EngineError('E1216', array
2130
+ ? `${call}() got ${String(value)} for the texture array ${name}; it takes a texture of several layers, from textures or assets.`
2131
+ : `${call}() got ${String(value)} for the texture ${name}; it takes a texture of one layer, from textures or assets.`);
2132
+ if (!array && value.depth !== 1)
2133
+ throw new EngineError('E1216', `${call}() got a texture of ${value.depth} layers for the texture ${name}; a texture declared \`var ${name}: texture_2d<f32>;\` takes one layer. Declare \`var ${name}: texture_2d_array<f32>;\`, and pick the layer in the shader.`);
2134
+ slots[slot] = value;
2135
+ }
2136
+ return slots;
2137
+ }
2138
+ /**
2139
+ * A material: how the surfaces of the objects that use it look. `Values` are the options that
2140
+ * `set` changes.
2141
+ *
2142
+ * @category api/materials
2143
+ */
2144
+ export class Material {
2145
+ core;
2146
+ call;
2147
+ shading;
2148
+ /** The engine core's id, or 0 once the material is destroyed. */
2149
+ liveId;
2150
+ /** The name that errors from `setUniform` give the call, made once. */
2151
+ oneCall;
2152
+ /**
2153
+ * @internal How far the material's displacement moves vertices at most, in the mesh's units,
2154
+ * which grows the bounds of objects with it: the farthest it has moved them, or 0.
2155
+ */
2156
+ boundsMargin = 0;
2157
+ /**
2158
+ * @internal True when the material moves the mesh's vertices in its shader, by a displacement
2159
+ * map or a custom `vertexOffset`: the shape that a mesh's levels would simplify is not the one
2160
+ * that draws, so a mesh that it draws takes no automatic levels.
2161
+ */
2162
+ shapesVertices = false;
2163
+ /**
2164
+ * @internal True when the material draws a mesh's base level at every distance, as a surface
2165
+ * that blends or lets light through does: a mesh that only such materials draw gains nothing
2166
+ * from automatic levels.
2167
+ */
2168
+ wholeOnly = false;
2169
+ /**
2170
+ * @internal True when the material draws both faces, so no copy's pieces drop by the way they
2171
+ * face: a mesh that it draws plans no facing pieces.
2172
+ */
2173
+ facesBoth = false;
2174
+ /** True when the normal map's slot holds a bump map, whose strength `bumpScale` sets. */
2175
+ bump = false;
2176
+ /** The displacement map's scale and bias, which `set` changes one at a time, where it has one. */
2177
+ displacement;
2178
+ /**
2179
+ * Where each map sits on the texture coordinates, as `set` last gave them: for every slot, the
2180
+ * offset's two numbers, the scale's two and the rotation, so an animation can change one pair
2181
+ * of one map and keep the rest.
2182
+ */
2183
+ uv;
2184
+ /**
2185
+ * The map that fills each row slot, which alone may place it, or undefined for a material whose
2186
+ * maps a sketch never places one by one.
2187
+ */
2188
+ owners;
2189
+ /** @internal */
2190
+ constructor(id,
2191
+ /** @internal */ core,
2192
+ /** The name that errors from `set` give the call, such as 'materials.standard.set'. */
2193
+ call,
2194
+ /** @internal The engine core's shading code, which decides what the material draws. */
2195
+ shading = SHADING_LIT,
2196
+ /** @internal The map that fills each row slot: see `slotOwners`. */
2197
+ owners) {
2198
+ this.core = core;
2199
+ this.call = call;
2200
+ this.shading = shading;
2201
+ this.owners = owners;
2202
+ this.liveId = id;
2203
+ this.oneCall = setUniformCall(call);
2204
+ }
2205
+ /** @internal True until `destroy` runs. */
2206
+ get live() {
2207
+ return this.liveId !== 0;
2208
+ }
2209
+ /** @internal The editable values that the inspector shows for this material. */
2210
+ values() {
2211
+ const out = {};
2212
+ if (!DEV)
2213
+ return out;
2214
+ if (this.inspectorColorGiven)
2215
+ out.color = hexOf(this.inspectorColor);
2216
+ if (this.inspectorEmissiveGiven)
2217
+ out.emissive = hexOf(this.inspectorEmissive);
2218
+ const numbers = this.inspectorNumbers;
2219
+ if (numbers === undefined)
2220
+ return out;
2221
+ for (let k = 0; k < INSPECTOR_NUMBERS.length; k++)
2222
+ if ((this.inspectorNumbersGiven & (1 << k)) !== 0)
2223
+ out[INSPECTOR_NUMBERS[k]] = numbers[k];
2224
+ out.alphaMode = this.inspectorAlphaMode ?? 'opaque';
2225
+ out.blending = this.inspectorBlending ?? 'normal';
2226
+ return out;
2227
+ }
2228
+ /**
2229
+ * @internal Records the values that the inspector shows. Even `set` writes only into arrays and
2230
+ * fields, because a sketch may call it in every frame. A production build does nothing here.
2231
+ */
2232
+ recordInspector(options, defaults) {
2233
+ if (!DEV)
2234
+ return;
2235
+ const values = options;
2236
+ if (this.inspectorColor === undefined)
2237
+ this.inspectorColor = new Float64Array(3);
2238
+ const color = this.inspectorColor;
2239
+ if (values.color !== undefined) {
2240
+ writeLinearColor(color, values.color, 'a material');
2241
+ this.inspectorColorGiven = true;
2242
+ }
2243
+ else if (defaults) {
2244
+ color.set([1, 1, 1]);
2245
+ this.inspectorColorGiven = true;
2246
+ }
2247
+ if (this.inspectorEmissive === undefined)
2248
+ this.inspectorEmissive = new Float64Array(3);
2249
+ const emissive = this.inspectorEmissive;
2250
+ if (values.emissive !== undefined) {
2251
+ writeLinearColor(emissive, values.emissive, 'a material');
2252
+ this.inspectorEmissiveGiven = true;
2253
+ }
2254
+ else if (defaults) {
2255
+ emissive.fill(0);
2256
+ this.inspectorEmissiveGiven = true;
2257
+ }
2258
+ if (this.inspectorNumbers === undefined)
2259
+ this.inspectorNumbers = new Float64Array(INSPECTOR_NUMBERS.length);
2260
+ const numbers = this.inspectorNumbers;
2261
+ this.inspectorNumbersGiven ??= 0;
2262
+ for (let k = 0; k < INSPECTOR_NUMBERS.length; k++) {
2263
+ const value = values[INSPECTOR_NUMBERS[k]];
2264
+ if (typeof value === 'number') {
2265
+ numbers[k] = value;
2266
+ this.inspectorNumbersGiven |= 1 << k;
2267
+ }
2268
+ else if (defaults) {
2269
+ numbers[k] = INSPECTOR_DEFAULTS[k];
2270
+ this.inspectorNumbersGiven |= 1 << k;
2271
+ }
2272
+ }
2273
+ const creation = values;
2274
+ if (creation.alphaMode !== undefined)
2275
+ this.inspectorAlphaMode = creation.alphaMode;
2276
+ else if (defaults)
2277
+ this.inspectorAlphaMode = 'opaque';
2278
+ if (creation.blending !== undefined)
2279
+ this.inspectorBlending = creation.blending;
2280
+ else if (defaults)
2281
+ this.inspectorBlending = 'normal';
2282
+ }
2283
+ /** @internal The engine core's id. Throws E1101 once the material is destroyed. */
2284
+ get id() {
2285
+ if (this.liveId === 0)
2286
+ throw new EngineError('E1101', `a call used a material of ${this.call.replace(/\.set$/, '')}() after its destroy().`);
2287
+ return this.liveId;
2288
+ }
2289
+ /**
2290
+ * Changes the values that it gets and keeps the others. Every object that uses the material
2291
+ * changes with it. Set up a material with it, and with `setUniform` change the values that a
2292
+ * frame changes: a value that changes in every frame crosses the `setUniform` call itself,
2293
+ * where this call reads it from a field of the options object, and a field that holds a
2294
+ * fraction holds a copy of it of its own. Throws E1101 once the material is destroyed.
2295
+ */
2296
+ set(options) {
2297
+ const { core, call } = this;
2298
+ const values = options;
2299
+ const id = this.id;
2300
+ if (DEV)
2301
+ checkValues(values, call);
2302
+ const color = linearOrNone(values.color, call, COLOR);
2303
+ const emissive = linearOrNone(values.emissive, call, EMISSIVE);
2304
+ const specular = specularOrNone(values.specularColor, call);
2305
+ const attenuation = linearOrNone(values.attenuationColor, call, ATTENUATION);
2306
+ const through = linearOrNone(values.diffuseTransmissionColor, call, THROUGH);
2307
+ const scatter = linearOrNone(values.subsurfaceColor, call, SCATTER);
2308
+ const sheen = linearOrNone(values.sheenColor, call, SHEEN);
2309
+ // A bump map's strength takes the normal scale's place.
2310
+ const kept = this.bump && values.normalScale ? { ...values, normalScale: undefined } : values;
2311
+ // A later part write keeps the rest of each map's transform, so a value that this call sets
2312
+ // is recorded before `writeValues` writes it, in the order that it writes them.
2313
+ if (values.uvTransform !== undefined)
2314
+ this.recordUv(values.uvTransform);
2315
+ this.recordMapUv(values.mapUvTransforms);
2316
+ writeValues(core, id, call, kept, color, emissive, specular, attenuation, through, scatter, sheen);
2317
+ writeMapUvTransforms(core, id, values.mapUvTransforms, this.owners, call);
2318
+ this.writeHeights(values);
2319
+ if (DEV)
2320
+ this.recordInspector(values, false);
2321
+ }
2322
+ /**
2323
+ * @internal Sets up the height maps of a standard material that `options` creates: a bump map
2324
+ * in the normal map's slot, unless a normal map or a wireframe takes it, and a displacement map.
2325
+ * Then writes their values.
2326
+ */
2327
+ heights(options) {
2328
+ const { core, call } = this;
2329
+ const id = this.id;
2330
+ const maps = [];
2331
+ this.bump = bumps(options);
2332
+ if (this.bump)
2333
+ maps.push([options.bumpMap, MAP_SLOT_BUMP]);
2334
+ if (options.displacementMap) {
2335
+ this.displacement = [1, 0];
2336
+ this.boundsMargin = 1;
2337
+ this.shapesVertices = true;
2338
+ maps.push([options.displacementMap, MAP_SLOT_DISPLACEMENT]);
2339
+ }
2340
+ for (const [map, slot] of maps) {
2341
+ if (!map)
2342
+ continue;
2343
+ const second = map.uvSet === 1 ? 1 : 0;
2344
+ core.checkGrowth(core.glue.setMaterialMap(id, slot, map.handle, second), call, undefined, true);
2345
+ }
2346
+ this.writeHeights(options);
2347
+ }
2348
+ /** Writes the bump map's strength and the displacement's scale and bias that `values` give. */
2349
+ writeHeights(values) {
2350
+ const { core, call } = this;
2351
+ const { bumpScale, displacementScale, displacementBias } = values;
2352
+ if (this.bump && bumpScale !== undefined) {
2353
+ const numbers = core.callValues();
2354
+ numbers[0] = bumpScale;
2355
+ numbers[1] = bumpScale;
2356
+ sendValue(core, this.id, MATERIAL_PARAM_NORMAL_SCALE, call);
2357
+ }
2358
+ const held = this.displacement;
2359
+ if (held && (displacementScale !== undefined || displacementBias !== undefined)) {
2360
+ const scale = displacementScale ?? held[0];
2361
+ const bias = displacementBias ?? held[1];
2362
+ held[0] = scale;
2363
+ held[1] = bias;
2364
+ const status = core.glue.setMaterialDisplacement(this.id, scale, bias);
2365
+ core.check(status, call, undefined, true);
2366
+ this.boundsMargin = Math.max(this.boundsMargin, Math.abs(bias), Math.abs(scale + bias));
2367
+ }
2368
+ }
2369
+ /**
2370
+ * Changes one value by name, and keeps the others: a number, such as `roughness`, `opacity` or
2371
+ * `emissiveIntensity`, or a color, such as `color`, `emissive` or `sheenColor`. It allocates
2372
+ * nothing, so a sketch can change a value in every frame. Every object that uses the material
2373
+ * changes with it. Throws E1101 once the material is destroyed, and E1216 for a name that it
2374
+ * does not take: a value that takes more than one parameter, as the texture transform, the
2375
+ * normal scales, the angle fade and the index of refraction do, goes through `set`.
2376
+ */
2377
+ setUniform(name, value) {
2378
+ writeOneValue(this.core, this.id, this.oneCall, name, value);
2379
+ }
2380
+ /**
2381
+ * @internal Writes one value by name, for a property animation: a number, or a linear color as
2382
+ * three numbers. A number stays within the range that the value takes, because a cubic key can
2383
+ * overshoot. It allocates nothing, so a track writes a value in every frame.
2384
+ */
2385
+ writeUniform(name, value) {
2386
+ if (typeof value === 'number') {
2387
+ const most = ONE_VALUE_MAX.get(name) ?? Number.POSITIVE_INFINITY;
2388
+ writeOneValue(this.core, this.id, this.oneCall, name, Math.max(0, Math.min(value, most)));
2389
+ return;
2390
+ }
2391
+ writeOneValue(this.core, this.id, this.oneCall, name, value);
2392
+ }
2393
+ /**
2394
+ * @internal Changes the offset or the scale of the maps' transforms, for a property animation,
2395
+ * and keeps the rest of each transform. `slot` names one map's transform, and leaving it out
2396
+ * moves every map's together, as a sketch's own animation does. It allocates nothing, so a
2397
+ * track writes a pair in every frame.
2398
+ */
2399
+ writeUvPair(name, u, v, slot) {
2400
+ const uv = this.uvValues();
2401
+ const first = slot === undefined ? 0 : mapRowSlot(slot);
2402
+ const last = slot === undefined ? MAP_SLOT_COUNT : first + 1;
2403
+ const offset = name === 'uvOffset';
2404
+ for (let k = first; k < last; k++) {
2405
+ const at = k * UV_VALUES_LENGTH;
2406
+ if (offset) {
2407
+ uv[at] = u;
2408
+ uv[at + 1] = v;
2409
+ }
2410
+ else {
2411
+ uv[at + 2] = u;
2412
+ uv[at + 3] = v;
2413
+ }
2414
+ writeUvMatrix(this.core, this.id, k, uv[at], uv[at + 1], uv[at + 2], uv[at + 3], uv[at + 4], this.call);
2415
+ }
2416
+ }
2417
+ /** @internal Keeps where `values` puts every map on the texture coordinates. */
2418
+ recordUv(values) {
2419
+ for (let k = 0; k < MAP_SLOT_COUNT; k++)
2420
+ this.recordUvSlot(k, values);
2421
+ }
2422
+ /**
2423
+ * @internal Keeps where each of `values`' maps puts it on the texture coordinates: only the map
2424
+ * that fills a row slot places it, as a bump map gives way to a normal map.
2425
+ */
2426
+ recordMapUv(values) {
2427
+ const owners = this.owners;
2428
+ if (values === undefined || owners === undefined)
2429
+ return;
2430
+ for (let slot = 0; slot < owners.length; slot++) {
2431
+ const key = owners[slot];
2432
+ if (key === undefined)
2433
+ continue;
2434
+ const transform = values[key];
2435
+ if (transform !== undefined)
2436
+ this.recordUvSlot(slot, transform);
2437
+ }
2438
+ }
2439
+ /** Keeps one map's transform, which a value makes where the material has none. */
2440
+ recordUvSlot(slot, values) {
2441
+ const uv = this.uvValues();
2442
+ const at = slot * UV_VALUES_LENGTH;
2443
+ const { offset, repeat, rotation = 0 } = values;
2444
+ uv[at] = offset ? offset[0] : 0;
2445
+ uv[at + 1] = offset ? offset[1] : 0;
2446
+ uv[at + 2] = repeat ? repeat[0] : 1;
2447
+ uv[at + 3] = repeat ? repeat[1] : 1;
2448
+ uv[at + 4] = rotation;
2449
+ }
2450
+ /** Each map's transform, which a value makes where the material has none. */
2451
+ uvValues() {
2452
+ let uv = this.uv;
2453
+ if (uv === undefined) {
2454
+ uv = new Array(MAP_SLOT_COUNT * UV_VALUES_LENGTH);
2455
+ for (let k = 0; k < MAP_SLOT_COUNT; k++) {
2456
+ const at = k * UV_VALUES_LENGTH;
2457
+ uv[at] = 0;
2458
+ uv[at + 1] = 0;
2459
+ uv[at + 2] = 1;
2460
+ uv[at + 3] = 1;
2461
+ uv[at + 4] = 0;
2462
+ }
2463
+ this.uv = uv;
2464
+ }
2465
+ return uv;
2466
+ }
2467
+ /**
2468
+ * Destroys the material. Objects and instance batches that still use it draw nothing until
2469
+ * `setMaterial` gives them another material. Once no object uses it, its place in the engine's
2470
+ * table of materials goes to the next material. When the last material of a custom material's
2471
+ * WGSL goes, the engine frees that WGSL's pipelines. The material's textures stay, so destroy
2472
+ * them apart. Later calls on the material, and calls that pass it, throw E1101.
2473
+ */
2474
+ destroy() {
2475
+ const { core } = this;
2476
+ const call = `${this.call.replace(/\.set$/, '')}.destroy`;
2477
+ core.check(core.glue.destroyMaterial(this.id), call, undefined, true);
2478
+ this.liveId = 0;
2479
+ }
2480
+ }
2481
+ /** A custom material, whose `set` changes its uniforms too. */
2482
+ class ShaderMaterial extends Material {
2483
+ uniforms;
2484
+ constructor(id, core, call,
2485
+ /** The uniforms that the material's WGSL declares, by name. */
2486
+ uniforms, shading) {
2487
+ super(id, core, call, shading);
2488
+ this.uniforms = uniforms;
2489
+ }
2490
+ /**
2491
+ * Changes the standard values and the uniforms that it gets, and keeps the others. It checks
2492
+ * every value before it changes any. It allocates nothing, so a sketch can change a uniform in
2493
+ * every frame.
2494
+ */
2495
+ set(options) {
2496
+ const { uniforms, call } = this;
2497
+ checkUniforms(uniforms, options, call);
2498
+ super.set(options);
2499
+ writeUniforms(this.core, this.id, uniforms, options, call);
2500
+ }
2501
+ /**
2502
+ * Changes one of the material's uniforms, or one of the standard values, by name. It allocates
2503
+ * nothing, so a sketch can change a uniform in every frame. Throws E1216 for a name that is no
2504
+ * uniform of the WGSL and no standard value, and for a value of another kind than the uniform
2505
+ * takes.
2506
+ */
2507
+ setUniform(name, value) {
2508
+ const uniform = this.uniforms.get(name);
2509
+ if (uniform) {
2510
+ // A number that the uniform takes goes straight through: its check is a length test and a
2511
+ // whole-number test, and a number passed to a call that the browser does not inline becomes
2512
+ // an object of its own. Every other value goes through the check, the rejected ones too.
2513
+ if (typeof value !== 'number' || !Number.isFinite(value) || !numberFits(uniform.type, value))
2514
+ checkUniform(uniform, value, this.oneCall);
2515
+ writeUniform(this.core, this.id, uniform, value, this.oneCall);
2516
+ return;
2517
+ }
2518
+ super.setUniform(name, value);
2519
+ }
2520
+ }
2521
+ /**
2522
+ * Material factories. The standard material follows glTF's metallic-roughness model and shades
2523
+ * with Lambert diffuse light and a GGX highlight. The unlit material shows its color whatever the
2524
+ * lights. The shadow-catcher material shows only the main directional light's shadows.
2525
+ *
2526
+ * @category api/materials
2527
+ */
2528
+ export class Materials {
2529
+ core;
2530
+ templates;
2531
+ shaders;
2532
+ /** @internal */
2533
+ constructor(core,
2534
+ /** The templates of compiled WGSL, which send each custom material's shader once. */
2535
+ templates = new ShaderTemplates(),
2536
+ /** @internal Asks the thread that draws for the shader files of features early. */
2537
+ shaders = new ShaderPreloads()) {
2538
+ this.core = core;
2539
+ this.templates = templates;
2540
+ this.shaders = shaders;
2541
+ }
2542
+ /** @internal The templates of compiled WGSL, which each shader a page writes goes to once. */
2543
+ get shaderTemplates() {
2544
+ return this.templates;
2545
+ }
2546
+ /**
2547
+ * @internal Creates a material that shades as the engine core's shading code says, with the
2548
+ * features and values of `options`.
2549
+ */
2550
+ create(shading, options, call, features = 0) {
2551
+ const { id, owners, wholeOnly, facesBoth } = this.createId(shading, options, call, hasLayers(options), features);
2552
+ const material = new Material(id, this.core, `${call}.set`, shading, owners);
2553
+ material.wholeOnly = wholeOnly;
2554
+ material.facesBoth = facesBoth;
2555
+ if (DEV)
2556
+ material.recordInspector(options, true);
2557
+ if (options.uvTransform !== undefined)
2558
+ material.recordUv(options.uvTransform);
2559
+ material.recordMapUv(options.mapUvTransforms);
2560
+ if (options.bumpMap || options.displacementMap)
2561
+ material.heights(options);
2562
+ return material;
2563
+ }
2564
+ /**
2565
+ * Creates a material in the engine core, with its standard options and the feature bits
2566
+ * `extra` and its layers, and returns its id. `sway` is the distance from the camera out to
2567
+ * which a custom material's vertex offset moves, in meters, or 0 for every distance.
2568
+ * `singleLayer` draws its blended surfaces in the camera's one-sample layer.
2569
+ */
2570
+ createId(shading, options, call, layered = hasLayers(options), extra = 0, sway = 0, singleLayer = false) {
2571
+ const [r, g, b] = linearColor(options.color ?? '#ffffff', call);
2572
+ const emissive = linearOrNone(options.emissive, call, EMISSIVE);
2573
+ const specular = specularOrNone(options.specularColor, call);
2574
+ const attenuation = linearOrNone(options.attenuationColor, call, ATTENUATION);
2575
+ const through = linearOrNone(options.diffuseTransmissionColor, call, THROUGH);
2576
+ const scatter = linearOrNone(options.subsurfaceColor, call, SCATTER);
2577
+ const sheen = linearOrNone(options.sheenColor, call, SHEEN);
2578
+ if (DEV) {
2579
+ checkValues(options, call);
2580
+ checkFeatures(options, call);
2581
+ }
2582
+ const opacity = options.opacity ?? 1;
2583
+ const features = (featureBits(options) & ~MATERIAL_FEATURE_COAT_SHEEN) |
2584
+ (layered ? MATERIAL_FEATURE_COAT_SHEEN : 0) |
2585
+ extra;
2586
+ // The shaders that let light through, decals' and those of a clear coat and a sheen,
2587
+ // load on first use: the download starts with the material, before any object draws
2588
+ // with it.
2589
+ if (features & MATERIAL_FEATURE_TRANSMISSION) {
2590
+ this.shaders.need('transmission');
2591
+ // The frame copies the opaque color for the surfaces that let light through to read.
2592
+ this.shaders.need('color_copy');
2593
+ }
2594
+ else if (features & MATERIAL_FEATURE_TRANSLUCENCY)
2595
+ this.shaders.need('translucency');
2596
+ if (features & MATERIAL_FEATURE_COAT_SHEEN)
2597
+ this.shaders.need('coat_sheen');
2598
+ // An opaque object brings the passes that the device and the preset draw over the scene's
2599
+ // opaque surfaces, such as occlusion culling and the bounce light.
2600
+ if (options.alphaMode !== 'blend')
2601
+ this.shaders.needPasses();
2602
+ // So do the builds of the weighted layer.
2603
+ if (options.alphaMode === 'blend' && options.blending === 'weighted')
2604
+ this.shaders.need('weighted');
2605
+ // So do the one-sample layer's steps.
2606
+ if (singleLayer && options.alphaMode === 'blend')
2607
+ this.shaders.need('single_layer');
2608
+ if (features & MATERIAL_FEATURE_DECAL)
2609
+ this.shaders.need('decals');
2610
+ if (bumps(options))
2611
+ this.shaders.need('bump');
2612
+ if (options.displacementMap)
2613
+ this.shaders.need('displacement');
2614
+ const { constant = 0, slopeScale = 0 } = options.depthBias ?? {};
2615
+ const { core } = this;
2616
+ const id = core.checkGrowth(core.glue.createMaterial(shading, features, r, g, b, opacity, constant, slopeScale, sway, singleLayer ? 1 : 0), call);
2617
+ const values = { ...options, color: undefined, opacity: undefined };
2618
+ const colors = [undefined, emissive, specular, attenuation, through, scatter, sheen];
2619
+ writeValues(core, id, call, values, ...colors);
2620
+ // A map whose file gives it a transform of its own keeps it over the material's, as three.js
2621
+ // gives each texture its own. Only the map that fills a slot may place it.
2622
+ const owners = slotOwners(options, features, layered);
2623
+ writeMapUvTransforms(core, id, options.mapUvTransforms, owners, call);
2624
+ for (const [key, slot] of MAP_OPTIONS) {
2625
+ const map = options[key];
2626
+ // A production build leaves out a map that would take another map's slot.
2627
+ if (!map ||
2628
+ skipsMap(key, features) ||
2629
+ skipsTransmissionMap(options, key) ||
2630
+ (layered && skipsLayerMap(options, key)))
2631
+ continue;
2632
+ const second = map.uvSet === 1 ? 1 : 0;
2633
+ core.checkGrowth(core.glue.setMaterialMap(id, slot, map.handle, second), call, undefined, true);
2634
+ }
2635
+ // A direction map needs the light map whose binding reads it, and a production build leaves
2636
+ // out both where the layers take the light map's slot.
2637
+ if (options.lightMapDirection && options.lightMap && !layered) {
2638
+ core.checkGrowth(core.glue.setMaterialMap(id, MAP_SLOT_LIGHT_MAP_DIRECTION, options.lightMapDirection.handle, 0), call, undefined, true);
2639
+ }
2640
+ const { lightMapOffset, lightMapRepeat } = options;
2641
+ if (lightMapOffset || lightMapRepeat) {
2642
+ const numbers = core.callValues();
2643
+ const [repeatU, repeatV] = lightMapRepeat ?? [1, 1];
2644
+ const [offsetU, offsetV] = lightMapOffset ?? [0, 0];
2645
+ numbers[0] = repeatU;
2646
+ numbers[1] = repeatV;
2647
+ sendValue(core, id, MATERIAL_PARAM_LIGHT_MAP_SCALE, call);
2648
+ numbers[0] = offsetU;
2649
+ numbers[1] = offsetV;
2650
+ sendValue(core, id, MATERIAL_PARAM_LIGHT_MAP_OFFSET, call);
2651
+ }
2652
+ // Blended surfaces and surfaces that let light through draw their base level alone.
2653
+ const wholeOnly = (features & (MATERIAL_FEATURE_BLEND | MATERIAL_FEATURE_TRANSMISSION)) !== 0;
2654
+ const facesBoth = (features & MATERIAL_FEATURE_DOUBLE_SIDED) !== 0;
2655
+ return { id, owners, wholeOnly, facesBoth };
2656
+ }
2657
+ /**
2658
+ * A lit material with glTF's metallic-roughness model.
2659
+ */
2660
+ standard(options = {}) {
2661
+ return this.create(SHADING_LIT, options, 'materials.standard');
2662
+ }
2663
+ /**
2664
+ * A decal's material: the standard material, projected onto every opaque surface inside the
2665
+ * box of each object that it draws. Give it to a mesh of `geometry.box()`: the object's
2666
+ * position, rotation and scale place the box, and the material's maps stretch over the box's x
2667
+ * and y sides, seen along its z axis. The surfaces inside take its color, roughness, metalness,
2668
+ * normal map and emissive light, lit by the scene's lights, and blend with them as far as its
2669
+ * alpha says. A decal draws after the opaque objects, and marks no blended surface. It casts no
2670
+ * shadow.
2671
+ */
2672
+ decal(options = {}) {
2673
+ return this.create(SHADING_LIT, options, 'materials.decal', MATERIAL_FEATURE_DECAL);
2674
+ }
2675
+ /**
2676
+ * A material that ignores lights and shows its color unlit. The exposure and the tone mapping
2677
+ * still apply to it.
2678
+ */
2679
+ unlit(options = {}) {
2680
+ const shading = options.map ? SHADING_UNLIT_MAP : SHADING_UNLIT;
2681
+ return this.create(shading, options, 'materials.unlit');
2682
+ }
2683
+ /**
2684
+ * A material that draws only the shadows that fall on it: its `color` where the main
2685
+ * directional light's shadow falls, and nothing where the light reaches it, at `opacity`. The
2686
+ * mesh must receive shadows (`setReceiveShadows(true)`). Every shadow that falls on the surface
2687
+ * comes from the main directional light; point and spot lights cast none onto it. The default
2688
+ * color is black. The material blends, so it draws in the transparent pass after the opaque
2689
+ * objects, and the scene's fog leaves it alone. It takes no texture maps.
2690
+ */
2691
+ shadowCatcher(options = {}) {
2692
+ return this.create(SHADING_LIT, { ...options, color: options.color ?? '#000000', alphaMode: 'blend' }, 'materials.shadowCatcher', MATERIAL_FEATURE_SHADOW_CATCHER);
2693
+ }
2694
+ /**
2695
+ * A custom material: the standard material with a surface function in WGSL, which changes how
2696
+ * each pixel of the surface looks before the engine lights it, or a full shader of your own. It
2697
+ * takes every option of `materials.standard` but the texture maps, the first values of the
2698
+ * uniforms that its WGSL declares, and the textures that its WGSL samples, a texture of
2699
+ * several layers among them for a declaration of a texture array. `set` changes the
2700
+ * standard values and the uniforms. Meshes need texture coordinates to draw with a surface
2701
+ * function, and the attributes that a full shader reads. Throws E1215 for WGSL that the null3D
2702
+ * Vite plugin did not compile, and for a whole shader whose `@vertex` entry point takes no
2703
+ * `InstanceIn`. Throws E1216 for a uniform or a texture that the WGSL does not declare, for a
2704
+ * value of the wrong kind, and for a uniform named as a standard value, such as `color`. A
2705
+ * development build throws E1217 for the `hash` alpha mode and for `alphaToCoverage` where the
2706
+ * WGSL never sets or reads the surface's `alpha`: only WGSL that does has the builds that cut
2707
+ * the material's shape, and its shadow caster and motion build test that alpha. It also throws
2708
+ * E1217 for `transmission` where the WGSL never sets the surface's `transmission`, and for
2709
+ * `diffuseTransmission` where it never names the surface's `diffuseTransmission` or
2710
+ * `diffuseTransmissionColor`: only WGSL that does has the builds that let light through.
2711
+ * When
2712
+ * TypeScript can see the WGSL, a wrong name or a value of the wrong kind also fails the type
2713
+ * check.
2714
+ */
2715
+ shader(options) {
2716
+ const call = 'materials.shader';
2717
+ if (DEV && options.blending === 'weighted')
2718
+ throw new EngineError('E1217', `${call}() got the 'weighted' blending, which custom materials do not take. Give it the 'normal' blending, which draws back to front.`);
2719
+ const compiled = this.compiledMaterial(options.wgsl, call);
2720
+ const sceneDepth = compiled.sceneDepth === true;
2721
+ // A custom material cuts its own shape only where its WGSL sets or reads the surface's
2722
+ // alpha: only that WGSL has the builds of alpha to coverage, the alpha hash and the masked
2723
+ // shadow, and the other materials keep their builds as few as before.
2724
+ const alpha = compiled.alpha === true;
2725
+ if (DEV && !alpha && (options.alphaMode === 'hash' || options.alphaToCoverage === true))
2726
+ throw new EngineError('E1217', `${call}() got ${options.alphaMode === 'hash' ? "the alpha mode 'hash'" : 'alphaToCoverage'}, but its WGSL never sets or reads the surface's alpha, so it has no builds that cut its shape. Set the alpha in fn surface, such as s.alpha = texel.a, and keep the mask.`);
2727
+ // A caster tests the coverage under a mask, so a shader that declares coverage takes the mask
2728
+ // mode, or the blend mode with the cutoff that its caster still tests. A bare blend would
2729
+ // leave the caster no cutoff, so it stays refused.
2730
+ const coverageCaster = options.alphaMode === 'blend' && options.alphaCutoff !== undefined;
2731
+ if (DEV &&
2732
+ compiled.functions.includes('coverage') &&
2733
+ options.alphaMode !== 'mask' &&
2734
+ !coverageCaster)
2735
+ throw new EngineError('E1217', `${call}() declared fn coverage but got ${options.alphaMode === undefined ? 'no alpha mode' : `the alpha mode '${options.alphaMode}'`}; its caster tests that coverage under a mask, so give it alphaMode: 'mask' and its alphaCutoff, or the 'blend' mode with the cutoff its caster tests.`);
2736
+ if (DEV)
2737
+ checkSceneInputs(options.sceneInputs ?? [], sceneDepth, compiled.textures.length, call);
2738
+ if (DEV && options.transmission !== undefined && !lets(compiled))
2739
+ throw new EngineError('E1217', `${call}() got transmission, but its WGSL never sets the surface's transmission, so it has no builds that let light through. Set it in fn surface, such as s.transmission = 1.0.`);
2740
+ if (DEV && options.subsurfaceRadius !== undefined)
2741
+ throw new EngineError('E1217', `${call}() got subsurfaceRadius; custom materials draw no subsurface blur. Give it to materials.standard.`);
2742
+ const translucent = builds(compiled, PERMUTATION_TRANSLUCENCY);
2743
+ if (DEV && options.diffuseTransmission !== undefined && !translucent)
2744
+ throw new EngineError('E1217', `${call}() got diffuseTransmission, but its WGSL never names the surface's diffuseTransmission, so it has no builds that let light through to its other side. Set it in fn surface, such as s.diffuseTransmission = 0.5.`);
2745
+ const layered = builds(compiled, PERMUTATION_COAT_SHEEN);
2746
+ if (DEV && !layered && hasLayers(options))
2747
+ throw new EngineError('E1217', `${call}() got a clear coat, a sheen or iridescence, but its WGSL never names the surface's layers, so it has no builds that light them. Set them in fn surface, such as s.clearcoat = 1.0 or s.sheenColor = vec3f(1.0).`);
2748
+ if (DEV &&
2749
+ options.swayDistance !== undefined &&
2750
+ !(Number.isFinite(options.swayDistance) && options.swayDistance >= 0))
2751
+ throw new EngineError('E1108', `${call}() got the swayDistance ${options.swayDistance}; it takes a finite 0 or more, and leaves it out for an offset that moves at every distance.`);
2752
+ const uniforms = new Map(compiled.uniforms.map((u) => [u.name, u]));
2753
+ for (const name of uniforms.keys())
2754
+ if (STANDARD_VALUES.has(name))
2755
+ throw new EngineError('E1216', `${call}() got WGSL whose uniform ${name} has the name of a standard value. Rename the field of struct Uniforms.`);
2756
+ const uniformValues = options.uniforms ?? {};
2757
+ checkUniforms(uniforms, uniformValues, call);
2758
+ const declared = compiled.textures;
2759
+ const textures = textureSlots(declared, options.textures ?? {}, call);
2760
+ const shading = this.templateOf(compiled) |
2761
+ (compiled.attributes << SHADING_CUSTOM_ATTRIBUTE_SHIFT) |
2762
+ (compiled.baseColor ? SHADING_CUSTOM_BASE_COLOR : 0) |
2763
+ (declared.length << SHADING_CUSTOM_TEXTURE_SHIFT) |
2764
+ (lets(compiled) ? SHADING_CUSTOM_TRANSMISSION : 0) |
2765
+ (builds(compiled, PERMUTATION_ROW_VALUES) ? SHADING_CUSTOM_ROW_VALUES : 0) |
2766
+ (builds(compiled, PERMUTATION_CASTER) ? SHADING_CUSTOM_CASTER : 0) |
2767
+ (compiled.objectIds ? SHADING_CUSTOM_OBJECT_IDS : 0);
2768
+ // A production build draws such a material without the light through it, as it has no
2769
+ // builds for it.
2770
+ const diffuseTransmission = translucent ? options.diffuseTransmission : undefined;
2771
+ const { id, wholeOnly, facesBoth } = this.createId(shading, {
2772
+ ...options,
2773
+ // A production build draws such a material at its cutoff, as it has no builds of the
2774
+ // hash or of alpha to coverage.
2775
+ alphaMode: !alpha && options.alphaMode === 'hash' ? 'mask' : options.alphaMode,
2776
+ alphaToCoverage: alpha ? options.alphaToCoverage : false,
2777
+ diffuseTransmission,
2778
+ subsurfaceRadius: undefined,
2779
+ }, call, layered, (sceneDepth ? MATERIAL_FEATURE_SCENE_DEPTH : 0) |
2780
+ (builds(compiled, PERMUTATION_MOTION) ? MATERIAL_FEATURE_MOVING_VERTICES : 0) |
2781
+ (alpha || compiled.functions.includes('coverage') ? MATERIAL_FEATURE_CASTER_COVERAGE : 0) |
2782
+ (options.castsStill ? MATERIAL_FEATURE_STILL_CASTER : 0), options.swayDistance ?? 0, options.singleLayer === true);
2783
+ // The copy of the opaque depth draws with the particle depth shaders, so the file loads
2784
+ // with the material, before its first frame.
2785
+ if (sceneDepth)
2786
+ this.shaders.need('particles');
2787
+ const material = new ShaderMaterial(id, this.core, `${call}.set`, uniforms, shading);
2788
+ material.shapesVertices = compiled.functions.includes('vertexOffset');
2789
+ material.wholeOnly = wholeOnly || lets(compiled);
2790
+ material.facesBoth = facesBoth;
2791
+ if (options.uvTransform !== undefined)
2792
+ material.recordUv(options.uvTransform);
2793
+ const { core } = this;
2794
+ writeUniforms(core, id, uniforms, uniformValues, call);
2795
+ textures.forEach((texture, slot) => {
2796
+ if (!texture)
2797
+ return;
2798
+ core.checkGrowth(core.glue.setMaterialMap(id, slot, texture.handle, 0), call, undefined, true);
2799
+ });
2800
+ return material;
2801
+ }
2802
+ /**
2803
+ * A custom material's compiled WGSL, or throws E1215 for WGSL that the plugin did not compile
2804
+ * and for a whole shader.
2805
+ */
2806
+ compiledMaterial(wgsl, call) {
2807
+ if (typeof wgsl !== 'object' || wgsl?.kind !== 'material') {
2808
+ throw new EngineError('E1215', typeof wgsl === 'object' && wgsl?.kind === 'shader'
2809
+ ? `${call}() got a whole shader whose @vertex entry point takes no InstanceIn. A full shader of a custom material finds each instance with InstanceIn and find_instance from null3d::mesh.`
2810
+ : `${call}() got WGSL as ${typeof wgsl === 'string' ? 'text' : String(wgsl)}, which the null3D Vite plugin did not compile.`);
2811
+ }
2812
+ return wgsl;
2813
+ }
2814
+ /**
2815
+ * The template of a custom material's WGSL, which goes to the thread that draws once. On the
2816
+ * dev server, WGSL under one hot update key shares one template, which takes the newest WGSL.
2817
+ */
2818
+ templateOf(compiled) {
2819
+ return this.templates.of(compiled, () => [customShader(compiled)], compiled.hot, compiled.builds);
2820
+ }
2821
+ /**
2822
+ * @internal Swaps the shader of every custom material made from WGSL under the keys of hot
2823
+ * updates. The plugin sends an update only when the new WGSL keeps the material's uniforms,
2824
+ * textures and vertex inputs, so the materials keep their values.
2825
+ */
2826
+ updateShaders(updates) {
2827
+ if (!DEV)
2828
+ return;
2829
+ for (const { key, shader } of updates) {
2830
+ if (shader.kind !== 'material')
2831
+ continue;
2832
+ this.templates.update(key, [customShader(shader)]);
2833
+ }
2834
+ }
2835
+ }
2836
+ /**
2837
+ * A material that shows a mesh's first texture coordinates as colors: u in red and v in green,
2838
+ * with no color encoding. Only meshes with texture coordinates draw with it. The engine's own
2839
+ * tests use it to check vertex formats.
2840
+ */
2841
+ export function texCoordsMaterial(materials) {
2842
+ return materials.create(SHADING_TEXCOORDS, {}, 'texCoordsMaterial');
2843
+ }