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