@lightningjs/renderer 3.0.0-beta10 → 3.0.0-beta11

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 (275) hide show
  1. package/LICENSE +202 -202
  2. package/NOTICE +3 -3
  3. package/README.md +133 -133
  4. package/dist/src/core/CoreTextNode.d.ts +3 -0
  5. package/dist/src/core/CoreTextNode.js +45 -10
  6. package/dist/src/core/CoreTextNode.js.map +1 -1
  7. package/dist/src/core/platform.d.ts +10 -0
  8. package/dist/src/core/platform.js +81 -0
  9. package/dist/src/core/platform.js.map +1 -0
  10. package/dist/src/core/renderers/CoreShader.d.ts +9 -0
  11. package/dist/src/core/renderers/CoreShader.js +28 -0
  12. package/dist/src/core/renderers/CoreShader.js.map +1 -0
  13. package/dist/src/core/renderers/canvas/CanvasCoreRenderer.d.ts +33 -0
  14. package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js +250 -0
  15. package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js.map +1 -0
  16. package/dist/src/core/renderers/canvas/CanvasCoreTexture.d.ts +16 -0
  17. package/dist/src/core/renderers/canvas/CanvasCoreTexture.js +124 -0
  18. package/dist/src/core/renderers/canvas/CanvasCoreTexture.js.map +1 -0
  19. package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.d.ts +13 -0
  20. package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js +113 -192
  21. package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js.map +1 -1
  22. package/dist/src/core/renderers/canvas/internal/ColorUtils.d.ts +0 -2
  23. package/dist/src/core/renderers/canvas/internal/ColorUtils.js +0 -14
  24. package/dist/src/core/renderers/canvas/internal/ColorUtils.js.map +1 -1
  25. package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.d.ts +10 -0
  26. package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js +43 -0
  27. package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js.map +1 -0
  28. package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.d.ts +12 -0
  29. package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js +58 -0
  30. package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js.map +1 -0
  31. package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.d.ts +9 -0
  32. package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js +38 -0
  33. package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js.map +1 -0
  34. package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.d.ts +56 -0
  35. package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +239 -0
  36. package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +1 -0
  37. package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.d.ts +34 -0
  38. package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js +114 -0
  39. package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js.map +1 -0
  40. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.d.ts +133 -0
  41. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +616 -0
  42. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -0
  43. package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +83 -0
  44. package/dist/src/core/renderers/webgl/WebGlCoreShader.js +233 -0
  45. package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +1 -0
  46. package/dist/src/core/renderers/webgl/internal/ShaderUtils.js +35 -35
  47. package/dist/src/core/renderers/webgl/shaders/DefaultShader.d.ts +9 -0
  48. package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +87 -0
  49. package/dist/src/core/renderers/webgl/shaders/DefaultShader.js.map +1 -0
  50. package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.d.ts +10 -0
  51. package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +119 -0
  52. package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js.map +1 -0
  53. package/dist/src/core/renderers/webgl/shaders/DynamicShader.d.ts +29 -0
  54. package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +413 -0
  55. package/dist/src/core/renderers/webgl/shaders/DynamicShader.js.map +1 -0
  56. package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.d.ts +28 -0
  57. package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +131 -0
  58. package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js.map +1 -0
  59. package/dist/src/core/renderers/webgl/shaders/SdfShader.d.ts +47 -0
  60. package/dist/src/core/renderers/webgl/shaders/SdfShader.js +160 -0
  61. package/dist/src/core/renderers/webgl/shaders/SdfShader.js.map +1 -0
  62. package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.d.ts +31 -0
  63. package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +71 -0
  64. package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js.map +1 -0
  65. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.d.ts +30 -0
  66. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js +58 -0
  67. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js.map +1 -0
  68. package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.d.ts +31 -0
  69. package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +71 -0
  70. package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js.map +1 -0
  71. package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.d.ts +31 -0
  72. package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +71 -0
  73. package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js.map +1 -0
  74. package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.d.ts +31 -0
  75. package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +71 -0
  76. package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js.map +1 -0
  77. package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.d.ts +9 -0
  78. package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js +136 -0
  79. package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js.map +1 -0
  80. package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.d.ts +36 -0
  81. package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js +85 -0
  82. package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js.map +1 -0
  83. package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.d.ts +45 -0
  84. package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js +104 -0
  85. package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js.map +1 -0
  86. package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.d.ts +22 -0
  87. package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js +45 -0
  88. package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js.map +1 -0
  89. package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.d.ts +58 -0
  90. package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js +80 -0
  91. package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js.map +1 -0
  92. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.d.ts +35 -0
  93. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +129 -0
  94. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js.map +1 -0
  95. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.d.ts +39 -0
  96. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +116 -0
  97. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js.map +1 -0
  98. package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.d.ts +61 -0
  99. package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js +127 -0
  100. package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js.map +1 -0
  101. package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.d.ts +40 -0
  102. package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +71 -0
  103. package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js.map +1 -0
  104. package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.d.ts +115 -0
  105. package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js +61 -0
  106. package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js.map +1 -0
  107. package/dist/src/core/shaders/templates/shaderUtils.d.ts +5 -0
  108. package/dist/src/core/shaders/templates/shaderUtils.js +41 -0
  109. package/dist/src/core/shaders/templates/shaderUtils.js.map +1 -0
  110. package/dist/src/core/shaders/webgl/Border.js +82 -82
  111. package/dist/src/core/shaders/webgl/Default.js +47 -47
  112. package/dist/src/core/shaders/webgl/DefaultBatched.js +61 -61
  113. package/dist/src/core/shaders/webgl/HolePunch.js +32 -32
  114. package/dist/src/core/shaders/webgl/LinearGradient.js +36 -36
  115. package/dist/src/core/shaders/webgl/RadialGradient.js +33 -33
  116. package/dist/src/core/shaders/webgl/Rounded.js +71 -71
  117. package/dist/src/core/shaders/webgl/RoundedWithBorder.js +111 -111
  118. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +130 -130
  119. package/dist/src/core/shaders/webgl/RoundedWithShadow.js +54 -54
  120. package/dist/src/core/shaders/webgl/SdfShader.js +62 -62
  121. package/dist/src/core/shaders/webgl/Shadow.js +83 -83
  122. package/dist/src/core/shaders/webgl/Spinner.d.ts +1 -0
  123. package/dist/src/core/shaders/webgl/Spinner.js +2 -0
  124. package/dist/src/core/shaders/webgl/Spinner.js.map +1 -0
  125. package/dist/src/core/text-rendering/CanvasFontHandler.d.ts +16 -0
  126. package/dist/src/core/text-rendering/CanvasFontHandler.js +29 -0
  127. package/dist/src/core/text-rendering/CanvasFontHandler.js.map +1 -1
  128. package/dist/src/core/text-rendering/SdfFontHandler.d.ts +15 -0
  129. package/dist/src/core/text-rendering/SdfFontHandler.js +34 -2
  130. package/dist/src/core/text-rendering/SdfFontHandler.js.map +1 -1
  131. package/dist/src/core/text-rendering/TextRenderer.d.ts +2 -0
  132. package/dist/src/core/text-rendering/TextTextureRendererUtils.js.map +1 -1
  133. package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js +2 -2
  134. package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js.map +1 -1
  135. package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js +0 -5
  136. package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js.map +1 -1
  137. package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.d.ts +1 -7
  138. package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js +2 -50
  139. package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js.map +1 -1
  140. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.d.ts +3 -2
  141. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +83 -42
  142. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -1
  143. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.d.ts +1 -1
  144. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js +8 -66
  145. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js.map +1 -1
  146. package/dist/src/core/text-rendering/renderers/TextRenderer.d.ts +4 -14
  147. package/dist/src/core/text-rendering/renderers/TextRenderer.js +0 -3
  148. package/dist/src/core/text-rendering/renderers/TextRenderer.js.map +1 -1
  149. package/dist/src/core/text-rendering/sdf/PeekableGenerator.d.ts +12 -0
  150. package/dist/src/core/text-rendering/sdf/PeekableGenerator.js +61 -0
  151. package/dist/src/core/text-rendering/sdf/PeekableGenerator.js.map +1 -0
  152. package/dist/src/core/text-rendering/sdf/SimpleFontShaper.d.ts +45 -0
  153. package/dist/src/core/text-rendering/sdf/SimpleFontShaper.js +69 -0
  154. package/dist/src/core/text-rendering/sdf/SimpleFontShaper.js.map +1 -0
  155. package/dist/src/main-api/DynamicShaderController.d.ts +29 -0
  156. package/dist/src/main-api/DynamicShaderController.js +58 -0
  157. package/dist/src/main-api/DynamicShaderController.js.map +1 -0
  158. package/dist/src/main-api/ShaderController.d.ts +31 -0
  159. package/dist/src/main-api/ShaderController.js +37 -0
  160. package/dist/src/main-api/ShaderController.js.map +1 -0
  161. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  162. package/exports/canvas-shaders.ts +28 -28
  163. package/exports/canvas.ts +45 -45
  164. package/exports/index.ts +82 -82
  165. package/exports/inspector.ts +24 -24
  166. package/exports/utils.ts +50 -50
  167. package/exports/webgl-shaders.ts +28 -28
  168. package/exports/webgl.ts +52 -52
  169. package/package.json +2 -1
  170. package/src/common/CommonTypes.ts +146 -146
  171. package/src/common/EventEmitter.ts +77 -77
  172. package/src/common/IAnimationController.ts +92 -92
  173. package/src/common/IEventEmitter.ts +28 -28
  174. package/src/core/CoreNode.test.ts +202 -202
  175. package/src/core/CoreNode.ts +2491 -2491
  176. package/src/core/CoreShaderManager.ts +188 -188
  177. package/src/core/CoreTextNode.ts +483 -443
  178. package/src/core/CoreTextureManager.ts +565 -565
  179. package/src/core/Stage.ts +906 -906
  180. package/src/core/TextureMemoryManager.ts +445 -445
  181. package/src/core/animations/AnimationManager.ts +38 -38
  182. package/src/core/animations/CoreAnimation.ts +291 -291
  183. package/src/core/animations/CoreAnimationController.ts +166 -166
  184. package/src/core/lib/ContextSpy.ts +41 -41
  185. package/src/core/lib/ImageWorker.ts +286 -286
  186. package/src/core/lib/Matrix3d.ts +244 -244
  187. package/src/core/lib/RenderCoords.ts +71 -71
  188. package/src/core/lib/WebGlContextWrapper.ts +1381 -1381
  189. package/src/core/lib/colorCache.ts +20 -20
  190. package/src/core/lib/colorParser.ts +85 -85
  191. package/src/core/lib/textureCompression.ts +152 -152
  192. package/src/core/lib/textureSvg.ts +78 -78
  193. package/src/core/lib/utils.ts +412 -412
  194. package/src/core/lib/validateImageBitmap.ts +87 -87
  195. package/src/core/platforms/Platform.ts +77 -77
  196. package/src/core/platforms/web/WebPlatform.ts +121 -121
  197. package/src/core/renderers/CoreContextTexture.ts +43 -43
  198. package/src/core/renderers/CoreRenderOp.ts +22 -22
  199. package/src/core/renderers/CoreRenderer.ts +110 -110
  200. package/src/core/renderers/CoreShaderNode.ts +175 -175
  201. package/src/core/renderers/CoreShaderProgram.ts +23 -23
  202. package/src/core/renderers/canvas/CanvasRenderer.ts +283 -283
  203. package/src/core/renderers/canvas/CanvasShaderNode.ts +96 -96
  204. package/src/core/renderers/canvas/CanvasTexture.ts +156 -156
  205. package/src/core/renderers/webgl/WebGlCtxRenderTexture.ts +91 -91
  206. package/src/core/renderers/webgl/WebGlCtxSubTexture.ts +50 -50
  207. package/src/core/renderers/webgl/WebGlCtxTexture.ts +310 -310
  208. package/src/core/renderers/webgl/WebGlRenderOp.ts +167 -167
  209. package/src/core/renderers/webgl/WebGlRenderer.ts +747 -747
  210. package/src/core/renderers/webgl/WebGlShaderNode.ts +435 -435
  211. package/src/core/renderers/webgl/WebGlShaderProgram.ts +341 -341
  212. package/src/core/renderers/webgl/internal/BufferCollection.ts +54 -54
  213. package/src/core/renderers/webgl/internal/RendererUtils.ts +155 -155
  214. package/src/core/renderers/webgl/internal/ShaderUtils.ts +281 -281
  215. package/src/core/renderers/webgl/internal/WebGlUtils.ts +35 -35
  216. package/src/core/shaders/canvas/Border.ts +75 -75
  217. package/src/core/shaders/canvas/HolePunch.ts +62 -62
  218. package/src/core/shaders/canvas/LinearGradient.ts +71 -71
  219. package/src/core/shaders/canvas/RadialGradient.ts +99 -99
  220. package/src/core/shaders/canvas/Rounded.ts +55 -55
  221. package/src/core/shaders/canvas/RoundedWithBorder.ts +74 -74
  222. package/src/core/shaders/canvas/RoundedWithBorderAndShadow.ts +90 -90
  223. package/src/core/shaders/canvas/RoundedWithShadow.ts +70 -70
  224. package/src/core/shaders/canvas/Shadow.ts +52 -52
  225. package/src/core/shaders/canvas/utils/render.ts +151 -151
  226. package/src/core/shaders/templates/BorderTemplate.ts +115 -115
  227. package/src/core/shaders/templates/HolePunchTemplate.ts +82 -82
  228. package/src/core/shaders/templates/LinearGradientTemplate.ts +71 -71
  229. package/src/core/shaders/templates/RadialGradientTemplate.ts +81 -81
  230. package/src/core/shaders/templates/RoundedTemplate.ts +98 -98
  231. package/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.ts +38 -38
  232. package/src/core/shaders/templates/RoundedWithBorderTemplate.ts +35 -35
  233. package/src/core/shaders/templates/RoundedWithShadowTemplate.ts +35 -35
  234. package/src/core/shaders/templates/ShadowTemplate.ts +106 -106
  235. package/src/core/shaders/utils.ts +46 -46
  236. package/src/core/shaders/webgl/Border.ts +116 -116
  237. package/src/core/shaders/webgl/Default.ts +89 -89
  238. package/src/core/shaders/webgl/DefaultBatched.ts +129 -129
  239. package/src/core/shaders/webgl/HolePunch.ts +75 -75
  240. package/src/core/shaders/webgl/LinearGradient.ts +82 -82
  241. package/src/core/shaders/webgl/RadialGradient.ts +85 -85
  242. package/src/core/shaders/webgl/Rounded.ts +117 -117
  243. package/src/core/shaders/webgl/RoundedWithBorder.ts +155 -155
  244. package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +175 -175
  245. package/src/core/shaders/webgl/RoundedWithShadow.ts +98 -98
  246. package/src/core/shaders/webgl/SdfShader.ts +134 -134
  247. package/src/core/shaders/webgl/Shadow.ts +115 -115
  248. package/src/core/text-rendering/CanvasFontHandler.ts +210 -176
  249. package/src/core/text-rendering/CanvasTextRenderer.ts +622 -622
  250. package/src/core/text-rendering/SdfFontHandler.ts +554 -517
  251. package/src/core/text-rendering/SdfTextRenderer.ts +466 -466
  252. package/src/core/text-rendering/TextRenderer.ts +406 -404
  253. package/src/core/text-rendering/Utils.ts +257 -257
  254. package/src/core/text-rendering/canvas/Settings.ts +99 -99
  255. package/src/core/text-rendering/canvas/Utils.test.ts +206 -206
  256. package/src/core/text-rendering/canvas/Utils.ts +178 -178
  257. package/src/core/text-rendering/canvas/calculateRenderInfo.ts +299 -299
  258. package/src/core/text-rendering/canvas/draw.ts +165 -165
  259. package/src/core/text-rendering/sdf/Utils.test.ts +402 -402
  260. package/src/core/text-rendering/sdf/Utils.ts +436 -436
  261. package/src/core/text-rendering/sdf/index.ts +20 -20
  262. package/src/core/textures/ColorTexture.ts +102 -102
  263. package/src/core/textures/ImageTexture.ts +418 -418
  264. package/src/core/textures/NoiseTexture.ts +104 -104
  265. package/src/core/textures/RenderTexture.ts +85 -85
  266. package/src/core/textures/SubTexture.ts +205 -205
  267. package/src/core/textures/Texture.ts +381 -381
  268. package/src/core/utils.ts +227 -227
  269. package/src/env.d.ts +7 -7
  270. package/src/main-api/INode.ts +100 -100
  271. package/src/main-api/Inspector.ts +567 -567
  272. package/src/main-api/Renderer.ts +873 -873
  273. package/src/main-api/utils.ts +45 -45
  274. package/src/utils.ts +267 -267
  275. package/COPYING +0 -1
