@luma.gl/shadertools 9.1.0-alpha.1 → 9.1.0-alpha.9

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 (232) hide show
  1. package/dist/dist.dev.js +816 -483
  2. package/dist/dist.min.js +2325 -1622
  3. package/dist/index.cjs +2669 -1808
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +29 -28
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +8 -12
  8. package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -1
  9. package/dist/lib/glsl-utils/shader-utils.js +2 -3
  10. package/dist/lib/shader-assembler.d.ts +3 -4
  11. package/dist/lib/shader-assembler.d.ts.map +1 -1
  12. package/dist/lib/shader-assembler.js +3 -2
  13. package/dist/lib/shader-assembly/assemble-shaders.d.ts +4 -3
  14. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  15. package/dist/lib/shader-assembly/assemble-shaders.js +43 -16
  16. package/dist/lib/shader-assembly/platform-defines.d.ts.map +1 -1
  17. package/dist/lib/shader-assembly/platform-defines.js +14 -6
  18. package/dist/lib/shader-module/shader-module-dependencies.d.ts +53 -0
  19. package/dist/lib/shader-module/shader-module-dependencies.d.ts.map +1 -0
  20. package/dist/lib/{shader-assembly/resolve-modules.js → shader-module/shader-module-dependencies.js} +38 -14
  21. package/dist/lib/shader-module/shader-module.d.ts +29 -11
  22. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  23. package/dist/lib/shader-module/shader-module.js +76 -6
  24. package/dist/lib/shader-module/shader-pass.d.ts +3 -2
  25. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  26. package/dist/module-injectors.d.ts +2 -2
  27. package/dist/module-injectors.d.ts.map +1 -1
  28. package/dist/module-injectors.js +13 -10
  29. package/dist/modules/engine/geometry/geometry.d.ts.map +1 -1
  30. package/dist/modules/engine/geometry/geometry.js +12 -8
  31. package/dist/modules/engine/picking/picking.d.ts +4 -4
  32. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  33. package/dist/modules/engine/picking/picking.js +103 -66
  34. package/dist/modules/engine/project/project.d.ts +2 -2
  35. package/dist/modules/engine/project/project.d.ts.map +1 -1
  36. package/dist/modules/engine/project/project.js +36 -22
  37. package/dist/modules/engine/transform/transform.d.ts.map +1 -1
  38. package/dist/modules/engine/transform/transform.js +28 -16
  39. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +9 -7
  40. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  41. package/dist/modules/lighting/gouraud-material/gouraud-material.js +2 -0
  42. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +2 -2
  43. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -1
  44. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +79 -53
  45. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
  46. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
  47. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +38 -23
  48. package/dist/modules/lighting/lights/lighting.d.ts +4 -4
  49. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  50. package/dist/modules/lighting/lights/lighting.js +2 -2
  51. package/dist/modules/lighting/no-material/dirlight.d.ts +4 -4
  52. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  53. package/dist/modules/lighting/no-material/dirlight.js +12 -9
  54. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +1 -1
  55. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
  56. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +304 -181
  57. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +71 -69
  58. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  59. package/dist/modules/lighting/pbr-material/pbr-material.js +4 -2
  60. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +1 -1
  61. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +1 -1
  62. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +38 -20
  63. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +1 -1
  64. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
  65. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +21 -16
  66. package/dist/modules/lighting/phong-material/phong-material.d.ts +12 -12
  67. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  68. package/dist/modules/lighting/phong-material/phong-material.js +3 -3
  69. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
  70. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  71. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +82 -54
  72. package/dist/modules/math/fp32/fp32.d.ts.map +1 -1
  73. package/dist/modules/math/fp32/fp32.js +127 -100
  74. package/dist/modules/math/random/random.d.ts +1 -1
  75. package/dist/modules/math/random/random.d.ts.map +1 -1
  76. package/dist/modules/math/random/random.js +3 -3
  77. package/dist/modules/module-injectors.d.ts +2 -2
  78. package/dist/modules/module-injectors.d.ts.map +1 -1
  79. package/dist/modules/module-injectors.js +13 -10
  80. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +4 -1
  81. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  82. package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js +16 -12
  83. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts +4 -1
  84. package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
  85. package/dist/modules/postprocessing/image-adjust-filters/denoise.js +21 -17
  86. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts +5 -2
  87. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  88. package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js +29 -22
  89. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts +4 -1
  90. package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
  91. package/dist/modules/postprocessing/image-adjust-filters/noise.js +14 -10
  92. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts +4 -1
  93. package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
  94. package/dist/modules/postprocessing/image-adjust-filters/sepia.js +17 -12
  95. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts +4 -1
  96. package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  97. package/dist/modules/postprocessing/image-adjust-filters/vibrance.js +12 -9
  98. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts +4 -1
  99. package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
  100. package/dist/modules/postprocessing/image-adjust-filters/vignette.js +13 -10
  101. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +5 -2
  102. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  103. package/dist/modules/postprocessing/image-blur-filters/tiltshift.js +40 -26
  104. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +5 -2
  105. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  106. package/dist/modules/postprocessing/image-blur-filters/triangleblur.js +32 -19
  107. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +4 -1
  108. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  109. package/dist/modules/postprocessing/image-blur-filters/zoomblur.js +2 -0
  110. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +4 -1
  111. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  112. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js +31 -27
  113. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +4 -1
  114. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  115. package/dist/modules/postprocessing/image-fun-filters/dotscreen.js +19 -15
  116. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts +8 -5
  117. package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
  118. package/dist/modules/postprocessing/image-fun-filters/edgework.js +53 -42
  119. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +4 -1
  120. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  121. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js +41 -33
  122. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts +4 -1
  123. package/dist/modules/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
  124. package/dist/modules/postprocessing/image-fun-filters/ink.js +27 -25
  125. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +2 -1
  126. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  127. package/dist/modules/postprocessing/image-fun-filters/magnify.js +17 -16
  128. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +5 -2
  129. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  130. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js +24 -20
  131. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts +5 -2
  132. package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
  133. package/dist/modules/postprocessing/image-warp-filters/swirl.js +26 -22
  134. package/dist/modules/postprocessing/image-warp-filters/warp.d.ts +2 -1
  135. package/dist/modules/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
  136. package/dist/modules/postprocessing/image-warp-filters/warp.js +9 -8
  137. package/dist/modules-webgl1/geometry/geometry.d.ts.map +1 -1
  138. package/dist/modules-webgl1/geometry/geometry.js +12 -8
  139. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +1 -1
  140. package/dist/modules-webgl1/lighting/dirlight/dirlight.js +8 -5
  141. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +1 -1
  142. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +1 -1
  143. package/dist/modules-webgl1/lighting/lights/lights-glsl.js +19 -11
  144. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +1 -1
  145. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +1 -1
  146. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +268 -157
  147. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +1 -1
  148. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +1 -1
  149. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +16 -12
  150. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +1 -1
  151. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +1 -1
  152. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +64 -55
  153. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
  154. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
  155. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +113 -81
  156. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +1 -1
  157. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +1 -1
  158. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +588 -433
  159. package/dist/modules-webgl1/project/project.d.ts +2 -2
  160. package/dist/modules-webgl1/project/project.d.ts.map +1 -1
  161. package/dist/modules-webgl1/project/project.js +5 -4
  162. package/package.json +2 -2
  163. package/src/index.ts +78 -32
  164. package/src/lib/glsl-utils/shader-utils.ts +1 -3
  165. package/src/lib/shader-assembler.ts +7 -8
  166. package/src/lib/shader-assembly/assemble-shaders.ts +52 -20
  167. package/src/lib/shader-assembly/platform-defines.ts +5 -6
  168. package/src/lib/shader-module/shader-module-dependencies.ts +112 -0
  169. package/src/lib/shader-module/shader-module.ts +129 -18
  170. package/src/lib/shader-module/shader-pass.ts +3 -2
  171. package/src/module-injectors.ts +2 -4
  172. package/src/modules/engine/geometry/geometry.ts +2 -3
  173. package/src/modules/engine/picking/picking.ts +7 -5
  174. package/src/modules/engine/project/project.ts +2 -3
  175. package/src/modules/engine/transform/transform.ts +1 -3
  176. package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
  177. package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +2 -4
  178. package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +1 -3
  179. package/src/modules/lighting/lights/lighting.ts +4 -2
  180. package/src/modules/lighting/no-material/dirlight.ts +6 -5
  181. package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +1 -2
  182. package/src/modules/lighting/pbr-material/pbr-material.ts +44 -38
  183. package/src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts +1 -3
  184. package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +1 -3
  185. package/src/modules/lighting/phong-material/phong-material.ts +4 -3
  186. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +2 -4
  187. package/src/modules/math/fp32/fp32.ts +1 -2
  188. package/src/modules/math/random/random.ts +1 -2
  189. package/src/modules/module-injectors.ts +2 -4
  190. package/src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts +6 -2
  191. package/src/modules/postprocessing/image-adjust-filters/denoise.ts +7 -3
  192. package/src/modules/postprocessing/image-adjust-filters/huesaturation.ts +9 -4
  193. package/src/modules/postprocessing/image-adjust-filters/noise.ts +6 -2
  194. package/src/modules/postprocessing/image-adjust-filters/sepia.ts +6 -2
  195. package/src/modules/postprocessing/image-adjust-filters/vibrance.ts +5 -2
  196. package/src/modules/postprocessing/image-adjust-filters/vignette.ts +11 -4
  197. package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +6 -2
  198. package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +6 -2
  199. package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +5 -0
  200. package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +6 -2
  201. package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +6 -2
  202. package/src/modules/postprocessing/image-fun-filters/edgework.ts +10 -4
  203. package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +6 -2
  204. package/src/modules/postprocessing/image-fun-filters/ink.ts +8 -3
  205. package/src/modules/postprocessing/image-fun-filters/magnify.ts +3 -2
  206. package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +6 -2
  207. package/src/modules/postprocessing/image-warp-filters/swirl.ts +8 -2
  208. package/src/modules/postprocessing/image-warp-filters/warp.ts +3 -2
  209. package/src/modules-webgl1/geometry/geometry.ts +2 -3
  210. package/src/modules-webgl1/lighting/dirlight/dirlight.ts +1 -2
  211. package/src/modules-webgl1/lighting/lights/lights-glsl.ts +1 -3
  212. package/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts +1 -2
  213. package/src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts +1 -3
  214. package/src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts +1 -3
  215. package/src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts +1 -3
  216. package/src/modules-webgl1/math/fp64/fp64-functions-glsl.ts +1 -3
  217. package/src/modules-webgl1/project/project.ts +1 -2
  218. package/dist/lib/glsl-utils/highlight.d.ts +0 -6
  219. package/dist/lib/glsl-utils/highlight.d.ts.map +0 -1
  220. package/dist/lib/glsl-utils/highlight.js +0 -9
  221. package/dist/lib/shader-assembly/resolve-modules.d.ts +0 -40
  222. package/dist/lib/shader-assembly/resolve-modules.d.ts.map +0 -1
  223. package/dist/lib/shader-module/normalize-shader-module.d.ts +0 -3
  224. package/dist/lib/shader-module/normalize-shader-module.d.ts.map +0 -1
  225. package/dist/lib/shader-module/normalize-shader-module.js +0 -14
  226. package/dist/lib/shader-module/shader-module-instance.d.ts +0 -28
  227. package/dist/lib/shader-module/shader-module-instance.d.ts.map +0 -1
  228. package/dist/lib/shader-module/shader-module-instance.js +0 -126
  229. package/src/lib/glsl-utils/highlight.ts +0 -11
  230. package/src/lib/shader-assembly/resolve-modules.ts +0 -81
  231. package/src/lib/shader-module/normalize-shader-module.ts +0 -17
  232. package/src/lib/shader-module/shader-module-instance.ts +0 -167
