melonjs 10.6.1 → 10.7.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.
@@ -1,22 +1,1022 @@
1
1
  /*!
2
- * melonJS Game Engine - v10.6.1
2
+ * melonJS Game Engine - v10.7.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
6
6
  * @copyright (C) 2011 - 2022 Olivier Biot
7
7
  */
8
- if (typeof window !== "undefined") {
9
- if (typeof window.console === "undefined") {
10
- window.console = {};
11
- window.console.log = function() {};
12
- window.console.assert = function() {};
13
- window.console.warn = function() {};
14
- window.console.error = function() {
8
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
9
+
10
+ var check = function (it) {
11
+ return it && it.Math == Math && it;
12
+ };
13
+
14
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
15
+ var global$m =
16
+ // eslint-disable-next-line es-x/no-global-this -- safe
17
+ check(typeof globalThis == 'object' && globalThis) ||
18
+ check(typeof window == 'object' && window) ||
19
+ // eslint-disable-next-line no-restricted-globals -- safe
20
+ check(typeof self == 'object' && self) ||
21
+ check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
22
+ // eslint-disable-next-line no-new-func -- fallback
23
+ (function () { return this; })() || Function('return this')();
24
+
25
+ var objectGetOwnPropertyDescriptor = {};
26
+
27
+ var fails$8 = function (exec) {
28
+ try {
29
+ return !!exec();
30
+ } catch (error) {
31
+ return true;
32
+ }
33
+ };
34
+
35
+ var fails$7 = fails$8;
36
+
37
+ // Detect IE8's incomplete defineProperty implementation
38
+ var descriptors = !fails$7(function () {
39
+ // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
40
+ return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
41
+ });
42
+
43
+ var fails$6 = fails$8;
44
+
45
+ var functionBindNative = !fails$6(function () {
46
+ // eslint-disable-next-line es-x/no-function-prototype-bind -- safe
47
+ var test = (function () { /* empty */ }).bind();
48
+ // eslint-disable-next-line no-prototype-builtins -- safe
49
+ return typeof test != 'function' || test.hasOwnProperty('prototype');
50
+ });
51
+
52
+ var NATIVE_BIND$1 = functionBindNative;
53
+
54
+ var call$4 = Function.prototype.call;
55
+
56
+ var functionCall = NATIVE_BIND$1 ? call$4.bind(call$4) : function () {
57
+ return call$4.apply(call$4, arguments);
58
+ };
59
+
60
+ var objectPropertyIsEnumerable = {};
61
+
62
+ var $propertyIsEnumerable = {}.propertyIsEnumerable;
63
+ // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
64
+ var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
65
+
66
+ // Nashorn ~ JDK8 bug
67
+ var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
68
+
69
+ // `Object.prototype.propertyIsEnumerable` method implementation
70
+ // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
71
+ objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
72
+ var descriptor = getOwnPropertyDescriptor$1(this, V);
73
+ return !!descriptor && descriptor.enumerable;
74
+ } : $propertyIsEnumerable;
75
+
76
+ var createPropertyDescriptor$2 = function (bitmap, value) {
77
+ return {
78
+ enumerable: !(bitmap & 1),
79
+ configurable: !(bitmap & 2),
80
+ writable: !(bitmap & 4),
81
+ value: value
82
+ };
83
+ };
84
+
85
+ var NATIVE_BIND = functionBindNative;
86
+
87
+ var FunctionPrototype$1 = Function.prototype;
88
+ var bind = FunctionPrototype$1.bind;
89
+ var call$3 = FunctionPrototype$1.call;
90
+ var uncurryThis$9 = NATIVE_BIND && bind.bind(call$3, call$3);
91
+
92
+ var functionUncurryThis = NATIVE_BIND ? function (fn) {
93
+ return fn && uncurryThis$9(fn);
94
+ } : function (fn) {
95
+ return fn && function () {
96
+ return call$3.apply(fn, arguments);
97
+ };
98
+ };
99
+
100
+ var uncurryThis$8 = functionUncurryThis;
101
+
102
+ var toString$2 = uncurryThis$8({}.toString);
103
+ var stringSlice = uncurryThis$8(''.slice);
104
+
105
+ var classofRaw = function (it) {
106
+ return stringSlice(toString$2(it), 8, -1);
107
+ };
108
+
109
+ var global$l = global$m;
110
+ var uncurryThis$7 = functionUncurryThis;
111
+ var fails$5 = fails$8;
112
+ var classof = classofRaw;
113
+
114
+ var Object$3 = global$l.Object;
115
+ var split = uncurryThis$7(''.split);
116
+
117
+ // fallback for non-array-like ES3 and non-enumerable old V8 strings
118
+ var indexedObject = fails$5(function () {
119
+ // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
120
+ // eslint-disable-next-line no-prototype-builtins -- safe
121
+ return !Object$3('z').propertyIsEnumerable(0);
122
+ }) ? function (it) {
123
+ return classof(it) == 'String' ? split(it, '') : Object$3(it);
124
+ } : Object$3;
125
+
126
+ var global$k = global$m;
127
+
128
+ var TypeError$7 = global$k.TypeError;
129
+
130
+ // `RequireObjectCoercible` abstract operation
131
+ // https://tc39.es/ecma262/#sec-requireobjectcoercible
132
+ var requireObjectCoercible$2 = function (it) {
133
+ if (it == undefined) throw TypeError$7("Can't call method on " + it);
134
+ return it;
135
+ };
136
+
137
+ // toObject with fallback for non-array-like ES3 strings
138
+ var IndexedObject = indexedObject;
139
+ var requireObjectCoercible$1 = requireObjectCoercible$2;
140
+
141
+ var toIndexedObject$3 = function (it) {
142
+ return IndexedObject(requireObjectCoercible$1(it));
143
+ };
144
+
145
+ // `IsCallable` abstract operation
146
+ // https://tc39.es/ecma262/#sec-iscallable
147
+ var isCallable$a = function (argument) {
148
+ return typeof argument == 'function';
149
+ };
150
+
151
+ var isCallable$9 = isCallable$a;
152
+
153
+ var isObject$5 = function (it) {
154
+ return typeof it == 'object' ? it !== null : isCallable$9(it);
155
+ };
156
+
157
+ var global$j = global$m;
158
+ var isCallable$8 = isCallable$a;
159
+
160
+ var aFunction = function (argument) {
161
+ return isCallable$8(argument) ? argument : undefined;
162
+ };
163
+
164
+ var getBuiltIn$3 = function (namespace, method) {
165
+ return arguments.length < 2 ? aFunction(global$j[namespace]) : global$j[namespace] && global$j[namespace][method];
166
+ };
167
+
168
+ var uncurryThis$6 = functionUncurryThis;
169
+
170
+ var objectIsPrototypeOf = uncurryThis$6({}.isPrototypeOf);
171
+
172
+ var getBuiltIn$2 = getBuiltIn$3;
173
+
174
+ var engineUserAgent = getBuiltIn$2('navigator', 'userAgent') || '';
175
+
176
+ var global$i = global$m;
177
+ var userAgent = engineUserAgent;
178
+
179
+ var process$1 = global$i.process;
180
+ var Deno = global$i.Deno;
181
+ var versions = process$1 && process$1.versions || Deno && Deno.version;
182
+ var v8 = versions && versions.v8;
183
+ var match, version$1;
184
+
185
+ if (v8) {
186
+ match = v8.split('.');
187
+ // in old Chrome, versions of V8 isn't V8 = Chrome / 10
188
+ // but their correct versions are not interesting for us
189
+ version$1 = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
190
+ }
191
+
192
+ // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
193
+ // so check `userAgent` even if `.v8` exists, but 0
194
+ if (!version$1 && userAgent) {
195
+ match = userAgent.match(/Edge\/(\d+)/);
196
+ if (!match || match[1] >= 74) {
197
+ match = userAgent.match(/Chrome\/(\d+)/);
198
+ if (match) version$1 = +match[1];
199
+ }
200
+ }
201
+
202
+ var engineV8Version = version$1;
203
+
204
+ /* eslint-disable es-x/no-symbol -- required for testing */
205
+
206
+ var V8_VERSION = engineV8Version;
207
+ var fails$4 = fails$8;
208
+
209
+ // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- required for testing
210
+ var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$4(function () {
211
+ var symbol = Symbol();
212
+ // Chrome 38 Symbol has incorrect toString conversion
213
+ // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
214
+ return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
215
+ // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
216
+ !Symbol.sham && V8_VERSION && V8_VERSION < 41;
217
+ });
218
+
219
+ /* eslint-disable es-x/no-symbol -- required for testing */
220
+
221
+ var NATIVE_SYMBOL$1 = nativeSymbol;
222
+
223
+ var useSymbolAsUid = NATIVE_SYMBOL$1
224
+ && !Symbol.sham
225
+ && typeof Symbol.iterator == 'symbol';
226
+
227
+ var global$h = global$m;
228
+ var getBuiltIn$1 = getBuiltIn$3;
229
+ var isCallable$7 = isCallable$a;
230
+ var isPrototypeOf = objectIsPrototypeOf;
231
+ var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
232
+
233
+ var Object$2 = global$h.Object;
234
+
235
+ var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
236
+ return typeof it == 'symbol';
237
+ } : function (it) {
238
+ var $Symbol = getBuiltIn$1('Symbol');
239
+ return isCallable$7($Symbol) && isPrototypeOf($Symbol.prototype, Object$2(it));
240
+ };
241
+
242
+ var global$g = global$m;
243
+
244
+ var String$2 = global$g.String;
245
+
246
+ var tryToString$1 = function (argument) {
247
+ try {
248
+ return String$2(argument);
249
+ } catch (error) {
250
+ return 'Object';
251
+ }
252
+ };
253
+
254
+ var global$f = global$m;
255
+ var isCallable$6 = isCallable$a;
256
+ var tryToString = tryToString$1;
257
+
258
+ var TypeError$6 = global$f.TypeError;
259
+
260
+ // `Assert: IsCallable(argument) is true`
261
+ var aCallable$1 = function (argument) {
262
+ if (isCallable$6(argument)) return argument;
263
+ throw TypeError$6(tryToString(argument) + ' is not a function');
264
+ };
265
+
266
+ var aCallable = aCallable$1;
267
+
268
+ // `GetMethod` abstract operation
269
+ // https://tc39.es/ecma262/#sec-getmethod
270
+ var getMethod$1 = function (V, P) {
271
+ var func = V[P];
272
+ return func == null ? undefined : aCallable(func);
273
+ };
274
+
275
+ var global$e = global$m;
276
+ var call$2 = functionCall;
277
+ var isCallable$5 = isCallable$a;
278
+ var isObject$4 = isObject$5;
279
+
280
+ var TypeError$5 = global$e.TypeError;
281
+
282
+ // `OrdinaryToPrimitive` abstract operation
283
+ // https://tc39.es/ecma262/#sec-ordinarytoprimitive
284
+ var ordinaryToPrimitive$1 = function (input, pref) {
285
+ var fn, val;
286
+ if (pref === 'string' && isCallable$5(fn = input.toString) && !isObject$4(val = call$2(fn, input))) return val;
287
+ if (isCallable$5(fn = input.valueOf) && !isObject$4(val = call$2(fn, input))) return val;
288
+ if (pref !== 'string' && isCallable$5(fn = input.toString) && !isObject$4(val = call$2(fn, input))) return val;
289
+ throw TypeError$5("Can't convert object to primitive value");
290
+ };
291
+
292
+ var shared$3 = {exports: {}};
293
+
294
+ var global$d = global$m;
295
+
296
+ // eslint-disable-next-line es-x/no-object-defineproperty -- safe
297
+ var defineProperty$1 = Object.defineProperty;
298
+
299
+ var setGlobal$3 = function (key, value) {
300
+ try {
301
+ defineProperty$1(global$d, key, { value: value, configurable: true, writable: true });
302
+ } catch (error) {
303
+ global$d[key] = value;
304
+ } return value;
305
+ };
306
+
307
+ var global$c = global$m;
308
+ var setGlobal$2 = setGlobal$3;
309
+
310
+ var SHARED = '__core-js_shared__';
311
+ var store$3 = global$c[SHARED] || setGlobal$2(SHARED, {});
312
+
313
+ var sharedStore = store$3;
314
+
315
+ var store$2 = sharedStore;
316
+
317
+ (shared$3.exports = function (key, value) {
318
+ return store$2[key] || (store$2[key] = value !== undefined ? value : {});
319
+ })('versions', []).push({
320
+ version: '3.22.4',
321
+ mode: 'global',
322
+ copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
323
+ license: 'https://github.com/zloirock/core-js/blob/v3.22.4/LICENSE',
324
+ source: 'https://github.com/zloirock/core-js'
325
+ });
326
+
327
+ var global$b = global$m;
328
+ var requireObjectCoercible = requireObjectCoercible$2;
329
+
330
+ var Object$1 = global$b.Object;
331
+
332
+ // `ToObject` abstract operation
333
+ // https://tc39.es/ecma262/#sec-toobject
334
+ var toObject$1 = function (argument) {
335
+ return Object$1(requireObjectCoercible(argument));
336
+ };
337
+
338
+ var uncurryThis$5 = functionUncurryThis;
339
+ var toObject = toObject$1;
340
+
341
+ var hasOwnProperty = uncurryThis$5({}.hasOwnProperty);
342
+
343
+ // `HasOwnProperty` abstract operation
344
+ // https://tc39.es/ecma262/#sec-hasownproperty
345
+ // eslint-disable-next-line es-x/no-object-hasown -- safe
346
+ var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
347
+ return hasOwnProperty(toObject(it), key);
348
+ };
349
+
350
+ var uncurryThis$4 = functionUncurryThis;
351
+
352
+ var id = 0;
353
+ var postfix = Math.random();
354
+ var toString$1 = uncurryThis$4(1.0.toString);
355
+
356
+ var uid$2 = function (key) {
357
+ return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36);
358
+ };
359
+
360
+ var global$a = global$m;
361
+ var shared$2 = shared$3.exports;
362
+ var hasOwn$6 = hasOwnProperty_1;
363
+ var uid$1 = uid$2;
364
+ var NATIVE_SYMBOL = nativeSymbol;
365
+ var USE_SYMBOL_AS_UID = useSymbolAsUid;
366
+
367
+ var WellKnownSymbolsStore = shared$2('wks');
368
+ var Symbol$1 = global$a.Symbol;
369
+ var symbolFor = Symbol$1 && Symbol$1['for'];
370
+ var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
371
+
372
+ var wellKnownSymbol$1 = function (name) {
373
+ if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
374
+ var description = 'Symbol.' + name;
375
+ if (NATIVE_SYMBOL && hasOwn$6(Symbol$1, name)) {
376
+ WellKnownSymbolsStore[name] = Symbol$1[name];
377
+ } else if (USE_SYMBOL_AS_UID && symbolFor) {
378
+ WellKnownSymbolsStore[name] = symbolFor(description);
379
+ } else {
380
+ WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
381
+ }
382
+ } return WellKnownSymbolsStore[name];
383
+ };
384
+
385
+ var global$9 = global$m;
386
+ var call$1 = functionCall;
387
+ var isObject$3 = isObject$5;
388
+ var isSymbol$1 = isSymbol$2;
389
+ var getMethod = getMethod$1;
390
+ var ordinaryToPrimitive = ordinaryToPrimitive$1;
391
+ var wellKnownSymbol = wellKnownSymbol$1;
392
+
393
+ var TypeError$4 = global$9.TypeError;
394
+ var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
395
+
396
+ // `ToPrimitive` abstract operation
397
+ // https://tc39.es/ecma262/#sec-toprimitive
398
+ var toPrimitive$1 = function (input, pref) {
399
+ if (!isObject$3(input) || isSymbol$1(input)) return input;
400
+ var exoticToPrim = getMethod(input, TO_PRIMITIVE);
401
+ var result;
402
+ if (exoticToPrim) {
403
+ if (pref === undefined) pref = 'default';
404
+ result = call$1(exoticToPrim, input, pref);
405
+ if (!isObject$3(result) || isSymbol$1(result)) return result;
406
+ throw TypeError$4("Can't convert object to primitive value");
407
+ }
408
+ if (pref === undefined) pref = 'number';
409
+ return ordinaryToPrimitive(input, pref);
410
+ };
411
+
412
+ var toPrimitive = toPrimitive$1;
413
+ var isSymbol = isSymbol$2;
414
+
415
+ // `ToPropertyKey` abstract operation
416
+ // https://tc39.es/ecma262/#sec-topropertykey
417
+ var toPropertyKey$2 = function (argument) {
418
+ var key = toPrimitive(argument, 'string');
419
+ return isSymbol(key) ? key : key + '';
420
+ };
421
+
422
+ var global$8 = global$m;
423
+ var isObject$2 = isObject$5;
424
+
425
+ var document$1 = global$8.document;
426
+ // typeof document.createElement is 'object' in old IE
427
+ var EXISTS$1 = isObject$2(document$1) && isObject$2(document$1.createElement);
428
+
429
+ var documentCreateElement = function (it) {
430
+ return EXISTS$1 ? document$1.createElement(it) : {};
431
+ };
432
+
433
+ var DESCRIPTORS$5 = descriptors;
434
+ var fails$3 = fails$8;
435
+ var createElement = documentCreateElement;
436
+
437
+ // Thanks to IE8 for its funny defineProperty
438
+ var ie8DomDefine = !DESCRIPTORS$5 && !fails$3(function () {
439
+ // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
440
+ return Object.defineProperty(createElement('div'), 'a', {
441
+ get: function () { return 7; }
442
+ }).a != 7;
443
+ });
444
+
445
+ var DESCRIPTORS$4 = descriptors;
446
+ var call = functionCall;
447
+ var propertyIsEnumerableModule = objectPropertyIsEnumerable;
448
+ var createPropertyDescriptor$1 = createPropertyDescriptor$2;
449
+ var toIndexedObject$2 = toIndexedObject$3;
450
+ var toPropertyKey$1 = toPropertyKey$2;
451
+ var hasOwn$5 = hasOwnProperty_1;
452
+ var IE8_DOM_DEFINE$1 = ie8DomDefine;
453
+
454
+ // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
455
+ var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
456
+
457
+ // `Object.getOwnPropertyDescriptor` method
458
+ // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
459
+ objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
460
+ O = toIndexedObject$2(O);
461
+ P = toPropertyKey$1(P);
462
+ if (IE8_DOM_DEFINE$1) try {
463
+ return $getOwnPropertyDescriptor$1(O, P);
464
+ } catch (error) { /* empty */ }
465
+ if (hasOwn$5(O, P)) return createPropertyDescriptor$1(!call(propertyIsEnumerableModule.f, O, P), O[P]);
466
+ };
467
+
468
+ var objectDefineProperty = {};
469
+
470
+ var DESCRIPTORS$3 = descriptors;
471
+ var fails$2 = fails$8;
472
+
473
+ // V8 ~ Chrome 36-
474
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3334
475
+ var v8PrototypeDefineBug = DESCRIPTORS$3 && fails$2(function () {
476
+ // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
477
+ return Object.defineProperty(function () { /* empty */ }, 'prototype', {
478
+ value: 42,
479
+ writable: false
480
+ }).prototype != 42;
481
+ });
482
+
483
+ var global$7 = global$m;
484
+ var isObject$1 = isObject$5;
485
+
486
+ var String$1 = global$7.String;
487
+ var TypeError$3 = global$7.TypeError;
488
+
489
+ // `Assert: Type(argument) is Object`
490
+ var anObject$2 = function (argument) {
491
+ if (isObject$1(argument)) return argument;
492
+ throw TypeError$3(String$1(argument) + ' is not an object');
493
+ };
494
+
495
+ var global$6 = global$m;
496
+ var DESCRIPTORS$2 = descriptors;
497
+ var IE8_DOM_DEFINE = ie8DomDefine;
498
+ var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
499
+ var anObject$1 = anObject$2;
500
+ var toPropertyKey = toPropertyKey$2;
501
+
502
+ var TypeError$2 = global$6.TypeError;
503
+ // eslint-disable-next-line es-x/no-object-defineproperty -- safe
504
+ var $defineProperty = Object.defineProperty;
505
+ // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
506
+ var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
507
+ var ENUMERABLE = 'enumerable';
508
+ var CONFIGURABLE$1 = 'configurable';
509
+ var WRITABLE = 'writable';
510
+
511
+ // `Object.defineProperty` method
512
+ // https://tc39.es/ecma262/#sec-object.defineproperty
513
+ objectDefineProperty.f = DESCRIPTORS$2 ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
514
+ anObject$1(O);
515
+ P = toPropertyKey(P);
516
+ anObject$1(Attributes);
517
+ if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
518
+ var current = $getOwnPropertyDescriptor(O, P);
519
+ if (current && current[WRITABLE]) {
520
+ O[P] = Attributes.value;
521
+ Attributes = {
522
+ configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
523
+ enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
524
+ writable: false
525
+ };
526
+ }
527
+ } return $defineProperty(O, P, Attributes);
528
+ } : $defineProperty : function defineProperty(O, P, Attributes) {
529
+ anObject$1(O);
530
+ P = toPropertyKey(P);
531
+ anObject$1(Attributes);
532
+ if (IE8_DOM_DEFINE) try {
533
+ return $defineProperty(O, P, Attributes);
534
+ } catch (error) { /* empty */ }
535
+ if ('get' in Attributes || 'set' in Attributes) throw TypeError$2('Accessors not supported');
536
+ if ('value' in Attributes) O[P] = Attributes.value;
537
+ return O;
538
+ };
539
+
540
+ var DESCRIPTORS$1 = descriptors;
541
+ var definePropertyModule$1 = objectDefineProperty;
542
+ var createPropertyDescriptor = createPropertyDescriptor$2;
543
+
544
+ var createNonEnumerableProperty$3 = DESCRIPTORS$1 ? function (object, key, value) {
545
+ return definePropertyModule$1.f(object, key, createPropertyDescriptor(1, value));
546
+ } : function (object, key, value) {
547
+ object[key] = value;
548
+ return object;
549
+ };
550
+
551
+ var makeBuiltIn$2 = {exports: {}};
552
+
553
+ var DESCRIPTORS = descriptors;
554
+ var hasOwn$4 = hasOwnProperty_1;
555
+
556
+ var FunctionPrototype = Function.prototype;
557
+ // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
558
+ var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
559
+
560
+ var EXISTS = hasOwn$4(FunctionPrototype, 'name');
561
+ // additional protection from minified / mangled / dropped function names
562
+ var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
563
+ var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
564
+
565
+ var functionName = {
566
+ EXISTS: EXISTS,
567
+ PROPER: PROPER,
568
+ CONFIGURABLE: CONFIGURABLE
569
+ };
570
+
571
+ var uncurryThis$3 = functionUncurryThis;
572
+ var isCallable$4 = isCallable$a;
573
+ var store$1 = sharedStore;
574
+
575
+ var functionToString = uncurryThis$3(Function.toString);
576
+
577
+ // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
578
+ if (!isCallable$4(store$1.inspectSource)) {
579
+ store$1.inspectSource = function (it) {
580
+ return functionToString(it);
581
+ };
582
+ }
583
+
584
+ var inspectSource$2 = store$1.inspectSource;
585
+
586
+ var global$5 = global$m;
587
+ var isCallable$3 = isCallable$a;
588
+ var inspectSource$1 = inspectSource$2;
589
+
590
+ var WeakMap$1 = global$5.WeakMap;
591
+
592
+ var nativeWeakMap = isCallable$3(WeakMap$1) && /native code/.test(inspectSource$1(WeakMap$1));
593
+
594
+ var shared$1 = shared$3.exports;
595
+ var uid = uid$2;
596
+
597
+ var keys = shared$1('keys');
598
+
599
+ var sharedKey$1 = function (key) {
600
+ return keys[key] || (keys[key] = uid(key));
601
+ };
602
+
603
+ var hiddenKeys$3 = {};
604
+
605
+ var NATIVE_WEAK_MAP = nativeWeakMap;
606
+ var global$4 = global$m;
607
+ var uncurryThis$2 = functionUncurryThis;
608
+ var isObject = isObject$5;
609
+ var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
610
+ var hasOwn$3 = hasOwnProperty_1;
611
+ var shared = sharedStore;
612
+ var sharedKey = sharedKey$1;
613
+ var hiddenKeys$2 = hiddenKeys$3;
614
+
615
+ var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
616
+ var TypeError$1 = global$4.TypeError;
617
+ var WeakMap = global$4.WeakMap;
618
+ var set, get, has;
619
+
620
+ var enforce = function (it) {
621
+ return has(it) ? get(it) : set(it, {});
622
+ };
623
+
624
+ var getterFor = function (TYPE) {
625
+ return function (it) {
626
+ var state;
627
+ if (!isObject(it) || (state = get(it)).type !== TYPE) {
628
+ throw TypeError$1('Incompatible receiver, ' + TYPE + ' required');
629
+ } return state;
630
+ };
631
+ };
632
+
633
+ if (NATIVE_WEAK_MAP || shared.state) {
634
+ var store = shared.state || (shared.state = new WeakMap());
635
+ var wmget = uncurryThis$2(store.get);
636
+ var wmhas = uncurryThis$2(store.has);
637
+ var wmset = uncurryThis$2(store.set);
638
+ set = function (it, metadata) {
639
+ if (wmhas(store, it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
640
+ metadata.facade = it;
641
+ wmset(store, it, metadata);
642
+ return metadata;
643
+ };
644
+ get = function (it) {
645
+ return wmget(store, it) || {};
646
+ };
647
+ has = function (it) {
648
+ return wmhas(store, it);
649
+ };
650
+ } else {
651
+ var STATE = sharedKey('state');
652
+ hiddenKeys$2[STATE] = true;
653
+ set = function (it, metadata) {
654
+ if (hasOwn$3(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
655
+ metadata.facade = it;
656
+ createNonEnumerableProperty$2(it, STATE, metadata);
657
+ return metadata;
658
+ };
659
+ get = function (it) {
660
+ return hasOwn$3(it, STATE) ? it[STATE] : {};
661
+ };
662
+ has = function (it) {
663
+ return hasOwn$3(it, STATE);
664
+ };
665
+ }
666
+
667
+ var internalState = {
668
+ set: set,
669
+ get: get,
670
+ has: has,
671
+ enforce: enforce,
672
+ getterFor: getterFor
673
+ };
674
+
675
+ var fails$1 = fails$8;
676
+ var isCallable$2 = isCallable$a;
677
+ var hasOwn$2 = hasOwnProperty_1;
678
+ var defineProperty = objectDefineProperty.f;
679
+ var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
680
+ var inspectSource = inspectSource$2;
681
+ var InternalStateModule = internalState;
682
+
683
+ var enforceInternalState = InternalStateModule.enforce;
684
+ var getInternalState = InternalStateModule.get;
685
+
686
+ var CONFIGURABLE_LENGTH = !fails$1(function () {
687
+ return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
688
+ });
689
+
690
+ var TEMPLATE = String(String).split('String');
691
+
692
+ var makeBuiltIn$1 = makeBuiltIn$2.exports = function (value, name, options) {
693
+ if (String(name).slice(0, 7) === 'Symbol(') {
694
+ name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
695
+ }
696
+ if (options && options.getter) name = 'get ' + name;
697
+ if (options && options.setter) name = 'set ' + name;
698
+ if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
699
+ defineProperty(value, 'name', { value: name, configurable: true });
700
+ }
701
+ if (CONFIGURABLE_LENGTH && options && hasOwn$2(options, 'arity') && value.length !== options.arity) {
702
+ defineProperty(value, 'length', { value: options.arity });
703
+ }
704
+ var state = enforceInternalState(value);
705
+ if (!hasOwn$2(state, 'source')) {
706
+ state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
707
+ } return value;
708
+ };
709
+
710
+ // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
711
+ // eslint-disable-next-line no-extend-native -- required
712
+ Function.prototype.toString = makeBuiltIn$1(function toString() {
713
+ return isCallable$2(this) && getInternalState(this).source || inspectSource(this);
714
+ }, 'toString');
715
+
716
+ var global$3 = global$m;
717
+ var isCallable$1 = isCallable$a;
718
+ var createNonEnumerableProperty$1 = createNonEnumerableProperty$3;
719
+ var makeBuiltIn = makeBuiltIn$2.exports;
720
+ var setGlobal$1 = setGlobal$3;
721
+
722
+ var defineBuiltIn$1 = function (O, key, value, options) {
723
+ var unsafe = options ? !!options.unsafe : false;
724
+ var simple = options ? !!options.enumerable : false;
725
+ var noTargetGet = options ? !!options.noTargetGet : false;
726
+ var name = options && options.name !== undefined ? options.name : key;
727
+ if (isCallable$1(value)) makeBuiltIn(value, name, options);
728
+ if (O === global$3) {
729
+ if (simple) O[key] = value;
730
+ else setGlobal$1(key, value);
731
+ return O;
732
+ } else if (!unsafe) {
733
+ delete O[key];
734
+ } else if (!noTargetGet && O[key]) {
735
+ simple = true;
736
+ }
737
+ if (simple) O[key] = value;
738
+ else createNonEnumerableProperty$1(O, key, value);
739
+ return O;
740
+ };
741
+
742
+ var objectGetOwnPropertyNames = {};
743
+
744
+ var ceil = Math.ceil;
745
+ var floor = Math.floor;
746
+
747
+ // `ToIntegerOrInfinity` abstract operation
748
+ // https://tc39.es/ecma262/#sec-tointegerorinfinity
749
+ var toIntegerOrInfinity$2 = function (argument) {
750
+ var number = +argument;
751
+ // eslint-disable-next-line no-self-compare -- safe
752
+ return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number);
753
+ };
754
+
755
+ var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
756
+
757
+ var max = Math.max;
758
+ var min$1 = Math.min;
759
+
760
+ // Helper for a popular repeating case of the spec:
761
+ // Let integer be ? ToInteger(index).
762
+ // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
763
+ var toAbsoluteIndex$1 = function (index, length) {
764
+ var integer = toIntegerOrInfinity$1(index);
765
+ return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
766
+ };
767
+
768
+ var toIntegerOrInfinity = toIntegerOrInfinity$2;
769
+
770
+ var min = Math.min;
771
+
772
+ // `ToLength` abstract operation
773
+ // https://tc39.es/ecma262/#sec-tolength
774
+ var toLength$1 = function (argument) {
775
+ return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
776
+ };
777
+
778
+ var toLength = toLength$1;
779
+
780
+ // `LengthOfArrayLike` abstract operation
781
+ // https://tc39.es/ecma262/#sec-lengthofarraylike
782
+ var lengthOfArrayLike$1 = function (obj) {
783
+ return toLength(obj.length);
784
+ };
785
+
786
+ var toIndexedObject$1 = toIndexedObject$3;
787
+ var toAbsoluteIndex = toAbsoluteIndex$1;
788
+ var lengthOfArrayLike = lengthOfArrayLike$1;
789
+
790
+ // `Array.prototype.{ indexOf, includes }` methods implementation
791
+ var createMethod = function (IS_INCLUDES) {
792
+ return function ($this, el, fromIndex) {
793
+ var O = toIndexedObject$1($this);
794
+ var length = lengthOfArrayLike(O);
795
+ var index = toAbsoluteIndex(fromIndex, length);
796
+ var value;
797
+ // Array#includes uses SameValueZero equality algorithm
798
+ // eslint-disable-next-line no-self-compare -- NaN check
799
+ if (IS_INCLUDES && el != el) while (length > index) {
800
+ value = O[index++];
801
+ // eslint-disable-next-line no-self-compare -- NaN check
802
+ if (value != value) return true;
803
+ // Array#indexOf ignores holes, Array#includes - not
804
+ } else for (;length > index; index++) {
805
+ if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
806
+ } return !IS_INCLUDES && -1;
807
+ };
808
+ };
809
+
810
+ var arrayIncludes = {
811
+ // `Array.prototype.includes` method
812
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
813
+ includes: createMethod(true),
814
+ // `Array.prototype.indexOf` method
815
+ // https://tc39.es/ecma262/#sec-array.prototype.indexof
816
+ indexOf: createMethod(false)
817
+ };
818
+
819
+ var uncurryThis$1 = functionUncurryThis;
820
+ var hasOwn$1 = hasOwnProperty_1;
821
+ var toIndexedObject = toIndexedObject$3;
822
+ var indexOf = arrayIncludes.indexOf;
823
+ var hiddenKeys$1 = hiddenKeys$3;
824
+
825
+ var push$1 = uncurryThis$1([].push);
826
+
827
+ var objectKeysInternal = function (object, names) {
828
+ var O = toIndexedObject(object);
829
+ var i = 0;
830
+ var result = [];
831
+ var key;
832
+ for (key in O) !hasOwn$1(hiddenKeys$1, key) && hasOwn$1(O, key) && push$1(result, key);
833
+ // Don't enum bug & hidden keys
834
+ while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
835
+ ~indexOf(result, key) || push$1(result, key);
836
+ }
837
+ return result;
838
+ };
839
+
840
+ // IE8- don't enum bug keys
841
+ var enumBugKeys$1 = [
842
+ 'constructor',
843
+ 'hasOwnProperty',
844
+ 'isPrototypeOf',
845
+ 'propertyIsEnumerable',
846
+ 'toLocaleString',
847
+ 'toString',
848
+ 'valueOf'
849
+ ];
850
+
851
+ var internalObjectKeys = objectKeysInternal;
852
+ var enumBugKeys = enumBugKeys$1;
853
+
854
+ var hiddenKeys = enumBugKeys.concat('length', 'prototype');
855
+
856
+ // `Object.getOwnPropertyNames` method
857
+ // https://tc39.es/ecma262/#sec-object.getownpropertynames
858
+ // eslint-disable-next-line es-x/no-object-getownpropertynames -- safe
859
+ objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
860
+ return internalObjectKeys(O, hiddenKeys);
861
+ };
862
+
863
+ var objectGetOwnPropertySymbols = {};
864
+
865
+ // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- safe
866
+ objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
867
+
868
+ var getBuiltIn = getBuiltIn$3;
869
+ var uncurryThis = functionUncurryThis;
870
+ var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
871
+ var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
872
+ var anObject = anObject$2;
873
+
874
+ var concat = uncurryThis([].concat);
875
+
876
+ // all object keys, includes non-enumerable and symbols
877
+ var ownKeys$1 = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
878
+ var keys = getOwnPropertyNamesModule.f(anObject(it));
879
+ var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
880
+ return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
881
+ };
882
+
883
+ var hasOwn = hasOwnProperty_1;
884
+ var ownKeys = ownKeys$1;
885
+ var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
886
+ var definePropertyModule = objectDefineProperty;
887
+
888
+ var copyConstructorProperties$1 = function (target, source, exceptions) {
889
+ var keys = ownKeys(source);
890
+ var defineProperty = definePropertyModule.f;
891
+ var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
892
+ for (var i = 0; i < keys.length; i++) {
893
+ var key = keys[i];
894
+ if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
895
+ defineProperty(target, key, getOwnPropertyDescriptor(source, key));
896
+ }
897
+ }
898
+ };
899
+
900
+ var fails = fails$8;
901
+ var isCallable = isCallable$a;
902
+
903
+ var replacement = /#|\.prototype\./;
904
+
905
+ var isForced$1 = function (feature, detection) {
906
+ var value = data$1[normalize$1(feature)];
907
+ return value == POLYFILL ? true
908
+ : value == NATIVE ? false
909
+ : isCallable(detection) ? fails(detection)
910
+ : !!detection;
911
+ };
912
+
913
+ var normalize$1 = isForced$1.normalize = function (string) {
914
+ return String(string).replace(replacement, '.').toLowerCase();
915
+ };
916
+
917
+ var data$1 = isForced$1.data = {};
918
+ var NATIVE = isForced$1.NATIVE = 'N';
919
+ var POLYFILL = isForced$1.POLYFILL = 'P';
920
+
921
+ var isForced_1 = isForced$1;
922
+
923
+ var global$2 = global$m;
924
+ var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
925
+ var createNonEnumerableProperty = createNonEnumerableProperty$3;
926
+ var defineBuiltIn = defineBuiltIn$1;
927
+ var setGlobal = setGlobal$3;
928
+ var copyConstructorProperties = copyConstructorProperties$1;
929
+ var isForced = isForced_1;
930
+
931
+ /*
932
+ options.target - name of the target object
933
+ options.global - target is the global object
934
+ options.stat - export as static methods of target
935
+ options.proto - export as prototype methods of target
936
+ options.real - real prototype method for the `pure` version
937
+ options.forced - export even if the native feature is available
938
+ options.bind - bind methods to the target, required for the `pure` version
939
+ options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
940
+ options.unsafe - use the simple assignment of property instead of delete + defineProperty
941
+ options.sham - add a flag to not completely full polyfills
942
+ options.enumerable - export as enumerable property
943
+ options.noTargetGet - prevent calling a getter on target
944
+ options.name - the .name of the function if it does not match the key
945
+ */
946
+ var _export = function (options, source) {
947
+ var TARGET = options.target;
948
+ var GLOBAL = options.global;
949
+ var STATIC = options.stat;
950
+ var FORCED, target, key, targetProperty, sourceProperty, descriptor;
951
+ if (GLOBAL) {
952
+ target = global$2;
953
+ } else if (STATIC) {
954
+ target = global$2[TARGET] || setGlobal(TARGET, {});
955
+ } else {
956
+ target = (global$2[TARGET] || {}).prototype;
957
+ }
958
+ if (target) for (key in source) {
959
+ sourceProperty = source[key];
960
+ if (options.noTargetGet) {
961
+ descriptor = getOwnPropertyDescriptor(target, key);
962
+ targetProperty = descriptor && descriptor.value;
963
+ } else targetProperty = target[key];
964
+ FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
965
+ // contained in target
966
+ if (!FORCED && targetProperty !== undefined) {
967
+ if (typeof sourceProperty == typeof targetProperty) continue;
968
+ copyConstructorProperties(sourceProperty, targetProperty);
969
+ }
970
+ // add a flag to not completely full polyfills
971
+ if (options.sham || (targetProperty && targetProperty.sham)) {
972
+ createNonEnumerableProperty(sourceProperty, 'sham', true);
973
+ }
974
+ defineBuiltIn(target, key, sourceProperty, options);
975
+ }
976
+ };
977
+
978
+ var $ = _export;
979
+ var global$1 = global$m;
980
+
981
+ // `globalThis` object
982
+ // https://tc39.es/ecma262/#sec-globalthis
983
+ $({ global: true }, {
984
+ globalThis: global$1
985
+ });
986
+
987
+ if (typeof globalThis !== "undefined") {
988
+ if (typeof globalThis.console === "undefined") {
989
+ globalThis.console = {};
990
+ globalThis.console.log = function() {};
991
+ globalThis.console.assert = function() {};
992
+ globalThis.console.warn = function() {};
993
+ globalThis.console.error = function() {
15
994
  alert(Array.prototype.slice.call(arguments).join(", "));
16
995
  };
17
996
  }
18
997
  }
