melonjs 19.9.1 → 20.1.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 (276) 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/settings.d.ts +150 -53
  6. package/build/application/settings.d.ts.map +1 -1
  7. package/build/camera/camera2d.d.ts +1 -1
  8. package/build/camera/camera2d.d.ts.map +1 -1
  9. package/build/camera/camera3d.d.ts +13 -11
  10. package/build/camera/camera3d.d.ts.map +1 -1
  11. package/build/camera/effects/fade_effect.d.ts.map +1 -1
  12. package/build/camera/effects/mask_effect.d.ts.map +1 -1
  13. package/build/const.d.ts +55 -26
  14. package/build/const.d.ts.map +1 -1
  15. package/build/geometries/box3d.d.ts +156 -0
  16. package/build/geometries/box3d.d.ts.map +1 -0
  17. package/build/index.d.ts +34 -24
  18. package/build/index.d.ts.map +1 -1
  19. package/build/index.js +22171 -8029
  20. package/build/index.js.map +4 -4
  21. package/build/lang/deprecated.d.ts +4 -4
  22. package/build/lang/deprecated.d.ts.map +1 -1
  23. package/build/level/gltf/GLTFModel.d.ts +4 -0
  24. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  25. package/build/level/gltf/GLTFScene.d.ts +42 -6
  26. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  27. package/build/level/gltf/srgb.d.ts +20 -0
  28. package/build/level/gltf/srgb.d.ts.map +1 -0
  29. package/build/level/level.d.ts +21 -2
  30. package/build/level/level.d.ts.map +1 -1
  31. package/build/lighting/light3d.d.ts +61 -13
  32. package/build/lighting/light3d.d.ts.map +1 -1
  33. package/build/loader/loader.d.ts +49 -21
  34. package/build/loader/loader.d.ts.map +1 -1
  35. package/build/loader/parsers/gltf.d.ts.map +1 -1
  36. package/build/loader/parsers/mtl.d.ts +18 -0
  37. package/build/loader/parsers/mtl.d.ts.map +1 -1
  38. package/build/loader/parsers/obj.d.ts +49 -0
  39. package/build/loader/parsers/obj.d.ts.map +1 -1
  40. package/build/loader/parsers/pbr.d.ts +63 -0
  41. package/build/loader/parsers/pbr.d.ts.map +1 -0
  42. package/build/loader/parsers/shader.d.ts +32 -24
  43. package/build/loader/parsers/shader.d.ts.map +1 -1
  44. package/build/physics/adapter.d.ts +86 -1
  45. package/build/physics/adapter.d.ts.map +1 -1
  46. package/build/physics/broadphase/octree.d.ts +35 -0
  47. package/build/physics/broadphase/octree.d.ts.map +1 -1
  48. package/build/physics/builtin/body.d.ts +123 -15
  49. package/build/physics/builtin/body.d.ts.map +1 -1
  50. package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
  51. package/build/physics/builtin/detector.d.ts +186 -1
  52. package/build/physics/builtin/detector.d.ts.map +1 -1
  53. package/build/physics/builtin/raycast.d.ts.map +1 -1
  54. package/build/physics/builtin/sat3d.d.ts +59 -0
  55. package/build/physics/builtin/sat3d.d.ts.map +1 -0
  56. package/build/physics/response.d.ts +32 -0
  57. package/build/physics/response.d.ts.map +1 -1
  58. package/build/physics/world.d.ts +1 -0
  59. package/build/physics/world.d.ts.map +1 -1
  60. package/build/renderable/container.d.ts +1 -0
  61. package/build/renderable/container.d.ts.map +1 -1
  62. package/build/renderable/groundshadow.d.ts +92 -0
  63. package/build/renderable/groundshadow.d.ts.map +1 -0
  64. package/build/renderable/instanced_mesh.d.ts +286 -0
  65. package/build/renderable/instanced_mesh.d.ts.map +1 -0
  66. package/build/renderable/mesh.d.ts +242 -23
  67. package/build/renderable/mesh.d.ts.map +1 -1
  68. package/build/renderable/renderable.d.ts +6 -4
  69. package/build/renderable/renderable.d.ts.map +1 -1
  70. package/build/renderable/sprite3d.d.ts +17 -6
  71. package/build/renderable/sprite3d.d.ts.map +1 -1
  72. package/build/renderable/text/text.d.ts.map +1 -1
  73. package/build/system/device.d.ts +11 -40
  74. package/build/system/device.d.ts.map +1 -1
  75. package/build/system/platform.d.ts +0 -16
  76. package/build/system/platform.d.ts.map +1 -1
  77. package/build/utils/utils.d.ts +2 -0
  78. package/build/utils/utils.d.ts.map +1 -1
  79. package/build/video/canvas/canvas_renderer.d.ts +22 -16
  80. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  81. package/build/video/{webgl/effects → effects}/blur.d.ts +2 -2
  82. package/build/video/effects/blur.d.ts.map +1 -0
  83. package/build/video/{webgl/effects → effects}/chromaticAberration.d.ts +2 -2
  84. package/build/video/effects/chromaticAberration.d.ts.map +1 -0
  85. package/build/video/{webgl/effects → effects}/colorMatrix.d.ts +3 -3
  86. package/build/video/effects/colorMatrix.d.ts.map +1 -0
  87. package/build/video/{webgl/effects → effects}/desaturate.d.ts +1 -1
  88. package/build/video/effects/desaturate.d.ts.map +1 -0
  89. package/build/video/{webgl/effects → effects}/dissolve.d.ts +2 -2
  90. package/build/video/effects/dissolve.d.ts.map +1 -0
  91. package/build/video/{webgl/effects → effects}/dropShadow.d.ts +2 -2
  92. package/build/video/effects/dropShadow.d.ts.map +1 -0
  93. package/build/video/{webgl/effects → effects}/flash.d.ts +2 -2
  94. package/build/video/effects/flash.d.ts.map +1 -0
  95. package/build/video/{webgl/effects → effects}/glow.d.ts +2 -2
  96. package/build/video/effects/glow.d.ts.map +1 -0
  97. package/build/video/effects/glsl_realization.d.ts +18 -0
  98. package/build/video/effects/glsl_realization.d.ts.map +1 -0
  99. package/build/video/{webgl/effects → effects}/hologram.d.ts +2 -2
  100. package/build/video/effects/hologram.d.ts.map +1 -0
  101. package/build/video/{webgl/effects → effects}/invert.d.ts +1 -1
  102. package/build/video/effects/invert.d.ts.map +1 -0
  103. package/build/video/{webgl/effects → effects}/outline.d.ts +2 -2
  104. package/build/video/effects/outline.d.ts.map +1 -0
  105. package/build/video/{webgl/effects → effects}/pixelate.d.ts +2 -2
  106. package/build/video/effects/pixelate.d.ts.map +1 -0
  107. package/build/video/{webgl/effects → effects}/radialGradient.d.ts +3 -4
  108. package/build/video/effects/radialGradient.d.ts.map +1 -0
  109. package/build/video/{webgl/effects → effects}/scanline.d.ts +2 -2
  110. package/build/video/effects/scanline.d.ts.map +1 -0
  111. package/build/video/{webgl/effects → effects}/sepia.d.ts +1 -1
  112. package/build/video/effects/sepia.d.ts.map +1 -0
  113. package/build/video/{webgl → effects}/shadereffect.d.ts +133 -25
  114. package/build/video/effects/shadereffect.d.ts.map +1 -0
  115. package/build/video/{webgl/effects → effects}/shine.d.ts +2 -2
  116. package/build/video/effects/shine.d.ts.map +1 -0
  117. package/build/video/{webgl/effects → effects}/tintPulse.d.ts +2 -2
  118. package/build/video/effects/tintPulse.d.ts.map +1 -0
  119. package/build/video/{webgl/effects → effects}/vignette.d.ts +2 -2
  120. package/build/video/effects/vignette.d.ts.map +1 -0
  121. package/build/video/{webgl/effects → effects}/wave.d.ts +2 -2
  122. package/build/video/effects/wave.d.ts.map +1 -0
  123. package/build/video/effects/wgsl/layout.d.ts +28 -0
  124. package/build/video/effects/wgsl/layout.d.ts.map +1 -0
  125. package/build/video/effects/wgsl/parse.d.ts +9 -0
  126. package/build/video/effects/wgsl/parse.d.ts.map +1 -0
  127. package/build/video/effects/wgsl/scaffold.d.ts +43 -0
  128. package/build/video/effects/wgsl/scaffold.d.ts.map +1 -0
  129. package/build/video/effects/wgsl_realization.d.ts +83 -0
  130. package/build/video/effects/wgsl_realization.d.ts.map +1 -0
  131. package/build/video/gpu/batcher.d.ts +71 -0
  132. package/build/video/gpu/batcher.d.ts.map +1 -0
  133. package/build/video/gpu/instancerecord.d.ts +164 -0
  134. package/build/video/gpu/instancerecord.d.ts.map +1 -0
  135. package/build/video/gpu/meshchunk.d.ts +49 -0
  136. package/build/video/gpu/meshchunk.d.ts.map +1 -0
  137. package/build/video/gpu/meshvertex.d.ts +54 -0
  138. package/build/video/gpu/meshvertex.d.ts.map +1 -0
  139. package/build/video/gpu/primitives.d.ts +60 -0
  140. package/build/video/gpu/primitives.d.ts.map +1 -0
  141. package/build/video/gpu/quadcorners.d.ts +11 -0
  142. package/build/video/gpu/quadcorners.d.ts.map +1 -0
  143. package/build/video/gpu/textureslots.d.ts +122 -0
  144. package/build/video/gpu/textureslots.d.ts.map +1 -0
  145. package/build/video/gpu/texturestore.d.ts +139 -0
  146. package/build/video/gpu/texturestore.d.ts.map +1 -0
  147. package/build/video/gpu/topology.d.ts +43 -0
  148. package/build/video/gpu/topology.d.ts.map +1 -0
  149. package/build/video/gpu/vertexformat.d.ts +72 -0
  150. package/build/video/gpu/vertexformat.d.ts.map +1 -0
  151. package/build/video/gradient.d.ts +14 -5
  152. package/build/video/gradient.d.ts.map +1 -1
  153. package/build/video/renderer.d.ts +153 -8
  154. package/build/video/renderer.d.ts.map +1 -1
  155. package/build/video/rendertarget/canvasrendertarget.d.ts +7 -6
  156. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  157. package/build/video/rendertarget/render_target_pool.d.ts +2 -2
  158. package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
  159. package/build/video/rendertarget/webglrendertarget.d.ts +38 -2
  160. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  161. package/build/video/rendertarget/webgpurendertarget.d.ts +83 -0
  162. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -0
  163. package/build/video/texture/atlas.d.ts.map +1 -1
  164. package/build/video/texture/cache.d.ts +20 -2
  165. package/build/video/texture/cache.d.ts.map +1 -1
  166. package/build/video/texture/noise_texture2d.d.ts +2 -2
  167. package/build/video/utils/autodetect.d.ts.map +1 -1
  168. package/build/video/video.d.ts +1 -55
  169. package/build/video/video.d.ts.map +1 -1
  170. package/build/video/webgl/batchers/batcher.d.ts +132 -35
  171. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  172. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +14 -0
  173. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
  174. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +63 -36
  175. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  176. package/build/video/webgl/batchers/material_batcher.d.ts +29 -20
  177. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  178. package/build/video/webgl/batchers/mesh_batcher.d.ts +308 -14
  179. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  180. package/build/video/webgl/batchers/primitive_batcher.d.ts +2 -2
  181. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  182. package/build/video/webgl/batchers/quad_batcher.d.ts +0 -2
  183. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  184. package/build/video/webgl/buffer/index.d.ts +1 -1
  185. package/build/video/webgl/buffer/instance_buffer.d.ts +54 -0
  186. package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -0
  187. package/build/video/webgl/buffer/retained_geometry.d.ts +83 -0
  188. package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -0
  189. package/build/video/webgl/buffer/uniformblock.d.ts +81 -0
  190. package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -0
  191. package/build/video/webgl/buffer/vertexstate.d.ts +101 -0
  192. package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -0
  193. package/build/video/webgl/glshader.d.ts +101 -8
  194. package/build/video/webgl/glshader.d.ts.map +1 -1
  195. package/build/video/webgl/lighting/constants.d.ts +20 -8
  196. package/build/video/webgl/lighting/constants.d.ts.map +1 -1
  197. package/build/video/webgl/lighting/pack.d.ts +1 -1
  198. package/build/video/webgl/lighting/pack3d.d.ts +27 -11
  199. package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
  200. package/build/video/webgl/lighting/std140.d.ts +110 -0
  201. package/build/video/webgl/lighting/std140.d.ts.map +1 -0
  202. package/build/video/webgl/shaders/multitexture-lit.d.ts +7 -3
  203. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  204. package/build/video/webgl/texture/store.d.ts +52 -0
  205. package/build/video/webgl/texture/store.d.ts.map +1 -0
  206. package/build/video/webgl/utils/maxtextures.d.ts +37 -0
  207. package/build/video/webgl/utils/maxtextures.d.ts.map +1 -0
  208. package/build/video/webgl/utils/samplercache.d.ts +69 -0
  209. package/build/video/webgl/utils/samplercache.d.ts.map +1 -0
  210. package/build/video/webgl/utils/string.d.ts +16 -0
  211. package/build/video/webgl/utils/string.d.ts.map +1 -1
  212. package/build/video/webgl/utils/topology.d.ts +24 -0
  213. package/build/video/webgl/utils/topology.d.ts.map +1 -0
  214. package/build/video/webgl/utils/vertexformat.d.ts +27 -0
  215. package/build/video/webgl/utils/vertexformat.d.ts.map +1 -0
  216. package/build/video/webgl/webgl_renderer.d.ts +148 -30
  217. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  218. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +40 -0
  219. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -0
  220. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +82 -0
  221. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -0
  222. package/build/video/webgpu/batchers/mesh_batcher.d.ts +301 -0
  223. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -0
  224. package/build/video/webgpu/batchers/primitive_batcher.d.ts +39 -0
  225. package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -0
  226. package/build/video/webgpu/batchers/quad_batcher.d.ts +143 -0
  227. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -0
  228. package/build/video/webgpu/batchers/webgpu_batcher.d.ts +70 -0
  229. package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -0
  230. package/build/video/webgpu/buffer/arena.d.ts +64 -0
  231. package/build/video/webgpu/buffer/arena.d.ts.map +1 -0
  232. package/build/video/webgpu/buffer/instance_buffer.d.ts +65 -0
  233. package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -0
  234. package/build/video/webgpu/buffer/retained_geometry.d.ts +55 -0
  235. package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -0
  236. package/build/video/webgpu/buffer/uniformring.d.ts +68 -0
  237. package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -0
  238. package/build/video/webgpu/effect_binding.d.ts +17 -0
  239. package/build/video/webgpu/effect_binding.d.ts.map +1 -0
  240. package/build/video/webgpu/pipeline/bindgroups.d.ts +36 -0
  241. package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -0
  242. package/build/video/webgpu/pipeline/cache.d.ts +173 -0
  243. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -0
  244. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +90 -0
  245. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -0
  246. package/build/video/webgpu/shaders/mesh-instanced.d.ts +60 -0
  247. package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -0
  248. package/build/video/webgpu/texture/compressed.d.ts +33 -0
  249. package/build/video/webgpu/texture/compressed.d.ts.map +1 -0
  250. package/build/video/webgpu/texture/frametexture.d.ts +65 -0
  251. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -0
  252. package/build/video/webgpu/texture/store.d.ts +149 -0
  253. package/build/video/webgpu/texture/store.d.ts.map +1 -0
  254. package/build/video/webgpu/webgpu_renderer.d.ts +536 -0
  255. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -0
  256. package/package.json +2 -2
  257. package/build/video/webgl/effects/blur.d.ts.map +0 -1
  258. package/build/video/webgl/effects/chromaticAberration.d.ts.map +0 -1
  259. package/build/video/webgl/effects/colorMatrix.d.ts.map +0 -1
  260. package/build/video/webgl/effects/desaturate.d.ts.map +0 -1
  261. package/build/video/webgl/effects/dissolve.d.ts.map +0 -1
  262. package/build/video/webgl/effects/dropShadow.d.ts.map +0 -1
  263. package/build/video/webgl/effects/flash.d.ts.map +0 -1
  264. package/build/video/webgl/effects/glow.d.ts.map +0 -1
  265. package/build/video/webgl/effects/hologram.d.ts.map +0 -1
  266. package/build/video/webgl/effects/invert.d.ts.map +0 -1
  267. package/build/video/webgl/effects/outline.d.ts.map +0 -1
  268. package/build/video/webgl/effects/pixelate.d.ts.map +0 -1
  269. package/build/video/webgl/effects/radialGradient.d.ts.map +0 -1
  270. package/build/video/webgl/effects/scanline.d.ts.map +0 -1
  271. package/build/video/webgl/effects/sepia.d.ts.map +0 -1
  272. package/build/video/webgl/effects/shine.d.ts.map +0 -1
  273. package/build/video/webgl/effects/tintPulse.d.ts.map +0 -1
  274. package/build/video/webgl/effects/vignette.d.ts.map +0 -1
  275. package/build/video/webgl/effects/wave.d.ts.map +0 -1
  276. package/build/video/webgl/shadereffect.d.ts.map +0 -1