package/dist/dist.dev.js CHANGED
@@ -54,8 +54,6 @@ var __exports__ = (() => {
54
54
  var bundle_exports = {};
55
55
  __export(bundle_exports, {
56
56
  ShaderAssembler: () => ShaderAssembler,
57
- ShaderModuleInstance: () => ShaderModuleInstance,
58
- _ShaderModuleInstance: () => ShaderModuleInstance,
59
57
  _getDependencyGraph: () => getDependencyGraph,
60
58
  _resolveModules: () => resolveModules,
61
59
  _warp: () => warp,
@@ -63,6 +61,7 @@ var __exports__ = (() => {
63
61
  brightnessContrast: () => brightnessContrast,
64
62
  bulgePinch: () => bulgePinch,
65
63
  capitalize: () => capitalize,
64
+ checkShaderModuleDeprecations: () => checkShaderModuleDeprecations,
66
65
  colorHalftone: () => colorHalftone,
67
66
  combineInjects: () => combineInjects,
68
67
  convertToVec4: () => convertToVec4,
@@ -85,17 +84,20 @@ var __exports__ = (() => {
85
84
  getQualifierDetails: () => getQualifierDetails,
86
85
  getShaderInfo: () => getShaderInfo,
87
86
  getShaderLayoutFromWGSL: () => getShaderLayoutFromWGSL,
88
- glsl: () => glsl,
87
+ getShaderModuleDependencies: () => getShaderModuleDependencies,
88
+ getShaderModuleSource: () => getShaderModuleSource,
89
+ getShaderModuleUniforms: () => getShaderModuleUniforms,
89
90
  gouraudLighting: () => gouraudLighting,
90
91
  gouraudMaterial: () => gouraudMaterial,
91
92
  hexagonalPixelate: () => hexagonalPixelate,
92
93
  hueSaturation: () => hueSaturation,
94
+ initializeShaderModule: () => initializeShaderModule,
95
+ initializeShaderModules: () => initializeShaderModules,
93
96
  ink: () => ink,
94
97
  lighting: () => lighting,
95
98
  lights1: () => lights,
96
99
  magnify: () => magnify,
97
100
  noise: () => noise,
98
- normalizeShaderModule: () => normalizeShaderModule,
99
101
  pbr: () => pbr,
100
102
  pbrMaterial: () => pbrMaterial,
101
103
  phongLighting: () => phongLighting,
@@ -117,9 +119,6 @@ var __exports__ = (() => {
117
119
  });
118
120
  __reExport(bundle_exports, __toESM(require_core(), 1));
119
121
 
120
- // src/lib/glsl-utils/highlight.ts
121
- var glsl = (x) => `${x}`;
122
-
123
122
  // src/lib/utils/assert.ts
124
123
  function assert(condition, message) {
125
124
  if (!condition) {
@@ -194,13 +193,16 @@ var __exports__ = (() => {
194
193
  }
195
194
 
196
195
  // src/module-injectors.ts
197
- var MODULE_INJECTORS_VS = glsl`\
198
- #ifdef MODULE_LOGDEPTH
196
+ var MODULE_INJECTORS_VS = (
197
+ /* glsl */
198
+ `#ifdef MODULE_LOGDEPTH
199
199
  logdepth_adjustPosition(gl_Position);
200
200
  #endif
201
- `;
202
- var MODULE_INJECTORS_FS = glsl`\
203
- #ifdef MODULE_MATERIAL
201
+ `
202
+ );
203
+ var MODULE_INJECTORS_FS = (
204
+ /* glsl */
205
+ `#ifdef MODULE_MATERIAL
204
206
  gl_FragColor = material_filterColor(gl_FragColor);
205
207
  #endif
206
208
 
@@ -220,7 +222,8 @@ var __exports__ = (() => {
220
222
  #ifdef MODULE_LOGDEPTH
221
223
  logdepth_setFragDepth();
222
224
  #endif
223
- `;
225
+ `
226
+ );
224
227
 
225
228
  // src/lib/shader-assembly/shader-injections.ts
226
229
  var MODULE_INJECTORS = {
@@ -321,148 +324,71 @@ ${inject[key]}` : inject[key];
321
324
  return result;
322
325
  }
323
326
 
324
- // src/lib/shader-module/shader-module-instance.ts
325
- var index = 1;
326
- var ShaderModuleInstance = class {
327
- name;
328
- vs;
329
- fs;
330
- getModuleUniforms;
331
- dependencies;
332
- deprecations;
333
- defines;
334
- injections;
335
- uniforms = {};
336
- uniformTypes = {};
337
- static instantiateModules(modules) {
338
- return modules.map((module) => {
339
- if (module instanceof ShaderModuleInstance) {
340
- return module;
341
- }
342
- assert(
343
- typeof module !== "string",
344
- `Shader module use by name is deprecated. Import shader module '${JSON.stringify(
345
- module
346
- )}' and use it directly.`
347
- );
348
- if (!module.name) {
349
- console.warn("shader module has no name");
350
- module.name = `shader-module-${index++}`;
351
- }
352
- const moduleObject = new ShaderModuleInstance(module);
353
- moduleObject.dependencies = ShaderModuleInstance.instantiateModules(
354
- module.dependencies || []
355
- );
356
- return moduleObject;
357
- });
358
- }
359
- constructor(props) {
360
- const {
361
- name,
362
- vs: vs6,
363
- fs: fs28,
364
- dependencies = [],
365
- uniformPropTypes = {},
366
- getUniforms: getUniforms9,
367
- deprecations = [],
368
- defines = {},
369
- inject = {}
370
- } = props;
371
- assert(typeof name === "string");
372
- this.name = name;
373
- this.vs = vs6;
374
- this.fs = fs28;
375
- this.getModuleUniforms = getUniforms9;
376
- this.dependencies = ShaderModuleInstance.instantiateModules(dependencies);
377
- this.deprecations = this._parseDeprecationDefinitions(deprecations);
378
- this.defines = defines;
379
- this.injections = normalizeInjections(inject);
380
- if (uniformPropTypes) {
381
- this.uniforms = makePropValidators(uniformPropTypes);
382
- }
383
- }
384
- // Extracts the source code chunk for the specified shader type from the named shader module
385
- getModuleSource(stage) {
386
- let moduleSource;
387
- switch (stage) {
388
- case "vertex":
389
- moduleSource = this.vs || "";
390
- break;
391
- case "fragment":
392
- moduleSource = this.fs || "";
393
- break;
394
- default:
395
- assert(false);
396
- }
397
- const moduleName = this.name.toUpperCase().replace(/[^0-9a-z]/gi, "_");
398
- return `// ----- MODULE ${this.name} ---------------
399
-
400
- #define MODULE_${moduleName}
401
- ${moduleSource}
402
-
403
- `;
404
- }
405
- getUniforms(userProps, uniforms) {
406
- if (this.getModuleUniforms) {
407
- return this.getModuleUniforms(userProps, uniforms);
408
- }
409
- return getValidatedProperties(userProps, this.uniforms, this.name);
410
- }
411
- getDefines() {
412
- return this.defines;
327
+ // src/lib/shader-module/shader-module.ts
328
+ function initializeShaderModules(modules) {
329
+ modules.map((module) => initializeShaderModule(module));
330
+ }
331
+ function initializeShaderModule(module) {
332
+ if (module.instance) {
333
+ return;
413
334
  }
414
- // Warn about deprecated uniforms or functions
415
- checkDeprecations(shaderSource, log2) {
416
- this.deprecations.forEach((def) => {
417
- if (def.regex?.test(shaderSource)) {
418
- if (def.deprecated) {
419
- log2.deprecated(def.old, def.new)();
420
- } else {
421
- log2.removed(def.old, def.new)();
422
- }
423
- }
424
- });
335
+ initializeShaderModules(module.dependencies || []);
336
+ const {
337
+ uniformPropTypes = {},
338
+ deprecations = [],
339
+ // defines = {},
340
+ inject = {}
341
+ } = module;
342
+ const instance = {
343
+ normalizedInjections: normalizeInjections(inject),
344
+ parsedDeprecations: parseDeprecationDefinitions(deprecations)
345
+ };
346
+ if (uniformPropTypes) {
347
+ instance.propValidators = makePropValidators(uniformPropTypes);
425
348
  }
426
- _parseDeprecationDefinitions(deprecations) {
427
- deprecations.forEach((def) => {
428
- switch (def.type) {
429
- case "function":
430
- def.regex = new RegExp(`\\b${def.old}\\(`);
431
- break;
432
- default:
433
- def.regex = new RegExp(`${def.type} ${def.old};`);
434
- }
435
- });
436
- return deprecations;
349
+ module.instance = instance;
350
+ }
351
+ function getShaderModuleUniforms(module, props, oldUniforms) {
352
+ initializeShaderModule(module);
353
+ const uniforms = oldUniforms || { ...module.defaultUniforms };
354
+ if (module.getUniforms) {
355
+ return module.getUniforms(props, uniforms);
437
356
  }
438
- _defaultGetUniforms(opts = {}) {
439
- const uniforms = {};
440
- const propTypes = this.uniforms;
441
- for (const key in propTypes) {
442
- const propDef = propTypes[key];
443
- if (key in opts && !propDef.private) {
444
- if (propDef.validate) {
445
- assert(propDef.validate(opts[key], propDef), `${this.name}: invalid ${key}`);
446
- }
447
- uniforms[key] = opts[key];
357
+ return getValidatedProperties(props, module.instance?.propValidators, module.name);
358
+ }
359
+ function checkShaderModuleDeprecations(shaderModule, shaderSource, log2) {
360
+ shaderModule.deprecations?.forEach((def) => {
361
+ if (def.regex?.test(shaderSource)) {
362
+ if (def.deprecated) {
363
+ log2.deprecated(def.old, def.new)();
448
364
  } else {
449
- uniforms[key] = propDef.value;
365
+ log2.removed(def.old, def.new)();
450
366
  }
451
367
  }
452
- return uniforms;
453
- }
454
- };
455
-
456
- // src/lib/shader-assembly/resolve-modules.ts
457
- function resolveModules(modules) {
458
- const instances = ShaderModuleInstance.instantiateModules(modules);
459
- return getShaderDependencies(instances);
368
+ });
460
369
  }
461
- function getShaderDependencies(modules) {
370
+ function parseDeprecationDefinitions(deprecations) {
371
+ deprecations.forEach((def) => {
372
+ switch (def.type) {
373
+ case "function":
374
+ def.regex = new RegExp(`\\b${def.old}\\(`);
375
+ break;
376
+ default:
377
+ def.regex = new RegExp(`${def.type} ${def.old};`);
378
+ }
379
+ });
380
+ return deprecations;
381
+ }
382
+
383
+ // src/lib/shader-module/shader-module-dependencies.ts
384
+ function getShaderModuleDependencies(modules) {
385
+ initializeShaderModules(modules);
462
386
  const moduleMap = {};
463
387
  const moduleDepth = {};
464
388
  getDependencyGraph({ modules, level: 0, moduleMap, moduleDepth });
465
- return Object.keys(moduleDepth).sort((a, b) => moduleDepth[b] - moduleDepth[a]).map((name) => moduleMap[name]);
389
+ const dependencies = Object.keys(moduleDepth).sort((a, b) => moduleDepth[b] - moduleDepth[a]).map((name) => moduleMap[name]);
390
+ initializeShaderModules(dependencies);
391
+ return dependencies;
466
392
  }
467
393
  function getDependencyGraph(options) {
468
394
  const { modules, level, moduleMap, moduleDepth } = options;
@@ -481,49 +407,71 @@ ${moduleSource}
481
407
  }
482
408
  }
483
409
  }
410
+ function getShaderDependencies(modules) {
411
+ initializeShaderModules(modules);
412
+ const moduleMap = {};
413
+ const moduleDepth = {};
414
+ getDependencyGraph({ modules, level: 0, moduleMap, moduleDepth });
415
+ modules = Object.keys(moduleDepth).sort((a, b) => moduleDepth[b] - moduleDepth[a]).map((name) => moduleMap[name]);
416
+ initializeShaderModules(modules);
417
+ return modules;
418
+ }
419
+ function resolveModules(modules) {
420
+ return getShaderDependencies(modules);
421
+ }
484
422
 
485
423
  // src/lib/shader-assembly/platform-defines.ts
486
424
  function getPlatformShaderDefines(platformInfo) {
487
425
  switch (platformInfo?.gpu.toLowerCase()) {
488
426
  case "apple":
489
- return glsl`\
490
- #define APPLE_GPU
427
+ return (
428
+ /* glsl */
429
+ `#define APPLE_GPU
491
430
  // Apple optimizes away the calculation necessary for emulated fp64
492
431
  #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
493
432
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
494
433
  // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
495
434
  #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
496
- `;
435
+ `
436
+ );
497
437
  case "nvidia":
498
- return glsl`\
499
- #define NVIDIA_GPU
438
+ return (
439
+ /* glsl */
440
+ `#define NVIDIA_GPU
500
441
  // Nvidia optimizes away the calculation necessary for emulated fp64
501
442
  #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
502
- `;
443
+ `
444
+ );
503
445
  case "intel":
504
- return glsl`\
505
- #define INTEL_GPU
446
+ return (
447
+ /* glsl */
448
+ `#define INTEL_GPU
506
449
  // Intel optimizes away the calculation necessary for emulated fp64
507
450
  #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
508
451
  // Intel's built-in 'tan' function doesn't have acceptable precision
509
452
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
510
453
  // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
511
454
  #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
512
- `;
455
+ `
456
+ );
513
457
  case "amd":
514
- return glsl`\
515
- #define AMD_GPU
516
- `;
458
+ return (
459
+ /* glsl */
460
+ `#define AMD_GPU
461
+ `
462
+ );
517
463
  default:
518
- return glsl`\
519
- #define DEFAULT_GPU
464
+ return (
465
+ /* glsl */
466
+ `#define DEFAULT_GPU
520
467
  // Prevent driver from optimizing away the calculation necessary for emulated fp64
521
468
  #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
522
469
  // Headless Chrome's software shader 'tan' function doesn't have acceptable precision
523
470
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
524
471
  // If the GPU doesn't have full 32 bits precision, will causes overflow
525
472
  #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
526
- `;
473
+ `
474
+ );
527
475
  }
528
476
  }
529
477
 
@@ -661,11 +609,13 @@ ${moduleSource}
661
609
 
662
610
  ${DECLARATION_INJECT_MARKER}
663
611
  `;
664
- var FRAGMENT_SHADER_PROLOGUE = glsl`\
665
- precision highp float;
666
- `;
612
+ var FRAGMENT_SHADER_PROLOGUE = (
613
+ /* glsl */
614
+ `precision highp float;
615
+ `
616
+ );
667
617
  function assembleWGSLShader(options) {
668
- const modules = resolveModules(options.modules || []);
618
+ const modules = getShaderModuleDependencies(options.modules || []);
669
619
  return {
670
620
  source: assembleShaderWGSL(options.platformInfo, {
671
621
  ...options,
@@ -678,7 +628,7 @@ precision highp float;
678
628
  }
679
629
  function assembleGLSLShaderPair(options) {
680
630
  const { vs: vs6, fs: fs28 } = options;
681
- const modules = resolveModules(options.modules || []);
631
+ const modules = getShaderModuleDependencies(options.modules || []);
682
632
  return {
683
633
  vs: assembleShaderGLSL(options.platformInfo, {
684
634
  ...options,
@@ -736,9 +686,9 @@ precision highp float;
736
686
  const modulesToInject = platformInfo.type !== "webgpu" ? modules : [];
737
687
  for (const module of modulesToInject) {
738
688
  if (log2) {
739
- module.checkDeprecations(coreSource, log2);
689
+ checkShaderModuleDeprecations(module, coreSource, log2);
740
690
  }
741
- const moduleSource = module.getModuleSource(stage, "wgsl");
691
+ const moduleSource = getShaderModuleSource(module, stage);
742
692
  assembledSource += moduleSource;
743
693
  const injections = module.injections[stage];
744
694
  for (const key in injections) {
@@ -782,7 +732,7 @@ precision highp float;
782
732
  const coreSource = sourceLines.slice(1).join("\n");
783
733
  const allDefines = {};
784
734
  modules.forEach((module) => {
785
- Object.assign(allDefines, module.getDefines());
735
+ Object.assign(allDefines, module.defines);
786
736
  });
787
737
  Object.assign(allDefines, defines);
788
738
  let assembledSource = "";
@@ -795,6 +745,7 @@ precision highp float;
795
745
  // ----- PROLOGUE -------------------------
796
746
  ${getShaderNameDefine({ id, source, stage })}
797
747
  ${`#define SHADER_TYPE_${stage.toUpperCase()}`}
748
+
798
749
  ${getPlatformShaderDefines(platformInfo)}
799
750
  ${stage === "fragment" ? FRAGMENT_SHADER_PROLOGUE : ""}
800
751
 
@@ -831,11 +782,11 @@ ${getApplicationDefines(allDefines)}
831
782
  }
832
783
  for (const module of modules) {
833
784
  if (log2) {
834
- module.checkDeprecations(coreSource, log2);
785
+ checkShaderModuleDeprecations(module, coreSource, log2);
835
786
  }
836
- const moduleSource = module.getModuleSource(stage);
787
+ const moduleSource = getShaderModuleSource(module, stage);
837
788
  assembledSource += moduleSource;
838
- const injections = module.injections[stage];
789
+ const injections = module.instance?.normalizedInjections[stage] || {};
839
790
  for (const key in injections) {
840
791
  const match = /^(v|f)s:#([\w-]+)$/.exec(key);
841
792
  if (match) {
@@ -864,7 +815,7 @@ ${getApplicationDefines(allDefines)}
864
815
  return function getUniforms9(opts) {
865
816
  const uniforms = {};
866
817
  for (const module of modules) {
867
- const moduleUniforms = module.getUniforms(opts, uniforms);
818
+ const moduleUniforms = module.getUniforms?.(opts, uniforms);
868
819
  Object.assign(uniforms, moduleUniforms);
869
820
  }
870
821
  return uniforms;
@@ -874,9 +825,7 @@ ${getApplicationDefines(allDefines)}
874
825
  const { id, source, stage } = options;
875
826
  const injectShaderName = id && source.indexOf("SHADER_NAME") === -1;
876
827
  return injectShaderName ? `
877
- #define SHADER_NAME ${id}_${stage}
878
-
879
- ` : "";
828
+ #define SHADER_NAME ${id}_${stage}` : "";
880
829
  }
881
830
  function getApplicationDefines(defines = {}) {
882
831
  let sourceText = "";
@@ -889,6 +838,32 @@ ${getApplicationDefines(allDefines)}
889
838
  }
890
839
  return sourceText;
891
840
  }
841
+ function getShaderModuleSource(module, stage) {
842
+ let moduleSource;
843
+ switch (stage) {
844
+ case "vertex":
845
+ moduleSource = module.vs || "";
846
+ break;
847
+ case "fragment":
848
+ moduleSource = module.fs || "";
849
+ break;
850
+ case "wgsl":
851
+ moduleSource = module.source || "";
852
+ break;
853
+ default:
854
+ assert(false);
855
+ }
856
+ if (!module.name) {
857
+ throw new Error("Shader module must have a name");
858
+ }
859
+ const moduleName = module.name.toUpperCase().replace(/[^0-9a-z]/gi, "_");
860
+ return `// ----- MODULE ${module.name} ---------------
861
+
862
+ #define MODULE_${moduleName}
863
+ ${moduleSource}
864
+
865
+ `;
866
+ }
892
867
 
893
868
  // src/lib/preprocessor/preprocessor.ts
894
869
  var IFDEF_REGEXP = /^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/;
@@ -998,9 +973,7 @@ ${getApplicationDefines(allDefines)}
998
973
  * Dedupe and combine with default modules
999
974
  */
1000
975
  _getModuleList(appModules = []) {
1001
- const modules = new Array(
1002
- this._defaultModules.length + appModules.length
1003
- );
976
+ const modules = new Array(this._defaultModules.length + appModules.length);
1004
977
  const seen = {};
1005
978
  let count = 0;
1006
979
  for (let i = 0, len = this._defaultModules.length; i < len; ++i) {
@@ -1018,31 +991,22 @@ ${getApplicationDefines(allDefines)}
1018
991
  }
1019
992
  }
1020
993
  modules.length = count;
1021
- return ShaderModuleInstance.instantiateModules(modules);
994
+ initializeShaderModules(modules);
995
+ return modules;
1022
996
  }
1023
997
  };
1024
998
  var ShaderAssembler = _ShaderAssembler;
1025
999
  /** Default ShaderAssembler instance */
1026
1000
  __publicField(ShaderAssembler, "defaultShaderAssembler");
1027
1001
 
1028
- // src/lib/shader-module/normalize-shader-module.ts
1029
- function normalizeShaderModule(module) {
1030
- if (!module.normalized) {
1031
- module.normalized = true;
1032
- if (module.uniformPropTypes && !module.getUniforms) {
1033
- const shaderModule = new ShaderModuleInstance(module);
1034
- module.getUniforms = shaderModule.getUniforms.bind(shaderModule);
1035
- }
1036
- }
1037
- return module;
1038
- }
1039
-
1040
1002
  // src/lib/glsl-utils/shader-utils.ts
1041
- var FS_GLES = glsl`\
1042
- out vec4 transform_output;
1003
+ var FS_GLES = (
1004
+ /* glsl */
1005
+ `out vec4 transform_output;
1043
1006
  void main() {
1044
1007
  transform_output = vec4(0);
1045
- }`;
1008
+ }`
1009
+ );
1046
1010
  var FS300 = `#version 300 es
1047
1011
  ${FS_GLES}`;
1048
1012
  function getQualifierDetails(line, qualifiers) {
@@ -1139,11 +1103,11 @@ void main() {
1139
1103
  return generateGLSLUniformDeclarations(module, options);
1140
1104
  }
1141
1105
  function generateGLSLUniformDeclarations(module, options) {
1142
- const glsl2 = [];
1106
+ const glsl = [];
1143
1107
  switch (options.uniforms) {
1144
1108
  case "scoped-interface-blocks":
1145
1109
  case "unscoped-interface-blocks":
1146
- glsl2.push(`uniform ${capitalize(module.name)} {`);
1110
+ glsl.push(`uniform ${capitalize(module.name)} {`);
1147
1111
  break;
1148
1112
  case "uniforms":
1149
1113
  }
@@ -1151,26 +1115,26 @@ void main() {
1151
1115
  const glslUniformType = getGLSLUniformType(uniformFormat);
1152
1116
  switch (options.uniforms) {
1153
1117
  case "scoped-interface-blocks":
1154
- glsl2.push(` ${glslUniformType} ${uniformName};`);
1118
+ glsl.push(` ${glslUniformType} ${uniformName};`);
1155
1119
  break;
1156
1120
  case "unscoped-interface-blocks":
1157
- glsl2.push(` ${glslUniformType} ${module.name}_${uniformName};`);
1121
+ glsl.push(` ${glslUniformType} ${module.name}_${uniformName};`);
1158
1122
  break;
1159
1123
  case "uniforms":
1160
- glsl2.push(`uniform ${glslUniformType} ${module.name}_${uniformName};`);
1124
+ glsl.push(`uniform ${glslUniformType} ${module.name}_${uniformName};`);
1161
1125
  }
1162
1126
  }
1163
1127
  switch (options.uniforms) {
1164
1128
  case "scoped-interface-blocks":
1165
- glsl2.push(`} ${module.name};`);
1129
+ glsl.push(`} ${module.name};`);
1166
1130
  break;
1167
1131
  case "unscoped-interface-blocks":
1168
- glsl2.push("};");
1132
+ glsl.push("};");
1169
1133
  break;
1170
1134
  case "uniforms":
1171
1135
  }
1172
- glsl2.push("");
1173
- return glsl2.join("\n");
1136
+ glsl.push("");
1137
+ return glsl.join("\n");
1174
1138
  }
1175
1139
  function getGLSLUniformType(uniformFormat) {
1176
1140
  const UNIFORM_TYPE_TO_GLSL = {
@@ -1196,8 +1160,8 @@ void main() {
1196
1160
  "mat4x3<f32>": "mat4x3",
1197
1161
  "mat4x4<f32>": "mat4"
1198
1162
  };
1199
- const glsl2 = UNIFORM_TYPE_TO_GLSL[uniformFormat];
1200
- return glsl2;
1163
+ const glsl = UNIFORM_TYPE_TO_GLSL[uniformFormat];
1164
+ return glsl;
1201
1165
  }
1202
1166
 
1203
1167
  // src/lib/shader-generator/wgsl/generate-wgsl.ts
@@ -1488,6 +1452,7 @@ void main() {
1488
1452
  return "assign";
1489
1453
  }
1490
1454
  search(callback) {
1455
+ this.variable.search(callback);
1491
1456
  this.value.search(callback);
1492
1457
  }
1493
1458
  };
@@ -1567,6 +1532,15 @@ void main() {
1567
1532
  return "enable";
1568
1533
  }
1569
1534
  };
1535
+ var Requires = class extends Statement {
1536
+ constructor(extensions) {
1537
+ super();
1538
+ this.extensions = extensions;
1539
+ }
1540
+ get astNodeType() {
1541
+ return "requires";
1542
+ }
1543
+ };
1570
1544
  var Diagnostic = class extends Statement {
1571
1545
  constructor(severity, rule) {
1572
1546
  super();
@@ -1838,6 +1812,9 @@ void main() {
1838
1812
  }
1839
1813
  search(callback) {
1840
1814
  callback(this);
1815
+ if (this.postfix) {
1816
+ this.postfix.search(callback);
1817
+ }
1841
1818
  }
1842
1819
  evaluate(context) {
1843
1820
  const constant = context.constants.get(this.name);
@@ -1931,6 +1908,15 @@ void main() {
1931
1908
  this.searchBlock(this.contents, callback);
1932
1909
  }
1933
1910
  };
1911
+ var ArrayIndex = class extends Expression {
1912
+ constructor(index) {
1913
+ super();
1914
+ this.index = index;
1915
+ }
1916
+ search(callback) {
1917
+ this.index.search(callback);
1918
+ }
1919
+ };
1934
1920
  var Operator = class extends Expression {
1935
1921
  constructor() {
1936
1922
  super();
@@ -2178,10 +2164,10 @@ void main() {
2178
2164
  continue: new TokenType("continue", TokenClass.keyword, "continue"),
2179
2165
  continuing: new TokenType("continuing", TokenClass.keyword, "continuing"),
2180
2166
  default: new TokenType("default", TokenClass.keyword, "default"),
2167
+ diagnostic: new TokenType("diagnostic", TokenClass.keyword, "diagnostic"),
2181
2168
  discard: new TokenType("discard", TokenClass.keyword, "discard"),
2182
2169
  else: new TokenType("else", TokenClass.keyword, "else"),
2183
2170
  enable: new TokenType("enable", TokenClass.keyword, "enable"),
2184
- diagnostic: new TokenType("diagnostic", TokenClass.keyword, "diagnostic"),
2185
2171
  fallthrough: new TokenType("fallthrough", TokenClass.keyword, "fallthrough"),
2186
2172
  false: new TokenType("false", TokenClass.keyword, "false"),
2187
2173
  fn: new TokenType("fn", TokenClass.keyword, "fn"),
@@ -2196,6 +2182,7 @@ void main() {
2196
2182
  read: new TokenType("read", TokenClass.keyword, "read"),
2197
2183
  read_write: new TokenType("read_write", TokenClass.keyword, "read_write"),
2198
2184
  return: new TokenType("return", TokenClass.keyword, "return"),
2185
+ requires: new TokenType("requires", TokenClass.keyword, "requires"),
2199
2186
  storage: new TokenType("storage", TokenClass.keyword, "storage"),
2200
2187
  switch: new TokenType("switch", TokenClass.keyword, "switch"),
2201
2188
  true: new TokenType("true", TokenClass.keyword, "true"),
@@ -2259,8 +2246,6 @@ void main() {
2259
2246
  and_and: new TokenType("and_and", TokenClass.token, "&&"),
2260
2247
  arrow: new TokenType("arrow ", TokenClass.token, "->"),
2261
2248
  attr: new TokenType("attr", TokenClass.token, "@"),
2262
- attr_left: new TokenType("attr_left", TokenClass.token, "[["),
2263
- attr_right: new TokenType("attr_right", TokenClass.token, "]]"),
2264
2249
  forward_slash: new TokenType("forward_slash", TokenClass.token, "/"),
2265
2250
  bang: new TokenType("bang", TokenClass.token, "!"),
2266
2251
  bracket_left: new TokenType("bracket_left", TokenClass.token, "["),
@@ -2304,6 +2289,63 @@ void main() {
2304
2289
  shift_right_equal: new TokenType("shift_right_equal", TokenClass.token, ">>="),
2305
2290
  shift_left_equal: new TokenType("shift_left_equal", TokenClass.token, "<<=")
2306
2291
  };
2292
+ TokenTypes.simpleTokens = {
2293
+ "@": _a.tokens.attr,
2294
+ "{": _a.tokens.brace_left,
2295
+ "}": _a.tokens.brace_right,
2296
+ ":": _a.tokens.colon,
2297
+ ",": _a.tokens.comma,
2298
+ "(": _a.tokens.paren_left,
2299
+ ")": _a.tokens.paren_right,
2300
+ ";": _a.tokens.semicolon
2301
+ };
2302
+ TokenTypes.literalTokens = {
2303
+ "&": _a.tokens.and,
2304
+ "&&": _a.tokens.and_and,
2305
+ "->": _a.tokens.arrow,
2306
+ "/": _a.tokens.forward_slash,
2307
+ "!": _a.tokens.bang,
2308
+ "[": _a.tokens.bracket_left,
2309
+ "]": _a.tokens.bracket_right,
2310
+ "=": _a.tokens.equal,
2311
+ "==": _a.tokens.equal_equal,
2312
+ "!=": _a.tokens.not_equal,
2313
+ ">": _a.tokens.greater_than,
2314
+ ">=": _a.tokens.greater_than_equal,
2315
+ ">>": _a.tokens.shift_right,
2316
+ "<": _a.tokens.less_than,
2317
+ "<=": _a.tokens.less_than_equal,
2318
+ "<<": _a.tokens.shift_left,
2319
+ "%": _a.tokens.modulo,
2320
+ "-": _a.tokens.minus,
2321
+ "--": _a.tokens.minus_minus,
2322
+ ".": _a.tokens.period,
2323
+ "+": _a.tokens.plus,
2324
+ "++": _a.tokens.plus_plus,
2325
+ "|": _a.tokens.or,
2326
+ "||": _a.tokens.or_or,
2327
+ "*": _a.tokens.star,
2328
+ "~": _a.tokens.tilde,
2329
+ "_": _a.tokens.underscore,
2330
+ "^": _a.tokens.xor,
2331
+ "+=": _a.tokens.plus_equal,
2332
+ "-=": _a.tokens.minus_equal,
2333
+ "*=": _a.tokens.times_equal,
2334
+ "/=": _a.tokens.division_equal,
2335
+ "%=": _a.tokens.modulo_equal,
2336
+ "&=": _a.tokens.and_equal,
2337
+ "|=": _a.tokens.or_equal,
2338
+ "^=": _a.tokens.xor_equal,
2339
+ ">>=": _a.tokens.shift_right_equal,
2340
+ "<<=": _a.tokens.shift_left_equal
2341
+ };
2342
+ TokenTypes.regexTokens = {
2343
+ decimal_float_literal: _a.tokens.decimal_float_literal,
2344
+ hex_float_literal: _a.tokens.hex_float_literal,
2345
+ int_literal: _a.tokens.int_literal,
2346
+ uint_literal: _a.tokens.uint_literal,
2347
+ ident: _a.tokens.ident
2348
+ };
2307
2349
  TokenTypes.storage_class = [
2308
2350
  _a.keywords.function,
2309
2351
  _a.keywords.private,
@@ -2426,7 +2468,7 @@ void main() {
2426
2468
  _a.keywords.bitcast,
2427
2469
  ..._a.any_texture_type
2428
2470
  ];
2429
- TokenTypes.attribute_name = [_a.tokens.ident, _a.keywords.block];
2471
+ TokenTypes.attribute_name = [_a.tokens.ident, _a.keywords.block, _a.keywords.diagnostic];
2430
2472
  TokenTypes.assignment_operators = [
2431
2473
  _a.tokens.equal,
2432
2474
  _a.tokens.plus_equal,
@@ -2530,7 +2572,32 @@ void main() {
2530
2572
  return true;
2531
2573
  }
2532
2574
  }
2575
+ const simpleToken = TokenTypes.simpleTokens[lexeme];
2576
+ if (simpleToken) {
2577
+ this._addToken(simpleToken);
2578
+ return true;
2579
+ }
2533
2580
  let matchType = TokenTypes.none;
2581
+ const isAlpha = this._isAlpha(lexeme);
2582
+ const isUnderscore = lexeme === "_";
2583
+ if (this._isAlphaNumeric(lexeme)) {
2584
+ let nextChar = this._peekAhead();
2585
+ while (this._isAlphaNumeric(nextChar)) {
2586
+ lexeme += this._advance();
2587
+ nextChar = this._peekAhead();
2588
+ }
2589
+ }
2590
+ if (isAlpha) {
2591
+ const matchedType = TokenTypes.keywords[lexeme];
2592
+ if (matchedType) {
2593
+ this._addToken(matchedType);
2594
+ return true;
2595
+ }
2596
+ }
2597
+ if (isAlpha || isUnderscore) {
2598
+ this._addToken(TokenTypes.tokens.ident);
2599
+ return true;
2600
+ }
2534
2601
  for (; ; ) {
2535
2602
  let matchedType = this._findType(lexeme);
2536
2603
  const nextLexeme = this._peekAhead();
@@ -2586,36 +2653,31 @@ void main() {
2586
2653
  return true;
2587
2654
  }
2588
2655
  _findType(lexeme) {
2589
- for (const name in TokenTypes.keywords) {
2590
- const type = TokenTypes.keywords[name];
2591
- if (this._match(lexeme, type.rule)) {
2592
- return type;
2656
+ for (const name in TokenTypes.regexTokens) {
2657
+ const type2 = TokenTypes.regexTokens[name];
2658
+ if (this._match(lexeme, type2.rule)) {
2659
+ return type2;
2593
2660
  }
2594
2661
  }
2595
- for (const name in TokenTypes.tokens) {
2596
- const type = TokenTypes.tokens[name];
2597
- if (this._match(lexeme, type.rule)) {
2598
- return type;
2599
- }
2662
+ const type = TokenTypes.literalTokens[lexeme];
2663
+ if (type) {
2664
+ return type;
2600
2665
  }
2601
2666
  return TokenTypes.none;
2602
2667
  }
2603
2668
  _match(lexeme, rule) {
2604
- if (typeof rule === "string") {
2605
- if (rule == lexeme) {
2606
- return true;
2607
- }
2608
- } else {
2609
- const match = rule.exec(lexeme);
2610
- if (match && match.index == 0 && match[0] == lexeme) {
2611
- return true;
2612
- }
2613
- }
2614
- return false;
2669
+ const match = rule.exec(lexeme);
2670
+ return match && match.index == 0 && match[0] == lexeme;
2615
2671
  }
2616
2672
  _isAtEnd() {
2617
2673
  return this._current >= this._source.length;
2618
2674
  }
2675
+ _isAlpha(c) {
2676
+ return c >= "a" && c <= "z" || c >= "A" && c <= "Z";
2677
+ }
2678
+ _isAlphaNumeric(c) {
2679
+ return c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c == "_" || c >= "0" && c <= "9";
2680
+ }
2619
2681
  _isWhitespace(c) {
2620
2682
  return c == " " || c == " " || c == "\r";
2621
2683
  }
@@ -2733,8 +2795,8 @@ void main() {
2733
2795
  const tk = this._peek();
2734
2796
  if (types instanceof Array) {
2735
2797
  const t = tk.type;
2736
- const index2 = types.indexOf(t);
2737
- return index2 != -1;
2798
+ const index = types.indexOf(t);
2799
+ return index != -1;
2738
2800
  }
2739
2801
  return tk.type == types;
2740
2802
  }
@@ -2765,6 +2827,11 @@ void main() {
2765
2827
  this._consume(TokenTypes.tokens.semicolon, "Expected ';'");
2766
2828
  return directive;
2767
2829
  }
2830
+ if (this._match(TokenTypes.keywords.requires)) {
2831
+ const requires = this._requires_directive();
2832
+ this._consume(TokenTypes.tokens.semicolon, "Expected ';'");
2833
+ return requires;
2834
+ }
2768
2835
  if (this._match(TokenTypes.keywords.enable)) {
2769
2836
  const enable = this._enable_directive();
2770
2837
  this._consume(TokenTypes.tokens.semicolon, "Expected ';'");
@@ -2871,6 +2938,9 @@ void main() {
2871
2938
  _statement() {
2872
2939
  while (this._match(TokenTypes.tokens.semicolon) && !this._isAtEnd())
2873
2940
  ;
2941
+ if (this._check(TokenTypes.tokens.attr)) {
2942
+ this._attribute();
2943
+ }
2874
2944
  if (this._check(TokenTypes.keywords.if)) {
2875
2945
  return this._if_statement();
2876
2946
  }
@@ -2930,6 +3000,9 @@ void main() {
2930
3000
  return null;
2931
3001
  }
2932
3002
  const condition = this._optional_paren_expression();
3003
+ if (this._check(TokenTypes.tokens.attr)) {
3004
+ this._attribute();
3005
+ }
2933
3006
  const block = this._compound_statement();
2934
3007
  return new While(condition, block);
2935
3008
  }
@@ -2951,6 +3024,9 @@ void main() {
2951
3024
  this._consume(TokenTypes.tokens.semicolon, "Expected ';'.");
2952
3025
  const increment = !this._check(TokenTypes.tokens.paren_right) ? this._for_increment() : null;
2953
3026
  this._consume(TokenTypes.tokens.paren_right, "Expected ')'.");
3027
+ if (this._check(TokenTypes.tokens.attr)) {
3028
+ this._attribute();
3029
+ }
2954
3030
  const body = this._compound_statement();
2955
3031
  return new For(init, condition, increment, body);
2956
3032
  }
@@ -3048,6 +3124,9 @@ void main() {
3048
3124
  if (!this._match(TokenTypes.keywords.loop)) {
3049
3125
  return null;
3050
3126
  }
3127
+ if (this._check(TokenTypes.tokens.attr)) {
3128
+ this._attribute();
3129
+ }
3051
3130
  this._consume(TokenTypes.tokens.brace_left, "Expected '{' for loop.");
3052
3131
  const statements = [];
3053
3132
  let statement = this._statement();
@@ -3073,6 +3152,9 @@ void main() {
3073
3152
  return null;
3074
3153
  }
3075
3154
  const condition = this._optional_paren_expression();
3155
+ if (this._check(TokenTypes.tokens.attr)) {
3156
+ this._attribute();
3157
+ }
3076
3158
  this._consume(TokenTypes.tokens.brace_left, "Expected '{' for switch.");
3077
3159
  const body = this._switch_body();
3078
3160
  if (body == null || body.length == 0) {
@@ -3086,6 +3168,9 @@ void main() {
3086
3168
  if (this._match(TokenTypes.keywords.case)) {
3087
3169
  const selector = this._case_selectors();
3088
3170
  this._match(TokenTypes.tokens.colon);
3171
+ if (this._check(TokenTypes.tokens.attr)) {
3172
+ this._attribute();
3173
+ }
3089
3174
  this._consume(TokenTypes.tokens.brace_left, "Exected '{' for switch case.");
3090
3175
  const body = this._case_body();
3091
3176
  this._consume(TokenTypes.tokens.brace_right, "Exected '}' for switch case.");
@@ -3093,6 +3178,9 @@ void main() {
3093
3178
  }
3094
3179
  if (this._match(TokenTypes.keywords.default)) {
3095
3180
  this._match(TokenTypes.tokens.colon);
3181
+ if (this._check(TokenTypes.tokens.attr)) {
3182
+ this._attribute();
3183
+ }
3096
3184
  this._consume(TokenTypes.tokens.brace_left, "Exected '{' for switch default.");
3097
3185
  const body = this._case_body();
3098
3186
  this._consume(TokenTypes.tokens.brace_right, "Exected '}' for switch default.");
@@ -3137,13 +3225,22 @@ void main() {
3137
3225
  return null;
3138
3226
  }
3139
3227
  const condition = this._optional_paren_expression();
3228
+ if (this._check(TokenTypes.tokens.attr)) {
3229
+ this._attribute();
3230
+ }
3140
3231
  const block = this._compound_statement();
3141
3232
  let elseif = [];
3142
3233
  if (this._match_elseif()) {
3234
+ if (this._check(TokenTypes.tokens.attr)) {
3235
+ this._attribute();
3236
+ }
3143
3237
  elseif = this._elseif_statement(elseif);
3144
3238
  }
3145
3239
  let _else = null;
3146
3240
  if (this._match(TokenTypes.keywords.else)) {
3241
+ if (this._check(TokenTypes.tokens.attr)) {
3242
+ this._attribute();
3243
+ }
3147
3244
  _else = this._compound_statement();
3148
3245
  }
3149
3246
  return new If(condition, block, elseif, _else);
@@ -3161,6 +3258,9 @@ void main() {
3161
3258
  const block = this._compound_statement();
3162
3259
  elseif.push(new ElseIf(condition, block));
3163
3260
  if (this._match_elseif()) {
3261
+ if (this._check(TokenTypes.tokens.attr)) {
3262
+ this._attribute();
3263
+ }
3164
3264
  this._elseif_statement(elseif);
3165
3265
  }
3166
3266
  return elseif;
@@ -3266,25 +3366,29 @@ void main() {
3266
3366
  _singular_expression() {
3267
3367
  const expr = this._primary_expression();
3268
3368
  const p = this._postfix_expression();
3269
- if (p)
3369
+ if (p) {
3270
3370
  expr.postfix = p;
3371
+ }
3271
3372
  return expr;
3272
3373
  }
3273
3374
  _postfix_expression() {
3274
3375
  if (this._match(TokenTypes.tokens.bracket_left)) {
3275
3376
  const expr = this._short_circuit_or_expression();
3276
3377
  this._consume(TokenTypes.tokens.bracket_right, "Expected ']'.");
3378
+ const arrayIndex = new ArrayIndex(expr);
3277
3379
  const p = this._postfix_expression();
3278
- if (p)
3279
- expr.postfix = p;
3280
- return expr;
3380
+ if (p) {
3381
+ arrayIndex.postfix = p;
3382
+ }
3383
+ return arrayIndex;
3281
3384
  }
3282
3385
  if (this._match(TokenTypes.tokens.period)) {
3283
3386
  const name = this._consume(TokenTypes.tokens.ident, "Expected member name.");
3284
3387
  const p = this._postfix_expression();
3285
3388
  const expr = new StringExpr(name.lexeme);
3286
- if (p)
3389
+ if (p) {
3287
3390
  expr.postfix = p;
3391
+ }
3288
3392
  return expr;
3289
3393
  }
3290
3394
  return null;
@@ -3523,6 +3627,14 @@ void main() {
3523
3627
  const name = this._consume(TokenTypes.tokens.ident, "identity expected.");
3524
3628
  return new Enable(name.toString());
3525
3629
  }
3630
+ _requires_directive() {
3631
+ const extensions = [this._consume(TokenTypes.tokens.ident, "identity expected.").toString()];
3632
+ while (this._match(TokenTypes.tokens.comma)) {
3633
+ const name = this._consume(TokenTypes.tokens.ident, "identity expected.");
3634
+ extensions.push(name.toString());
3635
+ }
3636
+ return new Requires(extensions);
3637
+ }
3526
3638
  _type_alias() {
3527
3639
  const name = this._consume(TokenTypes.tokens.ident, "identity expected.");
3528
3640
  this._consume(TokenTypes.tokens.equal, "Expected '=' for type alias.");
@@ -3665,29 +3777,6 @@ void main() {
3665
3777
  }
3666
3778
  attributes.push(attr);
3667
3779
  }
3668
- while (this._match(TokenTypes.tokens.attr_left)) {
3669
- if (!this._check(TokenTypes.tokens.attr_right)) {
3670
- do {
3671
- const name = this._consume(TokenTypes.attribute_name, "Expected attribute name");
3672
- const attr = new Attribute(name.toString(), null);
3673
- if (this._match(TokenTypes.tokens.paren_left)) {
3674
- attr.value = [
3675
- this._consume(TokenTypes.literal_or_ident, "Expected attribute value").toString()
3676
- ];
3677
- if (this._check(TokenTypes.tokens.comma)) {
3678
- this._advance();
3679
- do {
3680
- const v = this._consume(TokenTypes.literal_or_ident, "Expected attribute value").toString();
3681
- attr.value.push(v);
3682
- } while (this._match(TokenTypes.tokens.comma));
3683
- }
3684
- this._consume(TokenTypes.tokens.paren_right, "Expected ')'");
3685
- }
3686
- attributes.push(attr);
3687
- } while (this._match(TokenTypes.tokens.comma));
3688
- }
3689
- this._consume(TokenTypes.tokens.attr_right, "Expected ']]' after attribute declarations");
3690
- }
3691
3780
  if (attributes.length == 0) {
3692
3781
  return null;
3693
3782
  }
@@ -4607,17 +4696,11 @@ void main() {
4607
4696
  printRowMajor: true,
4608
4697
  _cartographicRadians: false
4609
4698
  };
4610
- globalThis.mathgl = globalThis.mathgl || {
4611
- config: {
4612
- ...DEFAULT_CONFIG
4613
- }
4614
- };
4699
+ globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
4615
4700
  var config = globalThis.mathgl.config;
4616
- function formatValue(value, {
4617
- precision = config.precision
4618
- } = {}) {
4701
+ function formatValue(value, { precision = config.precision } = {}) {
4619
4702
  value = round(value);
4620
- return "".concat(parseFloat(value.toPrecision(precision)));
4703
+ return `${parseFloat(value.toPrecision(precision))}`;
4621
4704
  }
4622
4705
  function isArray(value) {
4623
4706
  return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
@@ -4679,28 +4762,12 @@ void main() {
4679
4762
  }
4680
4763
 
4681
4764
  // ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
4682
- function _extendableBuiltin(cls) {
4683
- function ExtendableBuiltin() {
4684
- var instance = Reflect.construct(cls, Array.from(arguments));
4685
- Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
4686
- return instance;
4687
- }
4688
- ExtendableBuiltin.prototype = Object.create(cls.prototype, {
4689
- constructor: {
4690
- value: cls,
4691
- enumerable: false,
4692
- writable: true,
4693
- configurable: true
4694
- }
4695
- });
4696
- if (Object.setPrototypeOf) {
4697
- Object.setPrototypeOf(ExtendableBuiltin, cls);
4698
- } else {
4699
- ExtendableBuiltin.__proto__ = cls;
4700
- }
4701
- return ExtendableBuiltin;
4702
- }
4703
- var MathArray = class extends _extendableBuiltin(Array) {
4765
+ var MathArray = class extends Array {
4766
+ // Common methods
4767
+ /**
4768
+ * Clone the current object
4769
+ * @returns a new copy of this object
4770
+ */
4704
4771
  clone() {
4705
4772
  return new this.constructor().copy(this);
4706
4773
  }
@@ -4720,7 +4787,10 @@ void main() {
4720
4787
  return targetObject;
4721
4788
  }
4722
4789
  from(arrayOrObject) {
4723
- return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
4790
+ return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
4791
+ // @ts-ignore
4792
+ this.fromObject(arrayOrObject)
4793
+ );
4724
4794
  }
4725
4795
  to(arrayOrObject) {
4726
4796
  if (arrayOrObject === this) {
@@ -4731,18 +4801,20 @@ void main() {
4731
4801
  toTarget(target) {
4732
4802
  return target ? this.to(target) : this;
4733
4803
  }
4804
+ /** @deprecated */
4734
4805
  toFloat32Array() {
4735
4806
  return new Float32Array(this);
4736
4807
  }
4737
4808
  toString() {
4738
4809
  return this.formatString(config);
4739
4810
  }
4811
+ /** Formats string according to options */
4740
4812
  formatString(opts) {
4741
4813
  let string = "";
4742
4814
  for (let i = 0; i < this.ELEMENTS; ++i) {
4743
4815
  string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
4744
4816
  }
4745
- return "".concat(opts.printTypes ? this.constructor.name : "", "[").concat(string, "]");
4817
+ return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
4746
4818
  }
4747
4819
  equals(array) {
4748
4820
  if (!array || this.length !== array.length) {
@@ -4766,6 +4838,8 @@ void main() {
4766
4838
  }
4767
4839
  return true;
4768
4840
  }
4841
+ // Modifiers
4842
+ /** Negates all values in this object */
4769
4843
  negate() {
4770
4844
  for (let i = 0; i < this.ELEMENTS; ++i) {
4771
4845
  this[i] = -this[i];
@@ -4783,12 +4857,14 @@ void main() {
4783
4857
  }
4784
4858
  return this.check();
4785
4859
  }
4860
+ /** Minimal */
4786
4861
  min(vector) {
4787
4862
  for (let i = 0; i < this.ELEMENTS; ++i) {
4788
4863
  this[i] = Math.min(vector[i], this[i]);
4789
4864
  }
4790
4865
  return this.check();
4791
4866
  }
4867
+ /** Maximal */
4792
4868
  max(vector) {
4793
4869
  for (let i = 0; i < this.ELEMENTS; ++i) {
4794
4870
  this[i] = Math.max(vector[i], this[i]);
@@ -4829,18 +4905,25 @@ void main() {
4829
4905
  }
4830
4906
  return this.check();
4831
4907
  }
4908
+ /**
4909
+ * Multiplies all elements by `scale`
4910
+ * Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
4911
+ */
4832
4912
  multiplyByScalar(scalar) {
4833
4913
  for (let i = 0; i < this.ELEMENTS; ++i) {
4834
4914
  this[i] *= scalar;
4835
4915
  }
4836
4916
  return this.check();
4837
4917
  }
4918
+ // Debug checks
4919
+ /** Throws an error if array length is incorrect or contains illegal values */
4838
4920
  check() {
4839
4921
  if (config.debug && !this.validate()) {
4840
- throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
4922
+ throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
4841
4923
  }
4842
4924
  return this;
4843
4925
  }
4926
+ /** Returns false if the array length is incorrect or contains illegal values */
4844
4927
  validate() {
4845
4928
  let valid = this.length === this.ELEMENTS;
4846
4929
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -4848,39 +4931,48 @@ void main() {
4848
4931
  }
4849
4932
  return valid;
4850
4933
  }
4934
+ // three.js compatibility
4935
+ /** @deprecated */
4851
4936
  sub(a) {
4852
4937
  return this.subtract(a);
4853
4938
  }
4939
+ /** @deprecated */
4854
4940
  setScalar(a) {
4855
4941
  for (let i = 0; i < this.ELEMENTS; ++i) {
4856
4942
  this[i] = a;
4857
4943
  }
4858
4944
  return this.check();
4859
4945
  }
4946
+ /** @deprecated */
4860
4947
  addScalar(a) {
4861
4948
  for (let i = 0; i < this.ELEMENTS; ++i) {
4862
4949
  this[i] += a;
4863
4950
  }
4864
4951
  return this.check();
4865
4952
  }
4953
+ /** @deprecated */
4866
4954
  subScalar(a) {
4867
4955
  return this.addScalar(-a);
4868
4956
  }
4957
+ /** @deprecated */
4869
4958
  multiplyScalar(scalar) {
4870
4959
  for (let i = 0; i < this.ELEMENTS; ++i) {
4871
4960
  this[i] *= scalar;
4872
4961
  }
4873
4962
  return this.check();
4874
4963
  }
4964
+ /** @deprecated */
4875
4965
  divideScalar(a) {
4876
4966
  return this.multiplyByScalar(1 / a);
4877
4967
  }
4968
+ /** @deprecated */
4878
4969
  clampScalar(min, max) {
4879
4970
  for (let i = 0; i < this.ELEMENTS; ++i) {
4880
4971
  this[i] = Math.min(Math.max(this[i], min), max);
4881
4972
  }
4882
4973
  return this.check();
4883
4974
  }
4975
+ /** @deprecated */
4884
4976
  get elements() {
4885
4977
  return this;
4886
4978
  }
@@ -4900,13 +4992,13 @@ void main() {
4900
4992
  }
4901
4993
  function checkNumber(value) {
4902
4994
  if (!Number.isFinite(value)) {
4903
- throw new Error("Invalid number ".concat(JSON.stringify(value)));
4995
+ throw new Error(`Invalid number ${JSON.stringify(value)}`);
4904
4996
  }
4905
4997
  return value;
4906
4998
  }
4907
4999
  function checkVector(v, length, callerName = "") {
4908
5000
  if (config.debug && !validateVector(v, length)) {
4909
- throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
5001
+ throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
4910
5002
  }
4911
5003
  return v;
4912
5004
  }
@@ -5031,19 +5123,29 @@ void main() {
5031
5123
 
5032
5124
  // ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
5033
5125
  var Matrix = class extends MathArray {
5126
+ // fromObject(object) {
5127
+ // const array = object.elements;
5128
+ // return this.fromRowMajor(array);
5129
+ // }
5130
+ // toObject(object) {
5131
+ // const array = object.elements;
5132
+ // this.toRowMajor(array);
5133
+ // return object;
5134
+ // }
5135
+ // TODO better override formatString?
5034
5136
  toString() {
5035
5137
  let string = "[";
5036
5138
  if (config.printRowMajor) {
5037
5139
  string += "row-major:";
5038
5140
  for (let row = 0; row < this.RANK; ++row) {
5039
5141
  for (let col = 0; col < this.RANK; ++col) {
5040
- string += " ".concat(this[col * this.RANK + row]);
5142
+ string += ` ${this[col * this.RANK + row]}`;
5041
5143
  }
5042
5144
  }
5043
5145
  } else {
5044
5146
  string += "column-major:";
5045
5147
  for (let i = 0; i < this.ELEMENTS; ++i) {
5046
- string += " ".concat(this[i]);
5148
+ string += ` ${this[i]}`;
5047
5149
  }
5048
5150
  }
5049
5151
  string += "]";
@@ -5052,9 +5154,11 @@ void main() {
5052
5154
  getElementIndex(row, col) {
5053
5155
  return col * this.RANK + row;
5054
5156
  }
5157
+ // By default assumes row major indices
5055
5158
  getElement(row, col) {
5056
5159
  return this[col * this.RANK + row];
5057
5160
  }
5161
+ // By default assumes row major indices
5058
5162
  setElement(row, col, value) {
5059
5163
  this[col * this.RANK + row] = checkNumber(value);
5060
5164
  return this;
@@ -5820,6 +5924,7 @@ void main() {
5820
5924
  this[15] = array[15];
5821
5925
  return this.check();
5822
5926
  }
5927
+ // eslint-disable-next-line max-params
5823
5928
  set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
5824
5929
  this[0] = m00;
5825
5930
  this[1] = m10;
@@ -5839,6 +5944,8 @@ void main() {
5839
5944
  this[15] = m33;
5840
5945
  return this.check();
5841
5946
  }
5947
+ // accepts row major order, stores as column major
5948
+ // eslint-disable-next-line max-params
5842
5949
  setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
5843
5950
  this[0] = m00;
5844
5951
  this[1] = m10;
@@ -5877,25 +5984,41 @@ void main() {
5877
5984
  result[15] = this[15];
5878
5985
  return result;
5879
5986
  }
5987
+ // Constructors
5988
+ /** Set to identity matrix */
5880
5989
  identity() {
5881
5990
  return this.copy(IDENTITY_MATRIX);
5882
5991
  }
5992
+ /**
5993
+ *
5994
+ * @param object
5995
+ * @returns self
5996
+ */
5997
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5883
5998
  fromObject(object) {
5884
5999
  return this.check();
5885
6000
  }
6001
+ /**
6002
+ * Calculates a 4x4 matrix from the given quaternion
6003
+ * @param quaternion Quaternion to create matrix from
6004
+ * @returns self
6005
+ */
5886
6006
  fromQuaternion(quaternion) {
5887
6007
  fromQuat(this, quaternion);
5888
6008
  return this.check();
5889
6009
  }
6010
+ /**
6011
+ * Generates a frustum matrix with the given bounds
6012
+ * @param view.left - Left bound of the frustum
6013
+ * @param view.right - Right bound of the frustum
6014
+ * @param view.bottom - Bottom bound of the frustum
6015
+ * @param view.top - Top bound of the frustum
6016
+ * @param view.near - Near bound of the frustum
6017
+ * @param view.far - Far bound of the frustum. Can be set to Infinity.
6018
+ * @returns self
6019
+ */
5890
6020
  frustum(view) {
5891
- const {
5892
- left,
5893
- right,
5894
- bottom,
5895
- top,
5896
- near = DEFAULT_NEAR,
5897
- far = DEFAULT_FAR
5898
- } = view;
6021
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
5899
6022
  if (far === Infinity) {
5900
6023
  computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
5901
6024
  } else {
@@ -5903,35 +6026,47 @@ void main() {
5903
6026
  }
5904
6027
  return this.check();
5905
6028
  }
6029
+ /**
6030
+ * Generates a look-at matrix with the given eye position, focal point,
6031
+ * and up axis
6032
+ * @param view.eye - (vector) Position of the viewer
6033
+ * @param view.center - (vector) Point the viewer is looking at
6034
+ * @param view.up - (vector) Up axis
6035
+ * @returns self
6036
+ */
5906
6037
  lookAt(view) {
5907
- const {
5908
- eye,
5909
- center = [0, 0, 0],
5910
- up = [0, 1, 0]
5911
- } = view;
6038
+ const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
5912
6039
  lookAt(this, eye, center, up);
5913
6040
  return this.check();
5914
6041
  }
6042
+ /**
6043
+ * Generates a orthogonal projection matrix with the given bounds
6044
+ * from "traditional" view space parameters
6045
+ * @param view.left - Left bound of the frustum
6046
+ * @param view.right number Right bound of the frustum
6047
+ * @param view.bottom - Bottom bound of the frustum
6048
+ * @param view.top number Top bound of the frustum
6049
+ * @param view.near - Near bound of the frustum
6050
+ * @param view.far number Far bound of the frustum
6051
+ * @returns self
6052
+ */
5915
6053
  ortho(view) {
5916
- const {
5917
- left,
5918
- right,
5919
- bottom,
5920
- top,
5921
- near = DEFAULT_NEAR,
5922
- far = DEFAULT_FAR
5923
- } = view;
6054
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
5924
6055
  ortho(this, left, right, bottom, top, near, far);
5925
6056
  return this.check();
5926
6057
  }
6058
+ /**
6059
+ * Generates an orthogonal projection matrix with the same parameters
6060
+ * as a perspective matrix (plus focalDistance)
6061
+ * @param view.fovy Vertical field of view in radians
6062
+ * @param view.aspect Aspect ratio. Typically viewport width / viewport height
6063
+ * @param view.focalDistance Distance in the view frustum used for extent calculations
6064
+ * @param view.near Near bound of the frustum
6065
+ * @param view.far Far bound of the frustum
6066
+ * @returns self
6067
+ */
5927
6068
  orthographic(view) {
5928
- const {
5929
- fovy = DEFAULT_FOVY,
5930
- aspect = DEFAULT_ASPECT,
5931
- focalDistance = 1,
5932
- near = DEFAULT_NEAR,
5933
- far = DEFAULT_FAR
5934
- } = view;
6069
+ const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
5935
6070
  checkRadians(fovy);
5936
6071
  const halfY = fovy / 2;
5937
6072
  const top = focalDistance * Math.tan(halfY);
@@ -5945,32 +6080,53 @@ void main() {
5945
6080
  far
5946
6081
  });
5947
6082
  }
6083
+ /**
6084
+ * Generates a perspective projection matrix with the given bounds
6085
+ * @param view.fovy Vertical field of view in radians
6086
+ * @param view.aspect Aspect ratio. typically viewport width/height
6087
+ * @param view.near Near bound of the frustum
6088
+ * @param view.far Far bound of the frustum
6089
+ * @returns self
6090
+ */
5948
6091
  perspective(view) {
5949
- const {
5950
- fovy = 45 * Math.PI / 180,
5951
- aspect = 1,
5952
- near = 0.1,
5953
- far = 500
5954
- } = view;
6092
+ const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
5955
6093
  checkRadians(fovy);
5956
6094
  perspective(this, fovy, aspect, near, far);
5957
6095
  return this.check();
5958
6096
  }
6097
+ // Accessors
5959
6098
  determinant() {
5960
6099
  return determinant(this);
5961
6100
  }
6101
+ /**
6102
+ * Extracts the non-uniform scale assuming the matrix is an affine transformation.
6103
+ * The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
6104
+ * @param result
6105
+ * @returns self
6106
+ */
5962
6107
  getScale(result = [-0, -0, -0]) {
5963
6108
  result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
5964
6109
  result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
5965
6110
  result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
5966
6111
  return result;
5967
6112
  }
6113
+ /**
6114
+ * Gets the translation portion, assuming the matrix is a affine transformation matrix.
6115
+ * @param result
6116
+ * @returns self
6117
+ */
5968
6118
  getTranslation(result = [-0, -0, -0]) {
5969
6119
  result[0] = this[12];
5970
6120
  result[1] = this[13];
5971
6121
  result[2] = this[14];
5972
6122
  return result;
5973
6123
  }
6124
+ /**
6125
+ * Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
6126
+ * @param result
6127
+ * @param scaleResult
6128
+ * @returns self
6129
+ */
5974
6130
  getRotation(result, scaleResult) {
5975
6131
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
5976
6132
  scaleResult = scaleResult || [-0, -0, -0];
@@ -5996,6 +6152,12 @@ void main() {
5996
6152
  result[15] = 1;
5997
6153
  return result;
5998
6154
  }
6155
+ /**
6156
+ *
6157
+ * @param result
6158
+ * @param scaleResult
6159
+ * @returns self
6160
+ */
5999
6161
  getRotationMatrix3(result, scaleResult) {
6000
6162
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
6001
6163
  scaleResult = scaleResult || [-0, -0, -0];
@@ -6014,6 +6176,7 @@ void main() {
6014
6176
  result[8] = this[10] * inverseScale2;
6015
6177
  return result;
6016
6178
  }
6179
+ // Modifiers
6017
6180
  transpose() {
6018
6181
  transpose(this, this);
6019
6182
  return this.check();
@@ -6022,6 +6185,7 @@ void main() {
6022
6185
  invert(this, this);
6023
6186
  return this.check();
6024
6187
  }
6188
+ // Operations
6025
6189
  multiplyLeft(a) {
6026
6190
  multiply(this, a, this);
6027
6191
  return this.check();
@@ -6030,33 +6194,68 @@ void main() {
6030
6194
  multiply(this, this, a);
6031
6195
  return this.check();
6032
6196
  }
6197
+ // Rotates a matrix by the given angle around the X axis
6033
6198
  rotateX(radians2) {
6034
6199
  rotateX(this, this, radians2);
6035
6200
  return this.check();
6036
6201
  }
6202
+ // Rotates a matrix by the given angle around the Y axis.
6037
6203
  rotateY(radians2) {
6038
6204
  rotateY(this, this, radians2);
6039
6205
  return this.check();
6040
6206
  }
6207
+ /**
6208
+ * Rotates a matrix by the given angle around the Z axis.
6209
+ * @param radians
6210
+ * @returns self
6211
+ */
6041
6212
  rotateZ(radians2) {
6042
6213
  rotateZ(this, this, radians2);
6043
6214
  return this.check();
6044
6215
  }
6216
+ /**
6217
+ *
6218
+ * @param param0
6219
+ * @returns self
6220
+ */
6045
6221
  rotateXYZ(angleXYZ) {
6046
6222
  return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
6047
6223
  }
6224
+ /**
6225
+ *
6226
+ * @param radians
6227
+ * @param axis
6228
+ * @returns self
6229
+ */
6048
6230
  rotateAxis(radians2, axis) {
6049
6231
  rotate(this, this, radians2, axis);
6050
6232
  return this.check();
6051
6233
  }
6234
+ /**
6235
+ *
6236
+ * @param factor
6237
+ * @returns self
6238
+ */
6052
6239
  scale(factor) {
6053
6240
  scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
6054
6241
  return this.check();
6055
6242
  }
6243
+ /**
6244
+ *
6245
+ * @param vec
6246
+ * @returns self
6247
+ */
6056
6248
  translate(vector) {
6057
6249
  translate(this, this, vector);
6058
6250
  return this.check();
6059
6251
  }
6252
+ // Transforms
6253
+ /**
6254
+ * Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
6255
+ * @param vector
6256
+ * @param result
6257
+ * @returns self
6258
+ */
6060
6259
  transform(vector, result) {
6061
6260
  if (vector.length === 4) {
6062
6261
  result = transformMat43(result || [-0, -0, -0, -0], vector, this);
@@ -6065,10 +6264,14 @@ void main() {
6065
6264
  }
6066
6265
  return this.transformAsPoint(vector, result);
6067
6266
  }
6267
+ /**
6268
+ * Transforms any 2 or 3 element array as point (w implicitly 1)
6269
+ * @param vector
6270
+ * @param result
6271
+ * @returns self
6272
+ */
6068
6273
  transformAsPoint(vector, result) {
6069
- const {
6070
- length
6071
- } = vector;
6274
+ const { length } = vector;
6072
6275
  let out;
6073
6276
  switch (length) {
6074
6277
  case 2:
@@ -6083,6 +6286,12 @@ void main() {
6083
6286
  checkVector(out, vector.length);
6084
6287
  return out;
6085
6288
  }
6289
+ /**
6290
+ * Transforms any 2 or 3 element array as vector (w implicitly 0)
6291
+ * @param vector
6292
+ * @param result
6293
+ * @returns self
6294
+ */
6086
6295
  transformAsVector(vector, result) {
6087
6296
  let out;
6088
6297
  switch (vector.length) {
@@ -6098,15 +6307,19 @@ void main() {
6098
6307
  checkVector(out, vector.length);
6099
6308
  return out;
6100
6309
  }
6310
+ /** @deprecated */
6101
6311
  transformPoint(vector, result) {
6102
6312
  return this.transformAsPoint(vector, result);
6103
6313
  }
6314
+ /** @deprecated */
6104
6315
  transformVector(vector, result) {
6105
6316
  return this.transformAsPoint(vector, result);
6106
6317
  }
6318
+ /** @deprecated */
6107
6319
  transformDirection(vector, result) {
6108
6320
  return this.transformAsVector(vector, result);
6109
6321
  }
6322
+ // three.js math API compatibility
6110
6323
  makeRotationX(radians2) {
6111
6324
  return this.identity().rotateX(radians2);
6112
6325
  }
@@ -6262,28 +6475,31 @@ void main() {
6262
6475
  const matrixFP64 = new Float32Array(32);
6263
6476
  for (let i = 0; i < 4; ++i) {
6264
6477
  for (let j = 0; j < 4; ++j) {
6265
- const index2 = i * 4 + j;
6266
- fp64ify(matrix[j * 4 + i], matrixFP64, index2 * 2);
6478
+ const index = i * 4 + j;
6479
+ fp64ify(matrix[j * 4 + i], matrixFP64, index * 2);
6267
6480
  }
6268
6481
  }
6269
6482
  return matrixFP64;
6270
6483
  }
6271
6484
 
6272
6485
  // src/modules/math/random/random.ts
6273
- var fs = glsl`\
6274
- float random(vec3 scale, float seed) {
6486
+ var fs = (
6487
+ /* glsl */
6488
+ `float random(vec3 scale, float seed) {
6275
6489
  /* use the fragment position for a different seed per-pixel */
6276
6490
  return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
6277
6491
  }
6278
- `;
6492
+ `
6493
+ );
6279
6494
  var random = {
6280
6495
  name: "random",
6281
6496
  fs
6282
6497
  };
6283
6498
 
6284
6499
  // src/modules/math/fp32/fp32.ts
6285
- var fp32shader = glsl`\
6286
- #ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
6500
+ var fp32shader = (
6501
+ /* glsl */
6502
+ `#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
6287
6503
 
6288
6504
  // All these functions are for substituting tan() function from Intel GPU only
6289
6505
  const float TWO_PI = 6.2831854820251465;
@@ -6433,7 +6649,8 @@ float tan_fp32(float a) {
6433
6649
  return tan(a);
6434
6650
  #endif
6435
6651
  }
6436
- `;
6652
+ `
6653
+ );
6437
6654
  var fp32 = {
6438
6655
  name: "fp32",
6439
6656
  vs: fp32shader
@@ -6441,8 +6658,9 @@ float tan_fp32(float a) {
6441
6658
 
6442
6659
  // src/modules/engine/picking/picking.ts
6443
6660
  var DEFAULT_HIGHLIGHT_COLOR = new Float32Array([0, 1, 1, 1]);
6444
- var vs = glsl`\
6445
- uniform pickingUniforms {
6661
+ var vs = (
6662
+ /* glsl */
6663
+ `uniform pickingUniforms {
6446
6664
  float isActive;
6447
6665
  float isAttribute;
6448
6666
  float isHighlightActive;
@@ -6513,9 +6731,11 @@ void picking_setPickingAttribute(vec3 value) {
6513
6731
  picking_vRGBcolor_Avalid.rgb = value;
6514
6732
  }
6515
6733
  }
6516
- `;
6517
- var fs2 = glsl`\
6518
- uniform pickingUniforms {
6734
+ `
6735
+ );
6736
+ var fs2 = (
6737
+ /* glsl */
6738
+ `uniform pickingUniforms {
6519
6739
  float isActive;
6520
6740
  float isAttribute;
6521
6741
  float isHighlightActive;
@@ -6571,8 +6791,11 @@ vec4 picking_filterColor(vec4 color) {
6571
6791
  vec4 highlightColor = picking_filterHighlightColor(color);
6572
6792
  return picking_filterPickingColor(highlightColor);
6573
6793
  }
6574
- `;
6794
+ `
6795
+ );
6575
6796
  var picking = {
6797
+ props: {},
6798
+ uniforms: {},
6576
6799
  name: "picking",
6577
6800
  uniformTypes: {
6578
6801
  isActive: "f32",
@@ -6592,8 +6815,6 @@ vec4 picking_filterColor(vec4 color) {
6592
6815
  },
6593
6816
  vs,
6594
6817
  fs: fs2,
6595
- props: {},
6596
- uniforms: {},
6597
6818
  getUniforms
6598
6819
  };
6599
6820
  function getUniforms(opts = {}, prevUniforms) {
@@ -6624,8 +6845,9 @@ vec4 picking_filterColor(vec4 color) {
6624
6845
  }
6625
6846
 
6626
6847
  // src/modules/lighting/lights/lighting-uniforms-glsl.ts
6627
- var lightingUniforms = glsl`\
6628
- precision highp int;
6848
+ var lightingUniforms = (
6849
+ /* glsl */
6850
+ `precision highp int;
6629
6851
 
6630
6852
  // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
6631
6853
  struct AmbientLight {
@@ -6676,12 +6898,15 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
6676
6898
  }
6677
6899
 
6678
6900
  // #endif
6679
- `;
6901
+ `
6902
+ );
6680
6903
 
6681
6904
  // src/modules/lighting/lights/lighting.ts
6682
6905
  var MAX_LIGHTS = 5;
6683
6906
  var COLOR_FACTOR = 255;
6684
6907
  var lighting = {
6908
+ props: {},
6909
+ uniforms: {},
6685
6910
  name: "lighting",
6686
6911
  defines: {
6687
6912
  MAX_LIGHTS
@@ -6716,8 +6941,6 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
6716
6941
  },
6717
6942
  vs: lightingUniforms,
6718
6943
  fs: lightingUniforms,
6719
- props: {},
6720
- uniforms: {},
6721
6944
  getUniforms: getUniforms2
6722
6945
  };
6723
6946
  function getUniforms2(props, prevUniforms = {}) {
@@ -6798,15 +7021,18 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
6798
7021
  }
6799
7022
 
6800
7023
  // src/modules/lighting/no-material/dirlight.ts
6801
- var VS_GLSL = glsl`\
6802
- out vec3 dirlight_vNormal;
7024
+ var VS_GLSL = (
7025
+ /* glsl */
7026
+ `out vec3 dirlight_vNormal;
6803
7027
 
6804
7028
  void dirlight_setNormal(vec3 normal) {
6805
7029
  dirlight_vNormal = normalize(normal);
6806
7030
  }
6807
- `;
6808
- var FS_GLSL = glsl`\
6809
- uniform dirlightUniforms {
7031
+ `
7032
+ );
7033
+ var FS_GLSL = (
7034
+ /* glsl */
7035
+ `uniform dirlightUniforms {
6810
7036
  vec3 lightDirection;
6811
7037
  } dirlight;
6812
7038
 
@@ -6817,8 +7043,11 @@ vec4 dirlight_filterColor(vec4 color) {
6817
7043
  float d = abs(dot(dirlight_vNormal, normalize(dirlight.lightDirection)));
6818
7044
  return vec4(color.rgb * d, color.a);
6819
7045
  }
6820
- `;
7046
+ `
7047
+ );
6821
7048
  var dirlight = {
7049
+ props: {},
7050
+ uniforms: {},
6822
7051
  name: "dirlight",
6823
7052
  dependencies: [],
6824
7053
  vs: VS_GLSL,
@@ -6835,8 +7064,6 @@ vec4 dirlight_filterColor(vec4 color) {
6835
7064
  defaultUniforms: {
6836
7065
  lightDirection: new Float32Array([1, 1, 2])
6837
7066
  },
6838
- props: {},
6839
- uniforms: {},
6840
7067
  getUniforms: getUniforms3
6841
7068
  };
6842
7069
  function getUniforms3(opts = dirlight.defaultUniforms) {
@@ -6848,16 +7075,19 @@ vec4 dirlight_filterColor(vec4 color) {
6848
7075
  }
6849
7076
 
6850
7077
  // src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts
6851
- var GOURAUD_VS = glsl`\
6852
- uniform materialUniforms {
7078
+ var GOURAUD_VS = (
7079
+ /* glsl */
7080
+ `uniform materialUniforms {
6853
7081
  uniform float ambient;
6854
7082
  uniform float diffuse;
6855
7083
  uniform float shininess;
6856
7084
  uniform vec3 specularColor;
6857
7085
  } material;
6858
- `;
6859
- var GOURAUD_FS = glsl`\
6860
- uniform materialUniforms {
7086
+ `
7087
+ );
7088
+ var GOURAUD_FS = (
7089
+ /* glsl */
7090
+ `uniform materialUniforms {
6861
7091
  uniform float ambient;
6862
7092
  uniform float diffuse;
6863
7093
  uniform float shininess;
@@ -6938,10 +7168,13 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
6938
7168
  }
6939
7169
  return lightColor;
6940
7170
  }
6941
- `;
7171
+ `
7172
+ );
6942
7173
 
6943
7174
  // src/modules/lighting/gouraud-material/gouraud-material.ts
6944
7175
  var gouraudMaterial = {
7176
+ props: {},
7177
+ uniforms: {},
6945
7178
  name: "gouraud-lighting",
6946
7179
  // Note these are switched between phong and gouraud
6947
7180
  vs: GOURAUD_VS,
@@ -6968,16 +7201,19 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
6968
7201
  };
6969
7202
 
6970
7203
  // src/modules/lighting/phong-material/phong-shaders-glsl.ts
6971
- var PHONG_VS = glsl`\
6972
- uniform phongMaterialUniforms {
7204
+ var PHONG_VS = (
7205
+ /* glsl */
7206
+ `uniform phongMaterialUniforms {
6973
7207
  uniform float ambient;
6974
7208
  uniform float diffuse;
6975
7209
  uniform float shininess;
6976
7210
  uniform vec3 specularColor;
6977
7211
  } material;
6978
- `;
6979
- var PHONG_FS = glsl`\
6980
- uniform phongMaterialUniforms {
7212
+ `
7213
+ );
7214
+ var PHONG_FS = (
7215
+ /* glsl */
7216
+ `uniform phongMaterialUniforms {
6981
7217
  uniform float ambient;
6982
7218
  uniform float diffuse;
6983
7219
  uniform float shininess;
@@ -7061,18 +7297,21 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
7061
7297
  }
7062
7298
  return lightColor;
7063
7299
  }
7064
- `;
7300
+ `
7301
+ );
7065
7302
 
7066
7303
  // src/modules/lighting/phong-material/phong-material.ts
7067
7304
  var phongMaterial = {
7305
+ props: {},
7306
+ uniforms: {},
7068
7307
  name: "phong-lighting",
7308
+ dependencies: [lighting],
7069
7309
  // Note these are switched between phong and gouraud
7070
7310
  vs: PHONG_VS,
7071
7311
  fs: PHONG_FS,
7072
7312
  defines: {
7073
7313
  LIGHTING_FRAGMENT: 1
7074
7314
  },
7075
- dependencies: [lighting],
7076
7315
  uniformTypes: {
7077
7316
  ambient: "f32",
7078
7317
  diffuse: "f32",
@@ -7085,16 +7324,15 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
7085
7324
  shininess: 32,
7086
7325
  specularColor: [0.15, 0.15, 0.15]
7087
7326
  },
7088
- props: {},
7089
- uniforms: {},
7090
7327
  getUniforms(props) {
7091
7328
  return { ...phongMaterial.defaultUniforms, ...props };
7092
7329
  }
7093
7330
  };
7094
7331
 
7095
7332
  // src/modules/lighting/pbr-material/pbr-vertex-glsl.ts
7096
- var vs2 = glsl`\
7097
- uniform projection {
7333
+ var vs2 = (
7334
+ /* glsl */
7335
+ `uniform projection {
7098
7336
  mat4 u_MVPMatrix;
7099
7337
  mat4 u_ModelMatrix;
7100
7338
  mat4 u_NormalMatrix;
@@ -7135,11 +7373,13 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
7135
7373
  pbr_vUV = vec2(0.,0.);
7136
7374
  #endif
7137
7375
  }
7138
- `;
7376
+ `
7377
+ );
7139
7378
 
7140
7379
  // src/modules/lighting/pbr-material/pbr-fragment-glsl.ts
7141
- var fs3 = glsl`\
7142
- precision highp float;
7380
+ var fs3 = (
7381
+ /* glsl */
7382
+ `precision highp float;
7143
7383
 
7144
7384
  uniform Projection {
7145
7385
  // Projection
@@ -7544,11 +7784,15 @@ vec4 pbr_filterColor(vec4 colorUnused)
7544
7784
 
7545
7785
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
7546
7786
  }
7547
- `;
7787
+ `
7788
+ );
7548
7789
 
7549
7790
  // src/modules/lighting/pbr-material/pbr-material.ts
7550
7791
  var pbrMaterial = {
7792
+ props: {},
7793
+ uniforms: {},
7551
7794
  name: "pbr",
7795
+ dependencies: [lighting],
7552
7796
  vs: vs2,
7553
7797
  fs: fs3,
7554
7798
  defines: {
@@ -7609,13 +7853,13 @@ vec4 pbr_filterColor(vec4 colorUnused)
7609
7853
  // #ifdef USE_IBL (samplerCube)
7610
7854
  brdfLUT: { type: "texture", location: 15 }
7611
7855
  // #ifdef USE_IBL
7612
- },
7613
- dependencies: [lighting]
7856
+ }
7614
7857
  };
7615
7858
 
7616
7859
  // src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts
7617
- var fs4 = glsl`\
7618
-
7860
+ var fs4 = (
7861
+ /* glsl */
7862
+ `
7619
7863
  uniform brightnessContrastUniforms {
7620
7864
  float brightness;
7621
7865
  float contrast;
@@ -7634,8 +7878,11 @@ vec4 brightnessContrast_filterColor(vec4 color) {
7634
7878
  vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
7635
7879
  return brightnessContrast_filterColor(color);
7636
7880
  }
7637
- `;
7881
+ `
7882
+ );
7638
7883
  var brightnessContrast = {
7884
+ props: {},
7885
+ uniforms: {},
7639
7886
  name: "brightnessContrast",
7640
7887
  uniformTypes: {
7641
7888
  brightness: "f32",
@@ -7650,8 +7897,9 @@ vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
7650
7897
  };
7651
7898
 
7652
7899
  // src/modules/postprocessing/image-adjust-filters/denoise.ts
7653
- var fs5 = glsl`\
7654
- uniform denoiseUniforms {
7900
+ var fs5 = (
7901
+ /* glsl */
7902
+ `uniform denoiseUniforms {
7655
7903
  float strength;
7656
7904
  } noise;
7657
7905
 
@@ -7673,8 +7921,11 @@ vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
7673
7921
 
7674
7922
  return color / total;
7675
7923
  }
7676
- `;
7924
+ `
7925
+ );
7677
7926
  var denoise = {
7927
+ props: {},
7928
+ uniforms: {},
7678
7929
  name: "denoise",
7679
7930
  uniformTypes: {
7680
7931
  strength: "f32"
@@ -7688,8 +7939,9 @@ vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
7688
7939
  };
7689
7940
 
7690
7941
  // src/modules/postprocessing/image-adjust-filters/huesaturation.ts
7691
- var fs6 = glsl`\
7692
- uniform hueSaturationUniforms {
7942
+ var fs6 = (
7943
+ /* glsl */
7944
+ `uniform hueSaturationUniforms {
7693
7945
  float hue;
7694
7946
  float saturation;
7695
7947
  } hueSaturation;
@@ -7720,9 +7972,13 @@ vec4 hueSaturation_filterColor(vec4 color) {
7720
7972
  vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7721
7973
  return hueSaturation_filterColor(color);
7722
7974
  }
7723
- `;
7975
+ `
7976
+ );
7724
7977
  var hueSaturation = {
7978
+ props: {},
7979
+ uniforms: {},
7725
7980
  name: "hueSaturation",
7981
+ fs: fs6,
7726
7982
  uniformTypes: {
7727
7983
  hue: "f32",
7728
7984
  saturation: "f32"
@@ -7731,13 +7987,13 @@ vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7731
7987
  hue: { value: 0, min: -1, max: 1 },
7732
7988
  saturation: { value: 0, min: -1, max: 1 }
7733
7989
  },
7734
- fs: fs6,
7735
7990
  passes: [{ filter: true }]
7736
7991
  };
7737
7992
 
7738
7993
  // src/modules/postprocessing/image-adjust-filters/noise.ts
7739
- var fs7 = glsl`\
7740
- uniform noiseUniforms {
7994
+ var fs7 = (
7995
+ /* glsl */
7996
+ `uniform noiseUniforms {
7741
7997
  float amount;
7742
7998
  } noise;
7743
7999
 
@@ -7756,8 +8012,11 @@ vec4 noise_filterColor(vec4 color, vec2 texCoord) {
7756
8012
  vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7757
8013
  return noise_filterColor(color, texCoord);
7758
8014
  }
7759
- `;
8015
+ `
8016
+ );
7760
8017
  var noise = {
8018
+ props: {},
8019
+ uniforms: {},
7761
8020
  name: "noise",
7762
8021
  uniformTypes: {
7763
8022
  amount: "f32"
@@ -7770,8 +8029,9 @@ vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7770
8029
  };
7771
8030
 
7772
8031
  // src/modules/postprocessing/image-adjust-filters/sepia.ts
7773
- var fs8 = glsl`\
7774
- uniform sepiaUniforms {
8032
+ var fs8 = (
8033
+ /* glsl */
8034
+ `uniform sepiaUniforms {
7775
8035
  float amount;
7776
8036
  } sepia;
7777
8037
 
@@ -7791,8 +8051,11 @@ vec4 sepia_filterColor(vec4 color) {
7791
8051
  vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7792
8052
  return sepia_filterColor(color);
7793
8053
  }
7794
- `;
8054
+ `
8055
+ );
7795
8056
  var sepia = {
8057
+ props: {},
8058
+ uniforms: {},
7796
8059
  name: "sepia",
7797
8060
  uniformTypes: {
7798
8061
  amount: "f32"
@@ -7805,8 +8068,9 @@ vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7805
8068
  };
7806
8069
 
7807
8070
  // src/modules/postprocessing/image-adjust-filters/vibrance.ts
7808
- var fs9 = glsl`\
7809
- uniform vibranceUniforms {
8071
+ var fs9 = (
8072
+ /* glsl */
8073
+ `uniform vibranceUniforms {
7810
8074
  float amount;
7811
8075
  } vibrance;
7812
8076
 
@@ -7821,8 +8085,11 @@ vec4 vibrance_filterColor(vec4 color) {
7821
8085
  vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7822
8086
  return vibrance_filterColor(color);
7823
8087
  }
7824
- `;
8088
+ `
8089
+ );
7825
8090
  var vibrance = {
8091
+ props: {},
8092
+ uniforms: {},
7826
8093
  name: "vibrance",
7827
8094
  uniformPropTypes: {
7828
8095
  amount: { value: 0, min: -1, max: 1 }
@@ -7832,8 +8099,9 @@ vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7832
8099
  };
7833
8100
 
7834
8101
  // src/modules/postprocessing/image-adjust-filters/vignette.ts
7835
- var fs10 = glsl`\
7836
- uniform vignetteUniforms {
8102
+ var fs10 = (
8103
+ /* glsl */
8104
+ `uniform vignetteUniforms {
7837
8105
  float radius;
7838
8106
  float amount;
7839
8107
  } vignette;
@@ -7847,10 +8115,12 @@ vec4 vignette_filterColor(vec4 color, vec2 texCoord) {
7847
8115
  vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7848
8116
  return vignette_filterColor(color, texCoord);
7849
8117
  }
7850
- `;
8118
+ `
8119
+ );
7851
8120
  var vignette = {
8121
+ props: {},
8122
+ uniforms: {},
7852
8123
  name: "vignette",
7853
- fs: fs10,
7854
8124
  uniformTypes: {
7855
8125
  radius: "f32",
7856
8126
  amount: "f32"
@@ -7859,12 +8129,14 @@ vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
7859
8129
  radius: { value: 0.5, min: 0, max: 1 },
7860
8130
  amount: { value: 0.5, min: 0, max: 1 }
7861
8131
  },
7862
- passes: [{ filter: true }]
8132
+ passes: [{ filter: true }],
8133
+ fs: fs10
7863
8134
  };
7864
8135
 
7865
8136
  // src/modules/postprocessing/image-blur-filters/tiltshift.ts
7866
- var fs11 = glsl`\
7867
- uniform tiltShiftUniforms {
8137
+ var fs11 = (
8138
+ /* glsl */
8139
+ `uniform tiltShiftUniforms {
7868
8140
  float blurRadius;
7869
8141
  float gradientRadius;
7870
8142
  vec2 start;
@@ -7907,8 +8179,11 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
7907
8179
 
7908
8180
  return color;
7909
8181
  }
7910
- `;
8182
+ `
8183
+ );
7911
8184
  var tiltShift = {
8185
+ props: {},
8186
+ uniforms: {},
7912
8187
  name: "tiltShift",
7913
8188
  dependencies: [random],
7914
8189
  uniformTypes: {
@@ -7933,8 +8208,9 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
7933
8208
  };
7934
8209
 
7935
8210
  // src/modules/postprocessing/image-blur-filters/triangleblur.ts
7936
- var fs12 = glsl`\
7937
- uniform triangleBlurUniforms {
8211
+ var fs12 = (
8212
+ /* glsl */
8213
+ `uniform triangleBlurUniforms {
7938
8214
  float radius;
7939
8215
  vec2 delta;
7940
8216
  } triangleBlur;
@@ -7967,8 +8243,11 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
7967
8243
 
7968
8244
  return color;
7969
8245
  }
7970
- `;
8246
+ `
8247
+ );
7971
8248
  var triangleBlur = {
8249
+ props: {},
8250
+ uniforms: {},
7972
8251
  name: "triangleBlur",
7973
8252
  uniformTypes: {
7974
8253
  radius: "f32",
@@ -8022,6 +8301,8 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8022
8301
  }
8023
8302
  `;
8024
8303
  var zoomBlur = {
8304
+ props: {},
8305
+ uniforms: {},
8025
8306
  name: "zoomBlur",
8026
8307
  uniformTypes: {
8027
8308
  center: "vec2<f32>",
@@ -8037,8 +8318,9 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8037
8318
  };
8038
8319
 
8039
8320
  // src/modules/postprocessing/image-fun-filters/colorhalftone.ts
8040
- var fs14 = glsl`\
8041
- uniform colorHalftoneUniforms {
8321
+ var fs14 = (
8322
+ /* glsl */
8323
+ `uniform colorHalftoneUniforms {
8042
8324
  vec2 center;
8043
8325
  float angle;
8044
8326
  float size;
@@ -8072,8 +8354,11 @@ vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8072
8354
  k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
8073
8355
  return vec4(1.0 - cmy - k, color.a);
8074
8356
  }
8075
- `;
8357
+ `
8358
+ );
8076
8359
  var colorHalftone = {
8360
+ props: {},
8361
+ uniforms: {},
8077
8362
  name: "colorHalftone",
8078
8363
  uniformTypes: {
8079
8364
  center: "vec2<f32>",
@@ -8090,8 +8375,9 @@ vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8090
8375
  };
8091
8376
 
8092
8377
  // src/modules/postprocessing/image-fun-filters/dotscreen.ts
8093
- var fs15 = glsl`\
8094
- uniform dotScreenUniforms {
8378
+ var fs15 = (
8379
+ /* glsl */
8380
+ `uniform dotScreenUniforms {
8095
8381
  vec2 center;
8096
8382
  float angle;
8097
8383
  float size;
@@ -8113,8 +8399,11 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8113
8399
  float average = (color.r + color.g + color.b) / 3.0;
8114
8400
  return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
8115
8401
  }
8116
- `;
8402
+ `
8403
+ );
8117
8404
  var dotScreen = {
8405
+ props: {},
8406
+ uniforms: {},
8118
8407
  name: "dotScreen",
8119
8408
  uniformTypes: {
8120
8409
  center: "vec2<f32>",
@@ -8131,8 +8420,9 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
8131
8420
  };
8132
8421
 
8133
8422
  // src/modules/postprocessing/image-fun-filters/edgework.ts
8134
- var fs16 = glsl`\
8135
- uniform edgeWorkUniforms {
8423
+ var fs16 = (
8424
+ /* glsl */
8425
+ `uniform edgeWorkUniforms {
8136
8426
  float radius;
8137
8427
  vec2 delta;
8138
8428
  } edgeWork;
@@ -8186,15 +8476,18 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
8186
8476
  float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
8187
8477
  return vec4(c, c, c, 1.0);
8188
8478
  }
8189
- `;
8479
+ `
8480
+ );
8190
8481
  var edgeWork = {
8482
+ props: {},
8483
+ uniforms: {},
8191
8484
  name: "edgeWork",
8485
+ dependencies: [random],
8486
+ fs: fs16,
8192
8487
  uniformPropTypes: {
8193
8488
  radius: { value: 2, min: 1, softMax: 50 },
8194
8489
  delta: { value: [1, 0], private: true }
8195
8490
  },
8196
- fs: fs16,
8197
- dependencies: [random],
8198
8491
  passes: [
8199
8492
  {
8200
8493
  // @ts-expect-error
@@ -8210,8 +8503,9 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
8210
8503
  };
8211
8504
 
8212
8505
  // src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts
8213
- var fs17 = glsl`\
8214
- uniform hexagonalPixelateUniforms {
8506
+ var fs17 = (
8507
+ /* glsl */
8508
+ `uniform hexagonalPixelateUniforms {
8215
8509
  vec2 center;
8216
8510
  float scale;
8217
8511
  } hexagonalPixelate;
@@ -8253,8 +8547,11 @@ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord
8253
8547
 
8254
8548
  return texture(source, choice + hexagonalPixelate.center);
8255
8549
  }
8256
- `;
8550
+ `
8551
+ );
8257
8552
  var hexagonalPixelate = {
8553
+ props: {},
8554
+ uniforms: {},
8258
8555
  name: "hexagonalPixelate",
8259
8556
  uniformTypes: {
8260
8557
  center: "vec2<f32>",
@@ -8269,8 +8566,9 @@ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord
8269
8566
  };
8270
8567
 
8271
8568
  // src/modules/postprocessing/image-fun-filters/ink.ts
8272
- var fs18 = glsl`\
8273
- uniform inkUniforms {
8569
+ var fs18 = (
8570
+ /* glsl */
8571
+ `uniform inkUniforms {
8274
8572
  float strength;
8275
8573
  } ink;
8276
8574
 
@@ -8297,22 +8595,26 @@ vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8297
8595
  float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
8298
8596
  return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
8299
8597
  }
8300
- `;
8598
+ `
8599
+ );
8301
8600
  var ink = {
8601
+ props: {},
8602
+ uniforms: {},
8302
8603
  name: "ink",
8604
+ fs: fs18,
8303
8605
  uniformTypes: {
8304
8606
  strength: "f32"
8305
8607
  },
8306
8608
  uniformPropTypes: {
8307
8609
  strength: { value: 0.25, min: 0, softMax: 1 }
8308
8610
  },
8309
- fs: fs18,
8310
8611
  passes: [{ sampler: true }]
8311
8612
  };
8312
8613
 
8313
8614
  // src/modules/postprocessing/image-fun-filters/magnify.ts
8314
- var fs19 = glsl`\
8315
- uniform magnifyUniforms {
8615
+ var fs19 = (
8616
+ /* glsl */
8617
+ `uniform magnifyUniforms {
8316
8618
  vec2 screenXY;
8317
8619
  float radiusPixels;
8318
8620
  float zoom;
@@ -8332,7 +8634,8 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8332
8634
  }
8333
8635
  return texture(source, texCoord);
8334
8636
  }
8335
- `;
8637
+ `
8638
+ );
8336
8639
  var magnify = {
8337
8640
  name: "magnify",
8338
8641
  uniformTypes: {
@@ -8355,8 +8658,9 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8355
8658
  };
8356
8659
 
8357
8660
  // src/modules/postprocessing/image-warp-filters/warp.ts
8358
- var fs20 = glsl`\
8359
- vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
8661
+ var fs20 = (
8662
+ /* glsl */
8663
+ `vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
8360
8664
  vec4 color = texture(source, coord / texSize);
8361
8665
  vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
8362
8666
  if (coord != clampedCoord) {
@@ -8366,7 +8670,8 @@ vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
8366
8670
 
8367
8671
  return color;
8368
8672
  }
8369
- `;
8673
+ `
8674
+ );
8370
8675
  var warp = {
8371
8676
  name: "warp",
8372
8677
  passes: [],
@@ -8374,8 +8679,9 @@ vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
8374
8679
  };
8375
8680
 
8376
8681
  // src/modules/postprocessing/image-warp-filters/bulgepinch.ts
8377
- var fs21 = glsl`\
8378
- uniform bulgePinchUniforms {
8682
+ var fs21 = (
8683
+ /* glsl */
8684
+ `uniform bulgePinchUniforms {
8379
8685
  float radius;
8380
8686
  float strength;
8381
8687
  vec2 center;
@@ -8402,8 +8708,11 @@ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8402
8708
 
8403
8709
  return warp_sampleColor(source, texSize, coord);
8404
8710
  }
8405
- `;
8711
+ `
8712
+ );
8406
8713
  var bulgePinch = {
8714
+ props: {},
8715
+ uniforms: {},
8407
8716
  name: "bulgePinch",
8408
8717
  dependencies: [warp],
8409
8718
  fs: fs21,
@@ -8421,8 +8730,9 @@ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8421
8730
  };
8422
8731
 
8423
8732
  // src/modules/postprocessing/image-warp-filters/swirl.ts
8424
- var fs22 = glsl`\
8425
- uniform swirlUniforms {
8733
+ var fs22 = (
8734
+ /* glsl */
8735
+ `uniform swirlUniforms {
8426
8736
  float radius;
8427
8737
  float angle;
8428
8738
  vec2 center;
@@ -8451,8 +8761,11 @@ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
8451
8761
 
8452
8762
  return warp_sampleColor(source, texSize, coord);
8453
8763
  }
8454
- `;
8764
+ `
8765
+ );
8455
8766
  var swirl = {
8767
+ props: {},
8768
+ uniforms: {},
8456
8769
  name: "swirl",
8457
8770
  dependencies: [warp],
8458
8771
  fs: fs22,
@@ -9060,8 +9373,9 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
9060
9373
  };
9061
9374
 
9062
9375
  // src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts
9063
- var fp64arithmeticShader = glsl`\
9064
- uniform float ONE;
9376
+ var fp64arithmeticShader = (
9377
+ /* glsl */
9378
+ `uniform float ONE;
9065
9379
 
9066
9380
  /*
9067
9381
  About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
@@ -9226,11 +9540,13 @@ vec2 sqrt_fp64(vec2 a) {
9226
9540
  return sum_fp64(vec2(yn, 0.0), prod);
9227
9541
  #endif
9228
9542
  }
9229
- `;
9543
+ `
9544
+ );
9230
9545
 
9231
9546
  // src/modules-webgl1/math/fp64/fp64-functions-glsl.ts
9232
- var fp64functionShader = glsl`\
9233
- const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
9547
+ var fp64functionShader = (
9548
+ /* glsl */
9549
+ `const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
9234
9550
  const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
9235
9551
  const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
9236
9552
  const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
@@ -9899,7 +10215,8 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
9899
10215
  vec4_dot_fp64(a, tmp, out_val[i]);
9900
10216
  }
9901
10217
  }
9902
- `;
10218
+ `
10219
+ );
9903
10220
 
9904
10221
  // src/modules-webgl1/math/fp64/fp64.ts
9905
10222
  var CONST_UNIFORMS = {
@@ -9928,8 +10245,9 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
9928
10245
  };
9929
10246
 
9930
10247
  // src/modules-webgl1/geometry/geometry.ts
9931
- var vs3 = glsl`\
9932
- varying vec4 geometry_vPosition;
10248
+ var vs3 = (
10249
+ /* glsl */
10250
+ `varying vec4 geometry_vPosition;
9933
10251
  varying vec3 geometry_vNormal;
9934
10252
 
9935
10253
  void geometry_setNormal(vec3 normal) {
@@ -9943,9 +10261,11 @@ void geometry_setPosition(vec4 position) {
9943
10261
  void geometry_setPosition(vec3 position) {
9944
10262
  geometry_vPosition = vec4(position, 1.);
9945
10263
  }
9946
- `;
9947
- var fs24 = glsl`\
9948
- varying vec4 geometry_vPosition;
10264
+ `
10265
+ );
10266
+ var fs24 = (
10267
+ /* glsl */
10268
+ `varying vec4 geometry_vPosition;
9949
10269
  varying vec3 geometry_vNormal;
9950
10270
 
9951
10271
  vec4 geometry_getPosition() {
@@ -9955,7 +10275,8 @@ vec4 geometry_getPosition() {
9955
10275
  vec3 geometry_getNormal() {
9956
10276
  return geometry_vNormal;
9957
10277
  }
9958
- `;
10278
+ `
10279
+ );
9959
10280
  var geometry = {
9960
10281
  name: "geometry",
9961
10282
  vs: vs3,
@@ -9991,8 +10312,9 @@ vec3 geometry_getNormal() {
9991
10312
  }
9992
10313
  return uniforms;
9993
10314
  }
9994
- var common = glsl`\
9995
- varying vec4 project_vPositionWorld;
10315
+ var common = (
10316
+ /* glsl */
10317
+ `varying vec4 project_vPositionWorld;
9996
10318
  varying vec3 project_vNormalWorld;
9997
10319
 
9998
10320
  vec4 project_getPosition_World() {
@@ -10002,7 +10324,8 @@ vec4 project_getPosition_World() {
10002
10324
  vec3 project_getNormal_World() {
10003
10325
  return project_vNormalWorld;
10004
10326
  }
10005
- `;
10327
+ `
10328
+ );
10006
10329
  var vs4 = `${common}
10007
10330
 
10008
10331
  // Unprefixed uniforms
@@ -10067,8 +10390,9 @@ ${common}`;
10067
10390
  };
10068
10391
 
10069
10392
  // src/modules-webgl1/lighting/lights/lights-glsl.ts
10070
- var lightingShader = glsl`\
10071
- #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
10393
+ var lightingShader = (
10394
+ /* glsl */
10395
+ `#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
10072
10396
 
10073
10397
  struct AmbientLight {
10074
10398
  vec3 color;
@@ -10102,7 +10426,8 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
10102
10426
  }
10103
10427
 
10104
10428
  #endif
10105
- `;
10429
+ `
10430
+ );
10106
10431
 
10107
10432
  // src/modules-webgl1/lighting/lights/lights.ts
10108
10433
  var INITIAL_MODULE_OPTIONS = {
@@ -10123,19 +10448,19 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
10123
10448
  } else {
10124
10449
  lightSourceUniforms["lighting_uAmbientLight.color"] = [0, 0, 0];
10125
10450
  }
10126
- pointLights.forEach((pointLight, index2) => {
10127
- lightSourceUniforms[`lighting_uPointLight[${index2}].color`] = convertColor2(pointLight);
10128
- lightSourceUniforms[`lighting_uPointLight[${index2}].position`] = pointLight.position;
10129
- lightSourceUniforms[`lighting_uPointLight[${index2}].attenuation`] = pointLight.attenuation || [
10451
+ pointLights.forEach((pointLight, index) => {
10452
+ lightSourceUniforms[`lighting_uPointLight[${index}].color`] = convertColor2(pointLight);
10453
+ lightSourceUniforms[`lighting_uPointLight[${index}].position`] = pointLight.position;
10454
+ lightSourceUniforms[`lighting_uPointLight[${index}].attenuation`] = pointLight.attenuation || [
10130
10455
  1,
10131
10456
  0,
10132
10457
  0
10133
10458
  ];
10134
10459
  });
10135
10460
  lightSourceUniforms.lighting_uPointLightCount = pointLights.length;
10136
- directionalLights.forEach((directionalLight, index2) => {
10137
- lightSourceUniforms[`lighting_uDirectionalLight[${index2}].color`] = convertColor2(directionalLight);
10138
- lightSourceUniforms[`lighting_uDirectionalLight[${index2}].direction`] = directionalLight.direction;
10461
+ directionalLights.forEach((directionalLight, index) => {
10462
+ lightSourceUniforms[`lighting_uDirectionalLight[${index}].color`] = convertColor2(directionalLight);
10463
+ lightSourceUniforms[`lighting_uDirectionalLight[${index}].direction`] = directionalLight.direction;
10139
10464
  });
10140
10465
  lightSourceUniforms.lighting_uDirectionalLightCount = directionalLights.length;
10141
10466
  return lightSourceUniforms;
@@ -10196,8 +10521,9 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
10196
10521
  }
10197
10522
  return uniforms;
10198
10523
  }
10199
- var fs26 = glsl`\
10200
- uniform vec3 dirlight_uLightDirection;
10524
+ var fs26 = (
10525
+ /* glsl */
10526
+ `uniform vec3 dirlight_uLightDirection;
10201
10527
 
10202
10528
  /*
10203
10529
  * Returns color attenuated by angle from light source
@@ -10207,7 +10533,8 @@ vec4 dirlight_filterColor(vec4 color) {
10207
10533
  float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
10208
10534
  return vec4(color.rgb * d, color.a);
10209
10535
  }
10210
- `;
10536
+ `
10537
+ );
10211
10538
  var dirlight2 = {
10212
10539
  name: "dirlight",
10213
10540
  // vs // TODO - reuse normal from geometry module
@@ -10217,8 +10544,9 @@ vec4 dirlight_filterColor(vec4 color) {
10217
10544
  };
10218
10545
 
10219
10546
  // src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts
10220
- var lightingShader2 = glsl`\
10221
-
10547
+ var lightingShader2 = (
10548
+ /* glsl */
10549
+ `
10222
10550
  uniform float lighting_uAmbient;
10223
10551
  uniform float lighting_uDiffuse;
10224
10552
  uniform float lighting_uShininess;
@@ -10291,7 +10619,8 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
10291
10619
  }
10292
10620
  return lightColor;
10293
10621
  }
10294
- `;
10622
+ `
10623
+ );
10295
10624
 
10296
10625
  // src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts
10297
10626
  var INITIAL_MODULE_OPTIONS2 = {};
@@ -10334,8 +10663,9 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
10334
10663
  };
10335
10664
 
10336
10665
  // src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts
10337
- var vs5 = glsl`\
10338
- uniform mat4 u_MVPMatrix;
10666
+ var vs5 = (
10667
+ /* glsl */
10668
+ `uniform mat4 u_MVPMatrix;
10339
10669
  uniform mat4 u_ModelMatrix;
10340
10670
  uniform mat4 u_NormalMatrix;
10341
10671
 
@@ -10372,11 +10702,13 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
10372
10702
  pbr_vUV = vec2(0.,0.);
10373
10703
  #endif
10374
10704
  }
10375
- `;
10705
+ `
10706
+ );
10376
10707
 
10377
10708
  // src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts
10378
- var fs27 = glsl`\
10379
- precision highp float;
10709
+ var fs27 = (
10710
+ /* glsl */
10711
+ `precision highp float;
10380
10712
 
10381
10713
  uniform bool pbr_uUnlit;
10382
10714
 
@@ -10757,7 +11089,8 @@ vec4 pbr_filterColor(vec4 colorUnused)
10757
11089
 
10758
11090
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
10759
11091
  }
10760
- `;
11092
+ `
11093
+ );
10761
11094
 
10762
11095
  // src/modules-webgl1/lighting/pbr/pbr.ts
10763
11096
  var pbr = {