19
998
 
999
+ if ("performance" in globalThis === false) {
1000
+ globalThis.performance = {};
1001
+ }
1002
+
1003
+ Date.now = (Date.now || function () { // thanks IE8
1004
+ return new Date().getTime();
1005
+ });
1006
+
1007
+ if ("now" in globalThis.performance === false) {
1008
+
1009
+ var nowOffset = Date.now();
1010
+
1011
+ if (performance.timing && performance.timing.navigationStart) {
1012
+ nowOffset = performance.timing.navigationStart;
1013
+ }
1014
+
1015
+ globalThis.performance.now = function now() {
1016
+ return Date.now() - nowOffset;
1017
+ };
1018
+ }
1019
+
20
1020
  /**
21
1021
  * a collection of string utility functions
22
1022
  * @namespace utils.string
@@ -104,13 +1104,13 @@ function toHex$1(str) {
104
1104
  }
105
1105
 
106
1106
  var stringUtils = /*#__PURE__*/Object.freeze({
107
- __proto__: null,
108
- capitalize: capitalize,
109
- trimLeft: trimLeft,
110
- trimRight: trimRight,
111
- isNumeric: isNumeric,
112
- isBoolean: isBoolean,
113
- toHex: toHex$1
1107
+ __proto__: null,
1108
+ capitalize: capitalize,
1109
+ trimLeft: trimLeft,
1110
+ trimRight: trimRight,
1111
+ isNumeric: isNumeric,
1112
+ isBoolean: isBoolean,
1113
+ toHex: toHex$1
114
1114
  });
