melonjs 19.5.0 → 19.6.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/build/index.js +176 -19
- package/build/index.js.map +2 -2
- package/build/video/webgl/glshader.d.ts +46 -16
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/shadereffect.d.ts +23 -4
- package/build/video/webgl/shadereffect.d.ts.map +1 -1
- package/build/video/webgl/utils/uniforms.d.ts +8 -0
- package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -37,30 +37,57 @@ export default class GLShader {
|
|
|
37
37
|
*/
|
|
38
38
|
gl: WebGLRenderingContext;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* `true` once {@link destroy} has been called. After this flag is
|
|
41
|
+
* `true`, every method on the shader is a silent no-op — callers
|
|
42
|
+
* holding a stale reference (e.g. a still-registered update loop)
|
|
43
|
+
* do not crash the frame.
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
* @readonly
|
|
42
46
|
*/
|
|
43
|
-
|
|
47
|
+
readonly destroyed: boolean;
|
|
44
48
|
/**
|
|
45
|
-
* the
|
|
46
|
-
*
|
|
49
|
+
* `true` while the WebGL context is lost (and until it's
|
|
50
|
+
* restored). The GL program/attributes/uniforms are released
|
|
51
|
+
* during the suspended window but the shader source code is
|
|
52
|
+
* preserved so {@link _onContextRestored} can rebuild the
|
|
53
|
+
* program against the new context. User code generally doesn't
|
|
54
|
+
* read this — methods short-circuit internally — but it's
|
|
55
|
+
* available for diagnostic / debug-plugin tooling.
|
|
56
|
+
* @type {boolean}
|
|
57
|
+
* @readonly
|
|
47
58
|
*/
|
|
48
|
-
|
|
59
|
+
readonly suspended: boolean;
|
|
60
|
+
_sourceVertex: string;
|
|
61
|
+
_sourceFragment: string;
|
|
62
|
+
_precision: string | undefined;
|
|
63
|
+
_uniformCache: any;
|
|
64
|
+
program: WebGLProgram;
|
|
65
|
+
uniforms: object;
|
|
66
|
+
attributes: number[];
|
|
49
67
|
/**
|
|
50
|
-
* the
|
|
51
|
-
*
|
|
68
|
+
* (Re)compile the shader program against `this.gl` from the
|
|
69
|
+
* preserved source. Called from the constructor and from
|
|
70
|
+
* {@link _onContextRestored}. Replays any cached uniform values
|
|
71
|
+
* against the freshly-extracted uniforms proxy.
|
|
72
|
+
* @private
|
|
52
73
|
*/
|
|
53
|
-
|
|
74
|
+
private _compile;
|
|
75
|
+
vertex: any;
|
|
76
|
+
fragment: any;
|
|
54
77
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
78
|
+
* Handler for {@link ONCONTEXT_LOST}. Tears down the GL program
|
|
79
|
+
* but preserves the shader source + cached uniform values so the
|
|
80
|
+
* shader can be transparently rebuilt on context restore.
|
|
81
|
+
* @private
|
|
57
82
|
*/
|
|
58
|
-
|
|
83
|
+
private _onContextLost;
|
|
59
84
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
85
|
+
* Handler for {@link ONCONTEXT_RESTORED}. Re-compiles and
|
|
86
|
+
* re-links the shader against the new GL context, then replays
|
|
87
|
+
* any cached uniform values via {@link _compile}.
|
|
88
|
+
* @private
|
|
62
89
|
*/
|
|
63
|
-
|
|
90
|
+
private _onContextRestored;
|
|
64
91
|
/**
|
|
65
92
|
* Installs this shader program as part of current rendering state
|
|
66
93
|
*/
|
|
@@ -87,7 +114,10 @@ export default class GLShader {
|
|
|
87
114
|
*/
|
|
88
115
|
setVertexAttributes(gl: WebGLRenderingContext, attributes: object[], stride: number): void;
|
|
89
116
|
/**
|
|
90
|
-
* destroy this shader objects resources (program, attributes, uniforms)
|
|
117
|
+
* destroy this shader objects resources (program, attributes, uniforms).
|
|
118
|
+
* Idempotent — calling destroy twice (or after a context-lost suspend)
|
|
119
|
+
* is safe. Unsubscribes from the renderer's context lost / restored
|
|
120
|
+
* events so a destroyed shader is never automatically resurrected.
|
|
91
121
|
*/
|
|
92
122
|
destroy(): void;
|
|
93
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glshader.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/glshader.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"glshader.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/glshader.js"],"names":[],"mappings":"AAYA;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,gBA1BW,qBAAqB,UACrB,MAAM,YACN,MAAM,cACN,MAAM,EAyEhB;IAjDA;;;OAGG;IACH,IAFU,qBAAqB,CAEnB;IAEZ;;;;;;;OAOG;IACH,oBAHU,OAAO,CAGK;IAEtB;;;;;;;;;;OAUG;IACH,oBAHU,OAAO,CAGK;IAGtB,sBAA2B;IAC3B,wBAA+B;IAC/B,+BAA2B;IAG3B,mBAAwC;IAKvC,sBAAmB;IACnB,iBAAoB;IACpB,qBAAsB;IASxB;;;;;;OAMG;IACH,iBA0CC;IAzCA,YAGC;IACD,cAGC;IAoCF;;;;;OAKG;IACH,uBAgBC;IAED;;;;;OAKG;IACH,2BAMC;IAED;;OAEG;IACH,aAKC;IAED;;;;OAIG;IACH,wBAHW,MAAM,GACJ,KAAK,CAYjB;IAED;;;;;;OAMG;IACH,iBALW,MAAM,SACN,MAAM,GAAC,YAAY,QA0C7B;IAED;;;;;OAKG;IACH,wBAJW,qBAAqB,cACrB,MAAM,EAAE,UACR,MAAM,QAmBhB;IAED;;;;;OAKG;IACH,gBA2BC;CACD"}
|
|
@@ -35,12 +35,29 @@ export default class ShaderEffect {
|
|
|
35
35
|
*/
|
|
36
36
|
constructor(renderer: WebGLRenderer | CanvasRenderer, fragmentBody: string, precision?: string);
|
|
37
37
|
/**
|
|
38
|
-
* whether this effect is active (false in Canvas mode
|
|
38
|
+
* whether this effect is active (false in Canvas mode, false after
|
|
39
|
+
* {@link destroy}, and false while the WebGL context is suspended
|
|
40
|
+
* between an `ONCONTEXT_LOST` and the matching `ONCONTEXT_RESTORED`
|
|
41
|
+
* event).
|
|
39
42
|
* @type {boolean}
|
|
40
43
|
*/
|
|
41
44
|
enabled: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* `true` once {@link destroy} has been called. Distinct from
|
|
47
|
+
* `enabled` — which also toggles transiently across a context
|
|
48
|
+
* lost / restored cycle — to give callers a stable signal for
|
|
49
|
+
* "this effect has been explicitly released."
|
|
50
|
+
* @type {boolean}
|
|
51
|
+
* @readonly
|
|
52
|
+
*/
|
|
53
|
+
readonly destroyed: boolean;
|
|
42
54
|
/** @ignore */
|
|
43
55
|
_shader: GLShader | undefined;
|
|
56
|
+
/** @private */
|
|
57
|
+
private _onContextLost;
|
|
58
|
+
_enabledBeforeSuspend: boolean | undefined;
|
|
59
|
+
/** @private */
|
|
60
|
+
private _onContextRestored;
|
|
44
61
|
/**
|
|
45
62
|
* Set the uniform to the given value
|
|
46
63
|
* @param {string} name - the uniform name
|
|
@@ -56,15 +73,17 @@ export default class ShaderEffect {
|
|
|
56
73
|
/** @ignore */
|
|
57
74
|
get program(): WebGLProgram | null;
|
|
58
75
|
/** @ignore */
|
|
59
|
-
get vertex():
|
|
76
|
+
get vertex(): any;
|
|
60
77
|
/** @ignore */
|
|
61
|
-
get fragment():
|
|
78
|
+
get fragment(): any;
|
|
62
79
|
/** @ignore */
|
|
63
80
|
get attributes(): {};
|
|
64
81
|
/** @ignore */
|
|
65
82
|
get uniforms(): object;
|
|
66
83
|
/**
|
|
67
|
-
* destroy this shader effect
|
|
84
|
+
* destroy this shader effect. Idempotent — calling destroy twice
|
|
85
|
+
* is safe. Unsubscribes from the renderer's context-lost / restored
|
|
86
|
+
* events so a destroyed effect is not auto-reactivated.
|
|
68
87
|
*/
|
|
69
88
|
destroy(): void;
|
|
70
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadereffect.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/shadereffect.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shadereffect.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/shadereffect.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;IAoBC;;;;;;OAMG;IACH,sBANW,aAAa,GAAC,cAAc,gBAC5B,MAAM,cAGN,MAAM,EAkChB;IA1DD;;;;;;OAMG;IACH,SAFU,OAAO,CAED;IAEhB;;;;;;;OAOG;IACH,oBAHU,OAAO,CAGC;IA6BjB,cAAc;IACd,8BAKC;IAQF,eAAe;IACf,uBAOC;IAFA,2CAAyC;IAI1C,eAAe;IACf,2BAQC;IAED;;;;OAIG;IACH,iBAHW,MAAM,SACN,MAAM,GAAC,YAAY,QAM7B;IAED,cAAc;IACd,aAIC;IAED,cAAc;IACd,qCAEC;IAED,cAAc;IACd,iEAIC;IAED,cAAc;IACd,mCAEC;IAED,cAAc;IACd,kBAEC;IAED,cAAc;IACd,oBAEC;IAED,cAAc;IACd,qBAEC;IAED,cAAc;IACd,uBAEC;IAED;;;;OAIG;IACH,gBAiBC;CACD;qBA9LoB,eAAe"}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture the current value into the cache slot so future `setUniform`
|
|
3
|
+
* calls can short-circuit. Reuses the existing slot (and its allocation)
|
|
4
|
+
* when the length matches — only a length change or a first capture
|
|
5
|
+
* allocates a fresh array.
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
export function captureValue(prev: any, val: any): any;
|
|
1
9
|
/**
|
|
2
10
|
* Build the `uniforms` proxy object for a compiled shader program.
|
|
3
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniforms.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/uniforms.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uniforms.d.ts","sourceRoot":"","sources":["../../../../src/video/webgl/utils/uniforms.js"],"names":[],"mappings":"AA6DA;;;;;;GAMG;AACH,uDAoBC;AAED;;;;;;;;;;;;;;;GAeG;AACH,0DAmEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/webgl_renderer.js"],"names":[],"mappings":"AAsDA;;;GAGG;AACH;IAQE;;;;;OAKG;IACH,oBAJU,MAAM,CAIU;IAU1B;;;;OAIG;IACH,IAFU,qBAAqB,CAEI;IAYnC;;;;OAIG;IACH,wBAHU,QAAQ,CAG0B;IAS5C;;;;;OAKG;IACH,UAHU,MAAM,CAGO;IAEvB;;;OAGG;IACH,cAFU,WAAW,CAEqB;IAE1C;;;;OAIG;IACH,sBAHU,MAAM,CAGwD;IAExE;;;;OAIG;IACH,iBAHU,MAAM,CAMf;IAED;;;OAGG;IACH;;;QAEE;IAIF,kBAA6B;IAG7B,kBAAoB;IAGpB,sBAA4B;IAE5B;;;;OAIG;IACH,kBAFU,QAAQ,CAEuC;IAEzD;;;OAGG;IACH,gBAFU,OAAO,CAEc;IAE/B;;;OAGG;IACH,gBAFU,YAAY,CAES;IAE/B;;;OAGG;IACH,4BAAyB;IAuBzB,wBAA2B;IAkB3B,oBAAqD;
|
|
1
|
+
{"version":3,"file":"webgl_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/webgl_renderer.js"],"names":[],"mappings":"AAsDA;;;GAGG;AACH;IAQE;;;;;OAKG;IACH,oBAJU,MAAM,CAIU;IAU1B;;;;OAIG;IACH,IAFU,qBAAqB,CAEI;IAYnC;;;;OAIG;IACH,wBAHU,QAAQ,CAG0B;IAS5C;;;;;OAKG;IACH,UAHU,MAAM,CAGO;IAEvB;;;OAGG;IACH,cAFU,WAAW,CAEqB;IAE1C;;;;OAIG;IACH,sBAHU,MAAM,CAGwD;IAExE;;;;OAIG;IACH,iBAHU,MAAM,CAMf;IAED;;;OAGG;IACH;;;QAEE;IAIF,kBAA6B;IAG7B,kBAAoB;IAGpB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