@luma.gl/shadertools 9.0.0-beta.4 → 9.0.0-beta.6

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 (393) hide show
  1. package/dist/dist.dev.js +510 -677
  2. package/dist/index.cjs +153 -240
  3. package/dist/index.cjs.map +7 -0
  4. package/dist/index.d.ts +78 -78
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +22 -1
  7. package/dist/lib/filters/prop-types.d.ts.map +1 -1
  8. package/dist/lib/filters/prop-types.js +80 -66
  9. package/dist/lib/glsl-utils/get-shader-info.d.ts.map +1 -1
  10. package/dist/lib/glsl-utils/get-shader-info.js +26 -22
  11. package/dist/lib/glsl-utils/highlight.d.ts.map +1 -1
  12. package/dist/lib/glsl-utils/highlight.js +9 -2
  13. package/dist/lib/glsl-utils/shader-utils.d.ts +1 -2
  14. package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -1
  15. package/dist/lib/glsl-utils/shader-utils.js +67 -89
  16. package/dist/lib/shader-assembler.d.ts +4 -4
  17. package/dist/lib/shader-assembler.d.ts.map +1 -1
  18. package/dist/lib/shader-assembler.js +86 -60
  19. package/dist/lib/shader-assembly/assemble-shaders.d.ts +5 -5
  20. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  21. package/dist/lib/shader-assembly/assemble-shaders.js +333 -215
  22. package/dist/lib/shader-assembly/platform-defines.d.ts +1 -1
  23. package/dist/lib/shader-assembly/platform-defines.d.ts.map +1 -1
  24. package/dist/lib/shader-assembly/platform-defines.js +39 -31
  25. package/dist/lib/shader-assembly/platform-info.d.ts.map +1 -1
  26. package/dist/lib/shader-assembly/platform-info.js +3 -1
  27. package/dist/lib/shader-assembly/resolve-modules.d.ts +2 -2
  28. package/dist/lib/shader-assembly/resolve-modules.d.ts.map +1 -1
  29. package/dist/lib/shader-assembly/resolve-modules.js +54 -37
  30. package/dist/lib/shader-assembly/select-shaders.d.ts +2 -2
  31. package/dist/lib/shader-assembly/select-shaders.d.ts.map +1 -1
  32. package/dist/lib/shader-assembly/select-shaders.js +36 -29
  33. package/dist/lib/shader-assembly/shader-hooks.d.ts +1 -1
  34. package/dist/lib/shader-assembly/shader-hooks.d.ts.map +1 -1
  35. package/dist/lib/shader-assembly/shader-hooks.js +54 -51
  36. package/dist/lib/shader-assembly/shader-injections.d.ts.map +1 -1
  37. package/dist/lib/shader-assembly/shader-injections.js +108 -85
  38. package/dist/lib/shader-generator/generate-shader.d.ts +3 -3
  39. package/dist/lib/shader-generator/generate-shader.d.ts.map +1 -1
  40. package/dist/lib/shader-generator/generate-shader.js +10 -7
  41. package/dist/lib/shader-generator/glsl/generate-glsl.d.ts +1 -1
  42. package/dist/lib/shader-generator/glsl/generate-glsl.d.ts.map +1 -1
  43. package/dist/lib/shader-generator/glsl/generate-glsl.js +66 -57
  44. package/dist/lib/shader-generator/utils/capitalize.d.ts.map +1 -1
  45. package/dist/lib/shader-generator/utils/capitalize.js +9 -2
  46. package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts +1 -1
  47. package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts.map +1 -1
  48. package/dist/lib/shader-generator/wgsl/generate-wgsl.js +14 -11
  49. package/dist/lib/shader-module/normalize-shader-module.d.ts +1 -1
  50. package/dist/lib/shader-module/normalize-shader-module.d.ts.map +1 -1
  51. package/dist/lib/shader-module/normalize-shader-module.js +10 -8
  52. package/dist/lib/shader-module/shader-module-instance.d.ts +3 -3
  53. package/dist/lib/shader-module/shader-module-instance.d.ts.map +1 -1
  54. package/dist/lib/shader-module/shader-module-instance.js +107 -110
  55. package/dist/lib/shader-module/shader-module.d.ts +2 -2
  56. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  57. package/dist/lib/shader-module/shader-module.js +3 -1
  58. package/dist/lib/shader-module/shader-pass.d.ts +1 -1
  59. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  60. package/dist/lib/shader-module/shader-pass.js +3 -1
  61. package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts +1 -1
  62. package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts.map +1 -1
  63. package/dist/lib/shader-transpiler/transpile-glsl-shader.js +60 -53
  64. package/dist/lib/utils/assert.d.ts.map +1 -1
  65. package/dist/lib/utils/assert.js +8 -4
  66. package/dist/lib/wgsl/get-shader-layout-wgsl.d.ts.map +1 -1
  67. package/dist/lib/wgsl/get-shader-layout-wgsl.js +57 -50
  68. package/dist/libs/wgsl-reflect/wgsl_reflect.module.js +3207 -2414
  69. package/dist/module-injectors.d.ts.map +1 -1
  70. package/dist/module-injectors.js +5 -3
  71. package/dist/modules/engine/geometry/geometry.d.ts.map +1 -1
  72. package/dist/modules/engine/geometry/geometry.js +13 -6
  73. package/dist/modules/engine/picking/picking.d.ts +2 -2
  74. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  75. package/dist/modules/engine/picking/picking.js +60 -48
  76. package/dist/modules/engine/project/project.d.ts +1 -1
  77. package/dist/modules/engine/project/project.d.ts.map +1 -1
  78. package/dist/modules/engine/project/project.js +52 -34
  79. package/dist/modules/engine/transform/transform.d.ts.map +1 -1
  80. package/dist/modules/engine/transform/transform.js +7 -4
  81. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +1 -1
  82. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  83. package/dist/modules/lighting/gouraud-material/gouraud-material.js +28 -27
  84. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +42 -0
  85. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -0
  86. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +135 -0
  87. package/dist/modules/lighting/gouraud-material/gouraud-shaders.glsl.js +45 -4
  88. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +2 -0
  89. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -0
  90. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +57 -0
  91. package/dist/modules/lighting/lights/lighting-uniforms.d.ts +1 -1
  92. package/dist/modules/lighting/lights/lighting-uniforms.d.ts.map +1 -1
  93. package/dist/modules/lighting/lights/lighting-uniforms.glsl.js +4 -3
  94. package/dist/modules/lighting/lights/lighting-uniforms.js +129 -128
  95. package/dist/modules/lighting/no-material/dirlight.d.ts +1 -1
  96. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  97. package/dist/modules/lighting/no-material/dirlight.js +38 -23
  98. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +2 -0
  99. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -0
  100. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +424 -0
  101. package/dist/modules/lighting/pbr-material/pbr-fragment.glsl.d.ts.map +1 -1
  102. package/dist/modules/lighting/pbr-material/pbr-fragment.glsl.js +10 -11
  103. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +1 -1
  104. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  105. package/dist/modules/lighting/pbr-material/pbr-material.js +56 -68
  106. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +2 -0
  107. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +1 -0
  108. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +67 -0
  109. package/dist/modules/lighting/pbr-material/pbr-uniforms.glsl.js +4 -3
  110. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +2 -0
  111. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -0
  112. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +47 -0
  113. package/dist/modules/lighting/pbr-material/pbr-vertex.glsl.js +4 -3
  114. package/dist/modules/lighting/phong-material/phong-material.d.ts +1 -1
  115. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  116. package/dist/modules/lighting/phong-material/phong-material.js +28 -27
  117. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +42 -0
  118. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -0
  119. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +138 -0
  120. package/dist/modules/lighting/phong-material/phong-shaders.glsl.js +45 -4
  121. package/dist/modules/math/fp32/fp32.d.ts.map +1 -1
  122. package/dist/modules/math/fp32/fp32.js +10 -4
  123. package/dist/modules/math/random/random.d.ts.map +1 -1
  124. package/dist/modules/math/random/random.js +7 -4
  125. package/dist/modules/module-injectors.d.ts.map +1 -1
  126. package/dist/modules/module-injectors.js +5 -3
  127. package/dist/modules/postprocessing/fxaa/fxaa.d.ts +1 -1
  128. package/dist/modules/postprocessing/fxaa/fxaa.d.ts.map +1 -1
  129. package/dist/modules/postprocessing/fxaa/fxaa.js +71 -7
  130. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +1 -1
  131. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  132. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js +20 -24
  133. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts +1 -1
  134. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
  135. package/dist/modules/postprocessing/image-adjust-filters/denoise.js +20 -20
  136. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts +1 -1
  137. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  138. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js +23 -22
  139. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts +1 -1
  140. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
  141. package/dist/modules/postprocessing/image-adjust-filters/noise.js +17 -17
  142. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts +1 -1
  143. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
  144. package/dist/modules/postprocessing/image-adjust-filters/sepia.js +18 -17
  145. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts +1 -1
  146. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  147. package/dist/modules/postprocessing/image-adjust-filters/vibrance.js +11 -14
  148. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts +1 -1
  149. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
  150. package/dist/modules/postprocessing/image-adjust-filters/vignette.js +18 -22
  151. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +1 -1
  152. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  153. package/dist/modules/postprocessing/image-blur-filters/tiltshift.js +59 -43
  154. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +1 -1
  155. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  156. package/dist/modules/postprocessing/image-blur-filters/triangleblur.js +24 -30
  157. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +1 -1
  158. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  159. package/dist/modules/postprocessing/image-blur-filters/zoomblur.js +18 -20
  160. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +1 -1
  161. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  162. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js +22 -26
  163. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +1 -1
  164. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  165. package/dist/modules/postprocessing/image-fun-filters/dotscreen.js +20 -26
  166. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts +1 -1
  167. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
  168. package/dist/modules/postprocessing/image-fun-filters/edgework.js +27 -26
  169. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +1 -1
  170. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  171. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js +19 -22
  172. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts +1 -1
  173. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
  174. package/dist/modules/postprocessing/image-fun-filters/ink.js +19 -17
  175. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +1 -1
  176. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  177. package/dist/modules/postprocessing/image-fun-filters/magnify.js +24 -24
  178. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +1 -1
  179. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  180. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js +20 -26
  181. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts +1 -1
  182. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
  183. package/dist/modules/postprocessing/image-warp-filters/swirl.js +19 -26
  184. package/dist/modules/postprocessing/image-warp-filters/warp.d.ts +1 -1
  185. package/dist/modules/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
  186. package/dist/modules/postprocessing/image-warp-filters/warp.js +7 -5
  187. package/dist/modules-webgl1/geometry/geometry.js +10 -6
  188. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts +1 -1
  189. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +1 -1
  190. package/dist/modules-webgl1/lighting/dirlight/dirlight.js +20 -14
  191. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +2 -0
  192. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +1 -0
  193. package/dist/modules-webgl1/lighting/lights/lights-glsl.js +40 -0
  194. package/dist/modules-webgl1/lighting/lights/lights.d.ts +1 -1
  195. package/dist/modules-webgl1/lighting/lights/lights.d.ts.map +1 -1
  196. package/dist/modules-webgl1/lighting/lights/lights.glsl.js +2 -3
  197. package/dist/modules-webgl1/lighting/lights/lights.js +83 -86
  198. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +2 -0
  199. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +1 -0
  200. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +401 -0
  201. package/dist/modules-webgl1/lighting/pbr/pbr-fragment.glsl.d.ts.map +1 -1
  202. package/dist/modules-webgl1/lighting/pbr/pbr-fragment.glsl.js +10 -11
  203. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +2 -0
  204. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +1 -0
  205. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +43 -0
  206. package/dist/modules-webgl1/lighting/pbr/pbr-vertex.glsl.js +2 -3
  207. package/dist/modules-webgl1/lighting/pbr/pbr.d.ts.map +1 -1
  208. package/dist/modules-webgl1/lighting/pbr/pbr.js +16 -10
  209. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +2 -0
  210. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +1 -0
  211. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +79 -0
  212. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.d.ts.map +1 -1
  213. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.glsl.js +2 -3
  214. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js +33 -41
  215. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +2 -0
  216. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -0
  217. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +171 -0
  218. package/dist/modules-webgl1/math/fp64/fp64-arithmetic.glsl.js +3 -3
  219. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +2 -0
  220. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +1 -0
  221. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +675 -0
  222. package/dist/modules-webgl1/math/fp64/fp64-functions.glsl.js +3 -3
  223. package/dist/modules-webgl1/math/fp64/fp64-utils.d.ts.map +1 -1
  224. package/dist/modules-webgl1/math/fp64/fp64-utils.js +35 -17
  225. package/dist/modules-webgl1/math/fp64/fp64.d.ts +3 -3
  226. package/dist/modules-webgl1/math/fp64/fp64.d.ts.map +1 -1
  227. package/dist/modules-webgl1/math/fp64/fp64.js +27 -17
  228. package/dist/modules-webgl1/project/project.d.ts +1 -1
  229. package/dist/modules-webgl1/project/project.d.ts.map +1 -1
  230. package/dist/modules-webgl1/project/project.js +37 -30
  231. package/dist/types.d.ts.map +1 -1
  232. package/dist/types.js +4 -2
  233. package/dist.min.js +1985 -4992
  234. package/package.json +8 -6
  235. package/src/index.ts +4 -2
  236. package/src/lib/filters/prop-types.ts +33 -27
  237. package/src/lib/glsl-utils/get-shader-info.ts +2 -1
  238. package/src/lib/glsl-utils/highlight.ts +2 -1
  239. package/src/lib/glsl-utils/shader-utils.ts +15 -29
  240. package/src/lib/shader-assembler.ts +24 -15
  241. package/src/lib/shader-assembly/assemble-shaders.ts +32 -13
  242. package/src/lib/shader-assembly/platform-defines.ts +2 -1
  243. package/src/lib/shader-assembly/platform-info.ts +4 -3
  244. package/src/lib/shader-assembly/resolve-modules.ts +10 -7
  245. package/src/lib/shader-assembly/select-shaders.ts +9 -8
  246. package/src/lib/shader-assembly/shader-hooks.ts +4 -3
  247. package/src/lib/shader-assembly/shader-injections.ts +15 -10
  248. package/src/lib/shader-generator/generate-shader.ts +6 -2
  249. package/src/lib/shader-generator/glsl/generate-glsl.ts +15 -13
  250. package/src/lib/shader-generator/utils/capitalize.ts +2 -1
  251. package/src/lib/shader-generator/wgsl/generate-wgsl.ts +6 -2
  252. package/src/lib/shader-module/normalize-shader-module.ts +2 -1
  253. package/src/lib/shader-module/shader-module-instance.ts +9 -4
  254. package/src/lib/shader-module/shader-module.ts +10 -7
  255. package/src/lib/shader-module/shader-pass.ts +8 -4
  256. package/src/lib/shader-transpiler/transpile-glsl-shader.ts +12 -83
  257. package/src/lib/utils/assert.ts +2 -1
  258. package/src/lib/wgsl/get-shader-layout-wgsl.ts +3 -3
  259. package/src/module-injectors.ts +2 -1
  260. package/src/modules/engine/geometry/geometry.ts +2 -1
  261. package/src/modules/engine/picking/picking.ts +13 -12
  262. package/src/modules/engine/project/project.ts +6 -2
  263. package/src/modules/engine/transform/transform.ts +2 -1
  264. package/src/modules/lighting/gouraud-material/gouraud-material.ts +10 -9
  265. package/src/modules/lighting/gouraud-material/{gouraud-shaders.glsl.ts → gouraud-shaders-glsl.ts} +2 -1
  266. package/src/modules/lighting/lights/{lighting-uniforms.glsl.ts → lighting-uniforms-glsl.ts} +2 -1
  267. package/src/modules/lighting/lights/lighting-uniforms.ts +18 -12
  268. package/src/modules/lighting/no-material/dirlight.ts +6 -5
  269. package/src/modules/lighting/pbr-material/{pbr-fragment.glsl.ts → pbr-fragment-glsl.ts} +9 -14
  270. package/src/modules/lighting/pbr-material/pbr-material.ts +18 -16
  271. package/src/modules/lighting/pbr-material/{pbr-uniforms.glsl.ts → pbr-uniforms-glsl.ts} +2 -1
  272. package/src/modules/lighting/pbr-material/{pbr-vertex.glsl.ts → pbr-vertex-glsl.ts} +2 -1
  273. package/src/modules/lighting/phong-material/phong-material.ts +3 -2
  274. package/src/modules/lighting/phong-material/{phong-shaders.glsl.ts → phong-shaders-glsl.ts} +2 -1
  275. package/src/modules/math/fp32/fp32.ts +2 -1
  276. package/src/modules/math/random/random.ts +2 -1
  277. package/src/modules/module-injectors.ts +2 -1
  278. package/src/modules/postprocessing/fxaa/fxaa.ts +2 -1
  279. package/src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts +2 -1
  280. package/src/modules/postprocessing/image-adjust-filters/denoise.ts +4 -3
  281. package/src/modules/postprocessing/image-adjust-filters/huesaturation.ts +5 -4
  282. package/src/modules/postprocessing/image-adjust-filters/noise.ts +2 -1
  283. package/src/modules/postprocessing/image-adjust-filters/sepia.ts +2 -1
  284. package/src/modules/postprocessing/image-adjust-filters/vibrance.ts +2 -1
  285. package/src/modules/postprocessing/image-adjust-filters/vignette.ts +2 -1
  286. package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +2 -1
  287. package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +2 -1
  288. package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +4 -3
  289. package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +2 -1
  290. package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +2 -1
  291. package/src/modules/postprocessing/image-fun-filters/edgework.ts +2 -1
  292. package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +3 -2
  293. package/src/modules/postprocessing/image-fun-filters/ink.ts +5 -4
  294. package/src/modules/postprocessing/image-fun-filters/magnify.ts +5 -4
  295. package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +2 -1
  296. package/src/modules/postprocessing/image-warp-filters/swirl.ts +2 -1
  297. package/src/modules/postprocessing/image-warp-filters/warp.ts +2 -1
  298. package/src/modules-webgl1/lighting/dirlight/dirlight.ts +6 -3
  299. package/src/modules-webgl1/lighting/lights/{lights.glsl.ts → lights-glsl.ts} +4 -0
  300. package/src/modules-webgl1/lighting/lights/lights.ts +9 -3
  301. package/src/modules-webgl1/lighting/pbr/{pbr-fragment.glsl.ts → pbr-fragment-glsl.ts} +9 -13
  302. package/src/modules-webgl1/lighting/pbr/{pbr-vertex.glsl.ts → pbr-vertex-glsl.ts} +4 -0
  303. package/src/modules-webgl1/lighting/pbr/pbr.ts +6 -2
  304. package/src/modules-webgl1/lighting/phong-lighting/{phong-lighting.glsl.ts → phong-lighting-glsl.ts} +4 -0
  305. package/src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts +10 -5
  306. package/src/modules-webgl1/math/fp64/{fp64-arithmetic.glsl.ts → fp64-arithmetic-glsl.ts} +4 -1
  307. package/src/modules-webgl1/math/fp64/{fp64-functions.glsl.ts → fp64-functions-glsl.ts} +4 -1
  308. package/src/modules-webgl1/math/fp64/fp64-utils.ts +5 -1
  309. package/src/modules-webgl1/math/fp64/fp64.ts +8 -4
  310. package/src/modules-webgl1/project/project.ts +8 -4
  311. package/src/types.ts +26 -30
  312. package/dist/index.js.map +0 -1
  313. package/dist/lib/filters/prop-types.js.map +0 -1
  314. package/dist/lib/glsl-utils/get-shader-info.js.map +0 -1
  315. package/dist/lib/glsl-utils/highlight.js.map +0 -1
  316. package/dist/lib/glsl-utils/shader-utils.js.map +0 -1
  317. package/dist/lib/shader-assembler.js.map +0 -1
  318. package/dist/lib/shader-assembly/assemble-shaders.js.map +0 -1
  319. package/dist/lib/shader-assembly/platform-defines.js.map +0 -1
  320. package/dist/lib/shader-assembly/platform-info.js.map +0 -1
  321. package/dist/lib/shader-assembly/resolve-modules.js.map +0 -1
  322. package/dist/lib/shader-assembly/select-shaders.js.map +0 -1
  323. package/dist/lib/shader-assembly/shader-hooks.js.map +0 -1
  324. package/dist/lib/shader-assembly/shader-injections.js.map +0 -1
  325. package/dist/lib/shader-generator/generate-shader.js.map +0 -1
  326. package/dist/lib/shader-generator/glsl/generate-glsl.js.map +0 -1
  327. package/dist/lib/shader-generator/utils/capitalize.js.map +0 -1
  328. package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +0 -1
  329. package/dist/lib/shader-module/normalize-shader-module.js.map +0 -1
  330. package/dist/lib/shader-module/shader-module-instance.js.map +0 -1
  331. package/dist/lib/shader-module/shader-module.js.map +0 -1
  332. package/dist/lib/shader-module/shader-pass.js.map +0 -1
  333. package/dist/lib/shader-transpiler/transpile-glsl-shader.js.map +0 -1
  334. package/dist/lib/utils/assert.js.map +0 -1
  335. package/dist/lib/wgsl/get-shader-layout-wgsl.js.map +0 -1
  336. package/dist/libs/wgsl-reflect/wgsl_reflect.module.js.map +0 -1
  337. package/dist/module-injectors.js.map +0 -1
  338. package/dist/modules/engine/geometry/geometry.js.map +0 -1
  339. package/dist/modules/engine/picking/README.md +0 -88
  340. package/dist/modules/engine/picking/picking.js.map +0 -1
  341. package/dist/modules/engine/project/project.js.map +0 -1
  342. package/dist/modules/engine/transform/transform.js.map +0 -1
  343. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +0 -1
  344. package/dist/modules/lighting/gouraud-material/gouraud-shaders.glsl.js.map +0 -1
  345. package/dist/modules/lighting/lights/lighting-uniforms.glsl.js.map +0 -1
  346. package/dist/modules/lighting/lights/lighting-uniforms.js.map +0 -1
  347. package/dist/modules/lighting/no-material/dirlight.js.map +0 -1
  348. package/dist/modules/lighting/pbr-material/pbr-fragment.glsl.js.map +0 -1
  349. package/dist/modules/lighting/pbr-material/pbr-material.js.map +0 -1
  350. package/dist/modules/lighting/pbr-material/pbr-uniforms.glsl.js.map +0 -1
  351. package/dist/modules/lighting/pbr-material/pbr-vertex.glsl.js.map +0 -1
  352. package/dist/modules/lighting/phong-material/phong-material.js.map +0 -1
  353. package/dist/modules/lighting/phong-material/phong-shaders.glsl.js.map +0 -1
  354. package/dist/modules/math/fp32/fp32.js.map +0 -1
  355. package/dist/modules/math/random/random.js.map +0 -1
  356. package/dist/modules/module-injectors.js.map +0 -1
  357. package/dist/modules/postprocessing/fxaa/fxaa.js.map +0 -1
  358. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js.map +0 -1
  359. package/dist/modules/postprocessing/image-adjust-filters/denoise.js.map +0 -1
  360. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js.map +0 -1
  361. package/dist/modules/postprocessing/image-adjust-filters/noise.js.map +0 -1
  362. package/dist/modules/postprocessing/image-adjust-filters/sepia.js.map +0 -1
  363. package/dist/modules/postprocessing/image-adjust-filters/vibrance.js.map +0 -1
  364. package/dist/modules/postprocessing/image-adjust-filters/vignette.js.map +0 -1
  365. package/dist/modules/postprocessing/image-blur-filters/tiltshift.js.map +0 -1
  366. package/dist/modules/postprocessing/image-blur-filters/triangleblur.js.map +0 -1
  367. package/dist/modules/postprocessing/image-blur-filters/zoomblur.js.map +0 -1
  368. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js.map +0 -1
  369. package/dist/modules/postprocessing/image-fun-filters/dotscreen.js.map +0 -1
  370. package/dist/modules/postprocessing/image-fun-filters/edgework.js.map +0 -1
  371. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js.map +0 -1
  372. package/dist/modules/postprocessing/image-fun-filters/ink.js.map +0 -1
  373. package/dist/modules/postprocessing/image-fun-filters/magnify.js.map +0 -1
  374. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js.map +0 -1
  375. package/dist/modules/postprocessing/image-warp-filters/swirl.js.map +0 -1
  376. package/dist/modules/postprocessing/image-warp-filters/warp.js.map +0 -1
  377. package/dist/modules-webgl1/geometry/geometry.js.map +0 -1
  378. package/dist/modules-webgl1/lighting/dirlight/dirlight.js.map +0 -1
  379. package/dist/modules-webgl1/lighting/lights/lights.glsl.js.map +0 -1
  380. package/dist/modules-webgl1/lighting/lights/lights.js.map +0 -1
  381. package/dist/modules-webgl1/lighting/pbr/README.md +0 -12
  382. package/dist/modules-webgl1/lighting/pbr/pbr-fragment.glsl.js.map +0 -1
  383. package/dist/modules-webgl1/lighting/pbr/pbr-vertex.glsl.js.map +0 -1
  384. package/dist/modules-webgl1/lighting/pbr/pbr.js.map +0 -1
  385. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.glsl.js.map +0 -1
  386. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js.map +0 -1
  387. package/dist/modules-webgl1/math/fp64/fp64-arithmetic.glsl.js.map +0 -1
  388. package/dist/modules-webgl1/math/fp64/fp64-functions.glsl.js.map +0 -1
  389. package/dist/modules-webgl1/math/fp64/fp64-utils.js.map +0 -1
  390. package/dist/modules-webgl1/math/fp64/fp64.js.map +0 -1
  391. package/dist/modules-webgl1/project/README.md +0 -52
  392. package/dist/modules-webgl1/project/project.js.map +0 -1
  393. package/dist/types.js.map +0 -1
