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
@@ -0,0 +1,101 @@
1
+ /**
2
+ * A WebGL Vertex State — a Vertex Array Object owning a frozen vertex
3
+ * buffer layout: one `vertexAttribPointer` / `enableVertexAttribArray` per
4
+ * attribute against a given vertex buffer, plus the ELEMENT_ARRAY_BUFFER
5
+ * binding when the geometry is indexed.
6
+ *
7
+ * This is the engine's `GPUVertexState` analogue, and the layout it is built
8
+ * from is a `GPUVertexBufferLayout[]`: a list of buffer groups, each with its
9
+ * own buffer, `arrayStride` and `stepMode`. Attributes in a `"vertex"` group
10
+ * advance once per vertex (the ordinary case); attributes in an
11
+ * `"instance"` group advance once per *instance*, which is what
12
+ * `drawElementsInstanced` reads to stamp out N copies of one geometry.
13
+ * The layout is immutable once built, exactly like a vertex layout baked
14
+ * into a render pipeline.
15
+ *
16
+ * Attribute divisors are vertex-array state, so a fresh VAO starts with every
17
+ * divisor at 0 and `build()` creates one each time — an instanced layout can
18
+ * therefore never leak its divisors into an unrelated vertex state, and the
19
+ * single-buffer path issues no `vertexAttribDivisor` calls at all.
20
+ *
21
+ * Every method that mutates GL binding state saves and restores the live
22
+ * bindings itself, so building or rebuilding one vertex state can never
23
+ * disturb whichever one is mid-frame. Callers never touch
24
+ * `bindVertexArray` directly.
25
+ * @ignore
26
+ */
27
+ export default class WebGLVertexState {
28
+ /**
29
+ * Accepts either shape — the single-buffer one (`attributes` + `stride` +
30
+ * `buffer`) or a list of buffer groups (`buffers`). They are equivalent;
31
+ * the former is the latter with one `"vertex"` group.
32
+ * @param {WebGL2RenderingContext} gl - the WebGL context
33
+ * @param {object} descriptor - the vertex layout to realize
34
+ * @param {object[]} [descriptor.attributes] - attribute definitions (`name`, `size`, `type`, `normalized`, `offset`)
35
+ * @param {number} [descriptor.stride] - size of a single vertex in bytes (`arrayStride`)
36
+ * @param {WebGLBuffer} [descriptor.buffer] - the vertex buffer the attribute pointers read from
37
+ * @param {object[]} [descriptor.buffers] - buffer groups, each `{buffer, stride, attributes, stepMode}` where `stepMode` is `"vertex"` (default) or `"instance"`
38
+ * @param {Function} descriptor.resolveLocation - maps an attribute name to its shader location (`-1` when absent)
39
+ * @param {WebGLIndexBuffer} [descriptor.indexBuffer] - index buffer to capture, for indexed geometry
40
+ */
41
+ constructor(gl: WebGL2RenderingContext, descriptor: {
42
+ attributes?: object[] | undefined;
43
+ stride?: number | undefined;
44
+ buffer?: WebGLBuffer | undefined;
45
+ buffers?: object[] | undefined;
46
+ resolveLocation: Function;
47
+ indexBuffer?: any;
48
+ });
49
+ gl: WebGL2RenderingContext;
50
+ descriptor: {
51
+ attributes?: object[] | undefined;
52
+ stride?: number | undefined;
53
+ buffer?: WebGLBuffer | undefined;
54
+ buffers?: object[] | undefined;
55
+ resolveLocation: Function;
56
+ indexBuffer?: WebGLIndexBuffer;
57
+ };
58
+ /**
59
+ * the underlying GL vertex array object
60
+ * @type {WebGLVertexArrayObject}
61
+ */
62
+ handle: WebGLVertexArrayObject;
63
+ /**
64
+ * (Re)build the vertex array object from this state's descriptor,
65
+ * replacing any previous one. Called on construction and from every
66
+ * buffer-recreation path — a vertex state referencing a deleted buffer
67
+ * keeps it alive per the GL spec and draws stale data.
68
+ * @param {object} [changes] - descriptor fields to replace first (e.g. recreated `buffer` / `buffers` / `indexBuffer`)
69
+ */
70
+ build(changes?: object): void;
71
+ /**
72
+ * Capture an ELEMENT_ARRAY_BUFFER binding into this vertex state.
73
+ * Used when an index buffer is (re)created after the state was built —
74
+ * the quad batchers' static pattern buffer — since that binding is
75
+ * vertex-array state and would otherwise land in whichever state
76
+ * happens to be bound.
77
+ * @param {WebGLIndexBuffer} indexBuffer - the index buffer to capture
78
+ * @param {Function} [fill] - optional work to run with this state bound (buffer creation/upload)
79
+ */
80
+ captureIndexBuffer(indexBuffer: WebGLIndexBuffer, fill?: Function): void;
81
+ /**
82
+ * Make this vertex state current. One call restores the entire frozen
83
+ * layout — the WebGL analogue of `setPipeline` + `setVertexBuffer` +
84
+ * `setIndexBuffer`.
85
+ */
86
+ bind(): void;
87
+ /**
88
+ * Delete the underlying vertex array object, if any. Idempotent, and
89
+ * safe on a lost context: deleting an object belonging to a lost
90
+ * context would queue `INVALID_OPERATION` (deletion counts as *using*
91
+ * it — only the `is*` queries are exempt), so probe first.
92
+ */
93
+ release(): void;
94
+ /**
95
+ * Release the vertex array object. The vertex state must not be used
96
+ * after calling destroy.
97
+ */
98
+ destroy(): void;
99
+ #private;
100
+ }
101
+ //# sourceMappingURL=vertexstate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertexstate.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/buffer/vertexstate.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH;IACC;;;;;;;;;;;;OAYG;IACH,gBATW,sBAAsB,cAE9B;QAA8B,UAAU;QACZ,MAAM;QACD,MAAM;QACT,OAAO;QACR,eAAe;QACN,WAAW;KACnD,EAUA;IARA,2BAAY;IACZ;;;;;;sBAJU,gBAAgB;MAIE;IAC5B;;;OAGG;IACH,QAFU,sBAAsB,CAEd;IAyBnB;;;;;;OAMG;IACH,gBAFW,MAAM,QA4EhB;IAED;;;;;;;;OAQG;IACH,gCAHW,gBAAgB,yBAa1B;IAED;;;;OAIG;IACH,aAEC;IAED;;;;;OAKG;IACH,gBAOC;IAED;;;OAGG;IACH,gBAGC;;CACD"}
@@ -1,12 +1,40 @@
1
1
  /**
2
- * a base GL Shader object
2
+ * a complete custom shader program. Historically a WebGL-only GLSL
3
+ * program (the class keeps its name for compatibility), since 20.0 it can
4
+ * carry one realization per GPU backend — a `{vertex, fragment}` GLSL
5
+ * pair for the WebGL renderer and/or a complete `wgsl` module for the
6
+ * WebGPU renderer — mirroring how {@link ShaderEffect} carries one body
7
+ * per shading language. The {@link GLShader#isWebGL} / {@link GLShader#isWebGPU}
8
+ * flags report which realizations exist; a renderer hosts the one it
9
+ * speaks and anything else degrades to the built-in shading (never fatal).
10
+ *
11
+ * ### The WGSL module contract (custom `Mesh` shaders)
12
+ *
13
+ * The `wgsl` source is a complete module hosted by the mesh batchers:
14
+ * entry points must be named **`vertex_main`** (`@vertex`) and
15
+ * **`fragment_main`** (`@fragment`), over the frozen mesh vertex layout —
16
+ * `@location(0) aVertex : vec3f`, `@location(1) aRegion : vec2f`,
17
+ * `@location(2) aColor : vec4f`, plus `@location(3) aNormal : vec3f` on
18
+ * the 48-byte `lit` layout. Bind groups (declare only what is read):
19
+ * group 0 `FrameUniforms {projection : mat4x4<f32>, lineWidth : f32}`,
20
+ * group 1 the mesh texture + sampler, group 2 the `Light3dBlock` (lit
21
+ * host only), group 3 `MeshUniforms {model, view : mat4x4<f32>,
22
+ * tint, params, emissive : vec4f}` (`params.x` = alpha cutout). The
23
+ * vertex stage owns the projection (`projection * view * model`) and must
24
+ * remap the GL-convention clip z: `(clip.z + clip.w) * 0.5`. WGSL
25
+ * validation is asynchronous and never throws — a failing module logs its
26
+ * errors once and the mesh falls back to the built-in shading.
3
27
  * @category Rendering
4
28
  */
