melonjs 19.7.1 → 19.9.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 +21 -6
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +1 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/settings.d.ts +34 -0
- package/build/application/settings.d.ts.map +1 -1
- package/build/audio/audio.d.ts +1 -1
- package/build/audio/audio.d.ts.map +1 -1
- package/build/audio/backend.d.ts +21 -2
- package/build/audio/backend.d.ts.map +1 -1
- package/build/audio/playback.d.ts +8 -28
- package/build/audio/playback.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +49 -0
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/geometries/path2d.d.ts +188 -75
- package/build/geometries/path2d.d.ts.map +1 -1
- package/build/geometries/rectangle.d.ts.map +1 -1
- package/build/index.d.ts +11 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +19170 -13625
- package/build/index.js.map +4 -4
- package/build/level/gltf/GLTFModel.d.ts +173 -0
- package/build/level/gltf/GLTFModel.d.ts.map +1 -0
- package/build/level/gltf/GLTFScene.d.ts +84 -0
- package/build/level/gltf/GLTFScene.d.ts.map +1 -0
- package/build/level/gltf/gltf_sampler.d.ts +49 -0
- package/build/level/gltf/gltf_sampler.d.ts.map +1 -0
- package/build/level/level.d.ts +7 -3
- package/build/level/level.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +5 -0
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/{renderable → lighting}/light2d.d.ts +79 -78
- package/build/lighting/light2d.d.ts.map +1 -0
- package/build/lighting/light3d.d.ts +86 -0
- package/build/lighting/light3d.d.ts.map +1 -0
- package/build/loader/cache.d.ts +2 -0
- package/build/loader/cache.d.ts.map +1 -1
- package/build/loader/loader.d.ts +156 -8
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/fetchdata.d.ts +14 -0
- package/build/loader/parsers/fetchdata.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts +71 -0
- package/build/loader/parsers/gltf.d.ts.map +1 -0
- package/build/loader/parsers/mtl.d.ts.map +1 -1
- package/build/loader/parsers/shader.d.ts +47 -0
- package/build/loader/parsers/shader.d.ts.map +1 -0
- package/build/loader/parsers/video.d.ts.map +1 -1
- package/build/math/color.d.ts.map +1 -1
- package/build/math/math.d.ts +2 -2
- package/build/math/matrix2d.d.ts.map +1 -1
- package/build/math/noise.d.ts +141 -0
- package/build/math/noise.d.ts.map +1 -0
- package/build/math/observableVector2d.d.ts +1 -1
- package/build/math/observableVector2d.d.ts.map +1 -1
- package/build/math/observableVector3d.d.ts +1 -1
- package/build/math/observableVector3d.d.ts.map +1 -1
- package/build/math/vector2d.d.ts +1 -1
- package/build/math/vector2d.d.ts.map +1 -1
- package/build/math/vector3d.d.ts +1 -1
- package/build/math/vector3d.d.ts.map +1 -1
- package/build/math/vertex.d.ts +25 -0
- package/build/math/vertex.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +4 -3
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/broadphase/aabb3d.d.ts +23 -2
- package/build/physics/broadphase/aabb3d.d.ts.map +1 -1
- package/build/renderable/anchorPoint.d.ts +80 -0
- package/build/renderable/anchorPoint.d.ts.map +1 -0
- package/build/renderable/animation.d.ts +41 -0
- package/build/renderable/animation.d.ts.map +1 -0
- package/build/renderable/collectable.d.ts +7 -1
- package/build/renderable/collectable.d.ts.map +1 -1
- package/build/renderable/container.d.ts +0 -1
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +5 -2
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/frameAnimation.d.ts +154 -0
- package/build/renderable/frameAnimation.d.ts.map +1 -0
- package/build/renderable/imagelayer.d.ts +5 -2
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +175 -6
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/nineslicesprite.d.ts +5 -7
- package/build/renderable/nineslicesprite.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +28 -1
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +84 -34
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +350 -0
- package/build/renderable/sprite3d.d.ts.map +1 -0
- package/build/renderable/text/bitmaptext.d.ts +24 -12
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts +24 -1
- package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +50 -12
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/state/stage.d.ts +20 -1
- package/build/state/stage.d.ts.map +1 -1
- package/build/system/event.d.ts +18 -2
- package/build/system/event.d.ts.map +1 -1
- package/build/video/buffer/vertex.d.ts +7 -0
- package/build/video/buffer/vertex.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +4 -0
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/renderer.d.ts +62 -1
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +17 -6
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
- package/build/video/texture/atlas.d.ts +3 -2
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +55 -6
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/texture/frametexture.d.ts +73 -0
- package/build/video/texture/frametexture.d.ts.map +1 -0
- package/build/video/texture/noise_texture2d.d.ts +176 -0
- package/build/video/texture/noise_texture2d.d.ts.map +1 -0
- package/build/video/texture/parser/aseprite.d.ts.map +1 -1
- package/build/video/texture/texture2d.d.ts +83 -0
- package/build/video/texture/texture2d.d.ts.map +1 -0
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +18 -0
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -0
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +30 -4
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +39 -3
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +52 -11
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +13 -0
- package/build/video/webgl/buffer/index.d.ts.map +1 -1
- package/build/video/webgl/effects/hologram.d.ts +0 -5
- package/build/video/webgl/effects/hologram.d.ts.map +1 -1
- package/build/video/webgl/effects/shine.d.ts +1 -6
- package/build/video/webgl/effects/shine.d.ts.map +1 -1
- package/build/video/webgl/glshader.d.ts +29 -0
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/lighting/pack3d.d.ts +32 -0
- package/build/video/webgl/lighting/pack3d.d.ts.map +1 -0
- package/build/video/webgl/shadereffect.d.ts +183 -0
- package/build/video/webgl/shadereffect.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +59 -1
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +5 -5
- package/build/renderable/light2d.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/video/texture/cache.js"],"names":[],"mappings":";AAeA;;;GAGG;AACH;IACC;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/video/texture/cache.js"],"names":[],"mappings":";AAeA;;;GAGG;AACH;IACC;;OAEG;IACH,8CA4BC;IA1BA,cAAwB;IAExB,qBAAgC;IAChC,sBAAuB;IAavB,qBAAsB;IACtB,oBAA0B;IAM1B,6BAA8B;IAC9B,iBAAwB;IAIzB;;OAEG;IACH,cAKC;IAED;;OAEG;IACH,8BA4BC;IAED;;;;;;;OAOG;IACH,kBAHW,MAAM,QAKhB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,QAUhB;IAED;;;;OAIG;IACH,6BAIC;IAED;;;;;;;;;;OAUG;IACH,oCAaC;IAED;;;;;;;;OAQG;IACH,iCASC;IAED;;;;;;;;;;OAUG;IACH,+BATW,MAAM,OAuBhB;IAED;;;;;;;;OAQG;IACH,kCAIC;IAED;;;;OAIG;IACH,gCAFW,MAAM,OAShB;IAED;;;OAGG;IACH,yCAEC;IAED;;OAEG;IACH,yBAEC;IAED;;;OAGG;IACH,iCAwCC;IAED;;OAEG;IACH,yBAkBC;IAED;;OAEG;IACH,gCAcC;CACD;8BAjV6B,+BAA+B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A GPU-resident texture holding a captured frame — the value returned by
|
|
3
|
+
* {@link WebGLRenderer#toFrameTexture}. Its backing is a live `WebGLTexture`
|
|
4
|
+
* that the renderer refreshes **in place** on each capture, so a shader that
|
|
5
|
+
* has bound it once (via {@link ShaderEffect#setTexture}) keeps sampling the
|
|
6
|
+
* latest frame with no re-bind.
|
|
7
|
+
*
|
|
8
|
+
* Not part of the public class surface: obtain instances from
|
|
9
|
+
* `renderer.toFrameTexture()` and treat them as opaque {@link Texture2d}
|
|
10
|
+
* values. The `isGPUResident` flag is the discriminant `setTexture` uses to
|
|
11
|
+
* take its live-bind path (bind the existing handle) instead of uploading a
|
|
12
|
+
* static copy.
|
|
13
|
+
* @augments Texture2d
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
export class FrameTexture extends Texture2d {
|
|
17
|
+
/**
|
|
18
|
+
* @param {WebGLRenderer} renderer - the owning renderer (for the GL context)
|
|
19
|
+
* @param {number} width - capture width in pixels
|
|
20
|
+
* @param {number} height - capture height in pixels
|
|
21
|
+
*/
|
|
22
|
+
constructor(renderer: WebGLRenderer, width: number, height: number);
|
|
23
|
+
_renderer: WebGLRenderer;
|
|
24
|
+
/** @type {number} */
|
|
25
|
+
width: number;
|
|
26
|
+
/** @type {number} */
|
|
27
|
+
height: number;
|
|
28
|
+
/**
|
|
29
|
+
* the live backing texture, (re)filled by `renderer.toFrameTexture` and
|
|
30
|
+
* bound (never re-uploaded) by consumers
|
|
31
|
+
* @type {WebGLTexture|null}
|
|
32
|
+
*/
|
|
33
|
+
glTexture: WebGLTexture | null;
|
|
34
|
+
/**
|
|
35
|
+
* marks this as a live GPU-resident source — see {@link ShaderEffect#setTexture}
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
*/
|
|
38
|
+
isGPUResident: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The opaque GPU-resident backing — itself.
|
|
41
|
+
* @returns {FrameTexture}
|
|
42
|
+
*/
|
|
43
|
+
getTexture(): FrameTexture;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The Canvas-renderer counterpart of {@link FrameTexture}: a captured frame
|
|
47
|
+
* backed by an offscreen `<canvas>` copy of the drawing buffer, keeping the
|
|
48
|
+
* `toFrameTexture` family renderer-complete. A drawable source (not
|
|
49
|
+
* GPU-resident), so it flows through the normal image path; custom shaders
|
|
50
|
+
* don't run under the Canvas renderer, so this exists for API parity and
|
|
51
|
+
* CPU-side reuse (e.g. drawing the captured frame back onto the scene).
|
|
52
|
+
* @augments Texture2d
|
|
53
|
+
* @ignore
|
|
54
|
+
*/
|
|
55
|
+
export class CanvasFrameTexture extends Texture2d {
|
|
56
|
+
/**
|
|
57
|
+
* @param {HTMLCanvasElement|OffscreenCanvas} canvas - the backing copy
|
|
58
|
+
*/
|
|
59
|
+
constructor(canvas: HTMLCanvasElement | OffscreenCanvas);
|
|
60
|
+
/** @type {HTMLCanvasElement|OffscreenCanvas} */
|
|
61
|
+
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
62
|
+
/** @type {number} */
|
|
63
|
+
width: number;
|
|
64
|
+
/** @type {number} */
|
|
65
|
+
height: number;
|
|
66
|
+
/**
|
|
67
|
+
* The backing canvas copy.
|
|
68
|
+
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
69
|
+
*/
|
|
70
|
+
getTexture(): HTMLCanvasElement | OffscreenCanvas;
|
|
71
|
+
}
|
|
72
|
+
import Texture2d from "./texture2d.ts";
|
|
73
|
+
//# sourceMappingURL=frametexture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frametexture.d.ts","sourceRoot":"","sources":["../../../src/video/texture/frametexture.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;OAIG;IACH,sBAJW,aAAa,SACb,MAAM,UACN,MAAM,EAoBhB;IAhBA,yBAAyB;IACzB,qBAAqB;IACrB,OADW,MAAM,CACC;IAClB,qBAAqB;IACrB,QADW,MAAM,CACG;IACpB;;;;OAIG;IACH,WAFU,YAAY,GAAC,IAAI,CAEN;IACrB;;;OAGG;IACH,eAFU,OAAO,CAEQ;IAG1B;;;OAGG;IACH,cAFa,YAAY,CAIxB;CAaD;AAED;;;;;;;;;GASG;AACH;IACC;;OAEG;IACH,oBAFW,iBAAiB,GAAC,eAAe,EAU3C;IANA,gDAAgD;IAChD,QADW,iBAAiB,GAAC,eAAe,CACxB;IACpB,qBAAqB;IACrB,OADW,MAAM,CACQ;IACzB,qBAAqB;IACrB,QADW,MAAM,CACU;IAG5B;;;OAGG;IACH,cAFa,iBAAiB,GAAC,eAAe,CAI7C;CACD;sBA/FqB,gBAAgB"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
export default NoiseTexture2d;
|
|
2
|
+
/**
|
|
3
|
+
* A {@link Texture2d} that bakes a {@link Noise} field into a drawable canvas —
|
|
4
|
+
* usable directly as a sprite image, a normal map, an image layer, or a custom
|
|
5
|
+
* shader sampler.
|
|
6
|
+
*
|
|
7
|
+
* The bake runs on the CPU (renderer-agnostic, works under both the Canvas and
|
|
8
|
+
* WebGL backends) and produces an `HTMLCanvasElement` returned by
|
|
9
|
+
* {@link NoiseTexture2d#getTexture}. Three output modes:
|
|
10
|
+
* - **grayscale** (default) — the noise value mapped to `[0, 255]`.
|
|
11
|
+
* - **colorRamp** — the noise value mapped through a {@link Gradient}.
|
|
12
|
+
* - **asNormalMap** — the noise treated as a height field and encoded as
|
|
13
|
+
* tangent-space surface normals (RGB), for per-pixel lighting via
|
|
14
|
+
* {@link Sprite#normalMap} + {@link Light2d}.
|
|
15
|
+
*
|
|
16
|
+
* With `seamless: true` the texture's edges are cross-faded so it tiles with a
|
|
17
|
+
* much-reduced seam (an approximate, not pixel-exact, wrap); `seamlessBlendSkirt`
|
|
18
|
+
* controls how wide that edge blend band is. With `animated: true` the field is
|
|
19
|
+
* sampled in 3D (`getNoise3d`) using an internal `time` as the third axis —
|
|
20
|
+
* call {@link NoiseTexture2d#update} from your update loop to evolve it. Each
|
|
21
|
+
* re-bake bumps a `version` the renderer reads, so the GPU texture re-uploads
|
|
22
|
+
* automatically (and only when it actually changed — the three.js
|
|
23
|
+
* `Texture.needsUpdate` model).
|
|
24
|
+
*
|
|
25
|
+
* Note: live re-upload is currently wired through the lit **normal-map**
|
|
26
|
+
* pipeline ({@link Sprite#normalMap} + {@link Light2d}). An `animated` texture
|
|
27
|
+
* used as a plain color `image` bakes a static snapshot — the color texture
|
|
28
|
+
* cache does not yet honor `version` — so animate normals, not albedos, for now.
|
|
29
|
+
* @augments Texture2d
|
|
30
|
+
* @category Game Objects
|
|
31
|
+
* @example
|
|
32
|
+
* // a seamless water normal map fed to a lit sprite
|
|
33
|
+
* const ripples = new me.NoiseTexture2d({
|
|
34
|
+
* width: 256, height: 256,
|
|
35
|
+
* type: "simplex", octaves: 4, frequency: 0.03,
|
|
36
|
+
* seamless: true, asNormalMap: true, bumpStrength: 2, animated: true, speed: 0.6,
|
|
37
|
+
* });
|
|
38
|
+
* const water = new me.Sprite(x, y, { image: albedo, normalMap: ripples });
|
|
39
|
+
* // drive it yourself from your Stage's update(dt):
|
|
40
|
+
* ripples.update(dt);
|
|
41
|
+
*/
|
|
42
|
+
declare class NoiseTexture2d extends Texture2d {
|
|
43
|
+
/**
|
|
44
|
+
* @param {object} [settings] - configuration; any {@link Noise} setting
|
|
45
|
+
* (`type`, `seed`, `frequency`/`scale`, `octaves`, `gain`/`persistence`,
|
|
46
|
+
* `lacunarity`, `fractalType`, domain-warp settings) is forwarded when no
|
|
47
|
+
* `noise` instance is given.
|
|
48
|
+
* @param {number} [settings.width=256] - baked texture width in pixels
|
|
49
|
+
* @param {number} [settings.height=256] - baked texture height in pixels
|
|
50
|
+
* @param {Noise} [settings.noise] - an existing {@link Noise} to bake; when
|
|
51
|
+
* omitted one is built from the forwarded settings
|
|
52
|
+
* @param {boolean} [settings.seamless=false] - tile cleanly in both axes
|
|
53
|
+
* @param {number} [settings.seamlessBlendSkirt=0.1] - edge blend band width
|
|
54
|
+
* as a fraction (0..1) of the smaller dimension, when `seamless`
|
|
55
|
+
* @param {boolean} [settings.invert=false] - invert the noise value (`1 - v`)
|
|
56
|
+
* @param {boolean} [settings.asNormalMap=false] - encode as a normal map
|
|
57
|
+
* @param {number} [settings.bumpStrength=1] - normal steepness when `asNormalMap`
|
|
58
|
+
* @param {Gradient} [settings.colorRamp] - map the noise value to a color
|
|
59
|
+
* @param {boolean} [settings.animated=false] - sample in 3D (`getNoise3d`)
|
|
60
|
+
* using an internal `time` as the third axis, advanced by {@link NoiseTexture2d#update}
|
|
61
|
+
* @param {number} [settings.speed=1] - animation speed in noise z-units per
|
|
62
|
+
* second (only used while `animated`)
|
|
63
|
+
*/
|
|
64
|
+
constructor(settings?: {
|
|
65
|
+
width?: number | undefined;
|
|
66
|
+
height?: number | undefined;
|
|
67
|
+
noise?: Noise | undefined;
|
|
68
|
+
seamless?: boolean | undefined;
|
|
69
|
+
seamlessBlendSkirt?: number | undefined;
|
|
70
|
+
invert?: boolean | undefined;
|
|
71
|
+
asNormalMap?: boolean | undefined;
|
|
72
|
+
bumpStrength?: number | undefined;
|
|
73
|
+
colorRamp?: any;
|
|
74
|
+
animated?: boolean | undefined;
|
|
75
|
+
speed?: number | undefined;
|
|
76
|
+
});
|
|
77
|
+
/** baked texture width in pixels @type {number} */
|
|
78
|
+
width: number;
|
|
79
|
+
/** baked texture height in pixels @type {number} */
|
|
80
|
+
height: number;
|
|
81
|
+
/** the noise field baked by this texture @type {Noise} */
|
|
82
|
+
noise: Noise;
|
|
83
|
+
/** tile cleanly in both axes @type {boolean} */
|
|
84
|
+
seamless: boolean;
|
|
85
|
+
/** edge blend band width (0..1 of the smaller dimension) @type {number} */
|
|
86
|
+
seamlessBlendSkirt: number;
|
|
87
|
+
/** invert the noise value @type {boolean} */
|
|
88
|
+
invert: boolean;
|
|
89
|
+
/** encode the field as a tangent-space normal map @type {boolean} */
|
|
90
|
+
asNormalMap: boolean;
|
|
91
|
+
/** normal steepness when `asNormalMap` @type {number} */
|
|
92
|
+
bumpStrength: number;
|
|
93
|
+
/** optional color ramp applied to the noise value @type {Gradient|null} */
|
|
94
|
+
colorRamp: Gradient | null;
|
|
95
|
+
/** sample the field in 3D using `time` as the third axis @type {boolean} */
|
|
96
|
+
animated: boolean;
|
|
97
|
+
/** animation speed in noise z-units per second @type {number} */
|
|
98
|
+
speed: number;
|
|
99
|
+
/** the current animation time (third sampling axis) @type {number} */
|
|
100
|
+
time: number;
|
|
101
|
+
/** the baked output canvas (reused across re-bakes) @type {HTMLCanvasElement|null} @ignore */
|
|
102
|
+
_canvas: HTMLCanvasElement | null;
|
|
103
|
+
/** reused ImageData scratch (avoids a per-bake allocation) @type {ImageData|null} @ignore */
|
|
104
|
+
_imageData: ImageData | null;
|
|
105
|
+
/** reused height-field scratch (avoids a per-bake allocation) @type {Float32Array|null} @ignore */
|
|
106
|
+
_heights: Float32Array | null;
|
|
107
|
+
/** content revision, bumped on every bake and stamped on the canvas so
|
|
108
|
+
* the renderer re-uploads the GPU texture when it changes @type {number} @ignore */
|
|
109
|
+
_version: number;
|
|
110
|
+
/**
|
|
111
|
+
* The current content revision, bumped on every {@link NoiseTexture2d#bake}.
|
|
112
|
+
* Also stamped on the baked canvas (`getTexture().version`) so the renderer
|
|
113
|
+
* re-uploads the GPU texture only when it actually changed.
|
|
114
|
+
* @returns {number}
|
|
115
|
+
*/
|
|
116
|
+
get version(): number;
|
|
117
|
+
/**
|
|
118
|
+
* (Re)bake the texture from the current settings into the (reused) output
|
|
119
|
+
* canvas. Called once on construction; {@link NoiseTexture2d#update} calls it
|
|
120
|
+
* again per frame for animated textures.
|
|
121
|
+
* @returns {NoiseTexture2d} this texture for chaining
|
|
122
|
+
*/
|
|
123
|
+
bake(): NoiseTexture2d;
|
|
124
|
+
/**
|
|
125
|
+
* Advance an animated texture by `dt` milliseconds and re-bake it. The
|
|
126
|
+
* re-bake bumps the texture's `version`, so the renderer re-uploads the GPU
|
|
127
|
+
* texture automatically on the next draw — no renderer/app handle needed.
|
|
128
|
+
*
|
|
129
|
+
* This is NOT auto-called by the engine; drive it from your own update loop
|
|
130
|
+
* (e.g. {@link Stage#update}) for animated textures. No-op when not `animated`.
|
|
131
|
+
* @param {number} dt - elapsed time since the last update, in milliseconds
|
|
132
|
+
* @returns {NoiseTexture2d} this texture for chaining
|
|
133
|
+
*/
|
|
134
|
+
update(dt: number): NoiseTexture2d;
|
|
135
|
+
/**
|
|
136
|
+
* Raw noise sample at a texture pixel (2D, or 3D when animated). The time
|
|
137
|
+
* axis is divided by the noise frequency so that, after `getNoise3d` scales
|
|
138
|
+
* all coords by frequency, the field evolves at `speed` noise-units/second —
|
|
139
|
+
* decoupled from the spatial frequency (otherwise low-frequency textures
|
|
140
|
+
* would animate imperceptibly slowly).
|
|
141
|
+
* @ignore
|
|
142
|
+
*/
|
|
143
|
+
_rawNoise(x: any, y: any): number;
|
|
144
|
+
/**
|
|
145
|
+
* x-axis seamless blend: in the right skirt band, cross-fade toward the
|
|
146
|
+
* wrapped (period-shifted) sample so the left and right edges meet.
|
|
147
|
+
* @ignore
|
|
148
|
+
*/
|
|
149
|
+
_blendX(x: any, y: any, w: any, sk: any): any;
|
|
150
|
+
/**
|
|
151
|
+
* Sample the noise into a `[0, 1]` height field. When `seamless`, a skirt
|
|
152
|
+
* cross-fade near the far edges blends opposite edges so the texture tiles
|
|
153
|
+
* with a much-reduced seam.
|
|
154
|
+
* @returns {Float32Array} the per-pixel height field (length `width*height`)
|
|
155
|
+
* @ignore
|
|
156
|
+
*/
|
|
157
|
+
_buildHeightField(): Float32Array;
|
|
158
|
+
/** @ignore */
|
|
159
|
+
_writeGrayscale(data: any, heights: any): void;
|
|
160
|
+
/** @ignore */
|
|
161
|
+
_writeColorRamp(data: any, heights: any): void;
|
|
162
|
+
/**
|
|
163
|
+
* Encode the height field as a tangent-space normal map (RGB), with screen-Y
|
|
164
|
+
* flipped to normal-map Y-up so it round-trips through the lit shader's
|
|
165
|
+
* `rgb * 2 - 1` decode. Neighbor samples wrap when `seamless`.
|
|
166
|
+
* @ignore
|
|
167
|
+
*/
|
|
168
|
+
_writeNormalMap(data: any, heights: any): void;
|
|
169
|
+
/**
|
|
170
|
+
* @returns {HTMLCanvasElement} the baked texture canvas
|
|
171
|
+
*/
|
|
172
|
+
getTexture(): HTMLCanvasElement;
|
|
173
|
+
}
|
|
174
|
+
import Texture2d from "./texture2d.ts";
|
|
175
|
+
import { Noise } from "../../math/noise.ts";
|
|
176
|
+
//# sourceMappingURL=noise_texture2d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noise_texture2d.d.ts","sourceRoot":"","sources":["../../../src/video/texture/noise_texture2d.js"],"names":[],"mappings":";AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH;IACC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,uBAhBG;QAA0B,KAAK;QACL,MAAM;QACP,KAAK;QAEH,QAAQ;QACT,kBAAkB;QAEjB,MAAM;QACN,WAAW;QACZ,YAAY;QACV,SAAS;QACV,QAAQ;QAET,KAAK;KAEjC,EA4CA;IAxCA,mDAAmD;IACnD,OADyC,MAAM,CACb;IAClC,oDAAoD;IACpD,QAD0C,MAAM,CACZ;IACpC,0DAA0D;IAC1D,OADiD,KAAK,CAEiB;IACvE,gDAAgD;IAChD,UADqC,OAAO,CACF;IAC1C,2EAA2E;IAC3E,oBADiE,MAAM,CAItE;IACD,6CAA6C;IAC7C,QADkC,OAAO,CACH;IACtC,qEAAqE;IACrE,aAD0D,OAAO,CACjB;IAChD,yDAAyD;IACzD,cAD+C,MAAM,CACL;IAChD,2EAA2E;IAC3E,WAD0D,QAAQ,GAAC,IAAI,CAC5B;IAC3C,4EAA4E;IAC5E,UADiE,OAAO,CAC9B;IAC1C,iEAAiE;IACjE,OADuD,MAAM,CAC7B;IAChC,sEAAsE;IACtE,MAD4D,MAAM,CACrD;IAEb,8FAA8F;IAC9F,SAD4D,iBAAiB,GAAC,IAAI,CAC/D;IACnB,6FAA6F;IAC7F,YADmE,SAAS,GAAC,IAAI,CAC3D;IACtB,mGAAmG;IACnG,UADsE,YAAY,GAAC,IAAI,CACnE;IACpB;wFACoF;IACpF,UADkE,MAAM,CACvD;IAKlB;;;;;OAKG;IACH,eAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,QAFa,cAAc,CAiC1B;IAED;;;;;;;;;OASG;IACH,WAHW,MAAM,GACJ,cAAc,CAQ1B;IAED;;;;;;;OAOG;IACH,kCAMC;IAED;;;;OAIG;IACH,8CAOC;IAED;;;;;;OAMG;IACH,qBAHa,YAAY,CA2CxB;IAED,cAAc;IACd,+CASC;IAED,cAAc;IACd,+CAWC;IAED;;;;;OAKG;IACH,+CA+BC;IAED;;OAEG;IACH,cAFa,iBAAiB,CAI7B;CAcD;sBA5VqB,gBAAgB;sBAFhB,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aseprite.d.ts","sourceRoot":"","sources":["../../../../src/video/texture/parser/aseprite.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,oCALW,MAAM,gBACN,YAAY,GACV,MAAM,
|
|
1
|
+
{"version":3,"file":"aseprite.d.ts","sourceRoot":"","sources":["../../../../src/video/texture/parser/aseprite.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,oCALW,MAAM,gBACN,YAAY,GACV,MAAM,CAsFlB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time-only brand key; no runtime value can hold it.
|
|
3
|
+
* @ignore
|
|
4
|
+
*/
|
|
5
|
+
declare const gpuResidentBrand: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* An opaque, GPU-resident texture backing — the source a GPU-resident
|
|
8
|
+
* {@link Texture2d} resolves to (for example the framebuffer copy
|
|
9
|
+
* {@link WebGLRenderer#toFrameTexture} produces). Such a backing uploads/binds
|
|
10
|
+
* itself through the texture cache instead of being read back to the CPU. Its
|
|
11
|
+
* concrete shape is an engine internal that may change between releases:
|
|
12
|
+
* obtain values from the engine and pass them back to the engine — do not
|
|
13
|
+
* construct or inspect them.
|
|
14
|
+
*
|
|
15
|
+
* Nominally branded with a `unique symbol`, so only engine-provided values
|
|
16
|
+
* satisfy the type — a plain object is NOT assignable, keeping
|
|
17
|
+
* {@link Texture2dSource} (and {@link Texture2d#getTexture}) honestly typed.
|
|
18
|
+
*/
|
|
19
|
+
export interface GPUResidentTexture {
|
|
20
|
+
/**
|
|
21
|
+
* Phantom nominal brand — never present at runtime.
|
|
22
|
+
* @ignore
|
|
23
|
+
*/
|
|
24
|
+
readonly [gpuResidentBrand]: true;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The backing source a {@link Texture2d} resolves to through
|
|
28
|
+
* {@link Texture2d#getTexture}: a drawable (canvas/image) for CPU-backed
|
|
29
|
+
* assets, or an opaque {@link GPUResidentTexture} for GPU-resident ones.
|
|
30
|
+
*/
|
|
31
|
+
export type Texture2dSource = HTMLCanvasElement | HTMLImageElement | OffscreenCanvas | ImageBitmap | GPUResidentTexture;
|
|
32
|
+
/**
|
|
33
|
+
* Abstract base for a 2D texture asset — an object that owns a texture
|
|
34
|
+
* source and can be used anywhere the engine expects an image:
|
|
35
|
+
* {@link Sprite#image}, {@link Sprite#normalMap}, an {@link ImageLayer}, or
|
|
36
|
+
* bound as a sampler uniform in a custom shader (see
|
|
37
|
+
* {@link ShaderEffect#setTexture}).
|
|
38
|
+
*
|
|
39
|
+
* A `Texture2d` is recognized via `instanceof` and resolved to its backing
|
|
40
|
+
* source through {@link Texture2d#getTexture} — so passing the asset object
|
|
41
|
+
* directly (`{ image: myTexture }`) works the same as passing a raw
|
|
42
|
+
* `HTMLCanvasElement`. Raw DOM image/canvas sources and the loader's decoded
|
|
43
|
+
* `CompressedImage` data are accepted too, but are not part of this class
|
|
44
|
+
* hierarchy.
|
|
45
|
+
*
|
|
46
|
+
* Most assets are **CPU-backed** and resolve to a drawable canvas/image — those
|
|
47
|
+
* are the ones assignable to {@link Sprite#image} / {@link Sprite#normalMap} /
|
|
48
|
+
* an {@link ImageLayer} (which upload the drawable through the texture cache).
|
|
49
|
+
* Subclasses may also be **GPU-resident**, resolving to an opaque renderer
|
|
50
|
+
* backing that never leaves the GPU (e.g. the capture returned by
|
|
51
|
+
* `renderer.toFrameTexture()`). A GPU-resident texture is **not** a drawable
|
|
52
|
+
* source: use it as a custom-shader sampler via {@link ShaderEffect#setTexture}
|
|
53
|
+
* (which binds its live GL handle), NOT as `Sprite#image`. The contract admits
|
|
54
|
+
* both (a future WebGPU backend follows the same shape with a `GPUTexture`).
|
|
55
|
+
*
|
|
56
|
+
* Concrete implementations:
|
|
57
|
+
* - {@link TextureAtlas} — packed multi-region sprite sheet (CPU-backed)
|
|
58
|
+
* @category Game Objects
|
|
59
|
+
*/
|
|
60
|
+
export default abstract class Texture2d {
|
|
61
|
+
/**
|
|
62
|
+
* Return the backing source for this texture — a drawable canvas/image for
|
|
63
|
+
* CPU-backed assets (assignable to {@link Sprite#image} /
|
|
64
|
+
* {@link Sprite#normalMap} / an {@link ImageLayer}), or an opaque
|
|
65
|
+
* GPU-resident backing for GPU-resident ones (bind those as a custom-shader
|
|
66
|
+
* sampler via {@link ShaderEffect#setTexture}; they are not drawable sources).
|
|
67
|
+
* @returns the backing source
|
|
68
|
+
*/
|
|
69
|
+
abstract getTexture(): Texture2dSource;
|
|
70
|
+
/**
|
|
71
|
+
* Release any GPU/CPU resources held by this texture. The texture must not
|
|
72
|
+
* be used after calling destroy.
|
|
73
|
+
*
|
|
74
|
+
* Broadcasts {@link event.TEXTURE2D_DESTROYED} with the backing source so
|
|
75
|
+
* GPU-side caches keyed by source image (e.g. the lit batcher's normal-map
|
|
76
|
+
* textures) release what they hold for it. Subclasses that own additional
|
|
77
|
+
* resources override this and call `super.destroy()` FIRST — the source
|
|
78
|
+
* must still be resolvable when the event fires.
|
|
79
|
+
*/
|
|
80
|
+
destroy(): void;
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=texture2d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texture2d.d.ts","sourceRoot":"","sources":["../../../src/video/texture/texture2d.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,OAAO,CAAC,MAAM,gBAAgB,EAAE,OAAO,MAAM,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,QAAQ,CAAC,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACxB,iBAAiB,GACjB,gBAAgB,GAChB,eAAe,GACf,WAAW,GACX,kBAAkB,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,SAAS;IACtC;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,IAAI,eAAe;IAEtC;;;;;;;;;OASG;IACH,OAAO,IAAI,IAAI;CAGf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/batcher.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH;IACC;;;;;;;;;;;;;;;OAeG;IACH,sBAfW,aAAa,YAErB;QAA2B,UAAU,EACrC;YAAoC,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACuB,UAAU,EAAvC,OAAO;YACqB,MAAM,EAAlC,MAAM;SACd;QAAyB,MAAM,EAC/B;YAAgC,MAAM,EAA9B,MAAM;YACkB,QAAQ,EAAhC,MAAM;SACd;QAA0B,WAAW;QACV,OAAO;QACR,iBAAiB;KAC7C,EAGA;IAED;;;OAGG;IACH,yCA6HC;IA3HA,cAAwB;IAGxB,QAAqB;IAGrB,gBAA2C;IAE3C;;;OAGG;IACH,oCAA8B;IAE9B;;;OAGG;IACH,oCAA8B;IAE9B;;;;OAIG;IACH,yBAA6B;IAE7B;;;;OAIG;IACH,iCAAoB;IAEpB;;;;;OAKG;IACH,2BAAe;IAEf;;;;;OAKG;IACH,+BAAmB;IAEnB;;;OAGG;IACH,0CAAsB;IAqCtB;;;OAGG;IACH,sCAA0E;IAE1E;;;OAGG;IACH,oCAA+C;IAE/C;;;;OAIG;IACH,+CAA0B;IAE1B;;;;OAIG;IACH,iDAAuB;IAUxB;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/batcher.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH;IACC;;;;;;;;;;;;;;;OAeG;IACH,sBAfW,aAAa,YAErB;QAA2B,UAAU,EACrC;YAAoC,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACsB,IAAI,EAAhC,MAAM;YACuB,UAAU,EAAvC,OAAO;YACqB,MAAM,EAAlC,MAAM;SACd;QAAyB,MAAM,EAC/B;YAAgC,MAAM,EAA9B,MAAM;YACkB,QAAQ,EAAhC,MAAM;SACd;QAA0B,WAAW;QACV,OAAO;QACR,iBAAiB;KAC7C,EAGA;IAED;;;OAGG;IACH,yCA6HC;IA3HA,cAAwB;IAGxB,QAAqB;IAGrB,gBAA2C;IAE3C;;;OAGG;IACH,oCAA8B;IAE9B;;;OAGG;IACH,oCAA8B;IAE9B;;;;OAIG;IACH,yBAA6B;IAE7B;;;;OAIG;IACH,iCAAoB;IAEpB;;;;;OAKG;IACH,2BAAe;IAEf;;;;;OAKG;IACH,+BAAmB;IAEnB;;;OAGG;IACH,0CAAsB;IAqCtB;;;OAGG;IACH,sCAA0E;IAE1E;;;OAGG;IACH,oCAA+C;IAE/C;;;;OAIG;IACH,+CAA0B;IAE1B;;;;OAIG;IACH,iDAAuB;IAUxB;;;OAGG;IACH,cAoBC;IAED;;OAEG;IACH,aAYC;IAED;;;;OAIG;IACH,eAaC;IAED;;;;OAIG;IACH,kBAFW,QAAQ,QA8BlB;IAHE,uCAA4B;IAK/B;;;;;;;OAOG;IACH,mBANW,MAAM,QACN,MAAM,QACN,MAAM,cACN,OAAO,UACP,MAAM,QA+BhB;IAED;;;OAGG;IACH,sBAFW,QAAQ,QAIlB;IAED;;;;OAIG;IACH,oBAFW,MAAM,EAAE,QAOlB;IAED;;;OAGG;IACH,aAFW,MAAM,QAgFhB;CACD;;qBA9ZoB,gBAAgB;8BAFP,wBAAwB;6BACzB,oBAAoB;8BAMtB,2BAA2B;+BADxB,wBAAwB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A {@link MeshBatcher} variant that shades meshes with the active stage's
|
|
3
|
+
* {@link Light3d} lights (half-Lambert diffuse from directional lights +
|
|
4
|
+
* ambient). It extends the unlit batcher, adding a world-space `aNormal`
|
|
5
|
+
* vertex attribute (12-float layout vs 9) and a lit shader.
|
|
6
|
+
*
|
|
7
|
+
* Meshes opt in via `mesh.lit` — so standalone, unlit meshes keep the lean
|
|
8
|
+
* 9-float `MeshBatcher` and pay nothing for lighting. Both batchers share the
|
|
9
|
+
* mesh-mode depth-clear state (a single clear per target) since this one
|
|
10
|
+
* inherits {@link MeshBatcher#bind}.
|
|
11
|
+
* @category Rendering
|
|
12
|
+
*/
|
|
13
|
+
export default class LitMeshBatcher extends MeshBatcher {
|
|
14
|
+
/** push the 12-float lit vertex, appending the mesh's world-space normal. @ignore */
|
|
15
|
+
_pushVertex(vertexData: any, x: any, y: any, z: any, u: any, v: any, color: any, mesh: any, i3: any): void;
|
|
16
|
+
}
|
|
17
|
+
import MeshBatcher from "./mesh_batcher.js";
|
|
18
|
+
//# sourceMappingURL=lit_mesh_batcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit_mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/lit_mesh_batcher.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;GAWG;AACH;IAqBC,qFAAqF;IACrF,2GAaC;CA0BD;wBAzFuB,mBAAmB"}
|
|
@@ -28,13 +28,38 @@ export default class LitQuadBatcher extends QuadBatcher {
|
|
|
28
28
|
*/
|
|
29
29
|
boundNormalMaps: (ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | null)[] | undefined;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* Per-slot content `version` of the normal map currently bound there. An
|
|
32
|
+
* animated source keeps a stable canvas reference across re-bakes but
|
|
33
|
+
* bumps its `version`, so `addQuad` compares this (not just the reference)
|
|
34
|
+
* to know when to re-bind/re-upload. `-1` = nothing bound.
|
|
35
|
+
* @type {number[]}
|
|
33
36
|
* @ignore
|
|
34
37
|
*/
|
|
35
|
-
|
|
38
|
+
boundNormalVersions: number[] | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Map from a normal-map source image to its uploaded GL texture and the
|
|
41
|
+
* source `version` it was uploaded at. A source that bumps its `version`
|
|
42
|
+
* (e.g. an animated {@link NoiseTexture2d}) is re-uploaded on next bind —
|
|
43
|
+
* the three.js `Texture.needsUpdate` model, scoped to normal maps which
|
|
44
|
+
* live outside the color `TextureCache`.
|
|
45
|
+
* @type {Map<HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap, {tex: WebGLTexture, version: number}>}
|
|
46
|
+
* @ignore
|
|
47
|
+
*/
|
|
48
|
+
normalMapTextures: Map<ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas, {
|
|
49
|
+
tex: WebGLTexture;
|
|
50
|
+
version: number;
|
|
51
|
+
}> | undefined;
|
|
36
52
|
_lightCount: number | undefined;
|
|
37
53
|
_maxLights: number | undefined;
|
|
54
|
+
_onTexture2dDestroyed: ((source: any) => void) | null | undefined;
|
|
55
|
+
_normalRangeReserved: boolean | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Release the cached GL texture uploaded for the given normal-map source
|
|
58
|
+
* and clear any slot bookkeeping referencing it. Safe to call for images
|
|
59
|
+
* that were never bound.
|
|
60
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - normal-map source
|
|
61
|
+
*/
|
|
62
|
+
evictNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap): void;
|
|
38
63
|
/**
|
|
39
64
|
* Bind the paired normal sampler uniforms (`uNormalSampler0..N-1`)
|
|
40
65
|
* to texture units `maxBatchTextures..2*maxBatchTextures-1`. Called
|
|
@@ -85,8 +110,9 @@ export default class LitQuadBatcher extends QuadBatcher {
|
|
|
85
110
|
* encoding for any non-opaque texel.
|
|
86
111
|
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - normal-map source
|
|
87
112
|
* @param {number} unit - GL texture unit (already offset by `maxBatchTextures`)
|
|
113
|
+
* @param {number} [version=0] - the source revision being uploaded
|
|
88
114
|
*/
|
|
89
|
-
uploadNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, unit: number): void;
|
|
115
|
+
uploadNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, unit: number, version?: number): void;
|
|
90
116
|
/**
|
|
91
117
|
* Add a textured quad with optional paired normal map.
|
|
92
118
|
* @param {TextureAtlas} texture - Source texture atlas
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lit_quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/lit_quad_batcher.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lit_quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/lit_quad_batcher.js"],"names":[],"mappings":"AAMA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AACH;IAsEE;;;;;;OAMG;IACH,6GAAmD;IAEnD;;;;;;;OAOG;IACH,0CAAqD;IAErD;;;;;;;;OAQG;IACH;aAHoF,YAAY;iBAAW,MAAM;mBAG/E;IAElC,gCAAoB;IACpB,+BAA4B;IAQ3B,kEAEC;IAiCD,0CAAgC;IAoBlC;;;;;OAKG;IACH,sBAFW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAcxE;IAED;;;;;OAKG;IACH,2BAOC;IA4DD;;;;;;;;;;;;;;OAcG;IACH,2BANG;QAA+B,SAAS,EAAhC,YAAY;QACW,MAAM,EAA7B,YAAY;QACY,OAAO;QACd,KAAK,EAAtB,MAAM;QACc,OAAO;KACrC,QAgBA;IAED;;;;;;;;;OASG;IACH,qBAHW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAC9D,MAAM,QAiBhB;IAED;;;;;;;;;;;OAWG;IACH,uBAJW,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,QAC9D,MAAM,YACN,MAAM,QAwBhB;IAED;;;;;;;;;;;;;;OAcG;IACH,iBAbW,YAAY,KACZ,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,cACP,gBAAgB,GAAC,iBAAiB,GAAC,IAAI,QAwIjD;CA8DD;wBA1kBoC,mBAAmB;kCAIzB,0BAA0B"}
|
|
@@ -8,17 +8,35 @@
|
|
|
8
8
|
* @category Rendering
|
|
9
9
|
*/
|
|
10
10
|
export class MaterialBatcher extends Batcher {
|
|
11
|
+
set currentTextureUnit(unit: number);
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* The GL texture unit currently active (`gl.activeTexture`). Tracked on
|
|
14
|
+
* the RENDERER, not per batcher: the active unit is global GL state
|
|
15
|
+
* shared by every batcher instance, and a per-batcher copy desyncs as
|
|
16
|
+
* soon as another batcher (or a blit, or an FBO pass) moves the active
|
|
17
|
+
* unit — the stale copy then lets `bindTexture2D` skip `gl.activeTexture`
|
|
18
|
+
* and bind (or upload) a texture onto whatever unit is REALLY active.
|
|
19
|
+
* Symptom was video force-re-uploads overwriting a mesh texture with
|
|
20
|
+
* video frames after a mesh pass.
|
|
21
|
+
* @type {number}
|
|
13
22
|
* @ignore
|
|
14
23
|
*/
|
|
15
|
-
currentTextureUnit:
|
|
24
|
+
get currentTextureUnit(): number;
|
|
16
25
|
/**
|
|
17
26
|
* bound textures by unit
|
|
18
27
|
* @ignore
|
|
19
28
|
*/
|
|
20
29
|
boundTextures: any[] | undefined;
|
|
21
30
|
_onCacheReset: (() => void) | null | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Drop every cached texture binding after a {@link GPU_TEXTURE_CACHE_RESET}
|
|
33
|
+
* (the shared texture cache reassigned units — our per-unit view is stale).
|
|
34
|
+
* Subclasses that pair extra samplers to units (lit normal maps) override to
|
|
35
|
+
* forget those too; without that they'd assume the extra texture is still
|
|
36
|
+
* resident and skip re-binding it after the reset.
|
|
37
|
+
* @ignore
|
|
38
|
+
*/
|
|
39
|
+
_onTextureCacheReset(): void;
|
|
22
40
|
/**
|
|
23
41
|
* Free resources used by the batcher. Currently unsubscribes the
|
|
24
42
|
* texture-cache-reset listener so a discarded batcher doesn't keep
|
|
@@ -64,6 +82,19 @@ export class MaterialBatcher extends Batcher {
|
|
|
64
82
|
* @returns {number} unit the unit number that was associated with the given texture
|
|
65
83
|
*/
|
|
66
84
|
unbindTexture2D(texture?: WebGLTexture, unit?: number): number;
|
|
85
|
+
/**
|
|
86
|
+
* Forget whatever texture this batcher believes is bound to `unit`, so the
|
|
87
|
+
* next bind to it re-issues the GL bind. Used when a GL texture unit is
|
|
88
|
+
* clobbered OUTSIDE this batcher's own accounting — e.g.
|
|
89
|
+
* {@link WebGLRenderer#toFrameTexture}, which binds its capture to a scratch
|
|
90
|
+
* unit directly (not via the shared texture cache), so a different batcher's
|
|
91
|
+
* unit cache would otherwise skip a needed re-bind. Subclasses that pair
|
|
92
|
+
* extra samplers to the same unit (lit normal maps) override to drop those
|
|
93
|
+
* too.
|
|
94
|
+
* @param {number} unit - the GL texture unit to invalidate
|
|
95
|
+
* @ignore
|
|
96
|
+
*/
|
|
97
|
+
invalidateUnit(unit: number): void;
|
|
67
98
|
/**
|
|
68
99
|
* @ignore
|
|
69
100
|
* @param {TextureAtlas|TextureResource} texture
|
|
@@ -73,8 +104,13 @@ export class MaterialBatcher extends Batcher {
|
|
|
73
104
|
* @param {number} [h] - same as `w`.
|
|
74
105
|
* @param {boolean} [force=false]
|
|
75
106
|
* @param {boolean} [flush=true]
|
|
107
|
+
* @param {string} [repeat] - per-use wrap-mode override (a mesh's
|
|
108
|
+
* `textureRepeat`, #1503) — sampled with this wrap without mutating
|
|
109
|
+
* the shared atlas's `repeat`. The texture-unit cache keys by
|
|
110
|
+
* `(source, repeat)`, so each wrap gets its own unit + GL texture.
|
|
111
|
+
* Omit to use `texture.repeat`.
|
|
76
112
|
*/
|
|
77
|
-
uploadTexture(texture: TextureAtlas | TextureResource, w?: number, h?: number, force?: boolean, flush?: boolean): any;
|
|
113
|
+
uploadTexture(texture: TextureAtlas | TextureResource, w?: number, h?: number, force?: boolean, flush?: boolean, repeat?: string): any;
|
|
78
114
|
}
|
|
79
115
|
import { Batcher } from "./batcher.js";
|
|
80
116
|
import type { TextureAtlas } from "./../../texture/atlas.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"material_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/material_batcher.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;;GAIG;AACH;
|
|
1
|
+
{"version":3,"file":"material_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/material_batcher.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;;GAIG;AACH;IA6EC,6BAPU,MAAM,EASf;IAlBD;;;;;;;;;;;OAWG;IACH,0BAHU,MAAM,CAKf;IA/DA;;;OAGG;IACH,iCAAuB;IAwBtB,+CAEC;IAKH;;;;;;;OAOG;IACH,6BAIC;IAsBD;;;;;;OAMG;IACH,gBAKC;IAmBD;;;;;;;;;;;OAWG;IACH,sBAVW,MAAM,WACN,8DAAM,iBAAiB,GAAC,SAAS,GAAC,UAAU,EAAE,GAAC,YAAY,EAAE,UAC7D,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,uBACN,OAAO,WACP,OAAO,kCACL,YAAY,CAmKxB;IAED;;;OAGG;IACH,yBAFW,YAAY,GAAC,YAAY,QAgCnC;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,YAAY,CAIxB;IAED;;;;OAIG;IACH,uBAHW,YAAY,QACZ,MAAM,yBAsBhB;IAED;;;;;OAKG;IACH,0BAJW,YAAY,SACZ,MAAM,GACJ,MAAM,CAalB;IAED;;;;;;;;;;;OAWG;IACH,qBAHW,MAAM,QAQhB;IAED;;;;;;;;;;;;;;OAcG;IACH,uBAbW,YAAY,GAAC,eAAe,MAC5B,MAAM,MAGN,MAAM,UACN,OAAO,UACP,OAAO,WACP,MAAM,OAsDhB;CACD;wBAzduB,cAAc;kCAIP,0BAA0B"}
|
|
@@ -29,20 +29,61 @@ export default class MeshBatcher extends MaterialBatcher {
|
|
|
29
29
|
* @ignore
|
|
30
30
|
*/
|
|
31
31
|
init(renderer: any): void;
|
|
32
|
+
currentAlphaCutoff: any;
|
|
33
|
+
currentEmissiveR: any;
|
|
34
|
+
currentEmissiveG: any;
|
|
35
|
+
currentEmissiveB: any;
|
|
36
|
+
_onTargetChanged: ((emitter: any) => void) | null | undefined;
|
|
32
37
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* below (frame start, post-effect FBO bind/unbind), back to
|
|
37
|
-
* `false` by the first `bind()` of the new target after the
|
|
38
|
-
* lazy clear runs. Lifts depth clearing from per-mesh (legacy)
|
|
39
|
-
* to per-target — same model Three.js uses. The GPU's `LEQUAL`
|
|
40
|
-
* depth test then resolves inter-mesh occlusion per pixel
|
|
41
|
-
* against the accumulated buffer.
|
|
38
|
+
* The vertex attribute layout. The base (unlit) mesh batcher is
|
|
39
|
+
* `aVertex` (3) + `aRegion` (2) + `aColor` (4) = 9 floats. Subclasses
|
|
40
|
+
* (e.g. {@link LitMeshBatcher}) append their own attributes.
|
|
42
41
|
* @ignore
|
|
43
42
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
_attributeLayout(renderer: any): {
|
|
44
|
+
name: string;
|
|
45
|
+
size: number;
|
|
46
|
+
type: any;
|
|
47
|
+
normalized: boolean;
|
|
48
|
+
offset: number;
|
|
49
|
+
}[];
|
|
50
|
+
/**
|
|
51
|
+
* The shader sources for this batcher (unlit by default). Subclasses
|
|
52
|
+
* override to supply a lit shader.
|
|
53
|
+
* @ignore
|
|
54
|
+
*/
|
|
55
|
+
_shaderSources(): {
|
|
56
|
+
vertex: any;
|
|
57
|
+
fragment: any;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Invalidate the per-mesh `uAlphaCutoff` / `uEmissive` caches when the bound
|
|
61
|
+
* shader (GL program) changes — the new program's uniforms are at their own
|
|
62
|
+
* defaults, so the next mesh must re-issue them rather than trust the cache.
|
|
63
|
+
* Mirrors the base batcher's `currentSamplerUnit` reset (same condition), and
|
|
64
|
+
* matters when a custom mesh shader declaring those uniforms is interleaved
|
|
65
|
+
* with the built-in one on this batcher (e.g. `drawMesh` swapping a custom
|
|
66
|
+
* shader in and back out).
|
|
67
|
+
* @ignore
|
|
68
|
+
*/
|
|
69
|
+
useShader(shader: any): void;
|
|
70
|
+
/**
|
|
71
|
+
* Write one vertex into the buffer. The base (unlit) layout is
|
|
72
|
+
* `x, y, z, u, v, color`. Subclasses override to append per-vertex data
|
|
73
|
+
* matching their {@link MeshBatcher#_attributeLayout} (e.g.
|
|
74
|
+
* {@link LitMeshBatcher} pushes the world-space normal too).
|
|
75
|
+
* @param {object} vertexData - the batcher's vertex buffer
|
|
76
|
+
* @param {number} x
|
|
77
|
+
* @param {number} y
|
|
78
|
+
* @param {number} z
|
|
79
|
+
* @param {number} u
|
|
80
|
+
* @param {number} v
|
|
81
|
+
* @param {number} color - packed ARGB Uint32
|
|
82
|
+
* @param {object} _mesh - the source mesh (unused here; for subclasses)
|
|
83
|
+
* @param {number} _i3 - the source vertex's `index * 3` (for subclasses)
|
|
84
|
+
* @ignore
|
|
85
|
+
*/
|
|
86
|
+
_pushVertex(vertexData: object, x: number, y: number, z: number, u: number, v: number, color: number, _mesh: object, _i3: number): void;
|
|
46
87
|
/**
|
|
47
88
|
* Add a textured mesh to the batch. When the mesh has a
|
|
48
89
|
* `vertexColors` array (multi-material OBJ + bound MTL), each
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/mesh_batcher.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/mesh_batcher.js"],"names":[],"mappings":"AAyFA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;IACC;;;OAGG;IACH,0BAsCC;IA5BA,wBAA4B;IAI5B,sBAA0B;IAC1B,sBAA0B;IAC1B,sBAA0B;IAYzB,8DAOC;IAKH;;;;;OAKG;IACH;;;;;;QAgCC;IAED;;;;OAIG;IACH;;;MAEC;IAED;;;;;;;;;OASG;IACH,6BAWC;IAyDD;;;;;;;;;;;;;;;OAeG;IACH,wBAXW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,SACN,MAAM,SACN,MAAM,OACN,MAAM,QAKhB;IAED;;;;;;;;;;;;;;OAcG;IACH,cAHW,MAAM,QACN,MAAM,QA+JhB;CACD;gCA3d+B,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitive_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/primitive_batcher.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;;GAIG;AACH;IACC;;;OAGG;IACH,0BAsCC;IALA;;;OAGG;IACH,sBAAyB;IA0B1B;;;;;OAKG;IACH,mBAJW,MAAM,SACN,KAAK,EAAE,gBACP,MAAM,
|
|
1
|
+
{"version":3,"file":"primitive_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/primitive_batcher.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;;GAIG;AACH;IACC;;;OAGG;IACH,0BAsCC;IALA;;;OAGG;IACH,sBAAyB;IA0B1B;;;;;OAKG;IACH,mBAJW,MAAM,SACN,KAAK,EAAE,gBACP,MAAM,QAoDhB;;CAyMD;wBAjVuB,cAAc;2BAId,gCAAgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/quad_batcher.js"],"names":[],"mappings":"AAMA;;;GAGG;AAUH,iCAKE;AAEF;;;;GAIG;AACH;IACC;;;OAGG;IACH,0BA0DC;IAzDA;;;;OAIG;IACH,qCAA0D;IA2C1D;;;;;OAKG;IACH,qCAA2B;IAK5B;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/batchers/quad_batcher.js"],"names":[],"mappings":"AAMA;;;GAGG;AAUH,iCAKE;AAEF;;;;GAIG;AACH;IACC;;;OAGG;IACH,0BA0DC;IAzDA;;;;OAIG;IACH,qCAA0D;IA2C1D;;;;;OAKG;IACH,qCAA2B;IAK5B;;;;OAIG;IACH,0BAcC;IAED;;;;OAIG;IACH,0BAIC;IAED;;;;;;;OAOG;IACH,kBAFW,QAAQ,GAAC,YAAY,QAK/B;IAyDD;;;;;;;;;;OAUG;IACH,oBAPW,YAAY,KACZ,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,UACN,QAAQ,GAAC,YAAY,QAkE/B;IAED;;;;;;;;;;;;;OAaG;IACH,iBAZW,YAAY,KACZ,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,QAwEjB;CACD;yBAtWwB,2BAA2B;gCAIpB,uBAAuB;kCAIxB,0BAA0B"}
|
|
@@ -20,6 +20,19 @@ export default class WebGLIndexBuffer extends IndexBuffer {
|
|
|
20
20
|
* Bind this index buffer
|
|
21
21
|
*/
|
|
22
22
|
bind(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Replace the underlying GL buffer with a fresh one, deleting the old.
|
|
25
|
+
* Needed on context restore — the old buffer object belongs to the lost
|
|
26
|
+
* context and every upload through it would silently fail. Also keeps
|
|
27
|
+
* plain resets leak-free (`deleteBuffer` on a lost-context object is a
|
|
28
|
+
* harmless no-op).
|
|
29
|
+
*/
|
|
30
|
+
recreate(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Delete the underlying GL buffer. The index buffer must not be used
|
|
33
|
+
* after calling destroy.
|
|
34
|
+
*/
|
|
35
|
+
destroy(): void;
|
|
23
36
|
}
|
|
24
37
|
import IndexBuffer from "../../buffer/index.js";
|
|
25
38
|
//# sourceMappingURL=index.d.ts.map
|