melonjs 19.9.1 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/camera/effects/fade_effect.d.ts.map +1 -1
- package/build/camera/effects/mask_effect.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 +34 -24
- package/build/index.d.ts.map +1 -1
- package/build/index.js +22171 -8029
- 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 +86 -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 -15
- 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 +186 -1
- 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,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitive-batcher geometry assembly shared by both backends — pure CPU
|
|
3
|
+
* code, no GPU references (the `meshchunk.ts` / `meshvertex.ts`
|
|
4
|
+
* precedent). The vertex layout is the primitive tier's 6-float
|
|
5
|
+
* `x, y, z, nx, ny, packed-color` stream on both backends.
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
/** the minimal vertex-buffer surface this module writes — `@ignore` */
|
|
9
|
+
interface PrimitiveVertexData {
|
|
10
|
+
push(x: number, y: number, z: number, nx: number, ny: number, color: number): void;
|
|
11
|
+
isFull(count: number): boolean;
|
|
12
|
+
}
|
|
13
|
+
/** a 4×4 column-major transform (Matrix3d-shaped) — `@ignore` */
|
|
14
|
+
interface MatrixLike {
|
|
15
|
+
val: Float32Array;
|
|
16
|
+
isIdentity(): boolean;
|
|
17
|
+
}
|
|
18
|
+
interface PointLike {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Push `verts[start..end)` into the vertex buffer, transformed by the
|
|
24
|
+
* given view matrix. The caller guarantees the range fits.
|
|
25
|
+
*
|
|
26
|
+
* The transform includes the z column (m[8] / m[9] / m[10] / m[14]) so
|
|
27
|
+
* Camera3d's view matrix (X/Y-axis rotation) actually rotates the
|
|
28
|
+
* primitive in 3D. For 2D matrices those slots are identity, so output
|
|
29
|
+
* (x, y, z) is bit-identical to the legacy 2D-only multiply.
|
|
30
|
+
* @ignore
|
|
31
|
+
*/
|
|
32
|
+
export declare function pushPrimitiveRange(vertexData: PrimitiveVertexData, viewMatrix: MatrixLike, verts: PointLike[], start: number, end: number, colorUint32: number, z: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* Expand line pairs into triangles with perpendicular normals. The vertex
|
|
35
|
+
* shader offsets each vertex by `aNormal * uLineWidth * 0.5`, producing
|
|
36
|
+
* thick lines without manual geometry expansion in the renderer. The
|
|
37
|
+
* caller has already switched its draw mode to triangles.
|
|
38
|
+
*
|
|
39
|
+
* Each line pair expands to 2 triangles (6 vertices) — capacity is
|
|
40
|
+
* checked per pair through the `flush` callback, so a dashed/long
|
|
41
|
+
* thick-line path larger than the whole buffer flushes mid-shape instead
|
|
42
|
+
* of silently dropping the out-of-range writes (pairs are independent
|
|
43
|
+
* quads, so a mid-shape flush is invisible).
|
|
44
|
+
*
|
|
45
|
+
* The view matrix is applied (z column included) without mutating the
|
|
46
|
+
* inputs. Note: the perpendicular normal is computed in pre-projection
|
|
47
|
+
* world space, which appears non-perpendicular under perspective — a
|
|
48
|
+
* known limitation shared by both backends.
|
|
49
|
+
* @param vertexData - destination vertex stream
|
|
50
|
+
* @param viewMatrix - the current view matrix
|
|
51
|
+
* @param verts - line vertices in pairs [from, to, from, to, ...]
|
|
52
|
+
* @param vertexCount - number of vertices to consume
|
|
53
|
+
* @param colorUint32 - packed line color
|
|
54
|
+
* @param z - the current renderer depth
|
|
55
|
+
* @param flush - drains the vertex buffer when a pair no longer fits
|
|
56
|
+
* @ignore
|
|
57
|
+
*/
|
|
58
|
+
export declare function expandLinesToTriangles(vertexData: PrimitiveVertexData, viewMatrix: MatrixLike, verts: PointLike[], vertexCount: number, colorUint32: number, z: number, flush: () => void): void;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../../src/video/gpu/primitives.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uEAAuE;AACvE,UAAU,mBAAmB;IAC5B,IAAI,CACH,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,GACX,IAAI,CAAC;IACR,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B;AAED,iEAAiE;AACjE,UAAU,UAAU;IACnB,GAAG,EAAE,YAAY,CAAC;IAClB,UAAU,IAAI,OAAO,CAAC;CACtB;AAED,UAAU,SAAS;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,UAAU,EAAE,mBAAmB,EAC/B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,SAAS,EAAE,EAClB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,CAAC,EAAE,MAAM,GACP,IAAI,CAsBN;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,mBAAmB,EAC/B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,SAAS,EAAE,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,IAAI,GACf,IAAI,CAuDN"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Matrix3d } from "../../math/matrix3d.ts";
|
|
2
|
+
import { Vector3d } from "../../math/vector3d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Set the four corners of an axis-aligned quad and transform them by `m`
|
|
5
|
+
* (skipped when `m` is null/identity — the common untransformed case).
|
|
6
|
+
* Returns the shared corner pool, valid until the next call:
|
|
7
|
+
* `[topLeft, topRight, bottomLeft, bottomRight]`.
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
export declare function transformQuadCorners(m: Matrix3d | null | undefined, x: number, y: number, w: number, h: number, z: number): Vector3d[];
|
|
11
|
+
//# sourceMappingURL=quadcorners.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quadcorners.d.ts","sourceRoot":"","sources":["../../../src/video/gpu/quadcorners.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAyBlD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EAC9B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACP,QAAQ,EAAE,CAYZ"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-neutral texture slot assignment.
|
|
3
|
+
*
|
|
4
|
+
* Both GPU backends solve the same problem — "many textures, one draw call" —
|
|
5
|
+
* by giving each texture a small integer slot that the fragment shader selects
|
|
6
|
+
* on per-vertex. Only the *resource* differs: a WebGL texture unit, or an entry
|
|
7
|
+
* in a WebGPU material bind group. The assignment policy (who gets a slot, what
|
|
8
|
+
* happens when they run out, what is dropped) is identical, and used to be
|
|
9
|
+
* written twice — `TextureCache.allocateTextureUnit` on one side,
|
|
10
|
+
* `WebGPUQuadBatcher.segmentSlotFor` on the other — which is how the two drifted.
|
|
11
|
+
*
|
|
12
|
+
* This class owns that policy and nothing else. It never touches a GL unit or a
|
|
13
|
+
* bind group; the caller supplies the binding through the callbacks. That keeps
|
|
14
|
+
* it pure, so the same test suite proves both backends behave alike.
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
export class TextureSlotTable {
|
|
18
|
+
/**
|
|
19
|
+
* @param {object} options - table configuration
|
|
20
|
+
* @param {number} options.capacity - number of slots, `[0, capacity)`
|
|
21
|
+
* @param {Function} [options.onOverflow] - called when a new key arrives with
|
|
22
|
+
* no slot free. The caller must turn the pending work into GPU work (flush)
|
|
23
|
+
* before the table reassigns slots out from under it.
|
|
24
|
+
* @param {Function} [options.onEvict] - called with each slot index as it is
|
|
25
|
+
* dropped, so the caller can forget its binding for that slot
|
|
26
|
+
* @param {Function} [options.isReserved] - optional predicate; a slot it
|
|
27
|
+
* approves is held out of assignment entirely (WebGL parks `ShaderEffect`
|
|
28
|
+
* extra samplers on high units this way). Reservations survive a reset.
|
|
29
|
+
* @ignore
|
|
30
|
+
*/
|
|
31
|
+
constructor({ capacity, onOverflow, onEvict, isReserved }?: {
|
|
32
|
+
capacity: number;
|
|
33
|
+
onOverflow?: Function | undefined;
|
|
34
|
+
onEvict?: Function | undefined;
|
|
35
|
+
isReserved?: Function | undefined;
|
|
36
|
+
});
|
|
37
|
+
/** @type {Map<string, number>} key → slot */
|
|
38
|
+
slots: Map<string, number>;
|
|
39
|
+
/** @type {Set<number>} occupied slot indices */
|
|
40
|
+
used: Set<number>;
|
|
41
|
+
capacity: number;
|
|
42
|
+
onOverflow: Function | undefined;
|
|
43
|
+
onEvict: Function | undefined;
|
|
44
|
+
isReserved: Function | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* How many slots are currently taken.
|
|
47
|
+
*
|
|
48
|
+
* Occupancy, NOT the key map: slots claimed through {@link claim} carry no
|
|
49
|
+
* key at all (the WebGL cache allocates that way), so counting keys would
|
|
50
|
+
* report an empty table while every unit was in use.
|
|
51
|
+
* @returns {number} the number of occupied slots
|
|
52
|
+
* @ignore
|
|
53
|
+
*/
|
|
54
|
+
get size(): number;
|
|
55
|
+
/**
|
|
56
|
+
* Resize the table. Shrinking evicts every assignment at or above the new
|
|
57
|
+
* capacity; growing keeps everything. Called on context restore / device
|
|
58
|
+
* change, where the resolved limit can differ from the previous one.
|
|
59
|
+
* @param {number} capacity - the new slot count
|
|
60
|
+
* @ignore
|
|
61
|
+
*/
|
|
62
|
+
setCapacity(capacity: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* The slot this key already holds, without assigning one. Use when a miss
|
|
65
|
+
* should not trigger an overflow (probing, debug, bookkeeping).
|
|
66
|
+
* @param {string} key - the slot key
|
|
67
|
+
* @returns {number|undefined} the assigned slot, or `undefined`
|
|
68
|
+
* @ignore
|
|
69
|
+
*/
|
|
70
|
+
peek(key: string): number | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* The lowest assignable slot, or `-1` when every one is taken or reserved.
|
|
73
|
+
* Bounded by `capacity` on purpose: a caller that reserves every slot must
|
|
74
|
+
* get an answer rather than an infinite scan.
|
|
75
|
+
* @returns {number} a free slot index, or -1
|
|
76
|
+
* @ignore
|
|
77
|
+
*/
|
|
78
|
+
freeSlot(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Resolve a key to its slot, assigning one if needed.
|
|
81
|
+
*
|
|
82
|
+
* On exhaustion this calls `onOverflow` (the caller flushes) and then drops
|
|
83
|
+
* every assignment, so the incoming key starts a fresh set — the behaviour
|
|
84
|
+
* both backends already had. The eviction step is deliberately the only
|
|
85
|
+
* policy here: replacing this wipe with something finer (see #1586) changes
|
|
86
|
+
* both backends at once, which is the point of sharing it.
|
|
87
|
+
* @param {string} key - identifies the texture *and* the sampling state it
|
|
88
|
+
* needs, since two draws of one image under different filter/wrap settings
|
|
89
|
+
* cannot share a slot
|
|
90
|
+
* @returns {number} the slot to write into the vertex stream
|
|
91
|
+
* @ignore
|
|
92
|
+
*/
|
|
93
|
+
slotFor(key: string): number;
|
|
94
|
+
/**
|
|
95
|
+
* Take a slot without associating a key with it.
|
|
96
|
+
*
|
|
97
|
+
* The WebGL cache resolves textures to units through its own source-keyed
|
|
98
|
+
* index (a source can hold one unit per wrap mode it was sampled with), so
|
|
99
|
+
* it needs the *policy* — free-slot search honoring reservations, and the
|
|
100
|
+
* flush-then-evict behaviour on exhaustion — without the key map. WebGPU's
|
|
101
|
+
* batcher keys directly and goes through {@link slotFor}, which is this plus
|
|
102
|
+
* the mapping. Both therefore overflow on the same rule.
|
|
103
|
+
* @returns {number} the claimed slot
|
|
104
|
+
* @ignore
|
|
105
|
+
*/
|
|
106
|
+
claim(): number;
|
|
107
|
+
/**
|
|
108
|
+
* Drop a single assignment, freeing its slot. Reservations are untouched —
|
|
109
|
+
* they are owned by whoever reserved them, not by the table.
|
|
110
|
+
* @param {string} key - the slot key to release
|
|
111
|
+
* @returns {boolean} whether the key held a slot
|
|
112
|
+
* @ignore
|
|
113
|
+
*/
|
|
114
|
+
release(key: string): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Drop every assignment. `onEvict` fires once per slot that was live, so a
|
|
117
|
+
* caller tracking bindings per slot can forget exactly those.
|
|
118
|
+
* @ignore
|
|
119
|
+
*/
|
|
120
|
+
reset(): void;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=textureslots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textureslots.d.ts","sourceRoot":"","sources":["../../../src/video/gpu/textureslots.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH;IACC;;;;;;;;;;;;OAYG;IACH,4DAXG;QAAwB,QAAQ,EAAxB,MAAM;QACa,UAAU;QAGV,OAAO;QAEP,UAAU;KAGrC,EAWF;IARA,6CAA6C;IAC7C,OADW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CACR;IACtB,gDAAgD;IAChD,MADW,GAAG,CAAC,MAAM,CAAC,CACD;IACrB,iBAA6B;IAC7B,iCAA4B;IAC5B,8BAAsB;IACtB,iCAA4B;IAG7B;;;;;;;;OAQG;IACH,YAHa,MAAM,CAKlB;IAED;;;;;;OAMG;IACH,sBAHW,MAAM,QAoBhB;IAED;;;;;;OAMG;IACH,UAJW,MAAM,GACJ,MAAM,GAAC,SAAS,CAK5B;IAED;;;;;;OAMG;IACH,YAHa,MAAM,CAUlB;IAED;;;;;;;;;;;;;OAaG;IACH,aANW,MAAM,GAGJ,MAAM,CAWlB;IAED;;;;;;;;;;;OAWG;IACH,SAHa,MAAM,CAsBlB;IAED;;;;;;OAMG;IACH,aAJW,MAAM,GACJ,OAAO,CAYnB;IAED;;;;OAIG;IACH,cAQC;CACD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-neutral texture residency.
|
|
3
|
+
*
|
|
4
|
+
* There are two separate questions about a texture, and conflating them is
|
|
5
|
+
* what makes a GPU renderer re-upload work it already has:
|
|
6
|
+
*
|
|
7
|
+
* - **which slot is it in, for this draw?** — transient, per-batch, bounded by
|
|
8
|
+
* the shader's sampler count. That is {@link TextureSlotTable}.
|
|
9
|
+
* - **does it exist on the GPU, and is its content current?** — persistent,
|
|
10
|
+
* per-source, bounded by disposal. That is this class.
|
|
11
|
+
*
|
|
12
|
+
* The WebGL backend used to answer both with one field (`boundTextures[unit]`),
|
|
13
|
+
* so dropping a slot assignment destroyed the texture handle and the next draw
|
|
14
|
+
* rebuilt it from scratch — a full re-upload and mip regeneration per quad,
|
|
15
|
+
* once past the batching limit.
|
|
16
|
+
*
|
|
17
|
+
* This class owns the source → record index, the reuse-or-upload decision, and
|
|
18
|
+
* the lifetime bookkeeping. It touches no GL or WebGPU API: each backend
|
|
19
|
+
* supplies `onCreate` / `onUpload` / `onDestroy`, exactly as the slot table
|
|
20
|
+
* takes its binding through callbacks. That keeps the decision logic identical
|
|
21
|
+
* on both backends and testable without a device.
|
|
22
|
+
* @ignore
|
|
23
|
+
*/
|
|
24
|
+
export class TextureStore {
|
|
25
|
+
/**
|
|
26
|
+
* @param {object} [options] - store configuration
|
|
27
|
+
* @param {Function} [options.onCreate] - `(source, options) => handle`, allocate
|
|
28
|
+
* the backing GPU texture for a source seen for the first time
|
|
29
|
+
* @param {Function} [options.onUpload] - `(handle, source, record, options) => handle`,
|
|
30
|
+
* push the source's current content. May return a *replacement* handle when
|
|
31
|
+
* the shape changed and the old one cannot be respecified (immutable
|
|
32
|
+
* storage); returning nothing keeps the existing handle.
|
|
33
|
+
* @param {Function} [options.onDestroy] - `(handle, source)`, release the
|
|
34
|
+
* GPU texture. Called exactly once per handle.
|
|
35
|
+
* @ignore
|
|
36
|
+
*/
|
|
37
|
+
constructor({ onCreate, onUpload, onDestroy }?: {
|
|
38
|
+
onCreate?: Function | undefined;
|
|
39
|
+
onUpload?: Function | undefined;
|
|
40
|
+
onDestroy?: Function | undefined;
|
|
41
|
+
});
|
|
42
|
+
/** @type {Map<object, {handle: *, version: number, generation: number}>} */
|
|
43
|
+
records: Map<object, {
|
|
44
|
+
handle: any;
|
|
45
|
+
version: number;
|
|
46
|
+
generation: number;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Allocate the backing GPU texture for a source seen for the first time.
|
|
50
|
+
* @param {object} source - the image/canvas/resource
|
|
51
|
+
* @param {object} options - the resolve options
|
|
52
|
+
* @returns {*} the new handle
|
|
53
|
+
* @ignore
|
|
54
|
+
*/
|
|
55
|
+
onCreate(source: object, options: object): any;
|
|
56
|
+
/**
|
|
57
|
+
* Push the source's current content. May return a REPLACEMENT handle when
|
|
58
|
+
* the shape changed and the old one cannot be respecified.
|
|
59
|
+
* @param {*} handle - the existing handle
|
|
60
|
+
* @param {object} source - the image/canvas/resource
|
|
61
|
+
* @param {object} record - the resident record
|
|
62
|
+
* @param {object} options - the resolve options
|
|
63
|
+
* @returns {*} a replacement handle, or nothing to keep the existing one
|
|
64
|
+
* @ignore
|
|
65
|
+
*/
|
|
66
|
+
onUpload(handle: any, source: object, record: object, options: object): any;
|
|
67
|
+
/**
|
|
68
|
+
* Release a GPU texture. Called exactly once per handle.
|
|
69
|
+
* @param {*} handle - the handle to release
|
|
70
|
+
* @param {object} source - the source it belonged to
|
|
71
|
+
* @ignore
|
|
72
|
+
*/
|
|
73
|
+
onDestroy(handle: any, source: object): void;
|
|
74
|
+
generation: number;
|
|
75
|
+
/**
|
|
76
|
+
* how many sources are currently resident
|
|
77
|
+
* @returns {number} the record count
|
|
78
|
+
* @ignore
|
|
79
|
+
*/
|
|
80
|
+
get size(): number;
|
|
81
|
+
/**
|
|
82
|
+
* The live record for a source, uploading only when it is genuinely needed:
|
|
83
|
+
* the source has never been seen, its content changed, its handle predates
|
|
84
|
+
* the current context, or the caller forced it.
|
|
85
|
+
*
|
|
86
|
+
* A texture that merely moved to a different slot is NOT a reason to upload
|
|
87
|
+
* — that is the whole point of separating residency from slot assignment.
|
|
88
|
+
* @param {object} source - the image/canvas/resource backing the texture
|
|
89
|
+
* @param {object} [options] - resolution options
|
|
90
|
+
* @param {number} [options.version=0] - the source's content revision; a
|
|
91
|
+
* change from the recorded value forces a re-upload
|
|
92
|
+
* @param {boolean} [options.force=false] - re-upload regardless
|
|
93
|
+
* @returns {{handle: *, version: number, generation: number, uploaded: boolean}}
|
|
94
|
+
* the record, with `uploaded` reporting whether this call did GPU work
|
|
95
|
+
* @ignore
|
|
96
|
+
*/
|
|
97
|
+
getResidentRecord(source: object, options?: {
|
|
98
|
+
version?: number | undefined;
|
|
99
|
+
force?: boolean | undefined;
|
|
100
|
+
}): {
|
|
101
|
+
handle: any;
|
|
102
|
+
version: number;
|
|
103
|
+
generation: number;
|
|
104
|
+
uploaded: boolean;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The record for a source without resolving one, for callers that must not
|
|
108
|
+
* trigger GPU work (bookkeeping, debug, invalidation checks).
|
|
109
|
+
* @param {object} source - the source to look up
|
|
110
|
+
* @returns {object|undefined} the record, or `undefined`
|
|
111
|
+
* @ignore
|
|
112
|
+
*/
|
|
113
|
+
peek(source: object): object | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Release the GPU texture for one source. Driven by the source going away
|
|
116
|
+
* — never by a slot being reassigned, which is exactly the coupling this
|
|
117
|
+
* class exists to break.
|
|
118
|
+
* @param {object} source - the disposed source
|
|
119
|
+
* @returns {boolean} whether a record was held
|
|
120
|
+
* @ignore
|
|
121
|
+
*/
|
|
122
|
+
destroyTexture(source: object): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Drop every record and bump the generation. Called on context or device
|
|
125
|
+
* loss.
|
|
126
|
+
*
|
|
127
|
+
* This CLEARS the store in place — callers must never respond to a restore
|
|
128
|
+
* by constructing a replacement store. Doing so orphans every handle the
|
|
129
|
+
* old one was tracking, so the *second* loss leaks everything it had
|
|
130
|
+
* accumulated since the first. Both WebGL batchers re-run `init()` on
|
|
131
|
+
* restore, which is precisely how that mistake gets made here.
|
|
132
|
+
* @param {boolean} [destroy=false] - whether to release the handles first.
|
|
133
|
+
* Leave `false` for a lost context (the GPU objects are already gone);
|
|
134
|
+
* pass `true` for an orderly teardown.
|
|
135
|
+
* @ignore
|
|
136
|
+
*/
|
|
137
|
+
releaseAll(destroy?: boolean): void;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=texturestore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texturestore.d.ts","sourceRoot":"","sources":["../../../src/video/gpu/texturestore.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH;IACC;;;;;;;;;;;OAWG;IACH,gDAVG;QAA2B,QAAQ;QAER,QAAQ;QAIR,SAAS;KAEpC,EAuBF;IApBA,4EAA4E;IAC5E,SADW,GAAG,CAAC,MAAM,EAAE;QAAC,MAAM,EAAE,GAAC,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,CAAC,CAChD;IAqBzB;;;;;;OAMG;IACH,iBALW,MAAM,WACN,MAAM,GACJ,GAAC,CAOb;IAED;;;;;;;;;OASG;IACH,iBAPW,GAAC,UACD,MAAM,UACN,MAAM,WACN,MAAM,GACJ,GAAC,CASb;IAED;;;;;OAKG;IACH,kBAJW,GAAC,UACD,MAAM,QAMhB;IA3CA,mBAAmB;IA6CpB;;;;OAIG;IACH,YAHa,MAAM,CAKlB;IAED;;;;;;;;;;;;;;;OAeG;IACH,0BATW,MAAM,YAEd;QAAyB,OAAO;QAEN,KAAK;KAC/B,GAAU;QAAC,MAAM,EAAE,GAAC,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAC,CAqC/E;IAED;;;;;;OAMG;IACH,aAJW,MAAM,GACJ,MAAM,GAAC,SAAS,CAK5B;IAED;;;;;;;OAOG;IACH,uBAJW,MAAM,GACJ,OAAO,CAanB;IAED;;;;;;;;;;;;;OAaG;IACH,qBALW,OAAO,QAejB;CACD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-neutral primitive topologies.
|
|
3
|
+
*
|
|
4
|
+
* Names how a stream of vertices is assembled into primitives, in the GPU
|
|
5
|
+
* vocabulary rather than the GL one. Like {@link VertexFormat}, this lets a
|
|
6
|
+
* draw be described without a live rendering context, and lets a backend read
|
|
7
|
+
* the description directly instead of translating enums.
|
|
8
|
+
*
|
|
9
|
+
* This module holds no GL references, so a non-WebGL backend can import it
|
|
10
|
+
* without pulling in the WebGL layer.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* How vertices are assembled into primitives.
|
|
14
|
+
*
|
|
15
|
+
* Five of these are portable across backends. `"line-loop"` and
|
|
16
|
+
* `"triangle-fan"` are **engine extensions** with no modern GPU-API
|
|
17
|
+
* equivalent — they exist because the primitive batcher has always accepted
|
|
18
|
+
* them, and a future backend will have to emulate them (a line loop is a line
|
|
19
|
+
* strip plus a closing segment, which is already how the WebGL path draws it).
|
|
20
|
+
* Prefer {@link PORTABLE_TOPOLOGIES} for anything that must survive a backend
|
|
21
|
+
* change.
|
|
22
|
+
*/
|
|
23
|
+
export type Topology = "point-list" | "line-list" | "line-strip" | "line-loop" | "triangle-list" | "triangle-strip" | "triangle-fan";
|
|
24
|
+
/**
|
|
25
|
+
* The topologies with a direct equivalent in modern GPU APIs.
|
|
26
|
+
*
|
|
27
|
+
* `"line-loop"` and `"triangle-fan"` are deliberately absent — see
|
|
28
|
+
* {@link Topology}.
|
|
29
|
+
*/
|
|
30
|
+
export declare const PORTABLE_TOPOLOGIES: readonly ["point-list", "line-list", "line-strip", "triangle-list", "triangle-strip"];
|
|
31
|
+
/**
|
|
32
|
+
* Whether a value is a supported topology name.
|
|
33
|
+
* @param value - the value to test
|
|
34
|
+
* @returns `true` when `value` names a topology
|
|
35
|
+
*/
|
|
36
|
+
export declare function isTopology(value: unknown): value is Topology;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a topology has a direct equivalent in modern GPU APIs.
|
|
39
|
+
* @param topology - the topology to test
|
|
40
|
+
* @returns `false` for the two engine extensions, which a non-WebGL backend must emulate
|
|
41
|
+
*/
|
|
42
|
+
export declare function isPortableTopology(topology: Topology): boolean;
|
|
43
|
+
//# sourceMappingURL=topology.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../../src/video/gpu/topology.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GACjB,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,WAAW,GACX,eAAe,GACf,gBAAgB,GAChB,cAAc,CAAC;AAElB;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,uFAMQ,CAAC;AAgBzC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAE9D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-neutral vertex attribute formats.
|
|
3
|
+
*
|
|
4
|
+
* A vertex format names a component type and a component count in one token:
|
|
5
|
+
* `"float32x3"` is three 32-bit floats, `"unorm8x4"` is four unsigned bytes
|
|
6
|
+
* normalized to `[0, 1]`. That is everything a backend needs to interpret a
|
|
7
|
+
* slice of an interleaved vertex buffer, which is why it replaces the
|
|
8
|
+
* `size` + `type` + `normalized` triple the WebGL API works in.
|
|
9
|
+
*
|
|
10
|
+
* Naming follows the GPU vocabulary rather than the GL one, because the
|
|
11
|
+
* translation only runs one way: `"unorm8x4"` gives you `4` +
|
|
12
|
+
* `UNSIGNED_BYTE` + `normalized`, whereas `UNSIGNED_BYTE` alone cannot tell
|
|
13
|
+
* you the component count or whether it is normalized. Declaring the format
|
|
14
|
+
* also means a layout no longer needs a live rendering context to be written
|
|
15
|
+
* down — the GL enums are only resolved when a backend consumes it.
|
|
16
|
+
*
|
|
17
|
+
* This module holds no GL references at all, so a non-WebGL backend can
|
|
18
|
+
* import it without pulling in the WebGL layer.
|
|
19
|
+
* @see {@link Batcher#addAttribute}
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The scalar component type underlying a {@link VertexFormat}.
|
|
23
|
+
* @ignore
|
|
24
|
+
*/
|
|
25
|
+
export type VertexScalar = "float32" | "uint8" | "sint8" | "unorm8" | "snorm8" | "uint16" | "sint16" | "unorm16" | "snorm16" | "uint32" | "sint32";
|
|
26
|
+
/**
|
|
27
|
+
* A vertex attribute format: component type and count.
|
|
28
|
+
*
|
|
29
|
+
* The set is deliberately narrower than the full GPU vocabulary — see the
|
|
30
|
+
* module notes for what is excluded and why. Layouts that cannot be spelled
|
|
31
|
+
* here (three-component 8- and 16-bit types, for instance) remain expressible
|
|
32
|
+
* with the {@link Batcher#addAttribute} GL-enum form, which is supported
|
|
33
|
+
* indefinitely.
|
|
34
|
+
*/
|
|
35
|
+
export type VertexFormat = "float32" | "float32x2" | "float32x3" | "float32x4" | "uint8" | "uint8x2" | "uint8x4" | "sint8" | "sint8x2" | "sint8x4" | "unorm8" | "unorm8x2" | "unorm8x4" | "snorm8" | "snorm8x2" | "snorm8x4" | "uint16" | "uint16x2" | "uint16x4" | "sint16" | "sint16x2" | "sint16x4" | "unorm16" | "unorm16x2" | "unorm16x4" | "snorm16" | "snorm16x2" | "snorm16x4" | "uint32" | "uint32x2" | "uint32x3" | "uint32x4" | "sint32" | "sint32x2" | "sint32x3" | "sint32x4";
|
|
36
|
+
/**
|
|
37
|
+
* What a {@link VertexFormat} resolves to.
|
|
38
|
+
* @ignore
|
|
39
|
+
*/
|
|
40
|
+
export interface VertexFormatInfo {
|
|
41
|
+
/** number of components (1, 2, 3 or 4) */
|
|
42
|
+
components: 1 | 2 | 3 | 4;
|
|
43
|
+
/** total size of the attribute in bytes */
|
|
44
|
+
bytes: number;
|
|
45
|
+
/** whether integer values are scaled into `[0, 1]` / `[-1, 1]` when read by a shader */
|
|
46
|
+
normalized: boolean;
|
|
47
|
+
/** the underlying scalar type */
|
|
48
|
+
scalar: VertexScalar;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Every supported format, resolved.
|
|
52
|
+
*
|
|
53
|
+
* `bytes` is computed as `components × scalar size`, which is the same
|
|
54
|
+
* arithmetic the GL-enum path has always used — so a layout expressed either
|
|
55
|
+
* way produces an identical stride.
|
|
56
|
+
* @ignore
|
|
57
|
+
*/
|
|
58
|
+
export declare const VERTEX_FORMATS: Record<VertexFormat, VertexFormatInfo>;
|
|
59
|
+
/**
|
|
60
|
+
* Whether a value is a supported vertex format name.
|
|
61
|
+
* @param value - the value to test
|
|
62
|
+
* @returns `true` when `value` names a format in {@link VERTEX_FORMATS}
|
|
63
|
+
*/
|
|
64
|
+
export declare function isVertexFormat(value: unknown): value is VertexFormat;
|
|
65
|
+
/**
|
|
66
|
+
* Resolve a vertex format to its component count, size and normalization.
|
|
67
|
+
* @param format - the format to resolve
|
|
68
|
+
* @returns the resolved description
|
|
69
|
+
* @throws {Error} when `format` is not a supported format name
|
|
70
|
+
*/
|
|
71
|
+
export declare function resolveVertexFormat(format: VertexFormat): VertexFormatInfo;
|
|
72
|
+
//# sourceMappingURL=vertexformat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertexformat.d.ts","sourceRoot":"","sources":["../../../src/video/gpu/vertexformat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GACrB,SAAS,GACT,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,QAAQ,GACR,QAAQ,CAAC;AAEZ;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAErB,SAAS,GACT,WAAW,GACX,WAAW,GACX,WAAW,GAEX,OAAO,GACP,SAAS,GACT,SAAS,GACT,OAAO,GACP,SAAS,GACT,SAAS,GAET,QAAQ,GACR,UAAU,GACV,UAAU,GACV,QAAQ,GACR,UAAU,GACV,UAAU,GAEV,QAAQ,GACR,UAAU,GACV,UAAU,GACV,QAAQ,GACR,UAAU,GACV,UAAU,GAEV,SAAS,GACT,WAAW,GACX,WAAW,GACX,SAAS,GACT,WAAW,GACX,WAAW,GAEX,QAAQ,GACR,UAAU,GACV,UAAU,GACV,UAAU,GACV,QAAQ,GACR,UAAU,GACV,UAAU,GACV,UAAU,CAAC;AAEd;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,0CAA0C;IAC1C,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,UAAU,EAAE,OAAO,CAAC;IACpB,iCAAiC;IACjC,MAAM,EAAE,YAAY,CAAC;CACrB;AA0DD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,YAAY,EAAE,gBAAgB,CA0CjE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,CAS1E"}
|
|
@@ -77,17 +77,26 @@ export class Gradient {
|
|
|
77
77
|
*/
|
|
78
78
|
toCanvasGradient(context: CanvasRenderingContext2D): CanvasGradient;
|
|
79
79
|
/**
|
|
80
|
-
* Render the gradient
|
|
81
|
-
* Uses the original gradient coordinates so the
|
|
82
|
-
*
|
|
80
|
+
* Render the gradient into the fixed-resolution shared bake target for
|
|
81
|
+
* the given draw rect. Uses the original gradient coordinates so the
|
|
82
|
+
* result matches Canvas 2D behavior. Rects larger than the bake target
|
|
83
|
+
* are rasterized scaled-down; the destination quad stretches them back,
|
|
84
|
+
* which is visually equivalent (linear stop interpolation × linear
|
|
85
|
+
* texture filtering). The returned `width`/`height` describe the region
|
|
86
|
+
* of the canvas the caller must use as the drawImage SOURCE rect.
|
|
87
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - the active renderer (used to invalidate the GPU texture)
|
|
83
88
|
* @param {number} x - draw rect x
|
|
84
89
|
* @param {number} y - draw rect y
|
|
85
90
|
* @param {number} width - draw rect width
|
|
86
91
|
* @param {number} height - draw rect height
|
|
87
|
-
* @returns {HTMLCanvasElement|OffscreenCanvas} the
|
|
92
|
+
* @returns {{canvas: HTMLCanvasElement|OffscreenCanvas, width: number, height: number}} the shared gradient canvas + the used source-rect size
|
|
88
93
|
* @ignore
|
|
89
94
|
*/
|
|
90
|
-
toCanvas(renderer: CanvasRenderer | WebGLRenderer, x: number, y: number, width: number, height: number):
|
|
95
|
+
toCanvas(renderer: CanvasRenderer | WebGLRenderer, x: number, y: number, width: number, height: number): {
|
|
96
|
+
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
97
|
+
width: number;
|
|
98
|
+
height: number;
|
|
99
|
+
};
|
|
91
100
|
/**
|
|
92
101
|
* Get the interpolated color at a given position along the gradient.
|
|
93
102
|
* Useful for procedural effects like trails that need per-segment colors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gradient.d.ts","sourceRoot":"","sources":["../../src/video/gradient.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gradient.d.ts","sourceRoot":"","sources":["../../src/video/gradient.js"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH;IACC;;;OAGG;IACH,kBAHW,QAAQ,GAAC,QAAQ,UACjB,MAAM,EAAE,EAqDlB;IAlDA;;;OAGG;IACH,cAAc;IACd,YAA2B;IAE3B,0BAAgB;IAEhB;;;;OAIG;IACH,QAHU,MAAM,EAAE,CAGE;IAEpB;;;;OAIG;IACH,YAHU,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,CAG5B;IAEpB;;;;OAIG;IACH,iBAHU,cAAc,GAAC,SAAS,CAGF;IAEhC;;;;OAIG;IACH,eAHU,kBAAkB,GAAC,SAAS,CAGR;IAE9B;;;;OAIG;IACH,QAHU,OAAO,CAGC;IAElB;;;;OAIG;IACH,cAHU;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAC,EAAE,GAAC,IAAI,CAGvB;IAGzB;;;;;;;;;OASG;IACH,qBARW,MAAM,SACN,KAAK,GAAC,MAAM,GACV,QAAQ,CA0BpB;IAED;;;;;OAKG;IACH,0BAJW,wBAAwB,GACtB,cAAc,CAiC1B;IAED;;;;;;;;;;;;;;;OAeG;IACH,mBARW,cAAc,GAAC,aAAa,KAC5B,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,GACJ;QAAC,MAAM,EAAE,iBAAiB,GAAC,eAAe,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAwFtF;IAED;;;;;;;;;;;OAWG;IACH,qBATW,MAAM,OACN,KAAK,GACH,KAAK,CA+CjB;IAED;;;OAGG;IACH,0BAWC;IAED;;OAEG;IACH,gBAOC;CACD;+BA1V8B,sCAAsC;2BAF7C,kBAAkB"}
|