package/dist/dist.dev.js CHANGED
@@ -10,6 +10,7 @@ var __exports__ = (() => {
10
10
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
11
  var __getOwnPropNames = Object.getOwnPropertyNames;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
14
  var __export = (target, all) => {
14
15
  for (var name in all)
15
16
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -23,6 +24,10 @@ var __exports__ = (() => {
23
24
  return to;
24
25
  };
25
26
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var __publicField = (obj, key, value) => {
28
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
29
+ return value;
30
+ };
26
31
 
27
32
  // src/index.ts
28
33
  var src_exports = {};
@@ -121,7 +126,10 @@ var __exports__ = (() => {
121
126
  for (const [key, propsValidator] of Object.entries(propValidators)) {
122
127
  if (properties && key in properties && !propsValidator.private) {
123
128
  if (propsValidator.validate) {
124
- assert(propsValidator.validate(properties[key], propsValidator), `${errorMessage}: invalid ${key}`);
129
+ assert(
130
+ propsValidator.validate(properties[key], propsValidator),
131
+ `${errorMessage}: invalid ${key}`
132
+ );
125
133
  }
126
134
  validated[key] = properties[key];
127
135
  } else {
@@ -133,38 +141,20 @@ var __exports__ = (() => {
133
141
  function makePropValidator(propType) {
134
142
  let type = getTypeOf(propType);
135
143
  if (type !== "object") {
136
- return {
137
- value: propType,
138
- ...DEFAULT_PROP_VALIDATORS[type],
139
- type
140
- };
144
+ return { value: propType, ...DEFAULT_PROP_VALIDATORS[type], type };
141
145
  }
142
146
  if (typeof propType === "object") {
143
147
  if (!propType) {
144
- return {
145
- type: "object",
146
- value: null
147
- };
148
+ return { type: "object", value: null };
148
149
  }
149
150
  if (propType.type !== void 0) {
150
- return {
151
- ...propType,
152
- ...DEFAULT_PROP_VALIDATORS[propType.type],
153
- type: propType.type
154
- };
151
+ return { ...propType, ...DEFAULT_PROP_VALIDATORS[propType.type], type: propType.type };
155
152
  }
156
153
  if (propType.value === void 0) {
157
- return {
158
- type: "object",
159
- value: propType
160
- };
154
+ return { type: "object", value: propType };
161
155
  }
162
156
  type = getTypeOf(propType.value);
163
- return {
164
- ...propType,
165
- ...DEFAULT_PROP_VALIDATORS[type],
166
- type
167
- };
157
+ return { ...propType, ...DEFAULT_PROP_VALIDATORS[type], type };
168
158
  }
169
159
  throw new Error("props");
170
160
  }
@@ -214,10 +204,7 @@ var __exports__ = (() => {
214
204
  var fragments = [];
215
205
  var DECLARATION_INJECT_MARKER = "__LUMA_INJECT_DECLARATIONS__";
216
206
  function normalizeInjections(injections) {
217
- const result = {
218
- vertex: {},
219
- fragment: {}
220
- };
207
+ const result = { vertex: {}, fragment: {} };
221
208
  for (const hook in injections) {
222
209
  let injection = injections[hook];
223
210
  const stage = getHookStage(hook);
@@ -309,6 +296,14 @@ ${inject[key]}` : inject[key];
309
296
  // src/lib/shader-module/shader-module-instance.ts
310
297
  var index = 1;
311
298
  var ShaderModuleInstance = class {
299
+ name;
300
+ vs;
301
+ fs;
302
+ getModuleUniforms;
303
+ dependencies;
304
+ deprecations;
305
+ defines;
306
+ injections;
312
307
  uniforms = {};
313
308
  uniformTypes = {};
314
309
  static instantiateModules(modules) {
@@ -316,13 +311,20 @@ ${inject[key]}` : inject[key];
316
311
  if (module instanceof ShaderModuleInstance) {
317
312
  return module;
318
313
  }
319
- assert(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`);
314
+ assert(
315
+ typeof module !== "string",
316
+ `Shader module use by name is deprecated. Import shader module '${JSON.stringify(
317
+ module
318
+ )}' and use it directly.`
319
+ );
320
320
  if (!module.name) {
321
321
  console.warn("shader module has no name");
322
322
  module.name = `shader-module-${index++}`;
323
323
  }
324
324
  const moduleObject = new ShaderModuleInstance(module);
325
- moduleObject.dependencies = ShaderModuleInstance.instantiateModules(module.dependencies || []);
325
+ moduleObject.dependencies = ShaderModuleInstance.instantiateModules(
326
+ module.dependencies || []
327
+ );
326
328
  return moduleObject;
327
329
  });
328
330
  }
@@ -351,6 +353,7 @@ ${inject[key]}` : inject[key];
351
353
  this.uniforms = makePropValidators(uniformPropTypes);
352
354
  }
353
355
  }
356
+ // Extracts the source code chunk for the specified shader type from the named shader module
354
357
  getModuleSource(stage) {
355
358
  let moduleSource;
356
359
  switch (stage) {
@@ -380,6 +383,7 @@ ${moduleSource}
380
383
  getDefines() {
381
384
  return this.defines;
382
385
  }
386
+ // Warn about deprecated uniforms or functions
383
387
  checkDeprecations(shaderSource, log) {
384
388
  this.deprecations.forEach((def) => {
385
389
  if (def.regex?.test(shaderSource)) {
@@ -429,21 +433,11 @@ ${moduleSource}
429
433
  function getShaderDependencies(modules) {
430
434
  const moduleMap = {};
431
435
  const moduleDepth = {};
432
- getDependencyGraph({
433
- modules,
434
- level: 0,
435
- moduleMap,
436
- moduleDepth
437
- });
436
+ getDependencyGraph({ modules, level: 0, moduleMap, moduleDepth });
438
437
  return Object.keys(moduleDepth).sort((a, b) => moduleDepth[b] - moduleDepth[a]).map((name) => moduleMap[name]);
439
438
  }
440
439
  function getDependencyGraph(options) {
441
- const {
442
- modules,
443
- level,
444
- moduleMap,
445
- moduleDepth
446
- } = options;
440
+ const { modules, level, moduleMap, moduleDepth } = options;
447
441
  if (level >= 5) {
448
442
  throw new Error("Possible loop in shader dependency graph");
449
443
  }
@@ -455,12 +449,7 @@ ${moduleSource}
455
449
  }
456
450
  for (const module of modules) {
457
451
  if (module.dependencies) {
458
- getDependencyGraph({
459
- modules: module.dependencies,
460
- level: level + 1,
461
- moduleMap,
462
- moduleDepth
463
- });
452
+ getDependencyGraph({ modules: module.dependencies, level: level + 1, moduleMap, moduleDepth });
464
453
  }
465
454
  }
466
455
  }
@@ -567,62 +556,47 @@ ${moduleSource}
567
556
  }
568
557
 
569
558
  // src/lib/shader-transpiler/transpile-glsl-shader.ts
570
- function transpileGLSLShader(source, targetGLSLVersion, stage) {
559
+ function transpileGLSLShader(source, stage) {
571
560
  const sourceGLSLVersion = Number(source.match(/^#version[ \t]+(\d+)/m)?.[1] || 100);
572
561
  if (sourceGLSLVersion !== 300) {
573
562
  throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");
574
563
  }
575
- switch (targetGLSLVersion) {
576
- case 300:
577
- switch (stage) {
578
- case "vertex":
579
- source = convertShader(source, ES300_VERTEX_REPLACEMENTS);
580
- return source;
581
- case "fragment":
582
- source = convertShader(source, ES300_FRAGMENT_REPLACEMENTS);
583
- return source;
584
- default:
585
- throw new Error(stage);
586
- }
587
- case 100:
588
- switch (stage) {
589
- case "vertex":
590
- source = convertShader(source, ES100_VERTEX_REPLACEMENTS);
591
- return source;
592
- case "fragment":
593
- source = convertShader(source, ES100_FRAGMENT_REPLACEMENTS);
594
- source = convertFragmentShaderTo100(source);
595
- return source;
596
- default:
597
- throw new Error(stage);
598
- }
564
+ switch (stage) {
565
+ case "vertex":
566
+ source = convertShader(source, ES300_VERTEX_REPLACEMENTS);
567
+ return source;
568
+ case "fragment":
569
+ source = convertShader(source, ES300_FRAGMENT_REPLACEMENTS);
570
+ return source;
599
571
  default:
600
- throw new Error(String(targetGLSLVersion));
601
- }
602
- }
603
- var ES300_REPLACEMENTS = [[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/, "#version 300 es\n"], [/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g, "textureLod("], [/\btexture(2D|2DProj|Cube)(EXT)?\(/g, "texture("]];
604
- var ES300_VERTEX_REPLACEMENTS = [...ES300_REPLACEMENTS, [makeVariableTextRegExp("attribute"), "in $1"], [makeVariableTextRegExp("varying"), "out $1"]];
605
- var ES300_FRAGMENT_REPLACEMENTS = [...ES300_REPLACEMENTS, [makeVariableTextRegExp("varying"), "in $1"]];
606
- var ES100_REPLACEMENTS = [[/^#version[ \t]+300[ \t]+es/, "#version 100"], [/\btexture(2D|2DProj|Cube)Lod\(/g, "texture$1LodEXT("], [/\btexture\(/g, "texture2D("], [/\btextureLod\(/g, "texture2DLodEXT("]];
607
- var ES100_VERTEX_REPLACEMENTS = [...ES100_REPLACEMENTS, [makeVariableTextRegExp("in"), "attribute $1"], [makeVariableTextRegExp("out"), "varying $1"]];
608
- var ES100_FRAGMENT_REPLACEMENTS = [...ES100_REPLACEMENTS, [makeVariableTextRegExp("in"), "varying $1"]];
609
- var ES100_FRAGMENT_OUTPUT_NAME = "gl_FragColor";
610
- var ES300_FRAGMENT_OUTPUT_REGEX = /\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/;
572
+ throw new Error(stage);
573
+ }
574
+ }
575
+ var ES300_REPLACEMENTS = [
576
+ // Fix poorly formatted version directive
577
+ [/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/, "#version 300 es\n"],
578
+ // The individual `texture...()` functions were replaced with `texture()` overloads
579
+ [/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g, "textureLod("],
580
+ [/\btexture(2D|2DProj|Cube)(EXT)?\(/g, "texture("]
581
+ ];
582
+ var ES300_VERTEX_REPLACEMENTS = [
583
+ ...ES300_REPLACEMENTS,
584
+ // `attribute` keyword replaced with `in`
585
+ [makeVariableTextRegExp("attribute"), "in $1"],
586
+ // `varying` keyword replaced with `out`
587
+ [makeVariableTextRegExp("varying"), "out $1"]
588
+ ];
589
+ var ES300_FRAGMENT_REPLACEMENTS = [
590
+ ...ES300_REPLACEMENTS,
591
+ // `varying` keyword replaced with `in`
592
+ [makeVariableTextRegExp("varying"), "in $1"]
593
+ ];
611
594
  function convertShader(source, replacements) {
612
595
  for (const [pattern, replacement] of replacements) {
613
596
  source = source.replace(pattern, replacement);
614
597
  }
615
598
  return source;
616
599
  }
617
- function convertFragmentShaderTo100(source) {
618
- source = convertShader(source, ES100_FRAGMENT_REPLACEMENTS);
619
- const outputMatch = ES300_FRAGMENT_OUTPUT_REGEX.exec(source);
620
- if (outputMatch) {
621
- const outputName = outputMatch[1];
622
- source = source.replace(ES300_FRAGMENT_OUTPUT_REGEX, "").replace(new RegExp(`\\b${outputName}\\b`, "g"), ES100_FRAGMENT_OUTPUT_NAME);
623
- }
624
- return source;
625
- }
626
600
  function makeVariableTextRegExp(qualifier) {
627
601
  return new RegExp(`\\b${qualifier}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`, "g");
628
602
  }
@@ -653,10 +627,7 @@ ${moduleSource}
653
627
  return result;
654
628
  }
655
629
  function normalizeShaderHooks(hookFunctions) {
656
- const result = {
657
- vertex: {},
658
- fragment: {}
659
- };
630
+ const result = { vertex: {}, fragment: {} };
660
631
  for (const hookFunction of hookFunctions) {
661
632
  let opts;
662
633
  let hook;
@@ -670,9 +641,7 @@ ${moduleSource}
670
641
  hook = hook.trim();
671
642
  const [shaderStage, signature] = hook.split(":");
672
643
  const name = hook.replace(/\(.+/, "");
673
- const normalizedHook = Object.assign(opts, {
674
- signature
675
- });
644
+ const normalizedHook = Object.assign(opts, { signature });
676
645
  switch (shaderStage) {
677
646
  case "vs":
678
647
  result.vertex[name] = normalizedHook;
@@ -724,10 +693,7 @@ ${DECLARATION_INJECT_MARKER}
724
693
  precision highp float;
725
694
  `;
726
695
  function assembleShaders(options) {
727
- const {
728
- vs: vs6,
729
- fs: fs28
730
- } = options;
696
+ const { vs: vs6, fs: fs28 } = options;
731
697
  const modules = resolveModules(options.modules || []);
732
698
  switch (options.platformInfo.shaderLanguage) {
733
699
  case "glsl":
@@ -766,9 +732,11 @@ precision highp float;
766
732
  }
767
733
  function assembleWGSLShader(platformInfo, options) {
768
734
  const {
735
+ // id,
769
736
  source,
770
737
  stage,
771
738
  modules,
739
+ // defines = {},
772
740
  hookFunctions = [],
773
741
  inject = {},
774
742
  log
@@ -781,10 +749,7 @@ precision highp float;
781
749
  const declInjections = {};
782
750
  const mainInjections = {};
783
751
  for (const key in inject) {
784
- const injection = typeof inject[key] === "string" ? {
785
- injection: inject[key],
786
- order: 0
787
- } : inject[key];
752
+ const injection = typeof inject[key] === "string" ? { injection: inject[key], order: 0 } : inject[key];
788
753
  const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
789
754
  if (match) {
790
755
  const hash = match[2];
@@ -862,11 +827,7 @@ precision highp float;
862
827
  assembledSource = prologue ? `${sourceVersionDirective}
863
828
 
864
829
  // ----- PROLOGUE -------------------------
865
- ${getShaderNameDefine({
866
- id,
867
- source,
868
- stage
869
- })}
830
+ ${getShaderNameDefine({ id, source, stage })}
870
831
  ${`#define SHADER_TYPE_${stage.toUpperCase()}`}
871
832
  ${getPlatformShaderDefines(platformInfo)}
872
833
  ${getVersionDefines(platformInfo)}
@@ -885,10 +846,7 @@ ${getApplicationDefines(allDefines)}
885
846
  const declInjections = {};
886
847
  const mainInjections = {};
887
848
  for (const key in inject) {
888
- const injection = typeof inject[key] === "string" ? {
889
- injection: inject[key],
890
- order: 0
891
- } : inject[key];
849
+ const injection = typeof inject[key] === "string" ? { injection: inject[key], order: 0 } : inject[key];
892
850
  const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
893
851
  if (match) {
894
852
  const hash = match[2];
@@ -933,7 +891,7 @@ ${getApplicationDefines(allDefines)}
933
891
  assembledSource += coreSource;
934
892
  assembledSource = injectShader(assembledSource, stage, mainInjections);
935
893
  if (language === "glsl" && sourceVersion !== targetVersion) {
936
- assembledSource = transpileGLSLShader(assembledSource, targetVersion, stage);
894
+ assembledSource = transpileGLSLShader(assembledSource, stage);
937
895
  }
938
896
  return assembledSource.trim();
939
897
  }
@@ -948,11 +906,7 @@ ${getApplicationDefines(allDefines)}
948
906
  };
949
907
  }
950
908
  function getShaderNameDefine(options) {
951
- const {
952
- id,
953
- source,
954
- stage
955
- } = options;
909
+ const { id, source, stage } = options;
956
910
  const injectShaderName = id && source.indexOf("SHADER_NAME") === -1;
957
911
  return injectShaderName ? `
958
912
  #define SHADER_NAME ${id}_${stage}
@@ -981,11 +935,7 @@ ${getApplicationDefines(allDefines)}
981
935
  if (props.fs) {
982
936
  fs28 = getShaderSource(props.platformInfo, props.fs);
983
937
  }
984
- return {
985
- ...props,
986
- vs: vs6,
987
- fs: fs28
988
- };
938
+ return { ...props, vs: vs6, fs: fs28 };
989
939
  }
990
940
  function getShaderSource(platformInfo, shader) {
991
941
  if (typeof shader === "string") {
@@ -1006,30 +956,53 @@ ${getApplicationDefines(allDefines)}
1006
956
  }
1007
957
 
1008
958
  // src/lib/shader-assembler.ts
1009
- var ShaderAssembler = class {
959
+ var _ShaderAssembler = class {
960
+ /** Hook functions */
1010
961
  _hookFunctions = [];
962
+ /** Shader modules */
1011
963
  _defaultModules = [];
964
+ /**
965
+ * A default shader assembler instance - the natural place to register default modules and hooks
966
+ * @returns
967
+ */
1012
968
  static getDefaultShaderAssembler() {
1013
- ShaderAssembler.defaultShaderAssembler = ShaderAssembler.defaultShaderAssembler || new ShaderAssembler();
1014
- return ShaderAssembler.defaultShaderAssembler;
969
+ _ShaderAssembler.defaultShaderAssembler = _ShaderAssembler.defaultShaderAssembler || new _ShaderAssembler();
970
+ return _ShaderAssembler.defaultShaderAssembler;
1015
971
  }
972
+ /**
973
+ * Add a default module that does not have to be provided with every call to assembleShaders()
974
+ */
1016
975
  addDefaultModule(module) {
1017
- if (!this._defaultModules.find((m) => m.name === (typeof module === "string" ? module : module.name))) {
976
+ if (!this._defaultModules.find(
977
+ (m) => m.name === (typeof module === "string" ? module : module.name)
978
+ )) {
1018
979
  this._defaultModules.push(module);
1019
980
  }
1020
981
  }
982
+ /**
983
+ * Remove a default module
984
+ */
1021
985
  removeDefaultModule(module) {
1022
986
  const moduleName = typeof module === "string" ? module : module.name;
1023
987
  this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);
1024
988
  }
989
+ /**
990
+ * Register a shader hook
991
+ * @param hook
992
+ * @param opts
993
+ */
1025
994
  addShaderHook(hook, opts) {
1026
995
  if (opts) {
1027
- hook = Object.assign(opts, {
1028
- hook
1029
- });
996
+ hook = Object.assign(opts, { hook });
1030
997
  }
1031
998
  this._hookFunctions.push(hook);
1032
999
  }
1000
+ /**
1001
+ * Assemble a pair of shaders into a single shader program
1002
+ * @param platformInfo
1003
+ * @param props
1004
+ * @returns
1005
+ */
1033
1006
  assembleShaders(props) {
1034
1007
  const modules = this._getModuleList(props.modules);
1035
1008
  const hookFunctions = this._hookFunctions;
@@ -1040,13 +1013,15 @@ ${getApplicationDefines(allDefines)}
1040
1013
  modules,
1041
1014
  hookFunctions
1042
1015
  });
1043
- return {
1044
- ...assembled,
1045
- modules
1046
- };
1016
+ return { ...assembled, modules };
1047
1017
  }
1018
+ /**
1019
+ * Dedupe and combine with default modules
1020
+ */
1048
1021
  _getModuleList(appModules = []) {
1049
- const modules = new Array(this._defaultModules.length + appModules.length);
1022
+ const modules = new Array(
1023
+ this._defaultModules.length + appModules.length
1024
+ );
1050
1025
  const seen = {};
1051
1026
  let count = 0;
1052
1027
  for (let i = 0, len = this._defaultModules.length; i < len; ++i) {
@@ -1067,6 +1042,9 @@ ${getApplicationDefines(allDefines)}
1067
1042
  return ShaderModuleInstance.instantiateModules(modules);
1068
1043
  }
1069
1044
  };
1045
+ var ShaderAssembler = _ShaderAssembler;
1046
+ /** Default ShaderAssembler instance */
1047
+ __publicField(ShaderAssembler, "defaultShaderAssembler");
1070
1048
 
1071
1049
  // src/lib/shader-module/normalize-shader-module.ts
1072
1050
  function normalizeShaderModule(module) {
@@ -1081,7 +1059,6 @@ ${getApplicationDefines(allDefines)}
1081
1059
  }
1082
1060
 
1083
1061
  // src/lib/glsl-utils/shader-utils.ts
1084
- var FS100 = glsl`void main() {gl_FragColor = vec4(0);}`;
1085
1062
  var FS_GLES = glsl`\
1086
1063
  out vec4 transform_output;
1087
1064
  void main() {
@@ -1097,44 +1074,23 @@ ${FS_GLES}`;
1097
1074
  return null;
1098
1075
  }
1099
1076
  const name = definition.split(";")[0];
1100
- return {
1101
- qualifier,
1102
- type,
1103
- name
1104
- };
1077
+ return { qualifier, type, name };
1105
1078
  }
1106
1079
  function getPassthroughFS(options) {
1107
- const {
1108
- version = 100,
1109
- input,
1110
- inputChannels,
1111
- output
1112
- } = options || {};
1080
+ const { input, inputChannels, output } = options || {};
1113
1081
  if (!input) {
1114
- if (version === 300) {
1115
- return FS300;
1116
- } else if (version > 300) {
1117
- return `#version ${version}
1118
- ${FS_GLES}`;
1119
- }
1120
- return FS100;
1082
+ return FS300;
1121
1083
  }
1122
1084
  if (!inputChannels) {
1123
1085
  throw new Error("inputChannels");
1124
1086
  }
1125
1087
  const inputType = channelCountToType(inputChannels);
1126
1088
  const outputValue = convertToVec4(input, inputChannels);
1127
- if (version >= 300) {
1128
- return `#version ${version} ${version === 300 ? "es" : ""}
1089
+ return `#version 300 es
1129
1090
  in ${inputType} ${input};
1130
1091
  out vec4 ${output};
1131
1092
  void main() {
1132
1093
  ${output} = ${outputValue};
1133
- }`;
1134
- }
1135
- return `varying ${inputType} ${input};
1136
- void main() {
1137
- gl_FragColor = ${outputValue};
1138
1094
  }`;
1139
1095
  }
1140
1096
  function typeToChannelSuffix(type) {
@@ -1239,9 +1195,9 @@ void main() {
1239
1195
  }
1240
1196
  function getGLSLUniformType(uniformFormat) {
1241
1197
  const UNIFORM_TYPE_TO_GLSL = {
1242
- "f32": "float",
1243
- "i32": "int",
1244
- "u32": "uint",
1198
+ f32: "float",
1199
+ i32: "int",
1200
+ u32: "uint",
1245
1201
  "vec2<f32>": "vec2",
1246
1202
  "vec3<f32>": "vec3",
1247
1203
  "vec4<f32>": "vec4",
@@ -1603,6 +1559,7 @@ void main() {
1603
1559
  get isStruct() {
1604
1560
  return true;
1605
1561
  }
1562
+ /// Return the index of the member with the given name, or -1 if not found.
1606
1563
  getMemberIndex(name) {
1607
1564
  for (let i = 0; i < this.members.length; i++) {
1608
1565
  if (this.members[i].name == name)
@@ -2153,6 +2110,12 @@ void main() {
2153
2110
  rgba32sint: new TokenType("rgba32sint", TokenClass.keyword, "rgba32sint"),
2154
2111
  rgba32float: new TokenType("rgba32float", TokenClass.keyword, "rgba32float"),
2155
2112
  static_assert: new TokenType("static_assert", TokenClass.keyword, "static_assert")
2113
+ // WGSL grammar has a few keywords that have different token names than the strings they
2114
+ // represent. Aliasing them here.
2115
+ /*int32: new TokenType("i32", TokenClass.keyword, "i32"),
2116
+ uint32: new TokenType("u32", TokenClass.keyword, "u32"),
2117
+ float32: new TokenType("f32", TokenClass.keyword, "f32"),
2118
+ pointer: new TokenType("ptr", TokenClass.keyword, "ptr"),*/
2156
2119
  };
2157
2120
  TokenTypes.tokens = {
2158
2121
  decimal_float_literal: new TokenType("decimal_float_literal", TokenClass.token, /((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),
@@ -2209,23 +2172,146 @@ void main() {
2209
2172
  shift_right_equal: new TokenType("shift_right_equal", TokenClass.token, ">>="),
2210
2173
  shift_left_equal: new TokenType("shift_left_equal", TokenClass.token, "<<=")
2211
2174
  };
2212
- TokenTypes.storage_class = [_a.keywords.function, _a.keywords.private, _a.keywords.workgroup, _a.keywords.uniform, _a.keywords.storage];
2213
- TokenTypes.access_mode = [_a.keywords.read, _a.keywords.write, _a.keywords.read_write];
2214
- TokenTypes.sampler_type = [_a.keywords.sampler, _a.keywords.sampler_comparison];
2215
- TokenTypes.sampled_texture_type = [_a.keywords.texture_1d, _a.keywords.texture_2d, _a.keywords.texture_2d_array, _a.keywords.texture_3d, _a.keywords.texture_cube, _a.keywords.texture_cube_array];
2216
- TokenTypes.multisampled_texture_type = [_a.keywords.texture_multisampled_2d];
2217
- TokenTypes.storage_texture_type = [_a.keywords.texture_storage_1d, _a.keywords.texture_storage_2d, _a.keywords.texture_storage_2d_array, _a.keywords.texture_storage_3d];
2218
- TokenTypes.depth_texture_type = [_a.keywords.texture_depth_2d, _a.keywords.texture_depth_2d_array, _a.keywords.texture_depth_cube, _a.keywords.texture_depth_cube_array, _a.keywords.texture_depth_multisampled_2d];
2175
+ TokenTypes.storage_class = [
2176
+ _a.keywords.function,
2177
+ _a.keywords.private,
2178
+ _a.keywords.workgroup,
2179
+ _a.keywords.uniform,
2180
+ _a.keywords.storage
2181
+ ];
2182
+ TokenTypes.access_mode = [
2183
+ _a.keywords.read,
2184
+ _a.keywords.write,
2185
+ _a.keywords.read_write
2186
+ ];
2187
+ TokenTypes.sampler_type = [
2188
+ _a.keywords.sampler,
2189
+ _a.keywords.sampler_comparison
2190
+ ];
2191
+ TokenTypes.sampled_texture_type = [
2192
+ _a.keywords.texture_1d,
2193
+ _a.keywords.texture_2d,
2194
+ _a.keywords.texture_2d_array,
2195
+ _a.keywords.texture_3d,
2196
+ _a.keywords.texture_cube,
2197
+ _a.keywords.texture_cube_array
2198
+ ];
2199
+ TokenTypes.multisampled_texture_type = [
2200
+ _a.keywords.texture_multisampled_2d
2201
+ ];
2202
+ TokenTypes.storage_texture_type = [
2203
+ _a.keywords.texture_storage_1d,
2204
+ _a.keywords.texture_storage_2d,
2205
+ _a.keywords.texture_storage_2d_array,
2206
+ _a.keywords.texture_storage_3d
2207
+ ];
2208
+ TokenTypes.depth_texture_type = [
2209
+ _a.keywords.texture_depth_2d,
2210
+ _a.keywords.texture_depth_2d_array,
2211
+ _a.keywords.texture_depth_cube,
2212
+ _a.keywords.texture_depth_cube_array,
2213
+ _a.keywords.texture_depth_multisampled_2d
2214
+ ];
2219
2215
  TokenTypes.texture_external_type = [_a.keywords.texture_external];
2220
- TokenTypes.any_texture_type = [..._a.sampled_texture_type, ..._a.multisampled_texture_type, ..._a.storage_texture_type, ..._a.depth_texture_type, ..._a.texture_external_type];
2221
- TokenTypes.texel_format = [_a.keywords.r8unorm, _a.keywords.r8snorm, _a.keywords.r8uint, _a.keywords.r8sint, _a.keywords.r16uint, _a.keywords.r16sint, _a.keywords.r16float, _a.keywords.rg8unorm, _a.keywords.rg8snorm, _a.keywords.rg8uint, _a.keywords.rg8sint, _a.keywords.r32uint, _a.keywords.r32sint, _a.keywords.r32float, _a.keywords.rg16uint, _a.keywords.rg16sint, _a.keywords.rg16float, _a.keywords.rgba8unorm, _a.keywords.rgba8unorm_srgb, _a.keywords.rgba8snorm, _a.keywords.rgba8uint, _a.keywords.rgba8sint, _a.keywords.bgra8unorm, _a.keywords.bgra8unorm_srgb, _a.keywords.rgb10a2unorm, _a.keywords.rg11b10float, _a.keywords.rg32uint, _a.keywords.rg32sint, _a.keywords.rg32float, _a.keywords.rgba16uint, _a.keywords.rgba16sint, _a.keywords.rgba16float, _a.keywords.rgba32uint, _a.keywords.rgba32sint, _a.keywords.rgba32float];
2222
- TokenTypes.const_literal = [_a.tokens.int_literal, _a.tokens.uint_literal, _a.tokens.decimal_float_literal, _a.tokens.hex_float_literal, _a.keywords.true, _a.keywords.false];
2223
- TokenTypes.literal_or_ident = [_a.tokens.ident, _a.tokens.int_literal, _a.tokens.uint_literal, _a.tokens.decimal_float_literal, _a.tokens.hex_float_literal];
2224
- TokenTypes.element_count_expression = [_a.tokens.int_literal, _a.tokens.uint_literal, _a.tokens.ident];
2225
- TokenTypes.template_types = [_a.keywords.vec2, _a.keywords.vec3, _a.keywords.vec4, _a.keywords.mat2x2, _a.keywords.mat2x3, _a.keywords.mat2x4, _a.keywords.mat3x2, _a.keywords.mat3x3, _a.keywords.mat3x4, _a.keywords.mat4x2, _a.keywords.mat4x3, _a.keywords.mat4x4, _a.keywords.atomic, _a.keywords.bitcast, ..._a.any_texture_type];
2216
+ TokenTypes.any_texture_type = [
2217
+ ..._a.sampled_texture_type,
2218
+ ..._a.multisampled_texture_type,
2219
+ ..._a.storage_texture_type,
2220
+ ..._a.depth_texture_type,
2221
+ ..._a.texture_external_type
2222
+ ];
2223
+ TokenTypes.texel_format = [
2224
+ _a.keywords.r8unorm,
2225
+ _a.keywords.r8snorm,
2226
+ _a.keywords.r8uint,
2227
+ _a.keywords.r8sint,
2228
+ _a.keywords.r16uint,
2229
+ _a.keywords.r16sint,
2230
+ _a.keywords.r16float,
2231
+ _a.keywords.rg8unorm,
2232
+ _a.keywords.rg8snorm,
2233
+ _a.keywords.rg8uint,
2234
+ _a.keywords.rg8sint,
2235
+ _a.keywords.r32uint,
2236
+ _a.keywords.r32sint,
2237
+ _a.keywords.r32float,
2238
+ _a.keywords.rg16uint,
2239
+ _a.keywords.rg16sint,
2240
+ _a.keywords.rg16float,
2241
+ _a.keywords.rgba8unorm,
2242
+ _a.keywords.rgba8unorm_srgb,
2243
+ _a.keywords.rgba8snorm,
2244
+ _a.keywords.rgba8uint,
2245
+ _a.keywords.rgba8sint,
2246
+ _a.keywords.bgra8unorm,
2247
+ _a.keywords.bgra8unorm_srgb,
2248
+ _a.keywords.rgb10a2unorm,
2249
+ _a.keywords.rg11b10float,
2250
+ _a.keywords.rg32uint,
2251
+ _a.keywords.rg32sint,
2252
+ _a.keywords.rg32float,
2253
+ _a.keywords.rgba16uint,
2254
+ _a.keywords.rgba16sint,
2255
+ _a.keywords.rgba16float,
2256
+ _a.keywords.rgba32uint,
2257
+ _a.keywords.rgba32sint,
2258
+ _a.keywords.rgba32float
2259
+ ];
2260
+ TokenTypes.const_literal = [
2261
+ _a.tokens.int_literal,
2262
+ _a.tokens.uint_literal,
2263
+ _a.tokens.decimal_float_literal,
2264
+ _a.tokens.hex_float_literal,
2265
+ _a.keywords.true,
2266
+ _a.keywords.false
2267
+ ];
2268
+ TokenTypes.literal_or_ident = [
2269
+ _a.tokens.ident,
2270
+ _a.tokens.int_literal,
2271
+ _a.tokens.uint_literal,
2272
+ _a.tokens.decimal_float_literal,
2273
+ _a.tokens.hex_float_literal
2274
+ ];
2275
+ TokenTypes.element_count_expression = [
2276
+ _a.tokens.int_literal,
2277
+ _a.tokens.uint_literal,
2278
+ _a.tokens.ident
2279
+ ];
2280
+ TokenTypes.template_types = [
2281
+ _a.keywords.vec2,
2282
+ _a.keywords.vec3,
2283
+ _a.keywords.vec4,
2284
+ _a.keywords.mat2x2,
2285
+ _a.keywords.mat2x3,
2286
+ _a.keywords.mat2x4,
2287
+ _a.keywords.mat3x2,
2288
+ _a.keywords.mat3x3,
2289
+ _a.keywords.mat3x4,
2290
+ _a.keywords.mat4x2,
2291
+ _a.keywords.mat4x3,
2292
+ _a.keywords.mat4x4,
2293
+ _a.keywords.atomic,
2294
+ _a.keywords.bitcast,
2295
+ ..._a.any_texture_type
2296
+ ];
2226
2297
  TokenTypes.attribute_name = [_a.tokens.ident, _a.keywords.block];
2227
- TokenTypes.assignment_operators = [_a.tokens.equal, _a.tokens.plus_equal, _a.tokens.minus_equal, _a.tokens.times_equal, _a.tokens.division_equal, _a.tokens.modulo_equal, _a.tokens.and_equal, _a.tokens.or_equal, _a.tokens.xor_equal, _a.tokens.shift_right_equal, _a.tokens.shift_left_equal];
2228
- TokenTypes.increment_operators = [_a.tokens.plus_plus, _a.tokens.minus_minus];
2298
+ TokenTypes.assignment_operators = [
2299
+ _a.tokens.equal,
2300
+ _a.tokens.plus_equal,
2301
+ _a.tokens.minus_equal,
2302
+ _a.tokens.times_equal,
2303
+ _a.tokens.division_equal,
2304
+ _a.tokens.modulo_equal,
2305
+ _a.tokens.and_equal,
2306
+ _a.tokens.or_equal,
2307
+ _a.tokens.xor_equal,
2308
+ _a.tokens.shift_right_equal,
2309
+ _a.tokens.shift_left_equal
2310
+ ];
2311
+ TokenTypes.increment_operators = [
2312
+ _a.tokens.plus_plus,
2313
+ _a.tokens.minus_minus
2314
+ ];
2229
2315
  var Token = class {
2230
2316
  constructor(type, lexeme, line) {
2231
2317
  this.type = type;
@@ -2253,6 +2339,7 @@ void main() {
2253
2339
  this._line = 1;
2254
2340
  this._source = source !== null && source !== void 0 ? source : "";
2255
2341
  }
2342
+ /// Scan all tokens from the source.
2256
2343
  scanTokens() {
2257
2344
  while (!this._isAtEnd()) {
2258
2345
  this._start = this._current;
@@ -2262,6 +2349,7 @@ void main() {
2262
2349
  this._tokens.push(new Token(TokenTypes.eof, "", this._line));
2263
2350
  return this._tokens;
2264
2351
  }
2352
+ /// Scan a single token from the source.
2265
2353
  scanToken() {
2266
2354
  let lexeme = this._advance();
2267
2355
  if (lexeme == "\n") {
@@ -2618,7 +2706,11 @@ void main() {
2618
2706
  let result = null;
2619
2707
  if (this._check(TokenTypes.keywords.return))
2620
2708
  result = this._return_statement();
2621
- else if (this._check([TokenTypes.keywords.var, TokenTypes.keywords.let, TokenTypes.keywords.const]))
2709
+ else if (this._check([
2710
+ TokenTypes.keywords.var,
2711
+ TokenTypes.keywords.let,
2712
+ TokenTypes.keywords.const
2713
+ ]))
2622
2714
  result = this._variable_statement();
2623
2715
  else if (this._match(TokenTypes.keywords.discard))
2624
2716
  result = new Discard();
@@ -2803,7 +2895,9 @@ void main() {
2803
2895
  }
2804
2896
  _case_selectors() {
2805
2897
  var _a2, _b, _c, _d;
2806
- const selectors = [(_b = (_a2 = this._shift_expression()) === null || _a2 === void 0 ? void 0 : _a2.evaluate(this._context).toString()) !== null && _b !== void 0 ? _b : ""];
2898
+ const selectors = [
2899
+ (_b = (_a2 = this._shift_expression()) === null || _a2 === void 0 ? void 0 : _a2.evaluate(this._context).toString()) !== null && _b !== void 0 ? _b : ""
2900
+ ];
2807
2901
  while (this._match(TokenTypes.tokens.comma)) {
2808
2902
  selectors.push((_d = (_c = this._shift_expression()) === null || _c === void 0 ? void 0 : _c.evaluate(this._context).toString()) !== null && _d !== void 0 ? _d : "");
2809
2903
  }
@@ -2906,7 +3000,12 @@ void main() {
2906
3000
  }
2907
3001
  _relational_expression() {
2908
3002
  let expr = this._shift_expression();
2909
- while (this._match([TokenTypes.tokens.less_than, TokenTypes.tokens.greater_than, TokenTypes.tokens.less_than_equal, TokenTypes.tokens.greater_than_equal])) {
3003
+ while (this._match([
3004
+ TokenTypes.tokens.less_than,
3005
+ TokenTypes.tokens.greater_than,
3006
+ TokenTypes.tokens.less_than_equal,
3007
+ TokenTypes.tokens.greater_than_equal
3008
+ ])) {
2910
3009
  expr = new BinaryOperator(this._previous().toString(), expr, this._shift_expression());
2911
3010
  }
2912
3011
  return expr;
@@ -2927,13 +3026,23 @@ void main() {
2927
3026
  }
2928
3027
  _multiplicative_expression() {
2929
3028
  let expr = this._unary_expression();
2930
- while (this._match([TokenTypes.tokens.star, TokenTypes.tokens.forward_slash, TokenTypes.tokens.modulo])) {
3029
+ while (this._match([
3030
+ TokenTypes.tokens.star,
3031
+ TokenTypes.tokens.forward_slash,
3032
+ TokenTypes.tokens.modulo
3033
+ ])) {
2931
3034
  expr = new BinaryOperator(this._previous().toString(), expr, this._unary_expression());
2932
3035
  }
2933
3036
  return expr;
2934
3037
  }
2935
3038
  _unary_expression() {
2936
- if (this._match([TokenTypes.tokens.minus, TokenTypes.tokens.bang, TokenTypes.tokens.tilde, TokenTypes.tokens.star, TokenTypes.tokens.and])) {
3039
+ if (this._match([
3040
+ TokenTypes.tokens.minus,
3041
+ TokenTypes.tokens.bang,
3042
+ TokenTypes.tokens.tilde,
3043
+ TokenTypes.tokens.star,
3044
+ TokenTypes.tokens.and
3045
+ ])) {
2937
3046
  return new UnaryOperator(this._previous().toString(), this._unary_expression());
2938
3047
  }
2939
3048
  return this._singular_expression();
@@ -3187,7 +3296,14 @@ void main() {
3187
3296
  return aliasNode;
3188
3297
  }
3189
3298
  _type_decl() {
3190
- if (this._check([TokenTypes.tokens.ident, ...TokenTypes.texel_format, TokenTypes.keywords.bool, TokenTypes.keywords.f32, TokenTypes.keywords.i32, TokenTypes.keywords.u32])) {
3299
+ if (this._check([
3300
+ TokenTypes.tokens.ident,
3301
+ ...TokenTypes.texel_format,
3302
+ TokenTypes.keywords.bool,
3303
+ TokenTypes.keywords.f32,
3304
+ TokenTypes.keywords.i32,
3305
+ TokenTypes.keywords.u32
3306
+ ])) {
3191
3307
  const type2 = this._advance();
3192
3308
  const typeName = type2.toString();
3193
3309
  if (this._context.structs.has(typeName)) {
@@ -3298,7 +3414,9 @@ void main() {
3298
3414
  const name = this._consume(TokenTypes.attribute_name, "Expected attribute name");
3299
3415
  const attr = new Attribute(name.toString(), null);
3300
3416
  if (this._match(TokenTypes.tokens.paren_left)) {
3301
- attr.value = [this._consume(TokenTypes.literal_or_ident, "Expected attribute value").toString()];
3417
+ attr.value = [
3418
+ this._consume(TokenTypes.literal_or_ident, "Expected attribute value").toString()
3419
+ ];
3302
3420
  if (this._check(TokenTypes.tokens.comma)) {
3303
3421
  this._advance();
3304
3422
  do {
@@ -3921,74 +4039,23 @@ void main() {
3921
4039
  }
3922
4040
  };
3923
4041
  WgslReflect._typeInfo = {
3924
- f16: {
3925
- align: 2,
3926
- size: 2
3927
- },
3928
- i32: {
3929
- align: 4,
3930
- size: 4
3931
- },
3932
- u32: {
3933
- align: 4,
3934
- size: 4
3935
- },
3936
- f32: {
3937
- align: 4,
3938
- size: 4
3939
- },
3940
- atomic: {
3941
- align: 4,
3942
- size: 4
3943
- },
3944
- vec2: {
3945
- align: 8,
3946
- size: 8
3947
- },
3948
- vec3: {
3949
- align: 16,
3950
- size: 12
3951
- },
3952
- vec4: {
3953
- align: 16,
3954
- size: 16
3955
- },
3956
- mat2x2: {
3957
- align: 8,
3958
- size: 16
3959
- },
3960
- mat3x2: {
3961
- align: 8,
3962
- size: 24
3963
- },
3964
- mat4x2: {
3965
- align: 8,
3966
- size: 32
3967
- },
3968
- mat2x3: {
3969
- align: 16,
3970
- size: 32
3971
- },
3972
- mat3x3: {
3973
- align: 16,
3974
- size: 48
3975
- },
3976
- mat4x3: {
3977
- align: 16,
3978
- size: 64
3979
- },
3980
- mat2x4: {
3981
- align: 16,
3982
- size: 32
3983
- },
3984
- mat3x4: {
3985
- align: 16,
3986
- size: 48
3987
- },
3988
- mat4x4: {
3989
- align: 16,
3990
- size: 64
3991
- }
4042
+ f16: { align: 2, size: 2 },
4043
+ i32: { align: 4, size: 4 },
4044
+ u32: { align: 4, size: 4 },
4045
+ f32: { align: 4, size: 4 },
4046
+ atomic: { align: 4, size: 4 },
4047
+ vec2: { align: 8, size: 8 },
4048
+ vec3: { align: 16, size: 12 },
4049
+ vec4: { align: 16, size: 16 },
4050
+ mat2x2: { align: 8, size: 16 },
4051
+ mat3x2: { align: 8, size: 24 },
4052
+ mat4x2: { align: 8, size: 32 },
4053
+ mat2x3: { align: 16, size: 32 },
4054
+ mat3x3: { align: 16, size: 48 },
4055
+ mat4x3: { align: 16, size: 64 },
4056
+ mat2x4: { align: 16, size: 32 },
4057
+ mat3x4: { align: 16, size: 48 },
4058
+ mat4x4: { align: 16, size: 64 }
3992
4059
  };
3993
4060
  WgslReflect._textureTypes = TokenTypes.any_texture_type.map((t) => {
3994
4061
  return t.name;
@@ -3999,10 +4066,7 @@ void main() {
3999
4066
 
4000
4067
  // src/lib/wgsl/get-shader-layout-wgsl.ts
4001
4068
  function getShaderLayoutFromWGSL(source) {
4002
- const shaderLayout = {
4003
- attributes: [],
4004
- bindings: []
4005
- };
4069
+ const shaderLayout = { attributes: [], bindings: [] };
4006
4070
  const parsedWGSL = parseWGSL(source);
4007
4071
  for (const uniform of parsedWGSL.uniforms) {
4008
4072
  const members = [];
@@ -4016,6 +4080,7 @@ void main() {
4016
4080
  type: "uniform",
4017
4081
  name: uniform.name,
4018
4082
  location: uniform.binding,
4083
+ // @ts-expect-error
4019
4084
  group: uniform.group,
4020
4085
  members
4021
4086
  });
@@ -4052,9 +4117,7 @@ void main() {
4052
4117
  if (typeof error === "object" && error?.token) {
4053
4118
  message += error.token.line || "";
4054
4119
  }
4055
- throw new Error(message, {
4056
- cause: error
4057
- });
4120
+ throw new Error(message, { cause: error });
4058
4121
  }
4059
4122
  }
4060
4123
 
@@ -4410,7 +4473,7 @@ vec4 picking_filterColor(vec4 color) {
4410
4473
  return uniforms;
4411
4474
  }
4412
4475
 
4413
- // src/modules/lighting/lights/lighting-uniforms.glsl.ts
4476
+ // src/modules/lighting/lights/lighting-uniforms-glsl.ts
4414
4477
  var lightingUniforms = glsl`\
4415
4478
  precision highp int;
4416
4479
 
@@ -4468,11 +4531,6 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4468
4531
  // src/modules/lighting/lights/lighting-uniforms.ts
4469
4532
  var MAX_LIGHTS = 5;
4470
4533
  var COLOR_FACTOR = 255;
4471
- var LIGHT_TYPE = function(LIGHT_TYPE2) {
4472
- LIGHT_TYPE2[LIGHT_TYPE2["POINT"] = 0] = "POINT";
4473
- LIGHT_TYPE2[LIGHT_TYPE2["DIRECTIONAL"] = 1] = "DIRECTIONAL";
4474
- return LIGHT_TYPE2;
4475
- }(LIGHT_TYPE || {});
4476
4534
  var lighting = {
4477
4535
  name: "lighting",
4478
4536
  vs: lightingUniforms,
@@ -4487,59 +4545,48 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4487
4545
  enabled: "i32",
4488
4546
  ambientLightColor: "vec3<f32>",
4489
4547
  numberOfLights: "i32",
4548
+ // , array: MAX_LIGHTS,
4490
4549
  lightType: "i32",
4550
+ // , array: MAX_LIGHTS,
4491
4551
  lightColor: "vec3<f32>",
4552
+ // , array: MAX_LIGHTS,
4492
4553
  lightPosition: "vec3<f32>",
4554
+ // , array: MAX_LIGHTS,
4555
+ // TODO - could combine direction and attenuation
4493
4556
  lightDirection: "vec3<f32>",
4557
+ // , array: MAX_LIGHTS,
4494
4558
  lightAttenuation: "vec3<f32>"
4559
+ // , array: MAX_LIGHTS},
4495
4560
  },
4496
4561
  defaultUniforms: {
4497
4562
  enabled: 1,
4498
4563
  ambientLightColor: [0.1, 0.1, 0.1],
4499
4564
  numberOfLights: 0,
4500
- lightType: LIGHT_TYPE.POINT,
4565
+ lightType: 0 /* POINT */,
4501
4566
  lightColor: [1, 1, 1],
4502
4567
  lightPosition: [1, 1, 2],
4568
+ // TODO - could combine direction and attenuation
4503
4569
  lightDirection: [1, 1, 1],
4504
4570
  lightAttenuation: [1, 1, 1]
4505
4571
  }
4506
4572
  };
4507
4573
  function getUniforms2(props, prevUniforms = {}) {
4508
- props = props ? {
4509
- ...props
4510
- } : props;
4574
+ props = props ? { ...props } : props;
4511
4575
  if (!props) {
4512
- return {
4513
- ...lighting.defaultUniforms
4514
- };
4576
+ return { ...lighting.defaultUniforms };
4515
4577
  }
4516
4578
  if (props.lights) {
4517
- props = {
4518
- ...props,
4519
- ...extractLightTypes(props.lights),
4520
- lights: void 0
4521
- };
4579
+ props = { ...props, ...extractLightTypes(props.lights), lights: void 0 };
4522
4580
  }
4523
- const {
4524
- ambientLight,
4525
- pointLights,
4526
- directionalLights
4527
- } = props || {};
4581
+ const { ambientLight, pointLights, directionalLights } = props || {};
4528
4582
  const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0;
4529
4583
  if (!hasLights) {
4530
- return {
4531
- ...lighting.defaultUniforms,
4532
- enabled: 0
4533
- };
4584
+ return { ...lighting.defaultUniforms, enabled: 0 };
4534
4585
  }
4535
4586
  const uniforms = {
4536
4587
  ...lighting.defaultUniforms,
4537
4588
  ...prevUniforms,
4538
- ...getLightSourceUniforms({
4539
- ambientLight,
4540
- pointLights,
4541
- directionalLights
4542
- })
4589
+ ...getLightSourceUniforms({ ambientLight, pointLights, directionalLights })
4543
4590
  };
4544
4591
  if (props.enabled !== void 0) {
4545
4592
  uniforms.enabled = props.enabled ? 1 : 0;
@@ -4551,18 +4598,24 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4551
4598
  pointLights = [],
4552
4599
  directionalLights = []
4553
4600
  }) {
4554
- const lightSourceUniforms = {};
4601
+ const lightSourceUniforms = {
4602
+ // lightType: new Array(MAX_LIGHTS).fill(0),
4603
+ // lightColor: new Array(MAX_LIGHTS).fill([0, 0, 0]),
4604
+ // lightPosition: new Array(MAX_LIGHTS).fill([0, 0, 0]),
4605
+ // lightDirection: new Array(MAX_LIGHTS).fill([0, 0, 0]),
4606
+ // lightAttenuation: new Array(MAX_LIGHTS).fill([0, 0, 0])
4607
+ };
4555
4608
  lightSourceUniforms.ambientLightColor = convertColor(ambientLight);
4556
4609
  let currentLight = 0;
4557
4610
  for (const pointLight of pointLights) {
4558
- lightSourceUniforms.lightType = LIGHT_TYPE.POINT;
4611
+ lightSourceUniforms.lightType = 0 /* POINT */;
4559
4612
  lightSourceUniforms.lightColor = convertColor(pointLight);
4560
4613
  lightSourceUniforms.lightPosition = pointLight.position;
4561
4614
  lightSourceUniforms.lightAttenuation = [pointLight.attenuation || 1, 0, 0];
4562
4615
  currentLight++;
4563
4616
  }
4564
4617
  for (const directionalLight of directionalLights) {
4565
- lightSourceUniforms.lightType = LIGHT_TYPE.DIRECTIONAL;
4618
+ lightSourceUniforms.lightType = 1 /* DIRECTIONAL */;
4566
4619
  lightSourceUniforms.lightColor = convertColor(directionalLight);
4567
4620
  lightSourceUniforms.lightPosition = directionalLight.position;
4568
4621
  lightSourceUniforms.lightDirection = directionalLight.direction;
@@ -4572,10 +4625,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4572
4625
  return lightSourceUniforms;
4573
4626
  }
4574
4627
  function extractLightTypes(lights2) {
4575
- const lightSources = {
4576
- pointLights: [],
4577
- directionalLights: []
4578
- };
4628
+ const lightSources = { pointLights: [], directionalLights: [] };
4579
4629
  for (const light of lights2 || []) {
4580
4630
  switch (light.type) {
4581
4631
  case "ambient":
@@ -4593,10 +4643,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
4593
4643
  return lightSources;
4594
4644
  }
4595
4645
  function convertColor(colorDef = {}) {
4596
- const {
4597
- color = [0, 0, 0],
4598
- intensity = 1
4599
- } = colorDef;
4646
+ const { color = [0, 0, 0], intensity = 1 } = colorDef;
4600
4647
  return color.map((component) => component * intensity / COLOR_FACTOR);
4601
4648
  }
4602
4649
 
@@ -4626,6 +4673,14 @@ vec4 dirlight_filterColor(vec4 color) {
4626
4673
  dependencies: [],
4627
4674
  vs: VS_GLSL,
4628
4675
  fs: FS_GLSL,
4676
+ // vs: {glsl: VS_GLSL, wgsl: VS_WGSL},
4677
+ // fs: {glsl: FS_GLSL, wgsl: FS_WGSL},
4678
+ // fragmentInputs: [
4679
+ // {
4680
+ // name: 'dirlight_vNormal',
4681
+ // type: 'vec3<f32>'
4682
+ // }
4683
+ // ],
4629
4684
  uniformTypes: {
4630
4685
  lightDirection: "vec3<f32>"
4631
4686
  },
@@ -4642,7 +4697,7 @@ vec4 dirlight_filterColor(vec4 color) {
4642
4697
  return uniforms;
4643
4698
  }
4644
4699
 
4645
- // src/modules/lighting/gouraud-material/gouraud-shaders.glsl.ts
4700
+ // src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts
4646
4701
  var GOURAUD_VS = glsl`\
4647
4702
  uniform materialUniforms {
4648
4703
  uniform float ambient;
@@ -4738,6 +4793,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
4738
4793
  // src/modules/lighting/gouraud-material/gouraud-material.ts
4739
4794
  var gouraudMaterial = {
4740
4795
  name: "gouraud-lighting",
4796
+ // Note these are switched between phong and gouraud
4741
4797
  vs: GOURAUD_VS,
4742
4798
  fs: GOURAUD_FS,
4743
4799
  defines: {
@@ -4757,14 +4813,11 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
4757
4813
  specularColor: [0.15, 0.15, 0.15]
4758
4814
  },
4759
4815
  getUniforms(props) {
4760
- return {
4761
- ...gouraudMaterial.defaultUniforms,
4762
- ...props
4763
- };
4816
+ return { ...gouraudMaterial.defaultUniforms, ...props };
4764
4817
  }
4765
4818
  };
4766
4819
 
4767
- // src/modules/lighting/phong-material/phong-shaders.glsl.ts
4820
+ // src/modules/lighting/phong-material/phong-shaders-glsl.ts
4768
4821
  var PHONG_VS = glsl`\
4769
4822
  uniform phongMaterialUniforms {
4770
4823
  uniform float ambient;
@@ -4863,6 +4916,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
4863
4916
  // src/modules/lighting/phong-material/phong-material.ts
4864
4917
  var phongMaterial = {
4865
4918
  name: "phong-lighting",
4919
+ // Note these are switched between phong and gouraud
4866
4920
  vs: PHONG_VS,
4867
4921
  fs: PHONG_FS,
4868
4922
  defines: {
@@ -4882,14 +4936,11 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
4882
4936
  specularColor: [0.15, 0.15, 0.15]
4883
4937
  },
4884
4938
  getUniforms(props) {
4885
- return {
4886
- ...phongMaterial.defaultUniforms,
4887
- ...props
4888
- };
4939
+ return { ...phongMaterial.defaultUniforms, ...props };
4889
4940
  }
4890
4941
  };
4891
4942
 
4892
- // src/modules/lighting/pbr-material/pbr-vertex.glsl.ts
4943
+ // src/modules/lighting/pbr-material/pbr-vertex-glsl.ts
4893
4944
  var vs2 = glsl`\
4894
4945
  uniform projection {
4895
4946
  mat4 u_MVPMatrix;
@@ -4934,7 +4985,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
4934
4985
  }
4935
4986
  `;
4936
4987
 
4937
- // src/modules/lighting/pbr-material/pbr-fragment.glsl.ts
4988
+ // src/modules/lighting/pbr-material/pbr-fragment-glsl.ts
4938
4989
  var fs3 = glsl`\
4939
4990
  #if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
4940
4991
  # error PBR fragment shader: Texture LOD is not available
@@ -4944,15 +4995,6 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
4944
4995
  # error PBR fragment shader: Derivatives are not available
4945
4996
  #endif
4946
4997
 
4947
- // WebGL 1.0 does not support non-constant in for loops
4948
- // This provides an easy way to handle these cases
4949
- // and still take advantage of WebGL 2.0
4950
- #if (__VERSION__ < 300)
4951
- #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)
4952
- #else
4953
- #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
4954
- #endif
4955
-
4956
4998
  precision highp float;
4957
4999
 
4958
5000
  uniform Projection {
@@ -5299,7 +5341,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
5299
5341
  color += calculateFinalColor(pbrInfo, lighting_uAmbientLight.color);
5300
5342
 
5301
5343
  // Apply directional light
5302
- SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) {
5344
+ for(int i = 0, i < lighting_uDirectionalLightCount, i++) {
5303
5345
  if (i < lighting_uDirectionalLightCount) {
5304
5346
  PBRInfo_setDirectionalLight(pbrInfo, lighting_uDirectionalLight[i].direction);
5305
5347
  color += calculateFinalColor(pbrInfo, lighting_uDirectionalLight[i].color);
@@ -5307,7 +5349,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
5307
5349
  }
5308
5350
 
5309
5351
  // Apply point light
5310
- SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) {
5352
+ for(int i = 0, i < lighting_uPointLightCount, i++) {
5311
5353
  if (i < lighting_uPointLightCount) {
5312
5354
  PBRInfo_setPointLight(pbrInfo, lighting_uPointLight[i]);
5313
5355
  float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
@@ -5377,57 +5419,52 @@ vec4 pbr_filterColor(vec4 colorUnused)
5377
5419
  PBR_DEBUG: 0
5378
5420
  },
5379
5421
  uniformTypes: {
5422
+ // Material is unlit
5380
5423
  unlit: "i32",
5424
+ // Base color map
5381
5425
  baseColorMapEnabled: "i32",
5382
5426
  baseColorFactor: "vec4<f32>",
5383
5427
  normalMapEnabled: "i32",
5384
5428
  normalScale: "f32",
5429
+ // #ifdef HAS_NORMALMAP
5385
5430
  emissiveMapEnabled: "i32",
5386
5431
  emissiveFactor: "vec3<f32>",
5432
+ // #ifdef HAS_EMISSIVEMAP
5387
5433
  metallicRoughnessValues: "vec2<f32>",
5388
5434
  metallicRoughnessMapEnabled: "i32",
5389
5435
  occlusionMapEnabled: "i32",
5390
5436
  occlusionStrength: "f32",
5437
+ // #ifdef HAS_OCCLUSIONMAP
5391
5438
  alphaCutoffEnabled: "i32",
5392
5439
  alphaCutoff: "f32",
5440
+ // #ifdef ALPHA_CUTOFF
5441
+ // IBL
5393
5442
  IBLenabled: "i32",
5394
5443
  scaleIBLAmbient: "vec2<f32>",
5444
+ // #ifdef USE_IBL
5445
+ // debugging flags used for shader output of intermediate PBR variables
5446
+ // #ifdef PBR_DEBUG
5395
5447
  scaleDiffBaseMR: "vec4<f32>",
5396
5448
  scaleFGDSpec: "vec4<f32>"
5397
5449
  },
5398
5450
  bindings: {
5399
- baseColorSampler: {
5400
- type: "texture",
5401
- location: 8
5402
- },
5403
- normalSampler: {
5404
- type: "texture",
5405
- location: 9
5406
- },
5407
- emissiveSampler: {
5408
- type: "texture",
5409
- location: 10
5410
- },
5411
- metallicRoughnessSampler: {
5412
- type: "texture",
5413
- location: 11
5414
- },
5415
- occlusionSampler: {
5416
- type: "texture",
5417
- location: 12
5418
- },
5419
- diffuseEnvSampler: {
5420
- type: "texture",
5421
- location: 13
5422
- },
5423
- specularEnvSampler: {
5424
- type: "texture",
5425
- location: 14
5426
- },
5427
- brdfLUT: {
5428
- type: "texture",
5429
- location: 15
5430
- }
5451
+ baseColorSampler: { type: "texture", location: 8 },
5452
+ // #ifdef HAS_BASECOLORMAP
5453
+ normalSampler: { type: "texture", location: 9 },
5454
+ // #ifdef HAS_NORMALMAP
5455
+ emissiveSampler: { type: "texture", location: 10 },
5456
+ // #ifdef HAS_EMISSIVEMAP
5457
+ metallicRoughnessSampler: { type: "texture", location: 11 },
5458
+ // #ifdef HAS_METALROUGHNESSMAP
5459
+ occlusionSampler: { type: "texture", location: 12 },
5460
+ // #ifdef HAS_OCCLUSIONMAP
5461
+ // IBL Samplers
5462
+ diffuseEnvSampler: { type: "texture", location: 13 },
5463
+ // #ifdef USE_IBL (samplerCube)
5464
+ specularEnvSampler: { type: "texture", location: 14 },
5465
+ // #ifdef USE_IBL (samplerCube)
5466
+ brdfLUT: { type: "texture", location: 15 }
5467
+ // #ifdef USE_IBL
5431
5468
  },
5432
5469
  dependencies: [lighting]
5433
5470
  };
@@ -5461,23 +5498,11 @@ vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
5461
5498
  contrast: "f32"
5462
5499
  },
5463
5500
  uniformPropTypes: {
5464
- brightness: {
5465
- format: "f32",
5466
- value: 0,
5467
- min: -1,
5468
- max: 1
5469
- },
5470
- contrast: {
5471
- format: "f32",
5472
- value: 0,
5473
- min: -1,
5474
- max: 1
5475
- }
5501
+ brightness: { format: "f32", value: 0, min: -1, max: 1 },
5502
+ contrast: { format: "f32", value: 0, min: -1, max: 1 }
5476
5503
  },
5477
5504
  fs: fs4,
5478
- passes: [{
5479
- filter: true
5480
- }]
5505
+ passes: [{ filter: true }]
5481
5506
  };
5482
5507
 
5483
5508
  // src/modules/postprocessing/image-adjust-filters/denoise.ts
@@ -5511,19 +5536,11 @@ vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
5511
5536
  strength: "f32"
5512
5537
  },
5513
5538
  uniformPropTypes: {
5514
- strength: {
5515
- format: "f32",
5516
- value: 0.5,
5517
- min: 0,
5518
- max: 1
5519
- }
5539
+ strength: { format: "f32", value: 0.5, min: 0, max: 1 }
5540
+ // strength: {..., adjust: (strength: number): number => 0.53 + 200 * Math.pow(1 - strength, 4) // TODO - JS preprocessing
5520
5541
  },
5521
5542
  fs: fs5,
5522
- passes: [{
5523
- sampler: true
5524
- }, {
5525
- sampler: true
5526
- }]
5543
+ passes: [{ sampler: true }, { sampler: true }]
5527
5544
  };
5528
5545
 
5529
5546
  // src/modules/postprocessing/image-adjust-filters/huesaturation.ts
@@ -5567,21 +5584,11 @@ vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5567
5584
  saturation: "f32"
5568
5585
  },
5569
5586
  uniformPropTypes: {
5570
- hue: {
5571
- value: 0,
5572
- min: -1,
5573
- max: 1
5574
- },
5575
- saturation: {
5576
- value: 0,
5577
- min: -1,
5578
- max: 1
5579
- }
5587
+ hue: { value: 0, min: -1, max: 1 },
5588
+ saturation: { value: 0, min: -1, max: 1 }
5580
5589
  },
5581
5590
  fs: fs6,
5582
- passes: [{
5583
- filter: true
5584
- }]
5591
+ passes: [{ filter: true }]
5585
5592
  };
5586
5593
 
5587
5594
  // src/modules/postprocessing/image-adjust-filters/noise.ts
@@ -5612,16 +5619,10 @@ vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5612
5619
  amount: "f32"
5613
5620
  },
5614
5621
  uniformPropTypes: {
5615
- amount: {
5616
- value: 0.5,
5617
- min: 0,
5618
- max: 1
5619
- }
5622
+ amount: { value: 0.5, min: 0, max: 1 }
5620
5623
  },
5621
5624
  fs: fs7,
5622
- passes: [{
5623
- filter: true
5624
- }]
5625
+ passes: [{ filter: true }]
5625
5626
  };
5626
5627
 
5627
5628
  // src/modules/postprocessing/image-adjust-filters/sepia.ts
@@ -5653,16 +5654,10 @@ vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5653
5654
  amount: "f32"
5654
5655
  },
5655
5656
  uniformPropTypes: {
5656
- amount: {
5657
- value: 0.5,
5658
- min: 0,
5659
- max: 1
5660
- }
5657
+ amount: { value: 0.5, min: 0, max: 1 }
5661
5658
  },
5662
5659
  fs: fs8,
5663
- passes: [{
5664
- filter: true
5665
- }]
5660
+ passes: [{ filter: true }]
5666
5661
  };
5667
5662
 
5668
5663
  // src/modules/postprocessing/image-adjust-filters/vibrance.ts
@@ -5686,16 +5681,10 @@ vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5686
5681
  var vibrance = {
5687
5682
  name: "vibrance",
5688
5683
  uniformPropTypes: {
5689
- amount: {
5690
- value: 0,
5691
- min: -1,
5692
- max: 1
5693
- }
5684
+ amount: { value: 0, min: -1, max: 1 }
5694
5685
  },
5695
5686
  fs: fs9,
5696
- passes: [{
5697
- filter: true
5698
- }]
5687
+ passes: [{ filter: true }]
5699
5688
  };
5700
5689
 
5701
5690
  // src/modules/postprocessing/image-adjust-filters/vignette.ts
@@ -5723,20 +5712,10 @@ vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
5723
5712
  amount: "f32"
5724
5713
  },
5725
5714
  uniformPropTypes: {
5726
- radius: {
5727
- value: 0.5,
5728
- min: 0,
5729
- max: 1
5730
- },
5731
- amount: {
5732
- value: 0.5,
5733
- min: 0,
5734
- max: 1
5735
- }
5715
+ radius: { value: 0.5, min: 0, max: 1 },
5716
+ amount: { value: 0.5, min: 0, max: 1 }
5736
5717
  },
5737
- passes: [{
5738
- filter: true
5739
- }]
5718
+ passes: [{ filter: true }]
5740
5719
  };
5741
5720
 
5742
5721
  // src/modules/postprocessing/image-blur-filters/tiltshift.ts
@@ -5795,38 +5774,16 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
5795
5774
  invert: "i32"
5796
5775
  },
5797
5776
  uniformPropTypes: {
5798
- blurRadius: {
5799
- value: 15,
5800
- min: 0,
5801
- max: 50
5802
- },
5803
- gradientRadius: {
5804
- value: 200,
5805
- min: 0,
5806
- max: 400
5807
- },
5808
- start: {
5809
- value: [0, 0]
5810
- },
5811
- end: {
5812
- value: [1, 1]
5813
- },
5814
- invert: {
5815
- value: false,
5816
- private: true
5817
- }
5777
+ blurRadius: { value: 15, min: 0, max: 50 },
5778
+ gradientRadius: { value: 200, min: 0, max: 400 },
5779
+ start: { value: [0, 0] },
5780
+ end: { value: [1, 1] },
5781
+ invert: { value: false, private: true }
5818
5782
  },
5819
- passes: [{
5820
- sampler: true,
5821
- uniforms: {
5822
- invert: false
5823
- }
5824
- }, {
5825
- sampler: true,
5826
- uniforms: {
5827
- invert: true
5828
- }
5829
- }],
5783
+ passes: [
5784
+ { sampler: true, uniforms: { invert: false } },
5785
+ { sampler: true, uniforms: { invert: true } }
5786
+ ],
5830
5787
  dependencies: [random],
5831
5788
  fs: fs11
5832
5789
  };
@@ -5874,29 +5831,15 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
5874
5831
  delta: "vec2<f32>"
5875
5832
  },
5876
5833
  uniformPropTypes: {
5877
- radius: {
5878
- value: 20,
5879
- min: 0,
5880
- softMax: 100
5881
- },
5882
- delta: {
5883
- value: [1, 0],
5884
- private: true
5885
- }
5834
+ radius: { value: 20, min: 0, softMax: 100 },
5835
+ delta: { value: [1, 0], private: true }
5886
5836
  },
5887
5837
  fs: fs12,
5888
5838
  dependencies: [random],
5889
- passes: [{
5890
- sampler: true,
5891
- uniforms: {
5892
- delta: [1, 0]
5893
- }
5894
- }, {
5895
- sampler: true,
5896
- uniforms: {
5897
- delta: [0, 1]
5898
- }
5899
- }]
5839
+ passes: [
5840
+ { sampler: true, uniforms: { delta: [1, 0] } },
5841
+ { sampler: true, uniforms: { delta: [0, 1] } }
5842
+ ]
5900
5843
  };
5901
5844
 
5902
5845
  // src/modules/postprocessing/image-blur-filters/zoomblur.ts
@@ -5941,20 +5884,12 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
5941
5884
  strength: "f32"
5942
5885
  },
5943
5886
  uniformPropTypes: {
5944
- center: {
5945
- value: [0.5, 0.5]
5946
- },
5947
- strength: {
5948
- value: 0.3,
5949
- min: 0,
5950
- softMax: 1
5951
- }
5887
+ center: { value: [0.5, 0.5] },
5888
+ strength: { value: 0.3, min: 0, softMax: 1 }
5952
5889
  },
5953
5890
  fs: fs13,
5954
5891
  dependencies: [random],
5955
- passes: [{
5956
- sampler: true
5957
- }]
5892
+ passes: [{ sampler: true }]
5958
5893
  };
5959
5894
 
5960
5895
  // src/modules/postprocessing/image-fun-filters/colorhalftone.ts
@@ -6002,25 +5937,12 @@ vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
6002
5937
  size: "f32"
6003
5938
  },
6004
5939
  uniformPropTypes: {
6005
- center: {
6006
- value: [0.5, 0.5]
6007
- },
6008
- angle: {
6009
- value: 1.1,
6010
- softMin: 0,
6011
- softMax: Math.PI / 2
6012
- },
6013
- size: {
6014
- value: 4,
6015
- min: 1,
6016
- softMin: 3,
6017
- softMax: 20
6018
- }
5940
+ center: { value: [0.5, 0.5] },
5941
+ angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
5942
+ size: { value: 4, min: 1, softMin: 3, softMax: 20 }
6019
5943
  },
6020
5944
  fs: fs14,
6021
- passes: [{
6022
- filter: true
6023
- }]
5945
+ passes: [{ filter: true }]
6024
5946
  };
6025
5947
 
6026
5948
  // src/modules/postprocessing/image-fun-filters/dotscreen.ts
@@ -6056,25 +5978,12 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
6056
5978
  size: "f32"
6057
5979
  },
6058
5980
  uniformPropTypes: {
6059
- center: {
6060
- value: [0.5, 0.5]
6061
- },
6062
- angle: {
6063
- value: 1.1,
6064
- softMin: 0,
6065
- softMax: Math.PI / 2
6066
- },
6067
- size: {
6068
- value: 3,
6069
- min: 1,
6070
- softMin: 3,
6071
- softMax: 20
6072
- }
5981
+ center: { value: [0.5, 0.5] },
5982
+ angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
5983
+ size: { value: 3, min: 1, softMin: 3, softMax: 20 }
6073
5984
  },
6074
5985
  fs: fs15,
6075
- passes: [{
6076
- filter: true
6077
- }]
5986
+ passes: [{ filter: true }]
6078
5987
  };
6079
5988
 
6080
5989
  // src/modules/postprocessing/image-fun-filters/edgework.ts
@@ -6137,29 +6046,23 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
6137
6046
  var edgeWork = {
6138
6047
  name: "edgeWork",
6139
6048
  uniformPropTypes: {
6140
- radius: {
6141
- value: 2,
6142
- min: 1,
6143
- softMax: 50
6144
- },
6145
- delta: {
6146
- value: [1, 0],
6147
- private: true
6148
- }
6049
+ radius: { value: 2, min: 1, softMax: 50 },
6050
+ delta: { value: [1, 0], private: true }
6149
6051
  },
6150
6052
  fs: fs16,
6151
6053
  dependencies: [random],
6152
- passes: [{
6153
- sampler: "edgeWork_sampleColor1",
6154
- uniformPropTypes: {
6155
- delta: [1, 0]
6156
- }
6157
- }, {
6158
- sampler: "edgeWork_sampleColor2",
6159
- uniformPropTypes: {
6160
- delta: [0, 1]
6054
+ passes: [
6055
+ {
6056
+ // @ts-expect-error
6057
+ sampler: "edgeWork_sampleColor1",
6058
+ uniformPropTypes: { delta: [1, 0] }
6059
+ },
6060
+ {
6061
+ // @ts-expect-error
6062
+ sampler: "edgeWork_sampleColor2",
6063
+ uniformPropTypes: { delta: [0, 1] }
6161
6064
  }
6162
- }]
6065
+ ]
6163
6066
  };
6164
6067
 
6165
6068
  // src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts
@@ -6214,21 +6117,11 @@ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord
6214
6117
  scale: "f32"
6215
6118
  },
6216
6119
  uniformPropTypes: {
6217
- center: {
6218
- value: [0.5, 0.5],
6219
- hint: "screenspace"
6220
- },
6221
- scale: {
6222
- value: 10,
6223
- min: 1,
6224
- softMin: 5,
6225
- softMax: 50
6226
- }
6120
+ center: { value: [0.5, 0.5], hint: "screenspace" },
6121
+ scale: { value: 10, min: 1, softMin: 5, softMax: 50 }
6227
6122
  },
6228
6123
  fs: fs17,
6229
- passes: [{
6230
- sampler: true
6231
- }]
6124
+ passes: [{ sampler: true }]
6232
6125
  };
6233
6126
 
6234
6127
  // src/modules/postprocessing/image-fun-filters/ink.ts
@@ -6267,16 +6160,10 @@ vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
6267
6160
  strength: "f32"
6268
6161
  },
6269
6162
  uniformPropTypes: {
6270
- strength: {
6271
- value: 0.25,
6272
- min: 0,
6273
- softMax: 1
6274
- }
6163
+ strength: { value: 0.25, min: 0, softMax: 1 }
6275
6164
  },
6276
6165
  fs: fs18,
6277
- passes: [{
6278
- sampler: true
6279
- }]
6166
+ passes: [{ sampler: true }]
6280
6167
  };
6281
6168
 
6282
6169
  // src/modules/postprocessing/image-fun-filters/magnify.ts
@@ -6312,20 +6199,15 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
6312
6199
  borderColor: "vec4<f32>"
6313
6200
  },
6314
6201
  uniformPropTypes: {
6315
- screenXY: {
6316
- value: [0, 0]
6317
- },
6202
+ // range 0 to 1
6203
+ screenXY: { value: [0, 0] },
6318
6204
  radiusPixels: 200,
6319
6205
  zoom: 2,
6320
6206
  borderWidthPixels: 0,
6321
- borderColor: {
6322
- value: [255, 255, 255, 255]
6323
- }
6207
+ borderColor: { value: [255, 255, 255, 255] }
6324
6208
  },
6325
6209
  fs: fs19,
6326
- passes: [{
6327
- sampler: true
6328
- }]
6210
+ passes: [{ sampler: true }]
6329
6211
  };
6330
6212
 
6331
6213
  // src/modules/postprocessing/image-warp-filters/warp.ts
@@ -6386,24 +6268,12 @@ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
6386
6268
  strength: "f32"
6387
6269
  },
6388
6270
  uniformPropTypes: {
6389
- center: {
6390
- value: [0.5, 0.5]
6391
- },
6392
- radius: {
6393
- value: 200,
6394
- min: 1,
6395
- softMax: 600
6396
- },
6397
- strength: {
6398
- value: 0.5,
6399
- min: -1,
6400
- max: 1
6401
- }
6271
+ center: { value: [0.5, 0.5] },
6272
+ radius: { value: 200, min: 1, softMax: 600 },
6273
+ strength: { value: 0.5, min: -1, max: 1 }
6402
6274
  },
6403
6275
  dependencies: [warp],
6404
- passes: [{
6405
- sampler: true
6406
- }]
6276
+ passes: [{ sampler: true }]
6407
6277
  };
6408
6278
 
6409
6279
  // src/modules/postprocessing/image-warp-filters/swirl.ts
@@ -6447,24 +6317,12 @@ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
6447
6317
  angle: "f32"
6448
6318
  },
6449
6319
  uniformPropTypes: {
6450
- center: {
6451
- value: [0.5, 0.5]
6452
- },
6453
- radius: {
6454
- value: 200,
6455
- min: 1,
6456
- softMax: 600
6457
- },
6458
- angle: {
6459
- value: 3,
6460
- softMin: -25,
6461
- softMax: 25
6462
- }
6320
+ center: { value: [0.5, 0.5] },
6321
+ radius: { value: 200, min: 1, softMax: 600 },
6322
+ angle: { value: 3, softMin: -25, softMax: 25 }
6463
6323
  },
6464
6324
  dependencies: [warp],
6465
- passes: [{
6466
- sampler: true
6467
- }]
6325
+ passes: [{ sampler: true }]
6468
6326
  };
6469
6327
 
6470
6328
  // src/modules/postprocessing/fxaa/fxaa.ts
@@ -7053,9 +6911,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
7053
6911
  name: "fxaa",
7054
6912
  uniformPropTypes: {},
7055
6913
  fs: fs23,
7056
- passes: [{
7057
- sampler: true
7058
- }]
6914
+ passes: [{ sampler: true }]
7059
6915
  };
7060
6916
 
7061
6917
  // src/modules-webgl1/math/fp64/fp64-utils.ts
@@ -7080,7 +6936,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
7080
6936
  return matrixFP64;
7081
6937
  }
7082
6938
 
7083
- // src/modules-webgl1/math/fp64/fp64-arithmetic.glsl.ts
6939
+ // src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts
7084
6940
  var fp64arithmeticShader = glsl`\
7085
6941
  uniform float ONE;
7086
6942
 
@@ -7249,7 +7105,7 @@ vec2 sqrt_fp64(vec2 a) {
7249
7105
  }
7250
7106
  `;
7251
7107
 
7252
- // src/modules-webgl1/math/fp64/fp64-functions.glsl.ts
7108
+ // src/modules-webgl1/math/fp64/fp64-functions-glsl.ts
7253
7109
  var fp64functionShader = glsl`\
7254
7110
  const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
7255
7111
  const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
@@ -7924,6 +7780,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
7924
7780
 
7925
7781
  // src/modules-webgl1/math/fp64/fp64.ts
7926
7782
  var CONST_UNIFORMS = {
7783
+ // Used in LUMA_FP64_CODE_ELIMINATION_WORKAROUND
7927
7784
  ONE: 1
7928
7785
  };
7929
7786
  function getUniforms4() {
@@ -7941,6 +7798,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
7941
7798
  name: "fp64",
7942
7799
  vs: fp64functionShader,
7943
7800
  dependencies: [fp64arithmetic],
7801
+ // Additional Functions
7944
7802
  fp64ify,
7945
7803
  fp64LowPart,
7946
7804
  fp64ifyMatrix4
@@ -9553,7 +9411,9 @@ vec3 geometry_getNormal() {
9553
9411
  uniforms.cameraPositionWorld = opts.cameraPositionWorld;
9554
9412
  }
9555
9413
  if (opts.projectionMatrix !== void 0 || opts.viewMatrix !== void 0) {
9556
- uniforms.viewProjectionMatrix = new Matrix4(opts.projectionMatrix).multiplyRight(opts.viewMatrix);
9414
+ uniforms.viewProjectionMatrix = new Matrix4(opts.projectionMatrix).multiplyRight(
9415
+ opts.viewMatrix
9416
+ );
9557
9417
  }
9558
9418
  return uniforms;
9559
9419
  }
@@ -9632,7 +9492,7 @@ ${common}`;
9632
9492
  fs: fs25
9633
9493
  };
9634
9494
 
9635
- // src/modules-webgl1/lighting/lights/lights.glsl.ts
9495
+ // src/modules-webgl1/lighting/lights/lights-glsl.ts
9636
9496
  var lightingShader = glsl`\
9637
9497
  #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
9638
9498
 
@@ -9675,10 +9535,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
9675
9535
  lightSources: {}
9676
9536
  };
9677
9537
  function convertColor2(colorDef = {}) {
9678
- const {
9679
- color = [0, 0, 0],
9680
- intensity = 1
9681
- } = colorDef;
9538
+ const { color = [0, 0, 0], intensity = 1 } = colorDef;
9682
9539
  return color.map((component) => component * intensity / 255);
9683
9540
  }
9684
9541
  function getLightSourceUniforms2({
@@ -9695,7 +9552,11 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
9695
9552
  pointLights.forEach((pointLight, index2) => {
9696
9553
  lightSourceUniforms[`lighting_uPointLight[${index2}].color`] = convertColor2(pointLight);
9697
9554
  lightSourceUniforms[`lighting_uPointLight[${index2}].position`] = pointLight.position;
9698
- lightSourceUniforms[`lighting_uPointLight[${index2}].attenuation`] = pointLight.attenuation || [1, 0, 0];
9555
+ lightSourceUniforms[`lighting_uPointLight[${index2}].attenuation`] = pointLight.attenuation || [
9556
+ 1,
9557
+ 0,
9558
+ 0
9559
+ ];
9699
9560
  });
9700
9561
  lightSourceUniforms.lighting_uPointLightCount = pointLights.length;
9701
9562
  directionalLights.forEach((directionalLight, index2) => {
@@ -9707,30 +9568,21 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
9707
9568
  }
9708
9569
  function getUniforms6(opts = INITIAL_MODULE_OPTIONS) {
9709
9570
  if ("lightSources" in opts) {
9710
- const {
9711
- ambientLight,
9712
- pointLights,
9713
- directionalLights
9714
- } = opts.lightSources || {};
9571
+ const { ambientLight, pointLights, directionalLights } = opts.lightSources || {};
9715
9572
  const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0;
9716
9573
  if (!hasLights) {
9717
- return {
9718
- lighting_uEnabled: false
9719
- };
9574
+ return { lighting_uEnabled: false };
9720
9575
  }
9721
- return Object.assign({}, getLightSourceUniforms2({
9722
- ambientLight,
9723
- pointLights,
9724
- directionalLights
9725
- }), {
9726
- lighting_uEnabled: true
9727
- });
9576
+ return Object.assign(
9577
+ {},
9578
+ getLightSourceUniforms2({ ambientLight, pointLights, directionalLights }),
9579
+ {
9580
+ lighting_uEnabled: true
9581
+ }
9582
+ );
9728
9583
  }
9729
9584
  if ("lights" in opts) {
9730
- const lightSources = {
9731
- pointLights: [],
9732
- directionalLights: []
9733
- };
9585
+ const lightSources = { pointLights: [], directionalLights: [] };
9734
9586
  for (const light of opts.lights || []) {
9735
9587
  switch (light.type) {
9736
9588
  case "ambient":
@@ -9745,9 +9597,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
9745
9597
  default:
9746
9598
  }
9747
9599
  }
9748
- return getUniforms6({
9749
- lightSources
9750
- });
9600
+ return getUniforms6({ lightSources });
9751
9601
  }
9752
9602
  return {};
9753
9603
  }
@@ -9786,12 +9636,13 @@ vec4 dirlight_filterColor(vec4 color) {
9786
9636
  `;
9787
9637
  var dirlight2 = {
9788
9638
  name: "dirlight",
9639
+ // vs // TODO - reuse normal from geometry module
9789
9640
  fs: fs26,
9790
9641
  getUniforms: getUniforms7,
9791
9642
  dependencies: [project]
9792
9643
  };
9793
9644
 
9794
- // src/modules-webgl1/lighting/phong-lighting/phong-lighting.glsl.ts
9645
+ // src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts
9795
9646
  var lightingShader2 = glsl`\
9796
9647
 
9797
9648
  uniform float lighting_uAmbient;
@@ -9871,12 +9722,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
9871
9722
  // src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts
9872
9723
  var INITIAL_MODULE_OPTIONS2 = {};
9873
9724
  function getMaterialUniforms(material) {
9874
- const {
9875
- ambient = 0.35,
9876
- diffuse = 0.6,
9877
- shininess = 32,
9878
- specularColor = [30, 30, 30]
9879
- } = material;
9725
+ const { ambient = 0.35, diffuse = 0.6, shininess = 32, specularColor = [30, 30, 30] } = material;
9880
9726
  return {
9881
9727
  lighting_uAmbient: ambient,
9882
9728
  lighting_uDiffuse: diffuse,
@@ -9888,13 +9734,9 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
9888
9734
  if (!("material" in opts)) {
9889
9735
  return {};
9890
9736
  }
9891
- const {
9892
- material
9893
- } = opts;
9737
+ const { material } = opts;
9894
9738
  if (!material) {
9895
- return {
9896
- lighting_uEnabled: false
9897
- };
9739
+ return { lighting_uEnabled: false };
9898
9740
  }
9899
9741
  return getMaterialUniforms(material);
9900
9742
  }
@@ -9917,7 +9759,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
9917
9759
  getUniforms: getUniforms8
9918
9760
  };
9919
9761
 
9920
- // src/modules-webgl1/lighting/pbr/pbr-vertex.glsl.ts
9762
+ // src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts
9921
9763
  var vs5 = glsl`\
9922
9764
  uniform mat4 u_MVPMatrix;
9923
9765
  uniform mat4 u_ModelMatrix;
@@ -9958,7 +9800,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
9958
9800
  }
9959
9801
  `;
9960
9802
 
9961
- // src/modules-webgl1/lighting/pbr/pbr-fragment.glsl.ts
9803
+ // src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts
9962
9804
  var fs27 = glsl`\
9963
9805
  #if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
9964
9806
  # error PBR fragment shader: Texture LOD is not available
@@ -9968,15 +9810,6 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
9968
9810
  # error PBR fragment shader: Derivatives are not available
9969
9811
  #endif
9970
9812
 
9971
- // WebGL 1.0 does not support non-constant in for loops
9972
- // This provides an easy way to handle these cases
9973
- // and still take advantage of WebGL 2.0
9974
- #if (__VERSION__ < 300)
9975
- #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)
9976
- #else
9977
- #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
9978
- #endif
9979
-
9980
9813
  precision highp float;
9981
9814
 
9982
9815
  uniform bool pbr_uUnlit;
@@ -10305,7 +10138,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
10305
10138
  color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);
10306
10139
 
10307
10140
  // Apply directional light
10308
- SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) {
10141
+ for(int i = 0, i < lighting_uDirectionalLightCount, i++) {
10309
10142
  if (i < lighting_uDirectionalLightCount) {
10310
10143
  PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);
10311
10144
  color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);
@@ -10313,7 +10146,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
10313
10146
  }
10314
10147
 
10315
10148
  // Apply point light
10316
- SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) {
10149
+ for(int i = 0, i < lighting_uPointLightCount, i++) {
10317
10150
  if (i < lighting_uPointLightCount) {
10318
10151
  PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);
10319
10152
  float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));