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.
- package/README.md +25 -14
- package/build/application/application.d.ts +70 -16
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +2 -2
- package/build/application/settings.d.ts +150 -53
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +13 -11
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/const.d.ts +55 -26
- package/build/const.d.ts.map +1 -1
- package/build/geometries/box3d.d.ts +156 -0
- package/build/geometries/box3d.d.ts.map +1 -0
- package/build/index.d.ts +33 -23
- package/build/index.d.ts.map +1 -1
- package/build/index.js +21839 -8025
- package/build/index.js.map +4 -4
- package/build/lang/deprecated.d.ts +4 -4
- package/build/lang/deprecated.d.ts.map +1 -1
- package/build/level/gltf/GLTFModel.d.ts +4 -0
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts +42 -6
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/gltf/srgb.d.ts +20 -0
- package/build/level/gltf/srgb.d.ts.map +1 -0
- package/build/level/level.d.ts +21 -2
- package/build/level/level.d.ts.map +1 -1
- package/build/lighting/light3d.d.ts +61 -13
- package/build/lighting/light3d.d.ts.map +1 -1
- package/build/loader/loader.d.ts +49 -21
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts.map +1 -1
- package/build/loader/parsers/mtl.d.ts +18 -0
- package/build/loader/parsers/mtl.d.ts.map +1 -1
- package/build/loader/parsers/obj.d.ts +49 -0
- package/build/loader/parsers/obj.d.ts.map +1 -1
- package/build/loader/parsers/pbr.d.ts +63 -0
- package/build/loader/parsers/pbr.d.ts.map +1 -0
- package/build/loader/parsers/shader.d.ts +32 -24
- package/build/loader/parsers/shader.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +12 -1
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/broadphase/octree.d.ts +35 -0
- package/build/physics/broadphase/octree.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +123 -6
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts +12 -0
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/raycast.d.ts.map +1 -1
- package/build/physics/builtin/sat3d.d.ts +59 -0
- package/build/physics/builtin/sat3d.d.ts.map +1 -0
- package/build/physics/response.d.ts +32 -0
- package/build/physics/response.d.ts.map +1 -1
- package/build/physics/world.d.ts +1 -0
- package/build/physics/world.d.ts.map +1 -1
- package/build/renderable/container.d.ts +1 -0
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/groundshadow.d.ts +92 -0
- package/build/renderable/groundshadow.d.ts.map +1 -0
- package/build/renderable/instanced_mesh.d.ts +286 -0
- package/build/renderable/instanced_mesh.d.ts.map +1 -0
- package/build/renderable/mesh.d.ts +242 -23
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +6 -4
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +17 -6
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/system/device.d.ts +11 -40
- package/build/system/device.d.ts.map +1 -1
- package/build/system/platform.d.ts +0 -16
- package/build/system/platform.d.ts.map +1 -1
- package/build/utils/utils.d.ts +2 -0
- package/build/utils/utils.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +22 -16
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/{webgl/effects → effects}/blur.d.ts +2 -2
- package/build/video/effects/blur.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/chromaticAberration.d.ts +2 -2
- package/build/video/effects/chromaticAberration.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/colorMatrix.d.ts +3 -3
- package/build/video/effects/colorMatrix.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/desaturate.d.ts +1 -1
- package/build/video/effects/desaturate.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/dissolve.d.ts +2 -2
- package/build/video/effects/dissolve.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/dropShadow.d.ts +2 -2
- package/build/video/effects/dropShadow.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/flash.d.ts +2 -2
- package/build/video/effects/flash.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/glow.d.ts +2 -2
- package/build/video/effects/glow.d.ts.map +1 -0
- package/build/video/effects/glsl_realization.d.ts +18 -0
- package/build/video/effects/glsl_realization.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/hologram.d.ts +2 -2
- package/build/video/effects/hologram.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/invert.d.ts +1 -1
- package/build/video/effects/invert.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/outline.d.ts +2 -2
- package/build/video/effects/outline.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/pixelate.d.ts +2 -2
- package/build/video/effects/pixelate.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/radialGradient.d.ts +3 -4
- package/build/video/effects/radialGradient.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/scanline.d.ts +2 -2
- package/build/video/effects/scanline.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/sepia.d.ts +1 -1
- package/build/video/effects/sepia.d.ts.map +1 -0
- package/build/video/{webgl → effects}/shadereffect.d.ts +133 -25
- package/build/video/effects/shadereffect.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/shine.d.ts +2 -2
- package/build/video/effects/shine.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/tintPulse.d.ts +2 -2
- package/build/video/effects/tintPulse.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/vignette.d.ts +2 -2
- package/build/video/effects/vignette.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/wave.d.ts +2 -2
- package/build/video/effects/wave.d.ts.map +1 -0
- package/build/video/effects/wgsl/layout.d.ts +28 -0
- package/build/video/effects/wgsl/layout.d.ts.map +1 -0
- package/build/video/effects/wgsl/parse.d.ts +9 -0
- package/build/video/effects/wgsl/parse.d.ts.map +1 -0
- package/build/video/effects/wgsl/scaffold.d.ts +43 -0
- package/build/video/effects/wgsl/scaffold.d.ts.map +1 -0
- package/build/video/effects/wgsl_realization.d.ts +83 -0
- package/build/video/effects/wgsl_realization.d.ts.map +1 -0
- package/build/video/gpu/batcher.d.ts +71 -0
- package/build/video/gpu/batcher.d.ts.map +1 -0
- package/build/video/gpu/instancerecord.d.ts +164 -0
- package/build/video/gpu/instancerecord.d.ts.map +1 -0
- package/build/video/gpu/meshchunk.d.ts +49 -0
- package/build/video/gpu/meshchunk.d.ts.map +1 -0
- package/build/video/gpu/meshvertex.d.ts +54 -0
- package/build/video/gpu/meshvertex.d.ts.map +1 -0
- package/build/video/gpu/primitives.d.ts +60 -0
- package/build/video/gpu/primitives.d.ts.map +1 -0
- package/build/video/gpu/quadcorners.d.ts +11 -0
- package/build/video/gpu/quadcorners.d.ts.map +1 -0
- package/build/video/gpu/textureslots.d.ts +122 -0
- package/build/video/gpu/textureslots.d.ts.map +1 -0
- package/build/video/gpu/texturestore.d.ts +139 -0
- package/build/video/gpu/texturestore.d.ts.map +1 -0
- package/build/video/gpu/topology.d.ts +43 -0
- package/build/video/gpu/topology.d.ts.map +1 -0
- package/build/video/gpu/vertexformat.d.ts +72 -0
- package/build/video/gpu/vertexformat.d.ts.map +1 -0
- package/build/video/gradient.d.ts +14 -5
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +153 -8
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +7 -6
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +2 -2
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
- package/build/video/rendertarget/webglrendertarget.d.ts +38 -2
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webgpurendertarget.d.ts +83 -0
- package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -0
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +20 -2
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/texture/noise_texture2d.d.ts +2 -2
- package/build/video/utils/autodetect.d.ts.map +1 -1
- package/build/video/video.d.ts +1 -55
- package/build/video/video.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts +132 -35
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +14 -0
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +63 -36
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +29 -20
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +308 -14
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/primitive_batcher.d.ts +2 -2
- package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +0 -2
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +1 -1
- package/build/video/webgl/buffer/instance_buffer.d.ts +54 -0
- package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -0
- package/build/video/webgl/buffer/retained_geometry.d.ts +83 -0
- package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -0
- package/build/video/webgl/buffer/uniformblock.d.ts +81 -0
- package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -0
- package/build/video/webgl/buffer/vertexstate.d.ts +101 -0
- package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -0
- package/build/video/webgl/glshader.d.ts +101 -8
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/lighting/constants.d.ts +20 -8
- package/build/video/webgl/lighting/constants.d.ts.map +1 -1
- package/build/video/webgl/lighting/pack.d.ts +1 -1
- package/build/video/webgl/lighting/pack3d.d.ts +27 -11
- package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
- package/build/video/webgl/lighting/std140.d.ts +110 -0
- package/build/video/webgl/lighting/std140.d.ts.map +1 -0
- package/build/video/webgl/shaders/multitexture-lit.d.ts +7 -3
- package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
- package/build/video/webgl/texture/store.d.ts +52 -0
- package/build/video/webgl/texture/store.d.ts.map +1 -0
- package/build/video/webgl/utils/maxtextures.d.ts +37 -0
- package/build/video/webgl/utils/maxtextures.d.ts.map +1 -0
- package/build/video/webgl/utils/samplercache.d.ts +69 -0
- package/build/video/webgl/utils/samplercache.d.ts.map +1 -0
- package/build/video/webgl/utils/string.d.ts +16 -0
- package/build/video/webgl/utils/string.d.ts.map +1 -1
- package/build/video/webgl/utils/topology.d.ts +24 -0
- package/build/video/webgl/utils/topology.d.ts.map +1 -0
- package/build/video/webgl/utils/vertexformat.d.ts +27 -0
- package/build/video/webgl/utils/vertexformat.d.ts.map +1 -0
- package/build/video/webgl/webgl_renderer.d.ts +148 -30
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +40 -0
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +82 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/mesh_batcher.d.ts +301 -0
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/primitive_batcher.d.ts +39 -0
- package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/quad_batcher.d.ts +143 -0
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts +70 -0
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -0
- package/build/video/webgpu/buffer/arena.d.ts +64 -0
- package/build/video/webgpu/buffer/arena.d.ts.map +1 -0
- package/build/video/webgpu/buffer/instance_buffer.d.ts +65 -0
- package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -0
- package/build/video/webgpu/buffer/retained_geometry.d.ts +55 -0
- package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -0
- package/build/video/webgpu/buffer/uniformring.d.ts +68 -0
- package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -0
- package/build/video/webgpu/effect_binding.d.ts +17 -0
- package/build/video/webgpu/effect_binding.d.ts.map +1 -0
- package/build/video/webgpu/pipeline/bindgroups.d.ts +36 -0
- package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -0
- package/build/video/webgpu/pipeline/cache.d.ts +173 -0
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -0
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +90 -0
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -0
- package/build/video/webgpu/shaders/mesh-instanced.d.ts +60 -0
- package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -0
- package/build/video/webgpu/texture/compressed.d.ts +33 -0
- package/build/video/webgpu/texture/compressed.d.ts.map +1 -0
- package/build/video/webgpu/texture/frametexture.d.ts +65 -0
- package/build/video/webgpu/texture/frametexture.d.ts.map +1 -0
- package/build/video/webgpu/texture/store.d.ts +149 -0
- package/build/video/webgpu/texture/store.d.ts.map +1 -0
- package/build/video/webgpu/webgpu_renderer.d.ts +536 -0
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -0
- package/package.json +2 -2
- package/build/video/webgl/effects/blur.d.ts.map +0 -1
- package/build/video/webgl/effects/chromaticAberration.d.ts.map +0 -1
- package/build/video/webgl/effects/colorMatrix.d.ts.map +0 -1
- package/build/video/webgl/effects/desaturate.d.ts.map +0 -1
- package/build/video/webgl/effects/dissolve.d.ts.map +0 -1
- package/build/video/webgl/effects/dropShadow.d.ts.map +0 -1
- package/build/video/webgl/effects/flash.d.ts.map +0 -1
- package/build/video/webgl/effects/glow.d.ts.map +0 -1
- package/build/video/webgl/effects/hologram.d.ts.map +0 -1
- package/build/video/webgl/effects/invert.d.ts.map +0 -1
- package/build/video/webgl/effects/outline.d.ts.map +0 -1
- package/build/video/webgl/effects/pixelate.d.ts.map +0 -1
- package/build/video/webgl/effects/radialGradient.d.ts.map +0 -1
- package/build/video/webgl/effects/scanline.d.ts.map +0 -1
- package/build/video/webgl/effects/sepia.d.ts.map +0 -1
- package/build/video/webgl/effects/shine.d.ts.map +0 -1
- package/build/video/webgl/effects/tintPulse.d.ts.map +0 -1
- package/build/video/webgl/effects/vignette.d.ts.map +0 -1
- package/build/video/webgl/effects/wave.d.ts.map +0 -1
- package/build/video/webgl/shadereffect.d.ts.map +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebGL 2 sampler objects, deduplicated by their state.
|
|
3
|
+
*
|
|
4
|
+
* GL bakes wrap and filter into the texture *object*, which is why the same
|
|
5
|
+
* image drawn at two repeat modes historically needed two texture units AND
|
|
6
|
+
* two uploads (#1448). Sampler objects — core in GLES 3.0, and unconditionally
|
|
7
|
+
* available since 20.0 dropped WebGL 1 — move that state out of the texture and
|
|
8
|
+
* onto the unit, exactly as the WebGPU backend already separates `GPUTexture`
|
|
9
|
+
* from `GPUSampler`.
|
|
10
|
+
*
|
|
11
|
+
* That separation is what lets texture residency be keyed by **source alone**:
|
|
12
|
+
* one upload serves every variant, and the variant rides the sampler. Slot
|
|
13
|
+
* assignment stays per `(source, variant)`, because a bound sampler applies to
|
|
14
|
+
* a unit and a unit carries one at a time.
|
|
15
|
+
*
|
|
16
|
+
* Deliberately mirrors `WebGPUTextureStore.getSampler(filter, repeat, mipmaps)`
|
|
17
|
+
* — same key, same dedup, so the two backends stay legible side by side.
|
|
18
|
+
* @ignore
|
|
19
|
+
*/
|
|
20
|
+
export class GLSamplerCache {
|
|
21
|
+
/**
|
|
22
|
+
* @param {WebGL2RenderingContext} gl - the owning context
|
|
23
|
+
* @ignore
|
|
24
|
+
*/
|
|
25
|
+
constructor(gl: WebGL2RenderingContext);
|
|
26
|
+
gl: WebGL2RenderingContext;
|
|
27
|
+
/** @type {Map<string, WebGLSampler>} */
|
|
28
|
+
samplers: Map<string, WebGLSampler>;
|
|
29
|
+
lastFilter: number;
|
|
30
|
+
lastRepeat: any;
|
|
31
|
+
lastMipmap: any;
|
|
32
|
+
lastSampler: WebGLSampler | null;
|
|
33
|
+
/** @type {Array<WebGLSampler|null>} */
|
|
34
|
+
bound: Array<WebGLSampler | null>;
|
|
35
|
+
/**
|
|
36
|
+
* The sampler for a filter/wrap/mip combination, created once and reused.
|
|
37
|
+
*
|
|
38
|
+
* There are only a handful of live combinations in any scene — two filters
|
|
39
|
+
* times four repeat modes — so this Map stays tiny however many textures a
|
|
40
|
+
* game loads.
|
|
41
|
+
* @param {number} filter - `gl.NEAREST` or `gl.LINEAR`
|
|
42
|
+
* @param {string} [repeat="no-repeat"] - canvas-style repeat mode
|
|
43
|
+
* @param {boolean} [mipmap=false] - sample the mip chain (trilinear)
|
|
44
|
+
* @returns {WebGLSampler} the shared sampler
|
|
45
|
+
* @ignore
|
|
46
|
+
*/
|
|
47
|
+
get(filter: number, repeat?: string, mipmap?: boolean): WebGLSampler;
|
|
48
|
+
/**
|
|
49
|
+
* Bind a sampler to a texture unit, or unbind with `null`.
|
|
50
|
+
*
|
|
51
|
+
* A bound sampler overrides the texture object's own parameters entirely,
|
|
52
|
+
* which is what makes one texture usable at several variants at once.
|
|
53
|
+
* @param {number} unit - the texture unit
|
|
54
|
+
* @param {WebGLSampler|null} sampler - the sampler, or `null` to fall back
|
|
55
|
+
* to the texture's own state
|
|
56
|
+
* @ignore
|
|
57
|
+
*/
|
|
58
|
+
bind(unit: number, sampler: WebGLSampler | null): void;
|
|
59
|
+
/**
|
|
60
|
+
* Delete every sampler. Called on context loss — the GL objects died with
|
|
61
|
+
* the context, so this only drops our side of the bookkeeping and lets the
|
|
62
|
+
* next `get` mint fresh ones.
|
|
63
|
+
* @param {boolean} [destroy=false] - whether to `deleteSampler` first
|
|
64
|
+
* (orderly teardown; skip it for a lost context)
|
|
65
|
+
* @ignore
|
|
66
|
+
*/
|
|
67
|
+
releaseAll(destroy?: boolean): void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=samplercache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"samplercache.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/samplercache.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IACC;;;OAGG;IACH,gBAHW,sBAAsB,EAmBhC;IAfA,2BAAY;IACZ,wCAAwC;IACxC,UADW,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CACX;IAKzB,mBAAoB;IACpB,gBAAsB;IACtB,gBAAsB;IACtB,iCAAuB;IAGvB,uCAAuC;IACvC,OADW,KAAK,CAAC,YAAY,GAAC,IAAI,CAAC,CACpB;IAGhB;;;;;;;;;;;OAWG;IACH,YANW,MAAM,WACN,MAAM,WACN,OAAO,GACL,YAAY,CAsCxB;IAED;;;;;;;;;OASG;IACH,WALW,MAAM,WACN,YAAY,GAAC,IAAI,QAU3B;IAED;;;;;;;OAOG;IACH,qBAJW,OAAO,QAiBjB;CACD"}
|
|
@@ -3,4 +3,20 @@
|
|
|
3
3
|
* @ignore
|
|
4
4
|
*/
|
|
5
5
|
export function minify(src: any): any;
|
|
6
|
+
/**
|
|
7
|
+
* Prepend preprocessor defines to a GLSL source, respecting `#version`.
|
|
8
|
+
*
|
|
9
|
+
* `#version` must be the very first statement of a GLSL ES 3.00 shader —
|
|
10
|
+
* anything before it, including a `#define`, is a compile error. So defines
|
|
11
|
+
* go immediately *after* that line when one is present, and at the top when
|
|
12
|
+
* it is not (GLSL ES 1.00 sources declare no version).
|
|
13
|
+
*
|
|
14
|
+
* Used to compile shader variants from one source: the optional parts are
|
|
15
|
+
* `#ifdef`-guarded, and the variant is what defines are injected here.
|
|
16
|
+
* @param {string} source - the shader source
|
|
17
|
+
* @param {string} defines - `#define` lines, each newline-terminated
|
|
18
|
+
* @returns {string} the source with the defines injected
|
|
19
|
+
* @ignore
|
|
20
|
+
*/
|
|
21
|
+
export function injectDefines(source: string, defines: string): string;
|
|
6
22
|
//# sourceMappingURL=string.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/string.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,sCAWC"}
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/string.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,sCAWC;AAED;;;;;;;;;;;;;;GAcG;AACH,sCALW,MAAM,WACN,MAAM,GACJ,MAAM,CAoBlB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a draw mode to its GL enum.
|
|
3
|
+
*
|
|
4
|
+
* Accepts either vocabulary and always returns a number, so callers can keep
|
|
5
|
+
* comparing modes numerically. This matters more than it looks: a topology
|
|
6
|
+
* string that reaches a GL draw call is coerced to `NaN` and then to `0`,
|
|
7
|
+
* which *is* `POINTS` — so a missed translation does not throw, it silently
|
|
8
|
+
* renders the batch as points.
|
|
9
|
+
* @param {WebGL2RenderingContext} gl - the rendering context
|
|
10
|
+
* @param {string|GLenum} value - a topology name or a GL primitive enum
|
|
11
|
+
* @returns {GLenum} the GL primitive mode
|
|
12
|
+
* @throws {Error} when `value` is neither a known topology nor a number
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
export function resolveTopology(gl: WebGL2RenderingContext, value: string | GLenum): GLenum;
|
|
16
|
+
/**
|
|
17
|
+
* Name a GL primitive mode in the neutral vocabulary.
|
|
18
|
+
* @param {WebGL2RenderingContext} gl - the rendering context
|
|
19
|
+
* @param {GLenum} mode - a GL primitive mode
|
|
20
|
+
* @returns {string|undefined} the topology name, or `undefined` for an unknown mode
|
|
21
|
+
* @ignore
|
|
22
|
+
*/
|
|
23
|
+
export function topologyFromGL(gl: WebGL2RenderingContext, mode: GLenum): string | undefined;
|
|
24
|
+
//# sourceMappingURL=topology.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/topology.js"],"names":[],"mappings":"AA8BA;;;;;;;;;;;;;GAaG;AACH,oCANW,sBAAsB,SACtB,MAAM,GAAC,MAAM,GACX,MAAM,CA0BlB;AAED;;;;;;GAMG;AACH,mCALW,sBAAsB,QACtB,MAAM,GACJ,MAAM,GAAC,SAAS,CAa5B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The GL enum a vertex format's components are read as.
|
|
3
|
+
* @param {WebGL2RenderingContext} gl - the rendering context
|
|
4
|
+
* @param {string} format - a supported vertex format name
|
|
5
|
+
* @returns {GLenum} the matching component type
|
|
6
|
+
* @throws {Error} when `format` is not a supported format name
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
export function glTypeForFormat(gl: WebGL2RenderingContext, format: string): GLenum;
|
|
10
|
+
/**
|
|
11
|
+
* Name a WebGL attribute description in the neutral vocabulary.
|
|
12
|
+
*
|
|
13
|
+
* Returns `undefined` when the combination has no name — three-component 8-
|
|
14
|
+
* and 16-bit types, for instance, which the GPU vocabulary simply does not
|
|
15
|
+
* define. That absence is deliberate and meaningful: a made-up name would
|
|
16
|
+
* travel into a backend that cannot honour it and fail there, far from the
|
|
17
|
+
* layout that produced it. An attribute with no portable format is still
|
|
18
|
+
* perfectly valid on the WebGL path.
|
|
19
|
+
* @param {WebGL2RenderingContext} gl - the rendering context
|
|
20
|
+
* @param {number} size - component count (1-4)
|
|
21
|
+
* @param {GLenum} type - component type
|
|
22
|
+
* @param {boolean} normalized - whether integers are scaled into `[0, 1]` / `[-1, 1]`
|
|
23
|
+
* @returns {string|undefined} the format name, or `undefined` when none exists
|
|
24
|
+
* @ignore
|
|
25
|
+
*/
|
|
26
|
+
export function formatFromGL(gl: WebGL2RenderingContext, size: number, type: GLenum, normalized: boolean): string | undefined;
|
|
27
|
+
//# sourceMappingURL=vertexformat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertexformat.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/vertexformat.js"],"names":[],"mappings":"AAgCA;;;;;;;GAOG;AACH,oCANW,sBAAsB,UACtB,MAAM,GACJ,MAAM,CAOlB;AAED;;;;;;;;;;;;;;;GAeG;AACH,iCAPW,sBAAsB,QACtB,MAAM,QACN,MAAM,cACN,OAAO,GACL,MAAM,GAAC,SAAS,CAwC5B"}
|
|
@@ -16,6 +16,7 @@ export default class WebGLRenderer extends Renderer {
|
|
|
16
16
|
* @type {WebGLRenderingContext}
|
|
17
17
|
*/
|
|
18
18
|
gl: WebGLRenderingContext;
|
|
19
|
+
_renderTargetPool: RenderTargetPool;
|
|
19
20
|
/**
|
|
20
21
|
* Saved projection matrix for begin/endPostEffect.
|
|
21
22
|
* @type {Matrix3d}
|
|
@@ -35,12 +36,46 @@ export default class WebGLRenderer extends Renderer {
|
|
|
35
36
|
* @type {WebGLBuffer}
|
|
36
37
|
*/
|
|
37
38
|
vertexBuffer: WebGLBuffer;
|
|
39
|
+
/**
|
|
40
|
+
* Sampler objects, deduplicated by state. GL bakes wrap/filter into the
|
|
41
|
+
* texture object; a bound sampler overrides that, so one texture can
|
|
42
|
+
* serve several variants at once — which is what lets residency be
|
|
43
|
+
* keyed by source alone. Renderer-owned so every batcher shares it.
|
|
44
|
+
* @type {GLSamplerCache}
|
|
45
|
+
* @ignore
|
|
46
|
+
*/
|
|
47
|
+
samplerCache: GLSamplerCache;
|
|
48
|
+
/**
|
|
49
|
+
* Texture residency, keyed by SOURCE. The GL handle used to be
|
|
50
|
+
* reachable only through a batcher's per-unit array, so dropping a unit
|
|
51
|
+
* assignment destroyed the texture and the next draw rebuilt it from
|
|
52
|
+
* scratch — a full re-upload and mip regeneration per quad once past
|
|
53
|
+
* the batching limit. Owning it here, per renderer, means a texture
|
|
54
|
+
* that merely moves units costs a bind.
|
|
55
|
+
*
|
|
56
|
+
* Renderer-owned rather than batcher-owned on purpose: `init()` re-runs
|
|
57
|
+
* on context restore, so a batcher-owned store would be REPLACED there,
|
|
58
|
+
* orphaning every handle it tracked and leaking them on the next loss.
|
|
59
|
+
* @type {TextureStore}
|
|
60
|
+
* @ignore
|
|
61
|
+
*/
|
|
62
|
+
textureStore: TextureStore;
|
|
38
63
|
/**
|
|
39
64
|
* Maximum number of texture unit supported under the current context
|
|
40
65
|
* @type {number}
|
|
41
66
|
* @readonly
|
|
42
67
|
*/
|
|
43
68
|
readonly maxTextures: number;
|
|
69
|
+
/**
|
|
70
|
+
* Next free indexed `UNIFORM_BUFFER` binding point, handed out by
|
|
71
|
+
* {@link WebGLRenderer#reserveUniformBindingPoint}. Binding points are
|
|
72
|
+
* a context-wide namespace shared by every uniform block, so they are
|
|
73
|
+
* allocated here rather than picked as literals by whoever needs one —
|
|
74
|
+
* the same reason texture units go through `TextureCache.reserveUnit`.
|
|
75
|
+
* @type {number}
|
|
76
|
+
* @ignore
|
|
77
|
+
*/
|
|
78
|
+
_nextUniformBindingPoint: number;
|
|
44
79
|
/**
|
|
45
80
|
* the default shader precision based on application settings
|
|
46
81
|
* @type {string}
|
|
@@ -67,9 +102,9 @@ export default class WebGLRenderer extends Renderer {
|
|
|
67
102
|
currentTransform: Matrix3d;
|
|
68
103
|
/**
|
|
69
104
|
* The current batcher used by the renderer
|
|
70
|
-
* @type {
|
|
105
|
+
* @type {WebGLBatcher}
|
|
71
106
|
*/
|
|
72
|
-
currentBatcher:
|
|
107
|
+
currentBatcher: WebGLBatcher;
|
|
73
108
|
/**
|
|
74
109
|
* a reference to the current shader program used by the renderer
|
|
75
110
|
* @type {WebGLProgram}
|
|
@@ -86,17 +121,46 @@ export default class WebGLRenderer extends Renderer {
|
|
|
86
121
|
_activeTextureUnit: number;
|
|
87
122
|
/**
|
|
88
123
|
* The list of active batchers
|
|
89
|
-
* @type {Map<
|
|
124
|
+
* @type {Map<WebGLBatcher>}
|
|
90
125
|
*/
|
|
91
|
-
batchers: Map<
|
|
126
|
+
batchers: Map<WebGLBatcher, any>;
|
|
92
127
|
_scissorActive: boolean;
|
|
93
128
|
cache: TextureCache;
|
|
129
|
+
onGameReset: () => void;
|
|
130
|
+
onContextRestoredInvalidate: (renderer: any) => void;
|
|
131
|
+
onCanvasResize: (width: any, height: any) => void;
|
|
94
132
|
/**
|
|
95
|
-
* The WebGL version used by this renderer
|
|
133
|
+
* The WebGL version used by this renderer.
|
|
96
134
|
* @type {number}
|
|
97
|
-
* @default
|
|
135
|
+
* @default 2
|
|
136
|
+
* @deprecated since 20.0.0 — the WebGL renderer is WebGL 2 only, this is always `2`
|
|
98
137
|
*/
|
|
99
138
|
get WebGLVersion(): number;
|
|
139
|
+
_compressedTextureFormats: {
|
|
140
|
+
astc: any;
|
|
141
|
+
bptc: any;
|
|
142
|
+
s3tc: any;
|
|
143
|
+
s3tc_srgb: any;
|
|
144
|
+
pvrtc: any;
|
|
145
|
+
etc1: any;
|
|
146
|
+
etc2: any;
|
|
147
|
+
} | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Reset context state
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Tear down this renderer and free GPU/event resources. Walks every
|
|
153
|
+
* registered batcher's `destroy()` so cross-renderer subscriptions
|
|
154
|
+
* (`GPU_TEXTURE_CACHE_RESET` on `MaterialBatcher`, etc.) don't
|
|
155
|
+
* leak across `Application.destroy()` cycles. Safe to call multiple
|
|
156
|
+
* times — subsequent calls are no-ops.
|
|
157
|
+
*/
|
|
158
|
+
/**
|
|
159
|
+
* Release any GPU geometry retained for the given mesh. Called when a mesh
|
|
160
|
+
* is destroyed; harmless if it never had any.
|
|
161
|
+
* @param {object} mesh - the mesh whose geometry should be freed
|
|
162
|
+
*/
|
|
163
|
+
deleteMeshGeometry(mesh: object): void;
|
|
100
164
|
_lightShader: RadialGradientEffect | undefined;
|
|
101
165
|
_lightAtlas: TextureAtlas | undefined;
|
|
102
166
|
_frameTexture: FrameTexture | undefined;
|
|
@@ -120,22 +184,35 @@ export default class WebGLRenderer extends Renderer {
|
|
|
120
184
|
_getTMXGPURendererFor(orientation: string): object | undefined;
|
|
121
185
|
/**
|
|
122
186
|
* add a new batcher to this renderer
|
|
123
|
-
* @param {
|
|
187
|
+
* @param {WebGLBatcher} batcher - a batcher instance (must extend WebGLBatcher)
|
|
124
188
|
* @param {string} name - a name uniquely identifying this batcher
|
|
125
189
|
* @param {boolean} [activate=false] - true if the given batcher should be set as the active one
|
|
126
190
|
*/
|
|
127
|
-
addBatcher(batcher:
|
|
191
|
+
addBatcher(batcher: WebGLBatcher, name?: string, activate?: boolean): void;
|
|
128
192
|
/**
|
|
129
193
|
* set the active batcher for this renderer
|
|
130
194
|
* @param {string} name - a batcher name
|
|
131
195
|
* @param {GLShader} [shader] - an optional shader program to be used, instead of the default one, when activating the batcher
|
|
132
|
-
* @returns {
|
|
133
|
-
*/
|
|
134
|
-
setBatcher(name?: string, shader?: GLShader):
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
196
|
+
* @returns {WebGLBatcher} an instance to the current active batcher
|
|
197
|
+
*/
|
|
198
|
+
setBatcher(name?: string, shader?: GLShader): WebGLBatcher;
|
|
199
|
+
/**
|
|
200
|
+
* Whether the device state right now is the scene's, so a deferred
|
|
201
|
+
* ground-shadow drain (#1515) would actually land where it is meant to.
|
|
202
|
+
*
|
|
203
|
+
* A batcher transition is normally the end of the mesh pass — but not
|
|
204
|
+
* every one is. `setMask` fills its shape through the primitive batcher
|
|
205
|
+
* with **colour writes off and `stencilOp(…, INCR)` armed**, so draining
|
|
206
|
+
* there both discards every blob and stamps their footprints into the mask
|
|
207
|
+
* being built. A transition inside a post-effect bracket is bound to the
|
|
208
|
+
* child's FBO, so the blobs would be captured into that effect chain and
|
|
209
|
+
* lost from the world. In either case the queue simply waits: the camera
|
|
210
|
+
* drains it at the end of the world walk, which is the point that is always
|
|
211
|
+
* correct.
|
|
212
|
+
* @returns {boolean} true when a drain is safe here
|
|
213
|
+
* @ignore
|
|
137
214
|
*/
|
|
138
|
-
|
|
215
|
+
_canDrainShadows(): boolean;
|
|
139
216
|
/**
|
|
140
217
|
* Create a pattern with the specified repetition
|
|
141
218
|
* @param {HTMLImageElement|SVGImageElement|HTMLVideoElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas|VideoFrame} image - Source image to be used as the pattern's image
|
|
@@ -150,6 +227,23 @@ export default class WebGLRenderer extends Renderer {
|
|
|
150
227
|
*/
|
|
151
228
|
createPattern(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas | VideoFrame, repeat?: string): TextureAtlas;
|
|
152
229
|
_lightUniformsScratch: import("./lighting/pack.ts").LightUniformScratch | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* Claim the next indexed `UNIFORM_BUFFER` binding point.
|
|
232
|
+
*
|
|
233
|
+
* Binding points are context-wide: two uniform blocks sharing one silently
|
|
234
|
+
* overwrite each other, and the loser reads the winner's bytes as its own.
|
|
235
|
+
* Allocating them from here rather than hard-coding an integer per feature
|
|
236
|
+
* makes that collision impossible, and mirrors how texture units are
|
|
237
|
+
* claimed through {@link TextureCache#reserveUnit}.
|
|
238
|
+
*
|
|
239
|
+
* Callers hold their point for the life of the batcher — a context restore
|
|
240
|
+
* re-runs `init()`, which must reuse the point it already has rather than
|
|
241
|
+
* claim another, or a long-lived session would leak through the budget.
|
|
242
|
+
* @returns {number} the claimed binding point
|
|
243
|
+
* @throws {Error} when the device's binding points are exhausted
|
|
244
|
+
* @ignore
|
|
245
|
+
*/
|
|
246
|
+
reserveUniformBindingPoint(): number;
|
|
153
247
|
/**
|
|
154
248
|
* Lazy-init a shared 1×1 white `TextureAtlas` used as the source
|
|
155
249
|
* texture for `drawLight`'s procedural shader. The shader ignores
|
|
@@ -182,11 +276,11 @@ export default class WebGLRenderer extends Renderer {
|
|
|
182
276
|
* assume its normal map is still resident there and skip re-binding it,
|
|
183
277
|
* sampling the directly-bound texture as a normal map (wrong lighting).
|
|
184
278
|
* @param {number} unit - the GL texture unit that was clobbered
|
|
185
|
-
* @param {
|
|
279
|
+
* @param {WebGLBatcher} [except] - a batcher to skip (the one that just bound the
|
|
186
280
|
* texture — its own cache is already accurate)
|
|
187
281
|
* @ignore
|
|
188
282
|
*/
|
|
189
|
-
invalidateTextureUnit(unit: number, except?:
|
|
283
|
+
invalidateTextureUnit(unit: number, except?: WebGLBatcher): void;
|
|
190
284
|
/** @ignore */
|
|
191
285
|
endPostEffect(renderable: any): void;
|
|
192
286
|
/**
|
|
@@ -233,6 +327,38 @@ export default class WebGLRenderer extends Renderer {
|
|
|
233
327
|
* @see WebGLRenderer#createPattern
|
|
234
328
|
*/
|
|
235
329
|
drawPattern(pattern: TextureAtlas, x: number, y: number, width: number, height: number): void;
|
|
330
|
+
/**
|
|
331
|
+
* Draw a textured triangle mesh.
|
|
332
|
+
* Enables hardware depth testing and backface culling for the
|
|
333
|
+
* duration of the draw, then restores the previous GL state. Large
|
|
334
|
+
* meshes are automatically chunked across multiple draw calls to
|
|
335
|
+
* fit the vertex/index buffer limits.
|
|
336
|
+
*
|
|
337
|
+
* Multi-material meshes (OBJ files with multiple `usemtl` groups +
|
|
338
|
+
* a bound MTL) don't add any per-material draw calls here — the
|
|
339
|
+
* per-material colors are baked into `mesh.vertexColors` at
|
|
340
|
+
* construction time and pushed through the batcher's per-vertex
|
|
341
|
+
* `aColor` attribute. `mesh.tint` still multiplies on top at draw
|
|
342
|
+
* time, so flash / fade / team-color via `setTint` work the same
|
|
343
|
+
* as single-material. (The chunking-for-buffer-limits behavior
|
|
344
|
+
* above still applies to multi-material meshes as well.)
|
|
345
|
+
* @param {Mesh} mesh - a Mesh renderable or compatible object
|
|
346
|
+
* @param {Matrix3d} [modelMatrix] - where the mesh sits in the world. When
|
|
347
|
+
* given, the mesh is drawn from persistent model-space geometry and placed
|
|
348
|
+
* entirely by uniforms; when omitted, its vertices are taken as already
|
|
349
|
+
* positioned and accumulated through the batcher (the 2D-camera path).
|
|
350
|
+
*/
|
|
351
|
+
/**
|
|
352
|
+
* Draw one ground shadow per instance of an `InstancedMesh` (#1515), in a
|
|
353
|
+
* single call over the same instance buffer the mesh drew from.
|
|
354
|
+
* @param {InstancedMesh} mesh - the mesh casting the shadows
|
|
355
|
+
* @param {Matrix3d} shadowMatrix - the group matrix flattened onto the ground
|
|
356
|
+
* @param {object} quad - the shared shadow quad
|
|
357
|
+
* @ignore
|
|
358
|
+
*/
|
|
359
|
+
drawInstancedShadow(mesh: InstancedMesh, shadowMatrix: Matrix3d, quad: object): void;
|
|
360
|
+
drawMesh(mesh: any, modelMatrix: any): void;
|
|
361
|
+
_meshShaderWarned: boolean | undefined;
|
|
236
362
|
/**
|
|
237
363
|
* starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path
|
|
238
364
|
* @example
|
|
@@ -344,6 +470,8 @@ export default class WebGLRenderer extends Renderer {
|
|
|
344
470
|
* <img src="../images/darken-blendmode.png" width="180"/> <br>
|
|
345
471
|
* - "lighten" : retains the lightest pixels of both layers <br>
|
|
346
472
|
* <img src="../images/lighten-blendmode.png" width="180"/> <br>
|
|
473
|
+
* - "none" : blending disabled — the source replaces the destination
|
|
474
|
+
* outright, alpha included (matches the WebGPU renderer's "none") <br>
|
|
347
475
|
* Other CSS blend modes ("overlay", "color-dodge", "color-burn", "hard-light", "soft-light",
|
|
348
476
|
* "difference", "exclusion") may be supported by the Canvas renderer (browser-dependent)
|
|
349
477
|
* and will always fall back to "normal" in WebGL. <br>
|
|
@@ -470,18 +598,6 @@ export default class WebGLRenderer extends Renderer {
|
|
|
470
598
|
* @param {number} f - the f component to multiply the current matrix by
|
|
471
599
|
*/
|
|
472
600
|
transform(a: Matrix2d | Matrix3d | number, b: number, c: number, d: number, e: number, f: number): void;
|
|
473
|
-
/**
|
|
474
|
-
* clip the given region from the original canvas. Once a region is clipped,
|
|
475
|
-
* all future drawing will be limited to the clipped region.
|
|
476
|
-
* You can however save the current region using the save(),
|
|
477
|
-
* and restore it (with the restore() method) any time in the future.
|
|
478
|
-
* (<u>this is an experimental feature !</u>)
|
|
479
|
-
* @param {number} x - x axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
|
|
480
|
-
* @param {number} y - y axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
|
|
481
|
-
* @param {number} width - the width of the rectangle to start clipping from.
|
|
482
|
-
* @param {number} height - the height of the rectangle to start clipping from.
|
|
483
|
-
*/
|
|
484
|
-
clipRect(x: number, y: number, width: number, height: number): void;
|
|
485
601
|
/**
|
|
486
602
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
487
603
|
* If the drawing or rendering area is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
@@ -495,11 +611,13 @@ export default class WebGLRenderer extends Renderer {
|
|
|
495
611
|
#private;
|
|
496
612
|
}
|
|
497
613
|
import Renderer from "./../renderer.js";
|
|
614
|
+
import RenderTargetPool from "../rendertarget/render_target_pool.js";
|
|
498
615
|
import { Matrix3d } from "../../math/matrix3d.ts";
|
|
616
|
+
import { GLSamplerCache } from "./utils/samplercache.js";
|
|
499
617
|
import { Bounds } from "../../physics/bounds.ts";
|
|
500
|
-
import
|
|
618
|
+
import { WebGLBatcher } from "./batchers/batcher.js";
|
|
501
619
|
import TextureCache from "./../texture/cache.js";
|
|
502
|
-
import RadialGradientEffect from "
|
|
620
|
+
import RadialGradientEffect from "../effects/radialGradient.js";
|
|
503
621
|
import { TextureAtlas } from "./../texture/atlas.js";
|
|
504
622
|
import { FrameTexture } from "./../texture/frametexture.js";
|
|
505
623
|
import OrthogonalTMXLayerGPURenderer from "./renderers/tmxlayer/orthogonal.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/webgl_renderer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/webgl_renderer.js"],"names":[],"mappings":"AA2DA;;;GAGG;AACH;IAQE;;;;;OAKG;IACH,oBAJU,MAAM,CAIU;IAU1B;;;;OAIG;IACH,IAFU,qBAAqB,CAEI;IAgBnC,oCAIE;IAEF;;;;OAIG;IAIH,wBANU,QAAQ,CAMc;IAChC,yBAAyB;IASzB;;;;;OAKG;IACH,UAHU,MAAM,CAGO;IAEvB;;;OAGG;IACH,cAFU,WAAW,CAEqB;IAE1C;;;;;;;OAOG;IACH,cAHU,cAAc,CAGuB;IAE/C;;;;;;;;;;;;;OAaG;IACH,cAHU,YAAY,CAG4B;IAElD;;;;OAIG;IACH,sBAHU,MAAM,CAMf;IACD;;;;;;;;OAQG;IACH,0BAHU,MAAM,CAGiB;IAEjC;;;;OAIG;IACH,iBAHU,MAAM,CAMf;IAED;;;OAGG;IACH;;;QAEE;IAIF,kBAA6B;IAG7B,kBAAoB;IAGpB,sBAA4B;IAM5B,wBAAwB;IAExB;;;;OAIG;IACH,kBAFU,QAAQ,CAEuC;IAEzD;;;OAGG;IACH,gBAFU,YAAY,CAES;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AAS,GAAC,OAAO,GAAC,IAAI,GAAC,OAAO,WACnC,OAAO,QA0DjB;IArCE,sCAA4B;;CAoD/B;qBA1lGoB,kBAAkB;6BACV,uCAAuC;yBAhB3C,wBAAwB;+BAqClB,yBAAyB;uBApCjC,yBAAyB;6BAyBnB,uBAAuB;yBAP3B,uBAAuB;iCANf,8BAA8B;6BAKrB,uBAAuB;6BAEpC,8BAA8B;0CAajB,oCAAoC;sBAlC7C,uBAAuB;0BA0CjC,iCAAiC;+BAC5B,iCAAiC;6BACnC,6BAA6B;0BAChC,4BAA4B;6BACzB,+BAA+B;8BAC9B,wBAAwB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WebGPU lit mesh batcher — meshes shaded by the active stage's
|
|
3
|
+
* {@link Light3d} lights (half-Lambert diffuse from directional lights +
|
|
4
|
+
* ambient), the port of the GL `LitMeshBatcher`:
|
|
5
|
+
*
|
|
6
|
+
* - adds the `aNormal` vertex attribute (48-byte layout vs 36) and the lit
|
|
7
|
+
* shader family; meshes opt in via `mesh.lit`, so unlit meshes keep the
|
|
8
|
+
* lean base batcher and pay nothing for lighting
|
|
9
|
+
* - the std140 `Light3dBlock` binds at group 2 with a dynamic offset. The
|
|
10
|
+
* GL batcher re-packs and dirty-compares per draw
|
|
11
|
+
* (`UniformBlock.upload`); here a change lands in a FRESH arena region
|
|
12
|
+
* (queue-write law — an in-place write would retroactively re-light
|
|
13
|
+
* draws already recorded this frame), and an unchanged rig re-uses the
|
|
14
|
+
* frame's existing snapshot at zero upload cost
|
|
15
|
+
* @augments WebGPUMeshBatcher
|
|
16
|
+
* @category Rendering
|
|
17
|
+
*/
|
|
18
|
+
export default class WebGPULitMeshBatcher extends WebGPUMeshBatcher {
|
|
19
|
+
/**
|
|
20
|
+
* @override
|
|
21
|
+
*/
|
|
22
|
+
override init(renderer: any, settings: any): void;
|
|
23
|
+
lightsLayout: GPUBindGroupLayout | undefined;
|
|
24
|
+
blockData: Float32Array<ArrayBuffer> | undefined;
|
|
25
|
+
uploadedBlock: Float32Array<ArrayBuffer> | undefined;
|
|
26
|
+
lightBindGroups: Map<any, any> | undefined;
|
|
27
|
+
lightBinding: {
|
|
28
|
+
bindGroup: any;
|
|
29
|
+
dynamicOffset: any;
|
|
30
|
+
frameId: any;
|
|
31
|
+
} | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* build the light-block layout once per device (init drops it when the
|
|
34
|
+
* device changes)
|
|
35
|
+
* @ignore
|
|
36
|
+
*/
|
|
37
|
+
ensureLightsLayout(): GPUBindGroupLayout;
|
|
38
|
+
}
|
|
39
|
+
import WebGPUMeshBatcher from "./mesh_batcher.js";
|
|
40
|
+
//# sourceMappingURL=lit_mesh_batcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit_mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/lit_mesh_batcher.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;OAEG;IACH,kDAoBC;IAhBC,6CAA6B;IAU9B,iDAAiD;IACjD,qDAAqD;IAErD,2CAAgC;IAEhC;;;;yBAAwB;IA2CzB;;;;OAIG;IACH,yCAkBC;CA4JD;8BA7Q6B,mBAAmB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WebGPU lit quad batcher — normal-mapped sprites shaded by the
|
|
3
|
+
* Light2d std140 block, the port of the GL `LitQuadBatcher` under this
|
|
4
|
+
* backend's single-texture-per-draw-segment model:
|
|
5
|
+
*
|
|
6
|
+
* - group 1 is a combined material (color texture + normal map, four
|
|
7
|
+
* entries); a change of either flushes the segment, so there is no
|
|
8
|
+
* per-vertex normal-texture id and no sampler ladder
|
|
9
|
+
* - group 2 binds the std140 `Light2dBlock` with a dynamic offset — each
|
|
10
|
+
* `setLightUniforms` call snapshots the packed block into the effect
|
|
11
|
+
* uniform arena (queue writes execute before every recorded draw, so a
|
|
12
|
+
* shared buffer region per camera would be retroactively clobbered)
|
|
13
|
+
* - normal maps live outside the TextureCache (same as GL): resident
|
|
14
|
+
* GPUTextures keyed by source object, re-uploaded when the source's
|
|
15
|
+
* duck-typed `version` stamp advances (NoiseTexture2d and friends)
|
|
16
|
+
* @augments WebGPUQuadBatcher
|
|
17
|
+
* @category Rendering
|
|
18
|
+
*/
|
|
19
|
+
export default class WebGPULitQuadBatcher extends WebGPUQuadBatcher {
|
|
20
|
+
/**
|
|
21
|
+
* @override
|
|
22
|
+
*/
|
|
23
|
+
override init(renderer: any, settings: any): void;
|
|
24
|
+
litMaterialLayout: any;
|
|
25
|
+
lightsLayout: any;
|
|
26
|
+
blockData: Float32Array<ArrayBuffer> | undefined;
|
|
27
|
+
lightBindGroups: Map<any, any> | undefined;
|
|
28
|
+
lightBinding: {
|
|
29
|
+
bindGroup: any;
|
|
30
|
+
dynamicOffset: any;
|
|
31
|
+
frameId: any;
|
|
32
|
+
} | null | undefined;
|
|
33
|
+
litMaterials: Map<any, any> | undefined;
|
|
34
|
+
normalTextures: Map<any, any> | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Snapshot the packed light uniforms for the draws that follow — called
|
|
37
|
+
* by {@link WebGPURenderer#setLightUniforms} once per camera per frame.
|
|
38
|
+
* @param {object} packed - what packLights produced
|
|
39
|
+
*/
|
|
40
|
+
setLightUniforms(packed: object): void;
|
|
41
|
+
/**
|
|
42
|
+
* Whether a light block was snapshotted during the given frame — the
|
|
43
|
+
* renderer's lit gate requires this: a previous-frame binding points
|
|
44
|
+
* into a reset arena region, so it would sample reused bytes.
|
|
45
|
+
* @param {number} frameId - the renderer's current frame stamp
|
|
46
|
+
* @returns {boolean} true when lit draws can bind a valid light block
|
|
47
|
+
*/
|
|
48
|
+
hasCurrentLightBinding(frameId: number): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve (and lazily upload) the resident texture for a normal-map
|
|
51
|
+
* source, re-uploading when its duck-typed `version` stamp advances.
|
|
52
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} source - the normal-map image
|
|
53
|
+
* @returns {object} {texture, view, version, width, height}
|
|
54
|
+
* @ignore
|
|
55
|
+
*/
|
|
56
|
+
residentNormalMap(source: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap): object;
|
|
57
|
+
/**
|
|
58
|
+
* Add a lit textured quad — the base contract plus the normal map the
|
|
59
|
+
* segment shades with.
|
|
60
|
+
* @param {object} texture - the texture atlas to draw with
|
|
61
|
+
* @param {number} x - destination x
|
|
62
|
+
* @param {number} y - destination y
|
|
63
|
+
* @param {number} w - destination width
|
|
64
|
+
* @param {number} h - destination height
|
|
65
|
+
* @param {number} u0 - texture UV (u0)
|
|
66
|
+
* @param {number} v0 - texture UV (v0)
|
|
67
|
+
* @param {number} u1 - texture UV (u1)
|
|
68
|
+
* @param {number} v1 - texture UV (v1)
|
|
69
|
+
* @param {number} tint - tint color in UINT32 (argb) format
|
|
70
|
+
* @param {boolean} [reupload=false] - force the source pixels to re-upload
|
|
71
|
+
* @param {object} [normalMap] - the normal-map image paired with the texture
|
|
72
|
+
* @override
|
|
73
|
+
*/
|
|
74
|
+
override addQuad(texture: object, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number, reupload?: boolean, normalMap?: object): void;
|
|
75
|
+
/**
|
|
76
|
+
* lit draws bind the combined material at 1 and the light block at 2
|
|
77
|
+
* @override
|
|
78
|
+
*/
|
|
79
|
+
override recordDraw(pass: any, vertexCount: any): void;
|
|
80
|
+
}
|
|
81
|
+
import WebGPUQuadBatcher from "./quad_batcher.js";
|
|
82
|
+
//# sourceMappingURL=lit_quad_batcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit_quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/lit_quad_batcher.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;GAiBG;AACH;IACC;;OAEG;IACH,kDAmDC;IA9CA,uBAQE;IACF,kBAaE;IAcF,iDAA+C;IAE/C,2CAAgC;IAEhC;;;;yBAAwB;IAGxB,wCAA6B;IAE7B,0CAA+B;IAGhC;;;;OAIG;IACH,yBAFW,MAAM,QAuChB;IAED;;;;;;OAMG;IACH,gCAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;OAMG;IACH,0BAJW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,GAC5D,MAAM,CAsDlB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,0BAdW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,cACP,MAAM,QAyDhB;IAwBD;;;OAGG;IACH,uDASC;CAuBD;8BAnU6B,mBAAmB"}
|