@@ -1,10 +1,26 @@
1
1
  /**
2
- * A base WebGL Batcher object that manages shader programs, vertex attribute
3
- * definitions, and vertex buffer batching for efficient GPU draw calls.
2
+ * additional import for TypeScript
3
+ * @import WebGLRenderer from "./../webgl_renderer.js";
4
+ * @import {Matrix3d} from "../../../math/matrix3d.ts";
5
+ * @import {VertexFormat} from "../../gpu/vertexformat.ts";
6
+ * @import {Topology} from "../../gpu/topology.ts";
7
+ */
8
+ /**
9
+ * The base WebGL Batcher — manages shader programs, vertex attribute
10
+ * definitions, and vertex buffer batching for efficient GPU draw calls,
11
+ * realizing the backend-neutral {@link Batcher} lifecycle on GL state.
12
+ * Custom WebGL batchers extend this class.
13
+ * @augments Batcher
4
14
  * @category Rendering
5
15
  */
6
- export class Batcher {
16
+ export class WebGLBatcher extends Batcher {
17
+ /**
18
+ * @param {WebGLRenderer} renderer - the current WebGL renderer session
19
+ * @param {object} settings - additional settings to initialize this batcher (see {@link WebGLBatcher#init})
20
+ */
21
+ constructor(renderer: WebGLRenderer, settings: object);
7
22
  /**
23
+ * Initialize the batcher (called by the constructor)
8
24
  * @param {WebGLRenderer} renderer - the current WebGL renderer session
9
25
  * @param {object} settings - additional settings to initialize this batcher
10
26
  * @param {object[]} settings.attributes - an array of attributes definition
@@ -20,7 +36,7 @@ export class Batcher {
20
36
  * @param {boolean} [settings.indexed=false] - whether this batcher uses an index buffer for indexed drawing (drawElements)
21
37
  * @param {string} [settings.projectionUniform="uProjectionMatrix"] - the name of the projection matrix uniform in the shader
22
38
  */
23
- constructor(renderer: WebGLRenderer, settings: {
39
+ init(renderer: WebGLRenderer, settings: {
24
40
  attributes: {
25
41
  name: string;
26
42
  size: number;
@@ -35,15 +51,9 @@ export class Batcher {
35
51
  maxVertices?: number | undefined;
36
52
  indexed?: boolean | undefined;
37
53
  projectionUniform?: string | undefined;
38
- });
39
- /**
40
- * Initialize the batcher
41
- * @ignore
42
- */
43
- init(renderer: any, settings: any): void;
44
- renderer: any;
54
+ }): void;
45
55
  gl: any;
46
- viewMatrix: any;
56
+ viewMatrix: Matrix3d | undefined;
47
57
  /**
48
58
  * the default shader created by this batcher
49
59
  * @type {GLShader}
@@ -55,28 +65,38 @@ export class Batcher {
55
65
  */
56
66
  currentShader: GLShader | undefined;
57
67
  /**
58
- * primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
68
+ * @param {Topology|number} value - a topology name or a GL primitive mode
69
+ */
70
+ set mode(value: Topology | number);
71
+ /**
72
+ * Primitive type to render, as a GL enum (`gl.TRIANGLES`, `gl.LINES`, …).
73
+ *
74
+ * Assignable from either vocabulary — `batcher.mode = "line-list"` and
75
+ * `batcher.mode = gl.LINES` are equivalent — but always reads back as the
76
+ * GL enum, so existing comparisons keep working. Read
77
+ * {@link WebGLBatcher#topology} for the portable name.
59
78
  * @type {number}
60
79
  * @default gl.TRIANGLES
61
80
  */
62
- mode: number | undefined;
81
+ get mode(): number;
82
+ vertexState: WebGLVertexState | null | undefined;
63
83
  /**
64
84
  * an array of vertex attribute properties
65
- * @see Batcher.addAttribute
85
+ * @see WebGLBatcher.addAttribute
66
86
  * @type {Array.<Object>}
67
87
  */
68
88
  attributes: Object[] | undefined;
69
89
  /**
70
90
  * the stride of a single vertex in bytes
71
91
  * (will automatically be calculated as attributes definitions are added)
72
- * @see Batcher.addAttribute
92
+ * @see WebGLBatcher.addAttribute
73
93
  * @type {number}
74
94
  */
75
95
  stride: number | undefined;
76
96
  /**
77
97
  * the size of a single vertex in floats
78
98
  * (will automatically be calculated as attributes definitions are added)
79
- * @see Batcher.addAttribute
99
+ * @see WebGLBatcher.addAttribute
80
100
  * @type {number}
81
101
  */
82
102
  vertexSize: number | undefined;
@@ -108,20 +128,49 @@ export class Batcher {
108
128
  */
109
129
  indexBuffer: WebGLIndexBuffer | null | undefined;
110
130
  /**
111
- * Reset batcher internal state
131
+ * The GL buffer this batcher uploads its vertex data into: its own
132
+ * buffer for indexed (mesh-family) batchers, otherwise the renderer's
133
+ * shared one.
134
+ * @type {WebGLBuffer}
112
135
  * @ignore
113
136
  */
114
- reset(): void;
137
+ get uploadBuffer(): WebGLBuffer;
115
138
  /**
116
- * called by the WebGL renderer when a batcher becomes the current one
139
+ * (Re)build this batcher's {@link WebGLVertexState} — the frozen vertex
140
+ * buffer layout (`attributes` + `stride`) realized as a GL vertex array
141
+ * object bound to this batcher's upload buffer and, for indexed
142
+ * batchers, its index buffer.
143
+ *
144
+ * Every shader hosted by this batcher must declare a prefix of that
145
+ * layout, in layout order (see {@link validateShaderLocations}) — the
146
+ * locations are frozen here at the default shader's mapping.
147
+ * @ignore
117
148
  */
118
- bind(): void;
149
+ createVertexState(): void;
119
150
  /**
120
- * called by the WebGL renderer when this batcher is being replaced by another.
121
- * Disables this batcher's vertex attribute locations so they don't leak across
122
- * (otherwise stale stride/offset state can cause INVALID_OPERATION on the next draw).
151
+ * Validate (once per shader) that a hosted shader's attribute locations
152
+ * match this batcher's frozen vertex state. The engine's analogue of
153
+ * WebGPU's pipeline-creation validation: locations are bound in vertex
154
+ * source declaration order, so every shader hosted by this batcher must
155
+ * declare a prefix of the batcher's attribute layout, in layout order.
156
+ * A mismatched shader silently reads wrong vertex data — warn loudly.
157
+ * @ignore
123
158
  */
124
- unbind(): void;
159
+ validateShaderLocations(shader: any): void;
160
+ validatedShaders: WeakSet<object> | undefined;
161
+ /**
162
+ * Ensure the draw about to be recorded runs on THIS batcher's program.
163
+ * Normally `bind()` guaranteed that, but an `ONCONTEXT_RESTORED`
164
+ * emission recompiles every live GLShader — each replaying its uniform
165
+ * snapshot on its OWN program — leaving whichever recompiled last
166
+ * really bound while the renderer's cache still named another. The
167
+ * renderer invalidates its program cache on that event, so this
168
+ * pointer compare re-issues `useProgram` exactly when the drift
169
+ * happened and costs two loads otherwise. Called by every flush path
170
+ * (the base and the quad override).
171
+ * @ignore
172
+ */
173
+ syncProgram(): void;
125
174
  /**
126
175
  * Select the shader to use for compositing
127
176
  * @see GLShader
@@ -130,14 +179,57 @@ export class Batcher {
130
179
  useShader(shader: GLShader): void;
131
180
  currentSamplerUnit: number | undefined;
132
181
  /**
133
- * add vertex attribute property definition to the batcher
134
- * @param {string} name - name of the attribute in the vertex shader
135
- * @param {number} size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
136
- * @param {GLenum} type - data type of each component in the array
137
- * @param {boolean} normalized - whether integer data values should be normalized into a certain range when being cast to a float
138
- * @param {number} offset - offset in bytes of the first component in the vertex attribute array
182
+ * @param {Topology|number} value - a topology name or a GL primitive mode
139
183
  */
140
- addAttribute(name: string, size: number, type: GLenum, normalized: boolean, offset: number): void;
184
+ set topology(value: Topology | number);
185
+ /**
186
+ * How this batcher assembles vertices into primitives, in the
187
+ * backend-neutral vocabulary.
188
+ *
189
+ * `"line-loop"` and `"triangle-fan"` are engine extensions with no
190
+ * equivalent in modern GPU APIs — prefer the others for anything that must
191
+ * survive a backend change.
192
+ * @type {Topology}
193
+ * @default "triangle-list"
194
+ */
195
+ get topology(): Topology;
196
+ /**
197
+ * Add a vertex attribute to this batcher's layout.
198
+ *
199
+ * Accepts either vocabulary. The backend-neutral form names the component
200
+ * type and count in one token, which is what a non-WebGL backend can
201
+ * consume directly and what lets a layout be written without a live
202
+ * rendering context:
203
+ *
204
+ * ```js
205
+ * batcher.addAttribute({ name: "aColor", format: "unorm8x4", offset: 20 });
206
+ * batcher.addAttribute("aColor", "unorm8x4", 20);
207
+ * ```
208
+ *
209
+ * The GL form is supported indefinitely and behaves exactly as before:
210
+ *
211
+ * ```js
212
+ * batcher.addAttribute("aColor", 4, gl.UNSIGNED_BYTE, true, 20);
213
+ * ```
214
+ *
215
+ * Records keep both spellings, so existing readers of `size` / `type` /
216
+ * `normalized` are unaffected. A GL combination with no portable name —
217
+ * three-component 8- and 16-bit types, which the neutral vocabulary does
218
+ * not define — is stored with `format: undefined` rather than an invented
219
+ * name that a backend could not honour.
220
+ *
221
+ * The layout is frozen once `init()` has built the vertex state, and each
222
+ * record is frozen on insertion: a batcher rebuilds its vertex state from
223
+ * these records after a context loss, so a later mutation would take
224
+ * effect at restore time rather than where it was written.
225
+ * @param {string|object} name - attribute name, or a descriptor object
226
+ * @param {number|VertexFormat} [size] - component count (GL form), or the format (neutral form)
227
+ * @param {GLenum|number} [type] - component type (GL form), or the byte offset (neutral form)
228
+ * @param {boolean} [normalized] - whether integers are scaled into `[0, 1]` / `[-1, 1]` (GL form only)
229
+ * @param {number} [offset] - byte offset of the attribute within a vertex (GL form)
230
+ * @throws {Error} when the layout is frozen, the format or GL type is unknown, or a descriptor contradicts itself
231
+ */
232
+ addAttribute(name: string | object, size?: number | VertexFormat, type?: GLenum | number, normalized?: boolean, offset?: number, ...args: any[]): void;
141
233
  /**
142
234
  * set/change the current projection matrix
143
235
  * @param {Matrix3d} matrix - the new projection matrix
@@ -154,11 +246,16 @@ export class Batcher {
154
246
  * @param {number} [mode=gl.TRIANGLES] - the GL drawing mode
155
247
  */
156
248
  flush(mode?: number): void;
249
+ #private;
157
250
  }
158
- export default Batcher;
251
+ export default WebGLBatcher;
252
+ import { Batcher } from "../../gpu/batcher.js";
253
+ import type WebGLRenderer from "./../webgl_renderer.js";
254
+ import type { Matrix3d } from "../../../math/matrix3d.ts";
159
255
  import GLShader from "../glshader.js";
256
+ import type { Topology } from "../../gpu/topology.ts";
257
+ import WebGLVertexState from "../buffer/vertexstate.js";
160
258
  import VertexArrayBuffer from "../../buffer/vertex.js";
161
259
  import WebGLIndexBuffer from "../buffer/index.js";
162
- import type { Matrix3d } from "../../../math/matrix3d.ts";
163
- import type WebGLRenderer from "./../webgl_renderer.js";
260
+ import type { VertexFormat } from "../../gpu/vertexformat.ts";
164
261
  //# sourceMappingURL=batcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/batcher.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH;IACC;;;;;;;;;;;;;;;OAeG;IACH,sBAfW,aAAa,YAErB;QAA2B,UAAU,EACrC;YAAoC,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACuB,UAAU,EAAvC,OAAO;YACqB,MAAM,EAAlC,MAAM;SACd;QAAyB,MAAM,EAC/B;YAAgC,MAAM,EAA9B,MAAM;YACkB,QAAQ,EAAhC,MAAM;SACd;QAA0B,WAAW;QACV,OAAO;QACR,iBAAiB;KAC7C,EAGA;IAED;;;OAGG;IACH,yCA6HC;IA3HA,cAAwB;IAGxB,QAAqB;IAGrB,gBAA2C;IAE3C;;;OAGG;IACH,oCAA8B;IAE9B;;;OAGG;IACH,oCAA8B;IAE9B;;;;OAIG;IACH,yBAA6B;IAE7B;;;;OAIG;IACH,iCAAoB;IAEpB;;;;;OAKG;IACH,2BAAe;IAEf;;;;;OAKG;IACH,+BAAmB;IAEnB;;;OAGG;IACH,0CAAsB;IAqCtB;;;OAGG;IACH,sCAA0E;IAE1E;;;OAGG;IACH,oCAA+C;IAE/C;;;;OAIG;IACH,+CAA0B;IAE1B;;;;OAIG;IACH,iDAAuB;IAUxB;;;OAGG;IACH,cAoBC;IAED;;OAEG;IACH,aAYC;IAED;;;;OAIG;IACH,eAaC;IAED;;;;OAIG;IACH,kBAFW,QAAQ,QA8BlB;IAHE,uCAA4B;IAK/B;;;;;;;OAOG;IACH,mBANW,MAAM,QACN,MAAM,QACN,MAAM,cACN,OAAO,UACP,MAAM,QA+BhB;IAED;;;OAGG;IACH,sBAFW,QAAQ,QAIlB;IAED;;;;OAIG;IACH,oBAFW,MAAM,EAAE,QAOlB;IAED;;;OAGG;IACH,aAFW,MAAM,QAgFhB;CACD;;qBA9ZoB,gBAAgB;8BAFP,wBAAwB;6BACzB,oBAAoB;8BAMtB,2BAA2B;+BADxB,wBAAwB"}
1
+ {"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/batcher.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH;IAgBC;;;OAGG;IACH,sBAHW,aAAa,YACb,MAAM,EAKhB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,eAfW,aAAa,YAErB;QAA2B,UAAU,EACrC;YAAoC,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACuB,UAAU,EAAvC,OAAO;YACqB,MAAM,EAAlC,MAAM;SACd;QAAyB,MAAM,EAC/B;YAAgC,MAAM,EAA9B,MAAM;YACkB,QAAQ,EAAhC,MAAM;SACd;QAA0B,WAAW;QACV,OAAO;QACR,iBAAiB;KAC7C,QA+IA;IAzIA,QAAqB;IAGrB,iCAA2C;IAE3C;;;OAGG;IACH,oCAA8B;IAE9B;;;OAGG;IACH,oCAA8B;IA2X/B;;OAEG;IACH,gBAFW,QAAQ,GAAC,MAAM,EASzB;IAxBD;;;;;;;;;OASG;IACH,YAHU,MAAM,CAKf;IA/WC,iDAAuB;IAGxB;;;;OAIG;IACH,iCAAoB;IAEpB;;;;;OAKG;IACH,2BAAe;IAEf;;;;;OAKG;IACH,+BAAmB;IAEnB;;;OAGG;IACH,0CAAsB;IA4CtB;;;OAGG;IACH,sCAA0E;IAE1E;;;OAGG;IACH,oCAA+C;IAE/C;;;;OAIG;IACH,+CAA0B;IAE1B;;;;OAIG;IACH,iDAAuB;IAgBxB;;;;;;OAMG;IACH,oBAHU,WAAW,CAKpB;IAED;;;;;;;;;;OAUG;IACH,0BAiBC;IAyFD;;;;;;;;OAQG;IACH,2CA0BC;IAxBC,8CAAqC;IA0BvC;;;;;;;;;;;OAWG;IACH,oBAaC;IAED;;;;OAIG;IACH,kBAFW,QAAQ,QAuBlB;IAHE,uCAA4B;IAmB/B;;OAEG;IACH,oBAFW,QAAQ,GAAC,MAAM,EAIzB;IAnBD;;;;;;;;;OASG;IACH,gBAHU,QAAQ,CAKjB;IAmCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,mBAPW,MAAM,GAAC,MAAM,SACb,MAAM,GAAC,YAAY,SACnB,MAAM,GAAC,MAAM,eACb,OAAO,WACP,MAAM,wBA4BhB;IAiJD;;;OAGG;IACH,sBAFW,QAAQ,QAIlB;IAED;;;;OAIG;IACH,oBAFW,MAAM,EAAE,QAOlB;IAED;;;OAGG;IACH,aAFW,MAAM,QAqEhB;;CACD;;wBAvwB6C,sBAAsB;+BAUtC,wBAAwB;8BAC3B,2BAA2B;qBAPjC,gBAAgB;8BASV,uBAAuB;6BAVrB,0BAA0B;8BAJzB,wBAAwB;6BAGzB,oBAAoB;kCAUlB,2BAA2B"}
@@ -11,8 +11,22 @@
11
11
  * @category Rendering
12
12
  */
13
13
  export default class LitMeshBatcher extends MeshBatcher {
14
+ lightBlock: UniformBlock | undefined;
15
+ _lightBlockProgram: any;
16
+ /**
17
+ * Point the active program's `Light3dBlock` at our uniform buffer.
18
+ *
19
+ * A block binding is program state, so it has to be re-established
20
+ * whenever the program changes: a context restore recompiles it, `init`
21
+ * re-runs on reset, and `useShader` can swap one in without a batcher
22
+ * transition. Comparing against the program we last bound covers all
23
+ * three — a pointer compare in the steady state.
24
+ * @ignore
25
+ */
26
+ _bindLightBlock(): void;
14
27
  /** push the 12-float lit vertex, appending the mesh's world-space normal. @ignore */
15
28
  _pushVertex(vertexData: any, x: any, y: any, z: any, u: any, v: any, color: any, mesh: any, i3: any): void;
16
29
  }
17
30
  import MeshBatcher from "./mesh_batcher.js";
31
+ import UniformBlock from "../buffer/uniformblock.js";
18
32
  //# sourceMappingURL=lit_mesh_batcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lit_mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/lit_mesh_batcher.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;GAWG;AACH;IAqBC,qFAAqF;IACrF,2GAaC;CA0BD;wBAzFuB,mBAAmB"}
1
+ {"version":3,"file":"lit_mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/lit_mesh_batcher.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;;GAWG;AACH;IAuBE,qCAIC;IACD,wBAA8B;IAO/B;;;;;;;;;OASG;IACH,wBAQC;IAyCD,qFAAqF;IACrF,2GAaC;CA4DD;wBApMuB,mBAAmB;yBAPlB,2BAA2B"}
@@ -6,13 +6,12 @@
6
6
  * Lit-aware variant of `QuadBatcher` for the SpriteIlluminator workflow.
7
7
  *
8
8
  * Adds a 5th vertex attribute (`aNormalTextureId`) so each quad knows
9
- * which paired normal-map sampler to read, and bundles the per-frame
10
- * light uniforms (`uLightPos`, `uLightColor`, `uLightHeight`, `uAmbient`)
11
- * that the lit fragment shader iterates.
9
+ * which slot its normal map occupies, and owns the per-frame
10
+ * `Light2dBlock` uniform buffer that the lit fragment shader iterates.
12
11
  *
13
- * Texture-slot capacity is halved relative to `QuadBatcher` because each
14
- * sprite may need a paired (color, normal) sampler — color goes to unit
15
- * `n`, normal to unit `maxBatchTextures + n`. The `WebGLRenderer` only
12
+ * Colors and normal maps share ONE slot pool the same size as `QuadBatcher`'s
13
+ * (#1585) — a normal map is allocated a unit like any other texture, and
14
+ * `aNormalTextureId` records which one. The `WebGLRenderer` only
16
15
  * dispatches sprites here when the scene actually needs lighting (active
17
16
  * `Light2d` AND the sprite has a `normalMap`); unlit sprites stay on
18
17
  * `QuadBatcher` and pay nothing.
@@ -36,23 +35,37 @@ export default class LitQuadBatcher extends QuadBatcher {
36
35
  * @ignore
37
36
  */
38
37
  boundNormalVersions: number[] | undefined;
38
+ normalStore: WebGLTextureStore | undefined;
39
39
  /**
40
- * Map from a normal-map source image to its uploaded GL texture and the
41
- * source `version` it was uploaded at. A source that bumps its `version`
42
- * (e.g. an animated {@link NoiseTexture2d}) is re-uploaded on next bind —
43
- * the three.js `Texture.needsUpdate` model, scoped to normal maps which
44
- * live outside the color `TextureCache`.
45
- * @type {Map<HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap, {tex: WebGLTexture, version: number}>}
40
+ * Which slot in the shared pool each normal-map source currently holds.
41
+ * Normal maps are not in the color `TextureCache` (they are raw sources
42
+ * with their own GL textures), so their unit assignment is tracked here
43
+ * while the unit itself comes from the same allocator the colors use.
44
+ * @type {Map<HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap, number>}
46
45
  * @ignore
47
46
  */
48
- normalMapTextures: Map<ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas, {
49
- tex: WebGLTexture;
50
- version: number;
51
- }> | undefined;
47
+ normalUnits: Map<ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas, number> | undefined;
48
+ _cacheEpoch: any;
52
49
  _lightCount: number | undefined;
53
50
  _maxLights: number | undefined;
51
+ lightBlock: UniformBlock | undefined;
52
+ _lightBlockProgram: any;
54
53
  _onTexture2dDestroyed: ((source: any) => void) | null | undefined;
55
- _normalRangeReserved: boolean | undefined;
54
+ /**
55
+ * Point the active program's `Light2dBlock` at our uniform buffer.
56
+ *
57
+ * A block binding is *program* state, and the program can change under us
58
+ * in three ways: a context restore recompiles it, `setBatcher` can host a
59
+ * {@link ShaderEffect} on this batcher, and `init` re-runs on reset. Rather
60
+ * than hook each of those, re-bind whenever the program is not the one we
61
+ * last bound — a pointer compare per `bind`, and self-healing.
62
+ *
63
+ * A hosted `ShaderEffect` is a plain unlit ES 1.00 program with no light
64
+ * block, so `bindTo` reports failure and we simply record it, leaving the
65
+ * next real lit program to bind normally.
66
+ * @ignore
67
+ */
68
+ _bindLightBlock(): void;
56
69
  /**
57
70
  * Release the cached GL texture uploaded for the given normal-map source
58
71
  * and clear any slot bookkeeping referencing it. Safe to call for images
@@ -61,24 +74,23 @@ export default class LitQuadBatcher extends QuadBatcher {
61
74
  */
62
75
  evictNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap): void;
63
76
  /**
64
- * Bind the paired normal sampler uniforms (`uNormalSampler0..N-1`)
65
- * to texture units `maxBatchTextures..2*maxBatchTextures-1`. Called
66
- * from `init` and `reset`.
67
- * @ignore
68
- */
69
- bindNormalSamplers(): void;
70
- /**
71
- * Upload per-frame Light2d uniforms used by the lit fragment path.
77
+ * Upload the per-frame Light2d data used by the lit fragment path.
72
78
  * Called once per camera per frame (before the world tree walk).
73
79
  * Lights past `MAX_LIGHTS` are silently ignored.
74
80
  *
75
81
  * Coordinates must be supplied in the same space as the renderer's
76
82
  * pre-projection vertex coords (i.e. camera-local / FBO-local),
77
83
  * matching `Stage.drawLighting`'s convention.
84
+ *
85
+ * The data goes into the `Light2dBlock` uniform buffer, which is
86
+ * independent of which program is current — so unlike the uniform arrays
87
+ * this replaced, calling it does not disturb the active shader. The
88
+ * upload is skipped outright when the packed bytes are unchanged, so a
89
+ * scene whose lights are static still costs nothing per frame.
78
90
  * @param {object} uniforms
79
91
  * @param {Float32Array} uniforms.positions - flat array of `[x, y, radius, intensity]` per light, length = 4 * count
80
92
  * @param {Float32Array} uniforms.colors - flat array of `[r, g, b]` per light, length = 3 * count
81
- * @param {Float32Array} [uniforms.heights] - flat array of per-light height, length = MAX_LIGHTS
93
+ * @param {Float32Array} [uniforms.heights] - flat array of per-light height, length >= count
82
94
  * @param {number} uniforms.count - number of lights to render (clamped to MAX_LIGHTS)
83
95
  * @param {number[]} [uniforms.ambient] - `[r, g, b]` ambient floor (0..1 each)
84
96
  */
@@ -97,22 +109,35 @@ export default class LitQuadBatcher extends QuadBatcher {
97
109
  * but for normal-map textures which live outside the color
98
110
  * `TextureCache` (cached per-image in `normalMapTextures`).
99
111
  * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - normal-map source
100
- * @param {number} unit - GL texture unit (already offset by `maxBatchTextures`)
112
+ * @param {number} unit - GL texture unit the normal map is resolved to
101
113
  */
102
114
  bindNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, unit: number): void;
103
115
  /**
104
- * Upload a normal-map image to GL and cache the resulting `WebGLTexture`
105
- * for future `bindNormalMap` calls. Not meant to be called directly —
106
- * `bindNormalMap` invokes this on the first use of a given image.
116
+ * Drop a normal map's slot claim and hand the unit back to the allocator.
107
117
  *
108
- * `premultipliedAlpha = false` — normal maps store linear-encoded
109
- * surface normals; multiplying through alpha would corrupt the
110
- * encoding for any non-opaque texel.
118
+ * A normal map claims its unit through `allocateTextureUnit()`, which has no
119
+ * key to release against — so without this the unit stayed marked used for
120
+ * the rest of the session and the pool drained monotonically as normal maps
121
+ * came and went, until something forced a full reset.
111
122
  * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - normal-map source
112
- * @param {number} unit - GL texture unit (already offset by `maxBatchTextures`)
113
- * @param {number} [version=0] - the source revision being uploaded
123
+ * @ignore
124
+ */
125
+ releaseNormalUnit(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap): void;
126
+ /**
127
+ * Resolve a normal-map source to its slot in the shared pool, uploading and
128
+ * binding it if it is not already resident.
129
+ *
130
+ * A version-only bump (an animated source re-baking into the same canvas
131
+ * reference) re-uploads into the same GL handle and needs no flush —
132
+ * `version` only changes between frames, and the batch is flushed at every
133
+ * frame/camera boundary, so no in-flight vertex references stale content.
134
+ * A DIFFERENT source landing on a live slot does need the pending vertices
135
+ * drawn first.
136
+ * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} normalMap - the source
137
+ * @returns {number} the slot to write into `aNormalTextureId`
138
+ * @ignore
114
139
  */
115
- uploadNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, unit: number, version?: number): void;
140
+ resolveNormalUnit(normalMap: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap): number;
116
141
  /**
117
142
  * Add a textured quad with optional paired normal map.
118
143
  * @param {TextureAtlas} texture - Source texture atlas
@@ -131,5 +156,7 @@ export default class LitQuadBatcher extends QuadBatcher {
131
156
  addQuad(texture: TextureAtlas, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number, reupload?: boolean, normalMap?: HTMLImageElement | HTMLCanvasElement | null): void;
132
157
  }
133
158
  import QuadBatcher from "./quad_batcher.js";
159
+ import { WebGLTextureStore } from "../texture/store.js";
160
+ import UniformBlock from "../buffer/uniformblock.js";
134
161
  import type { TextureAtlas } from "./../../texture/atlas.js";
135
162
  //# sourceMappingURL=lit_quad_batcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lit_quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/lit_quad_batcher.js"],"names":[],"mappings":"AAMA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AACH;IAsEE;;;;;;OAMG;IACH,6GAAmD;IAEnD;;;;;;;OAOG;IACH,0CAAqD;IAErD;;;;;;;;OAQG;IACH;aAHoF,YAAY;iBAAW,MAAM;mBAG/E;IAElC,gCAAoB;IACpB,+BAA4B;IAQ3B,kEAEC;IAiCD,0CAAgC;IAoBlC;;;;;OAKG;IACH,sBAFW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAcxE;IAED;;;;;OAKG;IACH,2BAOC;IA4DD;;;;;;;;;;;;;;OAcG;IACH,2BANG;QAA+B,SAAS,EAAhC,YAAY;QACW,MAAM,EAA7B,YAAY;QACY,OAAO;QACd,KAAK,EAAtB,MAAM;QACc,OAAO;KACrC,QAgBA;IAED;;;;;;;;;OASG;IACH,qBAHW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAC9D,MAAM,QAiBhB;IAED;;;;;;;;;;;OAWG;IACH,uBAJW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAC9D,MAAM,YACN,MAAM,QAwBhB;IAED;;;;;;;;;;;;;;OAcG;IACH,iBAbW,YAAY,KACZ,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,cACP,gBAAgB,GAAC,iBAAiB,GAAC,IAAI,QAwIjD;CA8DD;wBA1kBoC,mBAAmB;kCAIzB,0BAA0B"}
1
+ {"version":3,"file":"lit_quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/lit_quad_batcher.js"],"names":[],"mappings":"AAcA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AACH;IA8DE;;;;;;OAMG;IACH,6GAAiD;IAEjD;;;;;;;OAOG;IACH,0CAAmD;IAmBnD,2CAAiD;IAEjD;;;;;;;OAOG;IACH,2GAA4B;IAC5B,iBAAoB;IAEpB,gCAAoB;IACpB,+BAA4B;IAkB5B,qCAIC;IACD,wBAA8B;IAW7B,kEAEC;IAoCH;;;;;;;;;;;;;OAaG;IACH,wBAQC;IAED;;;;;OAKG;IACH,sBAFW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAaxE;IA8ED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,2BANG;QAA+B,SAAS,EAAhC,YAAY;QACW,MAAM,EAA7B,YAAY;QACY,OAAO;QACd,KAAK,EAAtB,MAAM;QACc,OAAO;KACrC,QAMA;IAED;;;;;;;;;OASG;IACH,qBAHW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAC9D,MAAM,QAqChB;IAED;;;;;;;;;OASG;IACH,yBAHW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAaxE;IAED;;;;;;;;;;;;;OAaG;IACH,6BAJW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,GAC5D,MAAM,CAsClB;IAED;;;;;;;;;;;;;;OAcG;IACH,iBAbW,YAAY,KACZ,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,cACP,gBAAgB,GAAC,iBAAiB,GAAC,IAAI,QAsIjD;CA+DD;wBA3qBuB,mBAAmB;kCADT,qBAAqB;yBAT9B,2BAA2B;kCAcrB,0BAA0B"}
@@ -1,13 +1,9 @@
1
- /**
2
- * additional import for TypeScript
3
- * @import {TextureAtlas} from "./../../texture/atlas.js";
4
- */
5
- /**
6
- * Base class for batchers that manage WebGL textures and material properties.
7
- * Provides texture creation, binding, uploading, and deletion.
8
- * @category Rendering
9
- */
10
- export class MaterialBatcher extends Batcher {
1
+ export class MaterialBatcher extends WebGLBatcher {
2
+ /**
3
+ * Initialize the textured batcher
4
+ * @ignore
5
+ */
6
+ init(renderer: any, settings: any): void;
11
7
  set currentTextureUnit(unit: number);
12
8
  /**
13
9
  * The GL texture unit currently active (`gl.activeTexture`). Tracked on
@@ -27,6 +23,17 @@ export class MaterialBatcher extends Batcher {
27
23
  * @ignore
28
24
  */
29
25
  boundTextures: any[] | undefined;
26
+ /**
27
+ * Units whose texture CONTENT changed since the last upload (a
28
+ * canvas re-bake announced via `CanvasRenderTarget.invalidate`).
29
+ * Consumed by {@link MaterialBatcher#uploadTexture}, which then
30
+ * re-uploads INTO the existing texture — with immutable storage a
31
+ * same-shape re-upload is a pure `texSubImage2D`, so a ticking
32
+ * Text / gradient re-bake never re-allocates.
33
+ * @type {Set<number>}
34
+ * @ignore
35
+ */
36
+ dirtyUnits: Set<number> | undefined;
30
37
  _onCacheReset: (() => void) | null | undefined;
31
38
  /**
32
39
  * Drop every cached texture binding after a {@link GPU_TEXTURE_CACHE_RESET}
@@ -37,14 +44,6 @@ export class MaterialBatcher extends Batcher {
37
44
  * @ignore
38
45
  */
39
46
  _onTextureCacheReset(): void;
40
- /**
41
- * Free resources used by the batcher. Currently unsubscribes the
42
- * texture-cache-reset listener so a discarded batcher doesn't keep
43
- * accumulating handlers (relevant on context loss / renderer
44
- * teardown).
45
- * @ignore
46
- */
47
- destroy(): void;
48
47
  /**
49
48
  * Create a WebGL texture from an image
50
49
  * @param {number} unit - Destination texture unit
@@ -81,7 +80,17 @@ export class MaterialBatcher extends Batcher {
81
80
  * @param {number} [unit] - Texture unit to unbind from
82
81
  * @returns {number} unit the unit number that was associated with the given texture
83
82
  */
84
- unbindTexture2D(texture?: WebGLTexture, unit?: number): number;
83
+ /**
84
+ * Announce that the SOURCE content behind `unit` changed (same object,
85
+ * new pixels — a canvas re-bake): the next {@link MaterialBatcher#uploadTexture}
86
+ * for it re-uploads into the existing texture in place instead of
87
+ * discarding it. The allocation-preserving counterpart of
88
+ * {@link MaterialBatcher#unbindTexture2D}.
89
+ * @param {number} unit - the texture unit whose content is stale
90
+ * @ignore
91
+ */
92
+ markTextureDirty(unit: number): void;
93
+ unbindTexture2D(texture: any, unit: any): any;
85
94
  /**
86
95
  * Forget whatever texture this batcher believes is bound to `unit`, so the
87
96
  * next bind to it re-issues the GL bind. Used when a GL texture unit is
@@ -112,6 +121,6 @@ export class MaterialBatcher extends Batcher {
112
121
  */
113
122
  uploadTexture(texture: TextureAtlas | TextureResource, w?: number, h?: number, force?: boolean, flush?: boolean, repeat?: string): any;
114
123
  }
115
- import { Batcher } from "./batcher.js";
124
+ import { WebGLBatcher } from "./batcher.js";
116
125
  import type { TextureAtlas } from "./../../texture/atlas.js";
117
126
  //# sourceMappingURL=material_batcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"material_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/material_batcher.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;;GAIG;AACH;IA6EC,6BAPU,MAAM,EASf;IAlBD;;;;;;;;;;;OAWG;IACH,0BAHU,MAAM,CAKf;IA/DA;;;OAGG;IACH,iCAAuB;IAwBtB,+CAEC;IAKH;;;;;;;OAOG;IACH,6BAIC;IAsBD;;;;;;OAMG;IACH,gBAKC;IAmBD;;;;;;;;;;;OAWG;IACH,sBAVW,MAAM,WACN,8DAAM,iBAAiB,GAAC,SAAS,GAAC,UAAU,EAAE,GAAC,YAAY,EAAE,UAC7D,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,uBACN,OAAO,WACP,OAAO,kCACL,YAAY,CAmKxB;IAED;;;OAGG;IACH,yBAFW,YAAY,GAAC,YAAY,QAgCnC;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,YAAY,CAIxB;IAED;;;;OAIG;IACH,uBAHW,YAAY,QACZ,MAAM,yBAsBhB;IAED;;;;;OAKG;IACH,0BAJW,YAAY,SACZ,MAAM,GACJ,MAAM,CAalB;IAED;;;;;;;;;;;OAWG;IACH,qBAHW,MAAM,QAQhB;IAED;;;;;;;;;;;;;;OAcG;IACH,uBAbW,YAAY,GAAC,eAAe,MAC5B,MAAM,MAGN,MAAM,UACN,OAAO,UACP,OAAO,WACP,MAAM,OAsDhB;CACD;wBAzduB,cAAc;kCAIP,0BAA0B"}
1
+ {"version":3,"file":"material_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/material_batcher.js"],"names":[],"mappings":"AAgCA;IACC;;;OAGG;IACH,yCAoDC;IAiCD,6BAPU,MAAM,EASf;IAlBD;;;;;;;;;;;OAWG;IACH,0BAHU,MAAM,CAKf;IA5EA;;;OAGG;IACH,iCAAuB;IAEvB;;;;;;;;;OASG;IACH,oCAA2B;IAwB1B,+CAEC;IAKH;;;;;;;OAOG;IACH,6BAKC;IAsDD;;;;;;;;;;;OAWG;IACH,sBAVW,MAAM,WACN,8DAAM,iBAAiB,GAAC,SAAS,GAAC,UAAU,EAAE,GAAC,YAAY,EAAE,UAC7D,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,uBACN,OAAO,WACP,OAAO,kCACL,YAAY,CAoKxB;IAED;;;OAGG;IACH,yBAFW,YAAY,GAAC,YAAY,QAuCnC;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,YAAY,CAIxB;IAED;;;;OAIG;IACH,uBAHW,YAAY,QACZ,MAAM,yBAsBhB;IAED;;;;;OAKG;IACH;;;;;;;;OAQG;IACH,uBAHW,MAAM,QAKhB;IAED,8CAWC;IAED;;;;;;;;;;;OAWG;IACH,qBAHW,MAAM,QAQhB;IAED;;;;;;;;;;;;;;OAcG;IACH,uBAbW,YAAY,GAAC,eAAe,MAC5B,MAAM,MAGN,MAAM,UACN,OAAO,UACP,OAAO,WACP,MAAM,OA2GhB;CACD;6BApkB4B,cAAc;kCAIZ,0BAA0B"}