@@ -1,435 +1,435 @@
1
- import type { CoreNode } from '../../CoreNode.js';
2
- import { getNormalizedRgbaComponents } from '../../lib/utils.js';
3
- import type { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js';
4
- import type { Stage } from '../../Stage.js';
5
- import type { QuadOptions } from '../CoreRenderer.js';
6
- import { CoreShaderNode, type CoreShaderType } from '../CoreShaderNode.js';
7
- import type {
8
- UniformCollection,
9
- Vec2,
10
- Vec3,
11
- Vec4,
12
- } from './internal/ShaderUtils.js';
13
- import type { WebGlRenderer } from './WebGlRenderer.js';
14
- import type { WebGlRenderOp } from './WebGlRenderOp.js';
15
- import type { WebGlShaderProgram } from './WebGlShaderProgram.js';
16
-
17
- export type ShaderSource<T> =
18
- | string
19
- | ((renderer: WebGlRenderer, props: T) => string);
20
-
21
- /**
22
- * This is the WebGL specific ShaderType @mixes CoreShaderType
23
- */
24
- export type WebGlShaderType<T extends object = Record<string, unknown>> =
25
- CoreShaderType<T> & {
26
- /**
27
- * fragment shader source for WebGl or WebGl2
28
- */
29
- fragment: ShaderSource<T>;
30
- /**
31
- * vertex shader source for WebGl or WebGl2
32
- */
33
- vertex?: ShaderSource<T>;
34
- /**
35
- * This function is called when one of the props is changed, here you can update the uniforms you use in the fragment / vertex shader.
36
- * @param node WebGlContextWrapper with utilities to update uniforms, and other actions.
37
- */
38
- update?: (this: WebGlShaderNode<T>, node: CoreNode) => void;
39
-
40
- /**
41
- * only used for SDF shader, will be removed in the future.
42
- *
43
- * @warning don't use this in your shader type
44
- */
45
- onSdfBind?: (this: WebGlContextWrapper, props: T) => void;
46
- /**
47
- * This function is used to check if the shader can be reused based on quad info
48
- * @param props
49
- */
50
- canBatch?: (
51
- incomingQuad: QuadOptions,
52
- currentRenderOp: WebGlRenderOp,
53
- ) => boolean;
54
- /**
55
- * extensions required for specific shader?
56
- */
57
- webgl1Extensions?: string[];
58
- webgl2Extensions?: string[];
59
- supportsIndexedTextures?: boolean;
60
- };
61
-
62
- export class WebGlShaderNode<
63
- Props extends object = Record<string, unknown>,
64
- > extends CoreShaderNode<Props> {
65
- readonly program: WebGlShaderProgram;
66
- private updater: ((node: CoreNode, props?: Props) => void) | undefined =
67
- undefined;
68
- private valueKey: string = '';
69
- uniforms: UniformCollection = {
70
- single: {},
71
- vec2: {},
72
- vec3: {},
73
- vec4: {},
74
- };
75
-
76
- constructor(
77
- shaderKey: string,
78
- config: WebGlShaderType<Props>,
79
- program: WebGlShaderProgram,
80
- stage: Stage,
81
- props?: Props,
82
- ) {
83
- super(shaderKey, config, stage, props);
84
- this.program = program;
85
- if (config.update !== undefined) {
86
- this.updater = config.update!;
87
-
88
- this.update = () => {
89
- if (this.props === undefined) {
90
- this.updater!(this.node as CoreNode, this.props);
91
- return;
92
- }
93
-
94
- const prevKey = this.valueKey;
95
- this.valueKey = this.createValueKey();
96
-
97
- if (prevKey === this.valueKey) {
98
- return;
99
- }
100
-
101
- if (prevKey.length > 0) {
102
- this.stage.shManager.mutateShaderValueUsage(prevKey, -1);
103
- }
104
-
105
- const values = this.stage.shManager.getShaderValues(
106
- this.valueKey,
107
- ) as unknown as UniformCollection;
108
- if (values !== undefined) {
109
- this.uniforms = values;
110
- return;
111
- }
112
- //create empty uniform collection when calculating new values
113
- this.uniforms = {
114
- single: {},
115
- vec2: {},
116
- vec3: {},
117
- vec4: {},
118
- };
119
- this.updater!(this.node as CoreNode);
120
- this.stage.shManager.setShaderValues(
121
- this.valueKey,
122
- this.uniforms as unknown as Record<string, unknown>,
123
- );
124
- };
125
- }
126
- }
127
-
128
- /**
129
- * Sets the value of a RGBA variable
130
- * @param location
131
- * @param value
132
- */
133
- uniformRGBA(location: string, value: number) {
134
- this.uniform4fv(
135
- location,
136
- new Float32Array(getNormalizedRgbaComponents(value)),
137
- );
138
- }
139
-
140
- /**
141
- * Sets the value of a single float uniform variable.
142
- *
143
- * @param location - The location of the uniform variable.
144
- * @param v0 - The value to set.
145
- */
146
- uniform1f(location: string, value: number) {
147
- this.uniforms.single[location] = {
148
- method: 'uniform1f',
149
- value,
150
- };
151
- }
152
-
153
- /**
154
- * Sets the value of a float array uniform variable.
155
- *
156
- * @param location - The location of the uniform variable.
157
- * @param value - The array of values to set.
158
- */
159
- uniform1fv(location: string, value: Float32Array) {
160
- this.uniforms.single[location] = {
161
- method: 'uniform1fv',
162
- value,
163
- };
164
- }
165
-
166
- /**
167
- * Sets the value of a single integer uniform variable.
168
- *
169
- * @param location - The location of the uniform variable.
170
- * @param v0 - The value to set.
171
- */
172
- uniform1i(location: string, value: number) {
173
- this.uniforms.single[location] = {
174
- method: 'uniform1i',
175
- value,
176
- };
177
- }
178
-
179
- /**
180
- * Sets the value of an integer array uniform variable.
181
- *
182
- * @param location - The location of the uniform variable.
183
- * @param value - The array of values to set.
184
- */
185
- uniform1iv(location: string, value: Int32Array) {
186
- this.uniforms.single[location] = {
187
- method: 'uniform1iv',
188
- value,
189
- };
190
- }
191
-
192
- /**
193
- * Sets the value of a vec2 uniform variable.
194
- *
195
- * @param location - The location of the uniform variable.
196
- * @param v0 - The first component of the vector.
197
- * @param v1 - The second component of the vector.
198
- */
199
- uniform2f(location: string, v0: number, v1: number) {
200
- this.uniforms.vec2[location] = {
201
- method: 'uniform2f',
202
- value: [v0, v1],
203
- };
204
- }
205
-
206
- /**
207
- * Sets the value of a vec2 array uniform variable.
208
- *
209
- * @param location - The location of the uniform variable.
210
- * @param value - The array of vec2 values to set as FloatArray.
211
- */
212
- uniform2fv(location: string, value: Float32Array) {
213
- this.uniforms.single[location] = {
214
- method: 'uniform2fv',
215
- value,
216
- };
217
- }
218
-
219
- /**
220
- * Sets the value of a vec2 array uniform variable.
221
- *
222
- * @param location - The location of the uniform variable.
223
- * @param value - The array of vec2 values to set.
224
- */
225
- uniform2fa(location: string, value: Vec2) {
226
- this.uniforms.vec2[location] = {
227
- method: 'uniform2f',
228
- value,
229
- };
230
- }
231
-
232
- /**
233
- * Sets the value of a ivec2 uniform variable.
234
- *
235
- * @param location - The location of the uniform variable.
236
- * @param v0 - The first component of the vector.
237
- * @param v1 - The second component of the vector.
238
- */
239
- uniform2i(location: string, v0: number, v1: number) {
240
- this.uniforms.vec2[location] = {
241
- method: 'uniform2i',
242
- value: [v0, v1],
243
- };
244
- }
245
-
246
- /**
247
- * Sets the value of an ivec2 array uniform variable.
248
- *
249
- * @param location - The location of the uniform variable.
250
- * @param value - The array of ivec2 values to set.
251
- */
252
- uniform2iv(location: string, value: Int32Array) {
253
- this.uniforms.single[location] = {
254
- method: 'uniform2iv',
255
- value,
256
- };
257
- }
258
-
259
- /**
260
- * Sets the value of a vec3 uniform variable.
261
- *
262
- * @param location - The location of the uniform variable.
263
- * @param v0 - The first component of the vector.
264
- * @param v1 - The second component of the vector.
265
- * @param v2 - The third component of the vector.
266
- */
267
- uniform3f(location: string, v0: number, v1: number, v2: number) {
268
- this.uniforms.vec3[location] = {
269
- method: 'uniform3f',
270
- value: [v0, v1, v2],
271
- };
272
- }
273
-
274
- /**
275
- * Sets the value of a vec3 uniform variable.
276
- *
277
- * @param location - The location of the uniform variable.
278
- * @param
279
- */
280
- uniform3fa(location: string, value: Vec3) {
281
- this.uniforms.vec3[location] = {
282
- method: 'uniform3f',
283
- value,
284
- };
285
- }
286
-
287
- /**
288
- * Sets the value of a vec3 array uniform variable.
289
- *
290
- * @param location - The location of the uniform variable.
291
- * @param value - The array of vec3 values to set.
292
- */
293
- uniform3fv(location: string, value: Float32Array) {
294
- this.uniforms.single[location] = {
295
- method: 'uniform3fv',
296
- value,
297
- };
298
- }
299
-
300
- /**
301
- * Sets the value of a ivec3 uniform variable.
302
- *
303
- * @param location - The location of the uniform variable.
304
- * @param v0 - The first component of the vector.
305
- * @param v1 - The second component of the vector.
306
- * @param v2 - The third component of the vector.
307
- */
308
- uniform3i(location: string, v0: number, v1: number, v2: number) {
309
- this.uniforms.vec3[location] = {
310
- method: 'uniform3i',
311
- value: [v0, v1, v2],
312
- };
313
- }
314
-
315
- /**
316
- * Sets the value of an ivec3 array uniform variable.
317
- *
318
- * @param location - The location of the uniform variable.
319
- * @param value - The array of ivec3 values to set.
320
- */
321
- uniform3iv(location: string, value: Int32Array) {
322
- this.uniforms.single[location] = {
323
- method: 'uniform3iv',
324
- value,
325
- };
326
- }
327
-
328
- /**
329
- * Sets the value of a vec4 uniform variable.
330
- *
331
- * @param location - The location of the uniform variable.
332
- * @param v0 - The first component of the vector.
333
- * @param v1 - The second component of the vector.
334
- * @param v2 - The third component of the vector.
335
- * @param v3 - The fourth component of the vector.
336
- */
337
- uniform4f(location: string, v0: number, v1: number, v2: number, v3: number) {
338
- this.uniforms.vec4[location] = {
339
- method: 'uniform4f',
340
- value: [v0, v1, v2, v3],
341
- };
342
- }
343
-
344
- /**
345
- * Sets an array of numbers
346
- * @param location The location of the uniform variable.
347
- * @param value
348
- */
349
- uniform4fa(location: string, value: Vec4) {
350
- this.uniforms.vec4[location] = {
351
- method: 'uniform4f',
352
- value,
353
- };
354
- }
355
-
356
- /**
357
- * Sets the value of a vec4 array uniform variable.
358
- *
359
- * @param location - The location of the uniform variable.
360
- * @param value - The array of vec4 values to set.
361
- */
362
- uniform4fv(location: string, value: Float32Array) {
363
- this.uniforms.single[location] = {
364
- method: 'uniform4fv',
365
- value,
366
- };
367
- }
368
-
369
- /**
370
- * Sets the value of a ivec4 uniform variable.
371
- *
372
- * @param location - The location of the uniform variable.
373
- * @param v0 - The first component of the vector.
374
- * @param v1 - The second component of the vector.
375
- * @param v2 - The third component of the vector.
376
- * @param v3 - The fourth component of the vector.
377
- */
378
- uniform4i(location: string, v0: number, v1: number, v2: number, v3: number) {
379
- this.uniforms.vec4[location] = {
380
- method: 'uniform4i',
381
- value: [v0, v1, v2, v3],
382
- };
383
- }
384
-
385
- /**
386
- * Sets the value of an ivec4 array uniform variable.
387
- *
388
- * @param location - The location of the uniform variable.
389
- * @param value - The array of ivec4 values to set.
390
- */
391
- uniform4iv(location: string, value: Int32Array) {
392
- this.uniforms.single[location] = {
393
- method: 'uniform4iv',
394
- value,
395
- };
396
- }
397
-
398
- /**
399
- * Sets the value of a mat2 uniform variable.
400
- *
401
- * @param location - The location of the uniform variable.
402
- * @param transpose - Whether to transpose the matrix.
403
- * @param value - The array of mat2 values to set.
404
- */
405
- uniformMatrix2fv(location: string, value: Float32Array) {
406
- this.uniforms.single[location] = {
407
- method: 'uniformMatrix2fv',
408
- value,
409
- };
410
- }
411
-
412
- /**
413
- * Sets the value of a mat2 uniform variable.
414
- * @param location - The location of the uniform variable.
415
- * @param value - The array of mat2 values to set.
416
- */
417
- uniformMatrix3fv(location: string, value: Float32Array) {
418
- this.uniforms.single[location] = {
419
- method: 'uniformMatrix3fv',
420
- value,
421
- };
422
- }
423
-
424
- /**
425
- * Sets the value of a mat4 uniform variable.
426
- * @param location - The location of the uniform variable.
427
- * @param value - The array of mat4 values to set.
428
- */
429
- uniformMatrix4fv(location: string, value: Float32Array) {
430
- this.uniforms.single[location] = {
431
- method: 'uniformMatrix4fv',
432
- value,
433
- };
434
- }
435
- }
1
+ import type { CoreNode } from '../../CoreNode.js';
2
+ import { getNormalizedRgbaComponents } from '../../lib/utils.js';
3
+ import type { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js';
4
+ import type { Stage } from '../../Stage.js';
5
+ import type { QuadOptions } from '../CoreRenderer.js';
6
+ import { CoreShaderNode, type CoreShaderType } from '../CoreShaderNode.js';
7
+ import type {
8
+ UniformCollection,
9
+ Vec2,
10
+ Vec3,
11
+ Vec4,
12
+ } from './internal/ShaderUtils.js';
13
+ import type { WebGlRenderer } from './WebGlRenderer.js';
14
+ import type { WebGlRenderOp } from './WebGlRenderOp.js';
15
+ import type { WebGlShaderProgram } from './WebGlShaderProgram.js';
16
+
17
+ export type ShaderSource<T> =
18
+ | string
19
+ | ((renderer: WebGlRenderer, props: T) => string);
20
+
21
+ /**
22
+ * This is the WebGL specific ShaderType @mixes CoreShaderType
23
+ */
24
+ export type WebGlShaderType<T extends object = Record<string, unknown>> =
25
+ CoreShaderType<T> & {
26
+ /**
27
+ * fragment shader source for WebGl or WebGl2
28
+ */
29
+ fragment: ShaderSource<T>;
30
+ /**
31
+ * vertex shader source for WebGl or WebGl2
32
+ */
33
+ vertex?: ShaderSource<T>;
34
+ /**
35
+ * This function is called when one of the props is changed, here you can update the uniforms you use in the fragment / vertex shader.
36
+ * @param node WebGlContextWrapper with utilities to update uniforms, and other actions.
37
+ */
38
+ update?: (this: WebGlShaderNode<T>, node: CoreNode) => void;
39
+
40
+ /**
41
+ * only used for SDF shader, will be removed in the future.
42
+ *
43
+ * @warning don't use this in your shader type
44
+ */
45
+ onSdfBind?: (this: WebGlContextWrapper, props: T) => void;
46
+ /**
47
+ * This function is used to check if the shader can be reused based on quad info
48
+ * @param props
49
+ */
50
+ canBatch?: (
51
+ incomingQuad: QuadOptions,
52
+ currentRenderOp: WebGlRenderOp,
53
+ ) => boolean;
54
+ /**
55
+ * extensions required for specific shader?
56
+ */
57
+ webgl1Extensions?: string[];
58
+ webgl2Extensions?: string[];
59
+ supportsIndexedTextures?: boolean;
60
+ };
61
+
62
+ export class WebGlShaderNode<
63
+ Props extends object = Record<string, unknown>,
64
+ > extends CoreShaderNode<Props> {
65
+ readonly program: WebGlShaderProgram;
66
+ private updater: ((node: CoreNode, props?: Props) => void) | undefined =
67
+ undefined;
68
+ private valueKey: string = '';
69
+ uniforms: UniformCollection = {
70
+ single: {},
71
+ vec2: {},
72
+ vec3: {},
73
+ vec4: {},
74
+ };
75
+
76
+ constructor(
77
+ shaderKey: string,
78
+ config: WebGlShaderType<Props>,
79
+ program: WebGlShaderProgram,
80
+ stage: Stage,
81
+ props?: Props,
82
+ ) {
83
+ super(shaderKey, config, stage, props);
84
+ this.program = program;
85
+ if (config.update !== undefined) {
86
+ this.updater = config.update!;
87
+
88
+ this.update = () => {
89
+ if (this.props === undefined) {
90
+ this.updater!(this.node as CoreNode, this.props);
91
+ return;
92
+ }
93
+
94
+ const prevKey = this.valueKey;
95
+ this.valueKey = this.createValueKey();
96
+
97
+ if (prevKey === this.valueKey) {
98
+ return;
99
+ }
100
+
101
+ if (prevKey.length > 0) {
102
+ this.stage.shManager.mutateShaderValueUsage(prevKey, -1);
103
+ }
104
+
105
+ const values = this.stage.shManager.getShaderValues(
106
+ this.valueKey,
107
+ ) as unknown as UniformCollection;
108
+ if (values !== undefined) {
109
+ this.uniforms = values;
110
+ return;
111
+ }
112
+ //create empty uniform collection when calculating new values
113
+ this.uniforms = {
114
+ single: {},
115
+ vec2: {},
116
+ vec3: {},
117
+ vec4: {},
118
+ };
119
+ this.updater!(this.node as CoreNode);
120
+ this.stage.shManager.setShaderValues(
121
+ this.valueKey,
122
+ this.uniforms as unknown as Record<string, unknown>,
123
+ );
124
+ };
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Sets the value of a RGBA variable
130
+ * @param location
131
+ * @param value
132
+ */
133
+ uniformRGBA(location: string, value: number) {
134
+ this.uniform4fv(
135
+ location,
136
+ new Float32Array(getNormalizedRgbaComponents(value)),
137
+ );
138
+ }
139
+
140
+ /**
141
+ * Sets the value of a single float uniform variable.
142
+ *
143
+ * @param location - The location of the uniform variable.
144
+ * @param v0 - The value to set.
145
+ */
146
+ uniform1f(location: string, value: number) {
147
+ this.uniforms.single[location] = {
148
+ method: 'uniform1f',
149
+ value,
150
+ };
151
+ }
152
+
153
+ /**
154
+ * Sets the value of a float array uniform variable.
155
+ *
156
+ * @param location - The location of the uniform variable.
157
+ * @param value - The array of values to set.
158
+ */
159
+ uniform1fv(location: string, value: Float32Array) {
160
+ this.uniforms.single[location] = {
161
+ method: 'uniform1fv',
162
+ value,
163
+ };
164
+ }
165
+
166
+ /**
167
+ * Sets the value of a single integer uniform variable.
168
+ *
169
+ * @param location - The location of the uniform variable.
170
+ * @param v0 - The value to set.
171
+ */
172
+ uniform1i(location: string, value: number) {
173
+ this.uniforms.single[location] = {
174
+ method: 'uniform1i',
175
+ value,
176
+ };
177
+ }
178
+
179
+ /**
180
+ * Sets the value of an integer array uniform variable.
181
+ *
182
+ * @param location - The location of the uniform variable.
183
+ * @param value - The array of values to set.
184
+ */
185
+ uniform1iv(location: string, value: Int32Array) {
186
+ this.uniforms.single[location] = {
187
+ method: 'uniform1iv',
188
+ value,
189
+ };
190
+ }
191
+
192
+ /**
193
+ * Sets the value of a vec2 uniform variable.
194
+ *
195
+ * @param location - The location of the uniform variable.
196
+ * @param v0 - The first component of the vector.
197
+ * @param v1 - The second component of the vector.
198
+ */
199
+ uniform2f(location: string, v0: number, v1: number) {
200
+ this.uniforms.vec2[location] = {
201
+ method: 'uniform2f',
202
+ value: [v0, v1],
203
+ };
204
+ }
205
+
206
+ /**
207
+ * Sets the value of a vec2 array uniform variable.
208
+ *
209
+ * @param location - The location of the uniform variable.
210
+ * @param value - The array of vec2 values to set as FloatArray.
211
+ */
212
+ uniform2fv(location: string, value: Float32Array) {
213
+ this.uniforms.single[location] = {
214
+ method: 'uniform2fv',
215
+ value,
216
+ };
217
+ }
218
+
219
+ /**
220
+ * Sets the value of a vec2 array uniform variable.
221
+ *
222
+ * @param location - The location of the uniform variable.
223
+ * @param value - The array of vec2 values to set.
224
+ */
225
+ uniform2fa(location: string, value: Vec2) {
226
+ this.uniforms.vec2[location] = {
227
+ method: 'uniform2f',
228
+ value,
229
+ };
230
+ }
231
+
232
+ /**
233
+ * Sets the value of a ivec2 uniform variable.
234
+ *
235
+ * @param location - The location of the uniform variable.
236
+ * @param v0 - The first component of the vector.
237
+ * @param v1 - The second component of the vector.
238
+ */
239
+ uniform2i(location: string, v0: number, v1: number) {
240
+ this.uniforms.vec2[location] = {
241
+ method: 'uniform2i',
242
+ value: [v0, v1],
243
+ };
244
+ }
245
+
246
+ /**
247
+ * Sets the value of an ivec2 array uniform variable.
248
+ *
249
+ * @param location - The location of the uniform variable.
250
+ * @param value - The array of ivec2 values to set.
251
+ */
252
+ uniform2iv(location: string, value: Int32Array) {
253
+ this.uniforms.single[location] = {
254
+ method: 'uniform2iv',
255
+ value,
256
+ };
257
+ }
258
+
259
+ /**
260
+ * Sets the value of a vec3 uniform variable.
261
+ *
262
+ * @param location - The location of the uniform variable.
263
+ * @param v0 - The first component of the vector.
264
+ * @param v1 - The second component of the vector.
265
+ * @param v2 - The third component of the vector.
266
+ */
267
+ uniform3f(location: string, v0: number, v1: number, v2: number) {
268
+ this.uniforms.vec3[location] = {
269
+ method: 'uniform3f',
270
+ value: [v0, v1, v2],
271
+ };
272
+ }
273
+
274
+ /**
275
+ * Sets the value of a vec3 uniform variable.
276
+ *
277
+ * @param location - The location of the uniform variable.
278
+ * @param
279
+ */
280
+ uniform3fa(location: string, value: Vec3) {
281
+ this.uniforms.vec3[location] = {
282
+ method: 'uniform3f',
283
+ value,
284
+ };
285
+ }
286
+
287
+ /**
288
+ * Sets the value of a vec3 array uniform variable.
289
+ *
290
+ * @param location - The location of the uniform variable.
291
+ * @param value - The array of vec3 values to set.
292
+ */
293
+ uniform3fv(location: string, value: Float32Array) {
294
+ this.uniforms.single[location] = {
295
+ method: 'uniform3fv',
296
+ value,
297
+ };
298
+ }
299
+
300
+ /**
301
+ * Sets the value of a ivec3 uniform variable.
302
+ *
303
+ * @param location - The location of the uniform variable.
304
+ * @param v0 - The first component of the vector.
305
+ * @param v1 - The second component of the vector.
306
+ * @param v2 - The third component of the vector.
307
+ */
308
+ uniform3i(location: string, v0: number, v1: number, v2: number) {
309
+ this.uniforms.vec3[location] = {
310
+ method: 'uniform3i',
311
+ value: [v0, v1, v2],
312
+ };
313
+ }
314
+
315
+ /**
316
+ * Sets the value of an ivec3 array uniform variable.
317
+ *
318
+ * @param location - The location of the uniform variable.
319
+ * @param value - The array of ivec3 values to set.
320
+ */
321
+ uniform3iv(location: string, value: Int32Array) {
322
+ this.uniforms.single[location] = {
323
+ method: 'uniform3iv',
324
+ value,
325
+ };
326
+ }
327
+
328
+ /**
329
+ * Sets the value of a vec4 uniform variable.
330
+ *
331
+ * @param location - The location of the uniform variable.
332
+ * @param v0 - The first component of the vector.
333
+ * @param v1 - The second component of the vector.
334
+ * @param v2 - The third component of the vector.
335
+ * @param v3 - The fourth component of the vector.
336
+ */
337
+ uniform4f(location: string, v0: number, v1: number, v2: number, v3: number) {
338
+ this.uniforms.vec4[location] = {
339
+ method: 'uniform4f',
340
+ value: [v0, v1, v2, v3],
341
+ };
342
+ }
343
+
344
+ /**
345
+ * Sets an array of numbers
346
+ * @param location The location of the uniform variable.
347
+ * @param value
348
+ */
349
+ uniform4fa(location: string, value: Vec4) {
350
+ this.uniforms.vec4[location] = {
351
+ method: 'uniform4f',
352
+ value,
353
+ };
354
+ }
355
+
356
+ /**
357
+ * Sets the value of a vec4 array uniform variable.
358
+ *
359
+ * @param location - The location of the uniform variable.
360
+ * @param value - The array of vec4 values to set.
361
+ */
362
+ uniform4fv(location: string, value: Float32Array) {
363
+ this.uniforms.single[location] = {
364
+ method: 'uniform4fv',
365
+ value,
366
+ };
367
+ }
368
+
369
+ /**
370
+ * Sets the value of a ivec4 uniform variable.
371
+ *
372
+ * @param location - The location of the uniform variable.
373
+ * @param v0 - The first component of the vector.
374
+ * @param v1 - The second component of the vector.
375
+ * @param v2 - The third component of the vector.
376
+ * @param v3 - The fourth component of the vector.
377
+ */
378
+ uniform4i(location: string, v0: number, v1: number, v2: number, v3: number) {
379
+ this.uniforms.vec4[location] = {
380
+ method: 'uniform4i',
381
+ value: [v0, v1, v2, v3],
382
+ };
383
+ }
384
+
385
+ /**
386
+ * Sets the value of an ivec4 array uniform variable.
387
+ *
388
+ * @param location - The location of the uniform variable.
389
+ * @param value - The array of ivec4 values to set.
390
+ */
391
+ uniform4iv(location: string, value: Int32Array) {
392
+ this.uniforms.single[location] = {
393
+ method: 'uniform4iv',
394
+ value,
395
+ };
396
+ }
397
+
398
+ /**
399
+ * Sets the value of a mat2 uniform variable.
400
+ *
401
+ * @param location - The location of the uniform variable.
402
+ * @param transpose - Whether to transpose the matrix.
403
+ * @param value - The array of mat2 values to set.
404
+ */
405
+ uniformMatrix2fv(location: string, value: Float32Array) {
406
+ this.uniforms.single[location] = {
407
+ method: 'uniformMatrix2fv',
408
+ value,
409
+ };
410
+ }
411
+
412
+ /**
413
+ * Sets the value of a mat2 uniform variable.
414
+ * @param location - The location of the uniform variable.
415
+ * @param value - The array of mat2 values to set.
416
+ */
417
+ uniformMatrix3fv(location: string, value: Float32Array) {
418
+ this.uniforms.single[location] = {
419
+ method: 'uniformMatrix3fv',
420
+ value,
421
+ };
422
+ }
423
+
424
+ /**
425
+ * Sets the value of a mat4 uniform variable.
426
+ * @param location - The location of the uniform variable.
427
+ * @param value - The array of mat4 values to set.
428
+ */
429
+ uniformMatrix4fv(location: string, value: Float32Array) {
430
+ this.uniforms.single[location] = {
431
+ method: 'uniformMatrix4fv',
432
+ value,
433
+ };
434
+ }
435
+ }