melonjs 19.9.1 → 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 (274) 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/const.d.ts +55 -26
  12. package/build/const.d.ts.map +1 -1
  13. package/build/geometries/box3d.d.ts +156 -0
  14. package/build/geometries/box3d.d.ts.map +1 -0
  15. package/build/index.d.ts +33 -23
  16. package/build/index.d.ts.map +1 -1
  17. package/build/index.js +21839 -8025
  18. package/build/index.js.map +4 -4
  19. package/build/lang/deprecated.d.ts +4 -4
  20. package/build/lang/deprecated.d.ts.map +1 -1
  21. package/build/level/gltf/GLTFModel.d.ts +4 -0
  22. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  23. package/build/level/gltf/GLTFScene.d.ts +42 -6
  24. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  25. package/build/level/gltf/srgb.d.ts +20 -0
  26. package/build/level/gltf/srgb.d.ts.map +1 -0
  27. package/build/level/level.d.ts +21 -2
  28. package/build/level/level.d.ts.map +1 -1
  29. package/build/lighting/light3d.d.ts +61 -13
  30. package/build/lighting/light3d.d.ts.map +1 -1
  31. package/build/loader/loader.d.ts +49 -21
  32. package/build/loader/loader.d.ts.map +1 -1
  33. package/build/loader/parsers/gltf.d.ts.map +1 -1
  34. package/build/loader/parsers/mtl.d.ts +18 -0
  35. package/build/loader/parsers/mtl.d.ts.map +1 -1
  36. package/build/loader/parsers/obj.d.ts +49 -0
  37. package/build/loader/parsers/obj.d.ts.map +1 -1
  38. package/build/loader/parsers/pbr.d.ts +63 -0
  39. package/build/loader/parsers/pbr.d.ts.map +1 -0
  40. package/build/loader/parsers/shader.d.ts +32 -24
  41. package/build/loader/parsers/shader.d.ts.map +1 -1
  42. package/build/physics/adapter.d.ts +12 -1
  43. package/build/physics/adapter.d.ts.map +1 -1
  44. package/build/physics/broadphase/octree.d.ts +35 -0
  45. package/build/physics/broadphase/octree.d.ts.map +1 -1
  46. package/build/physics/builtin/body.d.ts +123 -6
  47. package/build/physics/builtin/body.d.ts.map +1 -1
  48. package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
  49. package/build/physics/builtin/detector.d.ts +12 -0
  50. package/build/physics/builtin/detector.d.ts.map +1 -1
  51. package/build/physics/builtin/raycast.d.ts.map +1 -1
  52. package/build/physics/builtin/sat3d.d.ts +59 -0
  53. package/build/physics/builtin/sat3d.d.ts.map +1 -0
  54. package/build/physics/response.d.ts +32 -0
  55. package/build/physics/response.d.ts.map +1 -1
  56. package/build/physics/world.d.ts +1 -0
  57. package/build/physics/world.d.ts.map +1 -1
  58. package/build/renderable/container.d.ts +1 -0
  59. package/build/renderable/container.d.ts.map +1 -1
  60. package/build/renderable/groundshadow.d.ts +92 -0
  61. package/build/renderable/groundshadow.d.ts.map +1 -0
  62. package/build/renderable/instanced_mesh.d.ts +286 -0
  63. package/build/renderable/instanced_mesh.d.ts.map +1 -0
  64. package/build/renderable/mesh.d.ts +242 -23
  65. package/build/renderable/mesh.d.ts.map +1 -1
  66. package/build/renderable/renderable.d.ts +6 -4
  67. package/build/renderable/renderable.d.ts.map +1 -1
  68. package/build/renderable/sprite3d.d.ts +17 -6
  69. package/build/renderable/sprite3d.d.ts.map +1 -1
  70. package/build/renderable/text/text.d.ts.map +1 -1
  71. package/build/system/device.d.ts +11 -40
  72. package/build/system/device.d.ts.map +1 -1
  73. package/build/system/platform.d.ts +0 -16
  74. package/build/system/platform.d.ts.map +1 -1
  75. package/build/utils/utils.d.ts +2 -0
  76. package/build/utils/utils.d.ts.map +1 -1
  77. package/build/video/canvas/canvas_renderer.d.ts +22 -16
  78. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  79. package/build/video/{webgl/effects → effects}/blur.d.ts +2 -2
  80. package/build/video/effects/blur.d.ts.map +1 -0
  81. package/build/video/{webgl/effects → effects}/chromaticAberration.d.ts +2 -2
  82. package/build/video/effects/chromaticAberration.d.ts.map +1 -0
  83. package/build/video/{webgl/effects → effects}/colorMatrix.d.ts +3 -3
  84. package/build/video/effects/colorMatrix.d.ts.map +1 -0
  85. package/build/video/{webgl/effects → effects}/desaturate.d.ts +1 -1
  86. package/build/video/effects/desaturate.d.ts.map +1 -0
  87. package/build/video/{webgl/effects → effects}/dissolve.d.ts +2 -2
  88. package/build/video/effects/dissolve.d.ts.map +1 -0
  89. package/build/video/{webgl/effects → effects}/dropShadow.d.ts +2 -2
  90. package/build/video/effects/dropShadow.d.ts.map +1 -0
  91. package/build/video/{webgl/effects → effects}/flash.d.ts +2 -2
  92. package/build/video/effects/flash.d.ts.map +1 -0
  93. package/build/video/{webgl/effects → effects}/glow.d.ts +2 -2
  94. package/build/video/effects/glow.d.ts.map +1 -0
  95. package/build/video/effects/glsl_realization.d.ts +18 -0
  96. package/build/video/effects/glsl_realization.d.ts.map +1 -0
  97. package/build/video/{webgl/effects → effects}/hologram.d.ts +2 -2
  98. package/build/video/effects/hologram.d.ts.map +1 -0
  99. package/build/video/{webgl/effects → effects}/invert.d.ts +1 -1
  100. package/build/video/effects/invert.d.ts.map +1 -0
  101. package/build/video/{webgl/effects → effects}/outline.d.ts +2 -2
  102. package/build/video/effects/outline.d.ts.map +1 -0
  103. package/build/video/{webgl/effects → effects}/pixelate.d.ts +2 -2
  104. package/build/video/effects/pixelate.d.ts.map +1 -0
  105. package/build/video/{webgl/effects → effects}/radialGradient.d.ts +3 -4
  106. package/build/video/effects/radialGradient.d.ts.map +1 -0
  107. package/build/video/{webgl/effects → effects}/scanline.d.ts +2 -2
  108. package/build/video/effects/scanline.d.ts.map +1 -0
  109. package/build/video/{webgl/effects → effects}/sepia.d.ts +1 -1
  110. package/build/video/effects/sepia.d.ts.map +1 -0
  111. package/build/video/{webgl → effects}/shadereffect.d.ts +133 -25
  112. package/build/video/effects/shadereffect.d.ts.map +1 -0
  113. package/build/video/{webgl/effects → effects}/shine.d.ts +2 -2
  114. package/build/video/effects/shine.d.ts.map +1 -0
  115. package/build/video/{webgl/effects → effects}/tintPulse.d.ts +2 -2
  116. package/build/video/effects/tintPulse.d.ts.map +1 -0
  117. package/build/video/{webgl/effects → effects}/vignette.d.ts +2 -2
  118. package/build/video/effects/vignette.d.ts.map +1 -0
  119. package/build/video/{webgl/effects → effects}/wave.d.ts +2 -2
  120. package/build/video/effects/wave.d.ts.map +1 -0
  121. package/build/video/effects/wgsl/layout.d.ts +28 -0
  122. package/build/video/effects/wgsl/layout.d.ts.map +1 -0
  123. package/build/video/effects/wgsl/parse.d.ts +9 -0
  124. package/build/video/effects/wgsl/parse.d.ts.map +1 -0
  125. package/build/video/effects/wgsl/scaffold.d.ts +43 -0
  126. package/build/video/effects/wgsl/scaffold.d.ts.map +1 -0
  127. package/build/video/effects/wgsl_realization.d.ts +83 -0
  128. package/build/video/effects/wgsl_realization.d.ts.map +1 -0
  129. package/build/video/gpu/batcher.d.ts +71 -0
  130. package/build/video/gpu/batcher.d.ts.map +1 -0
  131. package/build/video/gpu/instancerecord.d.ts +164 -0
  132. package/build/video/gpu/instancerecord.d.ts.map +1 -0
  133. package/build/video/gpu/meshchunk.d.ts +49 -0
  134. package/build/video/gpu/meshchunk.d.ts.map +1 -0
  135. package/build/video/gpu/meshvertex.d.ts +54 -0
  136. package/build/video/gpu/meshvertex.d.ts.map +1 -0
  137. package/build/video/gpu/primitives.d.ts +60 -0
  138. package/build/video/gpu/primitives.d.ts.map +1 -0
  139. package/build/video/gpu/quadcorners.d.ts +11 -0
  140. package/build/video/gpu/quadcorners.d.ts.map +1 -0
  141. package/build/video/gpu/textureslots.d.ts +122 -0
  142. package/build/video/gpu/textureslots.d.ts.map +1 -0
  143. package/build/video/gpu/texturestore.d.ts +139 -0
  144. package/build/video/gpu/texturestore.d.ts.map +1 -0
  145. package/build/video/gpu/topology.d.ts +43 -0
  146. package/build/video/gpu/topology.d.ts.map +1 -0
  147. package/build/video/gpu/vertexformat.d.ts +72 -0
  148. package/build/video/gpu/vertexformat.d.ts.map +1 -0
  149. package/build/video/gradient.d.ts +14 -5
  150. package/build/video/gradient.d.ts.map +1 -1
  151. package/build/video/renderer.d.ts +153 -8
  152. package/build/video/renderer.d.ts.map +1 -1
  153. package/build/video/rendertarget/canvasrendertarget.d.ts +7 -6
  154. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  155. package/build/video/rendertarget/render_target_pool.d.ts +2 -2
  156. package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
  157. package/build/video/rendertarget/webglrendertarget.d.ts +38 -2
  158. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  159. package/build/video/rendertarget/webgpurendertarget.d.ts +83 -0
  160. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -0
  161. package/build/video/texture/atlas.d.ts.map +1 -1
  162. package/build/video/texture/cache.d.ts +20 -2
  163. package/build/video/texture/cache.d.ts.map +1 -1
  164. package/build/video/texture/noise_texture2d.d.ts +2 -2
  165. package/build/video/utils/autodetect.d.ts.map +1 -1
  166. package/build/video/video.d.ts +1 -55
  167. package/build/video/video.d.ts.map +1 -1
  168. package/build/video/webgl/batchers/batcher.d.ts +132 -35
  169. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  170. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +14 -0
  171. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
  172. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +63 -36
  173. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  174. package/build/video/webgl/batchers/material_batcher.d.ts +29 -20
  175. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  176. package/build/video/webgl/batchers/mesh_batcher.d.ts +308 -14
  177. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  178. package/build/video/webgl/batchers/primitive_batcher.d.ts +2 -2
  179. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  180. package/build/video/webgl/batchers/quad_batcher.d.ts +0 -2
  181. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  182. package/build/video/webgl/buffer/index.d.ts +1 -1
  183. package/build/video/webgl/buffer/instance_buffer.d.ts +54 -0
  184. package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -0
  185. package/build/video/webgl/buffer/retained_geometry.d.ts +83 -0
  186. package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -0
  187. package/build/video/webgl/buffer/uniformblock.d.ts +81 -0
  188. package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -0
  189. package/build/video/webgl/buffer/vertexstate.d.ts +101 -0
  190. package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -0
  191. package/build/video/webgl/glshader.d.ts +101 -8
  192. package/build/video/webgl/glshader.d.ts.map +1 -1
  193. package/build/video/webgl/lighting/constants.d.ts +20 -8
  194. package/build/video/webgl/lighting/constants.d.ts.map +1 -1
  195. package/build/video/webgl/lighting/pack.d.ts +1 -1
  196. package/build/video/webgl/lighting/pack3d.d.ts +27 -11
  197. package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
  198. package/build/video/webgl/lighting/std140.d.ts +110 -0
  199. package/build/video/webgl/lighting/std140.d.ts.map +1 -0
  200. package/build/video/webgl/shaders/multitexture-lit.d.ts +7 -3
  201. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  202. package/build/video/webgl/texture/store.d.ts +52 -0
  203. package/build/video/webgl/texture/store.d.ts.map +1 -0
  204. package/build/video/webgl/utils/maxtextures.d.ts +37 -0
  205. package/build/video/webgl/utils/maxtextures.d.ts.map +1 -0
  206. package/build/video/webgl/utils/samplercache.d.ts +69 -0
  207. package/build/video/webgl/utils/samplercache.d.ts.map +1 -0
  208. package/build/video/webgl/utils/string.d.ts +16 -0
  209. package/build/video/webgl/utils/string.d.ts.map +1 -1
  210. package/build/video/webgl/utils/topology.d.ts +24 -0
  211. package/build/video/webgl/utils/topology.d.ts.map +1 -0
  212. package/build/video/webgl/utils/vertexformat.d.ts +27 -0
  213. package/build/video/webgl/utils/vertexformat.d.ts.map +1 -0
  214. package/build/video/webgl/webgl_renderer.d.ts +148 -30
  215. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  216. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +40 -0
  217. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -0
  218. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +82 -0
  219. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -0
  220. package/build/video/webgpu/batchers/mesh_batcher.d.ts +301 -0
  221. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -0
  222. package/build/video/webgpu/batchers/primitive_batcher.d.ts +39 -0
  223. package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -0
  224. package/build/video/webgpu/batchers/quad_batcher.d.ts +143 -0
  225. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -0
  226. package/build/video/webgpu/batchers/webgpu_batcher.d.ts +70 -0
  227. package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -0
  228. package/build/video/webgpu/buffer/arena.d.ts +64 -0
  229. package/build/video/webgpu/buffer/arena.d.ts.map +1 -0
  230. package/build/video/webgpu/buffer/instance_buffer.d.ts +65 -0
  231. package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -0
  232. package/build/video/webgpu/buffer/retained_geometry.d.ts +55 -0
  233. package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -0
  234. package/build/video/webgpu/buffer/uniformring.d.ts +68 -0
  235. package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -0
  236. package/build/video/webgpu/effect_binding.d.ts +17 -0
  237. package/build/video/webgpu/effect_binding.d.ts.map +1 -0
  238. package/build/video/webgpu/pipeline/bindgroups.d.ts +36 -0
  239. package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -0
  240. package/build/video/webgpu/pipeline/cache.d.ts +173 -0
  241. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -0
  242. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +90 -0
  243. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -0
  244. package/build/video/webgpu/shaders/mesh-instanced.d.ts +60 -0
  245. package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -0
  246. package/build/video/webgpu/texture/compressed.d.ts +33 -0
  247. package/build/video/webgpu/texture/compressed.d.ts.map +1 -0
  248. package/build/video/webgpu/texture/frametexture.d.ts +65 -0
  249. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -0
  250. package/build/video/webgpu/texture/store.d.ts +149 -0
  251. package/build/video/webgpu/texture/store.d.ts.map +1 -0
  252. package/build/video/webgpu/webgpu_renderer.d.ts +536 -0
  253. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -0
  254. package/package.json +2 -2
  255. package/build/video/webgl/effects/blur.d.ts.map +0 -1
  256. package/build/video/webgl/effects/chromaticAberration.d.ts.map +0 -1
  257. package/build/video/webgl/effects/colorMatrix.d.ts.map +0 -1
  258. package/build/video/webgl/effects/desaturate.d.ts.map +0 -1
  259. package/build/video/webgl/effects/dissolve.d.ts.map +0 -1
  260. package/build/video/webgl/effects/dropShadow.d.ts.map +0 -1
  261. package/build/video/webgl/effects/flash.d.ts.map +0 -1
  262. package/build/video/webgl/effects/glow.d.ts.map +0 -1
  263. package/build/video/webgl/effects/hologram.d.ts.map +0 -1
  264. package/build/video/webgl/effects/invert.d.ts.map +0 -1
  265. package/build/video/webgl/effects/outline.d.ts.map +0 -1
  266. package/build/video/webgl/effects/pixelate.d.ts.map +0 -1
  267. package/build/video/webgl/effects/radialGradient.d.ts.map +0 -1
  268. package/build/video/webgl/effects/scanline.d.ts.map +0 -1
  269. package/build/video/webgl/effects/sepia.d.ts.map +0 -1
  270. package/build/video/webgl/effects/shine.d.ts.map +0 -1
  271. package/build/video/webgl/effects/tintPulse.d.ts.map +0 -1
  272. package/build/video/webgl/effects/vignette.d.ts.map +0 -1
  273. package/build/video/webgl/effects/wave.d.ts.map +0 -1
  274. package/build/video/webgl/shadereffect.d.ts.map +0 -1