115
1115
 
116
1116
  /**
@@ -130,12 +1130,12 @@ var vendors$1 = [ "ms", "MS", "moz", "webkit", "o" ];
130
1130
  * @name prefixed
131
1131
  * @function
132
1132
  * @param {string} name Property name
133
- * @param {object} [obj=window] Object or element reference to access
1133
+ * @param {object} [obj=globalThis] Object or element reference to access
134
1134
  * @returns {string} Value of property
135
1135
  * @memberof utils.agent
136
1136
  */
137
1137
  function prefixed(name, obj) {
138
- obj = obj || window;
1138
+ obj = obj || globalThis;
139
1139
  if (name in obj) {
140
1140
  return obj[name];
141
1141
  }
@@ -156,12 +1156,12 @@ function prefixed(name, obj) {
156
1156
  * @function
157
1157
  * @param {string} name Property name
158
1158
  * @param {string} value Property value
159
- * @param {object} [obj=window] Object or element reference to access
1159
+ * @param {object} [obj=globalThis] Object or element reference to access
160
1160
  * @returns {boolean} true if one of the vendor-prefixed property was found
161
1161
  * @memberof utils.agent
162
1162
  */
163
1163
  function setPrefixed(name, value, obj) {
164
- obj = obj || window;
1164
+ obj = obj || globalThis;
165
1165
  if (name in obj) {
166
1166
  obj[name] = value;
167
1167
  return;
@@ -181,9 +1181,9 @@ function setPrefixed(name, value, obj) {
181
1181
  }
182
1182
 
183
1183
  var agentUtils = /*#__PURE__*/Object.freeze({
184
- __proto__: null,
185
- prefixed: prefixed,
186
- setPrefixed: setPrefixed
1184
+ __proto__: null,
1185
+ prefixed: prefixed,
1186
+ setPrefixed: setPrefixed
187
1187
  });
188
1188
 
189
1189
  /**
@@ -398,22 +1398,22 @@ function toBeCloseTo(expected, actual, precision = 2) {
398
1398
  }
399
1399
 
400
1400
  var math = /*#__PURE__*/Object.freeze({
401
- __proto__: null,
402
- DEG_TO_RAD: DEG_TO_RAD,
403
- RAD_TO_DEG: RAD_TO_DEG,
404
- TAU: TAU,
405
- ETA: ETA,
406
- EPSILON: EPSILON,
407
- isPowerOfTwo: isPowerOfTwo,
408
- nextPowerOfTwo: nextPowerOfTwo,
409
- degToRad: degToRad,
410
- radToDeg: radToDeg,
411
- clamp: clamp,
412
- random: random$1,
413
- randomFloat: randomFloat,
414
- weightedRandom: weightedRandom$1,
415
- round: round,
416
- toBeCloseTo: toBeCloseTo
1401
+ __proto__: null,
1402
+ DEG_TO_RAD: DEG_TO_RAD,
1403
+ RAD_TO_DEG: RAD_TO_DEG,
1404
+ TAU: TAU,
1405
+ ETA: ETA,
1406
+ EPSILON: EPSILON,
1407
+ isPowerOfTwo: isPowerOfTwo,
1408
+ nextPowerOfTwo: nextPowerOfTwo,
1409
+ degToRad: degToRad,
1410
+ radToDeg: radToDeg,
1411
+ clamp: clamp,
1412
+ random: random$1,
1413
+ randomFloat: randomFloat,
1414
+ weightedRandom: weightedRandom$1,
1415
+ round: round,
1416
+ toBeCloseTo: toBeCloseTo
417
1417
  });
418
1418
 
419
1419
  /**
@@ -471,10 +1471,10 @@ function weightedRandom(arr) {
471
1471
  }
472
1472
 
473
1473
  var arrayUtils = /*#__PURE__*/Object.freeze({
474
- __proto__: null,
475
- remove: remove,
476
- random: random,
477
- weightedRandom: weightedRandom
1474
+ __proto__: null,
1475
+ remove: remove,
1476
+ random: random,
1477
+ weightedRandom: weightedRandom
478
1478
  });
479
1479
 
480
1480
  /**
@@ -513,9 +1513,9 @@ function getExtension(path) {
513
1513
  }
514
1514
 
515
1515
  var fileUtils = /*#__PURE__*/Object.freeze({
516
- __proto__: null,
517
- getBasename: getBasename,
518
- getExtension: getExtension
1516
+ __proto__: null,
1517
+ getBasename: getBasename,
1518
+ getExtension: getExtension
519
1519
  });
520
1520
 
521
1521
  /**
@@ -555,13 +1555,13 @@ function defer(func, thisArg, ...args) {
555
1555
  * @returns {Function} the function that will be throttled
556
1556
  */
557
1557
  function throttle(fn, delay, no_trailing) {
558
- var last = window.performance.now(), deferTimer;
1558
+ var last = globalThis.performance.now(), deferTimer;
559
1559
  // `no_trailing` defaults to false.
560
1560
  if (typeof no_trailing !== "boolean") {
561
1561
  no_trailing = false;
562
1562
  }
563
1563
  return function () {
564
- var now = window.performance.now();
1564
+ var now = globalThis.performance.now();
565
1565
  var elasped = now - last;
566
1566
  var args = arguments;
567
1567
  if (elasped < delay) {
@@ -582,9 +1582,9 @@ function throttle(fn, delay, no_trailing) {
582
1582
  }
583
1583
 
584
1584
  var fnUtils = /*#__PURE__*/Object.freeze({
585
- __proto__: null,
586
- defer: defer,
587
- throttle: throttle
1585
+ __proto__: null,
1586
+ defer: defer,
1587
+ throttle: throttle
588
1588
  });
589
1589
 
590
1590
  var objectClass = {};
@@ -766,14 +1766,14 @@ function getInstanceCount() {
766
1766
  }
767
1767
 
768
1768
  var pooling = /*#__PURE__*/Object.freeze({
769
- __proto__: null,
770
- register: register,
771
- pull: pull,
772
- purge: purge,
773
- push: push,
774
- exists: exists,
775
- poolable: poolable,
776
- getInstanceCount: getInstanceCount
1769
+ __proto__: null,
1770
+ register: register,
1771
+ pull: pull,
1772
+ purge: purge,
1773
+ push: push,
1774
+ exists: exists,
1775
+ poolable: poolable,
1776
+ getInstanceCount: getInstanceCount
777
1777
  });
778
1778
 
779
1779
  /**
@@ -2384,72 +3384,73 @@ class Matrix3d {
2384
3384
  * @returns {Matrix3d} Reference to this object for method chaining
2385
3385
  */
2386
3386
  rotate(angle, v) {
2387
- var a = this.val,
2388
- x = v.x,
2389
- y = v.y,
2390
- z = v.z;
2391
-
2392
- var len = Math.sqrt(x * x + y * y + z * z);
2393
-
2394
- var s, c, t;
2395
- var a00, a01, a02, a03;
2396
- var a10, a11, a12, a13;
2397
- var a20, a21, a22, a23;
2398
- var b00, b01, b02;
2399
- var b10, b11, b12;
2400
- var b20, b21, b22;
3387
+ if (angle !== 0) {
3388
+ var a = this.val,
3389
+ x = v.x,
3390
+ y = v.y,
3391
+ z = v.z;
3392
+
3393
+ var len = Math.sqrt(x * x + y * y + z * z);
3394
+
3395
+ var s, c, t;
3396
+ var a00, a01, a02, a03;
3397
+ var a10, a11, a12, a13;
3398
+ var a20, a21, a22, a23;
3399
+ var b00, b01, b02;
3400
+ var b10, b11, b12;
3401
+ var b20, b21, b22;
3402
+
3403
+ if (len < EPSILON) {
3404
+ return null;
3405
+ }
3406
+
3407
+ len = 1 / len;
3408
+ x *= len;
3409
+ y *= len;
3410
+ z *= len;
3411
+
3412
+ s = Math.sin(angle);
3413
+ c = Math.cos(angle);
3414
+ t = 1 - c;
3415
+
3416
+ a00 = a[0];
3417
+ a01 = a[1];
3418
+ a02 = a[2];
3419
+ a03 = a[3];
3420
+ a10 = a[4];
3421
+ a11 = a[5];
3422
+ a12 = a[6];
3423
+ a13 = a[7];
3424
+ a20 = a[8];
3425
+ a21 = a[9];
3426
+ a22 = a[10];
3427
+ a23 = a[11];
2401
3428
 
2402
- if (len < EPSILON) {
2403
- return null;
3429
+ // Construct the elements of the rotation matrix
3430
+ b00 = x * x * t + c;
3431
+ b01 = y * x * t + z * s;
3432
+ b02 = z * x * t - y * s;
3433
+ b10 = x * y * t - z * s;
3434
+ b11 = y * y * t + c;
3435
+ b12 = z * y * t + x * s;
3436
+ b20 = x * z * t + y * s;
3437
+ b21 = y * z * t - x * s;
3438
+ b22 = z * z * t + c;
3439
+
3440
+ // Perform rotation-specific matrix multiplication
3441
+ a[0] = a00 * b00 + a10 * b01 + a20 * b02;
3442
+ a[1] = a01 * b00 + a11 * b01 + a21 * b02;
3443
+ a[2] = a02 * b00 + a12 * b01 + a22 * b02;
3444
+ a[3] = a03 * b00 + a13 * b01 + a23 * b02;
3445
+ a[4] = a00 * b10 + a10 * b11 + a20 * b12;
3446
+ a[5] = a01 * b10 + a11 * b11 + a21 * b12;
3447
+ a[6] = a02 * b10 + a12 * b11 + a22 * b12;
3448
+ a[7] = a03 * b10 + a13 * b11 + a23 * b12;
3449
+ a[8] = a00 * b20 + a10 * b21 + a20 * b22;
3450
+ a[9] = a01 * b20 + a11 * b21 + a21 * b22;
3451
+ a[10] = a02 * b20 + a12 * b21 + a22 * b22;
3452
+ a[11] = a03 * b20 + a13 * b21 + a23 * b22;
2404
3453
  }
2405
-
2406
- len = 1 / len;
2407
- x *= len;
2408
- y *= len;
2409
- z *= len;
2410
-
2411
- s = Math.sin(angle);
2412
- c = Math.cos(angle);
2413
- t = 1 - c;
2414
-
2415
- a00 = a[0];
2416
- a01 = a[1];
2417
- a02 = a[2];
2418
- a03 = a[3];
2419
- a10 = a[4];
2420
- a11 = a[5];
2421
- a12 = a[6];
2422
- a13 = a[7];
2423
- a20 = a[8];
2424
- a21 = a[9];
2425
- a22 = a[10];
2426
- a23 = a[11];
2427
-
2428
- // Construct the elements of the rotation matrix
2429
- b00 = x * x * t + c;
2430
- b01 = y * x * t + z * s;
2431
- b02 = z * x * t - y * s;
2432
- b10 = x * y * t - z * s;
2433
- b11 = y * y * t + c;
2434
- b12 = z * y * t + x * s;
2435
- b20 = x * z * t + y * s;
2436
- b21 = y * z * t - x * s;
2437
- b22 = z * z * t + c;
2438
-
2439
- // Perform rotation-specific matrix multiplication
2440
- a[0] = a00 * b00 + a10 * b01 + a20 * b02;
2441
- a[1] = a01 * b00 + a11 * b01 + a21 * b02;
2442
- a[2] = a02 * b00 + a12 * b01 + a22 * b02;
2443
- a[3] = a03 * b00 + a13 * b01 + a23 * b02;
2444
- a[4] = a00 * b10 + a10 * b11 + a20 * b12;
2445
- a[5] = a01 * b10 + a11 * b11 + a21 * b12;
2446
- a[6] = a02 * b10 + a12 * b11 + a22 * b12;
2447
- a[7] = a03 * b10 + a13 * b11 + a23 * b12;
2448
- a[8] = a00 * b20 + a10 * b21 + a20 * b22;
2449
- a[9] = a01 * b20 + a11 * b21 + a21 * b22;
2450
- a[10] = a02 * b20 + a12 * b21 + a22 * b22;
2451
- a[11] = a03 * b20 + a13 * b21 + a23 * b22;
2452
-
2453
3454
  return this;
2454
3455
  }
2455
3456
 
@@ -3103,8 +4104,6 @@ class Matrix2d {
3103
4104
  }
3104
4105
  }
3105
4106
 
3106
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3107
-
3108
4107
  var eventemitter3 = {exports: {}};
3109
4108
 
3110
4109
  (function (module) {
@@ -3804,7 +4803,7 @@ const DRAGEND = "me.game.dragend";
3804
4803
  * @memberof event
3805
4804
  * @see event.on
3806
4805
  */
3807
- const WINDOW_ONRESIZE = "window.onresize";
4806
+ const WINDOW_ONRESIZE = "globalThis.onresize";
3808
4807
 
3809
4808
  /**
3810
4809
  * Event for when the canvas is resized <br>
@@ -3844,7 +4843,7 @@ const VIEWPORT_ONRESIZE = "viewport.onresize";
3844
4843
  * @memberof event
3845
4844
  * @see event.on
3846
4845
  */
3847
- const WINDOW_ONORIENTATION_CHANGE = "window.orientationchange";
4846
+ const WINDOW_ONORIENTATION_CHANGE = "globalThis.orientationchange";
3848
4847
 
3849
4848
  /**
3850
4849
  * Event for when the (browser) window is scrolled <br>
@@ -3856,7 +4855,7 @@ const WINDOW_ONORIENTATION_CHANGE = "window.orientationchange";
3856
4855
  * @memberof event
3857
4856
  * @see event.on
3858
4857
  */
3859
- const WINDOW_ONSCROLL = "window.onscroll";
4858
+ const WINDOW_ONSCROLL = "globalThis.onscroll";
3860
4859
 
3861
4860
  /**
3862
4861
  * Event for when the viewport position is updated <br>
@@ -3871,8 +4870,8 @@ const WINDOW_ONSCROLL = "window.onscroll";
3871
4870
  const VIEWPORT_ONCHANGE = "viewport.onchange";
3872
4871
 
3873
4872
  /**
3874
- * Event for when WebGL context is lost <br>
3875
- * Data passed : {me.WebGLRenderer} the current webgl renderer instance`
4873
+ * Event for when the current context is lost <br>
4874
+ * Data passed : {me.Renderer} the current renderer instance
3876
4875
  * @public
3877
4876
  * @constant
3878
4877
  * @type {string}
@@ -3880,19 +4879,19 @@ const VIEWPORT_ONCHANGE = "viewport.onchange";
3880
4879
  * @memberof event
3881
4880
  * @see event.on
3882
4881
  */
3883
- const WEBGL_ONCONTEXT_LOST = "renderer.webglcontextlost";
4882
+ const ONCONTEXT_LOST = "renderer.contextlost";
3884
4883
 
3885
4884
  /**
3886
- * Event for when WebGL context is restored <br>
3887
- * Data passed : {me.WebGLRenderer} the current webgl renderer instance`
4885
+ * Event for when the current context is restored <br>
4886
+ * Data passed : {me.Renderer} the current renderer instance`
3888
4887
  * @public
3889
4888
  * @constant
3890
4889
  * @type {string}
3891
- * @name WEBGL_ONCONTEXT_RESTORED
4890
+ * @name ONCONTEXT_RESTORED
3892
4891
  * @memberof event
3893
4892
  * @see event.on
3894
4893
  */
3895
- const WEBGL_ONCONTEXT_RESTORED = "renderer.webglcontextrestored";
4894
+ const ONCONTEXT_RESTORED = "renderer.contextrestored";
3896
4895
 
3897
4896
  /**
3898
4897
  * calls each of the listeners registered for a given event.
@@ -3948,45 +4947,45 @@ function off(eventName, listener) {
3948
4947
  return eventEmitter.off(eventName, listener);
3949
4948
  }
3950
4949
 
3951
- var event = /*#__PURE__*/Object.freeze({
3952
- __proto__: null,
3953
- BOOT: BOOT,
3954
- STATE_PAUSE: STATE_PAUSE,
3955
- STATE_RESUME: STATE_RESUME,
3956
- STATE_STOP: STATE_STOP,
3957
- STATE_RESTART: STATE_RESTART,
3958
- VIDEO_INIT: VIDEO_INIT,
3959
- GAME_INIT: GAME_INIT,
3960
- GAME_RESET: GAME_RESET,
3961
- GAME_BEFORE_UPDATE: GAME_BEFORE_UPDATE,
3962
- GAME_AFTER_UPDATE: GAME_AFTER_UPDATE,
3963
- GAME_UPDATE: GAME_UPDATE,
3964
- GAME_BEFORE_DRAW: GAME_BEFORE_DRAW,
3965
- GAME_AFTER_DRAW: GAME_AFTER_DRAW,
3966
- LEVEL_LOADED: LEVEL_LOADED,
3967
- LOADER_COMPLETE: LOADER_COMPLETE,
3968
- LOADER_PROGRESS: LOADER_PROGRESS,
3969
- KEYDOWN: KEYDOWN,
3970
- KEYUP: KEYUP,
3971
- GAMEPAD_CONNECTED: GAMEPAD_CONNECTED,
3972
- GAMEPAD_DISCONNECTED: GAMEPAD_DISCONNECTED,
3973
- GAMEPAD_UPDATE: GAMEPAD_UPDATE,
3974
- POINTERMOVE: POINTERMOVE,
3975
- POINTERLOCKCHANGE: POINTERLOCKCHANGE,
3976
- DRAGSTART: DRAGSTART,
3977
- DRAGEND: DRAGEND,
3978
- WINDOW_ONRESIZE: WINDOW_ONRESIZE,
3979
- CANVAS_ONRESIZE: CANVAS_ONRESIZE,
3980
- VIEWPORT_ONRESIZE: VIEWPORT_ONRESIZE,
3981
- WINDOW_ONORIENTATION_CHANGE: WINDOW_ONORIENTATION_CHANGE,
3982
- WINDOW_ONSCROLL: WINDOW_ONSCROLL,
3983
- VIEWPORT_ONCHANGE: VIEWPORT_ONCHANGE,
3984
- WEBGL_ONCONTEXT_LOST: WEBGL_ONCONTEXT_LOST,
3985
- WEBGL_ONCONTEXT_RESTORED: WEBGL_ONCONTEXT_RESTORED,
3986
- emit: emit,
3987
- on: on,
3988
- once: once,
3989
- off: off
4950
+ var event$1 = /*#__PURE__*/Object.freeze({
4951
+ __proto__: null,
4952
+ BOOT: BOOT,
4953
+ STATE_PAUSE: STATE_PAUSE,
4954
+ STATE_RESUME: STATE_RESUME,
4955
+ STATE_STOP: STATE_STOP,
4956
+ STATE_RESTART: STATE_RESTART,
4957
+ VIDEO_INIT: VIDEO_INIT,
4958
+ GAME_INIT: GAME_INIT,
4959
+ GAME_RESET: GAME_RESET,
4960
+ GAME_BEFORE_UPDATE: GAME_BEFORE_UPDATE,
4961
+ GAME_AFTER_UPDATE: GAME_AFTER_UPDATE,
4962
+ GAME_UPDATE: GAME_UPDATE,
4963
+ GAME_BEFORE_DRAW: GAME_BEFORE_DRAW,
4964
+ GAME_AFTER_DRAW: GAME_AFTER_DRAW,
4965
+ LEVEL_LOADED: LEVEL_LOADED,
4966
+ LOADER_COMPLETE: LOADER_COMPLETE,
4967
+ LOADER_PROGRESS: LOADER_PROGRESS,
4968
+ KEYDOWN: KEYDOWN,
4969
+ KEYUP: KEYUP,
4970
+ GAMEPAD_CONNECTED: GAMEPAD_CONNECTED,
4971
+ GAMEPAD_DISCONNECTED: GAMEPAD_DISCONNECTED,
4972
+ GAMEPAD_UPDATE: GAMEPAD_UPDATE,
4973
+ POINTERMOVE: POINTERMOVE,
4974
+ POINTERLOCKCHANGE: POINTERLOCKCHANGE,
4975
+ DRAGSTART: DRAGSTART,
4976
+ DRAGEND: DRAGEND,
4977
+ WINDOW_ONRESIZE: WINDOW_ONRESIZE,
4978
+ CANVAS_ONRESIZE: CANVAS_ONRESIZE,
4979
+ VIEWPORT_ONRESIZE: VIEWPORT_ONRESIZE,
4980
+ WINDOW_ONORIENTATION_CHANGE: WINDOW_ONORIENTATION_CHANGE,
4981
+ WINDOW_ONSCROLL: WINDOW_ONSCROLL,
4982
+ VIEWPORT_ONCHANGE: VIEWPORT_ONCHANGE,
4983
+ ONCONTEXT_LOST: ONCONTEXT_LOST,
4984
+ ONCONTEXT_RESTORED: ONCONTEXT_RESTORED,
4985
+ emit: emit,
4986
+ on: on,
4987
+ once: once,
4988
+ off: off
3990
4989
  });
3991
4990
 
3992
4991
  var howler = {};
@@ -10158,6 +11157,21 @@ class Rect extends Polygon {
10158
11157
  this.pos.y = value - (this.height / 2);
10159
11158
  }
10160
11159
 
11160
+ /**
11161
+ * center the rectangle position around the given coordinates
11162
+ * @name centerOn
11163
+ * @memberof Rect.prototype
11164
+ * @function
11165
+ * @param {number} x the x coordinate around which to center this rectangle
11166
+ * @param {number} x the y coordinate around which to center this rectangle
11167
+ * @returns {Rect} this rectangle
11168
+ */
11169
+ centerOn(x, y) {
11170
+ this.centerX = x;
11171
+ this.centerY = y;
11172
+ return this;
11173
+ }
11174
+
10161
11175
  /**
10162
11176
  * resize the rectangle
10163
11177
  * @name resize
@@ -10664,9 +11678,11 @@ var KEY = {
10664
11678
  function initKeyboardEvent() {
10665
11679
  // make sure the keyboard is enable
10666
11680
  if (keyBoardEventTarget === null && device$1.isMobile === false) {
10667
- keyBoardEventTarget = window;
10668
- keyBoardEventTarget.addEventListener("keydown", keyDownEvent, false);
10669
- keyBoardEventTarget.addEventListener("keyup", keyUpEvent, false);
11681
+ keyBoardEventTarget = globalThis;
11682
+ if (typeof keyBoardEventTarget.addEventListener === "function") {
11683
+ keyBoardEventTarget.addEventListener("keydown", keyDownEvent, false);
11684
+ keyBoardEventTarget.addEventListener("keyup", keyUpEvent, false);
11685
+ }
10670
11686
  }
10671
11687
  }
10672
11688
  /**
@@ -11591,7 +12607,7 @@ class Pointer extends Bounds$1 {
11591
12607
  this.gameScreenY = this.y = tmpVec.y;
11592
12608
 
11593
12609
  // true if not originally a pointer event
11594
- this.isNormalized = !device$1.PointerEvent || (device$1.PointerEvent && !(event instanceof window.PointerEvent));
12610
+ this.isNormalized = !device$1.PointerEvent || (device$1.PointerEvent && !(event instanceof globalThis.PointerEvent));
11595
12611
 
11596
12612
  this.locked = locked;
11597
12613
  this.movementX = event.movementX || 0;
@@ -12189,8 +13205,8 @@ function globalToLocal(x, y, v) {
12189
13205
  v = v || pull("Vector2d");
12190
13206
  var rect = device$1.getElementBounds(renderer.getScreenCanvas());
12191
13207
  var pixelRatio = device$1.devicePixelRatio;
12192
- x -= rect.left + (window.pageXOffset || 0);
12193
- y -= rect.top + (window.pageYOffset || 0);
13208
+ x -= rect.left + (globalThis.pageXOffset || 0);
13209
+ y -= rect.top + (globalThis.pageYOffset || 0);
12194
13210
  var scale = scaleRatio;
12195
13211
  if (scale.x !== 1.0 || scale.y !== 1.0) {
12196
13212
  x /= scale.x;
@@ -12405,7 +13421,6 @@ function releaseAllPointerEvents(region) {
12405
13421
  * @memberof input
12406
13422
  * @public
12407
13423
  * @function
12408
- * @param {Function} [success] callback if the request is successful
12409
13424
  * @returns {boolean} return true if the request was successfully submitted
12410
13425
  * @example
12411
13426
  * // register on the pointer lock change event
@@ -12703,17 +13718,19 @@ var updateGamepads = function () {
12703
13718
  * gamepad connected callback
12704
13719
  * @ignore
12705
13720
  */
12706
- window.addEventListener("gamepadconnected", function (e) {
12707
- emit(GAMEPAD_CONNECTED, e.gamepad);
12708
- }, false);
13721
+ if (globalThis.navigator && typeof globalThis.navigator.getGamepads === "function") {
13722
+ globalThis.addEventListener("gamepadconnected", function (e) {
13723
+ emit(GAMEPAD_CONNECTED, e.gamepad);
13724
+ }, false);
12709
13725
 
12710
- /**
12711
- * gamepad disconnected callback
12712
- * @ignore
12713
- */
12714
- window.addEventListener("gamepaddisconnected", function (e) {
12715
- emit(GAMEPAD_DISCONNECTED, e.gamepad);
12716
- }, false);
13726
+ /**
13727
+ * gamepad disconnected callback
13728
+ * @ignore
13729
+ */
13730
+ globalThis.addEventListener("gamepaddisconnected", function (e) {
13731
+ emit(GAMEPAD_DISCONNECTED, e.gamepad);
13732
+ }, false);
13733
+ }
12717
13734
 
12718
13735
  /*
12719
13736
  * PUBLIC STUFF
@@ -12951,36 +13968,36 @@ var setGamepadMapping = addMapping;
12951
13968
  var preventDefault = true;
12952
13969
 
12953
13970
  var input = /*#__PURE__*/Object.freeze({
12954
- __proto__: null,
12955
- preventDefault: preventDefault,
12956
- get pointerEventTarget () { return pointerEventTarget; },
12957
- pointer: pointer,
12958
- get locked () { return locked; },
12959
- get throttlingInterval () { return throttlingInterval; },
12960
- globalToLocal: globalToLocal,
12961
- setTouchAction: setTouchAction,
12962
- bindPointer: bindPointer,
12963
- unbindPointer: unbindPointer,
12964
- registerPointerEvent: registerPointerEvent,
12965
- releasePointerEvent: releasePointerEvent,
12966
- releaseAllPointerEvents: releaseAllPointerEvents,
12967
- requestPointerLock: requestPointerLock,
12968
- exitPointerLock: exitPointerLock,
12969
- get keyBoardEventTarget () { return keyBoardEventTarget; },
12970
- KEY: KEY,
12971
- initKeyboardEvent: initKeyboardEvent,
12972
- isKeyPressed: isKeyPressed,
12973
- keyStatus: keyStatus,
12974
- triggerKeyEvent: triggerKeyEvent,
12975
- bindKey: bindKey,
12976
- getBindingKey: getBindingKey,
12977
- unlockKey: unlockKey,
12978
- unbindKey: unbindKey,
12979
- GAMEPAD: GAMEPAD,
12980
- bindGamepad: bindGamepad,
12981
- unbindGamepad: unbindGamepad,
12982
- setGamepadDeadzone: setGamepadDeadzone,
12983
- setGamepadMapping: setGamepadMapping
13971
+ __proto__: null,
13972
+ preventDefault: preventDefault,
13973
+ get pointerEventTarget () { return pointerEventTarget; },
13974
+ pointer: pointer,
13975
+ get locked () { return locked; },
13976
+ get throttlingInterval () { return throttlingInterval; },
13977
+ globalToLocal: globalToLocal,
13978
+ setTouchAction: setTouchAction,
13979
+ bindPointer: bindPointer,
13980
+ unbindPointer: unbindPointer,
13981
+ registerPointerEvent: registerPointerEvent,
13982
+ releasePointerEvent: releasePointerEvent,
13983
+ releaseAllPointerEvents: releaseAllPointerEvents,
13984
+ requestPointerLock: requestPointerLock,
13985
+ exitPointerLock: exitPointerLock,
13986
+ get keyBoardEventTarget () { return keyBoardEventTarget; },
13987
+ KEY: KEY,
13988
+ initKeyboardEvent: initKeyboardEvent,
13989
+ isKeyPressed: isKeyPressed,
13990
+ keyStatus: keyStatus,
13991
+ triggerKeyEvent: triggerKeyEvent,
13992
+ bindKey: bindKey,
13993
+ getBindingKey: getBindingKey,
13994
+ unlockKey: unlockKey,
13995
+ unbindKey: unbindKey,
13996
+ GAMEPAD: GAMEPAD,
13997
+ bindGamepad: bindGamepad,
13998
+ unbindGamepad: unbindGamepad,
13999
+ setGamepadDeadzone: setGamepadDeadzone,
14000
+ setGamepadMapping: setGamepadMapping
12984
14001
  });
12985
14002
 
12986
14003
  /**
@@ -14603,11 +15620,11 @@ function testEllipsePolygon(a, ellipseA, b, polyB, response) {
14603
15620
  }
14604
15621
 
14605
15622
  var SAT = /*#__PURE__*/Object.freeze({
14606
- __proto__: null,
14607
- testPolygonPolygon: testPolygonPolygon,
14608
- testEllipseEllipse: testEllipseEllipse,
14609
- testPolygonEllipse: testPolygonEllipse,
14610
- testEllipsePolygon: testEllipsePolygon
15623
+ __proto__: null,
15624
+ testPolygonPolygon: testPolygonPolygon,
15625
+ testEllipseEllipse: testEllipseEllipse,
15626
+ testPolygonEllipse: testPolygonEllipse,
15627
+ testEllipsePolygon: testEllipsePolygon
14611
15628
  });
14612
15629
 
14613
15630
  // a dummy object when using Line for raycasting
@@ -17302,7 +18319,7 @@ let sortOn = "z";
17302
18319
  * @name lastUpdate
17303
18320
  * @memberof game
17304
18321
  */
17305
- let lastUpdate = window.performance.now();
18322
+ let lastUpdate = globalThis.performance.now();
17306
18323
 
17307
18324
  /**
17308
18325
  * Fired when a level is fully loaded and all entities instantiated. <br>
@@ -17392,7 +18409,7 @@ function update$1(time, stage) {
17392
18409
  accumulatorUpdateDelta = (timer$1.interpolation) ? updateDelta : Math.max(updateDelta, updateAverageDelta);
17393
18410
 
17394
18411
  while (accumulator >= accumulatorUpdateDelta || timer$1.interpolation) {
17395
- lastUpdateStart = window.performance.now();
18412
+ lastUpdateStart = globalThis.performance.now();
17396
18413
 
17397
18414
  // game update event
17398
18415
  if (state.isPaused() !== true) {
@@ -17402,7 +18419,7 @@ function update$1(time, stage) {
17402
18419
  // update all objects (and pass the elapsed time since last frame)
17403
18420
  isDirty = stage.update(updateDelta) || isDirty;
17404
18421
 
17405
- lastUpdate = window.performance.now();
18422
+ lastUpdate = globalThis.performance.now();
17406
18423
  updateAverageDelta = lastUpdate - lastUpdateStart;
17407
18424
 
17408
18425
  accumulator -= accumulatorUpdateDelta;
@@ -17426,7 +18443,7 @@ function draw(stage) {
17426
18443
 
17427
18444
  if (renderer.isContextValid === true && (isDirty || isAlwaysDirty)) {
17428
18445
  // publish notification
17429
- emit(GAME_BEFORE_DRAW, window.performance.now());
18446
+ emit(GAME_BEFORE_DRAW, globalThis.performance.now());
17430
18447
 
17431
18448
  // prepare renderer to draw a new frame
17432
18449
  renderer.clear();
@@ -17441,24 +18458,24 @@ function draw(stage) {
17441
18458
  renderer.flush();
17442
18459
 
17443
18460
  // publish notification
17444
- emit(GAME_AFTER_DRAW, window.performance.now());
18461
+ emit(GAME_AFTER_DRAW, globalThis.performance.now());
17445
18462
  }
17446
18463
  }
17447
18464
 
17448
18465
  var game = /*#__PURE__*/Object.freeze({
17449
- __proto__: null,
17450
- get viewport () { return viewport; },
17451
- get world () { return world; },
17452
- mergeGroup: mergeGroup,
17453
- sortOn: sortOn,
17454
- get lastUpdate () { return lastUpdate; },
17455
- onLevelLoaded: onLevelLoaded,
17456
- reset: reset,
17457
- updateFrameRate: updateFrameRate,
17458
- getParentContainer: getParentContainer,
17459
- repaint: repaint,
17460
- update: update$1,
17461
- draw: draw
18466
+ __proto__: null,
18467
+ get viewport () { return viewport; },
18468
+ get world () { return world; },
18469
+ mergeGroup: mergeGroup,
18470
+ sortOn: sortOn,
18471
+ get lastUpdate () { return lastUpdate; },
18472
+ onLevelLoaded: onLevelLoaded,
18473
+ reset: reset,
18474
+ updateFrameRate: updateFrameRate,
18475
+ getParentContainer: getParentContainer,
18476
+ repaint: repaint,
18477
+ update: update$1,
18478
+ draw: draw
17462
18479
  });
17463
18480
 
17464
18481
  // some ref shortcut
@@ -18556,7 +19573,7 @@ function _startRunLoop() {
18556
19573
  timer$1.reset();
18557
19574
 
18558
19575
  // start the main loop
18559
- _animFrameId = window.requestAnimationFrame(_renderFrame);
19576
+ _animFrameId = globalThis.requestAnimationFrame(_renderFrame);
18560
19577
  }
18561
19578
  }
18562
19579
 
@@ -18596,7 +19613,7 @@ function _renderFrame(time) {
18596
19613
  draw(stage);
18597
19614
  // schedule the next frame update
18598
19615
  if (_animFrameId !== -1) {
18599
- _animFrameId = window.requestAnimationFrame(_renderFrame);
19616
+ _animFrameId = globalThis.requestAnimationFrame(_renderFrame);
18600
19617
  }
18601
19618
  }
18602
19619
 
@@ -18606,7 +19623,7 @@ function _renderFrame(time) {
18606
19623
  */
18607
19624
  function _stopRunLoop() {
18608
19625
  // cancel any previous animationRequestFrame
18609
- window.cancelAnimationFrame(_animFrameId);
19626
+ globalThis.cancelAnimationFrame(_animFrameId);
18610
19627
  _animFrameId = -1;
18611
19628
  }
18612
19629
 
@@ -18779,7 +19796,7 @@ var state = {
18779
19796
  }
18780
19797
 
18781
19798
  // store time when stopped
18782
- _pauseTime = window.performance.now();
19799
+ _pauseTime = globalThis.performance.now();
18783
19800
 
18784
19801
  // publish the stop notification
18785
19802
  emit(STATE_STOP);
@@ -18805,7 +19822,7 @@ var state = {
18805
19822
  }
18806
19823
 
18807
19824
  // store time when paused
18808
- _pauseTime = window.performance.now();
19825
+ _pauseTime = globalThis.performance.now();
18809
19826
 
18810
19827
  // publish the pause event
18811
19828
  emit(STATE_PAUSE);
@@ -18830,7 +19847,7 @@ var state = {
18830
19847
  }
18831
19848
 
18832
19849
  // calculate the elpased time
18833
- _pauseTime = window.performance.now() - _pauseTime;
19850
+ _pauseTime = globalThis.performance.now() - _pauseTime;
18834
19851
 
18835
19852
  // force repaint
18836
19853
  repaint();
@@ -18858,7 +19875,7 @@ var state = {
18858
19875
  }
18859
19876
 
18860
19877
  // calculate the elpased time
18861
- _pauseTime = window.performance.now() - _pauseTime;
19878
+ _pauseTime = globalThis.performance.now() - _pauseTime;
18862
19879
 
18863
19880
  // publish the resume event
18864
19881
  emit(STATE_RESUME, _pauseTime);
@@ -19199,7 +20216,7 @@ function decodeBase64AsArray(input, bytes) {
19199
20216
  bytes = bytes || 1;
19200
20217
 
19201
20218
  var i, j, len;
19202
- var dec = window.atob(input.replace(/[^A-Za-z0-9\+\/\=]/g, ""));
20219
+ var dec = globalThis.atob(input.replace(/[^A-Za-z0-9\+\/\=]/g, ""));
19203
20220
  var ar = new Uint32Array(dec.length / bytes);
19204
20221
 
19205
20222
  for (i = 0, len = dec.length / bytes; i < len; i++) {
@@ -21479,9 +22496,9 @@ class Renderer {
21479
22496
  if (device$1.ejecta === true) {
21480
22497
  // a main canvas is already automatically created by Ejecta
21481
22498
  this.canvas = document.getElementById("canvas");
21482
- } else if (typeof window.canvas !== "undefined") {
22499
+ } else if (typeof globalThis.canvas !== "undefined") {
21483
22500
  // a global canvas is available, e.g. webapp adapter for wechat
21484
- this.canvas = window.canvas;
22501
+ this.canvas = globalThis.canvas;
21485
22502
  } else if (typeof this.settings.canvas !== "undefined") {
21486
22503
  this.canvas = this.settings.canvas;
21487
22504
  } else {
@@ -21908,6 +22925,19 @@ class CanvasRenderer extends Renderer {
21908
22925
  // enable the tile texture seam fix with the canvas renderer
21909
22926
  this.uvOffset = 1;
21910
22927
  }
22928
+
22929
+ // context lost & restore event for canvas
22930
+ this.getScreenCanvas().addEventListener("contextlost", (e) => {
22931
+ e.preventDefault();
22932
+ this.isContextValid = false;
22933
+ event.emit(event.ONCONTEXT_LOST, this);
22934
+ }, false );
22935
+ // ctx.restoreContext()
22936
+ this.getScreenCanvas().addEventListener("contextrestored", () => {
22937
+ this.isContextValid = true;
22938
+ event.emit(event.ONCONTEXT_RESTORED, this);
22939
+ me.game.repaint();
22940
+ }, false );
21911
22941
  }
21912
22942
 
21913
22943
  /**
@@ -21938,7 +22968,7 @@ class CanvasRenderer extends Renderer {
21938
22968
  * <img src="images/normal-blendmode.png" width="510"/> <br>
21939
22969
  * - "multiply" : the pixels of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. <br>
21940
22970
  * <img src="images/multiply-blendmode.png" width="510"/> <br>
21941
- * - "lighter" : where both content overlap the color is determined by adding color values. <br>
22971
+ * - "additive or lighter" : where both content overlap the color is determined by adding color values. <br>
21942
22972
  * <img src="images/lighter-blendmode.png" width="510"/> <br>
21943
22973
  * - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
21944
22974
  * <img src="images/screen-blendmode.png" width="510"/> <br>
@@ -21946,7 +22976,7 @@ class CanvasRenderer extends Renderer {
21946
22976
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
21947
22977
  * @memberof CanvasRenderer.prototype
21948
22978
  * @function
21949
- * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter, "screen"
22979
+ * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter, "additive", "screen"
21950
22980
  * @param {CanvasRenderingContext2D} [context]
21951
22981
  */
21952
22982
  setBlendMode(mode = "normal", context) {
@@ -21958,6 +22988,7 @@ class CanvasRenderer extends Renderer {
21958
22988
  break;
21959
22989
 
21960
22990
  case "lighter" :
22991
+ case "additive" :
21961
22992
  context.globalCompositeOperation = "lighter";
21962
22993
  break;
21963
22994
 
@@ -26384,7 +27415,7 @@ function preloadTMX(tmxData, onload, onerror) {
26384
27415
  case "tsx":
26385
27416
  // ie9 does not fully implement the responseXML
26386
27417
  if (device$1.ua.match(/msie/i) || !xmlhttp.responseXML) {
26387
- if (window.DOMParser) {
27418
+ if (globalThis.DOMParser) {
26388
27419
  // manually create the XML DOM
26389
27420
  result = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
26390
27421
  } else {
@@ -27484,35 +28515,35 @@ function unloadAll() {
27484
28515
  }
27485
28516
 
27486
28517
  var audio = /*#__PURE__*/Object.freeze({
27487
- __proto__: null,
27488
- stopOnAudioError: stopOnAudioError,
27489
- init: init$1,
27490
- hasFormat: hasFormat,
27491
- hasAudio: hasAudio,
27492
- enable: enable,
27493
- disable: disable,
27494
- load: load,
27495
- play: play,
27496
- fade: fade,
27497
- seek: seek,
27498
- rate: rate,
27499
- stop: stop,
27500
- pause: pause,
27501
- resume: resume,
27502
- playTrack: playTrack,
27503
- stopTrack: stopTrack,
27504
- pauseTrack: pauseTrack,
27505
- resumeTrack: resumeTrack,
27506
- getCurrentTrack: getCurrentTrack,
27507
- setVolume: setVolume,
27508
- getVolume: getVolume,
27509
- mute: mute,
27510
- unmute: unmute,
27511
- muteAll: muteAll,
27512
- unmuteAll: unmuteAll,
27513
- muted: muted,
27514
- unload: unload,
27515
- unloadAll: unloadAll
28518
+ __proto__: null,
28519
+ stopOnAudioError: stopOnAudioError,
28520
+ init: init$1,
28521
+ hasFormat: hasFormat,
28522
+ hasAudio: hasAudio,
28523
+ enable: enable,
28524
+ disable: disable,
28525
+ load: load,
28526
+ play: play,
28527
+ fade: fade,
28528
+ seek: seek,
28529
+ rate: rate,
28530
+ stop: stop,
28531
+ pause: pause,
28532
+ resume: resume,
28533
+ playTrack: playTrack,
28534
+ stopTrack: stopTrack,
28535
+ pauseTrack: pauseTrack,
28536
+ resumeTrack: resumeTrack,
28537
+ getCurrentTrack: getCurrentTrack,
28538
+ setVolume: setVolume,
28539
+ getVolume: getVolume,
28540
+ mute: mute,
28541
+ unmute: unmute,
28542
+ muteAll: muteAll,
28543
+ unmuteAll: unmuteAll,
28544
+ muted: muted,
28545
+ unload: unload,
28546
+ unloadAll: unloadAll
27516
28547
  });
27517
28548
 
27518
28549
  /**
@@ -27669,8 +28700,8 @@ let swipeEnabled = true;
27669
28700
  */
27670
28701
  function _disableSwipeFn(e) {
27671
28702
  e.preventDefault();
27672
- if (typeof window.scroll === "function") {
27673
- window.scroll(0, 0);
28703
+ if (typeof globalThis.scroll === "function") {
28704
+ globalThis.scroll(0, 0);
27674
28705
  }
27675
28706
  return false;
27676
28707
  }
@@ -27685,24 +28716,27 @@ function _domReady() {
27685
28716
  // Make sure that the DOM is not already loaded
27686
28717
  if (!isReady) {
27687
28718
  // be sure document.body is there
27688
- if (!document.body) {
28719
+ if (!device.nodeJS && !document.body) {
27689
28720
  return setTimeout(_domReady, 13);
27690
28721
  }
27691
28722
 
27692
28723
  // clean up loading event
27693
- if (document.removeEventListener) {
27694
- document.removeEventListener(
28724
+ if (typeof globalThis.document !== "undefined" && typeof globalThis.document.removeEventListener === "function") {
28725
+ globalThis.document.removeEventListener(
27695
28726
  "DOMContentLoaded",
27696
28727
  this._domReady,
27697
28728
  false
27698
28729
  );
27699
28730
  }
27700
- // remove the event on window.onload (always added in `onReady`)
27701
- window.removeEventListener("load", _domReady, false);
28731
+
28732
+ if (typeof globalThis.removeEventListener === "function") {
28733
+ // remove the event on globalThis.onload (always added in `onReady`)
28734
+ globalThis.removeEventListener("load", _domReady, false);
28735
+ }
27702
28736
 
27703
28737
  // execute all callbacks
27704
28738
  while (readyList.length) {
27705
- readyList.shift().call(window, []);
28739
+ readyList.shift().call(globalThis, []);
27706
28740
  }
27707
28741
 
27708
28742
  // Remember that the DOM is ready
@@ -27740,7 +28774,7 @@ function _detectDevice() {
27740
28774
  device.BlackBerry ||
27741
28775
  device.Kindle || false;
27742
28776
  // ejecta
27743
- device.ejecta = (typeof window.ejecta !== "undefined");
28777
+ device.ejecta = (typeof globalThis.ejecta !== "undefined");
27744
28778
  // Wechat
27745
28779
  device.isWeixin = /MicroMessenger/i.test(device.ua);
27746
28780
  }
@@ -27760,46 +28794,44 @@ function _checkCapabilities() {
27760
28794
  }
27761
28795
 
27762
28796
  // Touch/Gesture Event feature detection
27763
- device.TouchEvent = !!("ontouchstart" in window);
27764
- device.PointerEvent = !!window.PointerEvent;
27765
- window.gesture = prefixed("gesture");
28797
+ device.TouchEvent = !!("ontouchstart" in globalThis);
28798
+ device.PointerEvent = !!globalThis.PointerEvent;
28799
+ globalThis.gesture = prefixed("gesture");
27766
28800
 
27767
28801
  // detect touch capabilities
27768
28802
  device.touch = device.TouchEvent || device.PointerEvent;
27769
28803
 
27770
28804
  // max amount of touch points ; always at least return 1 (e.g. headless chrome will return 0)
27771
- device.maxTouchPoints = device.touch ? (device.PointerEvent ? navigator.maxTouchPoints || 1 : 10) : 1;
28805
+ device.maxTouchPoints = device.touch ? (device.PointerEvent ? globalThis.navigator.maxTouchPoints || 1 : 10) : 1;
27772
28806
 
27773
28807
  // detect wheel event support
27774
28808
  // Modern browsers support "wheel", Webkit and IE support at least "mousewheel
27775
- device.wheel = ("onwheel" in document.createElement("div"));
28809
+ device.wheel = typeof globalThis.document !== "undefined" && "onwheel" in globalThis.document.createElement("div");
27776
28810
 
27777
28811
  // pointerlock detection (pointerLockElement can be null when the feature is supported)
27778
- device.hasPointerLockSupport = typeof document.pointerLockElement !== "undefined";
28812
+ device.hasPointerLockSupport = typeof globalThis.document !== "undefined" && typeof globalThis.document.pointerLockElement !== "undefined";
27779
28813
 
27780
28814
  // device orientation and motion detection
27781
- device.hasDeviceOrientation = !!window.DeviceOrientationEvent;
27782
- device.hasAccelerometer = !!window.DeviceMotionEvent;
28815
+ device.hasDeviceOrientation = !!globalThis.DeviceOrientationEvent;
28816
+ device.hasAccelerometer = !!globalThis.DeviceMotionEvent;
27783
28817
 
27784
28818
  // support the ScreenOrientation API
27785
28819
  device.ScreenOrientation = (typeof screen !== "undefined") &&
27786
28820
  (typeof screen.orientation !== "undefined");
27787
28821
 
27788
28822
  // fullscreen api detection & polyfill when possible
27789
- device.hasFullscreenSupport = prefixed("fullscreenEnabled", document) ||
27790
- document.mozFullScreenEnabled;
28823
+ device.hasFullscreenSupport = typeof globalThis.document !== "undefined" && (prefixed("fullscreenEnabled", globalThis.document) || globalThis.document.mozFullScreenEnabled);
27791
28824
 
27792
- document.exitFullscreen = prefixed("cancelFullScreen", document) ||
27793
- prefixed("exitFullscreen", document);
28825
+ if (device.hasFullscreenSupport === true) {
28826
+ globalThis.document.exitFullscreen = typeof globalThis.document !== "undefined" && (prefixed("cancelFullScreen", globalThis.document) || prefixed("exitFullscreen", globalThis.document));
28827
+ }
27794
28828
 
27795
- // vibration API poyfill
27796
- navigator.vibrate = prefixed("vibrate", navigator);
27797
28829
 
27798
28830
  // web Audio detection
27799
- device.hasWebAudio = !!(window.AudioContext || window.webkitAudioContext);
28831
+ device.hasWebAudio = !!(globalThis.AudioContext || globalThis.webkitAudioContext);
27800
28832
 
27801
28833
  try {
27802
- device.localStorage = !!window.localStorage;
28834
+ device.localStorage = !!globalThis.localStorage;
27803
28835
  } catch (e) {
27804
28836
  // the above generates an exception when cookies are blocked
27805
28837
  device.localStorage = false;
@@ -27809,75 +28841,78 @@ function _checkCapabilities() {
27809
28841
  // some browser (e.g. Safari) implements WebGL1 and WebGL2 contexts only
27810
28842
  // https://bugzilla.mozilla.org/show_bug.cgi?id=801176
27811
28843
  device.OffscreenCanvas =
27812
- (typeof window.OffscreenCanvas !== "undefined") &&
28844
+ (typeof globalThis.OffscreenCanvas !== "undefined") &&
27813
28845
  ((new OffscreenCanvas(0, 0).getContext( "2d" )) !== null);
27814
28846
  } catch (e) {
27815
28847
  device.OffscreenCanvas = false;
27816
28848
  }
27817
28849
 
27818
- // set pause/stop action on losing focus
27819
- window.addEventListener("blur", function () {
27820
- if (device.stopOnBlur) {
27821
- state.stop(true);
27822
- }
27823
- if (device.pauseOnBlur) {
27824
- state.pause(true);
27825
- }
27826
- }, false);
27827
- // set restart/resume action on gaining focus
27828
- window.addEventListener("focus", function () {
27829
- if (device.stopOnBlur) {
27830
- state.restart(true);
27831
- }
27832
- if (device.resumeOnFocus) {
27833
- state.resume(true);
27834
- }
27835
- // force focus if autofocus is on
27836
- if (device.autoFocus) {
27837
- device.focus();
27838
- }
27839
- }, false);
27840
-
27841
-
27842
- // Set the name of the hidden property and the change event for visibility
27843
- var hidden, visibilityChange;
27844
- if (typeof document.hidden !== "undefined") {
27845
- // Opera 12.10 and Firefox 18 and later support
27846
- hidden = "hidden";
27847
- visibilityChange = "visibilitychange";
27848
- } else if (typeof document.mozHidden !== "undefined") {
27849
- hidden = "mozHidden";
27850
- visibilityChange = "mozvisibilitychange";
27851
- } else if (typeof document.msHidden !== "undefined") {
27852
- hidden = "msHidden";
27853
- visibilityChange = "msvisibilitychange";
27854
- } else if (typeof document.webkitHidden !== "undefined") {
27855
- hidden = "webkitHidden";
27856
- visibilityChange = "webkitvisibilitychange";
27857
- }
27858
-
27859
- // register on the event if supported
27860
- if (typeof (visibilityChange) === "string") {
27861
- // add the corresponding event listener
27862
- document.addEventListener(visibilityChange,
27863
- function () {
27864
- if (document[hidden]) {
27865
- if (device.stopOnBlur) {
27866
- state.stop(true);
27867
- }
27868
- if (device.pauseOnBlur) {
27869
- state.pause(true);
27870
- }
27871
- } else {
27872
- if (device.stopOnBlur) {
27873
- state.restart(true);
27874
- }
27875
- if (device.resumeOnFocus) {
27876
- state.resume(true);
28850
+ if (typeof globalThis.addEventListener === "function") {
28851
+ // set pause/stop action on losing focus
28852
+ globalThis.addEventListener("blur", function () {
28853
+ if (device.stopOnBlur) {
28854
+ state.stop(true);
28855
+ }
28856
+ if (device.pauseOnBlur) {
28857
+ state.pause(true);
28858
+ }
28859
+ }, false);
28860
+ // set restart/resume action on gaining focus
28861
+ globalThis.addEventListener("focus", function () {
28862
+ if (device.stopOnBlur) {
28863
+ state.restart(true);
28864
+ }
28865
+ if (device.resumeOnFocus) {
28866
+ state.resume(true);
28867
+ }
28868
+ // force focus if autofocus is on
28869
+ if (device.autoFocus) {
28870
+ device.focus();
28871
+ }
28872
+ }, false);
28873
+ }
28874
+
28875
+ if (typeof globalThis.document !== "undefined") {
28876
+ // Set the name of the hidden property and the change event for visibility
28877
+ var hidden, visibilityChange;
28878
+ if (typeof globalThis.document.hidden !== "undefined") {
28879
+ // Opera 12.10 and Firefox 18 and later support
28880
+ hidden = "hidden";
28881
+ visibilityChange = "visibilitychange";
28882
+ } else if (typeof globalThis.document.mozHidden !== "undefined") {
28883
+ hidden = "mozHidden";
28884
+ visibilityChange = "mozvisibilitychange";
28885
+ } else if (typeof globalThis.document.msHidden !== "undefined") {
28886
+ hidden = "msHidden";
28887
+ visibilityChange = "msvisibilitychange";
28888
+ } else if (typeof globalThis.document.webkitHidden !== "undefined") {
28889
+ hidden = "webkitHidden";
28890
+ visibilityChange = "webkitvisibilitychange";
28891
+ }
28892
+
28893
+ // register on the event if supported
28894
+ if (typeof (visibilityChange) === "string") {
28895
+ // add the corresponding event listener
28896
+ globalThis.document.addEventListener(visibilityChange,
28897
+ function () {
28898
+ if (globalThis.document[hidden]) {
28899
+ if (device.stopOnBlur) {
28900
+ state.stop(true);
28901
+ }
28902
+ if (device.pauseOnBlur) {
28903
+ state.pause(true);
28904
+ }
28905
+ } else {
28906
+ if (device.stopOnBlur) {
28907
+ state.restart(true);
28908
+ }
28909
+ if (device.resumeOnFocus) {
28910
+ state.resume(true);
28911
+ }
27877
28912
  }
27878
- }
27879
- }, false
27880
- );
28913
+ }, false
28914
+ );
28915
+ }
27881
28916
  }
27882
28917
  }
27883
28918
 
@@ -27897,7 +28932,7 @@ let device = {
27897
28932
  * @name ua
27898
28933
  * @memberof device
27899
28934
  */
27900
- ua : navigator.userAgent,
28935
+ ua : typeof globalThis.navigator !== "undefined" ? globalThis.navigator.userAgent : "",
27901
28936
 
27902
28937
  /**
27903
28938
  * Browser Local Storage capabilities <br>
@@ -27971,7 +29006,7 @@ let device = {
27971
29006
  * @name nativeBase64
27972
29007
  * @memberof device
27973
29008
  */
27974
- nativeBase64 : (typeof(window.atob) === "function"),
29009
+ nativeBase64 : (typeof(globalThis.atob) === "function"),
27975
29010
 
27976
29011
  /**
27977
29012
  * Return the maximum number of simultaneous touch contact points are supported by the current device.
@@ -28050,24 +29085,33 @@ let device = {
28050
29085
  */
28051
29086
  linux : false,
28052
29087
 
28053
- /**
28054
- * equals to true if the game is running under Ejecta.
28055
- * @type {boolean}
28056
- * @readonly
28057
- * @see http://impactjs.com/ejecta
28058
- * @name ejecta
28059
- * @memberof device
28060
- */
29088
+ /**
29089
+ * equals to true if the game is running under Ejecta.
29090
+ * @type {boolean}
29091
+ * @readonly
29092
+ * @see http://impactjs.com/ejecta
29093
+ * @name ejecta
29094
+ * @memberof device
29095
+ */
28061
29096
  ejecta : false,
28062
29097
 
28063
29098
  /**
28064
- * equals to true if the game is running under Wechat.
29099
+ * equals to true if the is running under Wechat.
28065
29100
  * @type {boolean}
28066
29101
  * @readonly
28067
29102
  * @name isWeixin
28068
29103
  * @memberof device
28069
29104
  */
28070
- isWeixin : false,
29105
+ isWeixin : false,
29106
+
29107
+ /**
29108
+ * equals to true if running under node.js
29109
+ * @type {boolean}
29110
+ * @readonly
29111
+ * @name nodeJS
29112
+ * @memberof device
29113
+ */
29114
+ nodeJS : (typeof process !== "undefined") && (process.release.name === "node"),
28071
29115
 
28072
29116
  /**
28073
29117
  * equals to true if the device is running on ChromeOS.
@@ -28182,7 +29226,7 @@ let device = {
28182
29226
  * @name language
28183
29227
  * @memberof device
28184
29228
  */
28185
- language : navigator.language || navigator.browserLanguage || navigator.userLanguage || "en",
29229
+ language : typeof globalThis.navigator !== "undefined" ? globalThis.navigator.language || globalThis.navigator.browserLanguage || globalThis.navigator.userLanguage || "en" : "en",
28186
29230
 
28187
29231
  /**
28188
29232
  * Specify whether to pause the game when losing focus
@@ -28274,7 +29318,7 @@ let device = {
28274
29318
  // If the DOM is already ready
28275
29319
  if (isReady) {
28276
29320
  // Execute the function immediately
28277
- fn.call(window, []);
29321
+ fn.call(globalThis, []);
28278
29322
  }
28279
29323
  else {
28280
29324
  // Add the function to the wait list
@@ -28283,17 +29327,17 @@ let device = {
28283
29327
  // attach listeners if not yet done
28284
29328
  if (!readyBound) {
28285
29329
  // directly call domReady if document is already "ready"
28286
- if (document.readyState === "complete") {
29330
+ if (device.nodeJS === true || (typeof globalThis.document !== "undefined" && globalThis.document.readyState === "complete")) {
28287
29331
  // defer the fn call to ensure our script is fully loaded
28288
- window.setTimeout(_domReady, 0);
29332
+ globalThis.setTimeout(_domReady, 0);
28289
29333
  }
28290
29334
  else {
28291
- if (document.addEventListener) {
29335
+ if (typeof globalThis.document !== "undefined" && typeof globalThis.document.addEventListener === "function") {
28292
29336
  // Use the handy event callback
28293
- document.addEventListener("DOMContentLoaded", _domReady, false);
29337
+ globalThis.document.addEventListener("DOMContentLoaded", _domReady, false);
28294
29338
  }
28295
- // A fallback to window.onload, that will always work
28296
- window.addEventListener("load", _domReady, false);
29339
+ // A fallback to globalThis.onload, that will always work
29340
+ globalThis.addEventListener("load", _domReady, false);
28297
29341
  }
28298
29342
  readyBound = true;
28299
29343
  }
@@ -28308,11 +29352,11 @@ let device = {
28308
29352
  enableSwipe(enable) {
28309
29353
  if (enable !== false) {
28310
29354
  if (swipeEnabled === false) {
28311
- window.document.removeEventListener("touchmove", _disableSwipeFn, false);
29355
+ globalThis.document.removeEventListener("touchmove", _disableSwipeFn, false);
28312
29356
  swipeEnabled = true;
28313
29357
  }
28314
29358
  } else if (swipeEnabled === true) {
28315
- window.document.addEventListener("touchmove", _disableSwipeFn, false);
29359
+ globalThis.document.addEventListener("touchmove", _disableSwipeFn, false);
28316
29360
  swipeEnabled = false;
28317
29361
  }
28318
29362
  },
@@ -28366,7 +29410,7 @@ let device = {
28366
29410
  var PORTRAIT = "portrait";
28367
29411
  var LANDSCAPE = "landscape";
28368
29412
 
28369
- var screen = window.screen;
29413
+ var screen = globalThis.screen;
28370
29414
 
28371
29415
  // first try using "standard" values
28372
29416
  if (this.ScreenOrientation === true) {
@@ -28381,12 +29425,12 @@ let device = {
28381
29425
  }
28382
29426
 
28383
29427
  // check using the deprecated API
28384
- if (typeof window.orientation === "number") {
28385
- return (Math.abs(window.orientation) === 90) ? LANDSCAPE : PORTRAIT;
29428
+ if (typeof globalThis.orientation === "number") {
29429
+ return (Math.abs(globalThis.orientation) === 90) ? LANDSCAPE : PORTRAIT;
28386
29430
  }
28387
29431
 
28388
29432
  // fallback to window size check
28389
- return (window.outerWidth > window.outerHeight) ? LANDSCAPE : PORTRAIT;
29433
+ return (globalThis.outerWidth > globalThis.outerHeight) ? LANDSCAPE : PORTRAIT;
28390
29434
  },
28391
29435
 
28392
29436
  /**
@@ -28398,7 +29442,7 @@ let device = {
28398
29442
  * @returns {boolean} true if the orientation was unsuccessfully locked
28399
29443
  */
28400
29444
  lockOrientation(orientation) {
28401
- var screen = window.screen;
29445
+ var screen = globalThis.screen;
28402
29446
  if (typeof screen !== "undefined") {
28403
29447
  var _lockOrientation = prefixed("lockOrientation", screen);
28404
29448
  if (typeof _lockOrientation !== "undefined") {
@@ -28416,7 +29460,7 @@ let device = {
28416
29460
  * @returns {boolean} true if the orientation was unsuccessfully unlocked
28417
29461
  */
28418
29462
  unlockOrientation() {
28419
- var screen = window.screen;
29463
+ var screen = globalThis.screen;
28420
29464
  if (typeof screen !== "undefined") {
28421
29465
  var _unlockOrientation = prefixed("unlockOrientation", screen);
28422
29466
  if (typeof _unlockOrientation !== "undefined") {
@@ -28515,8 +29559,8 @@ let device = {
28515
29559
  if (typeof element === "object" && element !== document.body && typeof element.getBoundingClientRect !== "undefined") {
28516
29560
  return element.getBoundingClientRect();
28517
29561
  } else {
28518
- _domRect.width = _domRect.right = window.innerWidth;
28519
- _domRect.height = _domRect.bottom = window.innerHeight;
29562
+ _domRect.width = _domRect.right = globalThis.innerWidth;
29563
+ _domRect.height = _domRect.bottom = globalThis.innerHeight;
28520
29564
  return _domRect;
28521
29565
  } },
28522
29566
 
@@ -28547,7 +29591,7 @@ let device = {
28547
29591
  stencil: true,
28548
29592
  failIfMajorPerformanceCaveat : options.failIfMajorPerformanceCaveat
28549
29593
  };
28550
- _supported = !! (window.WebGLRenderingContext && (canvas.getContext("webgl", ctxOptions) || canvas.getContext("experimental-webgl", ctxOptions)));
29594
+ _supported = !! (globalThis.WebGLRenderingContext && (canvas.getContext("webgl", ctxOptions) || canvas.getContext("experimental-webgl", ctxOptions)));
28551
29595
  } catch (e) {
28552
29596
  _supported = false;
28553
29597
  }
@@ -28582,8 +29626,8 @@ let device = {
28582
29626
  * }
28583
29627
  */
28584
29628
  focus() {
28585
- if (typeof (window.focus) === "function") {
28586
- window.focus();
29629
+ if (typeof (globalThis.focus) === "function") {
29630
+ globalThis.focus();
28587
29631
  }
28588
29632
  },
28589
29633
 
@@ -28637,13 +29681,13 @@ let device = {
28637
29681
  .then(response => {
28638
29682
  if (response === "granted") {
28639
29683
  // add a listener for the devicemotion event
28640
- window.addEventListener("devicemotion", this.onDeviceMotion, false);
29684
+ globalThis.addEventListener("devicemotion", this.onDeviceMotion, false);
28641
29685
  accelInitialized = true;
28642
29686
  }
28643
29687
  }).catch(console.error);
28644
29688
  } else {
28645
29689
  // add a listener for the devicemotion event
28646
- window.addEventListener("devicemotion", this.onDeviceMotion, false);
29690
+ globalThis.addEventListener("devicemotion", this.onDeviceMotion, false);
28647
29691
  accelInitialized = true;
28648
29692
  }
28649
29693
  }
@@ -28657,7 +29701,7 @@ let device = {
28657
29701
  unwatchAccelerometer() {
28658
29702
  if (accelInitialized) {
28659
29703
  // remove the listener for the devicemotion event
28660
- window.removeEventListener("devicemotion", this.onDeviceMotion, false);
29704
+ globalThis.removeEventListener("devicemotion", this.onDeviceMotion, false);
28661
29705
  accelInitialized = false;
28662
29706
  }
28663
29707
  },
@@ -28687,12 +29731,12 @@ let device = {
28687
29731
  DeviceOrientationEvent.requestPermission()
28688
29732
  .then(response => {
28689
29733
  if (response === "granted") {
28690
- window.addEventListener("deviceorientation", this.onDeviceRotate, false);
29734
+ globalThis.addEventListener("deviceorientation", this.onDeviceRotate, false);
28691
29735
  deviceOrientationInitialized = true;
28692
29736
  }
28693
29737
  }).catch(console.error);
28694
29738
  } else {
28695
- window.addEventListener("deviceorientation", this.onDeviceRotate, false);
29739
+ globalThis.addEventListener("deviceorientation", this.onDeviceRotate, false);
28696
29740
  deviceOrientationInitialized = true;
28697
29741
  }
28698
29742
  }
@@ -28705,7 +29749,7 @@ let device = {
28705
29749
  */
28706
29750
  unwatchDeviceOrientation() {
28707
29751
  if (deviceOrientationInitialized) {
28708
- window.removeEventListener("deviceorientation", this.onDeviceRotate, false);
29752
+ globalThis.removeEventListener("deviceorientation", this.onDeviceRotate, false);
28709
29753
  deviceOrientationInitialized = false;
28710
29754
  }
28711
29755
  },
@@ -28728,8 +29772,8 @@ let device = {
28728
29772
  * me.device.vibrate(0);
28729
29773
  */
28730
29774
  vibrate(pattern) {
28731
- if (navigator.vibrate) {
28732
- navigator.vibrate(pattern);
29775
+ if (typeof globalThis.navigator !== "undefined" && typeof globalThis.navigator.vibrate === "function") {
29776
+ globalThis.navigator.vibrate(pattern);
28733
29777
  }
28734
29778
  }
28735
29779
 
@@ -28749,7 +29793,7 @@ Object.defineProperty(device, "devicePixelRatio", {
28749
29793
  * @ignore
28750
29794
  */
28751
29795
  get: function () {
28752
- return (window.devicePixelRatio || 1);
29796
+ return (globalThis.devicePixelRatio || 1);
28753
29797
  }
28754
29798
  });
28755
29799
 
@@ -29073,7 +30117,7 @@ class GLShader {
29073
30117
  this.uniforms = extractUniforms(this.gl, this);
29074
30118
 
29075
30119
  // destroy the shader on context lost (will be recreated on context restore)
29076
- on(WEBGL_ONCONTEXT_LOST, this.destroy, this);
30120
+ on(ONCONTEXT_LOST, this.destroy, this);
29077
30121
  }
29078
30122
 
29079
30123
  /**
@@ -29969,19 +31013,19 @@ class WebGLRenderer extends Renderer {
29969
31013
  // Create a texture cache
29970
31014
  this.cache = new TextureCache(this.maxTextures);
29971
31015
 
29972
- // to simulate context lost and restore :
31016
+ // to simulate context lost and restore in WebGL:
29973
31017
  // var ctx = me.video.renderer.context.getExtension('WEBGL_lose_context');
29974
31018
  // ctx.loseContext()
29975
31019
  this.getScreenCanvas().addEventListener("webglcontextlost", (e) => {
29976
31020
  e.preventDefault();
29977
31021
  this.isContextValid = false;
29978
- emit(WEBGL_ONCONTEXT_LOST, this);
31022
+ emit(ONCONTEXT_LOST, this);
29979
31023
  }, false );
29980
31024
  // ctx.restoreContext()
29981
31025
  this.getScreenCanvas().addEventListener("webglcontextrestored", () => {
29982
31026
  this.reset();
29983
31027
  this.isContextValid = true;
29984
- emit(WEBGL_ONCONTEXT_RESTORED, this);
31028
+ emit(ONCONTEXT_RESTORED, this);
29985
31029
  }, false );
29986
31030
  }
29987
31031
 
@@ -30376,7 +31420,7 @@ class WebGLRenderer extends Renderer {
30376
31420
  * <img src="images/normal-blendmode.png" width="510"/> <br>
30377
31421
  * - "multiply" : the pixels of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. <br>
30378
31422
  * <img src="images/multiply-blendmode.png" width="510"/> <br>
30379
- * - "lighter" : where both content overlap the color is determined by adding color values. <br>
31423
+ * - "additive or lighter" : where both content overlap the color is determined by adding color values. <br>
30380
31424
  * <img src="images/lighter-blendmode.png" width="510"/> <br>
30381
31425
  * - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
30382
31426
  * <img src="images/screen-blendmode.png" width="510"/> <br>
@@ -30384,7 +31428,7 @@ class WebGLRenderer extends Renderer {
30384
31428
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
30385
31429
  * @memberof WebGLRenderer.prototype
30386
31430
  * @function
30387
- * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "screen"
31431
+ * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "additive", "screen"
30388
31432
  * @param {WebGLRenderingContext} [gl]
30389
31433
  */
30390
31434
  setBlendMode(mode = "normal", gl = this.gl) {
@@ -30400,6 +31444,7 @@ class WebGLRenderer extends Renderer {
30400
31444
  break;
30401
31445
 
30402
31446
  case "lighter" :
31447
+ case "additive" :
30403
31448
  gl.blendFunc(gl.ONE, gl.ONE);
30404
31449
  break;
30405
31450
 
@@ -31011,7 +32056,7 @@ var designHeight = 0;
31011
32056
 
31012
32057
  // default video settings
31013
32058
  var settings = {
31014
- parent : document.body,
32059
+ parent : undefined,
31015
32060
  renderer : 2, // AUTO
31016
32061
  doubleBuffering : false,
31017
32062
  autoScale : false,
@@ -31056,8 +32101,8 @@ function onresize() {
31056
32101
  var canvasMaxWidth = Infinity;
31057
32102
  var canvasMaxHeight = Infinity;
31058
32103
 
31059
- if (window.getComputedStyle) {
31060
- var style = window.getComputedStyle(renderer.getScreenCanvas(), null);
32104
+ if (globalThis.getComputedStyle) {
32105
+ var style = globalThis.getComputedStyle(renderer.getScreenCanvas(), null);
31061
32106
  canvasMaxWidth = parseInt(style.maxWidth, 10) || Infinity;
31062
32107
  canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
31063
32108
  }
@@ -31267,7 +32312,7 @@ function init(width, height, options) {
31267
32312
  settings.zoomY = height * scaleRatio.y;
31268
32313
 
31269
32314
  //add a channel for the onresize/onorientationchange event
31270
- window.addEventListener(
32315
+ globalThis.addEventListener(
31271
32316
  "resize",
31272
32317
  utils.function.throttle(
31273
32318
  function (e) {
@@ -31277,7 +32322,7 @@ function init(width, height, options) {
31277
32322
  );
31278
32323
 
31279
32324
  // Screen Orientation API
31280
- window.addEventListener(
32325
+ globalThis.addEventListener(
31281
32326
  "orientationchange",
31282
32327
  function (e) {
31283
32328
  emit(WINDOW_ONORIENTATION_CHANGE, e);
@@ -31285,7 +32330,7 @@ function init(width, height, options) {
31285
32330
  false
31286
32331
  );
31287
32332
  // pre-fixed implementation on mozzila
31288
- window.addEventListener(
32333
+ globalThis.addEventListener(
31289
32334
  "onmozorientationchange",
31290
32335
  function (e) {
31291
32336
  emit(WINDOW_ONORIENTATION_CHANGE, e);
@@ -31294,13 +32339,13 @@ function init(width, height, options) {
31294
32339
  );
31295
32340
 
31296
32341
  if (device$1.ScreenOrientation === true) {
31297
- window.screen.orientation.onchange = function (e) {
32342
+ globalThis.screen.orientation.onchange = function (e) {
31298
32343
  emit(WINDOW_ONORIENTATION_CHANGE, e);
31299
32344
  };
31300
32345
  }
31301
32346
 
31302
32347
  // Automatically update relative canvas position on scroll
31303
- window.addEventListener("scroll", utils.function.throttle(
32348
+ globalThis.addEventListener("scroll", utils.function.throttle(
31304
32349
  function (e) {
31305
32350
  emit(WINDOW_ONSCROLL, e);
31306
32351
  }, 100
@@ -31327,14 +32372,14 @@ function init(width, height, options) {
31327
32372
  }
31328
32373
 
31329
32374
  // add our canvas (default to document.body if settings.parent is undefined)
31330
- parent = device$1.getElement(settings.parent);
32375
+ parent = device$1.getElement(typeof settings.parent !== "undefined" ? settings.parent : document.body);
31331
32376
  parent.appendChild(renderer.getScreenCanvas());
31332
32377
 
31333
32378
  // trigger an initial resize();
31334
32379
  onresize();
31335
32380
 
31336
32381
  // add an observer to detect when the dom tree is modified
31337
- if ("MutationObserver" in window) {
32382
+ if ("MutationObserver" in globalThis) {
31338
32383
  // Create an observer instance linked to the callback function
31339
32384
  var observer = new MutationObserver(onresize.bind(this));
31340
32385
 
@@ -31353,7 +32398,7 @@ function init(width, height, options) {
31353
32398
  renderType + " renderer" + gpu_renderer + " | " +
31354
32399
  audioType + " | " +
31355
32400
  "pixel ratio " + device$1.devicePixelRatio + " | " +
31356
- (device$1.isMobile ? "mobile" : "desktop") + " | " +
32401
+ (device$1.nodeJS ? "node.js" : device$1.isMobile ? "mobile" : "desktop") + " | " +
31357
32402
  device$1.getScreenOrientation() + " | " +
31358
32403
  device$1.language
31359
32404
  );
@@ -31440,17 +32485,17 @@ function scale(x, y) {
31440
32485
  }
31441
32486
 
31442
32487
  var video = /*#__PURE__*/Object.freeze({
31443
- __proto__: null,
31444
- CANVAS: CANVAS,
31445
- WEBGL: WEBGL,
31446
- AUTO: AUTO,
31447
- get parent () { return parent; },
31448
- scaleRatio: scaleRatio,
31449
- get renderer () { return renderer; },
31450
- init: init,
31451
- createCanvas: createCanvas,
31452
- getParent: getParent,
31453
- scale: scale
32488
+ __proto__: null,
32489
+ CANVAS: CANVAS,
32490
+ WEBGL: WEBGL,
32491
+ AUTO: AUTO,
32492
+ get parent () { return parent; },
32493
+ scaleRatio: scaleRatio,
32494
+ get renderer () { return renderer; },
32495
+ init: init,
32496
+ createCanvas: createCanvas,
32497
+ getParent: getParent,
32498
+ scale: scale
31454
32499
  });
31455
32500
 
31456
32501
  /**
@@ -31549,12 +32594,17 @@ var utils = {
31549
32594
  var hash = {};
31550
32595
 
31551
32596
  if (typeof url === "undefined") {
31552
- var location = document.location;
32597
+ if (typeof globalThis.document !== "undefined") {
32598
+ var location = globalThis.document.location;
31553
32599
 
31554
- if (location && location.hash) {
31555
- url = location.hash;
32600
+ if (location && location.hash) {
32601
+ url = location.hash;
32602
+ } else {
32603
+ // No "document.location" exist for Wechat mini game platform.
32604
+ return hash;
32605
+ }
31556
32606
  } else {
31557
- // No "document.location" exist for Wechat mini game platform.
32607
+ // "document" undefined on node.js
31558
32608
  return hash;
31559
32609
  }
31560
32610
  } else {
@@ -31743,7 +32793,7 @@ var timer = {
31743
32793
  */
31744
32794
  reset() {
31745
32795
  // set to "now"
31746
- last = now = window.performance.now();
32796
+ last = now = globalThis.performance.now();
31747
32797
  delta = 0;
31748
32798
  // reset delta counting variables
31749
32799
  framedelta = 0;
@@ -31882,23 +32932,23 @@ var x;
31882
32932
 
31883
32933
  // standardized functions
31884
32934
  // https://developer.mozilla.org/fr/docs/Web/API/Window/requestAnimationFrame
31885
- var requestAnimationFrame = window.requestAnimationFrame;
31886
- var cancelAnimationFrame = window.cancelAnimationFrame;
32935
+ var requestAnimationFrame = globalThis.requestAnimationFrame;
32936
+ var cancelAnimationFrame = globalThis.cancelAnimationFrame;
31887
32937
 
31888
32938
  // get prefixed rAF and cAF is standard one not supported
31889
32939
  for (x = 0; x < vendors.length && !requestAnimationFrame; ++x) {
31890
- requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
32940
+ requestAnimationFrame = globalThis[vendors[x] + "RequestAnimationFrame"];
31891
32941
  }
31892
32942
  for (x = 0; x < vendors.length && !cancelAnimationFrame; ++x) {
31893
- cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] ||
31894
- window[vendors[x] + "CancelRequestAnimationFrame"];
32943
+ cancelAnimationFrame = globalThis[vendors[x] + "CancelAnimationFrame"] ||
32944
+ globalThis[vendors[x] + "CancelRequestAnimationFrame"];
31895
32945
  }
31896
32946
 
31897
32947
  if (!requestAnimationFrame || !cancelAnimationFrame) {
31898
32948
  requestAnimationFrame = function (callback) {
31899
- var currTime = window.performance.now();
32949
+ var currTime = globalThis.performance.now();
31900
32950
  var timeToCall = Math.max(0, (1000 / timer$1.maxfps) - (currTime - lastTime));
31901
- var id = window.setTimeout(function () {
32951
+ var id = globalThis.setTimeout(function () {
31902
32952
  callback(currTime + timeToCall);
31903
32953
  }, timeToCall);
31904
32954
  lastTime = currTime + timeToCall;
@@ -31906,12 +32956,12 @@ if (!requestAnimationFrame || !cancelAnimationFrame) {
31906
32956
  };
31907
32957
 
31908
32958
  cancelAnimationFrame = function (id) {
31909
- window.clearTimeout(id);
32959
+ globalThis.clearTimeout(id);
31910
32960
  };
31911
32961
 
31912
32962
  // put back in global namespace
31913
- window.requestAnimationFrame = requestAnimationFrame;
31914
- window.cancelAnimationFrame = cancelAnimationFrame;
32963
+ globalThis.requestAnimationFrame = requestAnimationFrame;
32964
+ globalThis.cancelAnimationFrame = cancelAnimationFrame;
31915
32965
  }
31916
32966
 
31917
32967
  /**
@@ -31930,10 +32980,10 @@ class BasePlugin {
31930
32980
  * this can be overridden by the plugin
31931
32981
  * @public
31932
32982
  * @type {string}
31933
- * @default "10.6.1"
32983
+ * @default "10.7.0"
31934
32984
  * @name plugin.Base#version
31935
32985
  */
31936
- this.version = "10.6.1";
32986
+ this.version = "10.7.0";
31937
32987
  }
31938
32988
  }
31939
32989
 
@@ -34307,7 +35357,7 @@ class ImageLayer extends Sprite {
34307
35357
  this.repeat = settings.repeat || "repeat";
34308
35358
 
34309
35359
  // on context lost, all previous textures are destroyed
34310
- on(WEBGL_ONCONTEXT_RESTORED, this.createPattern, this);
35360
+ on(ONCONTEXT_RESTORED, this.createPattern, this);
34311
35361
  }
34312
35362
 
34313
35363
  /**
@@ -34508,7 +35558,7 @@ class ImageLayer extends Sprite {
34508
35558
  destroy() {
34509
35559
  push(this.ratio);
34510
35560
  this.ratio = undefined;
34511
- off(WEBGL_ONCONTEXT_RESTORED, this.createPattern);
35561
+ off(ONCONTEXT_RESTORED, this.createPattern);
34512
35562
  super.destroy();
34513
35563
  }
34514
35564
 
@@ -35352,143 +36402,63 @@ class DropTarget extends Renderable {
35352
36402
  }
35353
36403
 
35354
36404
  /**
35355
- * @classdesc
35356
- * Particle Container Object.
35357
- * @class ParticleContainer
35358
- * @augments Container
35359
- * @param {ParticleEmitter} emitter the emitter which owns this container
36405
+ * ParticleEmitterSettings contains the default settings for ParticleEmitter
36406
+ * @see ParticleEmitter
36407
+ * @namespace ParticleEmitterSettings
35360
36408
  */
35361
-
35362
- class ParticleContainer extends Container {
35363
-
35364
- /**
35365
- * @ignore
35366
- */
35367
- constructor(emitter) {
35368
- // call the super constructor
35369
- super(
35370
- viewport.pos.x,
35371
- viewport.pos.y,
35372
- viewport.width,
35373
- viewport.height
35374
- );
35375
-
35376
- // don't sort the particles by z-index
35377
- this.autoSort = false;
35378
-
35379
- // count the updates
35380
- this._updateCount = 0;
35381
-
35382
- // internally store how much time was skipped when frames are skipped
35383
- this._dt = 0;
35384
-
35385
- // cache the emitter for later use
35386
- this._emitter = emitter;
35387
-
35388
- this.autoTransform = false;
35389
-
35390
- this.anchorPoint.set(0, 0);
35391
-
35392
- this.isKinematic = true;
35393
- }
35394
-
36409
+ const ParticleEmitterSettings = {
35395
36410
  /**
35396
- * @ignore
36411
+ * Width of the particle spawn area.
36412
+ * @type {number}
36413
+ * @name width
36414
+ * @memberof ParticleEmitterSettings
36415
+ * @default 1
35397
36416
  */
35398
- update(dt) {
35399
- // skip frames if necessary
35400
- if (++this._updateCount > this._emitter.framesToSkip) {
35401
- this._updateCount = 0;
35402
- }
35403
- if (this._updateCount > 0) {
35404
- this._dt += dt;
35405
- return false;
35406
- }
35407
-
35408
- // apply skipped delta time
35409
- dt += this._dt;
35410
- this._dt = 0;
35411
-
35412
- // Update particles and remove them if they are dead
35413
- for (var i = this.children.length - 1; i >= 0; --i) {
35414
- var particle = this.children[i];
35415
- particle.inViewport = viewport.isVisible(particle, this.floating);
35416
- if (!particle.update(dt)) {
35417
- this.removeChildNow(particle);
35418
- }
35419
- }
35420
- return true;
35421
- }
36417
+ width : 1,
35422
36418
 
35423
36419
  /**
35424
- * @ignore
36420
+ * Height of the particle spawn area
36421
+ * @public
36422
+ * @type {number}
36423
+ * @name height
36424
+ * @memberof ParticleEmitterSettings
36425
+ * @default 1
35425
36426
  */
35426
- draw(renderer, rect) {
35427
- if (this.children.length > 0) {
35428
- var context = renderer.getContext(),
35429
- gco;
35430
- // Check for additive draw
35431
- if (this._emitter.textureAdditive) {
35432
- gco = context.globalCompositeOperation;
35433
- context.globalCompositeOperation = "lighter";
35434
- }
35435
-
35436
- super.draw(renderer, rect);
35437
-
35438
- // Restore globalCompositeOperation
35439
- if (this._emitter.textureAdditive) {
35440
- context.globalCompositeOperation = gco;
35441
- }
35442
- }
35443
- }
35444
- }
36427
+ height : 1,
35445
36428
 
35446
- // generate a default image for the particles
35447
- var pixel = (function () {
35448
- var canvas = createCanvas(1, 1);
35449
- var context = canvas.getContext("2d");
35450
- context.fillStyle = "#fff";
35451
- context.fillRect(0, 0, 1, 1);
35452
- return canvas;
35453
- })();
35454
-
35455
- /**
35456
- * me.ParticleEmitterSettings contains the default settings for me.ParticleEmitter
35457
- * @ignore
35458
- * @class
35459
- * @see ParticleEmitter
35460
- */
35461
- var ParticleEmitterSettings = {
35462
36429
  /**
35463
- * Width of the particle spawn area.<br>
36430
+ * image used for particles texture
36431
+ * (by default melonJS will create an white 8x8 texture image)
35464
36432
  * @public
35465
- * @type {number}
35466
- * @name width
36433
+ * @type {HTMLCanvasElement}
36434
+ * @name image
35467
36435
  * @memberof ParticleEmitterSettings
35468
- * @default 0
36436
+ * @default undefined
36437
+ * @see ParticleEmitterSettings.textureSize
35469
36438
  */
35470
- width : 0,
36439
+ image : undefined,
35471
36440
 
35472
36441
  /**
35473
- * Height of the particle spawn area
36442
+ * default texture size used for particles if no image is specified
36443
+ * (by default melonJS will create an white 8x8 texture image)
35474
36444
  * @public
35475
36445
  * @type {number}
35476
- * @name height
36446
+ * @name textureSize
35477
36447
  * @memberof ParticleEmitterSettings
35478
- * @default 0
36448
+ * @default 8
36449
+ * @see ParticleEmitterSettings.image
35479
36450
  */
35480
- height : 0,
36451
+ textureSize : 8,
35481
36452
 
35482
36453
  /**
35483
- * Image used for particles
36454
+ * tint to be applied to particles
35484
36455
  * @public
35485
- * @type {CanvasImageSource}
35486
- * @name image
36456
+ * @type {string}
36457
+ * @name tint
35487
36458
  * @memberof ParticleEmitterSettings
35488
- * @default 1x1 white pixel
35489
- * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#canvasimagesource
36459
+ * @default "#fff"
35490
36460
  */
35491
- image : pixel,
36461
+ tint : "#fff",
35492
36462
 
35493
36463
  /**
35494
36464
  * Total number of particles in the emitter
@@ -35511,7 +36481,7 @@ var ParticleEmitterSettings = {
35511
36481
  angle : Math.PI / 2,
35512
36482
 
35513
36483
  /**
35514
- * Variation in the start angle for particle launch in Radians
36484
+ * Variation in the start angle for particle launch in Radians.
35515
36485
  * @public
35516
36486
  * @type {number}
35517
36487
  * @name angleVariation
@@ -35521,7 +36491,7 @@ var ParticleEmitterSettings = {
35521
36491
  angleVariation : 0,
35522
36492
 
35523
36493
  /**
35524
- * Minimum time each particle lives once it is emitted in ms
36494
+ * Minimum time each particle lives once it is emitted in ms.
35525
36495
  * @public
35526
36496
  * @type {number}
35527
36497
  * @name minLife
@@ -35531,7 +36501,7 @@ var ParticleEmitterSettings = {
35531
36501
  minLife : 1000,
35532
36502
 
35533
36503
  /**
35534
- * Maximum time each particle lives once it is emitted in ms
36504
+ * Maximum time each particle lives once it is emitted in ms.
35535
36505
  * @public
35536
36506
  * @type {number}
35537
36507
  * @name maxLife
@@ -35654,18 +36624,31 @@ var ParticleEmitterSettings = {
35654
36624
  followTrajectory : false,
35655
36625
 
35656
36626
  /**
35657
- * Enable the Texture Additive by canvas composite operation (lighter).<br>
35658
- * WARNING: Composite Operation may decreases performance!.<br>
36627
+ * Enable the Texture Additive by composite operation ("additive" blendMode)
35659
36628
  * @public
35660
36629
  * @type {boolean}
35661
36630
  * @name textureAdditive
35662
36631
  * @default false
35663
36632
  * @memberof ParticleEmitterSettings
36633
+ * @see ParticleEmitterSettings.blendMode
35664
36634
  */
35665
36635
  textureAdditive : false,
35666
36636
 
35667
36637
  /**
35668
- * Update particles only in the viewport, remove it when out of viewport.<br>
36638
+ * the blend mode to be applied when rendering particles.
36639
+ * (note: this will superseed the `textureAdditive` setting if different than "normal")
36640
+ * @public
36641
+ * @type {string}
36642
+ * @name blendMode
36643
+ * @default normal
36644
+ * @memberof ParticleEmitterSettings
36645
+ * @see CanvasRenderer#setBlendMode
36646
+ * @see WebGLRenderer#setBlendMode
36647
+ */
36648
+ blendMode : "normal",
36649
+
36650
+ /**
36651
+ * Update particles only in the viewport, remove it when out of viewport.
35669
36652
  * @public
35670
36653
  * @type {boolean}
35671
36654
  * @name onlyInViewport
@@ -35675,7 +36658,7 @@ var ParticleEmitterSettings = {
35675
36658
  onlyInViewport : true,
35676
36659
 
35677
36660
  /**
35678
- * Render particles in screen space. <br>
36661
+ * Render particles in screen space.
35679
36662
  * @public
35680
36663
  * @type {boolean}
35681
36664
  * @name floating
@@ -35685,7 +36668,7 @@ var ParticleEmitterSettings = {
35685
36668
  floating : false,
35686
36669
 
35687
36670
  /**
35688
- * Maximum number of particles launched each time in this emitter (used only if emitter is Stream).<br>
36671
+ * Maximum number of particles launched each time in this emitter (used only if emitter is Stream).
35689
36672
  * @public
35690
36673
  * @type {number}
35691
36674
  * @name maxParticles
@@ -35695,8 +36678,7 @@ var ParticleEmitterSettings = {
35695
36678
  maxParticles : 10,
35696
36679
 
35697
36680
  /**
35698
- * How often a particle is emitted in ms (used only if emitter is Stream).<br>
35699
- * Necessary that value is greater than zero.<br>
36681
+ * How often a particle is emitted in ms (used only if emitter is a Stream).
35700
36682
  * @public
35701
36683
  * @type {number}
35702
36684
  * @name frequency
@@ -35706,8 +36688,8 @@ var ParticleEmitterSettings = {
35706
36688
  frequency : 100,
35707
36689
 
35708
36690
  /**
35709
- * Duration that the emitter releases particles in ms (used only if emitter is Stream).<br>
35710
- * After this period, the emitter stop the launch of particles.<br>
36691
+ * Duration that the emitter releases particles in ms (used only if emitter is Stream).
36692
+ * After this period, the emitter stop the launch of particles.
35711
36693
  * @public
35712
36694
  * @type {number}
35713
36695
  * @name duration
@@ -35717,8 +36699,8 @@ var ParticleEmitterSettings = {
35717
36699
  duration : Infinity,
35718
36700
 
35719
36701
  /**
35720
- * Skip n frames after updating the particle system once. <br>
35721
- * This can be used to reduce the performance impact of emitters with many particles.<br>
36702
+ * Skip n frames after updating the particle system once.
36703
+ * This can be used to reduce the performance impact of emitters with many particles.
35722
36704
  * @public
35723
36705
  * @type {number}
35724
36706
  * @name framesToSkip
@@ -35728,44 +36710,64 @@ var ParticleEmitterSettings = {
35728
36710
  framesToSkip : 0
35729
36711
  };
35730
36712
 
36713
+ // default texture used when no sprite is defined
36714
+ let defaultParticleTexture;
36715
+
36716
+ /**
36717
+ * @ignore
36718
+ */
36719
+ function createDefaultParticleTexture(w = 8, h = 8) {
36720
+ if (typeof defaultParticleTexture === "undefined") {
36721
+ defaultParticleTexture = createCanvas(w, h, true);
36722
+ var context = defaultParticleTexture.getContext("2d");
36723
+ context.fillStyle = "#fff";
36724
+ context.fillRect(0, 0, w, h);
36725
+ }
36726
+ return defaultParticleTexture;
36727
+ }
35731
36728
  /**
36729
+ * @classdesc
35732
36730
  * Particle Emitter Object.
35733
- * @class
35734
- * @augments Rect
35735
- * @param {number} x x-position of the particle emitter
35736
- * @param {number} y y-position of the particle emitter
35737
- * @param {object} settings An object containing the settings for the particle emitter. See {@link ParticleEmitterSettings}
35738
- * @example
35739
- * // Create a basic emitter at position 100, 100
35740
- * var emitter = new me.ParticleEmitter(100, 100);
35741
- *
35742
- * // Adjust the emitter properties
35743
- * emitter.totalParticles = 200;
35744
- * emitter.minLife = 1000;
35745
- * emitter.maxLife = 3000;
35746
- * emitter.z = 10;
35747
- *
35748
- * // Add the emitter to the game world
35749
- * me.game.world.addChild(emitter);
35750
- *
35751
- * // Launch all particles one time and stop, like a explosion
35752
- * emitter.burstParticles();
35753
- *
35754
- * // Launch constantly the particles, like a fountain
35755
- * emitter.streamParticles();
35756
- *
35757
- * // At the end, remove emitter from the game world
35758
- * // call this in onDestroyEvent function
35759
- * me.game.world.removeChild(emitter);
36731
+ * @augments Container
35760
36732
  */
35761
- class ParticleEmitter extends Renderable {
35762
-
36733
+ class ParticleEmitter extends Container {
35763
36734
  /**
35764
- * @ignore
36735
+ * @param {number} x x position of the particle emitter
36736
+ * @param {number} y y position of the particle emitter
36737
+ * @param {ParticleEmitterSettings} [settings=ParticleEmitterSettings] the settings for the particle emitter.
36738
+ * @example
36739
+ * // Create a basic emitter at position 100, 100
36740
+ * var emitter = new ParticleEmitter(100, 100);
36741
+ *
36742
+ * // Adjust the emitter properties
36743
+ * emitter.totalParticles = 200;
36744
+ * emitter.minLife = 1000;
36745
+ * emitter.maxLife = 3000;
36746
+ * emitter.z = 10;
36747
+ *
36748
+ * // Add the emitter to the game world
36749
+ * me.game.world.addChild(emitter);
36750
+ *
36751
+ * // Launch all particles one time and stop, like a explosion
36752
+ * emitter.burstParticles();
36753
+ *
36754
+ * // Launch constantly the particles, like a fountain
36755
+ * emitter.streamParticles();
36756
+ *
36757
+ * // At the end, remove emitter from the game world
36758
+ * // call this in onDestroyEvent function
36759
+ * me.game.world.removeChild(emitter);
35765
36760
  */
35766
- constructor(x, y, settings) {
36761
+ constructor(x, y, settings = {}) {
35767
36762
  // call the super constructor
35768
- super(x, y, Infinity, Infinity);
36763
+ super(
36764
+ x, y,
36765
+ settings.width | 1,
36766
+ settings.height | 1
36767
+ );
36768
+
36769
+ // center the emitter around the given coordinates
36770
+ this.centerOn(x, y);
35769
36771
 
35770
36772
  // Emitter is Stream, launch particles constantly
35771
36773
  /** @ignore */
@@ -35791,109 +36793,52 @@ class ParticleEmitter extends Renderable {
35791
36793
  // don't sort the particles by z-index
35792
36794
  this.autoSort = false;
35793
36795
 
35794
- this.container = new ParticleContainer(this);
35795
-
35796
- // Reset the emitter to defaults
35797
- this.reset(settings);
35798
- }
36796
+ // count the updates
36797
+ this._updateCount = 0;
35799
36798
 
35800
- /**
35801
- * @ignore
35802
- */
35803
- get z() {
35804
- return this.container.pos.z;
35805
- }
36799
+ // the emitter settings
36800
+ this.settings = {};
35806
36801
 
35807
- /**
35808
- * @ignore
35809
- */
35810
- set z(value) {
35811
- this.container.pos.z = value;
35812
- }
36802
+ // internally store how much time was skipped when frames are skipped
36803
+ this._dt = 0;
35813
36804
 
35814
- /**
35815
- * Floating property for particles, value is forwarded to the particle container <br>
35816
- * @type {boolean}
35817
- * @name floating
35818
- * @memberof ParticleEmitter
35819
- */
35820
- get floating() {
35821
- return this.container.floating;
35822
- }
36805
+ //this.anchorPoint.set(0, 0);
35823
36806
 
35824
- set floating(value) {
35825
- this.container.floating = value;
36807
+ // Reset the emitter to defaults
36808
+ this.reset(settings);
35826
36809
  }
35827
36810
 
35828
36811
  /**
35829
- * @ignore
36812
+ * Reset the emitter with particle emitter settings.
36813
+ * @param {object} settings [optional] object with emitter settings. See {@link ParticleEmitterSettings}
35830
36814
  */
35831
- onActivateEvent() {
35832
- this.ancestor.addChild(this.container);
35833
- this.container.pos.z = this.pos.z;
35834
- if (!this.ancestor.autoSort) {
35835
- this.ancestor.sort();
35836
- }
35837
- }
36815
+ reset(settings = {}) {
36816
+ Object.assign(this.settings, ParticleEmitterSettings, settings);
35838
36817
 
35839
- /**
35840
- * @ignore
35841
- */
35842
- onDeactivateEvent() {
35843
- if (this.ancestor.hasChild(this.container)) {
35844
- this.ancestor.removeChildNow(this.container);
36818
+ // Cache the image reference
36819
+ if (typeof this.settings.image === "undefined") {
36820
+ this.settings.image = createDefaultParticleTexture(settings.textureSize, settings.textureSize);
35845
36821
  }
35846
- }
35847
36822
 
35848
- /**
35849
- * @ignore
35850
- */
35851
- destroy() {
35852
- this.reset();
36823
+ this.floating = this.settings.floating;
36824
+
36825
+ this.isDirty = true;
35853
36826
  }
35854
36827
 
35855
36828
  /**
35856
- * returns a random point inside the bounds x axis of this emitter
35857
- * @name getRandomPointX
35858
- * @memberof ParticleEmitter
35859
- * @function
36829
+ * returns a random point on the x axis within the bounds of this emitter
35860
36830
  * @returns {number}
35861
36831
  */
35862
36832
  getRandomPointX() {
35863
- return this.pos.x + randomFloat(0, this.width);
36833
+ return randomFloat(0, this.getBounds().width);
35864
36834
  }
35865
36835
 
35866
36836
  /**
35867
- * returns a random point inside the bounds y axis of this emitter
35868
- * @name getRandomPointY
35869
- * @memberof ParticleEmitter
35870
- * @function
36837
+ * returns a random point on the y axis within the bounds this emitter
35871
36838
  * @returns {number}
35872
36839
  */
35873
36840
  getRandomPointY() {
35874
- return this.pos.y + randomFloat(0, this.height);
35875
- }
35876
-
35877
- /**
35878
- * Reset the emitter with default values.<br>
35879
- * @function
35880
- * @param {object} settings [optional] object with emitter settings. See {@link ParticleEmitterSettings}
35881
- * @name reset
35882
- * @memberof ParticleEmitter
35883
- */
35884
- reset(settings) {
35885
- // check if settings exists and create a dummy object if necessary
35886
- settings = settings || {};
35887
- var defaults = ParticleEmitterSettings;
35888
-
35889
- var width = (typeof settings.width === "number") ? settings.width : defaults.width;
35890
- var height = (typeof settings.height === "number") ? settings.height : defaults.height;
35891
- this.resize(width, height);
35892
-
35893
- Object.assign(this, defaults, settings);
35894
-
35895
- // reset particle container values
35896
- this.container.reset();
36841
+ return randomFloat(0, this.getBounds().height);
35897
36842
  }
35898
36843
 
35899
36844
  // Add count particles in the game world
@@ -35901,59 +36846,45 @@ class ParticleEmitter extends Renderable {
35901
36846
  addParticles(count) {
35902
36847
  for (var i = 0; i < ~~count; i++) {
35903
36848
  // Add particle to the container
35904
- var particle = pull("Particle", this);
35905
- this.container.addChild(particle);
36849
+ this.addChild(pull("Particle", this), this.pos.z);
35906
36850
  }
36851
+ this.isDirty = true;
35907
36852
  }
35908
36853
 
35909
36854
  /**
35910
- * Emitter is of type stream and is launching particles <br>
35911
- * @function
36855
+ * Emitter is of type stream and is launching particles
35912
36856
  * @returns {boolean} Emitter is Stream and is launching particles
35913
- * @name isRunning
35914
- * @memberof ParticleEmitter
35915
36857
  */
35916
36858
  isRunning() {
35917
36859
  return this._enabled && this._stream;
35918
36860
  }
35919
36861
 
35920
36862
  /**
35921
- * Launch particles from emitter constantly <br>
35922
- * Particles example: Fountains
36863
+ * Launch particles from emitter constantly (e.g. for stream)
35923
36864
  * @param {number} duration [optional] time that the emitter releases particles in ms
35924
- * @function
35925
- * @name streamParticles
35926
- * @memberof ParticleEmitter
35927
36865
  */
35928
36866
  streamParticles(duration) {
35929
36867
  this._enabled = true;
35930
36868
  this._stream = true;
35931
- this.frequency = Math.max(this.frequency, 1);
35932
- this._durationTimer = (typeof duration === "number") ? duration : this.duration;
36869
+ this.settings.frequency = Math.max(1, this.settings.frequency);
36870
+ this._durationTimer = (typeof duration === "number") ? duration : this.settings.duration;
35933
36871
  }
35934
36872
 
35935
36873
  /**
35936
- * Stop the emitter from generating new particles (used only if emitter is Stream) <br>
35937
- * @function
35938
- * @name stopStream
35939
- * @memberof ParticleEmitter
36874
+ * Stop the emitter from generating new particles (used only if emitter is Stream)
35940
36875
  */
35941
36876
  stopStream() {
35942
36877
  this._enabled = false;
35943
36878
  }
35944
36879
 
35945
36880
  /**
35946
- * Launch all particles from emitter and stop <br>
35947
- * Particles example: Explosions <br>
36881
+ * Launch all particles from emitter and stop (e.g. for explosion)
35948
36882
  * @param {number} total [optional] number of particles to launch
35949
- * @function
35950
- * @name burstParticles
35951
- * @memberof ParticleEmitter
35952
36883
  */
35953
36884
  burstParticles(total) {
35954
36885
  this._enabled = true;
35955
36886
  this._stream = false;
35956
- this.addParticles((typeof total === "number") ? total : this.totalParticles);
36887
+ this.addParticles((typeof total === "number") ? total : this.settings.totalParticles);
35957
36888
  this._enabled = false;
35958
36889
  }
35959
36890
 
@@ -35961,6 +36892,22 @@ class ParticleEmitter extends Renderable {
35961
36892
  * @ignore
35962
36893
  */
35963
36894
  update(dt) {
36895
+ // skip frames if necessary
36896
+ if (++this._updateCount > this.settings.framesToSkip) {
36897
+ this._updateCount = 0;
36898
+ }
36899
+ if (this._updateCount > 0) {
36900
+ this._dt += dt;
36901
+ return this.isDirty;
36902
+ }
36903
+
36904
+ // apply skipped delta time
36905
+ dt += this._dt;
36906
+ this._dt = 0;
36907
+
36908
+ // Update particles
36909
+ this.isDirty |= super.update(dt);
36910
+
35964
36911
  // Launch new particles, if emitter is Stream
35965
36912
  if ((this._enabled) && (this._stream)) {
35966
36913
  // Check if the emitter has duration set
@@ -35969,7 +36916,7 @@ class ParticleEmitter extends Renderable {
35969
36916
 
35970
36917
  if (this._durationTimer <= 0) {
35971
36918
  this.stopStream();
35972
- return false;
36919
+ return this.isDirty;
35973
36920
  }
35974
36921
  }
35975
36922
 
@@ -35977,117 +36924,136 @@ class ParticleEmitter extends Renderable {
35977
36924
  this._frequencyTimer += dt;
35978
36925
 
35979
36926
  // Check for new particles launch
35980
- var particlesCount = this.container.children.length;
35981
- if ((particlesCount < this.totalParticles) && (this._frequencyTimer >= this.frequency)) {
35982
- if ((particlesCount + this.maxParticles) <= this.totalParticles) {
35983
- this.addParticles(this.maxParticles);
36927
+ var particlesCount = this.children.length;
36928
+ if ((particlesCount < this.settings.totalParticles) && (this._frequencyTimer >= this.settings.frequency)) {
36929
+ if ((particlesCount + this.settings.maxParticles) <= this.settings.totalParticles) {
36930
+ this.addParticles(this.settings.maxParticles);
35984
36931
  }
35985
36932
  else {
35986
- this.addParticles(this.totalParticles - particlesCount);
36933
+ this.addParticles(this.settings.totalParticles - particlesCount);
35987
36934
  }
35988
-
35989
36935
  this._frequencyTimer = 0;
36936
+ this.isDirty = true;
35990
36937
  }
35991
36938
  }
35992
- return true;
36939
+ return this.isDirty;
35993
36940
  }
35994
36941
 
36942
+ /**
36943
+ * Destroy function
36944
+ * @ignore
36945
+ */
36946
+ destroy() {
36947
+ // call the parent destroy method
36948
+ super.destroy(arguments);
36949
+ // clean emitter specific Properties
36950
+ this.settings.image = undefined;
36951
+ this.settings = undefined;
36952
+ }
35995
36953
  }
35996
36954
 
35997
36955
  /**
35998
36956
  * @classdesc
35999
36957
  * Single Particle Object.
36000
- * @class Particle
36001
36958
  * @augments Renderable
36002
- * @param {ParticleEmitter} particle emitter
36003
36959
  */
36004
36960
  class Particle extends Renderable {
36005
36961
  /**
36006
- * @ignore
36962
+ * @param {ParticleEmitter} emitter the particle emitter
36007
36963
  */
36008
36964
  constructor(emitter) {
36009
36965
  // Call the super constructor
36010
36966
  super(
36011
36967
  emitter.getRandomPointX(),
36012
36968
  emitter.getRandomPointY(),
36013
- emitter.image.width,
36014
- emitter.image.height
36969
+ emitter.settings.image.width,
36970
+ emitter.settings.image.height
36015
36971
  );
36016
-
36017
- // particle velocity
36018
- this.vel = new Vector2d();
36019
36972
  this.onResetEvent(emitter, true);
36020
36973
  }
36021
36974
 
36975
+ /**
36976
+ * @ignore
36977
+ */
36022
36978
  onResetEvent(emitter, newInstance = false) {
36023
36979
  if (newInstance === false) {
36024
- super.onResetEvent(
36980
+ this.pos.set(
36025
36981
  emitter.getRandomPointX(),
36026
- emitter.getRandomPointY(),
36027
- emitter.image.width,
36028
- emitter.image.height
36982
+ emitter.getRandomPointY()
36029
36983
  );
36984
+ this.resize(
36985
+ emitter.settings.image.width,
36986
+ emitter.settings.image.height
36987
+ );
36988
+ } else {
36989
+ // particle velocity
36990
+ this.vel = new Vector2d();
36030
36991
  }
36031
36992
 
36993
+ this.image = emitter.settings.image;
36994
+
36032
36995
  // Particle will always update
36033
36996
  this.alwaysUpdate = true;
36034
36997
 
36035
- // Cache the image reference
36036
- this.image = emitter.image;
36998
+ if (typeof emitter.settings.tint === "string") {
36999
+ this.tint.parseCSS(emitter.settings.tint);
37000
+ }
37001
+
37002
+ if (emitter.settings.textureAdditive === true) {
37003
+ this.blendMode = "additive";
37004
+ }
37005
+
37006
+ if (emitter.settings.blendMode !== "normal") {
37007
+ this.blendMode = emitter.settings.blendMode;
37008
+ }
36037
37009
 
36038
37010
  // Set the start particle Angle and Speed as defined in emitter
36039
- var angle = emitter.angle + ((emitter.angleVariation > 0) ? (randomFloat(0, 2) - 1) * emitter.angleVariation : 0);
36040
- var speed = emitter.speed + ((emitter.speedVariation > 0) ? (randomFloat(0, 2) - 1) * emitter.speedVariation : 0);
37011
+ var angle = emitter.settings.angle + ((emitter.settings.angleVariation > 0) ? (randomFloat(0, 2) - 1) * emitter.settings.angleVariation : 0);
37012
+ var speed = emitter.settings.speed + ((emitter.settings.speedVariation > 0) ? (randomFloat(0, 2) - 1) * emitter.settings.speedVariation : 0);
36041
37013
 
36042
37014
  // Set the start particle Velocity
36043
37015
  this.vel.set(speed * Math.cos(angle), -speed * Math.sin(angle));
36044
37016
 
36045
37017
  // Set the start particle Time of Life as defined in emitter
36046
- this.life = randomFloat(emitter.minLife, emitter.maxLife);
37018
+ this.life = randomFloat(emitter.settings.minLife, emitter.settings.maxLife);
36047
37019
  this.startLife = this.life;
36048
37020
 
36049
37021
  // Set the start and end particle Scale as defined in emitter
36050
37022
  // clamp the values as minimum and maximum scales range
36051
37023
  this.startScale = clamp(
36052
- randomFloat(emitter.minStartScale, emitter.maxStartScale),
36053
- emitter.minStartScale,
36054
- emitter.maxStartScale
37024
+ randomFloat(emitter.settings.minStartScale, emitter.settings.maxStartScale),
37025
+ emitter.settings.minStartScale,
37026
+ emitter.settings.maxStartScale
36055
37027
  );
36056
37028
  this.endScale = clamp(
36057
- randomFloat(emitter.minEndScale, emitter.maxEndScale),
36058
- emitter.minEndScale,
36059
- emitter.maxEndScale
37029
+ randomFloat(emitter.settings.minEndScale, emitter.settings.maxEndScale),
37030
+ emitter.settings.minEndScale,
37031
+ emitter.settings.maxEndScale
36060
37032
  );
36061
37033
 
36062
37034
  // Set the particle Gravity and Wind (horizontal gravity) as defined in emitter
36063
- this.gravity = emitter.gravity;
36064
- this.wind = emitter.wind;
37035
+ this.gravity = emitter.settings.gravity;
37036
+ this.wind = emitter.settings.wind;
36065
37037
 
36066
37038
  // Set if the particle update the rotation in accordance the trajectory
36067
- this.followTrajectory = emitter.followTrajectory;
37039
+ this.followTrajectory = emitter.settings.followTrajectory;
36068
37040
 
36069
37041
  // Set if the particle update only in Viewport
36070
- this.onlyInViewport = emitter.onlyInViewport;
36071
-
36072
- // Set the particle Z Order
36073
- this.pos.z = emitter.z;
37042
+ this.onlyInViewport = emitter.settings.onlyInViewport;
36074
37043
 
36075
37044
  // cache inverse of the expected delta time
36076
37045
  this._deltaInv = timer$1.maxfps / 1000;
36077
37046
 
36078
37047
  // Set the start particle rotation as defined in emitter
36079
37048
  // if the particle not follow trajectory
36080
- if (!emitter.followTrajectory) {
36081
- this.angle = randomFloat(emitter.minRotation, emitter.maxRotation);
37049
+ if (!emitter.settings.followTrajectory) {
37050
+ this.angle = randomFloat(emitter.settings.minRotation, emitter.settings.maxRotation);
36082
37051
  }
36083
37052
  }
36084
37053
 
36085
37054
  /**
36086
37055
  * Update the Particle <br>
36087
37056
  * This is automatically called by the game manager {@link game}
36088
- * @name update
36089
- * @memberof Particle
36090
- * @function
36091
37057
  * @ignore
36092
37058
  * @param {number} dt time since the last update in milliseconds
36093
37059
  */
@@ -36098,6 +37064,11 @@ class Particle extends Renderable {
36098
37064
  // Decrease particle life
36099
37065
  this.life = this.life > dt ? this.life - dt : 0;
36100
37066
 
37067
+ if (this.life <= 0) {
37068
+ this.ancestor.removeChild(this);
37069
+ return false;
37070
+ }
37071
+
36101
37072
  // Calculate the particle Age Ratio
36102
37073
  var ageRatio = this.life / this.startLife;
36103
37074
 
@@ -36132,23 +37103,10 @@ class Particle extends Renderable {
36132
37103
  this.pos.x, this.pos.y, 1
36133
37104
  ).rotate(angle);
36134
37105
 
36135
- // Return true if the particle is not dead yet
36136
- return (this.inViewport || !this.onlyInViewport) && (this.life > 0);
36137
- }
37106
+ // mark as dirty if the particle is not dead yet
37107
+ this.isDirty = this.inViewport || !this.onlyInViewport;
36138
37108
 
36139
- /**
36140
- * @ignore
36141
- */
36142
- preDraw(renderer) {
36143
-
36144
- // restore is called in postDraw
36145
- renderer.save();
36146
-
36147
- // particle alpha value
36148
- renderer.setGlobalAlpha(renderer.globalAlpha() * this.alpha);
36149
-
36150
- // translate to the defined anchor point and scale it
36151
- renderer.transform(this.currentTransform);
37109
+ return super.update(dt);
36152
37110
  }
36153
37111
 
36154
37112
  /**
@@ -36527,7 +37485,7 @@ class DroptargetEntity extends DropTarget {
36527
37485
  }
36528
37486
  }
36529
37487
 
36530
- // ES5 polyfills
37488
+ // ES5/ES6 polyfills
36531
37489
 
36532
37490
 
36533
37491
  /**
@@ -36537,7 +37495,7 @@ class DroptargetEntity extends DropTarget {
36537
37495
  * @name version
36538
37496
  * @type {string}
36539
37497
  */
36540
- const version = "10.6.1";
37498
+ const version = "10.7.0";
36541
37499
 
36542
37500
 
36543
37501
  /**
@@ -36644,4 +37602,4 @@ device$1.onReady(function () {
36644
37602
  }
36645
37603
  });
36646
37604
 
36647
- export { BitmapText, BitmapTextData, Body, Bounds$1 as Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Pointer, Polygon, QuadTree, Rect, Renderable, Renderer, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, Vector2d, Vector3d, WebGLCompositor, WebGLRenderer, World, audio, boot, collision, device$1 as device, event, game, initialized, input, level, loader, plugin, plugins, pooling as pool, save, skipAutoInit, state, timer$1 as timer, utils, version, video, warning };
37605
+ export { BitmapText, BitmapTextData, Body, Bounds$1 as Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Pointer, Polygon, QuadTree, Rect, Renderable, Renderer, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, Vector2d, Vector3d, WebGLCompositor, WebGLRenderer, World, audio, boot, collision, device$1 as device, event$1 as event, game, initialized, input, level, loader, plugin, plugins, pooling as pool, save, skipAutoInit, state, timer$1 as timer, utils, version, video, warning };