melonjs 19.9.0 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/README.md +25 -14
  2. package/build/application/application.d.ts +70 -16
  3. package/build/application/application.d.ts.map +1 -1
  4. package/build/application/defaultApplicationSettings.d.ts +2 -2
  5. package/build/application/resize.d.ts.map +1 -1
  6. package/build/application/settings.d.ts +150 -53
  7. package/build/application/settings.d.ts.map +1 -1
  8. package/build/camera/camera2d.d.ts +1 -1
  9. package/build/camera/camera2d.d.ts.map +1 -1
  10. package/build/camera/camera3d.d.ts +13 -11
  11. package/build/camera/camera3d.d.ts.map +1 -1
  12. package/build/const.d.ts +55 -26
  13. package/build/const.d.ts.map +1 -1
  14. package/build/geometries/box3d.d.ts +156 -0
  15. package/build/geometries/box3d.d.ts.map +1 -0
  16. package/build/index.d.ts +33 -23
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js +21696 -7831
  19. package/build/index.js.map +4 -4
  20. package/build/lang/deprecated.d.ts +4 -4
  21. package/build/lang/deprecated.d.ts.map +1 -1
  22. package/build/level/gltf/GLTFModel.d.ts +4 -0
  23. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  24. package/build/level/gltf/GLTFScene.d.ts +42 -6
  25. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  26. package/build/level/gltf/srgb.d.ts +20 -0
  27. package/build/level/gltf/srgb.d.ts.map +1 -0
  28. package/build/level/level.d.ts +21 -2
  29. package/build/level/level.d.ts.map +1 -1
  30. package/build/lighting/light3d.d.ts +61 -13
  31. package/build/lighting/light3d.d.ts.map +1 -1
  32. package/build/loader/loader.d.ts +49 -21
  33. package/build/loader/loader.d.ts.map +1 -1
  34. package/build/loader/parsers/gltf.d.ts.map +1 -1
  35. package/build/loader/parsers/mtl.d.ts +18 -0
  36. package/build/loader/parsers/mtl.d.ts.map +1 -1
  37. package/build/loader/parsers/obj.d.ts +49 -0
  38. package/build/loader/parsers/obj.d.ts.map +1 -1
  39. package/build/loader/parsers/pbr.d.ts +63 -0
  40. package/build/loader/parsers/pbr.d.ts.map +1 -0
  41. package/build/loader/parsers/shader.d.ts +32 -24
  42. package/build/loader/parsers/shader.d.ts.map +1 -1
  43. package/build/particles/particle.d.ts.map +1 -1
  44. package/build/particles/settings.d.ts +3 -1
  45. package/build/particles/settings.d.ts.map +1 -1
  46. package/build/physics/adapter.d.ts +12 -1
  47. package/build/physics/adapter.d.ts.map +1 -1
  48. package/build/physics/broadphase/octree.d.ts +35 -0
  49. package/build/physics/broadphase/octree.d.ts.map +1 -1
  50. package/build/physics/builtin/body.d.ts +123 -6
  51. package/build/physics/builtin/body.d.ts.map +1 -1
  52. package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
  53. package/build/physics/builtin/detector.d.ts +12 -0
  54. package/build/physics/builtin/detector.d.ts.map +1 -1
  55. package/build/physics/builtin/raycast.d.ts.map +1 -1
  56. package/build/physics/builtin/sat3d.d.ts +59 -0
  57. package/build/physics/builtin/sat3d.d.ts.map +1 -0
  58. package/build/physics/response.d.ts +32 -0
  59. package/build/physics/response.d.ts.map +1 -1
  60. package/build/physics/world.d.ts +1 -0
  61. package/build/physics/world.d.ts.map +1 -1
  62. package/build/renderable/container.d.ts +1 -0
  63. package/build/renderable/container.d.ts.map +1 -1
  64. package/build/renderable/entity/entity.d.ts.map +1 -1
  65. package/build/renderable/frameAnimation.d.ts.map +1 -1
  66. package/build/renderable/groundshadow.d.ts +92 -0
  67. package/build/renderable/groundshadow.d.ts.map +1 -0
  68. package/build/renderable/instanced_mesh.d.ts +286 -0
  69. package/build/renderable/instanced_mesh.d.ts.map +1 -0
  70. package/build/renderable/mesh.d.ts +242 -23
  71. package/build/renderable/mesh.d.ts.map +1 -1
  72. package/build/renderable/nineslicesprite.d.ts.map +1 -1
  73. package/build/renderable/renderable.d.ts +6 -4
  74. package/build/renderable/renderable.d.ts.map +1 -1
  75. package/build/renderable/sprite.d.ts +3 -1
  76. package/build/renderable/sprite.d.ts.map +1 -1
  77. package/build/renderable/sprite3d.d.ts +17 -6
  78. package/build/renderable/sprite3d.d.ts.map +1 -1
  79. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  80. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  81. package/build/renderable/text/text.d.ts.map +1 -1
  82. package/build/state/stage.d.ts.map +1 -1
  83. package/build/system/device.d.ts +11 -40
  84. package/build/system/device.d.ts.map +1 -1
  85. package/build/system/platform.d.ts +0 -16
  86. package/build/system/platform.d.ts.map +1 -1
  87. package/build/utils/utils.d.ts +2 -0
  88. package/build/utils/utils.d.ts.map +1 -1
  89. package/build/video/canvas/canvas_renderer.d.ts +22 -16
  90. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  91. package/build/video/{webgl/effects → effects}/blur.d.ts +2 -2
  92. package/build/video/effects/blur.d.ts.map +1 -0
  93. package/build/video/{webgl/effects → effects}/chromaticAberration.d.ts +2 -2
  94. package/build/video/effects/chromaticAberration.d.ts.map +1 -0
  95. package/build/video/{webgl/effects → effects}/colorMatrix.d.ts +3 -3
  96. package/build/video/effects/colorMatrix.d.ts.map +1 -0
  97. package/build/video/{webgl/effects → effects}/desaturate.d.ts +1 -1
  98. package/build/video/effects/desaturate.d.ts.map +1 -0
  99. package/build/video/{webgl/effects → effects}/dissolve.d.ts +2 -2
  100. package/build/video/effects/dissolve.d.ts.map +1 -0
  101. package/build/video/{webgl/effects → effects}/dropShadow.d.ts +2 -2
  102. package/build/video/effects/dropShadow.d.ts.map +1 -0
  103. package/build/video/{webgl/effects → effects}/flash.d.ts +2 -2
  104. package/build/video/effects/flash.d.ts.map +1 -0
  105. package/build/video/{webgl/effects → effects}/glow.d.ts +2 -2
  106. package/build/video/effects/glow.d.ts.map +1 -0
  107. package/build/video/effects/glsl_realization.d.ts +18 -0
  108. package/build/video/effects/glsl_realization.d.ts.map +1 -0
  109. package/build/video/{webgl/effects → effects}/hologram.d.ts +2 -2
  110. package/build/video/effects/hologram.d.ts.map +1 -0
  111. package/build/video/{webgl/effects → effects}/invert.d.ts +1 -1
  112. package/build/video/effects/invert.d.ts.map +1 -0
  113. package/build/video/{webgl/effects → effects}/outline.d.ts +2 -2
  114. package/build/video/effects/outline.d.ts.map +1 -0
  115. package/build/video/{webgl/effects → effects}/pixelate.d.ts +2 -2
  116. package/build/video/effects/pixelate.d.ts.map +1 -0
  117. package/build/video/{webgl/effects → effects}/radialGradient.d.ts +3 -4
  118. package/build/video/effects/radialGradient.d.ts.map +1 -0
  119. package/build/video/{webgl/effects → effects}/scanline.d.ts +2 -2
  120. package/build/video/effects/scanline.d.ts.map +1 -0
  121. package/build/video/{webgl/effects → effects}/sepia.d.ts +1 -1
  122. package/build/video/effects/sepia.d.ts.map +1 -0
  123. package/build/video/{webgl → effects}/shadereffect.d.ts +133 -25
  124. package/build/video/effects/shadereffect.d.ts.map +1 -0
  125. package/build/video/{webgl/effects → effects}/shine.d.ts +2 -2
  126. package/build/video/effects/shine.d.ts.map +1 -0
  127. package/build/video/{webgl/effects → effects}/tintPulse.d.ts +2 -2
  128. package/build/video/effects/tintPulse.d.ts.map +1 -0
  129. package/build/video/{webgl/effects → effects}/vignette.d.ts +2 -2
  130. package/build/video/effects/vignette.d.ts.map +1 -0
  131. package/build/video/{webgl/effects → effects}/wave.d.ts +2 -2
  132. package/build/video/effects/wave.d.ts.map +1 -0
  133. package/build/video/effects/wgsl/layout.d.ts +28 -0
  134. package/build/video/effects/wgsl/layout.d.ts.map +1 -0
  135. package/build/video/effects/wgsl/parse.d.ts +9 -0
  136. package/build/video/effects/wgsl/parse.d.ts.map +1 -0
  137. package/build/video/effects/wgsl/scaffold.d.ts +43 -0
  138. package/build/video/effects/wgsl/scaffold.d.ts.map +1 -0
  139. package/build/video/effects/wgsl_realization.d.ts +83 -0
  140. package/build/video/effects/wgsl_realization.d.ts.map +1 -0
  141. package/build/video/gpu/batcher.d.ts +71 -0
  142. package/build/video/gpu/batcher.d.ts.map +1 -0
  143. package/build/video/gpu/instancerecord.d.ts +164 -0
  144. package/build/video/gpu/instancerecord.d.ts.map +1 -0
  145. package/build/video/gpu/meshchunk.d.ts +49 -0
  146. package/build/video/gpu/meshchunk.d.ts.map +1 -0
  147. package/build/video/gpu/meshvertex.d.ts +54 -0
  148. package/build/video/gpu/meshvertex.d.ts.map +1 -0
  149. package/build/video/gpu/primitives.d.ts +60 -0
  150. package/build/video/gpu/primitives.d.ts.map +1 -0
  151. package/build/video/gpu/quadcorners.d.ts +11 -0
  152. package/build/video/gpu/quadcorners.d.ts.map +1 -0
  153. package/build/video/gpu/textureslots.d.ts +122 -0
  154. package/build/video/gpu/textureslots.d.ts.map +1 -0
  155. package/build/video/gpu/texturestore.d.ts +139 -0
  156. package/build/video/gpu/texturestore.d.ts.map +1 -0
  157. package/build/video/gpu/topology.d.ts +43 -0
  158. package/build/video/gpu/topology.d.ts.map +1 -0
  159. package/build/video/gpu/vertexformat.d.ts +72 -0
  160. package/build/video/gpu/vertexformat.d.ts.map +1 -0
  161. package/build/video/gradient.d.ts +14 -5
  162. package/build/video/gradient.d.ts.map +1 -1
  163. package/build/video/renderer.d.ts +153 -8
  164. package/build/video/renderer.d.ts.map +1 -1
  165. package/build/video/rendertarget/canvasrendertarget.d.ts +7 -6
  166. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  167. package/build/video/rendertarget/render_target_pool.d.ts +2 -2
  168. package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
  169. package/build/video/rendertarget/webglrendertarget.d.ts +38 -2
  170. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  171. package/build/video/rendertarget/webgpurendertarget.d.ts +83 -0
  172. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -0
  173. package/build/video/texture/atlas.d.ts.map +1 -1
  174. package/build/video/texture/cache.d.ts +20 -2
  175. package/build/video/texture/cache.d.ts.map +1 -1
  176. package/build/video/texture/noise_texture2d.d.ts +2 -2
  177. package/build/video/utils/autodetect.d.ts.map +1 -1
  178. package/build/video/video.d.ts +1 -55
  179. package/build/video/video.d.ts.map +1 -1
  180. package/build/video/webgl/batchers/batcher.d.ts +132 -35
  181. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  182. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +14 -0
  183. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
  184. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +63 -36
  185. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  186. package/build/video/webgl/batchers/material_batcher.d.ts +29 -20
  187. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  188. package/build/video/webgl/batchers/mesh_batcher.d.ts +308 -14
  189. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  190. package/build/video/webgl/batchers/primitive_batcher.d.ts +2 -2
  191. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  192. package/build/video/webgl/batchers/quad_batcher.d.ts +0 -2
  193. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  194. package/build/video/webgl/buffer/index.d.ts +1 -1
  195. package/build/video/webgl/buffer/instance_buffer.d.ts +54 -0
  196. package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -0
  197. package/build/video/webgl/buffer/retained_geometry.d.ts +83 -0
  198. package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -0
  199. package/build/video/webgl/buffer/uniformblock.d.ts +81 -0
  200. package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -0
  201. package/build/video/webgl/buffer/vertexstate.d.ts +101 -0
  202. package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -0
  203. package/build/video/webgl/glshader.d.ts +101 -8
  204. package/build/video/webgl/glshader.d.ts.map +1 -1
  205. package/build/video/webgl/lighting/constants.d.ts +20 -8
  206. package/build/video/webgl/lighting/constants.d.ts.map +1 -1
  207. package/build/video/webgl/lighting/pack.d.ts +1 -1
  208. package/build/video/webgl/lighting/pack3d.d.ts +27 -11
  209. package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
  210. package/build/video/webgl/lighting/std140.d.ts +110 -0
  211. package/build/video/webgl/lighting/std140.d.ts.map +1 -0
  212. package/build/video/webgl/shaders/multitexture-lit.d.ts +7 -3
  213. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  214. package/build/video/webgl/texture/store.d.ts +52 -0
  215. package/build/video/webgl/texture/store.d.ts.map +1 -0
  216. package/build/video/webgl/utils/maxtextures.d.ts +37 -0
  217. package/build/video/webgl/utils/maxtextures.d.ts.map +1 -0
  218. package/build/video/webgl/utils/samplercache.d.ts +69 -0
  219. package/build/video/webgl/utils/samplercache.d.ts.map +1 -0
  220. package/build/video/webgl/utils/string.d.ts +16 -0
  221. package/build/video/webgl/utils/string.d.ts.map +1 -1
  222. package/build/video/webgl/utils/topology.d.ts +24 -0
  223. package/build/video/webgl/utils/topology.d.ts.map +1 -0
  224. package/build/video/webgl/utils/vertexformat.d.ts +27 -0
  225. package/build/video/webgl/utils/vertexformat.d.ts.map +1 -0
  226. package/build/video/webgl/webgl_renderer.d.ts +148 -30
  227. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  228. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +40 -0
  229. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -0
  230. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +82 -0
  231. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -0
  232. package/build/video/webgpu/batchers/mesh_batcher.d.ts +301 -0
  233. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -0
  234. package/build/video/webgpu/batchers/primitive_batcher.d.ts +39 -0
  235. package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -0
  236. package/build/video/webgpu/batchers/quad_batcher.d.ts +143 -0
  237. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -0
  238. package/build/video/webgpu/batchers/webgpu_batcher.d.ts +70 -0
  239. package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -0
  240. package/build/video/webgpu/buffer/arena.d.ts +64 -0
  241. package/build/video/webgpu/buffer/arena.d.ts.map +1 -0
  242. package/build/video/webgpu/buffer/instance_buffer.d.ts +65 -0
  243. package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -0
  244. package/build/video/webgpu/buffer/retained_geometry.d.ts +55 -0
  245. package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -0
  246. package/build/video/webgpu/buffer/uniformring.d.ts +68 -0
  247. package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -0
  248. package/build/video/webgpu/effect_binding.d.ts +17 -0
  249. package/build/video/webgpu/effect_binding.d.ts.map +1 -0
  250. package/build/video/webgpu/pipeline/bindgroups.d.ts +36 -0
  251. package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -0
  252. package/build/video/webgpu/pipeline/cache.d.ts +173 -0
  253. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -0
  254. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +90 -0
  255. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -0
  256. package/build/video/webgpu/shaders/mesh-instanced.d.ts +60 -0
  257. package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -0
  258. package/build/video/webgpu/texture/compressed.d.ts +33 -0
  259. package/build/video/webgpu/texture/compressed.d.ts.map +1 -0
  260. package/build/video/webgpu/texture/frametexture.d.ts +65 -0
  261. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -0
  262. package/build/video/webgpu/texture/store.d.ts +149 -0
  263. package/build/video/webgpu/texture/store.d.ts.map +1 -0
  264. package/build/video/webgpu/webgpu_renderer.d.ts +536 -0
  265. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -0
  266. package/package.json +5 -5
  267. package/build/video/webgl/effects/blur.d.ts.map +0 -1
  268. package/build/video/webgl/effects/chromaticAberration.d.ts.map +0 -1
  269. package/build/video/webgl/effects/colorMatrix.d.ts.map +0 -1
  270. package/build/video/webgl/effects/desaturate.d.ts.map +0 -1
  271. package/build/video/webgl/effects/dissolve.d.ts.map +0 -1
  272. package/build/video/webgl/effects/dropShadow.d.ts.map +0 -1
  273. package/build/video/webgl/effects/flash.d.ts.map +0 -1
  274. package/build/video/webgl/effects/glow.d.ts.map +0 -1
  275. package/build/video/webgl/effects/hologram.d.ts.map +0 -1
  276. package/build/video/webgl/effects/invert.d.ts.map +0 -1
  277. package/build/video/webgl/effects/outline.d.ts.map +0 -1
  278. package/build/video/webgl/effects/pixelate.d.ts.map +0 -1
  279. package/build/video/webgl/effects/radialGradient.d.ts.map +0 -1
  280. package/build/video/webgl/effects/scanline.d.ts.map +0 -1
  281. package/build/video/webgl/effects/sepia.d.ts.map +0 -1
  282. package/build/video/webgl/effects/shine.d.ts.map +0 -1
  283. package/build/video/webgl/effects/tintPulse.d.ts.map +0 -1
  284. package/build/video/webgl/effects/vignette.d.ts.map +0 -1
  285. package/build/video/webgl/effects/wave.d.ts.map +0 -1
  286. package/build/video/webgl/shadereffect.d.ts.map +0 -1