@@ -5,10 +5,14 @@
5
5
  * Owns mesh-mode GL state ownership (since 19.7 / #1468):
6
6
  *
7
7
  * - {@link MeshBatcher#bind} enters mesh mode — enables `DEPTH_TEST` +
8
- * `LEQUAL` + `depthMask`, disables `BLEND`, and runs a one-shot
9
- * `clearDepth(1.0) + clear(DEPTH_BUFFER_BIT)` if the active target's
10
- * depth attachment is still dirty. Subsequent mesh draws against the
11
- * same target rely on the accumulated depth buffer.
8
+ * `LEQUAL` + `depthMask`, disables `BLEND`.
9
+ * - {@link MeshBatcher#updatePassState} runs the one-shot
10
+ * `clearDepth(1.0) + clear(DEPTH_BUFFER_BIT)` when the active target's
11
+ * depth attachment is still dirty, immediately before a draw rather than
12
+ * on entry — `bind()` fires on a batcher *transition*, not once a frame,
13
+ * so a scene made only of meshes would otherwise never clear again after
14
+ * its first frame. Subsequent draws against the same target rely on the
15
+ * accumulated depth buffer.
12
16
  * - {@link MeshBatcher#unbind} exits mesh mode — restores non-mesh
13
17
  * defaults (`BLEND` on, `DEPTH_TEST` off, `depthMask` false) that the
14
18
  * 2D rendering paths assume.
@@ -18,7 +22,8 @@
18
22
  * framebuffer's attachments change identity.
19
23
  *
20
24
  * The WebGLRenderer doesn't know any of this — `setBatcher("mesh")` calls
21
- * `bind()` and the batcher sets up its own pass. Same lifecycle ports
25
+ * `bind()` and the batcher sets up its own pass, refreshing whatever is
26
+ * per-draw as it goes. Same lifecycle ports
22
27
  * cleanly to a future WebGPU renderer: `bind()` becomes "begin a
23
28
  * depth-enabled `RenderPassEncoder`", `unbind()` ends it.
24
29
  * @category Rendering
@@ -33,6 +38,23 @@ export default class MeshBatcher extends MaterialBatcher {
33
38
  currentEmissiveR: any;
34
39
  currentEmissiveG: any;
35
40
  currentEmissiveB: any;
41
+ currentShininess: any;
42
+ currentSpecularR: any;
43
+ currentSpecularG: any;
44
+ currentSpecularB: any;
45
+ currentAlphaMapUnit: any;
46
+ currentHasAlphaMap: any;
47
+ currentEyeX: any;
48
+ currentEyeY: any;
49
+ currentEyeZ: any;
50
+ retained: Map<any, any> | undefined;
51
+ instanced: Map<any, any> | undefined;
52
+ instancedShaders: Map<any, any> | undefined;
53
+ shadowShader: GLShader | undefined;
54
+ currentTintValue: any;
55
+ trilinearTextures: WeakSet<object> | undefined;
56
+ anisotropicExt: any;
57
+ maxAnisotropy: number | undefined;
36
58
  _onTargetChanged: ((emitter: any) => void) | null | undefined;
37
59
  /**
38
60
  * The vertex attribute layout. The base (unlit) mesh batcher is
@@ -40,11 +62,9 @@ export default class MeshBatcher extends MaterialBatcher {
40
62
  * (e.g. {@link LitMeshBatcher}) append their own attributes.
41
63
  * @ignore
42
64
  */
43
- _attributeLayout(renderer: any): {
65
+ _attributeLayout(_renderer: any): {
44
66
  name: string;
45
- size: number;
46
- type: any;
47
- normalized: boolean;
67
+ format: string;
48
68
  offset: number;
49
69
  }[];
50
70
  /**
@@ -67,6 +87,31 @@ export default class MeshBatcher extends MaterialBatcher {
67
87
  * @ignore
68
88
  */
69
89
  useShader(shader: any): void;
90
+ /**
91
+ * Refresh pass-scoped state, immediately before a draw.
92
+ *
93
+ * This exists because `bind()` is *not* a per-frame hook. `setBatcher`
94
+ * returns early when the requested batcher is already current, so a scene
95
+ * that draws nothing but meshes — no sprites, no UI, no unlit geometry to
96
+ * force a switch — binds once and never again. Anything set up in `bind()`
97
+ * then freezes at its first-frame value.
98
+ *
99
+ * The depth clear is one such thing. `renderer._meshDepthDirty` is re-armed
100
+ * every time the render target changes (frame-start `clear()`, FBO
101
+ * bind/unbind), but a flag nobody reads is a flag that does nothing: left in
102
+ * `bind()` it would stay armed forever and the depth attachment would carry
103
+ * the first frame's values for the life of the scene, occluding geometry as
104
+ * the camera moved. Consuming it here runs the clear once per target, which
105
+ * is what the flag always meant. {@link LitMeshBatcher} extends this with
106
+ * its light data, which had the same problem.
107
+ *
108
+ * Cheap by construction: one boolean test per draw in the common case.
109
+ * `depthMask` is guaranteed true here — `bind()` sets it and only `unbind()`
110
+ * clears it, so this batcher being current implies a writable depth buffer,
111
+ * without which `gl.clear(DEPTH_BUFFER_BIT)` would silently do nothing.
112
+ * @ignore
113
+ */
114
+ updatePassState(): void;
70
115
  /**
71
116
  * Write one vertex into the buffer. The base (unlit) layout is
72
117
  * `x, y, z, u, v, color`. Subclasses override to append per-vertex data
@@ -92,14 +137,263 @@ export default class MeshBatcher extends MaterialBatcher {
92
137
  * no extra draw calls per material vs single-material (large
93
138
  * meshes still get chunked across multiple flushes to fit the
94
139
  * vertex/index buffer limits — same behavior as single-material).
95
- * The shared `tint` is then multiplied into each vertex color
96
- * CPU-side (via `mulPackedARGB`, before `pushMesh`), preserving
97
- * runtime flash / fade / team-color effects — the mesh shader
98
- * itself just does `texture * aColor`, no extra uniform.
140
+ * The runtime `tint` is applied by the shader through the `uTint`
141
+ * uniform rather than being multiplied into each vertex color, so
142
+ * flash / fade / team-color effects never touch vertex data.
99
143
  * @param {object} mesh - a Mesh object with vertices, uvs, indices, and texture properties
100
144
  * @param {number} tint - tint color in UINT32 (argb) format
101
145
  */
102
- addMesh(mesh: object, tint: number): void;
146
+ /**
147
+ * Issue the per-draw placement uniforms: where the geometry sits
148
+ * (`uModelMatrix`), where the camera is (`uViewMatrix`), and the colour
149
+ * it is tinted with (`uTint`).
150
+ *
151
+ * Keeping these as uniforms rather than baking them into vertex data is
152
+ * what lets geometry be uploaded once and reused: moving, rotating,
153
+ * scaling or re-tinting a mesh changes only these values.
154
+ *
155
+ * Each set is guarded on the uniform actually being declared, because
156
+ * `GLShader.setUniform` throws on an unknown name and a custom mesh
157
+ * shader need not declare all of them.
158
+ * @param {Matrix3d} modelMatrix - the mesh's own placement, or identity when its vertices are already positioned
159
+ * @param {number} tint - tint colour in UINT32 (argb) format
160
+ * @ignore
161
+ */
162
+ /**
163
+ * Write one mesh's model-space geometry into `out` in this batcher's
164
+ * vertex layout, returning how many floats were written.
165
+ *
166
+ * The data deliberately carries no placement, camera or tint information
167
+ * — those are uniforms — so it stays valid for the lifetime of the
168
+ * geometry. Subclasses override to append their own per-vertex data.
169
+ * @param {object} mesh - the mesh to read geometry from
170
+ * @param {Float32Array} out - destination scratch, at least `vertexCount × vertexSize` long
171
+ * @returns {number} number of floats written
172
+ * @ignore
173
+ */
174
+ buildRetainedVertexData(mesh: object, out: Float32Array): number;
175
+ /**
176
+ * Get this mesh's retained geometry, building or refreshing it when the
177
+ * mesh's geometry version has moved on.
178
+ * @param {object} mesh - the mesh whose geometry is wanted
179
+ * @returns {RetainedGeometry} up-to-date geometry for the mesh
180
+ * @ignore
181
+ */
182
+ retainedGeometryFor(mesh: object): RetainedGeometry;
183
+ /**
184
+ * Draw a mesh from its retained geometry: bind the persistent buffers and
185
+ * issue one indexed draw, with placement supplied entirely by uniforms.
186
+ *
187
+ * Unlike {@link addMesh} this accumulates nothing and never chunks — the
188
+ * whole mesh is one draw call regardless of size, except for a
189
+ * multi-material model whose materials carry different diffuse textures:
190
+ * that draws one indexed range per entry in {@link Mesh#textureGroups}
191
+ * (#1573), over the same buffers, with only the sampler moving between
192
+ * them.
193
+ * @param {object} mesh - the mesh to draw
194
+ * @param {Matrix3d} modelMatrix - where the mesh sits in the world
195
+ * @param {number} tint - tint colour in UINT32 (argb) format
196
+ * @ignore
197
+ */
198
+ drawRetainedMesh(mesh: object, modelMatrix: Matrix3d, tint: number): void;
199
+ /**
200
+ * Enter the blended mesh draw state: alpha blending on, depth test still
201
+ * on, depth WRITES off (#1515).
202
+ *
203
+ * The blend function is set explicitly rather than through
204
+ * `renderer.setBlendMode`. That method short-circuits when the mode is
205
+ * unchanged, and `MeshBatcher.bind()` has already disabled `GL_BLEND`
206
+ * behind that cache's back — so asking for the mode the cache already
207
+ * claims would leave blending off and the draw opaque. Merely calling
208
+ * `setBlendEnabled(true)` is no better: it inherits whatever function the
209
+ * last 2D draw left, and under `"additive"` a dark shadow would *brighten*
210
+ * the ground.
211
+ * @ignore
212
+ */
213
+ beginBlendedDraw(): void;
214
+ /**
215
+ * Leave the blended draw state, restoring mesh mode exactly as
216
+ * {@link MeshBatcher#bind} left it.
217
+ *
218
+ * The blend FUNCTION is put back too, not just the enable bit. This draw
219
+ * overwrote it without touching `renderer.currentBlendMode`, so a later 2D
220
+ * draw asking for the mode the cache already claims would short-circuit
221
+ * and silently inherit this one's function. Re-issuing through
222
+ * `setBlendMode` with the cache invalidated restores both, and leaves the
223
+ * cache reading exactly what it read before.
224
+ * @ignore
225
+ */
226
+ endBlendedDraw(): void;
227
+ /**
228
+ * Get (building or refreshing as needed) the GPU state one instanced mesh
229
+ * draws from: its retained prototype geometry, its instance buffer, and
230
+ * the vertex state binding the two together.
231
+ *
232
+ * The vertex state is rebuilt only when a buffer object it references is
233
+ * replaced — a growing instance set reallocates, a merely-edited one does
234
+ * not — because a vertex array holding a deleted buffer keeps it alive per
235
+ * the GL spec and silently draws stale data.
236
+ * @param {InstancedMesh} mesh - the mesh to draw
237
+ * @returns {object} `{geometry, instances, vertexState}`
238
+ * @ignore
239
+ */
240
+ instancedStateFor(mesh: InstancedMesh): object;
241
+ /**
242
+ * The instanced shader for a given record layout, compiled on first use.
243
+ *
244
+ * Variants are source permutations rather than runtime branches: the
245
+ * optional slots are `#ifdef`-guarded, so a mesh that declares neither
246
+ * costs no unused attributes and no dead code. `minify` deliberately
247
+ * preserves newlines so the directives survive it.
248
+ * @param {object} layout - the instance record layout
249
+ * @returns {GLShader} the shader for that combination
250
+ * @ignore
251
+ */
252
+ instancedShaderFor(layout: object): GLShader;
253
+ /**
254
+ * The instanced shader sources for this batcher (unlit by default).
255
+ * Subclasses override to supply the lit pair.
256
+ * @ignore
257
+ */
258
+ _instancedShaderSources(): {
259
+ vertex: any;
260
+ fragment: any;
261
+ };
262
+ /**
263
+ * Resolve an instance record layout into GL attribute records, in the
264
+ * `{name, size, type, normalized, offset}` shape the vertex state wants.
265
+ * Every slot is a `float32x4`.
266
+ * @param {object} layout - the instance record layout
267
+ * @returns {object[]} attribute records
268
+ * @ignore
269
+ */
270
+ _instanceAttributeRecords(layout: object): object[];
271
+ /**
272
+ * Draw every visible instance of a mesh in one call.
273
+ *
274
+ * The geometry is bound once and the GPU walks the instance buffer,
275
+ * advancing the per-instance attributes one record per copy. Placement of
276
+ * the *group* still rides the ordinary uniforms, so moving the whole set
277
+ * costs one matrix and re-uploads nothing.
278
+ * @param {InstancedMesh} mesh - the mesh to draw
279
+ * @param {Matrix3d} modelMatrix - where the group sits in the world
280
+ * @param {number} tint - tint colour in UINT32 (argb) format
281
+ * @ignore
282
+ */
283
+ drawInstancedMesh(mesh: InstancedMesh, modelMatrix: Matrix3d, tint: number): void;
284
+ _instancedShaderWarned: boolean | undefined;
285
+ /**
286
+ * The instanced ground-shadow program (#1515), compiled on first use.
287
+ *
288
+ * ONE shader, not a variant per record layout: it reads only the three
289
+ * transform rows, so `hasColor` / `hasData` make no difference to it —
290
+ * which is also what stops a forest with per-instance colour and emissive
291
+ * from getting coloured, glowing shadows.
292
+ * @returns {GLShader} the shadow program
293
+ * @ignore
294
+ */
295
+ instancedShadowShader(): GLShader;
296
+ /**
297
+ * The vertex state pairing the SHARED shadow quad's geometry with this
298
+ * mesh's own instance records.
299
+ *
300
+ * Kept in its own slot with its own staleness fields rather than reusing
301
+ * the main pass's: that one keys on `builtGeometry` and `builtShader`, and
302
+ * the shadow pass differs in both, so sharing a slot would make the two
303
+ * passes rebuild each other's vertex array on every single draw.
304
+ *
305
+ * The instance buffer itself IS shared — the main pass already uploaded
306
+ * it this frame, so this adds no upload.
307
+ * @param {InstancedMesh} mesh - the mesh casting the shadows
308
+ * @param {object} quadGeometry - the shared shadow quad's retained geometry
309
+ * @returns {object} the per-mesh instanced state, with `shadowVertexState` built
310
+ * @ignore
311
+ */
312
+ instancedShadowStateFor(mesh: InstancedMesh, quadGeometry: object): object;
313
+ /**
314
+ * Draw one flat blob per instance, in a single call, from the same
315
+ * instance buffer the mesh itself drew from (#1515).
316
+ * @param {InstancedMesh} mesh - the mesh casting the shadows
317
+ * @param {Matrix3d} shadowMatrix - the group matrix, flattened onto the ground
318
+ * @param {number} tint - tint colour in UINT32 (argb) format
319
+ * @param {object} quad - the shared shadow quad mesh
320
+ * @ignore
321
+ */
322
+ drawInstancedShadow(mesh: InstancedMesh, shadowMatrix: Matrix3d, tint: number, quad: object): void;
323
+ /**
324
+ * Release the instance buffer and vertex state held for one mesh, if any.
325
+ * @param {object} mesh - the mesh whose instance state should be freed
326
+ * @ignore
327
+ */
328
+ releaseInstanced(mesh: object): void;
329
+ /**
330
+ * Release every instance buffer this batcher holds.
331
+ * @ignore
332
+ */
333
+ releaseAllInstanced(): void;
334
+ /**
335
+ * Release the retained geometry held for one mesh, if any.
336
+ * @param {object} mesh - the mesh whose geometry should be freed
337
+ * @ignore
338
+ */
339
+ releaseRetained(mesh: object): void;
340
+ /**
341
+ * Release every retained geometry this batcher holds.
342
+ * @ignore
343
+ */
344
+ releaseAllRetained(): void;
345
+ /**
346
+ * In addition to the attribute-layout check, warn once when a shader
347
+ * hosted on this batcher declares none of the placement uniforms.
348
+ *
349
+ * Mesh geometry is now uploaded in model space, so a shader that only
350
+ * declares `uProjectionMatrix` — which is what every mesh shader needed
351
+ * before, and what {@link ShaderEffect} still generates — will draw the
352
+ * mesh at its untransformed origin with no camera applied. That renders
353
+ * as "the model vanished" rather than as an error, so say so explicitly.
354
+ * @param {GLShader} shader - the shader about to be hosted
355
+ * @ignore
356
+ */
357
+ validateShaderLocations(shader: GLShader): void;
358
+ setPlacementUniforms(modelMatrix: any, tint: any): void;
359
+ /**
360
+ * Bind a mesh's material state: its texture (honouring the mesh's own
361
+ * `textureRepeat` wrap override) and the guarded `uAlphaCutoff` /
362
+ * `uEmissive` uniforms.
363
+ *
364
+ * Shared by the accumulated and retained draw paths so material changes
365
+ * take effect immediately either way, without touching geometry.
366
+ * @param {object} mesh - the mesh whose material should be applied
367
+ * @param {TextureAtlas} [texture] - bind this texture instead of the mesh's
368
+ * own — how a multi-material model's per-material `map_Kd` reaches the
369
+ * sampler, one draw range at a time (#1573). Everything else here is a
370
+ * property of the mesh, not of the material group.
371
+ * @returns {number} the texture unit the material landed on
372
+ * @ignore
373
+ */
374
+ applyMeshMaterial(mesh: object, texture?: TextureAtlas): number;
375
+ /**
376
+ * Point `uSampler` at a texture unit, if it moved and if the current
377
+ * shader has a sampler at all — a custom mesh shader that never samples
378
+ * (vertex colours only) declares none, and `setUniform` throws on an
379
+ * unknown name.
380
+ * @param {number} unit - the texture unit to sample from
381
+ * @ignore
382
+ */
383
+ bindSamplerUnit(unit: number): void;
384
+ addMesh(mesh: any, tint: any): void;
385
+ /**
386
+ * Accumulate one index range of a mesh into the batch, chunking triangles
387
+ * across flushes as the vertex / index buffers fill.
388
+ * @param {object} mesh - a Mesh with vertices, uvs, indices, texture
389
+ * @param {number} from - first index to accumulate
390
+ * @param {number} length - how many indices to accumulate
391
+ * @ignore
392
+ */
393
+ accumulateRange(mesh: object, from: number, length: number): void;
103
394
  }
104
395
  import { MaterialBatcher } from "./material_batcher.js";
396
+ import GLShader from "../glshader.js";
397
+ import RetainedGeometry from "../buffer/retained_geometry.js";
398
+ import { Matrix3d } from "../../../math/matrix3d.ts";
105
399
  //# sourceMappingURL=mesh_batcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/mesh_batcher.js"],"names":[],"mappings":"AAyFA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;IACC;;;OAGG;IACH,0BAsCC;IA5BA,wBAA4B;IAI5B,sBAA0B;IAC1B,sBAA0B;IAC1B,sBAA0B;IAYzB,8DAOC;IAKH;;;;;OAKG;IACH;;;;;;QAgCC;IAED;;;;OAIG;IACH;;;MAEC;IAED;;;;;;;;;OASG;IACH,6BAWC;IAyDD;;;;;;;;;;;;;;;OAeG;IACH,wBAXW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,SACN,MAAM,SACN,MAAM,OACN,MAAM,QAKhB;IAED;;;;;;;;;;;;;;OAcG;IACH,cAHW,MAAM,QACN,MAAM,QA+JhB;CACD;gCA3d+B,uBAAuB"}
1
+ {"version":3,"file":"mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/mesh_batcher.js"],"names":[],"mappings":"AAqDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IACC;;;OAGG;IACH,0BAiHC;IAvGA,wBAA4B;IAI5B,sBAA0B;IAC1B,sBAA0B;IAC1B,sBAA0B;IAI1B,sBAA0B;IAC1B,sBAA0B;IAC1B,sBAA0B;IAC1B,sBAA0B;IAI1B,yBAA6B;IAC7B,wBAA4B;IAI5B,iBAA6B;IAC7B,iBAA6B;IAC7B,iBAA6B;IAQ7B,oCAAyB;IAQzB,qCAA0B;IAS1B,4CAAiC;IAQjC,mCAA6B;IAO7B,sBAAiC;IAKjC,+CAAsC;IAMtC,oBAAuE;IACvE,kCAKI;IAYH,8DAOC;IAKH;;;;;OAKG;IACH;;;;QA0BC;IAED;;;;OAIG;IACH;;;MAEC;IAED;;;;;;;;;OASG;IACH,6BAcC;IAgED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,wBAOC;IAcD;;;;;;;;;;;;;;;OAeG;IACH,wBAXW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,SACN,MAAM,SACN,MAAM,OACN,MAAM,QAKhB;IAED;;;;;;;;;;;;;OAaG;IACH;;;;;;;;;;;;;;;OAeG;IACH;;;;;;;;;;;OAWG;IACH,8BALW,MAAM,OACN,YAAY,GACV,MAAM,CAMlB;IAED;;;;;;OAMG;IACH,0BAJW,MAAM,GACJ,gBAAgB,CAuB5B;IAED;;;;;;;;;;;;;;OAcG;IACH,uBALW,MAAM,eACN,QAAQ,QACR,MAAM,QAgFhB;IAED;;;;;;;;;;;;;OAaG;IACH,yBAYC;IAED;;;;;;;;;;;OAWG;IACH,uBAWC;IAED;;;;;;;;;;;;OAYG;IACH,wBAJW,aAAa,GACX,MAAM,CAqFlB;IAED;;;;;;;;;;OAUG;IACH,2BAJW,MAAM,GACJ,QAAQ,CAuBpB;IAED;;;;OAIG;IACH;;;MAEC;IAED;;;;;;;OAOG;IACH,kCAJW,MAAM,GACJ,MAAM,EAAE,CAcpB;IAED;;;;;;;;;;;OAWG;IACH,wBALW,aAAa,eACb,QAAQ,QACR,MAAM,QA2EhB;IAlDC,4CAAkC;IAoDpC;;;;;;;;;OASG;IACH,yBAHa,QAAQ,CAqBpB;IAED;;;;;;;;;;;;;;;OAeG;IACH,8BALW,aAAa,gBACb,MAAM,GACJ,MAAM,CAmElB;IAED;;;;;;;;OAQG;IACH,0BANW,aAAa,gBACb,QAAQ,QACR,MAAM,QACN,MAAM,QA+BhB;IAED;;;;OAIG;IACH,uBAHW,MAAM,QAWhB;IAED;;;OAGG;IACH,4BAOC;IAED;;;;OAIG;IACH,sBAHW,MAAM,QAUhB;IAED;;;OAGG;IACH,2BAMC;IAED;;;;;;;;;;;OAWG;IACH,gCAHW,QAAQ,QAqBlB;IAED,wDA6CC;IAED;;;;;;;;;;;;;;OAcG;IACH,wBARW,MAAM,YACN,YAAY,GAIV,MAAM,CAyKlB;IAED;;;;;;;OAOG;IACH,sBAHW,MAAM,QAWhB;IAED,oCAyBC;IAED;;;;;;;OAOG;IACH,sBALW,MAAM,QACN,MAAM,UACN,MAAM,QAqFhB;CACD;gCA56C+B,uBAAuB;qBANlC,gBAAgB;6BAFR,gCAAgC;yBAXpC,2BAA2B"}
@@ -7,7 +7,7 @@
7
7
  * Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
8
8
  * @category Rendering
9
9
  */
10
- export default class PrimitiveBatcher extends Batcher {
10
+ export default class PrimitiveBatcher extends WebGLBatcher {
11
11
  /**
12
12
  * Initialize the compositor
13
13
  * @ignore
@@ -27,6 +27,6 @@ export default class PrimitiveBatcher extends Batcher {
27
27
  drawVertices(mode: GLenum, verts: Point[], vertexCount?: number): void;
28
28
  #private;
29
29
  }
30
- import { Batcher } from "./batcher.js";
30
+ import { WebGLBatcher } from "./batcher.js";
31
31
  import type { Point } from "./../../../geometries/point.ts";
32
32
  //# sourceMappingURL=primitive_batcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"primitive_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/primitive_batcher.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;;GAIG;AACH;IACC;;;OAGG;IACH,0BAsCC;IALA;;;OAGG;IACH,sBAAyB;IA0B1B;;;;;OAKG;IACH,mBAJW,MAAM,SACN,KAAK,EAAE,gBACP,MAAM,QAoDhB;;CAyMD;wBAjVuB,cAAc;2BAId,gCAAgC"}
1
+ {"version":3,"file":"primitive_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/primitive_batcher.js"],"names":[],"mappings":"AASA;;;GAGG;AAEH;;;;GAIG;AACH;IACC;;;OAGG;IACH,0BAgCC;IALA;;;OAGG;IACH,sBAAyB;IA0B1B;;;;;OAKG;IACH,mBAJW,MAAM,SACN,KAAK,EAAE,gBACP,MAAM,QA2DhB;;CA8HD;6BAvQ4B,cAAc;2BAInB,gCAAgC"}
@@ -2,7 +2,6 @@
2
2
  * additional import for TypeScript
3
3
  * @import {TextureAtlas} from "./../../texture/atlas.js";
4
4
  */
5
- export const V_ARRAY: Vector3d[];
6
5
  /**
7
6
  * A WebGL Compositor object. This class handles all of the WebGL state<br>
8
7
  * Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
@@ -76,7 +75,6 @@ export default class QuadBatcher extends MaterialBatcher {
76
75
  */
77
76
  addQuad(texture: TextureAtlas, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number, reupload?: boolean): void;
78
77
  }
79
- import { Vector3d } from "../../../math/vector3d.ts";
80
78
  import { MaterialBatcher } from "./material_batcher.js";
81
79
  import type { TextureAtlas } from "./../../texture/atlas.js";
82
80
  //# sourceMappingURL=quad_batcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/quad_batcher.js"],"names":[],"mappings":"AAMA;;;GAGG;AAUH,iCAKE;AAEF;;;;GAIG;AACH;IACC;;;OAGG;IACH,0BA0DC;IAzDA;;;;OAIG;IACH,qCAA0D;IA2C1D;;;;;OAKG;IACH,qCAA2B;IAK5B;;;;OAIG;IACH,0BAcC;IAED;;;;OAIG;IACH,0BAIC;IAED;;;;;;;OAOG;IACH,kBAFW,QAAQ,GAAC,YAAY,QAK/B;IAyDD;;;;;;;;;;OAUG;IACH,oBAPW,YAAY,KACZ,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,UACN,QAAQ,GAAC,YAAY,QAkE/B;IAED;;;;;;;;;;;;;OAaG;IACH,iBAZW,YAAY,KACZ,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,QAwEjB;CACD;yBAtWwB,2BAA2B;gCAIpB,uBAAuB;kCAIxB,0BAA0B"}
1
+ {"version":3,"file":"quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/quad_batcher.js"],"names":[],"mappings":"AAOA;;;GAGG;AAEH;;;;GAIG;AACH;IACC;;;OAGG;IACH,0BAuDC;IAtDA;;;;OAIG;IAMH,qCAA4C;IAmC5C;;;;;OAKG;IACH,qCAA2B;IAK5B;;;;OAIG;IACH,0BAmBC;IAED;;;;OAIG;IACH,0BAIC;IAED;;;;;;;OAOG;IACH,kBAFW,QAAQ,GAAC,YAAY,QAK/B;IAwDD;;;;;;;;;;OAUG;IACH,oBAPW,YAAY,KACZ,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,UACN,QAAQ,GAAC,YAAY,QAoE/B;IAED;;;;;;;;;;;;;OAaG;IACH,iBAZW,YAAY,KACZ,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,QAuEjB;CACD;gCArV+B,uBAAuB;kCAIxB,0BAA0B"}
@@ -6,7 +6,7 @@ export default class WebGLIndexBuffer extends IndexBuffer {
6
6
  /**
7
7
  * @param {WebGLRenderingContext|WebGL2RenderingContext} gl - the WebGL context
8
8
  * @param {number} maxIndices - maximum number of indices this buffer can hold
9
- * @param {boolean} [useUint32=false] - use Uint32 indices (WebGL2) instead of Uint16 (WebGL1)
9
+ * @param {boolean} [useUint32=false] - use Uint32 indices instead of Uint16 (a capacity knob — Uint16 keeps index uploads half the size)
10
10
  */
11
11
  constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, maxIndices: number, useUint32?: boolean);
12
12
  gl: WebGLRenderingContext | WebGL2RenderingContext;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The GPU half of an {@link InstancedMesh}'s instance records — one
3
+ * `ARRAY_BUFFER` holding the packed per-instance transforms (and the opt-in
4
+ * colour / custom slots), uploaded with `bufferSubData` over only the range
5
+ * the CPU side actually touched.
6
+ *
7
+ * This is the instancing counterpart of {@link RetainedGeometry}: the mesh's
8
+ * geometry is uploaded once and never rewritten, and this buffer carries
9
+ * everything that differs between the copies. Moving one tree in a forest of
10
+ * five thousand therefore re-uploads 48 bytes, not the geometry and not the
11
+ * other 4 999 records.
12
+ *
13
+ * The buffer is sized to the mesh's capacity rather than its live instance
14
+ * count, so growing by one instance does not reallocate on the GPU until the
15
+ * CPU-side array itself grows.
16
+ * @ignore
17
+ */
18
+ export default class WebGLInstanceBuffer {
19
+ /**
20
+ * @param {WebGL2RenderingContext} gl - the WebGL context
21
+ */
22
+ constructor(gl: WebGL2RenderingContext);
23
+ gl: WebGL2RenderingContext;
24
+ /**
25
+ * the GL buffer holding the packed instance records
26
+ * @type {WebGLBuffer}
27
+ */
28
+ buffer: WebGLBuffer;
29
+ /**
30
+ * byte capacity currently allocated on the GPU; a CPU-side array
31
+ * larger than this forces a full reallocation rather than a sub-update
32
+ * @type {number}
33
+ */
34
+ capacity: number;
35
+ /**
36
+ * Push the dirty span of `data` to the GPU.
37
+ *
38
+ * Three cases, cheapest last: the CPU array outgrew the allocation (full
39
+ * `bufferData`), nothing is dirty (no call at all), or a span changed
40
+ * (one `bufferSubData` covering exactly it).
41
+ * @param {Float32Array} data - the CPU-side instance records
42
+ * @param {number} firstFloat - first dirty float offset (inclusive)
43
+ * @param {number} floatCount - number of dirty floats, 0 when clean
44
+ * @param {number} usedBytes - bytes of `data` actually in use
45
+ */
46
+ upload(data: Float32Array, firstFloat: number, floatCount: number, usedBytes: number): void;
47
+ /**
48
+ * Release the GL buffer. Safe to call twice, and on a lost context — the
49
+ * `isBuffer` probe is itself error-free, whereas deleting a handle whose
50
+ * context died raises INVALID_OPERATION.
51
+ */
52
+ destroy(): void;
53
+ }
54
+ //# sourceMappingURL=instance_buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance_buffer.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/buffer/instance_buffer.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;OAEG;IACH,gBAFW,sBAAsB,EAiBhC;IAdA,2BAAY;IAEZ;;;OAGG;IACH,QAFU,WAAW,CAEU;IAE/B;;;;OAIG;IACH,UAFU,MAAM,CAEC;IAGlB;;;;;;;;;;OAUG;IACH,aALW,YAAY,cACZ,MAAM,cACN,MAAM,aACN,MAAM,QAgChB;IAED;;;;OAIG;IACH,gBASC;CACD"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Persistent GPU geometry for one mesh — a vertex buffer, an index buffer
3
+ * and the {@link WebGLVertexState} that binds them together, all uploaded
4
+ * once and re-drawn from VRAM on subsequent frames.
5
+ *
6
+ * This is what makes the mesh path retained rather than immediate: the
7
+ * geometry it holds is in model space and carries no camera, placement or
8
+ * tint information, so moving, rotating, scaling or re-tinting a mesh
9
+ * changes only uniforms and never touches these buffers. They are rewritten
10
+ * only when the geometry itself changes, which the owning mesh signals by
11
+ * bumping its geometry version.
12
+ *
13
+ * Uploads go through a `Uint8Array` view of the float data rather than the
14
+ * `Float32Array` itself: some drivers canonicalize NaN bit patterns on a
15
+ * float upload, which would corrupt packed values. See `VertexArrayBuffer`.
16
+ * @ignore
17
+ */
18
+ export default class RetainedGeometry {
19
+ /**
20
+ * @param {WebGL2RenderingContext} gl - the WebGL context
21
+ * @param {object[]} attributes - the owning batcher's attribute definitions
22
+ * @param {number} stride - the owning batcher's vertex stride in bytes
23
+ * @param {Function} resolveLocation - maps an attribute name to its shader location
24
+ */
25
+ constructor(gl: WebGL2RenderingContext, attributes: object[], stride: number, resolveLocation: Function);
26
+ gl: WebGL2RenderingContext;
27
+ attributes: object[];
28
+ stride: number;
29
+ resolveLocation: Function;
30
+ /**
31
+ * the GL buffer holding the interleaved model-space vertex data
32
+ * @type {WebGLBuffer}
33
+ */
34
+ vertexBuffer: WebGLBuffer;
35
+ /**
36
+ * the GL buffer holding the index data, as authored
37
+ * @type {WebGLBuffer}
38
+ */
39
+ glIndexBuffer: WebGLBuffer;
40
+ /**
41
+ * `gl.UNSIGNED_SHORT` or `gl.UNSIGNED_INT`, matching the index array
42
+ * the mesh supplied — WebGL 2 draws 32-bit indices natively, so a
43
+ * mesh past 65 535 vertices is still a single draw call.
44
+ * @type {number}
45
+ */
46
+ indexType: number;
47
+ /**
48
+ * number of indices to draw
49
+ * @type {number}
50
+ */
51
+ indexCount: number;
52
+ /**
53
+ * the mesh geometry version this upload reflects; a mismatch against
54
+ * the mesh means the buffers are stale and must be rewritten
55
+ * @type {number}
56
+ */
57
+ uploadedVersion: number;
58
+ /**
59
+ * the frozen vertex state binding this geometry's buffers
60
+ * @type {WebGLVertexState}
61
+ */
62
+ vertexState: WebGLVertexState;
63
+ /**
64
+ * Upload interleaved vertex data and indices, replacing whatever this
65
+ * geometry held before.
66
+ * @param {Float32Array} vertexData - interleaved vertex data in the batcher's layout
67
+ * @param {number} floatCount - how many floats of `vertexData` are in use
68
+ * @param {Uint16Array|Uint32Array|number[]} indices - the index data, as authored
69
+ * @param {number} version - the mesh geometry version this data reflects
70
+ */
71
+ upload(vertexData: Float32Array, floatCount: number, indices: Uint16Array | Uint32Array | number[], version: number): void;
72
+ /**
73
+ * Make this geometry current for drawing.
74
+ */
75
+ bind(): void;
76
+ /**
77
+ * Release every GL object this geometry owns. Safe to call twice, and on
78
+ * a lost context.
79
+ */
80
+ destroy(): void;
81
+ }
82
+ import WebGLVertexState from "./vertexstate.js";
83
+ //# sourceMappingURL=retained_geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retained_geometry.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/buffer/retained_geometry.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;;;;OAKG;IACH,gBALW,sBAAsB,cACtB,MAAM,EAAE,UACR,MAAM,6BA+DhB;IA3DA,2BAAY;IACZ,qBAA4B;IAC5B,eAAoB;IACpB,0BAAsC;IAEtC;;;OAGG;IACH,cAFU,WAAW,CAEgB;IAErC;;;OAGG;IACH,eAFU,WAAW,CAEiB;IAEtC;;;;;OAKG;IACH,WAFU,MAAM,CAEkB;IAElC;;;OAGG;IACH,YAFU,MAAM,CAEG;IAEnB;;;;OAIG;IACH,iBAFU,MAAM,CAES;IAYzB;;;OAGG;IACH,aAFU,gBAAgB,CAQxB;IAGH;;;;;;;OAOG;IACH,mBALW,YAAY,cACZ,MAAM,WACN,WAAW,GAAC,WAAW,GAAC,MAAM,EAAE,WAChC,MAAM,QAsChB;IAED;;OAEG;IACH,aAEC;IAED;;;OAGG;IACH,gBAwBC;CACD;6BA1K4B,kBAAkB"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * A uniform buffer bound to a named block in one or more shader programs.
3
+ *
4
+ * Uniform arrays are charged against `MAX_FRAGMENT_UNIFORM_VECTORS`, a
5
+ * driver-reported budget that is small on weak devices. A uniform buffer is
6
+ * charged against `MAX_UNIFORM_BLOCK_SIZE` instead — guaranteed at least
7
+ * 16 KB, typically 64 KB — so bulk per-frame data stops competing with
8
+ * everything else the shader declares.
9
+ *
10
+ * Data is staged in a `Float32Array` and uploaded with `bufferSubData`, so
11
+ * only the live prefix crosses the bus. Uploads are skipped entirely when the
12
+ * staged bytes have not changed, which preserves the property the uniform
13
+ * cache gives today: a scene whose lights are static costs nothing per frame.
14
+ *
15
+ * ## Context loss
16
+ *
17
+ * A block binding is program state, not buffer state, and every program is
18
+ * recompiled on restore — so the binding has to be re-established afterwards
19
+ * or the shader reads an unbound block and renders black. Callers re-bind
20
+ * lazily, whenever the program they last bound is no longer the current one;
21
+ * that covers a context restore without anyone subscribing to an event. The
22
+ * buffer itself needs no recovery hook — the renderer re-runs each batcher's
23
+ * `init()` on restore, which releases this block and builds a new one.
24
+ * @ignore
25
+ */
26
+ export default class UniformBlock {
27
+ /**
28
+ * @param {WebGL2RenderingContext} gl - the rendering context
29
+ * @param {number} floats - capacity in floats
30
+ * @param {number} bindingPoint - the indexed binding point to occupy
31
+ */
32
+ constructor(gl: WebGL2RenderingContext, floats: number, bindingPoint: number);
33
+ gl: WebGL2RenderingContext;
34
+ /**
35
+ * staging buffer; callers write into this then call `upload`
36
+ * @type {Float32Array}
37
+ */
38
+ data: Float32Array;
39
+ /**
40
+ * mirror of what was last uploaded, so an unchanged frame can skip the
41
+ * `bufferSubData` entirely
42
+ * @type {Float32Array}
43
+ */
44
+ _uploaded: Float32Array;
45
+ /** nothing has been uploaded yet, so the mirror is not yet valid */
46
+ _everUploaded: boolean;
47
+ /** live length of the last upload; -1 until there has been one */
48
+ _uploadedLength: number;
49
+ /** @type {number} */
50
+ bindingPoint: number;
51
+ /** @type {WebGLBuffer|null} */
52
+ buffer: WebGLBuffer | null;
53
+ /**
54
+ * Point a program's named block at this buffer's binding point.
55
+ *
56
+ * Safe to call repeatedly — after a context restore the program is a new
57
+ * object and must be re-bound, and there is no way to ask whether it
58
+ * already was.
59
+ * @param {WebGLProgram} program - the linked program
60
+ * @param {string} blockName - the block's name in GLSL
61
+ * @returns {boolean} `false` when the program does not declare the block
62
+ */
63
+ bindTo(program: WebGLProgram, blockName: string): boolean;
64
+ /**
65
+ * Upload the first `floats` entries of {@link UniformBlock#data}.
66
+ *
67
+ * Compares against the previous upload first and does nothing when the
68
+ * bytes are identical. Uniform writes are already skipped when unchanged
69
+ * (`utils/uniforms.js`), so uploading unconditionally here would make a
70
+ * static scene more expensive than it was before the buffer existed.
71
+ * @param {number} floats - how many floats of the staging buffer are live
72
+ * @returns {boolean} whether anything was actually sent to the GPU
73
+ */
74
+ upload(floats: number): boolean;
75
+ /**
76
+ * Release the GL buffer. Safe to call twice, and on a lost context.
77
+ */
78
+ destroy(): void;
79
+ #private;
80
+ }
81
+ //# sourceMappingURL=uniformblock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniformblock.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/buffer/uniformblock.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;IACC;;;;OAIG;IACH,gBAJW,sBAAsB,UACtB,MAAM,gBACN,MAAM,EAkChB;IA/BA,2BAAY;IAEZ;;;OAGG;IACH,MAFU,YAAY,CAEc;IAEpC;;;;OAIG;IACH,WAFU,YAAY,CAEmB;IAEzC,oEAAoE;IACpE,uBAA0B;IAE1B,kEAAkE;IAClE,wBAAyB;IAEzB,qBAAqB;IACrB,cADW,MAAM,CACe;IAEhC,+BAA+B;IAC/B,QADW,WAAW,GAAC,IAAI,CACI;IAQhC;;;;;;;;;OASG;IACH,gBAJW,YAAY,aACZ,MAAM,GACJ,OAAO,CAanB;IAED;;;;;;;;;OASG;IACH,eAHW,MAAM,GACJ,OAAO,CAmBnB;IAoBD;;OAEG;IACH,gBAYC;;CACD"}