melonjs 20.1.0 → 20.1.1
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 +97 -12
- package/build/index.js.map +2 -2
- package/build/level/gltf/GLTFModel.d.ts +17 -1
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/loader/parsers/fontface.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/frameAnimation.d.ts +20 -2
- package/build/renderable/frameAnimation.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/system/timer.d.ts.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - 20.1.
|
|
2
|
+
* melonJS Game Engine - 20.1.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -12366,7 +12366,10 @@ var Timer = class {
|
|
|
12366
12366
|
* @ignore
|
|
12367
12367
|
*/
|
|
12368
12368
|
updateTimers() {
|
|
12369
|
-
for (const timer2 of this.timers) {
|
|
12369
|
+
for (const timer2 of [...this.timers]) {
|
|
12370
|
+
if (!this.timers.includes(timer2)) {
|
|
12371
|
+
continue;
|
|
12372
|
+
}
|
|
12370
12373
|
if (!(timer2.pauseable && state_default.isPaused())) {
|
|
12371
12374
|
timer2.elapsed += this.delta;
|
|
12372
12375
|
}
|
|
@@ -17607,7 +17610,7 @@ var Renderable = class _Renderable extends Rect {
|
|
|
17607
17610
|
*/
|
|
17608
17611
|
get parentApp() {
|
|
17609
17612
|
if (!this._parentApp && this.ancestor) {
|
|
17610
|
-
this._parentApp = this.ancestor.getRootAncestor()
|
|
17613
|
+
this._parentApp = this.ancestor.getRootAncestor()?.app;
|
|
17611
17614
|
}
|
|
17612
17615
|
return this._parentApp;
|
|
17613
17616
|
}
|
|
@@ -21076,6 +21079,9 @@ var FrameAnimation = class {
|
|
|
21076
21079
|
this.resetAnim = () => {
|
|
21077
21080
|
if (typeof onComplete === "function") {
|
|
21078
21081
|
onComplete();
|
|
21082
|
+
if (!this._isCurrentAnimationLive()) {
|
|
21083
|
+
return false;
|
|
21084
|
+
}
|
|
21079
21085
|
}
|
|
21080
21086
|
this.setCurrentAnimation(next, null, true);
|
|
21081
21087
|
};
|
|
@@ -21083,6 +21089,9 @@ var FrameAnimation = class {
|
|
|
21083
21089
|
this.resetAnim = () => {
|
|
21084
21090
|
if (typeof onComplete === "function") {
|
|
21085
21091
|
onComplete();
|
|
21092
|
+
if (!this._isCurrentAnimationLive()) {
|
|
21093
|
+
return false;
|
|
21094
|
+
}
|
|
21086
21095
|
}
|
|
21087
21096
|
this._animDone = true;
|
|
21088
21097
|
return false;
|
|
@@ -21168,6 +21177,26 @@ var FrameAnimation = class {
|
|
|
21168
21177
|
* @param {number} id - the frame id
|
|
21169
21178
|
* @returns {object} the frame data
|
|
21170
21179
|
*/
|
|
21180
|
+
/**
|
|
21181
|
+
* Whether the current animation is still resolvable.
|
|
21182
|
+
*
|
|
21183
|
+
* `update()` hands control to user code in the middle of its frame loop:
|
|
21184
|
+
* `onended`, and the completion callback behind `resetAnim`. That code is
|
|
21185
|
+
* free to tear the host down — "remove me once the animation finishes" is
|
|
21186
|
+
* an entirely reasonable reaction, and `removeChildNow()` destroys the
|
|
21187
|
+
* sprite, whose `destroy()` empties `anim`. Everything after the callback
|
|
21188
|
+
* reads out of `anim`, so the loop has to check it is still there rather
|
|
21189
|
+
* than resume into a map the callback just cleared.
|
|
21190
|
+
*
|
|
21191
|
+
* A callback that switches animations with `setCurrentAnimation()` leaves
|
|
21192
|
+
* this true, which is the point: only a genuinely torn-down host stops the
|
|
21193
|
+
* loop.
|
|
21194
|
+
* @ignore
|
|
21195
|
+
* @returns {boolean} true while the current animation can still be read
|
|
21196
|
+
*/
|
|
21197
|
+
_isCurrentAnimationLive() {
|
|
21198
|
+
return this.current !== void 0 && this.current !== null && this.anim[this.current.name] !== void 0;
|
|
21199
|
+
}
|
|
21171
21200
|
getAnimationFrameObjectByIndex(id) {
|
|
21172
21201
|
return this.anim[this.current.name].frames[id];
|
|
21173
21202
|
}
|
|
@@ -21201,6 +21230,9 @@ var FrameAnimation = class {
|
|
|
21201
21230
|
*/
|
|
21202
21231
|
update(dt) {
|
|
21203
21232
|
let changed = false;
|
|
21233
|
+
if (!this._isCurrentAnimationLive()) {
|
|
21234
|
+
return changed;
|
|
21235
|
+
}
|
|
21204
21236
|
if (!this.animationpause && !this._animDone && this.current.length > 1) {
|
|
21205
21237
|
let duration = this.getAnimationFrameObjectByIndex(
|
|
21206
21238
|
this.current.idx
|
|
@@ -21214,9 +21246,16 @@ var FrameAnimation = class {
|
|
|
21214
21246
|
if (this.current.idx === 0) {
|
|
21215
21247
|
if (typeof this.host.onended === "function") {
|
|
21216
21248
|
this.host.onended();
|
|
21249
|
+
if (!this._isCurrentAnimationLive()) {
|
|
21250
|
+
break;
|
|
21251
|
+
}
|
|
21217
21252
|
}
|
|
21218
21253
|
if (typeof this.resetAnim === "function") {
|
|
21219
|
-
|
|
21254
|
+
const keepPlaying = this.resetAnim();
|
|
21255
|
+
if (!this._isCurrentAnimationLive()) {
|
|
21256
|
+
break;
|
|
21257
|
+
}
|
|
21258
|
+
if (keepPlaying === false) {
|
|
21220
21259
|
this.setAnimationFrame(this.current.length - 1);
|
|
21221
21260
|
this.dt %= duration;
|
|
21222
21261
|
break;
|
|
@@ -23314,11 +23353,13 @@ function preloadBinary(data2, onload2, onerror, settings) {
|
|
|
23314
23353
|
// src/loader/parsers/fontface.js
|
|
23315
23354
|
function preloadFontFace(data2, onload2, onerror) {
|
|
23316
23355
|
const fontFaceSet = typeof globalThis.document !== "undefined" ? globalThis.document.fonts : void 0;
|
|
23317
|
-
|
|
23318
|
-
|
|
23356
|
+
let src = data2.src;
|
|
23357
|
+
if (!src.startsWith("url(") && !src.startsWith("local(")) {
|
|
23358
|
+
const escaped = src.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
23359
|
+
src = `url('${escaped}')`;
|
|
23319
23360
|
}
|
|
23320
23361
|
if (typeof fontFaceSet !== "undefined") {
|
|
23321
|
-
const font = new FontFace(data2.name,
|
|
23362
|
+
const font = new FontFace(data2.name, src);
|
|
23322
23363
|
font.load().then(
|
|
23323
23364
|
() => {
|
|
23324
23365
|
fontList[data2.name] = font;
|
|
@@ -26711,9 +26752,12 @@ var Container = class _Container extends Renderable {
|
|
|
26711
26752
|
let isFloating = false;
|
|
26712
26753
|
const isPaused = state_default.isPaused();
|
|
26713
26754
|
const children = this.getChildren();
|
|
26714
|
-
const childrenLength = children.length;
|
|
26715
26755
|
const cameras = state_default.current().cameras;
|
|
26716
|
-
|
|
26756
|
+
const pass = children.slice();
|
|
26757
|
+
for (let i = pass.length, obj; i--, obj = pass[i]; ) {
|
|
26758
|
+
if (obj.ancestor !== this) {
|
|
26759
|
+
continue;
|
|
26760
|
+
}
|
|
26717
26761
|
if (isPaused && !obj.updateWhenPaused) {
|
|
26718
26762
|
continue;
|
|
26719
26763
|
}
|
|
@@ -27053,6 +27097,9 @@ var GLTFModel = class extends Container {
|
|
|
27053
27097
|
this.resetAnim = () => {
|
|
27054
27098
|
if (typeof onComplete === "function") {
|
|
27055
27099
|
onComplete();
|
|
27100
|
+
if (!this._isLive()) {
|
|
27101
|
+
return false;
|
|
27102
|
+
}
|
|
27056
27103
|
}
|
|
27057
27104
|
this.setCurrentAnimation(next);
|
|
27058
27105
|
};
|
|
@@ -27060,6 +27107,9 @@ var GLTFModel = class extends Container {
|
|
|
27060
27107
|
this.resetAnim = () => {
|
|
27061
27108
|
if (typeof onComplete === "function") {
|
|
27062
27109
|
onComplete();
|
|
27110
|
+
if (!this._isLive()) {
|
|
27111
|
+
return false;
|
|
27112
|
+
}
|
|
27063
27113
|
}
|
|
27064
27114
|
this._animDone = true;
|
|
27065
27115
|
return false;
|
|
@@ -27139,6 +27189,9 @@ var GLTFModel = class extends Container {
|
|
|
27139
27189
|
if (this.current.time >= duration) {
|
|
27140
27190
|
if (typeof this.onended === "function") {
|
|
27141
27191
|
this.onended();
|
|
27192
|
+
if (!this._isLive()) {
|
|
27193
|
+
return super.update(dt);
|
|
27194
|
+
}
|
|
27142
27195
|
}
|
|
27143
27196
|
if (typeof this.resetAnim === "function") {
|
|
27144
27197
|
if (this.resetAnim() === false) {
|
|
@@ -27150,6 +27203,9 @@ var GLTFModel = class extends Container {
|
|
|
27150
27203
|
this.current.time %= duration;
|
|
27151
27204
|
}
|
|
27152
27205
|
}
|
|
27206
|
+
if (!this._isLive()) {
|
|
27207
|
+
return super.update(dt);
|
|
27208
|
+
}
|
|
27153
27209
|
this._pose();
|
|
27154
27210
|
this.isDirty = true;
|
|
27155
27211
|
}
|
|
@@ -27161,6 +27217,24 @@ var GLTFModel = class extends Container {
|
|
|
27161
27217
|
* not animate use their cached rest matrix.
|
|
27162
27218
|
* @ignore
|
|
27163
27219
|
*/
|
|
27220
|
+
/**
|
|
27221
|
+
* Whether this model is still alive.
|
|
27222
|
+
*
|
|
27223
|
+
* `update()` hands control to user code — `onended`, and the completion
|
|
27224
|
+
* callback behind `resetAnim` — and then poses the hierarchy. A callback
|
|
27225
|
+
* that removed the model (a death animation removing its own model is the
|
|
27226
|
+
* obvious case) has had `Renderable.destroy()` run, which releases `pos` to
|
|
27227
|
+
* the pool and leaves it undefined on every part. `_pose()` writes
|
|
27228
|
+
* `mesh.pos`, so it must not run on a torn-down model.
|
|
27229
|
+
*
|
|
27230
|
+
* `pos` and not `ancestor`: a model that was never added to a container is
|
|
27231
|
+
* perfectly poseable, and several callers do exactly that.
|
|
27232
|
+
* @ignore
|
|
27233
|
+
* @returns {boolean} true while the model can still be posed
|
|
27234
|
+
*/
|
|
27235
|
+
_isLive() {
|
|
27236
|
+
return this.pos !== void 0;
|
|
27237
|
+
}
|
|
27164
27238
|
_pose() {
|
|
27165
27239
|
const clip = this.current.name ? this.anim[this.current.name] : null;
|
|
27166
27240
|
const t = this.current.time;
|
|
@@ -48368,14 +48442,23 @@ var Detector = class {
|
|
|
48368
48442
|
objB.onCollisionActive(viewB, objA);
|
|
48369
48443
|
}
|
|
48370
48444
|
}
|
|
48445
|
+
if (objA.body === void 0 || objB.body === void 0) {
|
|
48446
|
+
continue;
|
|
48447
|
+
}
|
|
48371
48448
|
const eitherSensor = objA.body.isSensor === true || objB.body.isSensor === true || this.response.isTriggerContact === true;
|
|
48372
48449
|
const aHasModern = typeof objA.onCollisionActive === "function";
|
|
48373
48450
|
const bHasModern = typeof objB.onCollisionActive === "function";
|
|
48374
48451
|
const aOptsOut = !aHasModern && typeof objA.onCollision === "function" && objA.onCollision(this.response, objB) === false;
|
|
48452
|
+
if (objA.body === void 0 || objB.body === void 0) {
|
|
48453
|
+
continue;
|
|
48454
|
+
}
|
|
48375
48455
|
if (!aOptsOut && objA.body.isStatic === false && !eitherSensor) {
|
|
48376
48456
|
objA.body.respondToCollision.call(objA.body, this.response);
|
|
48377
48457
|
}
|
|
48378
48458
|
const bOptsOut = !bHasModern && typeof objB.onCollision === "function" && objB.onCollision(this.response, objA) === false;
|
|
48459
|
+
if (objA.body === void 0 || objB.body === void 0) {
|
|
48460
|
+
continue;
|
|
48461
|
+
}
|
|
48379
48462
|
if (!bOptsOut && objB.body.isStatic === false && !eitherSensor) {
|
|
48380
48463
|
objB.body.respondToCollision.call(objB.body, this.response);
|
|
48381
48464
|
}
|
|
@@ -48651,8 +48734,10 @@ var BuiltinAdapter = class {
|
|
|
48651
48734
|
this.detector.collisions(ancestor);
|
|
48652
48735
|
}
|
|
48653
48736
|
}
|
|
48654
|
-
body.force
|
|
48655
|
-
|
|
48737
|
+
if (body.force !== void 0) {
|
|
48738
|
+
body.force.set(0, 0);
|
|
48739
|
+
body.forceZ = 0;
|
|
48740
|
+
}
|
|
48656
48741
|
}
|
|
48657
48742
|
this.detector.endFrame();
|
|
48658
48743
|
}
|
|
@@ -50392,7 +50477,7 @@ var Trigger = class extends Renderable {
|
|
|
50392
50477
|
};
|
|
50393
50478
|
|
|
50394
50479
|
// src/version.ts
|
|
50395
|
-
var version = "20.1.
|
|
50480
|
+
var version = "20.1.1";
|
|
50396
50481
|
|
|
50397
50482
|
// src/system/bootstrap.ts
|
|
50398
50483
|
var initialized = false;
|