melonjs 20.5.0 → 20.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/application/defaultApplicationSettings.d.ts +1 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/settings.d.ts +37 -0
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/index.js +320 -62
- package/build/index.js.map +3 -3
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts.map +1 -1
- package/build/video/renderer.d.ts +44 -0
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/effect_binding.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/melonjs-effects-and-shaders/SKILL.md +37 -0
- package/skills/melonjs-loading-assets/SKILL.md +42 -8
- package/skills/melonjs-performance/SKILL.md +34 -6
- package/skills/melonjs-scenes-and-state/SKILL.md +37 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultApplicationSettings.d.ts","sourceRoot":"","sources":["../../src/application/defaultApplicationSettings.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"defaultApplicationSettings.d.ts","sourceRoot":"","sources":["../../src/application/defaultApplicationSettings.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;CAoBC,CAAC"}
|
|
@@ -100,6 +100,43 @@ export type ApplicationSettings = {
|
|
|
100
100
|
* @default false
|
|
101
101
|
*/
|
|
102
102
|
antiAlias: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Warm the renderer up during `loader.preload()`, behind the loading
|
|
105
|
+
* screen, instead of paying for it on the frame that first draws (GPU
|
|
106
|
+
* backends — the Canvas renderer has nothing to warm and ignores this).
|
|
107
|
+
*
|
|
108
|
+
* Today that means the built-in shader programs, which is all
|
|
109
|
+
* {@link Renderer#prewarm} does. Named for the intent rather than the
|
|
110
|
+
* current contents: anything else worth doing before the first frame
|
|
111
|
+
* belongs behind the same switch, and should not need a second setting.
|
|
112
|
+
*
|
|
113
|
+
* A GPU backend does not finish a shader when handed the source; it
|
|
114
|
+
* finishes it the first time something is drawn with it. That puts the
|
|
115
|
+
* whole cost on the frame a scene first appears, which is the moment a
|
|
116
|
+
* level or stage comes up and its geometry arrives a beat late. Warming
|
|
117
|
+
* up moves it to where a progress bar is already on screen.
|
|
118
|
+
*
|
|
119
|
+
* **On by default.** The cost is small and it is paid where nothing is
|
|
120
|
+
* waiting on a frame: a purely 2D game links the mesh-tier programs
|
|
121
|
+
* it will never bind — both the unlit tier and the lit one that inherits
|
|
122
|
+
* from it — measured at about 60ms on a fast desktop GPU, inside a preload
|
|
123
|
+
* that is already showing a progress bar. A tiny 2D game with a near-empty
|
|
124
|
+
* preload is the one case that pays without any possible benefit. Set it to
|
|
125
|
+
* `false` for a target where linking is slow enough that the preload
|
|
126
|
+
* itself would suffer.
|
|
127
|
+
*
|
|
128
|
+
* The warm-up is run by `loader.preload()` — every call, not just the
|
|
129
|
+
* first — so a game that preloads gets it automatically and a game that
|
|
130
|
+
* never calls `preload()` never gets it at all. Call
|
|
131
|
+
* {@link Renderer#prewarm} directly in that case.
|
|
132
|
+
*
|
|
133
|
+
* Shaders declared as assets (`{type: "shader"}`) are covered too, so a
|
|
134
|
+
* level's own effects are warmed by declaring them alongside that level's
|
|
135
|
+
* assets rather than building them inline when the level starts.
|
|
136
|
+
* @default true
|
|
137
|
+
* @see {@link Renderer#prewarm}
|
|
138
|
+
*/
|
|
139
|
+
prewarm: boolean;
|
|
103
140
|
/**
|
|
104
141
|
* Default texture magnification/minification filter, **decoupled from
|
|
105
142
|
* `antiAlias`** (GPU backends — WebGL and WebGPU; the 2D Canvas
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/application/settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,KAAK,SAAS,GACX,QAAQ,GACR,UAAU,GACV,SAAS,GACT,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,MAAM,GACN,SAAS,GACT,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC;AAEhB;;;;;;;;GAQG;AACH,KAAK,WAAW,GACb,SAAS,GACT,MAAM,GACN,cAAc,GACd;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAE/B,KAAK,eAAe,GAAG,SAAS,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAEpE,MAAM,MAAM,mBAAmB,GAAG;IACjC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,QAAQ,EAAE,YAAY,GAAG,QAAQ,CAAC;IAElC;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvB;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;;;;;;;;;;;;;;OAeG;IACH,eAAe,EAAE,eAAe,CAAC;IAEjC;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;;;;;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AAC,EAAE,OAAO,GACb,IAAI;IAmBP;;;;;;;;;;;;;OAaG;IACH,OAAO,CACN,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,QAAQ,GAAE,MAAa,EACvB,UAAU,CAAC,EAAE,MAAM,IAAI,GACrB,IAAI;IAWP;;;;;;;;;OASG;IACH,MAAM,CACL,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,QAAQ,GAAE,MAAa,EACvB,UAAU,CAAC,EAAE,MAAM,IAAI,GACrB,IAAI;IAWP;;;;;;OAMG;IACH,eAAe,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC;IAKrD;;;;;;OAMG;IACH,eAAe,CAAC,CAAC,SAAS,YAAY,EACrC,WAAW,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GACpC,CAAC,GAAG,SAAS;IAMhB;;;;;;OAMG;IACH,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAQ9C;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAQjC;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,GAAE,OAAsB,GAAG,OAAO;IA0BrE;;;;;;OAMG;IACH,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAS1D;;;;;;OAMG;IACH,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ;CA2S1D"}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - 20.
|
|
2
|
+
* melonJS Game Engine - 20.6.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -6891,6 +6891,52 @@ var Renderer = class _Renderer {
|
|
|
6891
6891
|
*/
|
|
6892
6892
|
flush() {
|
|
6893
6893
|
}
|
|
6894
|
+
/**
|
|
6895
|
+
* Compile the backend's built-in shader programs up front, so the first
|
|
6896
|
+
* frame that draws them does not stall while the driver builds them.
|
|
6897
|
+
*
|
|
6898
|
+
* A GPU backend does not finish a shader when you hand it the source. It
|
|
6899
|
+
* finishes it the first time something is actually drawn with it, which
|
|
6900
|
+
* puts the whole cost on the frame a scene first appears — the moment a
|
|
6901
|
+
* level or stage comes up and its geometry arrives a beat late. Calling
|
|
6902
|
+
* this while a loading screen is still on screen moves that cost to where
|
|
6903
|
+
* nobody is waiting on a frame.
|
|
6904
|
+
*
|
|
6905
|
+
* Resolves immediately on a backend with nothing to compile (Canvas).
|
|
6906
|
+
* What "ready" means is backend-specific and worth knowing: WebGL's link
|
|
6907
|
+
* blocks, so a resolved promise there means the programs are genuinely
|
|
6908
|
+
* built; WebGPU's `createShaderModule` returns before its compilation
|
|
6909
|
+
* finishes, so a resolved promise there means the modules have been
|
|
6910
|
+
* requested and validation is under way.
|
|
6911
|
+
*
|
|
6912
|
+
* **You normally do not call this.** `loader.preload()` calls it for you,
|
|
6913
|
+
* once the assets are in and before `LOADER_COMPLETE` fires — so it runs
|
|
6914
|
+
* while the loading screen is still up — whenever the application's
|
|
6915
|
+
* `prewarm` setting is on, which it is by default. Every `preload()` warms,
|
|
6916
|
+
* not just the first, so a per-level preload warms whatever that level
|
|
6917
|
+
* brought with it.
|
|
6918
|
+
*
|
|
6919
|
+
* Two consequences worth knowing:
|
|
6920
|
+
*
|
|
6921
|
+
* - **A game that never calls `loader.preload()` is never warmed.** There
|
|
6922
|
+
* is no other hook. Call this yourself if you load assets some other way
|
|
6923
|
+
* and still want the warm-up.
|
|
6924
|
+
* - It is deliberately NOT called from `Application.init()`. That runs
|
|
6925
|
+
* before anything is on screen, so warming there would only lengthen a
|
|
6926
|
+
* blank page instead of hiding behind a progress bar.
|
|
6927
|
+
* @returns {Promise<void>} settles when the built-in programs are ready
|
|
6928
|
+
* @example
|
|
6929
|
+
* // the usual case: nothing to write. `preload()` warms on the way through
|
|
6930
|
+
* await loader.preload(resources);
|
|
6931
|
+
* @example
|
|
6932
|
+
* // only needed if you do not use the preloader, or want a second warm-up
|
|
6933
|
+
* // at a point of your own choosing
|
|
6934
|
+
* await app.renderer.prewarm();
|
|
6935
|
+
* state.change(state.PLAY);
|
|
6936
|
+
*/
|
|
6937
|
+
prewarm() {
|
|
6938
|
+
return Promise.resolve();
|
|
6939
|
+
}
|
|
6894
6940
|
/**
|
|
6895
6941
|
* Mark the start of a screen-space (`floating`) draw, during which the
|
|
6896
6942
|
* camera's screen projection is installed and world-space geometry cannot
|
|
@@ -13429,7 +13475,7 @@ var input_exports = {};
|
|
|
13429
13475
|
__export(input_exports, {
|
|
13430
13476
|
GAMEPAD: () => GAMEPAD,
|
|
13431
13477
|
KEY: () => KEY,
|
|
13432
|
-
_app: () =>
|
|
13478
|
+
_app: () => _app3,
|
|
13433
13479
|
bindGamepad: () => bindGamepad,
|
|
13434
13480
|
bindKey: () => bindKey,
|
|
13435
13481
|
bindPointer: () => bindPointer,
|
|
@@ -20798,7 +20844,16 @@ var Camera2d = class extends Renderable {
|
|
|
20798
20844
|
container.draw(r, this);
|
|
20799
20845
|
}
|
|
20800
20846
|
renderer.flushTransparent();
|
|
20847
|
+
const hasCameraEffects = this.cameraEffects.length > 0;
|
|
20848
|
+
if (hasCameraEffects) {
|
|
20849
|
+
renderer.setProjection(this.screenProjection);
|
|
20850
|
+
}
|
|
20801
20851
|
this.drawFX(renderer);
|
|
20852
|
+
if (hasCameraEffects) {
|
|
20853
|
+
renderer.setProjection(
|
|
20854
|
+
isNonDefault ? this.worldProjection : this.projectionMatrix
|
|
20855
|
+
);
|
|
20856
|
+
}
|
|
20802
20857
|
container.postDraw(r);
|
|
20803
20858
|
this.postDraw(r);
|
|
20804
20859
|
if (stage) {
|
|
@@ -22291,6 +22346,13 @@ var DefaultLoadingScreen = class extends Stage {
|
|
|
22291
22346
|
* @internal
|
|
22292
22347
|
*/
|
|
22293
22348
|
#cleanedUp = false;
|
|
22349
|
+
/**
|
|
22350
|
+
* whether the preloader has reported done. Latched on LOADER_COMPLETE
|
|
22351
|
+
* and read by the logo's own load callback — NOT a teardown signal.
|
|
22352
|
+
* @ignore
|
|
22353
|
+
* @internal
|
|
22354
|
+
*/
|
|
22355
|
+
#loadingComplete = false;
|
|
22294
22356
|
/**
|
|
22295
22357
|
* Pin the loading screen to a Camera2d regardless of the
|
|
22296
22358
|
* application's `cameraClass` setting. The loader must render
|
|
@@ -22310,13 +22372,14 @@ var DefaultLoadingScreen = class extends Stage {
|
|
|
22310
22372
|
const barHeight = 8;
|
|
22311
22373
|
this.#app = app;
|
|
22312
22374
|
this.#cleanedUp = false;
|
|
22375
|
+
this.#loadingComplete = false;
|
|
22313
22376
|
app.world.backgroundColor.parseCSS("#202020");
|
|
22314
22377
|
const { width, height } = app.renderer;
|
|
22315
22378
|
this.progressBar = new ProgressBar(0, height / 2, width, barHeight);
|
|
22316
22379
|
app.world.addChild(this.progressBar, 1);
|
|
22317
|
-
once(LOADER_COMPLETE, this.#
|
|
22318
|
-
load2({ name: "melonjs_logo", type: "image", src: melonjs_logo_default }
|
|
22319
|
-
if (this.#cleanedUp) {
|
|
22380
|
+
once(LOADER_COMPLETE, this.#onLoaderComplete, this);
|
|
22381
|
+
load2({ name: "melonjs_logo", type: "image", src: melonjs_logo_default }).then(() => {
|
|
22382
|
+
if (this.#loadingComplete || this.#cleanedUp) {
|
|
22320
22383
|
return;
|
|
22321
22384
|
}
|
|
22322
22385
|
this.logoSprite = new Sprite(width / 2, height / 2, {
|
|
@@ -22325,8 +22388,18 @@ var DefaultLoadingScreen = class extends Stage {
|
|
|
22325
22388
|
frameheight: 256
|
|
22326
22389
|
});
|
|
22327
22390
|
app.world.addChild(this.logoSprite, 2);
|
|
22391
|
+
}).catch(() => {
|
|
22328
22392
|
});
|
|
22329
22393
|
}
|
|
22394
|
+
/**
|
|
22395
|
+
* The preloader is done. Latched so a late-arriving logo is not added
|
|
22396
|
+
* to a world that is about to be replaced; nothing is torn down here.
|
|
22397
|
+
* @ignore
|
|
22398
|
+
* @internal
|
|
22399
|
+
*/
|
|
22400
|
+
#onLoaderComplete() {
|
|
22401
|
+
this.#loadingComplete = true;
|
|
22402
|
+
}
|
|
22330
22403
|
/**
|
|
22331
22404
|
* Remove loading screen children and unload the logo
|
|
22332
22405
|
* @ignore
|
|
@@ -22354,8 +22427,8 @@ var DefaultLoadingScreen = class extends Stage {
|
|
|
22354
22427
|
* @internal
|
|
22355
22428
|
*/
|
|
22356
22429
|
onDestroyEvent() {
|
|
22357
|
-
if (!this.#
|
|
22358
|
-
off(LOADER_COMPLETE, this.#
|
|
22430
|
+
if (!this.#loadingComplete) {
|
|
22431
|
+
off(LOADER_COMPLETE, this.#onLoaderComplete, this);
|
|
22359
22432
|
}
|
|
22360
22433
|
this.#cleanup();
|
|
22361
22434
|
}
|
|
@@ -35128,6 +35201,21 @@ function initParsers() {
|
|
|
35128
35201
|
setParser("shader", preloadShader);
|
|
35129
35202
|
parserInitialized = true;
|
|
35130
35203
|
}
|
|
35204
|
+
var _app2;
|
|
35205
|
+
on(GAME_INIT, (app) => {
|
|
35206
|
+
_app2 = app;
|
|
35207
|
+
});
|
|
35208
|
+
function runShaderPrewarm() {
|
|
35209
|
+
if (_app2 === void 0 || _app2.settings?.prewarm !== true) {
|
|
35210
|
+
return Promise.resolve();
|
|
35211
|
+
}
|
|
35212
|
+
try {
|
|
35213
|
+
return Promise.resolve(_app2.renderer?.prewarm?.()).catch(() => {
|
|
35214
|
+
});
|
|
35215
|
+
} catch {
|
|
35216
|
+
return Promise.resolve();
|
|
35217
|
+
}
|
|
35218
|
+
}
|
|
35131
35219
|
function completeLoading(onloadcb) {
|
|
35132
35220
|
const callback = onloadcb || onload;
|
|
35133
35221
|
if (typeof callback === "function") {
|
|
@@ -35171,7 +35259,7 @@ function preload(assets, onloadcb, switchToLoadState = true) {
|
|
|
35171
35259
|
if (switchToLoadState === true) {
|
|
35172
35260
|
state_default.change(state_default.LOADING);
|
|
35173
35261
|
}
|
|
35174
|
-
return Promise.all(promises).then(() => {
|
|
35262
|
+
return Promise.all(promises).then(runShaderPrewarm).then(() => {
|
|
35175
35263
|
completeLoading(onload);
|
|
35176
35264
|
});
|
|
35177
35265
|
}
|
|
@@ -39017,6 +39105,18 @@ var WebGLBatcher = class extends Batcher {
|
|
|
39017
39105
|
vertex.clear();
|
|
39018
39106
|
}
|
|
39019
39107
|
}
|
|
39108
|
+
/**
|
|
39109
|
+
* Build any shader variant this batcher compiles lazily.
|
|
39110
|
+
*
|
|
39111
|
+
* A batcher whose only program is the one built in its constructor has
|
|
39112
|
+
* nothing to do here — which is every batcher but the mesh one.
|
|
39113
|
+
* @returns {Promise<void>} settles once this batcher is warm
|
|
39114
|
+
* @ignore
|
|
39115
|
+
* @internal
|
|
39116
|
+
*/
|
|
39117
|
+
prewarm() {
|
|
39118
|
+
return Promise.resolve();
|
|
39119
|
+
}
|
|
39020
39120
|
};
|
|
39021
39121
|
|
|
39022
39122
|
// src/video/gpu/primitives.ts
|
|
@@ -42070,6 +42170,71 @@ var MeshBatcher = class extends MaterialBatcher {
|
|
|
42070
42170
|
}
|
|
42071
42171
|
return shader;
|
|
42072
42172
|
}
|
|
42173
|
+
/**
|
|
42174
|
+
* Build every shader variant this batcher can reach, so none of them is
|
|
42175
|
+
* compiled on the frame a scene first draws.
|
|
42176
|
+
*
|
|
42177
|
+
* The set is enumerable because each variant is a source permutation, not
|
|
42178
|
+
* a runtime branch: fog on or off, and the three instance-record slots.
|
|
42179
|
+
* That is 1 fogged mesh + 8 instanced + 2 ground-shadow programs; the
|
|
42180
|
+
* plain mesh program is built in the constructor and is already here.
|
|
42181
|
+
*
|
|
42182
|
+
* Yields between programs. Linking is synchronous in WebGL and a dozen
|
|
42183
|
+
* links in one task is a dropped frame — which on a loading screen is a
|
|
42184
|
+
* stuttering progress bar, trading one visible hitch for another.
|
|
42185
|
+
* @returns {Promise<void>} settles once every variant is linked
|
|
42186
|
+
* @ignore
|
|
42187
|
+
* @internal
|
|
42188
|
+
*/
|
|
42189
|
+
async prewarm() {
|
|
42190
|
+
const yieldToFrame = () => {
|
|
42191
|
+
if (globalThis.document?.hidden === true) {
|
|
42192
|
+
return Promise.resolve();
|
|
42193
|
+
}
|
|
42194
|
+
return new Promise((resolve) => {
|
|
42195
|
+
setTimeout(resolve, 0);
|
|
42196
|
+
});
|
|
42197
|
+
};
|
|
42198
|
+
const alive = () => {
|
|
42199
|
+
return this.gl !== null && this.gl?.isContextLost?.() !== true;
|
|
42200
|
+
};
|
|
42201
|
+
const sources = this._shaderSources();
|
|
42202
|
+
const instanced = this._instancedShaderSources();
|
|
42203
|
+
for (const fogDefine of ["", "#define FOG\n"]) {
|
|
42204
|
+
if (fogDefine !== "") {
|
|
42205
|
+
this.shaderVariant("mesh|fog", sources, fogDefine, fogDefine);
|
|
42206
|
+
await yieldToFrame();
|
|
42207
|
+
if (!alive()) {
|
|
42208
|
+
return;
|
|
42209
|
+
}
|
|
42210
|
+
}
|
|
42211
|
+
for (const hasColor of [false, true]) {
|
|
42212
|
+
for (const hasData of [false, true]) {
|
|
42213
|
+
const key = (hasColor ? 1 : 0) | (hasData ? 2 : 0) | (fogDefine !== "" ? 4 : 0);
|
|
42214
|
+
this.shaderVariant(
|
|
42215
|
+
`instanced|${key}`,
|
|
42216
|
+
instanced,
|
|
42217
|
+
(hasColor ? "#define INSTANCE_COLORS\n" : "") + (hasData ? "#define INSTANCE_DATA\n" : "") + fogDefine,
|
|
42218
|
+
(hasData ? "#define INSTANCE_DATA\n" : "") + fogDefine
|
|
42219
|
+
);
|
|
42220
|
+
await yieldToFrame();
|
|
42221
|
+
if (!alive()) {
|
|
42222
|
+
return;
|
|
42223
|
+
}
|
|
42224
|
+
}
|
|
42225
|
+
}
|
|
42226
|
+
this.shaderVariant(
|
|
42227
|
+
fogDefine === "" ? "shadow" : "shadow|fog",
|
|
42228
|
+
{ vertex: mesh_shadow_instanced_default, fragment: mesh_default },
|
|
42229
|
+
fogDefine,
|
|
42230
|
+
fogDefine
|
|
42231
|
+
);
|
|
42232
|
+
await yieldToFrame();
|
|
42233
|
+
if (!alive()) {
|
|
42234
|
+
return;
|
|
42235
|
+
}
|
|
42236
|
+
}
|
|
42237
|
+
}
|
|
42073
42238
|
/**
|
|
42074
42239
|
* Whether the bound program is one this batcher would pick for a plain
|
|
42075
42240
|
* mesh — its own, or the fog variant of its own.
|
|
@@ -44343,6 +44508,7 @@ var WebGLRenderer = class _WebGLRenderer extends Renderer {
|
|
|
44343
44508
|
this.onContextRestoredInvalidate = (renderer) => {
|
|
44344
44509
|
if (renderer === this) {
|
|
44345
44510
|
this.currentProgram = void 0;
|
|
44511
|
+
this._prewarmed = void 0;
|
|
44346
44512
|
}
|
|
44347
44513
|
};
|
|
44348
44514
|
this.onCanvasResize = (width, height) => {
|
|
@@ -44426,6 +44592,29 @@ var WebGLRenderer = class _WebGLRenderer extends Renderer {
|
|
|
44426
44592
|
batcher.releaseRetained?.(mesh);
|
|
44427
44593
|
});
|
|
44428
44594
|
}
|
|
44595
|
+
/**
|
|
44596
|
+
* Compile every shader variant the built-in batchers can reach.
|
|
44597
|
+
*
|
|
44598
|
+
* A WebGL batcher builds its own program in its constructor, so the base
|
|
44599
|
+
* programs are already linked by the time `init()` resolves. What is not
|
|
44600
|
+
* is the mesh batcher's permutations — fog, and the three instance-record
|
|
44601
|
+
* slots — which are built on first use and so land on the frame a 3D
|
|
44602
|
+
* scene first draws.
|
|
44603
|
+
* @returns {Promise<void>} settles once every variant is linked
|
|
44604
|
+
* @see {@link Renderer#prewarm}
|
|
44605
|
+
*/
|
|
44606
|
+
prewarm() {
|
|
44607
|
+
if (this._prewarmed === void 0) {
|
|
44608
|
+
this._prewarmed = Promise.all(
|
|
44609
|
+
[...this.batchers.values()].map((batcher) => {
|
|
44610
|
+
return batcher.prewarm();
|
|
44611
|
+
})
|
|
44612
|
+
).then(() => {
|
|
44613
|
+
this.setBatcher("quad");
|
|
44614
|
+
});
|
|
44615
|
+
}
|
|
44616
|
+
return this._prewarmed;
|
|
44617
|
+
}
|
|
44429
44618
|
destroy() {
|
|
44430
44619
|
off(GAME_RESET, this.onGameReset);
|
|
44431
44620
|
off(ONCONTEXT_RESTORED, this.onContextRestoredInvalidate);
|
|
@@ -47315,8 +47504,8 @@ var Pointer = class extends Bounds {
|
|
|
47315
47504
|
this.isPrimary = typeof event.isPrimary !== "undefined" ? event.isPrimary : true;
|
|
47316
47505
|
this.button = event.button || 0;
|
|
47317
47506
|
this.type = event.type;
|
|
47318
|
-
if (typeof
|
|
47319
|
-
|
|
47507
|
+
if (typeof _app3?.viewport !== "undefined") {
|
|
47508
|
+
_app3.viewport.localToWorld(this.gameScreenX, this.gameScreenY, tmpVec);
|
|
47320
47509
|
}
|
|
47321
47510
|
this.gameWorldX = tmpVec.x;
|
|
47322
47511
|
this.gameWorldY = tmpVec.y;
|
|
@@ -47337,9 +47526,9 @@ var pointer_default = Pointer;
|
|
|
47337
47526
|
var T_POINTERS = [];
|
|
47338
47527
|
var eventHandlers = /* @__PURE__ */ new Map();
|
|
47339
47528
|
var currentPointer;
|
|
47340
|
-
var
|
|
47529
|
+
var _app3;
|
|
47341
47530
|
on(GAME_INIT, (app) => {
|
|
47342
|
-
|
|
47531
|
+
_app3 = app;
|
|
47343
47532
|
});
|
|
47344
47533
|
var pointerInitialized = false;
|
|
47345
47534
|
var lastTimeStamp = 0;
|
|
@@ -47403,7 +47592,7 @@ function registerEventListener(eventList, callback) {
|
|
|
47403
47592
|
}
|
|
47404
47593
|
function enablePointerEvent() {
|
|
47405
47594
|
if (!pointerInitialized) {
|
|
47406
|
-
if (!
|
|
47595
|
+
if (!_app3) {
|
|
47407
47596
|
throw new Error("Pointer events require an initialized Application");
|
|
47408
47597
|
}
|
|
47409
47598
|
currentPointer = new Rect(0, 0, 1, 1);
|
|
@@ -47411,7 +47600,7 @@ function enablePointerEvent() {
|
|
|
47411
47600
|
T_POINTERS.push(new pointer_default());
|
|
47412
47601
|
}
|
|
47413
47602
|
if (pointerEventTarget === null || pointerEventTarget === void 0) {
|
|
47414
|
-
pointerEventTarget =
|
|
47603
|
+
pointerEventTarget = _app3.renderer.getCanvas();
|
|
47415
47604
|
}
|
|
47416
47605
|
if (pointerEvent) {
|
|
47417
47606
|
activeEventList = pointerEventList;
|
|
@@ -47465,7 +47654,7 @@ function enablePointerEvent() {
|
|
|
47465
47654
|
globalThis.document.addEventListener(
|
|
47466
47655
|
POINTERLOCKCHANGE,
|
|
47467
47656
|
() => {
|
|
47468
|
-
locked = globalThis.document.pointerLockElement ===
|
|
47657
|
+
locked = globalThis.document.pointerLockElement === _app3.getParentElement();
|
|
47469
47658
|
emit(POINTERLOCKCHANGE, locked);
|
|
47470
47659
|
},
|
|
47471
47660
|
true
|
|
@@ -47515,7 +47704,7 @@ function dispatchEvent(normalizedEvents2) {
|
|
|
47515
47704
|
}
|
|
47516
47705
|
lastTimeStamp = pointer2.event.timeStamp;
|
|
47517
47706
|
}
|
|
47518
|
-
const worldOffset =
|
|
47707
|
+
const worldOffset = _app3.world.pos;
|
|
47519
47708
|
const absoluteWorldX = pointer2.gameWorldX + worldOffset.x;
|
|
47520
47709
|
const absoluteWorldY = pointer2.gameWorldY + worldOffset.y;
|
|
47521
47710
|
currentPointer.pos.set(pointer2.gameWorldX, pointer2.gameWorldY);
|
|
@@ -47525,16 +47714,16 @@ function dispatchEvent(normalizedEvents2) {
|
|
|
47525
47714
|
pointer2.gameY = pointer2.gameLocalY = pointer2.gameScreenY;
|
|
47526
47715
|
emit(POINTERMOVE, pointer2);
|
|
47527
47716
|
}
|
|
47528
|
-
let candidates =
|
|
47717
|
+
let candidates = _app3.world.broadphase.retrieve(
|
|
47529
47718
|
currentPointer,
|
|
47530
|
-
(a, b) =>
|
|
47719
|
+
(a, b) => _app3.world._sortReverseZ(a, b),
|
|
47531
47720
|
void 0
|
|
47532
47721
|
);
|
|
47533
47722
|
if (worldOffset.x !== 0 || worldOffset.y !== 0) {
|
|
47534
47723
|
currentPointer.pos.set(absoluteWorldX, absoluteWorldY);
|
|
47535
|
-
const absoluteCandidates =
|
|
47724
|
+
const absoluteCandidates = _app3.world.broadphase.retrieve(
|
|
47536
47725
|
currentPointer,
|
|
47537
|
-
(a, b) =>
|
|
47726
|
+
(a, b) => _app3.world._sortReverseZ(a, b),
|
|
47538
47727
|
void 0
|
|
47539
47728
|
);
|
|
47540
47729
|
for (const candidate of candidates) {
|
|
@@ -47543,10 +47732,10 @@ function dispatchEvent(normalizedEvents2) {
|
|
|
47543
47732
|
}
|
|
47544
47733
|
}
|
|
47545
47734
|
candidates = absoluteCandidates.sort(
|
|
47546
|
-
(a, b) =>
|
|
47735
|
+
(a, b) => _app3.world._sortReverseZ(a, b)
|
|
47547
47736
|
);
|
|
47548
47737
|
}
|
|
47549
|
-
candidates = candidates.concat([
|
|
47738
|
+
candidates = candidates.concat([_app3.viewport]);
|
|
47550
47739
|
for (let c = candidates.length, candidate; c--, candidate = candidates[c]; ) {
|
|
47551
47740
|
if (eventHandlers.has(candidate) && candidate.isKinematic !== true) {
|
|
47552
47741
|
const handlers = eventHandlers.get(candidate);
|
|
@@ -47709,11 +47898,11 @@ function hasRegisteredEvents() {
|
|
|
47709
47898
|
}
|
|
47710
47899
|
function globalToLocal(x, y, v) {
|
|
47711
47900
|
v = v || vector2dPool.get();
|
|
47712
|
-
const rect = getElementBounds(
|
|
47901
|
+
const rect = getElementBounds(_app3.renderer.getCanvas());
|
|
47713
47902
|
const pixelRatio = globalThis.devicePixelRatio || 1;
|
|
47714
47903
|
x -= rect.left + (globalThis.pageXOffset || 0);
|
|
47715
47904
|
y -= rect.top + (globalThis.pageYOffset || 0);
|
|
47716
|
-
const scale2 =
|
|
47905
|
+
const scale2 = _app3.renderer.scaleRatio;
|
|
47717
47906
|
if (scale2.x !== 1 || scale2.y !== 1) {
|
|
47718
47907
|
x /= scale2.x;
|
|
47719
47908
|
y /= scale2.y;
|
|
@@ -47805,7 +47994,7 @@ function releaseAllPointerEvents(region) {
|
|
|
47805
47994
|
}
|
|
47806
47995
|
function requestPointerLock() {
|
|
47807
47996
|
if (hasPointerLockSupport) {
|
|
47808
|
-
const element =
|
|
47997
|
+
const element = _app3.getParentElement();
|
|
47809
47998
|
void element.requestPointerLock();
|
|
47810
47999
|
return true;
|
|
47811
48000
|
}
|
|
@@ -52489,7 +52678,7 @@ var Trigger = class extends Renderable {
|
|
|
52489
52678
|
};
|
|
52490
52679
|
|
|
52491
52680
|
// src/version.ts
|
|
52492
|
-
var version = "20.
|
|
52681
|
+
var version = "20.6.0";
|
|
52493
52682
|
|
|
52494
52683
|
// src/system/bootstrap.ts
|
|
52495
52684
|
var initialized = false;
|
|
@@ -55216,46 +55405,75 @@ var WebGPUPipelineCache = class _WebGPUPipelineCache {
|
|
|
55216
55405
|
primitive.cullMode = meshState.cullMode;
|
|
55217
55406
|
primitive.frontFace = meshState.frontFace;
|
|
55218
55407
|
}
|
|
55219
|
-
pipeline = this.device.createRenderPipeline(
|
|
55220
|
-
|
|
55221
|
-
|
|
55222
|
-
|
|
55223
|
-
|
|
55224
|
-
|
|
55225
|
-
|
|
55226
|
-
...meshState ? { constants: { enable_fog: fogFlag } } : {}
|
|
55227
|
-
},
|
|
55228
|
-
fragment: {
|
|
55229
|
-
module: this.modules[shaderKey],
|
|
55230
|
-
entryPoint: "fragment_main",
|
|
55231
|
-
...meshState ? { constants: { enable_fog: fogFlag } } : {},
|
|
55232
|
-
targets: [
|
|
55233
|
-
{
|
|
55234
|
-
format: this.format,
|
|
55235
|
-
blend: shaderKey === "clear" ? void 0 : gpuBlendState(blend, pma),
|
|
55236
|
-
writeMask: stencil.colorWriteMask
|
|
55237
|
-
}
|
|
55238
|
-
]
|
|
55239
|
-
},
|
|
55240
|
-
primitive,
|
|
55241
|
-
depthStencil: {
|
|
55242
|
-
format: DEPTH_STENCIL_FORMAT,
|
|
55243
|
-
// `!== false`, not `!!`: mesh draws that never set the field (and
|
|
55244
|
-
// every bare `{cullMode, frontFace}` literal) must keep writing
|
|
55245
|
-
// depth exactly as they did before the axis existed
|
|
55246
|
-
depthWriteEnabled: meshState ? meshState.depthWrite !== false : false,
|
|
55247
|
-
depthCompare: meshState ? "less-equal" : "always",
|
|
55248
|
-
stencilFront: stencil.stencil,
|
|
55249
|
-
stencilBack: stencil.stencil,
|
|
55250
|
-
stencilReadMask: stencil.readMask,
|
|
55251
|
-
stencilWriteMask: stencil.writeMask
|
|
55252
|
-
},
|
|
55253
|
-
multisample: { count: this.sampleCount }
|
|
55254
|
-
});
|
|
55408
|
+
pipeline = this.device.createRenderPipeline(
|
|
55409
|
+
this._descriptor(key, shaderKey, blend, pma, stencil, primitive, {
|
|
55410
|
+
vertexLayout,
|
|
55411
|
+
meshState,
|
|
55412
|
+
fogFlag
|
|
55413
|
+
})
|
|
55414
|
+
);
|
|
55255
55415
|
this.pipelines.set(key, pipeline);
|
|
55256
55416
|
}
|
|
55257
55417
|
return pipeline;
|
|
55258
55418
|
}
|
|
55419
|
+
/**
|
|
55420
|
+
* Assemble a pipeline descriptor.
|
|
55421
|
+
*
|
|
55422
|
+
* Split out of `get()` so the descriptor can be read on its own — it is
|
|
55423
|
+
* long, and every field in it is load-bearing for cache correctness: a
|
|
55424
|
+
* pipeline built from a descriptor that differs from the one a draw would
|
|
55425
|
+
* have produced is worse than no cache entry at all, because the draw
|
|
55426
|
+
* silently builds a second one under a key nothing will hit again.
|
|
55427
|
+
* @param {string} key - the cache key, used as the label
|
|
55428
|
+
* @param {string} shaderKey - the module family
|
|
55429
|
+
* @param {string} blend - normalized blend mode
|
|
55430
|
+
* @param {boolean} pma - premultiplied alpha
|
|
55431
|
+
* @param {object} stencil - the resolved stencil state
|
|
55432
|
+
* @param {object} primitive - the resolved primitive state
|
|
55433
|
+
* @param {object} opts - `{vertexLayout, meshState, fogFlag}`
|
|
55434
|
+
* @returns {GPURenderPipelineDescriptor} the descriptor
|
|
55435
|
+
* @ignore
|
|
55436
|
+
* @internal
|
|
55437
|
+
*/
|
|
55438
|
+
_descriptor(key, shaderKey, blend, pma, stencil, primitive, opts) {
|
|
55439
|
+
const { vertexLayout, meshState, fogFlag } = opts;
|
|
55440
|
+
return {
|
|
55441
|
+
label: `melonJS ${key}`,
|
|
55442
|
+
layout: this.pipelineLayouts[shaderKey],
|
|
55443
|
+
vertex: {
|
|
55444
|
+
module: this.modules[shaderKey],
|
|
55445
|
+
entryPoint: "vertex_main",
|
|
55446
|
+
buffers: vertexLayout ?? [],
|
|
55447
|
+
...meshState ? { constants: { enable_fog: fogFlag } } : {}
|
|
55448
|
+
},
|
|
55449
|
+
fragment: {
|
|
55450
|
+
module: this.modules[shaderKey],
|
|
55451
|
+
entryPoint: "fragment_main",
|
|
55452
|
+
...meshState ? { constants: { enable_fog: fogFlag } } : {},
|
|
55453
|
+
targets: [
|
|
55454
|
+
{
|
|
55455
|
+
format: this.format,
|
|
55456
|
+
blend: shaderKey === "clear" ? void 0 : gpuBlendState(blend, pma),
|
|
55457
|
+
writeMask: stencil.colorWriteMask
|
|
55458
|
+
}
|
|
55459
|
+
]
|
|
55460
|
+
},
|
|
55461
|
+
primitive,
|
|
55462
|
+
depthStencil: {
|
|
55463
|
+
format: DEPTH_STENCIL_FORMAT,
|
|
55464
|
+
// `!== false`, not `!!`: mesh draws that never set the field (and
|
|
55465
|
+
// every bare `{cullMode, frontFace}` literal) must keep writing
|
|
55466
|
+
// depth exactly as they did before the axis existed
|
|
55467
|
+
depthWriteEnabled: meshState ? meshState.depthWrite !== false : false,
|
|
55468
|
+
depthCompare: meshState ? "less-equal" : "always",
|
|
55469
|
+
stencilFront: stencil.stencil,
|
|
55470
|
+
stencilBack: stencil.stencil,
|
|
55471
|
+
stencilReadMask: stencil.readMask,
|
|
55472
|
+
stencilWriteMask: stencil.writeMask
|
|
55473
|
+
},
|
|
55474
|
+
multisample: { count: this.sampleCount }
|
|
55475
|
+
};
|
|
55476
|
+
}
|
|
55259
55477
|
/**
|
|
55260
55478
|
* drop every cached pipeline (device loss — the whole cache object is
|
|
55261
55479
|
* rebuilt by the renderer's restore path, this exists for symmetry)
|
|
@@ -58450,6 +58668,45 @@ var WebGPURenderer = class _WebGPURenderer extends Renderer {
|
|
|
58450
58668
|
}
|
|
58451
58669
|
return this.renderPass;
|
|
58452
58670
|
}
|
|
58671
|
+
/**
|
|
58672
|
+
* Compile the WGSL module of every shader asset the loader has, ahead of
|
|
58673
|
+
* the frame that first draws it.
|
|
58674
|
+
*
|
|
58675
|
+
* WebGPU splits what WebGL fuses into one program. The **modules** for
|
|
58676
|
+
* the engine's own families — quad, blit, primitive, clear, and the mesh
|
|
58677
|
+
* tiers — are already created when the pipeline cache and the batchers
|
|
58678
|
+
* are constructed, so there is nothing lazy there to warm. A **pipeline**
|
|
58679
|
+
* is lazy, but it is keyed by draw state (blend, cull, depth-write) as
|
|
58680
|
+
* well as by shader, so the set a scene will ask for cannot be known from
|
|
58681
|
+
* here — and creating one costs almost nothing anyway, because WebGPU
|
|
58682
|
+
* records the intent and leaves the work to first use.
|
|
58683
|
+
*
|
|
58684
|
+
* What IS both lazy and knowable is a `ShaderEffect`'s module:
|
|
58685
|
+
* `prepareEffectBinding` builds it, and it is only ever called from
|
|
58686
|
+
* inside the draw path. Every effect the loader compiled from a
|
|
58687
|
+
* `{type: "shader"}` asset is already in `shaderList`, so those are
|
|
58688
|
+
* exactly the ones that can be brought forward — which is what makes
|
|
58689
|
+
* declaring a level's effects alongside that level's assets worth doing.
|
|
58690
|
+
*
|
|
58691
|
+
* Effects constructed inline when a stage builds are not here yet and
|
|
58692
|
+
* cannot be warmed; that is a property of when they come into existence,
|
|
58693
|
+
* not a limitation of this method.
|
|
58694
|
+
* @returns {Promise<void>} settles once those modules are built
|
|
58695
|
+
* @see {@link Renderer#prewarm}
|
|
58696
|
+
*/
|
|
58697
|
+
prewarm() {
|
|
58698
|
+
return Promise.resolve().then(() => {
|
|
58699
|
+
for (const effect of Object.values(shaderList)) {
|
|
58700
|
+
const realization = effect?.wgslRealization;
|
|
58701
|
+
if (realization === void 0 || realization.valid !== true) {
|
|
58702
|
+
continue;
|
|
58703
|
+
}
|
|
58704
|
+
if (realization.gpu === null || realization.gpu.epoch !== this.pipelineCache.epoch) {
|
|
58705
|
+
buildEffectGPU(this, effect, realization);
|
|
58706
|
+
}
|
|
58707
|
+
}
|
|
58708
|
+
});
|
|
58709
|
+
}
|
|
58453
58710
|
/**
|
|
58454
58711
|
* end the open pass and submit the frame's command buffer
|
|
58455
58712
|
* @override
|
|
@@ -60255,6 +60512,7 @@ var defaultApplicationSettings = {
|
|
|
60255
60512
|
powerPreference: "default",
|
|
60256
60513
|
transparent: false,
|
|
60257
60514
|
antiAlias: false,
|
|
60515
|
+
prewarm: true,
|
|
60258
60516
|
textureFilter: "auto",
|
|
60259
60517
|
maxTextures: "auto",
|
|
60260
60518
|
castGroundShadow: true,
|