@lightningjs/renderer 3.0.0-beta10 → 3.0.0-beta12

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 (355) hide show
  1. package/LICENSE +202 -202
  2. package/NOTICE +3 -3
  3. package/README.md +133 -133
  4. package/dist/src/common/CommonTypes.d.ts +2 -2
  5. package/dist/src/core/CoreNode.d.ts +8 -7
  6. package/dist/src/core/CoreNode.js +57 -61
  7. package/dist/src/core/CoreNode.js.map +1 -1
  8. package/dist/src/core/CoreTextNode.d.ts +3 -0
  9. package/dist/src/core/CoreTextNode.js +54 -19
  10. package/dist/src/core/CoreTextNode.js.map +1 -1
  11. package/dist/src/core/Stage.js +4 -4
  12. package/dist/src/core/Stage.js.map +1 -1
  13. package/dist/src/core/lib/textureCompression.js +4 -4
  14. package/dist/src/core/lib/textureCompression.js.map +1 -1
  15. package/dist/src/core/platform.d.ts +10 -0
  16. package/dist/src/core/platform.js +81 -0
  17. package/dist/src/core/platform.js.map +1 -0
  18. package/dist/src/core/renderers/CoreShader.d.ts +9 -0
  19. package/dist/src/core/renderers/CoreShader.js +28 -0
  20. package/dist/src/core/renderers/CoreShader.js.map +1 -0
  21. package/dist/src/core/renderers/CoreShaderNode.js +2 -2
  22. package/dist/src/core/renderers/CoreShaderNode.js.map +1 -1
  23. package/dist/src/core/renderers/canvas/CanvasCoreRenderer.d.ts +33 -0
  24. package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js +250 -0
  25. package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js.map +1 -0
  26. package/dist/src/core/renderers/canvas/CanvasCoreTexture.d.ts +16 -0
  27. package/dist/src/core/renderers/canvas/CanvasCoreTexture.js +124 -0
  28. package/dist/src/core/renderers/canvas/CanvasCoreTexture.js.map +1 -0
  29. package/dist/src/core/renderers/canvas/CanvasRenderer.js +1 -1
  30. package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
  31. package/dist/src/core/renderers/canvas/CanvasTexture.js +5 -5
  32. package/dist/src/core/renderers/canvas/CanvasTexture.js.map +1 -1
  33. package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.d.ts +13 -0
  34. package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js +113 -192
  35. package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js.map +1 -1
  36. package/dist/src/core/renderers/canvas/internal/ColorUtils.d.ts +0 -2
  37. package/dist/src/core/renderers/canvas/internal/ColorUtils.js +0 -14
  38. package/dist/src/core/renderers/canvas/internal/ColorUtils.js.map +1 -1
  39. package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.d.ts +10 -0
  40. package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js +43 -0
  41. package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js.map +1 -0
  42. package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.d.ts +12 -0
  43. package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js +58 -0
  44. package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js.map +1 -0
  45. package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.d.ts +9 -0
  46. package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js +38 -0
  47. package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js.map +1 -0
  48. package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.d.ts +56 -0
  49. package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +239 -0
  50. package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +1 -0
  51. package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.d.ts +34 -0
  52. package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js +114 -0
  53. package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js.map +1 -0
  54. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.d.ts +133 -0
  55. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +616 -0
  56. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -0
  57. package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +83 -0
  58. package/dist/src/core/renderers/webgl/WebGlCoreShader.js +233 -0
  59. package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +1 -0
  60. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js +5 -6
  61. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js.map +1 -1
  62. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.d.ts +13 -0
  63. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js +34 -5
  64. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js.map +1 -1
  65. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +21 -21
  66. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -1
  67. package/dist/src/core/renderers/webgl/WebGlRenderOp.js +1 -1
  68. package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +1 -1
  69. package/dist/src/core/renderers/webgl/WebGlRenderer.js +12 -11
  70. package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
  71. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +2 -2
  72. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -1
  73. package/dist/src/core/renderers/webgl/internal/ShaderUtils.js +35 -35
  74. package/dist/src/core/renderers/webgl/shaders/DefaultShader.d.ts +9 -0
  75. package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +87 -0
  76. package/dist/src/core/renderers/webgl/shaders/DefaultShader.js.map +1 -0
  77. package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.d.ts +10 -0
  78. package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +119 -0
  79. package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js.map +1 -0
  80. package/dist/src/core/renderers/webgl/shaders/DynamicShader.d.ts +29 -0
  81. package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +413 -0
  82. package/dist/src/core/renderers/webgl/shaders/DynamicShader.js.map +1 -0
  83. package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.d.ts +28 -0
  84. package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +131 -0
  85. package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js.map +1 -0
  86. package/dist/src/core/renderers/webgl/shaders/SdfShader.d.ts +47 -0
  87. package/dist/src/core/renderers/webgl/shaders/SdfShader.js +160 -0
  88. package/dist/src/core/renderers/webgl/shaders/SdfShader.js.map +1 -0
  89. package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.d.ts +31 -0
  90. package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +71 -0
  91. package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js.map +1 -0
  92. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.d.ts +30 -0
  93. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js +58 -0
  94. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js.map +1 -0
  95. package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.d.ts +31 -0
  96. package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +71 -0
  97. package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js.map +1 -0
  98. package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.d.ts +31 -0
  99. package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +71 -0
  100. package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js.map +1 -0
  101. package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.d.ts +31 -0
  102. package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +71 -0
  103. package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js.map +1 -0
  104. package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.d.ts +9 -0
  105. package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js +136 -0
  106. package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js.map +1 -0
  107. package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.d.ts +36 -0
  108. package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js +85 -0
  109. package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js.map +1 -0
  110. package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.d.ts +45 -0
  111. package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js +104 -0
  112. package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js.map +1 -0
  113. package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.d.ts +22 -0
  114. package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js +45 -0
  115. package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js.map +1 -0
  116. package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.d.ts +58 -0
  117. package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js +80 -0
  118. package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js.map +1 -0
  119. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.d.ts +35 -0
  120. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +129 -0
  121. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js.map +1 -0
  122. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.d.ts +39 -0
  123. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +116 -0
  124. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js.map +1 -0
  125. package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.d.ts +61 -0
  126. package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js +127 -0
  127. package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js.map +1 -0
  128. package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.d.ts +40 -0
  129. package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +71 -0
  130. package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js.map +1 -0
  131. package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.d.ts +115 -0
  132. package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js +61 -0
  133. package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js.map +1 -0
  134. package/dist/src/core/shaders/canvas/Border.js +4 -4
  135. package/dist/src/core/shaders/canvas/Border.js.map +1 -1
  136. package/dist/src/core/shaders/canvas/HolePunch.js +3 -3
  137. package/dist/src/core/shaders/canvas/HolePunch.js.map +1 -1
  138. package/dist/src/core/shaders/canvas/LinearGradient.js +2 -2
  139. package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -1
  140. package/dist/src/core/shaders/canvas/RadialGradient.js +4 -4
  141. package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -1
  142. package/dist/src/core/shaders/canvas/Rounded.js +1 -1
  143. package/dist/src/core/shaders/canvas/Rounded.js.map +1 -1
  144. package/dist/src/core/shaders/canvas/RoundedWithBorder.js +3 -3
  145. package/dist/src/core/shaders/canvas/RoundedWithBorder.js.map +1 -1
  146. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js +3 -3
  147. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +1 -1
  148. package/dist/src/core/shaders/canvas/RoundedWithShadow.js +1 -1
  149. package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +1 -1
  150. package/dist/src/core/shaders/templates/BorderTemplate.d.ts +1 -1
  151. package/dist/src/core/shaders/templates/BorderTemplate.js +10 -10
  152. package/dist/src/core/shaders/templates/BorderTemplate.js.map +1 -1
  153. package/dist/src/core/shaders/templates/HolePunchTemplate.d.ts +2 -2
  154. package/dist/src/core/shaders/templates/HolePunchTemplate.js +2 -2
  155. package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +1 -1
  156. package/dist/src/core/shaders/templates/RadialGradientTemplate.d.ts +2 -2
  157. package/dist/src/core/shaders/templates/RadialGradientTemplate.js +2 -2
  158. package/dist/src/core/shaders/templates/RadialGradientTemplate.js.map +1 -1
  159. package/dist/src/core/shaders/templates/shaderUtils.d.ts +5 -0
  160. package/dist/src/core/shaders/templates/shaderUtils.js +41 -0
  161. package/dist/src/core/shaders/templates/shaderUtils.js.map +1 -0
  162. package/dist/src/core/shaders/webgl/Border.js +83 -83
  163. package/dist/src/core/shaders/webgl/Border.js.map +1 -1
  164. package/dist/src/core/shaders/webgl/Default.js +47 -47
  165. package/dist/src/core/shaders/webgl/DefaultBatched.js +61 -61
  166. package/dist/src/core/shaders/webgl/HolePunch.js +34 -34
  167. package/dist/src/core/shaders/webgl/HolePunch.js.map +1 -1
  168. package/dist/src/core/shaders/webgl/LinearGradient.js +36 -36
  169. package/dist/src/core/shaders/webgl/RadialGradient.js +35 -35
  170. package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -1
  171. package/dist/src/core/shaders/webgl/Rounded.js +72 -72
  172. package/dist/src/core/shaders/webgl/Rounded.js.map +1 -1
  173. package/dist/src/core/shaders/webgl/RoundedWithBorder.js +113 -113
  174. package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -1
  175. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +132 -132
  176. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -1
  177. package/dist/src/core/shaders/webgl/RoundedWithShadow.js +55 -55
  178. package/dist/src/core/shaders/webgl/RoundedWithShadow.js.map +1 -1
  179. package/dist/src/core/shaders/webgl/SdfShader.js +62 -62
  180. package/dist/src/core/shaders/webgl/Shadow.js +83 -83
  181. package/dist/src/core/shaders/webgl/Spinner.d.ts +1 -0
  182. package/dist/src/core/shaders/webgl/Spinner.js +2 -0
  183. package/dist/src/core/shaders/webgl/Spinner.js.map +1 -0
  184. package/dist/src/core/text-rendering/CanvasFontHandler.d.ts +16 -0
  185. package/dist/src/core/text-rendering/CanvasFontHandler.js +29 -0
  186. package/dist/src/core/text-rendering/CanvasFontHandler.js.map +1 -1
  187. package/dist/src/core/text-rendering/SdfFontHandler.d.ts +15 -0
  188. package/dist/src/core/text-rendering/SdfFontHandler.js +34 -2
  189. package/dist/src/core/text-rendering/SdfFontHandler.js.map +1 -1
  190. package/dist/src/core/text-rendering/TextRenderer.d.ts +2 -0
  191. package/dist/src/core/text-rendering/TextTextureRendererUtils.js.map +1 -1
  192. package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js +2 -2
  193. package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js.map +1 -1
  194. package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js +0 -5
  195. package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js.map +1 -1
  196. package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.d.ts +1 -7
  197. package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js +2 -50
  198. package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js.map +1 -1
  199. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.d.ts +3 -2
  200. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +83 -42
  201. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -1
  202. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.d.ts +1 -1
  203. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js +8 -66
  204. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js.map +1 -1
  205. package/dist/src/core/text-rendering/renderers/TextRenderer.d.ts +4 -14
  206. package/dist/src/core/text-rendering/renderers/TextRenderer.js +0 -3
  207. package/dist/src/core/text-rendering/renderers/TextRenderer.js.map +1 -1
  208. package/dist/src/core/text-rendering/sdf/PeekableGenerator.d.ts +12 -0
  209. package/dist/src/core/text-rendering/sdf/PeekableGenerator.js +61 -0
  210. package/dist/src/core/text-rendering/sdf/PeekableGenerator.js.map +1 -0
  211. package/dist/src/core/text-rendering/sdf/SimpleFontShaper.d.ts +45 -0
  212. package/dist/src/core/text-rendering/sdf/SimpleFontShaper.js +69 -0
  213. package/dist/src/core/text-rendering/sdf/SimpleFontShaper.js.map +1 -0
  214. package/dist/src/core/textures/ColorTexture.js +1 -1
  215. package/dist/src/core/textures/ColorTexture.js.map +1 -1
  216. package/dist/src/core/textures/ImageTexture.d.ts +2 -2
  217. package/dist/src/core/textures/ImageTexture.js +11 -11
  218. package/dist/src/core/textures/ImageTexture.js.map +1 -1
  219. package/dist/src/core/textures/NoiseTexture.d.ts +2 -2
  220. package/dist/src/core/textures/NoiseTexture.js +6 -6
  221. package/dist/src/core/textures/NoiseTexture.js.map +1 -1
  222. package/dist/src/core/textures/RenderTexture.d.ts +6 -6
  223. package/dist/src/core/textures/RenderTexture.js +10 -10
  224. package/dist/src/core/textures/RenderTexture.js.map +1 -1
  225. package/dist/src/core/textures/SubTexture.d.ts +4 -4
  226. package/dist/src/core/textures/SubTexture.js +8 -8
  227. package/dist/src/core/textures/SubTexture.js.map +1 -1
  228. package/dist/src/core/textures/Texture.d.ts +3 -4
  229. package/dist/src/core/textures/Texture.js +4 -4
  230. package/dist/src/core/textures/Texture.js.map +1 -1
  231. package/dist/src/main-api/DynamicShaderController.d.ts +29 -0
  232. package/dist/src/main-api/DynamicShaderController.js +58 -0
  233. package/dist/src/main-api/DynamicShaderController.js.map +1 -0
  234. package/dist/src/main-api/Inspector.js +7 -7
  235. package/dist/src/main-api/Inspector.js.map +1 -1
  236. package/dist/src/main-api/Renderer.js +2 -2
  237. package/dist/src/main-api/Renderer.js.map +1 -1
  238. package/dist/src/main-api/ShaderController.d.ts +31 -0
  239. package/dist/src/main-api/ShaderController.js +37 -0
  240. package/dist/src/main-api/ShaderController.js.map +1 -0
  241. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  242. package/exports/canvas-shaders.ts +28 -28
  243. package/exports/canvas.ts +45 -45
  244. package/exports/index.ts +82 -82
  245. package/exports/inspector.ts +24 -24
  246. package/exports/utils.ts +50 -50
  247. package/exports/webgl-shaders.ts +28 -28
  248. package/exports/webgl.ts +52 -52
  249. package/package.json +2 -1
  250. package/src/common/CommonTypes.ts +146 -146
  251. package/src/common/EventEmitter.ts +77 -77
  252. package/src/common/IAnimationController.ts +92 -92
  253. package/src/common/IEventEmitter.ts +28 -28
  254. package/src/core/CoreNode.test.ts +202 -202
  255. package/src/core/CoreNode.ts +2481 -2491
  256. package/src/core/CoreShaderManager.ts +188 -188
  257. package/src/core/CoreTextNode.ts +483 -443
  258. package/src/core/CoreTextureManager.ts +565 -565
  259. package/src/core/Stage.ts +906 -906
  260. package/src/core/TextureMemoryManager.ts +445 -445
  261. package/src/core/animations/AnimationManager.ts +38 -38
  262. package/src/core/animations/CoreAnimation.ts +291 -291
  263. package/src/core/animations/CoreAnimationController.ts +166 -166
  264. package/src/core/lib/ContextSpy.ts +41 -41
  265. package/src/core/lib/ImageWorker.ts +286 -286
  266. package/src/core/lib/Matrix3d.ts +244 -244
  267. package/src/core/lib/RenderCoords.ts +71 -71
  268. package/src/core/lib/WebGlContextWrapper.ts +1381 -1381
  269. package/src/core/lib/colorCache.ts +20 -20
  270. package/src/core/lib/colorParser.ts +85 -85
  271. package/src/core/lib/textureCompression.ts +152 -152
  272. package/src/core/lib/textureSvg.ts +78 -78
  273. package/src/core/lib/utils.ts +412 -412
  274. package/src/core/lib/validateImageBitmap.ts +87 -87
  275. package/src/core/platforms/Platform.ts +77 -77
  276. package/src/core/platforms/web/WebPlatform.ts +121 -121
  277. package/src/core/renderers/CoreContextTexture.ts +43 -43
  278. package/src/core/renderers/CoreRenderOp.ts +22 -22
  279. package/src/core/renderers/CoreRenderer.ts +110 -110
  280. package/src/core/renderers/CoreShaderNode.ts +175 -175
  281. package/src/core/renderers/CoreShaderProgram.ts +23 -23
  282. package/src/core/renderers/canvas/CanvasRenderer.ts +283 -283
  283. package/src/core/renderers/canvas/CanvasShaderNode.ts +96 -96
  284. package/src/core/renderers/canvas/CanvasTexture.ts +156 -156
  285. package/src/core/renderers/webgl/WebGlCtxRenderTexture.ts +81 -91
  286. package/src/core/renderers/webgl/WebGlCtxSubTexture.ts +95 -50
  287. package/src/core/renderers/webgl/WebGlCtxTexture.ts +301 -310
  288. package/src/core/renderers/webgl/WebGlRenderOp.ts +167 -167
  289. package/src/core/renderers/webgl/WebGlRenderer.ts +746 -747
  290. package/src/core/renderers/webgl/WebGlShaderNode.ts +435 -435
  291. package/src/core/renderers/webgl/WebGlShaderProgram.ts +341 -341
  292. package/src/core/renderers/webgl/internal/BufferCollection.ts +54 -54
  293. package/src/core/renderers/webgl/internal/RendererUtils.ts +155 -155
  294. package/src/core/renderers/webgl/internal/ShaderUtils.ts +281 -281
  295. package/src/core/renderers/webgl/internal/WebGlUtils.ts +35 -35
  296. package/src/core/shaders/canvas/Border.ts +75 -75
  297. package/src/core/shaders/canvas/HolePunch.ts +55 -62
  298. package/src/core/shaders/canvas/LinearGradient.ts +71 -71
  299. package/src/core/shaders/canvas/RadialGradient.ts +99 -99
  300. package/src/core/shaders/canvas/Rounded.ts +55 -55
  301. package/src/core/shaders/canvas/RoundedWithBorder.ts +72 -74
  302. package/src/core/shaders/canvas/RoundedWithBorderAndShadow.ts +88 -90
  303. package/src/core/shaders/canvas/RoundedWithShadow.ts +70 -70
  304. package/src/core/shaders/canvas/Shadow.ts +52 -52
  305. package/src/core/shaders/canvas/utils/render.ts +151 -151
  306. package/src/core/shaders/templates/BorderTemplate.ts +115 -115
  307. package/src/core/shaders/templates/HolePunchTemplate.ts +82 -82
  308. package/src/core/shaders/templates/LinearGradientTemplate.ts +71 -71
  309. package/src/core/shaders/templates/RadialGradientTemplate.ts +81 -81
  310. package/src/core/shaders/templates/RoundedTemplate.ts +98 -98
  311. package/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.ts +38 -38
  312. package/src/core/shaders/templates/RoundedWithBorderTemplate.ts +35 -35
  313. package/src/core/shaders/templates/RoundedWithShadowTemplate.ts +35 -35
  314. package/src/core/shaders/templates/ShadowTemplate.ts +106 -106
  315. package/src/core/shaders/utils.ts +46 -46
  316. package/src/core/shaders/webgl/Border.ts +116 -116
  317. package/src/core/shaders/webgl/Default.ts +89 -89
  318. package/src/core/shaders/webgl/DefaultBatched.ts +129 -129
  319. package/src/core/shaders/webgl/HolePunch.ts +75 -75
  320. package/src/core/shaders/webgl/LinearGradient.ts +82 -82
  321. package/src/core/shaders/webgl/RadialGradient.ts +85 -85
  322. package/src/core/shaders/webgl/Rounded.ts +113 -117
  323. package/src/core/shaders/webgl/RoundedWithBorder.ts +151 -155
  324. package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +175 -175
  325. package/src/core/shaders/webgl/RoundedWithShadow.ts +94 -98
  326. package/src/core/shaders/webgl/SdfShader.ts +134 -134
  327. package/src/core/shaders/webgl/Shadow.ts +115 -115
  328. package/src/core/text-rendering/CanvasFontHandler.ts +210 -176
  329. package/src/core/text-rendering/CanvasTextRenderer.ts +622 -622
  330. package/src/core/text-rendering/SdfFontHandler.ts +554 -517
  331. package/src/core/text-rendering/SdfTextRenderer.ts +466 -466
  332. package/src/core/text-rendering/TextRenderer.ts +406 -404
  333. package/src/core/text-rendering/Utils.ts +257 -257
  334. package/src/core/text-rendering/canvas/Settings.ts +99 -99
  335. package/src/core/text-rendering/canvas/Utils.test.ts +206 -206
  336. package/src/core/text-rendering/canvas/Utils.ts +178 -178
  337. package/src/core/text-rendering/canvas/calculateRenderInfo.ts +299 -299
  338. package/src/core/text-rendering/canvas/draw.ts +165 -165
  339. package/src/core/text-rendering/sdf/Utils.test.ts +402 -402
  340. package/src/core/text-rendering/sdf/Utils.ts +436 -436
  341. package/src/core/text-rendering/sdf/index.ts +20 -20
  342. package/src/core/textures/ColorTexture.ts +102 -102
  343. package/src/core/textures/ImageTexture.ts +418 -418
  344. package/src/core/textures/NoiseTexture.ts +104 -104
  345. package/src/core/textures/RenderTexture.ts +85 -85
  346. package/src/core/textures/SubTexture.ts +205 -205
  347. package/src/core/textures/Texture.ts +381 -381
  348. package/src/core/utils.ts +227 -227
  349. package/src/env.d.ts +7 -7
  350. package/src/main-api/INode.ts +100 -100
  351. package/src/main-api/Inspector.ts +567 -567
  352. package/src/main-api/Renderer.ts +873 -873
  353. package/src/main-api/utils.ts +45 -45
  354. package/src/utils.ts +267 -267
  355. 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
+ }