@@ -2,9 +2,90 @@
2
2
  * A simplified shader class for applying custom fragment effects to renderables.
3
3
  * Only requires a fragment `apply()` function — the vertex shader, uniforms, and
4
4
  * texture sampling boilerplate are handled automatically.
5
- * In Canvas mode, the shader is silently disabled (all methods become no-ops).
5
+ *
6
+ * ## Dual-language bodies
7
+ *
8
+ * An effect body is written in the active renderer's shading language:
9
+ * GLSL on the WebGL renderer, WGSL on the WebGPU renderer. Pass a plain
10
+ * string for a GLSL-only effect (the historical form), or one body per
11
+ * language for an effect that runs on both backends:
12
+ *
13
+ * ```js
14
+ * new ShaderEffect(renderer, { glsl: glslBody, wgsl: wgslBody });
15
+ * ```
16
+ *
17
+ * The renderer compiles the body matching its
18
+ * {@link Renderer#shaderLanguage}. When no matching body exists — a
19
+ * GLSL-only effect on the WebGPU renderer, any effect on the Canvas
20
+ * renderer — the effect warns once and stays **disabled**
21
+ * (`enabled === false`, every method a safe no-op): the scene renders
22
+ * without the effect, it never breaks.
23
+ *
24
+ * ## The WGSL convention
25
+ *
26
+ * A WGSL body mirrors the GLSL one — declarations plus an apply function,
27
+ * compiled verbatim inside engine boilerplate:
28
+ *
29
+ * - `fn apply(color : vec4f, uv : vec2f) -> vec4f` — required; receives
30
+ * the sampled, tinted pixel and its UV, returns the modified color.
31
+ * - Uniforms are the members of ONE struct bound as
32
+ * `@group(3) @binding(0) var<uniform> fx : MyUniforms;` — member names
33
+ * are the {@link ShaderEffect#setUniform} names, so a dual-language
34
+ * effect uses the same uniform names in both bodies and one
35
+ * `setUniform` call serves both. Supported member types: `f32`, `i32`,
36
+ * `u32`, `vec2f`, `vec3f`, `vec4f`, `mat3x3f`, `mat4x4f`,
37
+ * `array<vec4f, N>`.
38
+ * - Extra {@link ShaderEffect#setTexture} samplers are texture/sampler
39
+ * pairs at explicit consecutive group-3 bindings (from 1):
40
+ * `@group(3) @binding(1) var uNoise : texture_2d<f32>;`
41
+ * `@group(3) @binding(2) var uNoiseSampler : sampler;`
42
+ * - The source texture is available as `uTexture` with `uSampler`
43
+ * (`textureSample(uTexture, uSampler, uv)` — the WGSL spelling of
44
+ * GLSL's `texture2D(uSampler, uv)`), and the interpolated tint as
45
+ * `vColor`, under the same names as the GLSL side.
46
+ * - The shader builtins keep their names: `screen_uv`, `noise_uv`, and
47
+ * `screen_texture` — sampled through `screen_sampler` (clamped) or
48
+ * `screen_sampler_repeat` (wrapping), replacing the GLSL
49
+ * `: screen_texture(repeat)` annotation.
50
+ * - Porting note: a texture sampled after a non-uniform `return` or
51
+ * inside a varying branch must use
52
+ * `textureSampleLevel(uTexture, uSampler, uv, 0.0)` (a WGSL
53
+ * uniform-control-flow rule; identical output for sprite textures).
54
+ *
55
+ * ## Directional UV arithmetic (`uUVYDir`)
56
+ *
57
+ * The vertical orientation of `apply()`'s UV space depends on the draw
58
+ * path: sampling the sprite directly, `uv.y` grows downward, but the
59
+ * WebGL multi-effect (pooled) path composites through capture FBOs whose
60
+ * rows are bottom-up — there `uv.y` grows upward. A body that offsets its
61
+ * sampling coordinate vertically (a drop shadow, a directional smear)
62
+ * would render mirrored on that path. Declare a `float uUVYDir` uniform
63
+ * (WGSL: `uUVYDir : f32` in the uniform struct) and multiply vertical UV
64
+ * offsets by it: the renderer feeds `+1` where `uv.y` grows downward —
65
+ * including every WebGPU path — and `-1` on the WebGL pooled path, so
66
+ * "down" stays down everywhere. Initialize it to `1.0` with `setUniform`;
67
+ * bodies that don't declare it are unaffected. The built-in
68
+ * {@link DropShadowEffect} is the reference use.
6
69
  * @category Rendering
7
70
  * @example
71
+ * // one effect, both backends: dual-language body
72
+ * mySprite.shader = new ShaderEffect(renderer, {
73
+ * glsl: `
74
+ * uniform float uStrength;
75
+ * vec4 apply(vec4 color, vec2 uv) {
76
+ * return vec4(color.rgb * uStrength, color.a);
77
+ * }
78
+ * `,
79
+ * wgsl: `
80
+ * struct Fx { uStrength : f32, };
81
+ * @group(3) @binding(0) var<uniform> fx : Fx;
82
+ * fn apply(color : vec4f, uv : vec2f) -> vec4f {
83
+ * return vec4f(color.rgb * fx.uStrength, color.a);
84
+ * }
85
+ * `,
86
+ * });
87
+ * mySprite.shader.setUniform("uStrength", 0.5); // sets either backend
88
+ * @example
8
89
  * // create a grayscale effect
9
90
  * mySprite.shader = new ShaderEffect(renderer, `
10
91
  * vec4 apply(vec4 color, vec2 uv) {
@@ -44,13 +125,21 @@
44
125
  */
45
126
  export default class ShaderEffect {
46
127
  /**
47
- * @param {WebGLRenderer|CanvasRenderer} renderer - the current renderer instance
48
- * @param {string} fragmentBody - GLSL code containing a `vec4 apply(vec4 color, vec2 uv)` function
49
- * that receives the sampled pixel color and UV coordinates, and returns the modified color.
50
- * You can declare additional `uniform` variables before the `apply()` function.
51
- * @param {string} [precision=auto detected] - float precision ('lowp', 'mediump' or 'highp')
128
+ * @param {WebGLRenderer|WebGPURenderer|CanvasRenderer} renderer - the current renderer instance
129
+ * @param {string|{glsl?: string, wgsl?: string}} body - the effect body:
130
+ * a GLSL string (containing a `vec4 apply(vec4 color, vec2 uv)` function —
131
+ * unchanged from previous versions), or an object carrying one body per
132
+ * shading language (`glsl` and/or `wgsl`, the WGSL body defining
133
+ * `fn apply(color : vec4f, uv : vec2f) -> vec4f`). The renderer picks the
134
+ * body matching its {@link Renderer#shaderLanguage}; when no matching body
135
+ * exists the effect warns once and stays disabled (`enabled === false`),
136
+ * exactly like the Canvas renderer.
137
+ * @param {string} [precision=auto detected] - float precision ('lowp', 'mediump' or 'highp'), GLSL only
52
138
  */
53
- constructor(renderer: WebGLRenderer | CanvasRenderer, fragmentBody: string, precision?: string);
139
+ constructor(renderer: WebGLRenderer | WebGPURenderer | CanvasRenderer, body: string | {
140
+ glsl?: string;
141
+ wgsl?: string;
142
+ }, precision?: string);
54
143
  /**
55
144
  * whether this effect is active (false in Canvas mode, false after
56
145
  * {@link destroy}, and false while the WebGL context is suspended
@@ -89,14 +178,25 @@ export default class ShaderEffect {
89
178
  */
90
179
  _renderer: any;
91
180
  /**
92
- * the construction "recipe" (fragment body + precision), kept so
181
+ * the construction "recipe" (body + precision), kept VERBATIM so
93
182
  * {@link clone} can compile an independent copy. Stored before the
94
- * Canvas-mode early return so cloning behaves consistently there too.
183
+ * disabled-stub early return so cloning behaves consistently there too.
95
184
  * @ignore
96
185
  */
97
- _fragmentBody: string;
186
+ _fragmentBody: string | {
187
+ glsl?: string;
188
+ wgsl?: string;
189
+ };
98
190
  /** @ignore */
99
191
  _precision: string | undefined;
192
+ /**
193
+ * extra texture samplers bound via {@link setTexture}, keyed by the
194
+ * uniform name → `{ image, repeat, tex }` (`tex` is the uploaded GL
195
+ * texture, created lazily on first draw; unused on WebGPU, where the
196
+ * bind group is built lazily instead)
197
+ * @ignore
198
+ */
199
+ _extraTextures: Map<any, any> | undefined;
100
200
  /**
101
201
  * samplers annotated `: screen_texture` — the renderer checks this to
102
202
  * know when to refresh the shared frame capture before the effect draws
@@ -108,16 +208,11 @@ export default class ShaderEffect {
108
208
  repeat: string;
109
209
  }>;
110
210
  /** @ignore */
111
- _hasNoiseUV: boolean | undefined;
211
+ _hasNoiseUV: any;
112
212
  /** @ignore */
113
213
  _shader: GLShader | undefined;
114
- /**
115
- * extra texture samplers bound via {@link setTexture}, keyed by the
116
- * uniform name → `{ image, repeat, tex }` (`tex` is the uploaded GL
117
- * texture, created lazily on first draw)
118
- * @ignore
119
- */
120
- _extraTextures: Map<any, any> | undefined;
214
+ /** @ignore */
215
+ wgslRealization: WGSLEffectRealization | undefined;
121
216
  /** @private */
122
217
  private _onContextLost;
123
218
  _enabledBeforeSuspend: boolean | undefined;
@@ -153,6 +248,20 @@ export default class ShaderEffect {
153
248
  * flow.setTime(me.timer.getTime() / 1000);
154
249
  */
155
250
  setTime(seconds: number): ShaderEffect;
251
+ /**
252
+ * Feed the UV y-direction of the space `apply()` is about to run in:
253
+ * `+1` where `uv.y` grows downward (direct sprite sampling, and every
254
+ * WebGPU path), `-1` on the WebGL pooled-blit path, whose capture FBOs
255
+ * are bottom-up — there, y-directional UV arithmetic inside a body
256
+ * runs vertically mirrored unless compensated. Directional bodies
257
+ * (DropShadow) declare a `uUVYDir` uniform and multiply their y
258
+ * offsets with it, so "down" means down on every path of every
259
+ * backend. A silent no-op for bodies that don't declare the uniform.
260
+ * @param {number} dir - +1 (uv.y grows downward) or -1 (upward)
261
+ * @ignore
262
+ */
263
+ _setUVYDir(dir: number): void;
264
+ _uvYDir: any;
156
265
  /**
157
266
  * Feed the `noise_uv` builtin's frame rect for the object about to draw:
158
267
  * the source texture dimensions, the destination (object) dimensions, and
@@ -170,14 +279,12 @@ export default class ShaderEffect {
170
279
  _setNoiseUVRect(sourceWidth: number, sourceHeight: number, objectWidth: number, objectHeight: number, u0: number, v0: number): void;
171
280
  /**
172
281
  * Apply the wrap mode a `: screen_texture(<repeat>)` annotation asked for
173
- * onto the live capture handle. Captures are NPOT (canvas-sized), which
174
- * WebGL 1 cannot repeat — warn once and keep the clamp there. The unit is
175
- * force-activated first: the batcher's bind may have been skipped as
176
- * redundant while the GL active unit points elsewhere.
282
+ * onto the live capture handle. The unit is force-activated first: the
283
+ * batcher's bind may have been skipped as redundant while the GL active
284
+ * unit points elsewhere.
177
285
  * @ignore
178
286
  */
179
287
  _applyCaptureWrap(batcher: any, glTex: any, entry: any): void;
180
- _captureWrapWarned: boolean | undefined;
181
288
  /**
182
289
  * Bind an **extra** texture to a named `sampler2D` uniform in this shader, so
183
290
  * a custom effect can read a *second* texture — a noise map, mask, gradient,
@@ -192,7 +299,7 @@ export default class ShaderEffect {
192
299
  * drawable source. No-op in Canvas mode.
193
300
  * @param {string} name - the `sampler2D` uniform name declared in the fragment
194
301
  * @param {Texture2d|HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - the texture: an engine texture asset, or a raw drawable source
195
- * @param {"repeat"|"repeat-x"|"repeat-y"|"no-repeat"} [repeat="no-repeat"] - wrap mode; use `"repeat"` for a tiled/scrolled texture (power-of-two size under WebGL 1)
302
+ * @param {"repeat"|"repeat-x"|"repeat-y"|"no-repeat"} [repeat="no-repeat"] - wrap mode; use `"repeat"` for a tiled/scrolled texture
196
303
  * @returns {ShaderEffect} this effect for chaining
197
304
  * @example
198
305
  * // "water": distort the sprite by a static noise texture scrolled over time
@@ -269,6 +376,7 @@ export default class ShaderEffect {
269
376
  */
270
377
  destroy(): void;
271
378
  }
272
- import GLShader from "./glshader.js";
379
+ import GLShader from "../webgl/glshader.js";
380
+ import WGSLEffectRealization from "./wgsl_realization.js";
273
381
  import Texture2d from "../texture/texture2d.ts";
274
382
  //# sourceMappingURL=shadereffect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shadereffect.d.ts","sourceRoot":"","sources":["../../../src/video/effects/shadereffect.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4HG;AACH;IAiCC;;;;;;;;;;;OAWG;IACH,sBAXW,aAAa,GAAC,cAAc,GAAC,cAAc,QAC3C,MAAM,GAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,cAQrC,MAAM,EAqHhB;IA/JD;;;;;;OAMG;IACH,SAFU,OAAO,CAED;IAEhB;;;;;;;OAOG;IACH,oBAHU,OAAO,CAGC;IAElB;;;;;;;;;;OAUG;IACH,QAHU,OAAO,CAGF;IAed;;;;;;OAMG;IACH,eAAyB;IAEzB;;;;;OAKG;IACH;eA1ByB,MAAM;eAAS,MAAM;MA0BrB;IACzB,cAAc;IACd,+BAA2B;IAoB3B;;;;;;OAMG;IACH,0CAA+B;IAQ9B;;;;;OAKG;IACH,wBAHU,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAGK;IACpD,cAAc;IACd,iBAAkC;IAElC,cAAc;IACd,8BAKC;IAyBD,cAAc;IACd,mDAAkC;IAsBpC,eAAe;IACf,uBAkBC;IAbA,2CAAyC;IAe1C,eAAe;IACf,2BAQC;IAED;;;;OAIG;IACH,iBAHW,MAAM,SACN,MAAM,GAAC,YAAY,QAmB7B;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,iBAbW,MAAM,GACJ,YAAY,CAuCxB;IAED;;;;;;;;;;;OAWG;IACH,gBAHW,MAAM,QAqBhB;IATC,aAAkB;IAWpB;;;;;;;;;;;;;OAaG;IACH,6BARW,MAAM,gBACN,MAAM,eACN,MAAM,gBACN,MAAM,MACN,MAAM,MACN,MAAM,QAoDhB;IAED;;;;;;OAMG;IACH,8DAaC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,iBAnBW,MAAM,SACN,SAAS,GAAC,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,WACxE,QAAQ,GAAC,UAAU,GAAC,UAAU,GAAC,WAAW,GACxC,YAAY,CA0GxB;IAED;;;;;;;;OAQG;IACH,0BAHW,MAAM,QA2FhB;IA3DI,4CAAkC;IA6DvC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,SARa,YAAY,CAqDxB;IAKD,cAAc;IACd,aAIC;IAED,cAAc;IACd,qCAIC;IAED,cAAc;IACd,iEAIC;IAED,cAAc;IACd,mCAEC;IAED,cAAc;IACd,kBAEC;IAED,cAAc;IACd,oBAEC;IAED,cAAc;IACd,qBAEC;IAED,cAAc;IACd,uBAEC;IAED;;;;OAIG;IACH,gBAyCC;CACD;qBA34BoB,sBAAsB;kCAET,uBAAuB;sBAHnC,yBAAyB"}
@@ -47,7 +47,7 @@ export default class ShineEffect extends ShaderEffect {
47
47
  * @param {number} [options.pulseDepth=0.0] - subtle base-brightness pulse amplitude (0 disables the pulse)
48
48
  * @param {number} [options.pulseSpeed=3.0] - pulse oscillation rate (radians/second)
49
49
  */
50
- constructor(renderer: import("../webgl_renderer.js").default, options?: {
50
+ constructor(renderer: any, options?: {
51
51
  color?: number[] | undefined;
52
52
  speed?: number | undefined;
53
53
  width?: number | undefined;
@@ -78,5 +78,5 @@ export default class ShineEffect extends ShaderEffect {
78
78
  */
79
79
  setBands(value: number): void;
80
80
  }
81
- import ShaderEffect from "../shadereffect.js";
81
+ import ShaderEffect from "./shadereffect.js";
82
82
  //# sourceMappingURL=shine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shine.d.ts","sourceRoot":"","sources":["../../../src/video/effects/shine.js"],"names":[],"mappings":"AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH;IACC;;;;;;;;;;;OAWG;IACH,qCATG;QAA2B,KAAK;QACP,KAAK;QACL,KAAK;QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,UAAU;QACV,UAAU;KACrC,EAgEA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,oBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;CACD;yBA5LwB,mBAAmB"}
@@ -23,7 +23,7 @@ export default class TintPulseEffect extends ShaderEffect {
23
23
  * @param {number} [options.speed=2.0] - pulse speed (oscillations per second)
24
24
  * @param {number} [options.intensity=0.3] - maximum tint strength (0.0–1.0)
25
25
  */
26
- constructor(renderer: import("../webgl_renderer.js").default, options?: {
26
+ constructor(renderer: any, options?: {
27
27
  color?: number[] | undefined;
28
28
  speed?: number | undefined;
29
29
  intensity?: number | undefined;
@@ -39,5 +39,5 @@ export default class TintPulseEffect extends ShaderEffect {
39
39
  */
40
40
  setColor(color: number[]): void;
41
41
  }
42
- import ShaderEffect from "../shadereffect.js";
42
+ import ShaderEffect from "./shadereffect.js";
43
43
  //# sourceMappingURL=tintPulse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tintPulse.d.ts","sourceRoot":"","sources":["../../../src/video/effects/tintPulse.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;;;;;OAMG;IACH,qCAJG;QAA2B,KAAK;QACP,KAAK;QACL,SAAS;KACpC,EAqBA;IAED;;;OAGG;IACH,cAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;CACD;yBAjFwB,mBAAmB"}
@@ -21,7 +21,7 @@ export default class VignetteEffect extends ShaderEffect {
21
21
  * @param {number} [options.strength=0.15] - edge darkening power (lower = stronger darkening, higher = softer falloff)
22
22
  * @param {number} [options.size=25.0] - vignette spread multiplier (higher = smaller dark area)
23
23
  */
24
- constructor(renderer: import("../webgl_renderer.js").default, options?: {
24
+ constructor(renderer: any, options?: {
25
25
  strength?: number | undefined;
26
26
  size?: number | undefined;
27
27
  });
@@ -38,5 +38,5 @@ export default class VignetteEffect extends ShaderEffect {
38
38
  */
39
39
  setSize(size: number): void;
40
40
  }
41
- import ShaderEffect from "../shadereffect.js";
41
+ import ShaderEffect from "./shadereffect.js";
42
42
  //# sourceMappingURL=vignette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vignette.d.ts","sourceRoot":"","sources":["../../../src/video/effects/vignette.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;GAeG;AACH;IACC;;;;;OAKG;IACH,qCAHG;QAAyB,QAAQ;QACR,IAAI;KAC/B,EASA;IALA,iBAAwC;IACxC,aAAgC;IAMjC;;;OAGG;IACH,sBAFW,MAAM,QAKhB;IAED;;;OAGG;IACH,cAFW,MAAM,QAKhB;CACD;yBA/EwB,mBAAmB"}
@@ -18,7 +18,7 @@ export default class WaveEffect extends ShaderEffect {
18
18
  * @param {number} [options.frequency=10.0] - number of waves across the sprite
19
19
  * @param {number} [options.speed=2.0] - wave animation speed
20
20
  */
21
- constructor(renderer: import("../webgl_renderer.js").default, options?: {
21
+ constructor(renderer: any, options?: {
22
22
  amplitude?: number | undefined;
23
23
  frequency?: number | undefined;
24
24
  speed?: number | undefined;
@@ -39,5 +39,5 @@ export default class WaveEffect extends ShaderEffect {
39
39
  */
40
40
  setFrequency(frequency: number): void;
41
41
  }
42
- import ShaderEffect from "../shadereffect.js";
42
+ import ShaderEffect from "./shadereffect.js";
43
43
  //# sourceMappingURL=wave.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wave.d.ts","sourceRoot":"","sources":["../../../src/video/effects/wave.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;GAWG;AACH;IACC;;;;;;OAMG;IACH,qCAJG;QAAyB,SAAS;QACT,SAAS;QACT,KAAK;KAChC,EAqBA;IAED;;;OAGG;IACH,cAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAIhB;CACD;yBArFwB,mBAAmB"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * normalize the `vecN<f32>` / `matCxR<f32>` spellings onto the short forms
3
+ * used as TYPE_LAYOUT keys
4
+ * @param {string} type - a WGSL type token
5
+ * @returns {string} the canonical spelling
6
+ * @ignore
7
+ */
8
+ export function normalizeWGSLType(type: string): string;
9
+ /**
10
+ * Compute the uniform-buffer layout for a parsed struct member list.
11
+ * @param {Array<{name: string, type: string}>} members - struct members in declaration order
12
+ * @returns {{map: Map<string, {offset: number, size: number, type: string}>, size: number}|null}
13
+ * the name → placement map and the total (16-byte-rounded) struct size,
14
+ * or `null` when a member type is unsupported
15
+ * @ignore
16
+ */
17
+ export function computeUniformLayout(members: Array<{
18
+ name: string;
19
+ type: string;
20
+ }>): {
21
+ map: Map<string, {
22
+ offset: number;
23
+ size: number;
24
+ type: string;
25
+ }>;
26
+ size: number;
27
+ } | null;
28
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../../src/video/effects/wgsl/layout.js"],"names":[],"mappings":"AAqCA;;;;;;GAMG;AACH,wCAJW,MAAM,GACJ,MAAM,CAQlB;AAUD;;;;;;;GAOG;AACH,8CANW,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC,GACjC;IAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAC,IAAI,CAuB/F"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parse a WGSL effect body's declarations.
3
+ * @param {string} body - the user WGSL body
4
+ * @returns {object} `{ok: true, layout, structSize, uniformVar, textures, builtins, maxUserBinding}`
5
+ * or `{ok: false, error}`
6
+ * @ignore
7
+ */
8
+ export function parseWGSLBody(body: string): object;
9
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../src/video/effects/wgsl/parse.js"],"names":[],"mappings":"AAoHA;;;;;;GAMG;AACH,oCALW,MAAM,GACJ,MAAM,CAqKlB"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * WGSL module assembly for a ShaderEffect body — the WGSL counterpart of
3
+ * `glsl_realization.js`'s source templating. The user body is embedded
4
+ * VERBATIM (WGSL module-scope declarations are order-independent); the
5
+ * scaffold contributes the vertex/fragment entry points over the frozen
6
+ * 28-byte quad layout, the frame-globals and material groups, and the
7
+ * builtin declarations the parser detected.
8
+ *
9
+ * Frozen conventions carried over from the core quad shader:
10
+ * - clip-z remap `(z + w) * 0.5` (GL-convention [-w, w] → WebGPU [0, w])
11
+ * - packed-ARGB attribute read as (B,G,R,A) → `.bgr * .a` premultiply
12
+ * - `screen_uv` is y-down (`0.5 - ndc.y * 0.5`): WebGPU texture row 0 is
13
+ * the top, so the capture is sampled without any flip
14
+ * @ignore
15
+ */
16
+ /**
17
+ * builtin group-3 bindings are assigned ABOVE the highest user binding so
18
+ * they can never collide: ME uniform first, then the capture texture and
19
+ * its sampler variants
20
+ * @param {object} parsed - the parseWGSLBody result
21
+ * @returns {{me: number, screenTexture: number, screenSamplerClamp: number, screenSamplerRepeat: number}}
22
+ * assigned binding indices (-1 when the builtin is unused)
23
+ * @ignore
24
+ */
25
+ export function assignBuiltinBindings(parsed: object): {
26
+ me: number;
27
+ screenTexture: number;
28
+ screenSamplerClamp: number;
29
+ screenSamplerRepeat: number;
30
+ };
31
+ /**
32
+ * Assemble the complete WGSL module for an effect body.
33
+ * @param {string} body - the user WGSL body (embedded verbatim)
34
+ * @param {object} parsed - the parseWGSLBody result
35
+ * @returns {{code: string, bindings: object}} the module text and the
36
+ * builtin binding assignment (consumed when building the bind group)
37
+ * @ignore
38
+ */
39
+ export function buildWGSLModule(body: string, parsed: object): {
40
+ code: string;
41
+ bindings: object;
42
+ };
43
+ //# sourceMappingURL=scaffold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../../../src/video/effects/wgsl/scaffold.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;GAQG;AACH,8CALW,MAAM,GACJ;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAC,CA0BxG;AAED;;;;;;;GAOG;AACH,sCANW,MAAM,UACN,MAAM,GACJ;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAyG5C"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * The WGSL realization of a ShaderEffect — the WebGPU counterpart of the
3
+ * GLShader the GLSL branch compiles.
4
+ *
5
+ * WebGPU has no uniform reflection, so this object carries everything the
6
+ * backend needs to drive the effect: the parsed uniform layout (name →
7
+ * byte placement), a CPU-side mirror of the uniform block that
8
+ * `setUniform` writes into, the texture binding table, and the assembled
9
+ * module text. GPU objects (shader module, bind group layout, bind group)
10
+ * are built lazily by the renderer's effect path — uniform VALUES are
11
+ * snapshotted from the mirror into a per-frame arena at every bind, so a
12
+ * shared effect bound twice in a frame with different values stays
13
+ * correct under WebGPU's queue-write-before-draws ordering.
14
+ * @ignore
15
+ */
16
+ export default class WGSLEffectRealization {
17
+ /**
18
+ * Parse + assemble; on any parse failure `valid` is false and `error`
19
+ * carries the reason (the effect then warns and stays disabled).
20
+ * @param {string} body - the user WGSL body
21
+ */
22
+ constructor(body: string);
23
+ /**
24
+ * whether the body parsed into a realizable shape
25
+ * @type {boolean}
26
+ */
27
+ valid: boolean;
28
+ /** @type {string|null} */
29
+ error: string | null;
30
+ /** name → {offset, size, type} placement in the uniform block */
31
+ layout: any;
32
+ /** total uniform block byte size (0 = no uniform struct) */
33
+ structSize: any;
34
+ /** user texture/sampler pairs (binding table) */
35
+ textures: any;
36
+ /** builtin usage flags */
37
+ builtins: any;
38
+ /** the complete assembled WGSL module text */
39
+ code: string | undefined;
40
+ /** builtin binding assignment (ME / capture texture / samplers) */
41
+ builtinBindings: object | undefined;
42
+ cpu: ArrayBuffer | undefined;
43
+ f32: Float32Array<ArrayBuffer> | undefined;
44
+ i32: Int32Array<ArrayBuffer> | undefined;
45
+ u32: Uint32Array<ArrayBuffer> | undefined;
46
+ meMirror: Float32Array<ArrayBuffer> | undefined;
47
+ /**
48
+ * last user-set value per uniform name — the clone-replay source
49
+ * (exact values, not mirror read-back)
50
+ * @type {Map<string, number|number[]>}
51
+ */
52
+ values: Map<string, number | number[]>;
53
+ warned: Set<any> | undefined;
54
+ /**
55
+ * device-scoped GPU state, built lazily by the renderer's effect
56
+ * path and invalidated via the pipeline-cache epoch (device loss)
57
+ * @type {object|null}
58
+ */
59
+ gpu: object | null;
60
+ /**
61
+ * Write a uniform value into the CPU mirror.
62
+ * @param {string} name - a struct member name of the body's uniform block
63
+ * @param {number|number[]|Float32Array|{val: Float32Array}} value - the value
64
+ * (objects exposing `.val` — Matrix2d/3d, ColorMatrix — are unwrapped)
65
+ * @returns {boolean} true when the name exists and the value was written
66
+ */
67
+ setUniform(name: string, value: number | number[] | Float32Array | {
68
+ val: Float32Array;
69
+ }): boolean;
70
+ /**
71
+ * whether the uniform block declares the given member (the WGSL
72
+ * counterpart of the GLSL active-uniform check `setTime` relies on)
73
+ * @param {string} name - member name
74
+ * @returns {boolean} true when present
75
+ */
76
+ hasUniform(name: string): boolean;
77
+ /**
78
+ * drop device-scoped state (device loss / destroy) — the CPU mirror
79
+ * and values survive, so nothing needs replaying on restore
80
+ */
81
+ releaseGPU(): void;
82
+ }
83
+ //# sourceMappingURL=wgsl_realization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgsl_realization.d.ts","sourceRoot":"","sources":["../../../src/video/effects/wgsl_realization.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;OAIG;IACH,kBAFW,MAAM,EA2DhB;IAtDA;;;OAGG;IACH,OAFU,OAAO,CAEc;IAC/B,0BAA0B;IAC1B,OADW,MAAM,GAAC,IAAI,CAC+B;IAMrD,iEAAiE;IACjE,YAA2B;IAC3B,4DAA4D;IAC5D,gBAAmC;IACnC,iDAAiD;IACjD,cAA+B;IAC/B,0BAA0B;IAC1B,cAA+B;IAG/B,8CAA8C;IAC9C,yBAAuB;IACvB,mEAAmE;IACnE,oCAAsC;IAGtC,6BAAwD;IACxD,2CAAqC;IACrC,yCAAmC;IACnC,0CAAoC;IAIpC,gDAAmC;IAEnC;;;;OAIG;IACH,QAFU,GAAG,CAAC,MAAM,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,CAEf;IAIvB,6BAAuB;IAEvB;;;;OAIG;IACH,KAFU,MAAM,GAAC,IAAI,CAEN;IAGhB;;;;;;OAMG;IACH,iBALW,MAAM,SACN,MAAM,GAAC,MAAM,EAAE,GAAC,YAAY,GAAC;QAAC,GAAG,EAAE,YAAY,CAAA;KAAC,GAE9C,OAAO,CAwDnB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,mBAEC;CACD"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * additional import for TypeScript
3
+ * @import Renderer from "../renderer.js";
4
+ */
5
+ /**
6
+ * Default maximum number of vertices per batch.
7
+ * At 4096 vertices (1024 quads), the vertex buffer is ~80 KB (5 floats × 4 bytes × 4096),
8
+ * which balances draw call reduction with safe buffer upload sizes on mobile tile-based GPUs.
9
+ * Within the Uint16 index limit (65,535) — a deliberate capacity choice
10
+ * (smaller index uploads), not an API constraint.
11
+ * @ignore
12
+ */
13
+ export const DEFAULT_MAX_VERTICES: 4096;
14
+ /**
15
+ * Backend-neutral base class for renderer batchers.
16
+ *
17
+ * A batcher accumulates vertices into a CPU staging buffer and turns them
18
+ * into GPU work in batches — one draw call for many shapes/sprites. This
19
+ * class defines the lifecycle contract shared by every backend:
20
+ *
21
+ * - `init(renderer, settings)` — build (or rebuild after a context/device
22
+ * loss) the batcher's GPU-facing state; called by the constructor
23
+ * - `bind()` / `unbind()` — the renderer switches the active batcher
24
+ * - `flush()` — turn the pending vertices into GPU work
25
+ * - `reset()` — drop transient state (game reset / context restore)
26
+ * - `destroy()` — release every GPU resource the batcher owns
27
+ *
28
+ * Custom batchers extend the class matching the renderer they target —
29
+ * {@link WebGLBatcher} for the WebGL renderer, `WebGPUBatcher` for the
30
+ * WebGPU renderer — and are registered through `renderer.addBatcher()`,
31
+ * which accepts any Batcher subclass.
32
+ * @category Rendering
33
+ */
34
+ export class Batcher {
35
+ /**
36
+ * Initialize (or re-initialize after a context/device loss) this batcher.
37
+ * Derived classes override this with their full `(renderer, settings)`
38
+ * signature and own the whole body; the base implementation only stores
39
+ * the renderer reference.
40
+ * @param {Renderer} renderer - the owning renderer
41
+ */
42
+ init(renderer: Renderer): void;
43
+ /**
44
+ * the renderer this batcher is bound to
45
+ * @type {Renderer}
46
+ */
47
+ renderer: Renderer | undefined;
48
+ /**
49
+ * called by the renderer when this batcher becomes the current one
50
+ */
51
+ bind(): void;
52
+ /**
53
+ * called by the renderer when this batcher is being replaced by another
54
+ */
55
+ unbind(): void;
56
+ /**
57
+ * turn the pending vertices into GPU work
58
+ */
59
+ flush(): void;
60
+ /**
61
+ * reset the batcher's transient state (game reset / context restore)
62
+ */
63
+ reset(): void;
64
+ /**
65
+ * release every GPU resource this batcher owns
66
+ */
67
+ destroy(): void;
68
+ }
69
+ export default Batcher;
70
+ import type Renderer from "../renderer.js";
71
+ //# sourceMappingURL=batcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../src/video/gpu/batcher.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AACH,mCAAoC,IAAI,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAMC;;;;;;OAMG;IACH,eAFW,QAAQ,QAQlB;IALA;;;OAGG;IACH,+BAAwB;IAGzB;;OAEG;IACH,aAAS;IAET;;OAEG;IACH,eAAW;IAEX;;OAEG;IACH,cAAU;IAEV;;OAEG;IACH,cAAU;IAEV;;OAEG;IACH,gBAAY;CACZ;;0BA9EwB,gBAAgB"}