5
29
  export default class GLShader {
6
30
  /**
7
- * @param {WebGLRenderingContext} gl - the current WebGL rendering context
8
- * @param {string} vertex - a string containing the GLSL source code to set
9
- * @param {string} fragment - a string containing the GLSL source code to set
31
+ * @param {WebGLRenderingContext} [gl] - the current WebGL rendering
32
+ * context (`renderer.gl` — undefined on non-WebGL renderers, which
33
+ * simply skips the GLSL realization)
34
+ * @param {string|object} vertex - a string containing the GLSL vertex
35
+ * source, OR a sources object `{vertex, fragment, wgsl, precision,
36
+ * label}` carrying one realization per backend (any omittable)
37
+ * @param {string} [fragment] - a string containing the GLSL fragment source
10
38
  * @param {string} [precision=auto detected] - float precision ('lowp', 'mediump' or 'highp').
11
39
  * @see https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders
12
40
  * @example
@@ -29,13 +57,51 @@ export default class GLShader {
29
57
  * )
30
58
  * // use the shader
31
59
  * myShader.bind();
60
+ * @example
61
+ * // a dual-backend custom mesh shader: the same object hosts on
62
+ * // whichever GPU renderer is active (gl is undefined on WebGPU)
63
+ * myMesh.shader = new me.GLShader(app.renderer.gl, {
64
+ * vertex: toonVertexGLSL,
65
+ * fragment: toonFragmentGLSL,
66
+ * wgsl: toonModuleWGSL,
67
+ * });
32
68
  */
33
- constructor(gl: WebGLRenderingContext, vertex: string, fragment: string, precision?: string);
69
+ constructor(gl?: WebGLRenderingContext, vertex: string | object, fragment?: string, precision?: string);
34
70
  /**
35
71
  * the active gl rendering context
36
72
  * @type {WebGLRenderingContext}
37
73
  */
38
74
  gl: WebGLRenderingContext;
75
+ /**
76
+ * `true` when this shader carries a WebGL realization: a
77
+ * `{vertex, fragment}` GLSL pair compiled against a live context.
78
+ * @type {boolean}
79
+ * @readonly
80
+ */
81
+ readonly isWebGL: boolean;
82
+ /**
83
+ * `true` when this shader carries a WebGPU realization: a complete
84
+ * `wgsl` module (see the class docs for the module contract).
85
+ * @type {boolean}
86
+ * @readonly
87
+ */
88
+ readonly isWebGPU: boolean;
89
+ /**
90
+ * the complete WGSL module source, when {@link GLShader#isWebGPU}
91
+ * @type {string|undefined}
92
+ */
93
+ wgsl: string | undefined;
94
+ /**
95
+ * optional debug label, carried onto the GPU shader module (shows
96
+ * up in browser GPU error messages and profilers)
97
+ * @type {string|undefined}
98
+ */
99
+ label: string | undefined;
100
+ wgslValid: boolean;
101
+ _wgslRegistrations: {
102
+ epoch: number;
103
+ keys: Map<any, any>;
104
+ };
39
105
  /**
40
106
  * `true` once {@link destroy} has been called. After this flag is
41
107
  * `true`, every method on the shader is a silent no-op — callers
@@ -68,8 +134,8 @@ export default class GLShader {
68
134
  * @readonly
69
135
  */
70
136
  readonly suspended: boolean;
71
- _sourceVertex: string;
72
- _sourceFragment: string;
137
+ _sourceVertex: string | object;
138
+ _sourceFragment: string | undefined;
73
139
  _precision: string | undefined;
74
140
  _uniformCache: any;
75
141
  program: WebGLProgram;
@@ -118,7 +184,15 @@ export default class GLShader {
118
184
  */
119
185
  setUniform(name: string, value: object | Float32Array): void;
120
186
  /**
121
- * activate the given vertex attribute for this shader
187
+ * activate the given vertex attribute for this shader.
188
+ *
189
+ * Note: since 20.0 the engine no longer calls this per frame — each
190
+ * {@link WebGLBatcher} captures its attribute layout once into an immutable
191
+ * vertex-state object (VAO) at init (see `WebGLBatcher.createVertexState`).
192
+ * Kept public for custom callers managing their own vertex setup.
193
+ * Custom shaders hosted by a built-in batcher must declare that
194
+ * batcher's attributes first, in layout order — attribute locations
195
+ * are bound in declaration order and the vertex state is frozen.
122
196
  * @param {WebGLRenderingContext} gl - the current WebGL rendering context
123
197
  * @param {object[]} attributes - an array of vertex attributes
124
198
  * @param {number} stride - the size of a single vertex in bytes
@@ -142,6 +216,25 @@ export default class GLShader {
142
216
  * @returns {GLShader} a new, caller-owned shader (`shared === false`)
143
217
  */
144
218
  clone(): GLShader;
219
+ /**
220
+ * Register this shader's WGSL module as a pipeline family for one
221
+ * hosting mesh batcher, against that host's positional group-layout
222
+ * list and frozen vertex layout. Registered once per host per device
223
+ * generation; the module text is namespaced by the host key so the
224
+ * same shader yields distinct families (distinct pipeline layouts) on
225
+ * the unlit and lit hosts. Asynchronous WGSL validation errors flip
226
+ * {@link GLShader#wgslValid} and the host falls back to its built-in
227
+ * shading (warn-and-degrade, never fatal).
228
+ * @param {object} cache - the WebGPU renderer's pipeline cache
229
+ * @param {string} host - the hosting family's vertex-layout key
230
+ * @param {GPUBindGroupLayout[]} bindGroupLayouts - the host's group list
231
+ * @param {string} vertexLayoutKey - the host's registered vertex layout
232
+ * @returns {string|null} the family key to pass to the pipeline cache's
233
+ * `get`, or null when the module failed validation on this device
234
+ * generation (the host then uses its built-in family)
235
+ * @ignore
236
+ */
237
+ registerWGSL(cache: object, host: string, bindGroupLayouts: GPUBindGroupLayout[], vertexLayoutKey: string): string | null;
145
238
  /**
146
239
  * destroy this shader objects resources (program, attributes, uniforms).
147
240
  * Idempotent — calling destroy twice (or after a context-lost suspend)
@@ -1 +1 @@
1
- {"version":3,"file":"glshader.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/glshader.js"],"names":[],"mappings":"AAYA;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,gBA1BW,qBAAqB,UACrB,MAAM,YACN,MAAM,cACN,MAAM,EAqFhB;IA7DA;;;OAGG;IACH,IAFU,qBAAqB,CAEnB;IAEZ;;;;;;;OAOG;IACH,oBAHU,OAAO,CAGK;IAEtB;;;;;;;;;OASG;IACH,QAHU,OAAO,CAGE;IAEnB;;;;;;;;;;OAUG;IACH,oBAHU,OAAO,CAGK;IAGtB,sBAA2B;IAC3B,wBAA+B;IAC/B,+BAA2B;IAG3B,mBAAwC;IAKvC,sBAAmB;IACnB,iBAAoB;IACpB,qBAAsB;IASxB;;;;;;OAMG;IACH,iBA0CC;IAzCA,YAGC;IACD,cAGC;IAoCF;;;;;OAKG;IACH,uBAgBC;IAED;;;;;OAKG;IACH,2BAMC;IAED;;OAEG;IACH,aAKC;IAED;;;;OAIG;IACH,wBAHW,MAAM,GACJ,KAAK,CAYjB;IAED;;;;;;OAMG;IACH,iBALW,MAAM,SACN,MAAM,GAAC,YAAY,QA0C7B;IAED;;;;;OAKG;IACH,wBAJW,qBAAqB,cACrB,MAAM,EAAE,UACR,MAAM,QAmBhB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,SAFa,QAAQ,CAyBpB;IAED;;;;;OAKG;IACH,gBA2BC;CACD"}
1
+ {"version":3,"file":"glshader.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/glshader.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,iBAtCW,qBAAqB,UAGrB,MAAM,GAAC,MAAM,aAGb,MAAM,cACN,MAAM,EAiKhB;IArHA;;;OAGG;IACH,IAFU,qBAAqB,CAEnB;IAEZ;;;;;OAKG;IACH,kBAHU,OAAO,CAIwD;IAEzE;;;;;OAKG;IACH,mBAHU,OAAO,CAGuB;IAExC;;;OAGG;IACH,MAFU,MAAM,GAAC,SAAS,CAEV;IAEhB;;;;OAIG;IACH,OAFU,MAAM,GAAC,SAAS,CAER;IAIlB,mBAAqB;IAKrB;;;MAAwD;IAWxD;;;;;;;OAOG;IACH,oBAHU,OAAO,CAGK;IAEtB;;;;;;;;;OASG;IACH,QAHU,OAAO,CAGE;IAEnB;;;;;;;;;;OAUG;IACH,oBAHU,OAAO,CAGK;IAGtB,+BAA2B;IAC3B,oCAA+B;IAC/B,+BAA2B;IAG3B,mBAAwC;IAMtC,sBAAmB;IACnB,iBAAoB;IACpB,qBAAsB;IAgBzB;;;;;;OAMG;IACH,iBA0CC;IAzCA,YAGC;IACD,cAGC;IAoCF;;;;;OAKG;IACH,uBAgBC;IAED;;;;;OAKG;IACH,2BAMC;IAED;;OAEG;IACH,aAMC;IAED;;;;OAIG;IACH,wBAHW,MAAM,GACJ,KAAK,CAcjB;IAED;;;;;;OAMG;IACH,iBALW,MAAM,SACN,MAAM,GAAC,YAAY,QA4C7B;IAED;;;;;;;;;;;;;OAaG;IACH,wBAJW,qBAAqB,cACrB,MAAM,EAAE,UACR,MAAM,QAmBhB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,SAFa,QAAQ,CA8BpB;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,oBATW,MAAM,QACN,MAAM,oBACN,kBAAkB,EAAE,mBACpB,MAAM,GACJ,MAAM,GAAC,IAAI,CAgFvB;IAED;;;;;OAKG;IACH,gBAkCC;CACD"}
@@ -1,13 +1,25 @@
1
1
  /**
2
- * Constants shared between the lit fragment shader (`multitexture-lit.js`),
3
- * the lit batcher (`LitQuadBatcher`), and the uniform packer (`pack.ts`).
4
- * Kept in a tiny standalone module so the three consumers don't depend on
5
- * each other transitively for a single integer.
2
+ * Constants shared between the lit fragment shaders
3
+ * (`multitexture-lit.js`, `mesh-lit.frag`), the lit batchers
4
+ * (`LitQuadBatcher`, `LitMeshBatcher`), the uniform packers (`pack.ts`,
5
+ * `pack3d.ts`) and the std140 writer (`std140.ts`). Kept in a tiny
6
+ * standalone module so the consumers don't depend on each other
7
+ * transitively for a couple of integers.
6
8
  */
7
9
  /**
8
- * Maximum number of `Light2d` instances the lit fragment shader supports
9
- * concurrently per draw call. Lights past this index are ignored. Sized
10
- * to keep the GLSL uniform arrays comfortably within WebGL1 limits.
10
+ * Maximum number of lights the lit fragment shaders support concurrently
11
+ * per draw call. Lights past this index are ignored.
12
+ *
13
+ * The data travels in a uniform buffer, so this is an allocation rather
14
+ * than a compatibility question: 32 lights cost 1056 bytes against
15
+ * `MAX_UNIFORM_BLOCK_SIZE`, which is at least 16 KB everywhere. Uniform
16
+ * _arrays_, the previous transport, are charged against the much smaller
17
+ * `MAX_FRAGMENT_UNIFORM_VECTORS` — shared with every other uniform the
18
+ * shader declares — which is what held this at 8.
19
+ *
20
+ * It is not a statement about what a device can afford to _shade_: the
21
+ * fragment loop still runs once per pixel per live light. Unused capacity
22
+ * is free — the loop bound is the live count — but filling it is not.
11
23
  */
12
- export declare const MAX_LIGHTS = 8;
24
+ export declare const MAX_LIGHTS = 32;
13
25
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/lighting/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU,IAAI,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/lighting/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,KAAK,CAAC"}
@@ -58,7 +58,7 @@ interface ColorLike {
58
58
  * the lit fragment's `lightPos - vWorldPos` math lines up with the
59
59
  * camera's view.
60
60
  *
61
- * Lights past `MAX_LIGHTS` (8) are silently dropped. Unused slots are
61
+ * Lights past `MAX_LIGHTS` are silently dropped. Unused slots are
62
62
  * zero-filled so stale data from a previous frame can't leak into the
63
63
  * shader.
64
64
  *
@@ -4,26 +4,42 @@ import type { Light3d } from "../../../lighting/light3d.ts";
4
4
  * @ignore
5
5
  */
6
6
  export interface PackedMeshLighting {
7
- /** number of active directional lights, clamped to `MAX_LIGHTS`. */
7
+ /** number of active shaded lights, clamped to `MAX_LIGHTS`. */
8
8
  count: number;
9
- /** `MAX_LIGHTS × 3` surface→light directions (already negated, normalized). */
10
- directions: Float32Array;
11
- /** `MAX_LIGHTS × 3` directional light colors premultiplied by intensity. */
12
- colors: Float32Array;
9
+ /**
10
+ * `MAX_LIGHTS × 4` — `[x, y, z, range]` per light; `range` is `-1` for
11
+ * directional lights (the shader's type sentinel).
12
+ */
13
+ posRange: Float32Array;
14
+ /**
15
+ * `MAX_LIGHTS × 4` — `[dx, dy, dz, cos(outerConeAngle)]` per light;
16
+ * `cosOuter` is `-1` when no cone applies (directional carries the
17
+ * pre-negated surface→light vector, point carries no direction).
18
+ */
19
+ dirCone: Float32Array;
20
+ /**
21
+ * `MAX_LIGHTS × 4` — `[r, g, b, cos(innerConeAngle)]` per light,
22
+ * color premultiplied by intensity.
23
+ */
24
+ colorInner: Float32Array;
13
25
  /** the summed ambient color (RGB, 0..1+). */
14
26
  ambient: Float32Array;
15
27
  }
16
28
  /**
17
29
  * Pack an iterable of {@link Light3d} (e.g. the active `Stage`'s 3D-light set)
18
- * into the uniform arrays the mesh-lit shader reads:
19
- * - **directional** lights contribute a surface→light direction (negated travel
20
- * direction, normalized) + a color premultiplied by intensity, up to
21
- * `MAX_LIGHTS`. Re-normalized here so a direction mutated at runtime without
30
+ * into the std140-ready arrays the mesh-lit shader reads:
31
+ * - **directional** lights contribute a surface→light direction (negated
32
+ * travel direction, normalized) + a color premultiplied by intensity.
33
+ * Re-normalized here so a direction mutated at runtime without
22
34
  * re-normalizing still shades correctly.
35
+ * - **point** lights contribute their world position, `range` (quadratic
36
+ * falloff over the range — the Light2d model) and premultiplied color.
37
+ * - **spot** lights add their travel direction and the cone cosines
38
+ * (`innerConeAngle` clamped just inside `outerConeAngle`, so the
39
+ * smoothstep denominator never collapses).
23
40
  * - **ambient** lights are summed into a single flat ambient color.
24
41
  *
25
- * Other types (`"point"`) are skipped — not shaded yet. The same buffers are
26
- * returned each call (overwritten in place).
42
+ * The same buffers are returned each call (overwritten in place).
27
43
  * @param lights - iterable of lights, or `null`/`undefined` (treated as empty)
28
44
  * @returns the packed lighting (reused instance)
29
45
  * @ignore
@@ -1 +1 @@
1
- {"version":3,"file":"pack3d.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/lighting/pack3d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAG5D;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAClC,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,UAAU,EAAE,YAAY,CAAC;IACzB,4EAA4E;IAC5E,MAAM,EAAE,YAAY,CAAC;IACrB,6CAA6C;IAC7C,OAAO,EAAE,YAAY,CAAC;CACtB;AAcD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAC1C,kBAAkB,CAuCpB"}
1
+ {"version":3,"file":"pack3d.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/lighting/pack3d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAG5D;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAClC,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,YAAY,CAAC;IACvB;;;;OAIG;IACH,OAAO,EAAE,YAAY,CAAC;IACtB;;;OAGG;IACH,UAAU,EAAE,YAAY,CAAC;IACzB,6CAA6C;IAC7C,OAAO,EAAE,YAAY,CAAC;CACtB;AAgBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAC1C,kBAAkB,CAuFpB"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Header, occupying two `vec4`s before the light array begins.
3
+ *
4
+ * ```glsl
5
+ * int count; // offset 0
6
+ * vec3 ambient; // offset 16 — a vec3 aligns to 16, so it cannot share
7
+ * ```
8
+ *
9
+ * `count` is written as a float and read back with `int(...)` in the
10
+ * shader. Declaring it `int` in the block would be tidier, but mixing int
11
+ * and float members means the staging buffer can no longer be a single
12
+ * `Float32Array` view, and the cast is free on every GPU that matters.
13
+ * @ignore
14
+ */
15
+ export declare const HEADER_FLOATS: number;
16
+ /**
17
+ * floats occupied by one light: two `vec4`s
18
+ * @ignore
19
+ */
20
+ export declare const LIGHT_FLOATS: number;
21
+ /**
22
+ * total floats in a light block, header included
23
+ * @ignore
24
+ */
25
+ export declare const BLOCK_FLOATS: number;
26
+ /**
27
+ * total bytes in a light block
28
+ * @ignore
29
+ */
30
+ export declare const BLOCK_BYTES: number;
31
+ /**
32
+ * Lay out 2D (`Light2d`) data.
33
+ *
34
+ * ```glsl
35
+ * struct Light2dData {
36
+ * vec4 posRadiusIntensity; // x, y, radius, intensity
37
+ * vec4 colorHeight; // r, g, b, lightHeight
38
+ * };
39
+ * ```
40
+ * @param out - staging buffer, at least `BLOCK_FLOATS` long
41
+ * @param packed - what {@link packLights} produced
42
+ * @param packed.count - number of live lights, clamped to `MAX_LIGHTS`
43
+ * @param packed.positions - `[x, y, radius, intensity]` per light
44
+ * @param packed.colors - `[r, g, b]` per light, 0..1 per channel
45
+ * @param packed.heights - per-light height; absent means 0
46
+ * @param packed.ambient - `[r, g, b]` ambient floor; absent means black
47
+ * @returns how many floats of `out` are live, for a partial upload
48
+ * @ignore
49
+ */
50
+ export declare function writeLight2dBlock(out: Float32Array, packed: {
51
+ count: number;
52
+ positions: Float32Array;
53
+ colors: Float32Array;
54
+ heights?: Float32Array;
55
+ ambient?: ArrayLike<number>;
56
+ }): number;
57
+ /**
58
+ * floats occupied by one 3D light: three `vec4`s. The 3D block grew from
59
+ * two when point/spot shading landed (#1536) — a spot light needs position
60
+ * + range + direction + both cone cosines + color, which cannot fold into
61
+ * two vec4s' padding. The 2D block keeps its two-vec4 stride.
62
+ * @ignore
63
+ */
64
+ export declare const LIGHT3D_FLOATS: number;
65
+ /**
66
+ * total floats in a 3D light block, header included
67
+ * @ignore
68
+ */
69
+ export declare const BLOCK3D_FLOATS: number;
70
+ /**
71
+ * total bytes in a 3D light block
72
+ * @ignore
73
+ */
74
+ export declare const BLOCK3D_BYTES: number;
75
+ /**
76
+ * Lay out 3D (`Light3d`) data.
77
+ *
78
+ * ```glsl
79
+ * struct Light3dData {
80
+ * vec4 posRange; // x, y, z = world position · w = range;
81
+ * // w < 0 marks a DIRECTIONAL light (xyz unused)
82
+ * vec4 dirCone; // x, y, z = direction · w = cos(outerConeAngle);
83
+ * // w = -1 marks "no cone" (directional dir is the
84
+ * // pre-negated surface→light vector; a point light
85
+ * // carries no direction)
86
+ * vec4 colorInner; // r, g, b = color × intensity · w = cos(innerConeAngle)
87
+ * };
88
+ * ```
89
+ *
90
+ * The type is inferred from the sentinels rather than a tag slot:
91
+ * `posRange.w < 0` → directional; otherwise positional, with a cone
92
+ * applied when `dirCone.w > -1`.
93
+ * @param out - staging buffer, at least `BLOCK3D_FLOATS` long
94
+ * @param packed - what {@link packMeshLights} produced
95
+ * @param packed.count - number of live lights, clamped to `MAX_LIGHTS`
96
+ * @param packed.posRange - `[x, y, z, range]` per light (range -1 for directional)
97
+ * @param packed.dirCone - `[dx, dy, dz, cosOuter]` per light (cosOuter -1 for none)
98
+ * @param packed.colorInner - `[r, g, b, cosInner]` per light
99
+ * @param packed.ambient - `[r, g, b]` ambient floor; absent means black
100
+ * @returns how many floats of `out` are live, for a partial upload
101
+ * @ignore
102
+ */
103
+ export declare function writeLight3dBlock(out: Float32Array, packed: {
104
+ count: number;
105
+ posRange: Float32Array;
106
+ dirCone: Float32Array;
107
+ colorInner: Float32Array;
108
+ ambient?: ArrayLike<number>;
109
+ }): number;
110
+ //# sourceMappingURL=std140.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"std140.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/lighting/std140.ts"],"names":[],"mappings":"AAsCA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,QAAW,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,YAAY,QAAW,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,YAAY,QAA4C,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAgD,CAAC;AA0BzE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE;IACP,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,YAAY,CAAC;IACxB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;CAC5B,GACC,MAAM,CAkCR;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAAW,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,cAAc,QAA8C,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,aAAa,QAAkD,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE;IACP,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,YAAY,CAAC;IACzB,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;CAC5B,GACC,MAAM,CA4BR"}
@@ -7,17 +7,21 @@
7
7
  * unlit fast path inside this same shader (sample color, multiply by
8
8
  * vertex color, return) so lit and unlit sprites can share the lit batch
9
9
  * when they coexist with active lights. The cost vs the truly-unlit
10
- * `QuadBatcher` shader is one varying read + one comparison per fragment.
10
+ * `QuadBatcher` shader is one interpolated read + one comparison per
11
+ * fragment.
11
12
  *
12
13
  * The light's "height above the sprite plane" is encoded as a small
13
14
  * fraction of the light's radius (default `0.075`) so that lights
14
15
  * exactly at a fragment's screen position don't produce degenerate
15
16
  * flat shading.
17
+ *
18
+ * GLSL ES 3.00, because the light data arrives in a uniform block and
19
+ * blocks do not exist in ES 1.00 (see #1552). The paired vertex shader
20
+ * `quad-multi-lit.vert` is on the same version — both stages of a program
21
+ * must agree.
16
22
  * @param {number} maxTextures - the number of color/normal texture units to support
17
23
  * @returns {string} GLSL fragment shader source
18
24
  * @ignore
19
25
  */
20
26
  export function buildLitMultiTextureFragment(maxTextures: number): string;
21
- export { MAX_LIGHTS };
22
- import { MAX_LIGHTS } from "../lighting/constants.ts";
23
27
  //# sourceMappingURL=multitexture-lit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"multitexture-lit.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/shaders/multitexture-lit.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;GAkBG;AACH,0DAJW,MAAM,GACJ,MAAM,CAiFlB;;2BAjI0B,0BAA0B"}
1
+ {"version":3,"file":"multitexture-lit.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/shaders/multitexture-lit.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,0DAJW,MAAM,GACJ,MAAM,CAsGlB"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The WebGL realization of {@link TextureStore}.
3
+ *
4
+ * The shared base owns the policy — source → record, the reuse-or-upload
5
+ * decision, generation and lifetime bookkeeping. This subclass owns the GL
6
+ * calls, and nothing else. Mirrors the `Batcher` / `WebGLBatcher` /
7
+ * `WebGPUBatcher` arrangement: one neutral base, one realization per backend.
8
+ *
9
+ * Two instances exist per renderer: the colour store, which every batcher
10
+ * shares through `WebGLRenderer.textureStore`, and the lit batcher's
11
+ * normal-map store — normal maps live outside the colour `TextureCache`, so
12
+ * their handles are that batcher's to own, but the policy is identical.
13
+ * @augments TextureStore
14
+ * @ignore
15
+ */
16
+ export class WebGLTextureStore extends TextureStore {
17
+ /**
18
+ * @param {WebGL2RenderingContext} gl - the owning context
19
+ * @ignore
20
+ */
21
+ constructor(gl: WebGL2RenderingContext);
22
+ gl: WebGL2RenderingContext;
23
+ /**
24
+ * @returns {WebGLTexture} a fresh texture object
25
+ * @ignore
26
+ */
27
+ onCreate(): WebGLTexture;
28
+ /**
29
+ * Push the source's pixels.
30
+ *
31
+ * Delegated to a per-call closure rather than implemented here, because a
32
+ * GL upload needs the *batcher's* `createTexture2D`: it binds the target
33
+ * unit, tracks immutable-storage shape, and swaps the texture object when
34
+ * the shape changes. None of that is residency, and moving it into the
35
+ * store would drag the batcher's unit bookkeeping along with it.
36
+ * @param {WebGLTexture} handle - the existing texture object
37
+ * @param {object} source - the image/canvas being uploaded
38
+ * @param {object} record - the resident record
39
+ * @param {object} options - carries `upload(handle)`
40
+ * @returns {WebGLTexture} the handle actually used, which may be a
41
+ * replacement when immutable storage had to be respecified
42
+ * @ignore
43
+ */
44
+ onUpload(handle: WebGLTexture, source: object, record: object, options: object): WebGLTexture;
45
+ /**
46
+ * @param {WebGLTexture} handle - the texture object to release
47
+ * @ignore
48
+ */
49
+ onDestroy(handle: WebGLTexture): void;
50
+ }
51
+ import { TextureStore } from "./../../gpu/texturestore.js";
52
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/texture/store.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;OAGG;IACH,gBAHW,sBAAsB,EAMhC;IADA,2BAAY;IAGb;;;OAGG;IACH,YAHa,YAAY,CAKxB;IAED;;;;;;;;;;;;;;;OAeG;IACH,iBARW,YAAY,UACZ,MAAM,UACN,MAAM,WACN,MAAM,GACJ,YAAY,CAMxB;IAED;;;OAGG;IACH,kBAHW,YAAY,QAKtB;CACD;6BA9D4B,6BAA6B"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Resolve the texture-unit pool this renderer will use.
3
+ *
4
+ * Clamping happens ONCE, at renderer construction, before the batchers and the
5
+ * `TextureCache` are built — every consumer derives from the result, so the
6
+ * batchers' sampler counts and the cache's capacity cannot disagree. A setting
7
+ * above what the device reports is clamped down rather than honoured: declaring
8
+ * more `sampler2D` uniforms than the device has units fails to link, and a link
9
+ * failure at startup is not a useful way to learn about a typo.
10
+ * @param {number} deviceMax - the device's `MAX_TEXTURE_IMAGE_UNITS`
11
+ * @param {"auto"|number} [setting="auto"] - the `maxTextures` application setting
12
+ * @returns {number} the pool size, at least 1 and never above `deviceMax`
13
+ * @ignore
14
+ */
15
+ export function resolveMaxTextures(deviceMax: number, setting?: "auto" | number): number;
16
+ /**
17
+ * Default ceiling applied when `maxTextures` is `"auto"`.
18
+ *
19
+ * There is no spec maximum to defer to — WebGL 2 / GLES 3.0 only set a
20
+ * *minimum* of 16 for `MAX_TEXTURE_IMAGE_UNITS`, and an implementation may
21
+ * report any value at or above it. What actually limits us is that the
22
+ * multi-texture fragment shader unrolls one sampler and one branch per unit
23
+ * (see `buildMultiTextureFragment`), so a very wide pool costs compile time
24
+ * and register pressure, and historically some drivers mis-compile the widest
25
+ * ladders. 32 covers current desktop and mobile hardware while staying a
26
+ * conservative default; raise or lower it with the `maxTextures` setting.
27
+ * @ignore
28
+ */
29
+ export const AUTO_MAX_TEXTURES: 32;
30
+ /**
31
+ * Smallest pool the engine will resolve to. A lit quad occupies a colour slot
32
+ * and a normal-map slot simultaneously, so anything narrower makes the two ids
33
+ * collide and the sprite samples its own albedo as a normal map.
34
+ * @ignore
35
+ */
36
+ export const MIN_MAX_TEXTURES: 2;
37
+ //# sourceMappingURL=maxtextures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maxtextures.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/maxtextures.js"],"names":[],"mappings":"AAuBA;;;;;;;;;;;;;GAaG;AACH,8CALW,MAAM,YACN,MAAM,GAAC,MAAM,GACX,MAAM,CAgBlB;AAlDD;;;;;;;;;;;;GAYG;AACH,gCAAiC,EAAE,CAAC;AAEpC;;;;;GAKG;AACH,+BAAgC,CAAC,CAAC"}