melonjs 10.7.0 → 10.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/melonjs.js +1488 -666
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +929 -202
- package/dist/melonjs.module.js +1575 -777
- package/package.json +9 -9
- package/src/camera/camera2d.js +1 -1
- package/src/entity/entity.js +6 -7
- package/src/geometries/ellipse.js +10 -11
- package/src/geometries/line.js +3 -3
- package/src/geometries/path2d.js +319 -0
- package/src/geometries/poly.js +11 -11
- package/src/geometries/rectangle.js +15 -15
- package/src/geometries/roundrect.js +164 -0
- package/src/index.js +5 -1
- package/src/input/gamepad.js +2 -2
- package/src/input/pointerevent.js +1 -1
- package/src/lang/deprecated.js +1 -1
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/level/tiled/TMXObject.js +9 -12
- package/src/level/tiled/TMXTileMap.js +23 -4
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/loader.js +4 -4
- package/src/loader/loadingscreen.js +1 -1
- package/src/math/color.js +1 -1
- package/src/math/matrix2.js +1 -1
- package/src/math/matrix3.js +1 -1
- package/src/math/observable_vector2.js +1 -1
- package/src/math/observable_vector3.js +1 -1
- package/src/math/vector2.js +1 -1
- package/src/math/vector3.js +1 -1
- package/src/particles/emitter.js +23 -14
- package/src/particles/particle.js +3 -2
- package/src/physics/body.js +67 -51
- package/src/physics/bounds.js +8 -9
- package/src/physics/world.js +1 -1
- package/src/polyfill/index.js +1 -0
- package/src/polyfill/roundrect.js +235 -0
- package/src/renderable/collectable.js +9 -2
- package/src/renderable/colorlayer.js +1 -1
- package/src/renderable/container.js +1 -1
- package/src/renderable/imagelayer.js +1 -1
- package/src/renderable/renderable.js +2 -2
- package/src/renderable/sprite.js +2 -3
- package/src/renderable/trigger.js +10 -4
- package/src/state/stage.js +1 -1
- package/src/state/state.js +1 -1
- package/src/system/device.js +10 -8
- package/src/system/pooling.js +156 -149
- package/src/text/bitmaptext.js +1 -1
- package/src/text/text.js +1 -1
- package/src/utils/utils.js +2 -2
- package/src/video/canvas/canvas_renderer.js +83 -39
- package/src/video/renderer.js +36 -16
- package/src/video/texture.js +1 -1
- package/src/video/webgl/glshader.js +29 -193
- package/src/video/webgl/utils/attributes.js +16 -0
- package/src/video/webgl/utils/precision.js +11 -0
- package/src/video/webgl/utils/program.js +58 -0
- package/src/video/webgl/utils/string.js +16 -0
- package/src/video/webgl/utils/uniforms.js +87 -0
- package/src/video/webgl/webgl_compositor.js +1 -14
- package/src/video/webgl/webgl_renderer.js +124 -182
package/dist/melonjs.module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v10.
|
|
2
|
+
* melonJS Game Engine - v10.9.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
|
|
@@ -317,10 +317,10 @@ var store$2 = sharedStore;
|
|
|
317
317
|
(shared$3.exports = function (key, value) {
|
|
318
318
|
return store$2[key] || (store$2[key] = value !== undefined ? value : {});
|
|
319
319
|
})('versions', []).push({
|
|
320
|
-
version: '3.22.
|
|
320
|
+
version: '3.22.5',
|
|
321
321
|
mode: 'global',
|
|
322
322
|
copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
|
|
323
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.22.
|
|
323
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.22.5/LICENSE',
|
|
324
324
|
source: 'https://github.com/zloirock/core-js'
|
|
325
325
|
});
|
|
326
326
|
|
|
@@ -430,19 +430,19 @@ var documentCreateElement = function (it) {
|
|
|
430
430
|
return EXISTS$1 ? document$1.createElement(it) : {};
|
|
431
431
|
};
|
|
432
432
|
|
|
433
|
-
var DESCRIPTORS$
|
|
433
|
+
var DESCRIPTORS$6 = descriptors;
|
|
434
434
|
var fails$3 = fails$8;
|
|
435
435
|
var createElement = documentCreateElement;
|
|
436
436
|
|
|
437
437
|
// Thanks to IE8 for its funny defineProperty
|
|
438
|
-
var ie8DomDefine = !DESCRIPTORS$
|
|
438
|
+
var ie8DomDefine = !DESCRIPTORS$6 && !fails$3(function () {
|
|
439
439
|
// eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
|
|
440
440
|
return Object.defineProperty(createElement('div'), 'a', {
|
|
441
441
|
get: function () { return 7; }
|
|
442
442
|
}).a != 7;
|
|
443
443
|
});
|
|
444
444
|
|
|
445
|
-
var DESCRIPTORS$
|
|
445
|
+
var DESCRIPTORS$5 = descriptors;
|
|
446
446
|
var call = functionCall;
|
|
447
447
|
var propertyIsEnumerableModule = objectPropertyIsEnumerable;
|
|
448
448
|
var createPropertyDescriptor$1 = createPropertyDescriptor$2;
|
|
@@ -456,7 +456,7 @@ var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
|
|
|
456
456
|
|
|
457
457
|
// `Object.getOwnPropertyDescriptor` method
|
|
458
458
|
// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
|
|
459
|
-
objectGetOwnPropertyDescriptor.f = DESCRIPTORS$
|
|
459
|
+
objectGetOwnPropertyDescriptor.f = DESCRIPTORS$5 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
|
|
460
460
|
O = toIndexedObject$2(O);
|
|
461
461
|
P = toPropertyKey$1(P);
|
|
462
462
|
if (IE8_DOM_DEFINE$1) try {
|
|
@@ -467,12 +467,12 @@ objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor$1 :
|
|
|
467
467
|
|
|
468
468
|
var objectDefineProperty = {};
|
|
469
469
|
|
|
470
|
-
var DESCRIPTORS$
|
|
470
|
+
var DESCRIPTORS$4 = descriptors;
|
|
471
471
|
var fails$2 = fails$8;
|
|
472
472
|
|
|
473
473
|
// V8 ~ Chrome 36-
|
|
474
474
|
// https://bugs.chromium.org/p/v8/issues/detail?id=3334
|
|
475
|
-
var v8PrototypeDefineBug = DESCRIPTORS$
|
|
475
|
+
var v8PrototypeDefineBug = DESCRIPTORS$4 && fails$2(function () {
|
|
476
476
|
// eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
|
|
477
477
|
return Object.defineProperty(function () { /* empty */ }, 'prototype', {
|
|
478
478
|
value: 42,
|
|
@@ -493,7 +493,7 @@ var anObject$2 = function (argument) {
|
|
|
493
493
|
};
|
|
494
494
|
|
|
495
495
|
var global$6 = global$m;
|
|
496
|
-
var DESCRIPTORS$
|
|
496
|
+
var DESCRIPTORS$3 = descriptors;
|
|
497
497
|
var IE8_DOM_DEFINE = ie8DomDefine;
|
|
498
498
|
var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
|
|
499
499
|
var anObject$1 = anObject$2;
|
|
@@ -510,7 +510,7 @@ var WRITABLE = 'writable';
|
|
|
510
510
|
|
|
511
511
|
// `Object.defineProperty` method
|
|
512
512
|
// https://tc39.es/ecma262/#sec-object.defineproperty
|
|
513
|
-
objectDefineProperty.f = DESCRIPTORS$
|
|
513
|
+
objectDefineProperty.f = DESCRIPTORS$3 ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
|
|
514
514
|
anObject$1(O);
|
|
515
515
|
P = toPropertyKey(P);
|
|
516
516
|
anObject$1(Attributes);
|
|
@@ -537,11 +537,11 @@ objectDefineProperty.f = DESCRIPTORS$2 ? V8_PROTOTYPE_DEFINE_BUG ? function defi
|
|
|
537
537
|
return O;
|
|
538
538
|
};
|
|
539
539
|
|
|
540
|
-
var DESCRIPTORS$
|
|
540
|
+
var DESCRIPTORS$2 = descriptors;
|
|
541
541
|
var definePropertyModule$1 = objectDefineProperty;
|
|
542
542
|
var createPropertyDescriptor = createPropertyDescriptor$2;
|
|
543
543
|
|
|
544
|
-
var createNonEnumerableProperty$3 = DESCRIPTORS$
|
|
544
|
+
var createNonEnumerableProperty$3 = DESCRIPTORS$2 ? function (object, key, value) {
|
|
545
545
|
return definePropertyModule$1.f(object, key, createPropertyDescriptor(1, value));
|
|
546
546
|
} : function (object, key, value) {
|
|
547
547
|
object[key] = value;
|
|
@@ -550,17 +550,17 @@ var createNonEnumerableProperty$3 = DESCRIPTORS$1 ? function (object, key, value
|
|
|
550
550
|
|
|
551
551
|
var makeBuiltIn$2 = {exports: {}};
|
|
552
552
|
|
|
553
|
-
var DESCRIPTORS = descriptors;
|
|
553
|
+
var DESCRIPTORS$1 = descriptors;
|
|
554
554
|
var hasOwn$4 = hasOwnProperty_1;
|
|
555
555
|
|
|
556
556
|
var FunctionPrototype = Function.prototype;
|
|
557
557
|
// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
|
|
558
|
-
var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
|
|
558
|
+
var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
|
|
559
559
|
|
|
560
560
|
var EXISTS = hasOwn$4(FunctionPrototype, 'name');
|
|
561
561
|
// additional protection from minified / mangled / dropped function names
|
|
562
562
|
var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
|
|
563
|
-
var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
|
|
563
|
+
var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
|
|
564
564
|
|
|
565
565
|
var functionName = {
|
|
566
566
|
EXISTS: EXISTS,
|
|
@@ -675,15 +675,17 @@ var internalState = {
|
|
|
675
675
|
var fails$1 = fails$8;
|
|
676
676
|
var isCallable$2 = isCallable$a;
|
|
677
677
|
var hasOwn$2 = hasOwnProperty_1;
|
|
678
|
-
var
|
|
678
|
+
var DESCRIPTORS = descriptors;
|
|
679
679
|
var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
|
|
680
680
|
var inspectSource = inspectSource$2;
|
|
681
681
|
var InternalStateModule = internalState;
|
|
682
682
|
|
|
683
683
|
var enforceInternalState = InternalStateModule.enforce;
|
|
684
684
|
var getInternalState = InternalStateModule.get;
|
|
685
|
+
// eslint-disable-next-line es-x/no-object-defineproperty -- safe
|
|
686
|
+
var defineProperty = Object.defineProperty;
|
|
685
687
|
|
|
686
|
-
var CONFIGURABLE_LENGTH = !fails$1(function () {
|
|
688
|
+
var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails$1(function () {
|
|
687
689
|
return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
|
|
688
690
|
});
|
|
689
691
|
|
|
@@ -701,6 +703,11 @@ var makeBuiltIn$1 = makeBuiltIn$2.exports = function (value, name, options) {
|
|
|
701
703
|
if (CONFIGURABLE_LENGTH && options && hasOwn$2(options, 'arity') && value.length !== options.arity) {
|
|
702
704
|
defineProperty(value, 'length', { value: options.arity });
|
|
703
705
|
}
|
|
706
|
+
if (options && hasOwn$2(options, 'constructor') && options.constructor) {
|
|
707
|
+
if (DESCRIPTORS) try {
|
|
708
|
+
defineProperty(value, 'prototype', { writable: false });
|
|
709
|
+
} catch (error) { /* empty */ }
|
|
710
|
+
} else value.prototype = undefined;
|
|
704
711
|
var state = enforceInternalState(value);
|
|
705
712
|
if (!hasOwn$2(state, 'source')) {
|
|
706
713
|
state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
|
|
@@ -822,17 +829,17 @@ var toIndexedObject = toIndexedObject$3;
|
|
|
822
829
|
var indexOf = arrayIncludes.indexOf;
|
|
823
830
|
var hiddenKeys$1 = hiddenKeys$3;
|
|
824
831
|
|
|
825
|
-
var push
|
|
832
|
+
var push = uncurryThis$1([].push);
|
|
826
833
|
|
|
827
834
|
var objectKeysInternal = function (object, names) {
|
|
828
835
|
var O = toIndexedObject(object);
|
|
829
836
|
var i = 0;
|
|
830
837
|
var result = [];
|
|
831
838
|
var key;
|
|
832
|
-
for (key in O) !hasOwn$1(hiddenKeys$1, key) && hasOwn$1(O, key) && push
|
|
839
|
+
for (key in O) !hasOwn$1(hiddenKeys$1, key) && hasOwn$1(O, key) && push(result, key);
|
|
833
840
|
// Don't enum bug & hidden keys
|
|
834
841
|
while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
|
|
835
|
-
~indexOf(result, key) || push
|
|
842
|
+
~indexOf(result, key) || push(result, key);
|
|
836
843
|
}
|
|
837
844
|
return result;
|
|
838
845
|
};
|
|
@@ -1587,10 +1594,8 @@ var fnUtils = /*#__PURE__*/Object.freeze({
|
|
|
1587
1594
|
throttle: throttle
|
|
1588
1595
|
});
|
|
1589
1596
|
|
|
1590
|
-
var objectClass = {};
|
|
1591
|
-
var instance_counter = 0;
|
|
1592
|
-
|
|
1593
1597
|
/**
|
|
1598
|
+
* @classdesc
|
|
1594
1599
|
* This object is used for object pooling - a technique that might speed up your game if used properly.<br>
|
|
1595
1600
|
* If some of your classes will be instantiated and removed a lot at a time, it is a
|
|
1596
1601
|
* good idea to add the class to this object pool. A separate pool for that class
|
|
@@ -1601,180 +1606,181 @@ var instance_counter = 0;
|
|
|
1601
1606
|
* which means, that on level loading the engine will try to instantiate every object
|
|
1602
1607
|
* found in the map, based on the user defined name in each Object Properties<br>
|
|
1603
1608
|
* <img src="images/object_properties.png"/><br>
|
|
1604
|
-
* @
|
|
1609
|
+
* @see {@link pool} a default global instance of ObjectPool
|
|
1605
1610
|
*/
|
|
1611
|
+
class ObjectPool {
|
|
1606
1612
|
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1613
|
+
constructor() {
|
|
1614
|
+
this.objectClass = {};
|
|
1615
|
+
this.instance_counter = 0;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* register an object to the pool. <br>
|
|
1620
|
+
* Pooling must be set to true if more than one such objects will be created. <br>
|
|
1621
|
+
* (Note: for an object to be poolable, it must implements a `onResetEvent` method)
|
|
1622
|
+
* @param {string} className as defined in the Name field of the Object Properties (in Tiled)
|
|
1623
|
+
* @param {object} classObj corresponding Class to be instantiated
|
|
1624
|
+
* @param {boolean} [recycling=false] enables object recycling for the specified class
|
|
1625
|
+
* @example
|
|
1626
|
+
* // implement CherryEntity
|
|
1627
|
+
* class CherryEntity extends Spritesheet {
|
|
1628
|
+
* onResetEvent() {
|
|
1629
|
+
* // reset object mutable properties
|
|
1630
|
+
* this.lifeBar = 100;
|
|
1631
|
+
* }
|
|
1632
|
+
* };
|
|
1633
|
+
* // add our users defined entities in the object pool and enable object recycling
|
|
1634
|
+
* me.pool.register("cherryentity", CherryEntity, true);
|
|
1635
|
+
*/
|
|
1636
|
+
register(className, classObj, recycling = false) {
|
|
1637
|
+
if (typeof (classObj) !== "undefined") {
|
|
1638
|
+
this.objectClass[className] = {
|
|
1639
|
+
"class" : classObj,
|
|
1640
|
+
"pool" : (recycling ? [] : undefined)
|
|
1641
|
+
};
|
|
1642
|
+
} else {
|
|
1643
|
+
throw new Error("Cannot register object '" + className + "', invalid class");
|
|
1644
|
+
}
|
|
1634
1645
|
}
|
|
1635
|
-
|
|
1636
|
-
/**
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
instance_counter--;
|
|
1677
|
-
}
|
|
1678
|
-
else {
|
|
1679
|
-
// create a new instance
|
|
1680
|
-
args[0] = proto;
|
|
1681
|
-
obj = new (proto.bind.apply(proto, args))();
|
|
1682
|
-
if (poolArray) {
|
|
1683
|
-
obj.className = name;
|
|
1646
|
+
|
|
1647
|
+
/**
|
|
1648
|
+
* Pull a new instance of the requested object (if added into the object pool)
|
|
1649
|
+
* @param {string} name as used in {@link pool.register}
|
|
1650
|
+
* @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
|
|
1651
|
+
* @returns {object} the instance of the requested object
|
|
1652
|
+
* @example
|
|
1653
|
+
* me.pool.register("bullet", BulletEntity, true);
|
|
1654
|
+
* me.pool.register("enemy", EnemyEntity, true);
|
|
1655
|
+
* // ...
|
|
1656
|
+
* // when we need to manually create a new bullet:
|
|
1657
|
+
* var bullet = me.pool.pull("bullet", x, y, direction);
|
|
1658
|
+
* // ...
|
|
1659
|
+
* // params aren't a fixed number
|
|
1660
|
+
* // when we need new enemy we can add more params, that the object construct requires:
|
|
1661
|
+
* var enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
|
|
1662
|
+
* // ...
|
|
1663
|
+
* // when we want to destroy existing object, the remove
|
|
1664
|
+
* // function will ensure the object can then be reallocated later
|
|
1665
|
+
* me.game.world.removeChild(enemy);
|
|
1666
|
+
* me.game.world.removeChild(bullet);
|
|
1667
|
+
*/
|
|
1668
|
+
pull(name) {
|
|
1669
|
+
var args = new Array(arguments.length);
|
|
1670
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
1671
|
+
args[i] = arguments[i];
|
|
1672
|
+
}
|
|
1673
|
+
var className = this.objectClass[name];
|
|
1674
|
+
if (className) {
|
|
1675
|
+
var proto = className["class"],
|
|
1676
|
+
poolArray = className.pool,
|
|
1677
|
+
obj;
|
|
1678
|
+
|
|
1679
|
+
if (poolArray && ((obj = poolArray.pop()))) {
|
|
1680
|
+
// pull an existing instance from the pool
|
|
1681
|
+
args.shift();
|
|
1682
|
+
// call the object onResetEvent function if defined
|
|
1683
|
+
if (typeof(obj.onResetEvent) === "function") {
|
|
1684
|
+
obj.onResetEvent.apply(obj, args);
|
|
1685
|
+
}
|
|
1686
|
+
this.instance_counter--;
|
|
1684
1687
|
}
|
|
1688
|
+
else {
|
|
1689
|
+
// create a new instance
|
|
1690
|
+
args[0] = proto;
|
|
1691
|
+
obj = new (proto.bind.apply(proto, args))();
|
|
1692
|
+
if (poolArray) {
|
|
1693
|
+
obj.className = name;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
return obj;
|
|
1685
1697
|
}
|
|
1686
|
-
|
|
1698
|
+
throw new Error("Cannot instantiate object of type '" + name + "'");
|
|
1687
1699
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
objectClass[className].pool = [];
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* purge the object pool from any inactive object <br>
|
|
1703
|
+
* Object pooling must be enabled for this function to work<br>
|
|
1704
|
+
* note: this will trigger the garbage collector
|
|
1705
|
+
*/
|
|
1706
|
+
purge() {
|
|
1707
|
+
for (var className in this.objectClass) {
|
|
1708
|
+
if (this.objectClass[className]) {
|
|
1709
|
+
this.objectClass[className].pool = [];
|
|
1710
|
+
}
|
|
1700
1711
|
}
|
|
1712
|
+
this.instance_counter = 0;
|
|
1701
1713
|
}
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
return false;
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* Push back an object instance into the object pool <br>
|
|
1717
|
+
* Object pooling for the object class must be enabled,
|
|
1718
|
+
* and object must have been instantiated using {@link pool#pull},
|
|
1719
|
+
* otherwise this function won't work
|
|
1720
|
+
* @throws will throw an error if the object cannot be recycled
|
|
1721
|
+
* @param {object} obj instance to be recycled
|
|
1722
|
+
* @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
|
|
1723
|
+
* @returns {boolean} true if the object was successfully recycled in the object pool
|
|
1724
|
+
*/
|
|
1725
|
+
push(obj, throwOnError = true) {
|
|
1726
|
+
if (!this.poolable(obj)) {
|
|
1727
|
+
if (throwOnError === true ) {
|
|
1728
|
+
throw new Error("me.pool: object " + obj + " cannot be recycled");
|
|
1729
|
+
} else {
|
|
1730
|
+
return false;
|
|
1731
|
+
}
|
|
1721
1732
|
}
|
|
1733
|
+
|
|
1734
|
+
// store back the object instance for later recycling
|
|
1735
|
+
this.objectClass[obj.className].pool.push(obj);
|
|
1736
|
+
this.instance_counter++;
|
|
1737
|
+
|
|
1738
|
+
return true;
|
|
1722
1739
|
}
|
|
1723
1740
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1741
|
+
/**
|
|
1742
|
+
* Check if an object with the provided name is registered
|
|
1743
|
+
* @param {string} name of the registered object class
|
|
1744
|
+
* @returns {boolean} true if the classname is registered
|
|
1745
|
+
*/
|
|
1746
|
+
exists(name) {
|
|
1747
|
+
return name in this.objectClass;
|
|
1748
|
+
};
|
|
1727
1749
|
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
* if (!me.pool.poolable(myCherryEntity)) {
|
|
1748
|
-
* // object was not properly registered
|
|
1749
|
-
* }
|
|
1750
|
-
*/
|
|
1751
|
-
function poolable(obj) {
|
|
1752
|
-
var className = obj.className;
|
|
1753
|
-
return (typeof className !== "undefined") &&
|
|
1754
|
-
(typeof obj.onResetEvent === "function") &&
|
|
1755
|
-
(className in objectClass) &&
|
|
1756
|
-
(objectClass[className].pool !== "undefined");
|
|
1750
|
+
/**
|
|
1751
|
+
* Check if an object is poolable
|
|
1752
|
+
* (was properly registered with the recycling feature enable)
|
|
1753
|
+
* @see register
|
|
1754
|
+
* @param {object} obj object to be checked
|
|
1755
|
+
* @returns {boolean} true if the object is poolable
|
|
1756
|
+
* @example
|
|
1757
|
+
* if (!me.pool.poolable(myCherryEntity)) {
|
|
1758
|
+
* // object was not properly registered
|
|
1759
|
+
* }
|
|
1760
|
+
*/
|
|
1761
|
+
poolable(obj) {
|
|
1762
|
+
var className = obj.className;
|
|
1763
|
+
return (typeof className !== "undefined") &&
|
|
1764
|
+
(typeof obj.onResetEvent === "function") &&
|
|
1765
|
+
(className in this.objectClass) &&
|
|
1766
|
+
(this.objectClass[className].pool !== "undefined");
|
|
1767
|
+
|
|
1768
|
+
}
|
|
1757
1769
|
|
|
1770
|
+
/**
|
|
1771
|
+
* returns the amount of object instance currently in the pool
|
|
1772
|
+
* @returns {number} amount of object instance
|
|
1773
|
+
*/
|
|
1774
|
+
getInstanceCount() {
|
|
1775
|
+
return this.instance_counter;
|
|
1776
|
+
}
|
|
1758
1777
|
}
|
|
1759
1778
|
/**
|
|
1760
|
-
*
|
|
1761
|
-
* @
|
|
1762
|
-
* @
|
|
1779
|
+
* a default global object pool instance
|
|
1780
|
+
* @public
|
|
1781
|
+
* @type {ObjectPool}
|
|
1763
1782
|
*/
|
|
1764
|
-
|
|
1765
|
-
return instance_counter;
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
var pooling = /*#__PURE__*/Object.freeze({
|
|
1769
|
-
__proto__: null,
|
|
1770
|
-
register: register,
|
|
1771
|
-
pull: pull,
|
|
1772
|
-
purge: purge,
|
|
1773
|
-
push: push,
|
|
1774
|
-
exists: exists,
|
|
1775
|
-
poolable: poolable,
|
|
1776
|
-
getInstanceCount: getInstanceCount
|
|
1777
|
-
});
|
|
1783
|
+
var pool$1 = new ObjectPool();
|
|
1778
1784
|
|
|
1779
1785
|
/**
|
|
1780
1786
|
* @classdesc
|
|
@@ -2290,7 +2296,7 @@ class Vector2d {
|
|
|
2290
2296
|
* @returns {Vector2d} new me.Vector2d
|
|
2291
2297
|
*/
|
|
2292
2298
|
clone() {
|
|
2293
|
-
return pull("Vector2d", this.x, this.y);
|
|
2299
|
+
return pool$1.pull("Vector2d", this.x, this.y);
|
|
2294
2300
|
}
|
|
2295
2301
|
|
|
2296
2302
|
/**
|
|
@@ -2584,7 +2590,7 @@ class Color {
|
|
|
2584
2590
|
* @returns {Color} Reference to the newly cloned object
|
|
2585
2591
|
*/
|
|
2586
2592
|
clone() {
|
|
2587
|
-
return pull("Color").copy(this);
|
|
2593
|
+
return pool$1.pull("Color").copy(this);
|
|
2588
2594
|
}
|
|
2589
2595
|
|
|
2590
2596
|
/**
|
|
@@ -3254,12 +3260,12 @@ class Matrix3d {
|
|
|
3254
3260
|
*/
|
|
3255
3261
|
applyInverse(v) {
|
|
3256
3262
|
// invert the current matrix
|
|
3257
|
-
var im = pull("Matrix3d", this).invert();
|
|
3263
|
+
var im = pool$1.pull("Matrix3d", this).invert();
|
|
3258
3264
|
|
|
3259
3265
|
// apply the inverted matrix
|
|
3260
3266
|
im.apply(v);
|
|
3261
3267
|
|
|
3262
|
-
push(im);
|
|
3268
|
+
pool$1.push(im);
|
|
3263
3269
|
|
|
3264
3270
|
return v;
|
|
3265
3271
|
}
|
|
@@ -3566,7 +3572,7 @@ class Matrix3d {
|
|
|
3566
3572
|
* @returns {Matrix3d}
|
|
3567
3573
|
*/
|
|
3568
3574
|
clone() {
|
|
3569
|
-
return pull("Matrix3d", this);
|
|
3575
|
+
return pool$1.pull("Matrix3d", this);
|
|
3570
3576
|
}
|
|
3571
3577
|
|
|
3572
3578
|
/**
|
|
@@ -4072,7 +4078,7 @@ class Matrix2d {
|
|
|
4072
4078
|
* @returns {Matrix2d}
|
|
4073
4079
|
*/
|
|
4074
4080
|
clone() {
|
|
4075
|
-
return pull("Matrix2d", this);
|
|
4081
|
+
return pool$1.pull("Matrix2d", this);
|
|
4076
4082
|
}
|
|
4077
4083
|
|
|
4078
4084
|
/**
|
|
@@ -8657,7 +8663,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
8657
8663
|
* @returns {ObservableVector2d} new me.ObservableVector2d
|
|
8658
8664
|
*/
|
|
8659
8665
|
clone() {
|
|
8660
|
-
return pull("ObservableVector2d", this._x, this._y, {onUpdate: this.onUpdate, scope: this.scope});
|
|
8666
|
+
return pool$1.pull("ObservableVector2d", this._x, this._y, {onUpdate: this.onUpdate, scope: this.scope});
|
|
8661
8667
|
}
|
|
8662
8668
|
|
|
8663
8669
|
/**
|
|
@@ -8668,7 +8674,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
8668
8674
|
* @returns {Vector2d} new me.Vector2d
|
|
8669
8675
|
*/
|
|
8670
8676
|
toVector2d() {
|
|
8671
|
-
return pull("Vector2d", this._x, this._y);
|
|
8677
|
+
return pool$1.pull("Vector2d", this._x, this._y);
|
|
8672
8678
|
}
|
|
8673
8679
|
|
|
8674
8680
|
/**
|
|
@@ -9235,7 +9241,7 @@ class Vector3d {
|
|
|
9235
9241
|
* @returns {Vector3d} new me.Vector3d
|
|
9236
9242
|
*/
|
|
9237
9243
|
clone() {
|
|
9238
|
-
return pull("Vector3d", this.x, this.y, this.z);
|
|
9244
|
+
return pool$1.pull("Vector3d", this.x, this.y, this.z);
|
|
9239
9245
|
}
|
|
9240
9246
|
|
|
9241
9247
|
/**
|
|
@@ -9767,7 +9773,7 @@ class ObservableVector3d extends Vector3d {
|
|
|
9767
9773
|
* @returns {ObservableVector3d} new me.ObservableVector3d
|
|
9768
9774
|
*/
|
|
9769
9775
|
clone() {
|
|
9770
|
-
return pull("ObservableVector3d",
|
|
9776
|
+
return pool$1.pull("ObservableVector3d",
|
|
9771
9777
|
this._x,
|
|
9772
9778
|
this._y,
|
|
9773
9779
|
this._z,
|
|
@@ -9783,7 +9789,7 @@ class ObservableVector3d extends Vector3d {
|
|
|
9783
9789
|
* @returns {Vector3d} new me.Vector3d
|
|
9784
9790
|
*/
|
|
9785
9791
|
toVector3d() {
|
|
9786
|
-
return pull("Vector3d", this._x, this._y, this._z);
|
|
9792
|
+
return pool$1.pull("Vector3d", this._x, this._y, this._z);
|
|
9787
9793
|
}
|
|
9788
9794
|
|
|
9789
9795
|
/**
|
|
@@ -10506,16 +10512,16 @@ class Polygon {
|
|
|
10506
10512
|
* @public
|
|
10507
10513
|
* @type {Vector2d}
|
|
10508
10514
|
* @name pos
|
|
10509
|
-
* @memberof Polygon
|
|
10515
|
+
* @memberof Polygon.prototype
|
|
10510
10516
|
*/
|
|
10511
|
-
this.pos =
|
|
10517
|
+
this.pos = pool$1.pull("Vector2d");
|
|
10512
10518
|
|
|
10513
10519
|
/**
|
|
10514
10520
|
* The bounding rectangle for this shape
|
|
10515
10521
|
* @ignore
|
|
10516
10522
|
* @type {Bounds}
|
|
10517
10523
|
* @name _bounds
|
|
10518
|
-
* @memberof Polygon
|
|
10524
|
+
* @memberof Polygon.prototype
|
|
10519
10525
|
*/
|
|
10520
10526
|
this._bounds;
|
|
10521
10527
|
|
|
@@ -10525,7 +10531,7 @@ class Polygon {
|
|
|
10525
10531
|
* @public
|
|
10526
10532
|
* @type {Vector2d[]}
|
|
10527
10533
|
* @name points
|
|
10528
|
-
* @memberof Polygon
|
|
10534
|
+
* @memberof Polygon.prototype
|
|
10529
10535
|
*/
|
|
10530
10536
|
this.points = [];
|
|
10531
10537
|
|
|
@@ -10598,13 +10604,13 @@ class Polygon {
|
|
|
10598
10604
|
if (typeof vertices[0] === "object") {
|
|
10599
10605
|
// array of {x,y} object
|
|
10600
10606
|
vertices.forEach((vertice) => {
|
|
10601
|
-
this.points.push(
|
|
10607
|
+
this.points.push(pool$1.pull("Vector2d", vertice.x, vertice.y));
|
|
10602
10608
|
});
|
|
10603
10609
|
|
|
10604
10610
|
} else {
|
|
10605
10611
|
// it's a flat array
|
|
10606
10612
|
for (var p = 0; p < vertices.length; p += 2) {
|
|
10607
|
-
this.points.push(
|
|
10613
|
+
this.points.push(pool$1.pull("Vector2d", vertices[p], vertices[p + 1]));
|
|
10608
10614
|
}
|
|
10609
10615
|
}
|
|
10610
10616
|
} else {
|
|
@@ -10739,12 +10745,12 @@ class Polygon {
|
|
|
10739
10745
|
// Calculate the edges/normals
|
|
10740
10746
|
for (i = 0; i < len; i++) {
|
|
10741
10747
|
if (edges[i] === undefined) {
|
|
10742
|
-
edges[i] =
|
|
10748
|
+
edges[i] = pool$1.pull("Vector2d");
|
|
10743
10749
|
}
|
|
10744
10750
|
edges[i].copy(points[(i + 1) % len]).sub(points[i]);
|
|
10745
10751
|
|
|
10746
10752
|
if (normals[i] === undefined) {
|
|
10747
|
-
normals[i] =
|
|
10753
|
+
normals[i] = pool$1.pull("Vector2d");
|
|
10748
10754
|
}
|
|
10749
10755
|
normals[i].copy(edges[i]).perp().normalize();
|
|
10750
10756
|
}
|
|
@@ -10860,14 +10866,14 @@ class Polygon {
|
|
|
10860
10866
|
/**
|
|
10861
10867
|
* Shifts the Polygon to the given position vector.
|
|
10862
10868
|
* @name shift
|
|
10863
|
-
* @memberof Polygon
|
|
10869
|
+
* @memberof Polygon.prototype
|
|
10864
10870
|
* @function
|
|
10865
10871
|
* @param {Vector2d} position
|
|
10866
10872
|
*/
|
|
10867
10873
|
/**
|
|
10868
10874
|
* Shifts the Polygon to the given x, y position.
|
|
10869
10875
|
* @name shift
|
|
10870
|
-
* @memberof Polygon
|
|
10876
|
+
* @memberof Polygon.prototype
|
|
10871
10877
|
* @function
|
|
10872
10878
|
* @param {number} x
|
|
10873
10879
|
* @param {number} y
|
|
@@ -10948,7 +10954,7 @@ class Polygon {
|
|
|
10948
10954
|
*/
|
|
10949
10955
|
getBounds() {
|
|
10950
10956
|
if (typeof this._bounds === "undefined") {
|
|
10951
|
-
this._bounds = pull("Bounds");
|
|
10957
|
+
this._bounds = pool$1.pull("Bounds");
|
|
10952
10958
|
}
|
|
10953
10959
|
return this._bounds;
|
|
10954
10960
|
}
|
|
@@ -11001,10 +11007,10 @@ class Rect extends Polygon {
|
|
|
11001
11007
|
constructor(x, y, w, h) {
|
|
11002
11008
|
// parent constructor
|
|
11003
11009
|
super(x, y, [
|
|
11004
|
-
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11010
|
+
pool$1.pull("Vector2d", 0, 0), // 0, 0
|
|
11011
|
+
pool$1.pull("Vector2d", w, 0), // 1, 0
|
|
11012
|
+
pool$1.pull("Vector2d", w, h), // 1, 1
|
|
11013
|
+
pool$1.pull("Vector2d", 0, h) // 0, 1
|
|
11008
11014
|
]);
|
|
11009
11015
|
this.shapeType = "Rectangle";
|
|
11010
11016
|
}
|
|
@@ -11048,7 +11054,7 @@ class Rect extends Polygon {
|
|
|
11048
11054
|
* @public
|
|
11049
11055
|
* @type {number}
|
|
11050
11056
|
* @name left
|
|
11051
|
-
* @memberof Rect
|
|
11057
|
+
* @memberof Rect.prototype
|
|
11052
11058
|
*/
|
|
11053
11059
|
get left() {
|
|
11054
11060
|
return this.pos.x;
|
|
@@ -11059,7 +11065,7 @@ class Rect extends Polygon {
|
|
|
11059
11065
|
* @public
|
|
11060
11066
|
* @type {number}
|
|
11061
11067
|
* @name right
|
|
11062
|
-
* @memberof Rect
|
|
11068
|
+
* @memberof Rect.prototype
|
|
11063
11069
|
*/
|
|
11064
11070
|
get right() {
|
|
11065
11071
|
var w = this.width;
|
|
@@ -11071,7 +11077,7 @@ class Rect extends Polygon {
|
|
|
11071
11077
|
* @public
|
|
11072
11078
|
* @type {number}
|
|
11073
11079
|
* @name top
|
|
11074
|
-
* @memberof Rect
|
|
11080
|
+
* @memberof Rect.prototype
|
|
11075
11081
|
*/
|
|
11076
11082
|
get top() {
|
|
11077
11083
|
return this.pos.y;
|
|
@@ -11082,7 +11088,7 @@ class Rect extends Polygon {
|
|
|
11082
11088
|
* @public
|
|
11083
11089
|
* @type {number}
|
|
11084
11090
|
* @name bottom
|
|
11085
|
-
* @memberof Rect
|
|
11091
|
+
* @memberof Rect.prototype
|
|
11086
11092
|
*/
|
|
11087
11093
|
get bottom() {
|
|
11088
11094
|
var h = this.height;
|
|
@@ -11094,7 +11100,7 @@ class Rect extends Polygon {
|
|
|
11094
11100
|
* @public
|
|
11095
11101
|
* @type {number}
|
|
11096
11102
|
* @name width
|
|
11097
|
-
* @memberof Rect
|
|
11103
|
+
* @memberof Rect.prototype
|
|
11098
11104
|
*/
|
|
11099
11105
|
get width() {
|
|
11100
11106
|
return this.points[2].x;
|
|
@@ -11110,7 +11116,7 @@ class Rect extends Polygon {
|
|
|
11110
11116
|
* @public
|
|
11111
11117
|
* @type {number}
|
|
11112
11118
|
* @name height
|
|
11113
|
-
* @memberof Rect
|
|
11119
|
+
* @memberof Rect.prototype
|
|
11114
11120
|
*/
|
|
11115
11121
|
get height() {
|
|
11116
11122
|
return this.points[2].y;
|
|
@@ -11126,7 +11132,7 @@ class Rect extends Polygon {
|
|
|
11126
11132
|
* @public
|
|
11127
11133
|
* @type {number}
|
|
11128
11134
|
* @name centerX
|
|
11129
|
-
* @memberof Rect
|
|
11135
|
+
* @memberof Rect.prototype
|
|
11130
11136
|
*/
|
|
11131
11137
|
get centerX() {
|
|
11132
11138
|
if (isFinite(this.width)) {
|
|
@@ -11144,7 +11150,7 @@ class Rect extends Polygon {
|
|
|
11144
11150
|
* @public
|
|
11145
11151
|
* @type {number}
|
|
11146
11152
|
* @name centerY
|
|
11147
|
-
* @memberof Rect
|
|
11153
|
+
* @memberof Rect.prototype
|
|
11148
11154
|
*/
|
|
11149
11155
|
get centerY() {
|
|
11150
11156
|
if (isFinite(this.height)) {
|
|
@@ -11286,7 +11292,7 @@ class Rect extends Polygon {
|
|
|
11286
11292
|
/**
|
|
11287
11293
|
* Returns true if the rectangle contains the given point
|
|
11288
11294
|
* @name contains
|
|
11289
|
-
* @memberof Rect
|
|
11295
|
+
* @memberof Rect.prototype
|
|
11290
11296
|
* @function
|
|
11291
11297
|
* @param {Vector2d} point
|
|
11292
11298
|
* @returns {boolean} true if contains
|
|
@@ -11355,7 +11361,7 @@ class Rect extends Polygon {
|
|
|
11355
11361
|
* @returns {Polygon} a new Polygon that represents this rectangle.
|
|
11356
11362
|
*/
|
|
11357
11363
|
toPolygon() {
|
|
11358
|
-
return
|
|
11364
|
+
return pool$1.pull("Polygon",
|
|
11359
11365
|
this.pos.x, this.pos.y, this.points
|
|
11360
11366
|
);
|
|
11361
11367
|
}
|
|
@@ -11829,6 +11835,8 @@ class Bounds$1 {
|
|
|
11829
11835
|
* @param {Vector2d[]} [vertices] an array of me.Vector2d points
|
|
11830
11836
|
*/
|
|
11831
11837
|
constructor(vertices) {
|
|
11838
|
+
// @ignore
|
|
11839
|
+
this._center = new Vector2d();
|
|
11832
11840
|
this.onResetEvent(vertices);
|
|
11833
11841
|
}
|
|
11834
11842
|
|
|
@@ -11845,9 +11853,6 @@ class Bounds$1 {
|
|
|
11845
11853
|
if (typeof vertices !== "undefined") {
|
|
11846
11854
|
this.update(vertices);
|
|
11847
11855
|
}
|
|
11848
|
-
|
|
11849
|
-
// @ignore
|
|
11850
|
-
this._center = new Vector2d();
|
|
11851
11856
|
}
|
|
11852
11857
|
|
|
11853
11858
|
/**
|
|
@@ -12269,11 +12274,11 @@ class Bounds$1 {
|
|
|
12269
12274
|
* @returns {Polygon} a new Polygon that represents this bounds.
|
|
12270
12275
|
*/
|
|
12271
12276
|
toPolygon () {
|
|
12272
|
-
return
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
+
return pool$1.pull("Polygon", this.x, this.y, [
|
|
12278
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
12279
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
12280
|
+
pool$1.pull("Vector2d", this.width, this.height),
|
|
12281
|
+
pool$1.pull("Vector2d", 0, this.height)
|
|
12277
12282
|
]);
|
|
12278
12283
|
}
|
|
12279
12284
|
|
|
@@ -12969,11 +12974,11 @@ function dispatchEvent(normalizedEvents) {
|
|
|
12969
12974
|
if (typeof region.currentTransform !== "undefined") {
|
|
12970
12975
|
if (!region.currentTransform.isIdentity()) {
|
|
12971
12976
|
var invV = region.currentTransform.applyInverse(
|
|
12972
|
-
pull("Vector2d", gameX, gameY)
|
|
12977
|
+
pool$1.pull("Vector2d", gameX, gameY)
|
|
12973
12978
|
);
|
|
12974
12979
|
gameX = invV.x;
|
|
12975
12980
|
gameY = invV.y;
|
|
12976
|
-
push(invV);
|
|
12981
|
+
pool$1.push(invV);
|
|
12977
12982
|
}
|
|
12978
12983
|
}
|
|
12979
12984
|
eventInBounds = bounds.contains(gameX, gameY);
|
|
@@ -13202,7 +13207,7 @@ var throttlingInterval;
|
|
|
13202
13207
|
* };
|
|
13203
13208
|
*/
|
|
13204
13209
|
function globalToLocal(x, y, v) {
|
|
13205
|
-
v = v || pull("Vector2d");
|
|
13210
|
+
v = v || pool$1.pull("Vector2d");
|
|
13206
13211
|
var rect = device$1.getElementBounds(renderer.getScreenCanvas());
|
|
13207
13212
|
var pixelRatio = device$1.devicePixelRatio;
|
|
13208
13213
|
x -= rect.left + (globalThis.pageXOffset || 0);
|
|
@@ -13510,8 +13515,8 @@ var leadingZeroRE = /^0+/;
|
|
|
13510
13515
|
function addMapping(id, mapping) {
|
|
13511
13516
|
var expanded_id = id.replace(vendorProductRE, function (_, a, b) {
|
|
13512
13517
|
return (
|
|
13513
|
-
"000".
|
|
13514
|
-
"000".
|
|
13518
|
+
"000".slice(a.length - 1) + a + "-" +
|
|
13519
|
+
"000".slice(b.length - 1) + b + "-"
|
|
13515
13520
|
);
|
|
13516
13521
|
});
|
|
13517
13522
|
var sparse_id = id.replace(vendorProductRE, function (_, a, b) {
|
|
@@ -14082,7 +14087,7 @@ class Renderable extends Rect {
|
|
|
14082
14087
|
* @name currentTransform
|
|
14083
14088
|
* @memberof Renderable#
|
|
14084
14089
|
*/
|
|
14085
|
-
this.currentTransform = pull("Matrix2d");
|
|
14090
|
+
this.currentTransform = pool$1.pull("Matrix2d");
|
|
14086
14091
|
}
|
|
14087
14092
|
this.currentTransform.identity();
|
|
14088
14093
|
|
|
@@ -14171,7 +14176,7 @@ class Renderable extends Rect {
|
|
|
14171
14176
|
* @name anchorPoint
|
|
14172
14177
|
* @memberof Renderable#
|
|
14173
14178
|
*/
|
|
14174
|
-
this.anchorPoint = pull("ObservableVector2d", 0.5, 0.5, { onUpdate: this.onAnchorUpdate, scope: this });
|
|
14179
|
+
this.anchorPoint = pool$1.pull("ObservableVector2d", 0.5, 0.5, { onUpdate: this.onAnchorUpdate, scope: this });
|
|
14175
14180
|
}
|
|
14176
14181
|
|
|
14177
14182
|
/**
|
|
@@ -14221,7 +14226,7 @@ class Renderable extends Rect {
|
|
|
14221
14226
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
14222
14227
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
14223
14228
|
* @public
|
|
14224
|
-
* @type {Rect|Polygon|Line|Ellipse}
|
|
14229
|
+
* @type {Rect|RoundRect|Polygon|Line|Ellipse}
|
|
14225
14230
|
* @name mask
|
|
14226
14231
|
* @default undefined
|
|
14227
14232
|
* @memberof Renderable#
|
|
@@ -14256,7 +14261,7 @@ class Renderable extends Rect {
|
|
|
14256
14261
|
* // remove the tint
|
|
14257
14262
|
* this.tint.setColor(255, 255, 255);
|
|
14258
14263
|
*/
|
|
14259
|
-
this.tint = pull("Color", 255, 255, 255, 1.0);
|
|
14264
|
+
this.tint = pool$1.pull("Color", 255, 255, 255, 1.0);
|
|
14260
14265
|
|
|
14261
14266
|
/**
|
|
14262
14267
|
* the blend mode to be applied to this renderable (see renderer setBlendMode for available blend mode)
|
|
@@ -14290,7 +14295,7 @@ class Renderable extends Rect {
|
|
|
14290
14295
|
* @name pos
|
|
14291
14296
|
* @memberof Renderable#
|
|
14292
14297
|
*/
|
|
14293
|
-
this.pos = pull("ObservableVector3d", x, y, 0, { onUpdate: this.updateBoundsPos, scope: this});
|
|
14298
|
+
this.pos = pool$1.pull("ObservableVector3d", x, y, 0, { onUpdate: this.updateBoundsPos, scope: this});
|
|
14294
14299
|
}
|
|
14295
14300
|
|
|
14296
14301
|
/**
|
|
@@ -14661,7 +14666,7 @@ class Renderable extends Rect {
|
|
|
14661
14666
|
*/
|
|
14662
14667
|
getAbsolutePosition() {
|
|
14663
14668
|
if (typeof this._absPos === "undefined") {
|
|
14664
|
-
this._absPos = pull("Vector2d");
|
|
14669
|
+
this._absPos = pool$1.pull("Vector2d");
|
|
14665
14670
|
}
|
|
14666
14671
|
// XXX Cache me or something
|
|
14667
14672
|
this._absPos.set(this.pos.x, this.pos.y);
|
|
@@ -14816,32 +14821,32 @@ class Renderable extends Rect {
|
|
|
14816
14821
|
*/
|
|
14817
14822
|
destroy() {
|
|
14818
14823
|
// allow recycling object properties
|
|
14819
|
-
push(this.currentTransform);
|
|
14824
|
+
pool$1.push(this.currentTransform);
|
|
14820
14825
|
this.currentTransform = undefined;
|
|
14821
14826
|
|
|
14822
|
-
push(this.anchorPoint);
|
|
14827
|
+
pool$1.push(this.anchorPoint);
|
|
14823
14828
|
this.anchorPoint = undefined;
|
|
14824
14829
|
|
|
14825
|
-
push(this.pos);
|
|
14830
|
+
pool$1.push(this.pos);
|
|
14826
14831
|
this.pos = undefined;
|
|
14827
14832
|
|
|
14828
14833
|
if (typeof this._absPos !== "undefined") {
|
|
14829
|
-
push(this._absPos);
|
|
14834
|
+
pool$1.push(this._absPos);
|
|
14830
14835
|
this._absPos = undefined;
|
|
14831
14836
|
}
|
|
14832
14837
|
|
|
14833
|
-
push(this._bounds);
|
|
14838
|
+
pool$1.push(this._bounds);
|
|
14834
14839
|
this._bounds = undefined;
|
|
14835
14840
|
|
|
14836
14841
|
this.onVisibilityChange = undefined;
|
|
14837
14842
|
|
|
14838
14843
|
if (typeof this.mask !== "undefined") {
|
|
14839
|
-
push(this.mask);
|
|
14844
|
+
pool$1.push(this.mask);
|
|
14840
14845
|
this.mask = undefined;
|
|
14841
14846
|
}
|
|
14842
14847
|
|
|
14843
14848
|
if (typeof this.tint !== "undefined") {
|
|
14844
|
-
push(this.tint);
|
|
14849
|
+
pool$1.push(this.tint);
|
|
14845
14850
|
this.tint = undefined;
|
|
14846
14851
|
}
|
|
14847
14852
|
|
|
@@ -14890,9 +14895,9 @@ class Ellipse {
|
|
|
14890
14895
|
* @public
|
|
14891
14896
|
* @type {Vector2d}
|
|
14892
14897
|
* @name pos
|
|
14893
|
-
* @memberof Ellipse
|
|
14898
|
+
* @memberof Ellipse.prototype
|
|
14894
14899
|
*/
|
|
14895
|
-
this.pos =
|
|
14900
|
+
this.pos = pool$1.pull("Vector2d");
|
|
14896
14901
|
|
|
14897
14902
|
/**
|
|
14898
14903
|
* The bounding rectangle for this shape
|
|
@@ -14905,7 +14910,7 @@ class Ellipse {
|
|
|
14905
14910
|
* @public
|
|
14906
14911
|
* @type {number}
|
|
14907
14912
|
* @name radius
|
|
14908
|
-
* @memberof Ellipse
|
|
14913
|
+
* @memberof Ellipse.prototype
|
|
14909
14914
|
*/
|
|
14910
14915
|
this.radius = NaN;
|
|
14911
14916
|
|
|
@@ -14914,27 +14919,27 @@ class Ellipse {
|
|
|
14914
14919
|
* @public
|
|
14915
14920
|
* @type {Vector2d}
|
|
14916
14921
|
* @name radiusV
|
|
14917
|
-
* @memberof Ellipse
|
|
14922
|
+
* @memberof Ellipse.prototype
|
|
14918
14923
|
*/
|
|
14919
|
-
this.radiusV =
|
|
14924
|
+
this.radiusV = pool$1.pull("Vector2d");
|
|
14920
14925
|
|
|
14921
14926
|
/**
|
|
14922
14927
|
* Radius squared, for pythagorean theorom
|
|
14923
14928
|
* @public
|
|
14924
14929
|
* @type {Vector2d}
|
|
14925
14930
|
* @name radiusSq
|
|
14926
|
-
* @memberof Ellipse
|
|
14931
|
+
* @memberof Ellipse.prototype
|
|
14927
14932
|
*/
|
|
14928
|
-
this.radiusSq =
|
|
14933
|
+
this.radiusSq = pool$1.pull("Vector2d");
|
|
14929
14934
|
|
|
14930
14935
|
/**
|
|
14931
14936
|
* x/y scaling ratio for ellipse
|
|
14932
14937
|
* @public
|
|
14933
14938
|
* @type {Vector2d}
|
|
14934
14939
|
* @name ratio
|
|
14935
|
-
* @memberof Ellipse
|
|
14940
|
+
* @memberof Ellipse.prototype
|
|
14936
14941
|
*/
|
|
14937
|
-
this.ratio =
|
|
14942
|
+
this.ratio = pool$1.pull("Vector2d");
|
|
14938
14943
|
|
|
14939
14944
|
// the shape type
|
|
14940
14945
|
this.shapeType = "Ellipse";
|
|
@@ -15124,7 +15129,7 @@ class Ellipse {
|
|
|
15124
15129
|
*/
|
|
15125
15130
|
getBounds() {
|
|
15126
15131
|
if (typeof this._bounds === "undefined") {
|
|
15127
|
-
this._bounds = pull("Bounds");
|
|
15132
|
+
this._bounds = pool$1.pull("Bounds");
|
|
15128
15133
|
}
|
|
15129
15134
|
return this._bounds;
|
|
15130
15135
|
}
|
|
@@ -16016,7 +16021,7 @@ class Body {
|
|
|
16016
16021
|
* @public
|
|
16017
16022
|
* @type {Bounds}
|
|
16018
16023
|
*/
|
|
16019
|
-
this.bounds =
|
|
16024
|
+
this.bounds = pool$1.pull("Bounds");
|
|
16020
16025
|
}
|
|
16021
16026
|
|
|
16022
16027
|
if (typeof this.shapes === "undefined") {
|
|
@@ -16050,55 +16055,54 @@ class Body {
|
|
|
16050
16055
|
*/
|
|
16051
16056
|
this.collisionType = collision.types.ENEMY_OBJECT;
|
|
16052
16057
|
|
|
16053
|
-
/**
|
|
16054
|
-
* body velocity
|
|
16055
|
-
* @public
|
|
16056
|
-
* @type {Vector2d}
|
|
16057
|
-
* @default <0,0>
|
|
16058
|
-
*/
|
|
16059
16058
|
if (typeof this.vel === "undefined") {
|
|
16060
|
-
|
|
16059
|
+
/**
|
|
16060
|
+
* body velocity
|
|
16061
|
+
* @public
|
|
16062
|
+
* @type {Vector2d}
|
|
16063
|
+
* @default <0,0>
|
|
16064
|
+
*/
|
|
16065
|
+
this.vel = pool$1.pull("Vector2d");
|
|
16061
16066
|
}
|
|
16062
16067
|
this.vel.set(0, 0);
|
|
16063
16068
|
|
|
16064
|
-
/**
|
|
16065
|
-
* body force or acceleration (automatically) applied to the body.
|
|
16066
|
-
* when defining a force, user should also define a max velocity
|
|
16067
|
-
* @public
|
|
16068
|
-
* @type {Vector2d}
|
|
16069
|
-
* @default <0,0>
|
|
16070
|
-
* @see Body.setMaxVelocity
|
|
16071
|
-
* @example
|
|
16072
|
-
* // define a default maximum acceleration, initial force and friction
|
|
16073
|
-
* this.body.force.set(0, 0);
|
|
16074
|
-
* this.body.friction.set(0.4, 0);
|
|
16075
|
-
* this.body.setMaxVelocity(3, 15);
|
|
16076
|
-
*
|
|
16077
|
-
* // apply a postive or negative force when pressing left of right key
|
|
16078
|
-
* update(dt) {
|
|
16079
|
-
* if (me.input.isKeyPressed("left")) {
|
|
16080
|
-
* this.body.force.x = -this.body.maxVel.x;
|
|
16081
|
-
* } else if (me.input.isKeyPressed("right")) {
|
|
16082
|
-
* this.body.force.x = this.body.maxVel.x;
|
|
16083
|
-
* } else {
|
|
16084
|
-
* this.body.force.x = 0;
|
|
16085
|
-
* }
|
|
16086
|
-
* }
|
|
16087
|
-
*/
|
|
16088
16069
|
if (typeof this.force === "undefined") {
|
|
16089
|
-
|
|
16070
|
+
/**
|
|
16071
|
+
* body force or acceleration (automatically) applied to the body.
|
|
16072
|
+
* when defining a force, user should also define a max velocity
|
|
16073
|
+
* @public
|
|
16074
|
+
* @type {Vector2d}
|
|
16075
|
+
* @default <0,0>
|
|
16076
|
+
* @see Body.setMaxVelocity
|
|
16077
|
+
* @example
|
|
16078
|
+
* // define a default maximum acceleration, initial force and friction
|
|
16079
|
+
* this.body.force.set(0, 0);
|
|
16080
|
+
* this.body.friction.set(0.4, 0);
|
|
16081
|
+
* this.body.setMaxVelocity(3, 15);
|
|
16082
|
+
*
|
|
16083
|
+
* // apply a postive or negative force when pressing left of right key
|
|
16084
|
+
* update(dt) {
|
|
16085
|
+
* if (me.input.isKeyPressed("left")) {
|
|
16086
|
+
* this.body.force.x = -this.body.maxVel.x;
|
|
16087
|
+
* } else if (me.input.isKeyPressed("right")) {
|
|
16088
|
+
* this.body.force.x = this.body.maxVel.x;
|
|
16089
|
+
* } else {
|
|
16090
|
+
* this.body.force.x = 0;
|
|
16091
|
+
* }
|
|
16092
|
+
* }
|
|
16093
|
+
*/
|
|
16094
|
+
this.force = pool$1.pull("Vector2d");
|
|
16090
16095
|
}
|
|
16091
16096
|
this.force.set(0, 0);
|
|
16092
16097
|
|
|
16093
|
-
|
|
16094
|
-
/**
|
|
16095
|
-
* body friction
|
|
16096
|
-
* @public
|
|
16097
|
-
* @type {Vector2d}
|
|
16098
|
-
* @default <0,0>
|
|
16099
|
-
*/
|
|
16100
16098
|
if (typeof this.friction === "undefined") {
|
|
16101
|
-
|
|
16099
|
+
/**
|
|
16100
|
+
* body friction
|
|
16101
|
+
* @public
|
|
16102
|
+
* @type {Vector2d}
|
|
16103
|
+
* @default <0,0>
|
|
16104
|
+
*/
|
|
16105
|
+
this.friction = pool$1.pull("Vector2d");
|
|
16102
16106
|
}
|
|
16103
16107
|
this.friction.set(0, 0);
|
|
16104
16108
|
|
|
@@ -16119,14 +16123,14 @@ class Body {
|
|
|
16119
16123
|
*/
|
|
16120
16124
|
this.mass = 1;
|
|
16121
16125
|
|
|
16122
|
-
/**
|
|
16123
|
-
* max velocity (to limit body velocity)
|
|
16124
|
-
* @public
|
|
16125
|
-
* @type {Vector2d}
|
|
16126
|
-
* @default <490,490>
|
|
16127
|
-
*/
|
|
16128
16126
|
if (typeof this.maxVel === "undefined") {
|
|
16129
|
-
|
|
16127
|
+
/**
|
|
16128
|
+
* max velocity (to limit body velocity)
|
|
16129
|
+
* @public
|
|
16130
|
+
* @type {Vector2d}
|
|
16131
|
+
* @default <490,490>
|
|
16132
|
+
*/
|
|
16133
|
+
this.maxVel = pool$1.pull("Vector2d");
|
|
16130
16134
|
}
|
|
16131
16135
|
// cap by default to half the default gravity force
|
|
16132
16136
|
this.maxVel.set(490, 490);
|
|
@@ -16276,7 +16280,7 @@ class Body {
|
|
|
16276
16280
|
polygon.setShape(0, 0, vertices);
|
|
16277
16281
|
} else {
|
|
16278
16282
|
// this will replace any other non polygon shape type if defined
|
|
16279
|
-
this.shapes[index] =
|
|
16283
|
+
this.shapes[index] = pool$1.pull("Polygon", 0, 0, vertices);
|
|
16280
16284
|
}
|
|
16281
16285
|
|
|
16282
16286
|
// update the body bounds to take in account the new vertices
|
|
@@ -16664,11 +16668,28 @@ class Body {
|
|
|
16664
16668
|
* @ignore
|
|
16665
16669
|
*/
|
|
16666
16670
|
destroy() {
|
|
16671
|
+
// push back instance into object pool
|
|
16672
|
+
pool$1.push(this.bounds);
|
|
16673
|
+
pool$1.push(this.vel);
|
|
16674
|
+
pool$1.push(this.force);
|
|
16675
|
+
pool$1.push(this.friction);
|
|
16676
|
+
pool$1.push(this.maxVel);
|
|
16677
|
+
this.shapes.forEach((shape) => {
|
|
16678
|
+
pool$1.push(shape);
|
|
16679
|
+
});
|
|
16680
|
+
|
|
16681
|
+
// set to undefined
|
|
16667
16682
|
this.onBodyUpdate = undefined;
|
|
16668
16683
|
this.ancestor = undefined;
|
|
16669
16684
|
this.bounds = undefined;
|
|
16670
|
-
this.
|
|
16685
|
+
this.vel = undefined;
|
|
16686
|
+
this.force = undefined;
|
|
16687
|
+
this.friction = undefined;
|
|
16688
|
+
this.maxVel = undefined;
|
|
16671
16689
|
this.shapes.length = 0;
|
|
16690
|
+
|
|
16691
|
+
// reset some variable to default
|
|
16692
|
+
this.setStatic(false);
|
|
16672
16693
|
}
|
|
16673
16694
|
}
|
|
16674
16695
|
|
|
@@ -16796,7 +16817,7 @@ class Container extends Renderable {
|
|
|
16796
16817
|
* // add a red background color to this container
|
|
16797
16818
|
* this.backgroundColor.setColor(255, 0, 0);
|
|
16798
16819
|
*/
|
|
16799
|
-
this.backgroundColor = pull("Color", 0, 0, 0, 0.0);
|
|
16820
|
+
this.backgroundColor = pool$1.pull("Color", 0, 0, 0, 0.0);
|
|
16800
16821
|
|
|
16801
16822
|
/**
|
|
16802
16823
|
* Used by the debug panel plugin
|
|
@@ -17354,7 +17375,7 @@ class Container extends Renderable {
|
|
|
17354
17375
|
|
|
17355
17376
|
if (!keepalive) {
|
|
17356
17377
|
// attempt at recycling the object
|
|
17357
|
-
if (push(child, false) === false ) {
|
|
17378
|
+
if (pool$1.push(child, false) === false ) {
|
|
17358
17379
|
// else just destroy it
|
|
17359
17380
|
if (typeof child.destroy === "function") {
|
|
17360
17381
|
child.destroy();
|
|
@@ -18115,7 +18136,7 @@ class World extends Container {
|
|
|
18115
18136
|
* @name bodies
|
|
18116
18137
|
* @memberof World
|
|
18117
18138
|
* @public
|
|
18118
|
-
* @type {Set}
|
|
18139
|
+
* @type {Set<Body>}
|
|
18119
18140
|
*/
|
|
18120
18141
|
this.bodies = new Set();
|
|
18121
18142
|
|
|
@@ -18523,7 +18544,7 @@ class Camera2d extends Renderable {
|
|
|
18523
18544
|
* @name bounds
|
|
18524
18545
|
* @memberof Camera2d
|
|
18525
18546
|
*/
|
|
18526
|
-
this.bounds = pull("Bounds");
|
|
18547
|
+
this.bounds = pool$1.pull("Bounds");
|
|
18527
18548
|
|
|
18528
18549
|
/**
|
|
18529
18550
|
* enable or disable damping
|
|
@@ -19011,8 +19032,8 @@ class Camera2d extends Renderable {
|
|
|
19011
19032
|
* });
|
|
19012
19033
|
*/
|
|
19013
19034
|
fadeOut(color, duration = 1000, onComplete) {
|
|
19014
|
-
this._fadeOut.color = pull("Color").copy(color);
|
|
19015
|
-
this._fadeOut.tween = pull("Tween", this._fadeOut.color)
|
|
19035
|
+
this._fadeOut.color = pool$1.pull("Color").copy(color);
|
|
19036
|
+
this._fadeOut.tween = pool$1.pull("Tween", this._fadeOut.color)
|
|
19016
19037
|
.to({ alpha: 0.0 }, duration)
|
|
19017
19038
|
.onComplete(onComplete || null);
|
|
19018
19039
|
this._fadeOut.tween.isPersistent = true;
|
|
@@ -19033,10 +19054,10 @@ class Camera2d extends Renderable {
|
|
|
19033
19054
|
* me.game.viewport.fadeIn("#FFFFFF", 75);
|
|
19034
19055
|
*/
|
|
19035
19056
|
fadeIn(color, duration = 1000, onComplete) {
|
|
19036
|
-
this._fadeIn.color = pull("Color").copy(color);
|
|
19057
|
+
this._fadeIn.color = pool$1.pull("Color").copy(color);
|
|
19037
19058
|
var _alpha = this._fadeIn.color.alpha;
|
|
19038
19059
|
this._fadeIn.color.alpha = 0.0;
|
|
19039
|
-
this._fadeIn.tween = pull("Tween", this._fadeIn.color)
|
|
19060
|
+
this._fadeIn.tween = pool$1.pull("Tween", this._fadeIn.color)
|
|
19040
19061
|
.to({ alpha: _alpha }, duration)
|
|
19041
19062
|
.onComplete(onComplete || null);
|
|
19042
19063
|
this._fadeIn.tween.isPersistent = true;
|
|
@@ -19090,7 +19111,7 @@ class Camera2d extends Renderable {
|
|
|
19090
19111
|
*/
|
|
19091
19112
|
localToWorld(x, y, v) {
|
|
19092
19113
|
// TODO memoization for one set of coords (multitouch)
|
|
19093
|
-
v = v || pull("Vector2d");
|
|
19114
|
+
v = v || pool$1.pull("Vector2d");
|
|
19094
19115
|
v.set(x, y).add(this.pos).sub(world.pos);
|
|
19095
19116
|
if (!this.currentTransform.isIdentity()) {
|
|
19096
19117
|
this.invCurrentTransform.apply(v);
|
|
@@ -19111,7 +19132,7 @@ class Camera2d extends Renderable {
|
|
|
19111
19132
|
*/
|
|
19112
19133
|
worldToLocal(x, y, v) {
|
|
19113
19134
|
// TODO memoization for one set of coords (multitouch)
|
|
19114
|
-
v = v || pull("Vector2d");
|
|
19135
|
+
v = v || pool$1.pull("Vector2d");
|
|
19115
19136
|
v.set(x, y);
|
|
19116
19137
|
if (!this.currentTransform.isIdentity()) {
|
|
19117
19138
|
this.currentTransform.apply(v);
|
|
@@ -19136,7 +19157,7 @@ class Camera2d extends Renderable {
|
|
|
19136
19157
|
// remove the tween if over
|
|
19137
19158
|
if (this._fadeIn.color.alpha === 1.0) {
|
|
19138
19159
|
this._fadeIn.tween = null;
|
|
19139
|
-
push(this._fadeIn.color);
|
|
19160
|
+
pool$1.push(this._fadeIn.color);
|
|
19140
19161
|
this._fadeIn.color = null;
|
|
19141
19162
|
}
|
|
19142
19163
|
}
|
|
@@ -19153,7 +19174,7 @@ class Camera2d extends Renderable {
|
|
|
19153
19174
|
// remove the tween if over
|
|
19154
19175
|
if (this._fadeOut.color.alpha === 0.0) {
|
|
19155
19176
|
this._fadeOut.tween = null;
|
|
19156
|
-
push(this._fadeOut.color);
|
|
19177
|
+
pool$1.push(this._fadeOut.color);
|
|
19157
19178
|
this._fadeOut.color = null;
|
|
19158
19179
|
}
|
|
19159
19180
|
}
|
|
@@ -19231,7 +19252,7 @@ class Stage {
|
|
|
19231
19252
|
* Cameras will be renderered based on this order defined in this list.
|
|
19232
19253
|
* Only the "default" camera will be resized when the window or canvas is resized.
|
|
19233
19254
|
* @public
|
|
19234
|
-
* @type {Map}
|
|
19255
|
+
* @type {Map<Camera2d>}
|
|
19235
19256
|
* @name cameras
|
|
19236
19257
|
* @memberof Stage
|
|
19237
19258
|
*/
|
|
@@ -19495,7 +19516,7 @@ class DefaultLoadingScreen extends Stage {
|
|
|
19495
19516
|
|
|
19496
19517
|
), 2);
|
|
19497
19518
|
|
|
19498
|
-
var logo1 = pull("Text",
|
|
19519
|
+
var logo1 = pool$1.pull("Text",
|
|
19499
19520
|
renderer.getWidth() / 2,
|
|
19500
19521
|
(renderer.getHeight() / 2) + 16, {
|
|
19501
19522
|
font: "century gothic",
|
|
@@ -19509,7 +19530,7 @@ class DefaultLoadingScreen extends Stage {
|
|
|
19509
19530
|
);
|
|
19510
19531
|
logo1.anchorPoint.set(0, 0);
|
|
19511
19532
|
|
|
19512
|
-
var logo2 = pull("Text",
|
|
19533
|
+
var logo2 = pool$1.pull("Text",
|
|
19513
19534
|
renderer.getWidth() / 2,
|
|
19514
19535
|
(renderer.getHeight() / 2) + 16, {
|
|
19515
19536
|
font: "century gothic",
|
|
@@ -20040,7 +20061,7 @@ var state = {
|
|
|
20040
20061
|
// if fading effect
|
|
20041
20062
|
if (_fade.duration && _stages[state].transition) {
|
|
20042
20063
|
/** @ignore */
|
|
20043
|
-
_onSwitchComplete =
|
|
20064
|
+
_onSwitchComplete = () => {
|
|
20044
20065
|
viewport.fadeOut(_fade.color, _fade.duration);
|
|
20045
20066
|
};
|
|
20046
20067
|
viewport.fadeIn(
|
|
@@ -21222,7 +21243,7 @@ class TextureAtlas {
|
|
|
21222
21243
|
var height = image.height;
|
|
21223
21244
|
|
|
21224
21245
|
// calculate the sprite count (line, col)
|
|
21225
|
-
var spritecount = pull("Vector2d",
|
|
21246
|
+
var spritecount = pool$1.pull("Vector2d",
|
|
21226
21247
|
~~((width - margin + spacing) / (data.framewidth + spacing)),
|
|
21227
21248
|
~~((height - margin + spacing) / (data.frameheight + spacing))
|
|
21228
21249
|
);
|
|
@@ -21265,7 +21286,7 @@ class TextureAtlas {
|
|
|
21265
21286
|
this.addUVs(atlas, name, width, height);
|
|
21266
21287
|
}
|
|
21267
21288
|
|
|
21268
|
-
push(spritecount);
|
|
21289
|
+
pool$1.push(spritecount);
|
|
21269
21290
|
|
|
21270
21291
|
return atlas;
|
|
21271
21292
|
}
|
|
@@ -21438,7 +21459,7 @@ class TextureAtlas {
|
|
|
21438
21459
|
*/
|
|
21439
21460
|
createSpriteFromName(name, settings, nineSlice = false) {
|
|
21440
21461
|
// instantiate a new sprite object
|
|
21441
|
-
return pull(
|
|
21462
|
+
return pool$1.pull(
|
|
21442
21463
|
nineSlice === true ? "me.NineSliceSprite" : "me.Sprite",
|
|
21443
21464
|
0, 0,
|
|
21444
21465
|
Object.assign({
|
|
@@ -21579,7 +21600,7 @@ class Sprite extends Renderable {
|
|
|
21579
21600
|
* @name offset
|
|
21580
21601
|
* @memberof Sprite#
|
|
21581
21602
|
*/
|
|
21582
|
-
this.offset = pull("Vector2d", 0, 0);
|
|
21603
|
+
this.offset = pool$1.pull("Vector2d", 0, 0);
|
|
21583
21604
|
|
|
21584
21605
|
/**
|
|
21585
21606
|
* The source texture object this sprite object is using
|
|
@@ -21604,7 +21625,7 @@ class Sprite extends Renderable {
|
|
|
21604
21625
|
// length of the current animation name
|
|
21605
21626
|
length : 0,
|
|
21606
21627
|
//current frame texture offset
|
|
21607
|
-
offset :
|
|
21628
|
+
offset : pool$1.pull("Vector2d"),
|
|
21608
21629
|
// current frame size
|
|
21609
21630
|
width : 0,
|
|
21610
21631
|
height : 0,
|
|
@@ -22096,7 +22117,7 @@ class Sprite extends Renderable {
|
|
|
22096
22117
|
* @ignore
|
|
22097
22118
|
*/
|
|
22098
22119
|
destroy() {
|
|
22099
|
-
push(this.offset);
|
|
22120
|
+
pool$1.push(this.offset);
|
|
22100
22121
|
this.offset = undefined;
|
|
22101
22122
|
super.destroy();
|
|
22102
22123
|
}
|
|
@@ -22336,6 +22357,167 @@ class Tile extends Bounds$1 {
|
|
|
22336
22357
|
}
|
|
22337
22358
|
}
|
|
22338
22359
|
|
|
22360
|
+
// https://developer.chrome.com/blog/canvas2d/#round-rect
|
|
22361
|
+
|
|
22362
|
+
/**
|
|
22363
|
+
* @classdesc
|
|
22364
|
+
* a rectangle object with rounded corners
|
|
22365
|
+
* @augments Rect
|
|
22366
|
+
*/
|
|
22367
|
+
class RoundRect extends Rect {
|
|
22368
|
+
/**
|
|
22369
|
+
* @param {number} x position of the rounded rectangle
|
|
22370
|
+
* @param {number} y position of the rounded rectangle
|
|
22371
|
+
* @param {number} width the rectangle width
|
|
22372
|
+
* @param {number} height the rectangle height
|
|
22373
|
+
* @param {number} [radius=20] the radius of the rounded corner
|
|
22374
|
+
*/
|
|
22375
|
+
constructor(x, y, width, height, radius = 20) {
|
|
22376
|
+
// parent constructor
|
|
22377
|
+
super(x, y, width, height);
|
|
22378
|
+
|
|
22379
|
+
// set the corner radius
|
|
22380
|
+
this.radius = radius;
|
|
22381
|
+
}
|
|
22382
|
+
|
|
22383
|
+
/** @ignore */
|
|
22384
|
+
onResetEvent(x, y, w, h, radius) {
|
|
22385
|
+
super.setShape(x, y, w, h);
|
|
22386
|
+
this.radius = radius;
|
|
22387
|
+
}
|
|
22388
|
+
|
|
22389
|
+
|
|
22390
|
+
/**
|
|
22391
|
+
* the radius of the rounded corner
|
|
22392
|
+
* @public
|
|
22393
|
+
* @type {number}
|
|
22394
|
+
* @default 20
|
|
22395
|
+
* @name radius
|
|
22396
|
+
* @memberof RoundRect.prototype
|
|
22397
|
+
*/
|
|
22398
|
+
get radius() {
|
|
22399
|
+
return this._radius;
|
|
22400
|
+
}
|
|
22401
|
+
set radius(value) {
|
|
22402
|
+
// verify the rectangle is at least as wide and tall as the rounded corners.
|
|
22403
|
+
if (this.width < 2 * value) {
|
|
22404
|
+
value = this.width / 2;
|
|
22405
|
+
}
|
|
22406
|
+
if (this.height < 2 * value) {
|
|
22407
|
+
value = this.height / 2;
|
|
22408
|
+
}
|
|
22409
|
+
this._radius = value;
|
|
22410
|
+
}
|
|
22411
|
+
|
|
22412
|
+
/**
|
|
22413
|
+
* copy the position, size and radius of the given rounded rectangle into this one
|
|
22414
|
+
* @name copy
|
|
22415
|
+
* @memberof RoundRect.prototype
|
|
22416
|
+
* @function
|
|
22417
|
+
* @param {RoundRect} rrect source rounded rectangle
|
|
22418
|
+
* @returns {RoundRect} new rectangle
|
|
22419
|
+
*/
|
|
22420
|
+
copy(rrect) {
|
|
22421
|
+
super.setShape(rrect.pos.x, rrect.pos.y, rrect.width, rrect.height);
|
|
22422
|
+
this.radius = rrect.radius;
|
|
22423
|
+
return this;
|
|
22424
|
+
}
|
|
22425
|
+
|
|
22426
|
+
/**
|
|
22427
|
+
* Returns true if the rounded rectangle contains the given point
|
|
22428
|
+
* @name contains
|
|
22429
|
+
* @memberof RoundRect.prototype
|
|
22430
|
+
* @function
|
|
22431
|
+
* @param {number} x x coordinate
|
|
22432
|
+
* @param {number} y y coordinate
|
|
22433
|
+
* @returns {boolean} true if contains
|
|
22434
|
+
*/
|
|
22435
|
+
|
|
22436
|
+
/**
|
|
22437
|
+
* Returns true if the rounded rectangle contains the given point
|
|
22438
|
+
* @name contains
|
|
22439
|
+
* @memberof RoundRect.prototype
|
|
22440
|
+
* @function
|
|
22441
|
+
* @param {Vector2d} point
|
|
22442
|
+
* @returns {boolean} true if contains
|
|
22443
|
+
*/
|
|
22444
|
+
contains() {
|
|
22445
|
+
var arg0 = arguments[0];
|
|
22446
|
+
var _x, _y;
|
|
22447
|
+
if (arguments.length === 2) {
|
|
22448
|
+
// x, y
|
|
22449
|
+
_x = arg0;
|
|
22450
|
+
_y = arguments[1];
|
|
22451
|
+
} else {
|
|
22452
|
+
if (arg0 instanceof Rect) {
|
|
22453
|
+
// good enough
|
|
22454
|
+
return super.contains(arg0);
|
|
22455
|
+
} else {
|
|
22456
|
+
// vector
|
|
22457
|
+
_x = arg0.x;
|
|
22458
|
+
_y = arg0.y;
|
|
22459
|
+
}
|
|
22460
|
+
}
|
|
22461
|
+
|
|
22462
|
+
// check whether point is outside the bounding box
|
|
22463
|
+
if (_x < this.left || _x >= this.right || _y < this.top || _y >= this.bottom) {
|
|
22464
|
+
return false; // outside bounding box
|
|
22465
|
+
}
|
|
22466
|
+
|
|
22467
|
+
// check whether point is within the bounding box minus radius
|
|
22468
|
+
if ((_x >= this.left + this.radius && _x <= this.right - this.radius) || (_y >= this.top + this.radius && _y <= this.bottom - this.radius)) {
|
|
22469
|
+
return true;
|
|
22470
|
+
}
|
|
22471
|
+
|
|
22472
|
+
// check whether point is in one of the rounded corner areas
|
|
22473
|
+
var tx, ty;
|
|
22474
|
+
var radiusX = Math.max(0, Math.min(this.radius, this.width / 2));
|
|
22475
|
+
var radiusY = Math.max(0, Math.min(this.radius, this.height / 2));
|
|
22476
|
+
|
|
22477
|
+
if (_x < this.left + radiusX && _y < this.top + radiusY) {
|
|
22478
|
+
tx = _x - this.left - radiusX;
|
|
22479
|
+
ty = _y - this.top - radiusY;
|
|
22480
|
+
} else if (_x > this.right - radiusX && _y < this.top + radiusY) {
|
|
22481
|
+
tx = _x - this.right + radiusX;
|
|
22482
|
+
ty = _y - this.top - radiusY;
|
|
22483
|
+
} else if (_x > this.right - radiusX && _y > this.bottom - radiusY) {
|
|
22484
|
+
tx = _x - this.right + radiusX;
|
|
22485
|
+
ty = _y - this.bottom + radiusY;
|
|
22486
|
+
} else if (_x < this.left + radiusX && _y > this.bottom - radiusY) {
|
|
22487
|
+
tx = _x - this.left - radiusX;
|
|
22488
|
+
ty = _y - this.bottom + radiusY;
|
|
22489
|
+
} else {
|
|
22490
|
+
return false; // inside and not within the rounded corner area
|
|
22491
|
+
}
|
|
22492
|
+
|
|
22493
|
+
// Pythagorean theorem.
|
|
22494
|
+
return ((tx * tx) + (ty * ty) <= (radiusX * radiusY));
|
|
22495
|
+
}
|
|
22496
|
+
|
|
22497
|
+
/**
|
|
22498
|
+
* check if this RoundRect is identical to the specified one
|
|
22499
|
+
* @name equals
|
|
22500
|
+
* @memberof RoundRect.prototype
|
|
22501
|
+
* @function
|
|
22502
|
+
* @param {RoundRect} rrect
|
|
22503
|
+
* @returns {boolean} true if equals
|
|
22504
|
+
*/
|
|
22505
|
+
equals(rrect) {
|
|
22506
|
+
return super.equals(rrect) && this.radius === rrect.radius;
|
|
22507
|
+
}
|
|
22508
|
+
|
|
22509
|
+
/**
|
|
22510
|
+
* clone this RoundRect
|
|
22511
|
+
* @name clone
|
|
22512
|
+
* @memberof RoundRect.prototype
|
|
22513
|
+
* @function
|
|
22514
|
+
* @returns {RoundRect} new RoundRect
|
|
22515
|
+
*/
|
|
22516
|
+
clone() {
|
|
22517
|
+
return new RoundRect(this.pos.x, this.pos.y, this.width, this.height, radius);
|
|
22518
|
+
}
|
|
22519
|
+
}
|
|
22520
|
+
|
|
22339
22521
|
/**
|
|
22340
22522
|
* @classdesc
|
|
22341
22523
|
* a line segment Object
|
|
@@ -22411,11 +22593,11 @@ class Line extends Polygon {
|
|
|
22411
22593
|
|
|
22412
22594
|
// Calculate the edges/normals
|
|
22413
22595
|
if (edges[0] === undefined) {
|
|
22414
|
-
edges[0] =
|
|
22596
|
+
edges[0] = pool$1.pull("Vector2d");
|
|
22415
22597
|
}
|
|
22416
22598
|
edges[0].copy(points[1]).sub(points[0]);
|
|
22417
22599
|
if (normals[0] === undefined) {
|
|
22418
|
-
normals[0] =
|
|
22600
|
+
normals[0] = pool$1.pull("Vector2d");
|
|
22419
22601
|
}
|
|
22420
22602
|
normals[0].copy(edges[0]).perp().normalize();
|
|
22421
22603
|
|
|
@@ -22443,6 +22625,321 @@ class Line extends Polygon {
|
|
|
22443
22625
|
|
|
22444
22626
|
}
|
|
22445
22627
|
|
|
22628
|
+
/**
|
|
22629
|
+
* @classdesc
|
|
22630
|
+
* a simplified path2d implementation, supporting only one path
|
|
22631
|
+
*/
|
|
22632
|
+
class Path2D$1 {
|
|
22633
|
+
constructor() {
|
|
22634
|
+
/**
|
|
22635
|
+
* the points defining the current path
|
|
22636
|
+
* @public
|
|
22637
|
+
* @type {Vector2d[]}
|
|
22638
|
+
* @name points
|
|
22639
|
+
* @memberof Path2D#
|
|
22640
|
+
*/
|
|
22641
|
+
this.points = [];
|
|
22642
|
+
|
|
22643
|
+
/**
|
|
22644
|
+
* space between interpolated points for quadratic and bezier curve approx. in pixels.
|
|
22645
|
+
* @public
|
|
22646
|
+
* @type {number}
|
|
22647
|
+
* @name arcResolution
|
|
22648
|
+
* @default 5
|
|
22649
|
+
* @memberof Path2D#
|
|
22650
|
+
*/
|
|
22651
|
+
this.arcResolution = 5;
|
|
22652
|
+
|
|
22653
|
+
/* @ignore */
|
|
22654
|
+
this.vertices = [];
|
|
22655
|
+
}
|
|
22656
|
+
|
|
22657
|
+
/**
|
|
22658
|
+
* begin a new path
|
|
22659
|
+
* @name beginPath
|
|
22660
|
+
* @memberof Path2D.prototype
|
|
22661
|
+
* @function
|
|
22662
|
+
*/
|
|
22663
|
+
beginPath() {
|
|
22664
|
+
// empty the cache and recycle all vectors
|
|
22665
|
+
this.points.forEach((point) => {
|
|
22666
|
+
pool$1.push(point);
|
|
22667
|
+
});
|
|
22668
|
+
this.points.length = 0;
|
|
22669
|
+
}
|
|
22670
|
+
|
|
22671
|
+
/**
|
|
22672
|
+
* causes the point of the pen to move back to the start of the current path.
|
|
22673
|
+
* It tries to draw a straight line from the current point to the start.
|
|
22674
|
+
* If the shape has already been closed or has only one point, this function does nothing.
|
|
22675
|
+
* @name closePath
|
|
22676
|
+
* @memberof Path2D.prototype
|
|
22677
|
+
* @function
|
|
22678
|
+
*/
|
|
22679
|
+
closePath() {
|
|
22680
|
+
var points = this.points;
|
|
22681
|
+
if (points.length > 1 && !points[points.length-1].equals(points[0])) {
|
|
22682
|
+
points.push(pool$1.pull("Vector2d", points[0].x, points[0].y));
|
|
22683
|
+
}
|
|
22684
|
+
}
|
|
22685
|
+
|
|
22686
|
+
/**
|
|
22687
|
+
* triangulate the shape defined by this path into an array of triangles
|
|
22688
|
+
* @name triangulatePath
|
|
22689
|
+
* @memberof Path2D.prototype
|
|
22690
|
+
* @function
|
|
22691
|
+
* @returns {Vector2d[]}
|
|
22692
|
+
*/
|
|
22693
|
+
triangulatePath() {
|
|
22694
|
+
var i = 0;
|
|
22695
|
+
var points = this.points;
|
|
22696
|
+
var vertices = this.vertices;
|
|
22697
|
+
var indices = earcut$1.exports(points.flatMap(p => [p.x, p.y]));
|
|
22698
|
+
|
|
22699
|
+
// calculate all vertices
|
|
22700
|
+
for (i = 0; i < indices.length; i++ ) {
|
|
22701
|
+
if (typeof vertices[i] === "undefined") {
|
|
22702
|
+
// increase cache buffer if necessary
|
|
22703
|
+
vertices[i] = pool$1.pull("Vector2d");
|
|
22704
|
+
}
|
|
22705
|
+
vertices[i].set(points[indices[i]].x, points[indices[i]].y);
|
|
22706
|
+
}
|
|
22707
|
+
|
|
22708
|
+
// recycle overhead from a previous triangulation
|
|
22709
|
+
while (vertices.length > indices.length) {
|
|
22710
|
+
pool$1.push(vertices[vertices.length-1]);
|
|
22711
|
+
vertices.length -= 1;
|
|
22712
|
+
}
|
|
22713
|
+
|
|
22714
|
+
return vertices;
|
|
22715
|
+
}
|
|
22716
|
+
|
|
22717
|
+
/**
|
|
22718
|
+
* moves the starting point of the current path to the (x, y) coordinates.
|
|
22719
|
+
* @name moveTo
|
|
22720
|
+
* @memberof Path2D.prototype
|
|
22721
|
+
* @function
|
|
22722
|
+
* @param {number} x the x-axis (horizontal) coordinate of the point.
|
|
22723
|
+
* @param {number} y the y-axis (vertical) coordinate of the point.
|
|
22724
|
+
*/
|
|
22725
|
+
moveTo(x, y) {
|
|
22726
|
+
this.points.push(pool$1.pull("Vector2d", x, y));
|
|
22727
|
+
}
|
|
22728
|
+
|
|
22729
|
+
/**
|
|
22730
|
+
* connects the last point in the current patch to the (x, y) coordinates with a straight line.
|
|
22731
|
+
* @name lineTo
|
|
22732
|
+
* @memberof Path2D.prototype
|
|
22733
|
+
* @function
|
|
22734
|
+
* @param {number} x the x-axis coordinate of the line's end point.
|
|
22735
|
+
* @param {number} y the y-axis coordinate of the line's end point.
|
|
22736
|
+
*/
|
|
22737
|
+
lineTo(x, y) {
|
|
22738
|
+
this.points.push(pool$1.pull("Vector2d", x, y));
|
|
22739
|
+
}
|
|
22740
|
+
|
|
22741
|
+
/**
|
|
22742
|
+
* adds an arc to the current path which is centered at (x, y) position with the given radius,
|
|
22743
|
+
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to clockwise).
|
|
22744
|
+
* @name arc
|
|
22745
|
+
* @memberof Path2D.prototype
|
|
22746
|
+
* @function
|
|
22747
|
+
* @param {number} x the horizontal coordinate of the arc's center.
|
|
22748
|
+
* @param {number} y the vertical coordinate of the arc's center.
|
|
22749
|
+
* @param {number} radius the arc's radius. Must be positive.
|
|
22750
|
+
* @param {number} startAngle the angle at which the arc starts in radians, measured from the positive x-axis.
|
|
22751
|
+
* @param {number} endAngle the angle at which the arc ends in radians, measured from the positive x-axis.
|
|
22752
|
+
* @param {boolean} [anticlockwise=false] an optional boolean value. If true, draws the arc counter-clockwise between the start and end angles.
|
|
22753
|
+
*/
|
|
22754
|
+
arc(x, y, radius, startAngle, endAngle, anticlockwise = false) {
|
|
22755
|
+
var points = this.points;
|
|
22756
|
+
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
22757
|
+
//bring angles all in [0, 2*PI] range
|
|
22758
|
+
if (startAngle === endAngle) return;
|
|
22759
|
+
var fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
|
|
22760
|
+
|
|
22761
|
+
startAngle = startAngle % (TAU);
|
|
22762
|
+
endAngle = endAngle % (TAU);
|
|
22763
|
+
|
|
22764
|
+
if (startAngle < 0) startAngle += TAU;
|
|
22765
|
+
if (endAngle < 0) endAngle += TAU;
|
|
22766
|
+
|
|
22767
|
+
if (startAngle >= endAngle) {
|
|
22768
|
+
endAngle+= TAU;
|
|
22769
|
+
}
|
|
22770
|
+
|
|
22771
|
+
var diff = endAngle - startAngle;
|
|
22772
|
+
var direction = 1;
|
|
22773
|
+
if (anticlockwise) {
|
|
22774
|
+
direction = -1;
|
|
22775
|
+
diff = TAU - diff;
|
|
22776
|
+
}
|
|
22777
|
+
|
|
22778
|
+
if (fullCircle) diff = TAU;
|
|
22779
|
+
|
|
22780
|
+
var length = diff * radius;
|
|
22781
|
+
var nr_of_interpolation_points = length / this.arcResolution;
|
|
22782
|
+
var dangle = diff / nr_of_interpolation_points;
|
|
22783
|
+
|
|
22784
|
+
var angle = startAngle;
|
|
22785
|
+
for (var j = 0; j < nr_of_interpolation_points; j++) {
|
|
22786
|
+
points.push(pool$1.pull("Vector2d", x + radius * Math.cos(angle), y + radius * Math.sin(angle)));
|
|
22787
|
+
angle += direction * dangle;
|
|
22788
|
+
}
|
|
22789
|
+
points.push(pool$1.pull("Vector2d", x + radius * Math.cos(endAngle), y + radius * Math.sin(endAngle)));
|
|
22790
|
+
}
|
|
22791
|
+
|
|
22792
|
+
/**
|
|
22793
|
+
* adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
|
|
22794
|
+
* @name arcTo
|
|
22795
|
+
* @memberof Path2D.prototype
|
|
22796
|
+
* @function
|
|
22797
|
+
* @param {number} x the x-axis coordinate of the first control point.
|
|
22798
|
+
* @param {number} y the y-axis coordinate of the first control point.
|
|
22799
|
+
* @param {number} x the x-axis coordinate of the second control point.
|
|
22800
|
+
* @param {number} y the y-axis coordinate of the second control point.
|
|
22801
|
+
* @param {number} radius the arc's radius. Must be positive.
|
|
22802
|
+
*/
|
|
22803
|
+
arcTo(x1, y1, x2, y2, radius) {
|
|
22804
|
+
var points = this.points;
|
|
22805
|
+
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
22806
|
+
var x0 = points[points.length-1].x, y0 = points[points.length-1].y;
|
|
22807
|
+
|
|
22808
|
+
//a = -incoming vector, b = outgoing vector to x1, y1
|
|
22809
|
+
var a = [x0 - x1, y0 - y1];
|
|
22810
|
+
var b = [x2 - x1, y2 - y1];
|
|
22811
|
+
|
|
22812
|
+
//normalize
|
|
22813
|
+
var l_a = Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2));
|
|
22814
|
+
var l_b = Math.sqrt(Math.pow(b[0], 2) + Math.pow(b[1], 2));
|
|
22815
|
+
a[0] /= l_a; a[1] /= l_a; b[0] /= l_b; b[1] /= l_b;
|
|
22816
|
+
var angle = Math.atan2(a[1], a[0]) - Math.atan2(b[1], b[0]);
|
|
22817
|
+
|
|
22818
|
+
//work out tangent points using tan(θ) = opposite / adjacent; angle/2 because hypotenuse is the bisection of a,b
|
|
22819
|
+
var tan_angle_div2 = Math.tan(angle/2);
|
|
22820
|
+
var adj_l = (radius/tan_angle_div2);
|
|
22821
|
+
|
|
22822
|
+
var tangent_point1 = [x1 + a[0] * adj_l, y1 + a[1] * adj_l];
|
|
22823
|
+
var tangent_point2 = [x1 + b[0] * adj_l, y1 + b[1] * adj_l];
|
|
22824
|
+
|
|
22825
|
+
points.push(pool$1.pull("Vector2d", tangent_point1[0], tangent_point1[1]));
|
|
22826
|
+
|
|
22827
|
+
var bisec = [(a[0] + b[0]) / 2.0, (a[1] + b[1]) / 2.0];
|
|
22828
|
+
var bisec_l = Math.sqrt(Math.pow(bisec[0], 2) + Math.pow(bisec[1], 2));
|
|
22829
|
+
bisec[0] /= bisec_l; bisec[1] /= bisec_l;
|
|
22830
|
+
|
|
22831
|
+
var hyp_l = Math.sqrt(Math.pow(radius, 2) + Math.pow(adj_l, 2));
|
|
22832
|
+
var center = [x1 + hyp_l * bisec[0], y1 + hyp_l * bisec[1]];
|
|
22833
|
+
|
|
22834
|
+
var startAngle = Math.atan2(tangent_point1[1] - center[1], tangent_point1[0] - center[0]);
|
|
22835
|
+
var endAngle = Math.atan2(tangent_point2[1] - center[1], tangent_point2[0] - center[0]);
|
|
22836
|
+
|
|
22837
|
+
this.arc(center[0], center[1], radius, startAngle, endAngle);
|
|
22838
|
+
}
|
|
22839
|
+
|
|
22840
|
+
/**
|
|
22841
|
+
* adds an elliptical arc to the path which is centered at (x, y) position with the radii radiusX and radiusY
|
|
22842
|
+
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise.
|
|
22843
|
+
* @name ellipse
|
|
22844
|
+
* @memberof Path2D.prototype
|
|
22845
|
+
* @function
|
|
22846
|
+
* @param {number} x the x-axis (horizontal) coordinate of the ellipse's center.
|
|
22847
|
+
* @param {number} y the y-axis (vertical) coordinate of the ellipse's center.
|
|
22848
|
+
* @param {number} radiusX the ellipse's major-axis radius. Must be non-negative.
|
|
22849
|
+
* @param {number} radiusY the ellipse's minor-axis radius. Must be non-negative.
|
|
22850
|
+
* @param {number} rotation the rotation of the ellipse, expressed in radians.
|
|
22851
|
+
* @param {number} startAngle the angle at which the ellipse starts, measured clockwise from the positive x-axis and expressed in radians.
|
|
22852
|
+
* @param {number} endAngle the angle at which the ellipse ends, measured clockwise from the positive x-axis and expressed in radians.
|
|
22853
|
+
* @param {boolean} [anticlockwise=false] an optional boolean value which, if true, draws the ellipse counterclockwise (anticlockwise).
|
|
22854
|
+
*/
|
|
22855
|
+
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise = false) {
|
|
22856
|
+
var points = this.points;
|
|
22857
|
+
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
22858
|
+
if (startAngle === endAngle) return;
|
|
22859
|
+
var fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
|
|
22860
|
+
|
|
22861
|
+
//bring angles all in [0, 2*PI] range
|
|
22862
|
+
startAngle = startAngle % (TAU);
|
|
22863
|
+
endAngle = endAngle % (TAU);
|
|
22864
|
+
if (startAngle < 0) startAngle += TAU;
|
|
22865
|
+
if (endAngle < 0) endAngle += TAU;
|
|
22866
|
+
|
|
22867
|
+
if (startAngle>=endAngle) {
|
|
22868
|
+
endAngle += TAU;
|
|
22869
|
+
}
|
|
22870
|
+
|
|
22871
|
+
var diff = endAngle - startAngle;
|
|
22872
|
+
|
|
22873
|
+
var direction = 1;
|
|
22874
|
+
if (anticlockwise) {
|
|
22875
|
+
direction = -1;
|
|
22876
|
+
diff = TAU - diff;
|
|
22877
|
+
}
|
|
22878
|
+
|
|
22879
|
+
if (fullCircle) diff = TAU;
|
|
22880
|
+
|
|
22881
|
+
var length = (diff * radiusX + diff * radiusY) / 2;
|
|
22882
|
+
var nr_of_interpolation_points = length / this.arcResolution;
|
|
22883
|
+
var dangle = diff / nr_of_interpolation_points;
|
|
22884
|
+
|
|
22885
|
+
var angle = startAngle;
|
|
22886
|
+
var cos_rotation = Math.cos(rotation);
|
|
22887
|
+
var sin_rotation = Math.sin(rotation);
|
|
22888
|
+
for (var j = 0; j < nr_of_interpolation_points; j++) {
|
|
22889
|
+
var _x1 = radiusX * Math.cos(angle);
|
|
22890
|
+
var _y1 = radiusY * Math.sin(angle);
|
|
22891
|
+
var _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
|
|
22892
|
+
var _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
|
|
22893
|
+
points.push(pool$1.pull("Vector2d", _x2, _y2));
|
|
22894
|
+
angle += direction * dangle;
|
|
22895
|
+
}
|
|
22896
|
+
//var x1 = radiusX * Math.cos(endAngle);
|
|
22897
|
+
//var y1 = radiusY * Math.sin(endAngle);
|
|
22898
|
+
//points.push(pool.pull("Vector2d", x + x1 * cos_rotation - y1 * sin_rotation, y + x1 * sin_rotation + y1 * cos_rotation));
|
|
22899
|
+
}
|
|
22900
|
+
|
|
22901
|
+
/**
|
|
22902
|
+
* creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
|
|
22903
|
+
* @name rect
|
|
22904
|
+
* @memberof Path2D.prototype
|
|
22905
|
+
* @function
|
|
22906
|
+
* @param {number} x the x-axis coordinate of the rectangle's starting point.
|
|
22907
|
+
* @param {number} y the y-axis coordinate of the rectangle's starting point.
|
|
22908
|
+
* @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
|
|
22909
|
+
* @param {number} height the rectangle's height. Positive values are down, and negative are up.
|
|
22910
|
+
*/
|
|
22911
|
+
rect(x, y, width, height) {
|
|
22912
|
+
this.moveTo(x, y);
|
|
22913
|
+
this.lineTo(x + width, y);
|
|
22914
|
+
this.lineTo(x + width, y + height);
|
|
22915
|
+
this.lineTo(x, y + height);
|
|
22916
|
+
this.lineTo(x, y);
|
|
22917
|
+
}
|
|
22918
|
+
|
|
22919
|
+
/**
|
|
22920
|
+
* adds an rounded rectangle to the current path.
|
|
22921
|
+
* @name roundRect
|
|
22922
|
+
* @memberof Path2D.prototype
|
|
22923
|
+
* @function
|
|
22924
|
+
* @param {number} x the x-axis coordinate of the rectangle's starting point.
|
|
22925
|
+
* @param {number} y the y-axis coordinate of the rectangle's starting point.
|
|
22926
|
+
* @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
|
|
22927
|
+
* @param {number} height the rectangle's height. Positive values are down, and negative are up.
|
|
22928
|
+
* @param {number} radius the arc's radius to draw the borders. Must be positive.
|
|
22929
|
+
*/
|
|
22930
|
+
roundRect(x, y, width, height, radius) {
|
|
22931
|
+
this.moveTo(x + radius, y);
|
|
22932
|
+
this.lineTo(x + width - radius, y);
|
|
22933
|
+
this.arcTo(x + width, y, x + width, y + radius, radius);
|
|
22934
|
+
this.lineTo(x + width, y + height - radius);
|
|
22935
|
+
this.arcTo(x + width, y + height, x + width - radius, y + height, radius);
|
|
22936
|
+
this.lineTo(x + radius, y + height);
|
|
22937
|
+
this.arcTo(x, y + height, x, y + height - radius, radius);
|
|
22938
|
+
this.lineTo(x, y + radius);
|
|
22939
|
+
this.arcTo(x, y, x + radius, y, radius);
|
|
22940
|
+
}
|
|
22941
|
+
}
|
|
22942
|
+
|
|
22446
22943
|
/**
|
|
22447
22944
|
* @classdesc
|
|
22448
22945
|
* a base renderer object
|
|
@@ -22476,12 +22973,20 @@ class Renderer {
|
|
|
22476
22973
|
/**
|
|
22477
22974
|
* true if the current rendering context is valid
|
|
22478
22975
|
* @name isContextValid
|
|
22479
|
-
* @memberof Renderer
|
|
22976
|
+
* @memberof Renderer#
|
|
22480
22977
|
* @default true
|
|
22481
22978
|
* type {boolean}
|
|
22482
22979
|
*/
|
|
22483
22980
|
this.isContextValid = true;
|
|
22484
22981
|
|
|
22982
|
+
/**
|
|
22983
|
+
* The Path2D instance used by the renderer to draw primitives
|
|
22984
|
+
* @name path2D
|
|
22985
|
+
* @type {Path2D}
|
|
22986
|
+
* @memberof Renderer#
|
|
22987
|
+
*/
|
|
22988
|
+
this.path2D = new Path2D$1();
|
|
22989
|
+
|
|
22485
22990
|
/**
|
|
22486
22991
|
* @ignore
|
|
22487
22992
|
*/
|
|
@@ -22764,15 +23269,23 @@ class Renderer {
|
|
|
22764
23269
|
* @name stroke
|
|
22765
23270
|
* @memberof Renderer.prototype
|
|
22766
23271
|
* @function
|
|
22767
|
-
* @param {Rect|Polygon|Line|Ellipse} shape a shape object to stroke
|
|
23272
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to stroke
|
|
22768
23273
|
* @param {boolean} [fill=false] fill the shape with the current color if true
|
|
22769
23274
|
*/
|
|
22770
23275
|
stroke(shape, fill) {
|
|
22771
23276
|
if (shape instanceof Rect || shape instanceof Bounds$1) {
|
|
22772
23277
|
this.strokeRect(shape.left, shape.top, shape.width, shape.height, fill);
|
|
22773
|
-
|
|
23278
|
+
return;
|
|
23279
|
+
}
|
|
23280
|
+
if (shape instanceof Line || shape instanceof Polygon) {
|
|
22774
23281
|
this.strokePolygon(shape, fill);
|
|
22775
|
-
|
|
23282
|
+
return;
|
|
23283
|
+
}
|
|
23284
|
+
if (shape instanceof RoundRect) {
|
|
23285
|
+
this.strokeRoundRect(shape.left, shape.top, shape.width, shape.height, shape.radius, fill);
|
|
23286
|
+
return;
|
|
23287
|
+
}
|
|
23288
|
+
if (shape instanceof Ellipse) {
|
|
22776
23289
|
this.strokeEllipse(
|
|
22777
23290
|
shape.pos.x,
|
|
22778
23291
|
shape.pos.y,
|
|
@@ -22780,7 +23293,20 @@ class Renderer {
|
|
|
22780
23293
|
shape.radiusV.y,
|
|
22781
23294
|
fill
|
|
22782
23295
|
);
|
|
23296
|
+
return;
|
|
22783
23297
|
}
|
|
23298
|
+
throw new Error("Invalid geometry for fill/stroke");
|
|
23299
|
+
}
|
|
23300
|
+
|
|
23301
|
+
/**
|
|
23302
|
+
* fill the given shape
|
|
23303
|
+
* @name fill
|
|
23304
|
+
* @memberof Renderer.prototype
|
|
23305
|
+
* @function
|
|
23306
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to fill
|
|
23307
|
+
*/
|
|
23308
|
+
fill(shape) {
|
|
23309
|
+
this.stroke(shape, true);
|
|
22784
23310
|
}
|
|
22785
23311
|
|
|
22786
23312
|
/**
|
|
@@ -22812,17 +23338,6 @@ class Renderer {
|
|
|
22812
23338
|
return canvas;
|
|
22813
23339
|
}
|
|
22814
23340
|
|
|
22815
|
-
/**
|
|
22816
|
-
* fill the given shape
|
|
22817
|
-
* @name fill
|
|
22818
|
-
* @memberof Renderer.prototype
|
|
22819
|
-
* @function
|
|
22820
|
-
* @param {Rect|Polygon|Line|Ellipse} shape a shape object to fill
|
|
22821
|
-
*/
|
|
22822
|
-
fill(shape) {
|
|
22823
|
-
this.stroke(shape, true);
|
|
22824
|
-
}
|
|
22825
|
-
|
|
22826
23341
|
/**
|
|
22827
23342
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
22828
23343
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
@@ -22830,7 +23345,7 @@ class Renderer {
|
|
|
22830
23345
|
* @name setMask
|
|
22831
23346
|
* @memberof Renderer.prototype
|
|
22832
23347
|
* @function
|
|
22833
|
-
* @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
23348
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
22834
23349
|
*/
|
|
22835
23350
|
// eslint-disable-next-line no-unused-vars
|
|
22836
23351
|
setMask(mask) {}
|
|
@@ -22936,7 +23451,6 @@ class CanvasRenderer extends Renderer {
|
|
|
22936
23451
|
this.getScreenCanvas().addEventListener("contextrestored", () => {
|
|
22937
23452
|
this.isContextValid = true;
|
|
22938
23453
|
event.emit(event.ONCONTEXT_RESTORED, this);
|
|
22939
|
-
me.game.repaint();
|
|
22940
23454
|
}, false );
|
|
22941
23455
|
}
|
|
22942
23456
|
|
|
@@ -23061,7 +23575,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23061
23575
|
* @param {number} height The rectangle's height.
|
|
23062
23576
|
*/
|
|
23063
23577
|
clearRect(x, y, width, height) {
|
|
23064
|
-
this.
|
|
23578
|
+
this.getContext().clearRect(x, y, width, height);
|
|
23065
23579
|
}
|
|
23066
23580
|
|
|
23067
23581
|
/**
|
|
@@ -23080,7 +23594,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23080
23594
|
* var basic = renderer.createPattern(image, "no-repeat");
|
|
23081
23595
|
*/
|
|
23082
23596
|
createPattern(image, repeat) {
|
|
23083
|
-
return this.
|
|
23597
|
+
return this.getContext().createPattern(image, repeat);
|
|
23084
23598
|
}
|
|
23085
23599
|
|
|
23086
23600
|
/**
|
|
@@ -23106,10 +23620,11 @@ class CanvasRenderer extends Renderer {
|
|
|
23106
23620
|
* renderer.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
|
|
23107
23621
|
*/
|
|
23108
23622
|
drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
|
|
23109
|
-
if (this.
|
|
23623
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23110
23624
|
// Fast path: don't draw fully transparent
|
|
23111
23625
|
return;
|
|
23112
23626
|
}
|
|
23627
|
+
var context = this.getContext();
|
|
23113
23628
|
|
|
23114
23629
|
if (typeof sw === "undefined") {
|
|
23115
23630
|
sw = dw = image.width;
|
|
@@ -23143,7 +23658,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23143
23658
|
// get a tinted version of this image from the texture cache
|
|
23144
23659
|
source = this.cache.tint(image, this.currentTint.toRGB());
|
|
23145
23660
|
}
|
|
23146
|
-
|
|
23661
|
+
context.drawImage(source, sx, sy, sw, sh, dx, dy, dw, dh);
|
|
23147
23662
|
}
|
|
23148
23663
|
|
|
23149
23664
|
/**
|
|
@@ -23159,14 +23674,15 @@ class CanvasRenderer extends Renderer {
|
|
|
23159
23674
|
* @see CanvasRenderer#createPattern
|
|
23160
23675
|
*/
|
|
23161
23676
|
drawPattern(pattern, x, y, width, height) {
|
|
23162
|
-
if (this.
|
|
23677
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23163
23678
|
// Fast path: don't draw fully transparent
|
|
23164
23679
|
return;
|
|
23165
23680
|
}
|
|
23166
|
-
var
|
|
23167
|
-
|
|
23168
|
-
|
|
23169
|
-
|
|
23681
|
+
var context = this.getContext();
|
|
23682
|
+
var fillStyle = context.fillStyle;
|
|
23683
|
+
context.fillStyle = pattern;
|
|
23684
|
+
context.fillRect(x, y, width, height);
|
|
23685
|
+
context.fillStyle = fillStyle;
|
|
23170
23686
|
}
|
|
23171
23687
|
|
|
23172
23688
|
/**
|
|
@@ -23183,12 +23699,12 @@ class CanvasRenderer extends Renderer {
|
|
|
23183
23699
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23184
23700
|
*/
|
|
23185
23701
|
strokeArc(x, y, radius, start, end, antiClockwise, fill = false) {
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
if (context.globalAlpha < 1 / 255) {
|
|
23702
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23189
23703
|
// Fast path: don't draw fully transparent
|
|
23190
23704
|
return;
|
|
23191
23705
|
}
|
|
23706
|
+
var context = this.getContext();
|
|
23707
|
+
|
|
23192
23708
|
context.translate(x, y);
|
|
23193
23709
|
context.beginPath();
|
|
23194
23710
|
context.arc(0, 0, radius, start, end, antiClockwise || false);
|
|
@@ -23224,12 +23740,11 @@ class CanvasRenderer extends Renderer {
|
|
|
23224
23740
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23225
23741
|
*/
|
|
23226
23742
|
strokeEllipse(x, y, w, h, fill = false) {
|
|
23227
|
-
|
|
23228
|
-
|
|
23229
|
-
if (context.globalAlpha < 1 / 255) {
|
|
23743
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23230
23744
|
// Fast path: don't draw fully transparent
|
|
23231
23745
|
return;
|
|
23232
23746
|
}
|
|
23747
|
+
var context = this.getContext();
|
|
23233
23748
|
|
|
23234
23749
|
var hw = w,
|
|
23235
23750
|
hh = h,
|
|
@@ -23280,9 +23795,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23280
23795
|
* @param {number} endY the end y coordinate
|
|
23281
23796
|
*/
|
|
23282
23797
|
strokeLine(startX, startY, endX, endY) {
|
|
23283
|
-
|
|
23284
|
-
|
|
23285
|
-
if (context < 1 / 255) {
|
|
23798
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23286
23799
|
// Fast path: don't draw fully transparent
|
|
23287
23800
|
return;
|
|
23288
23801
|
}
|
|
@@ -23316,12 +23829,11 @@ class CanvasRenderer extends Renderer {
|
|
|
23316
23829
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23317
23830
|
*/
|
|
23318
23831
|
strokePolygon(poly, fill = false) {
|
|
23319
|
-
|
|
23320
|
-
|
|
23321
|
-
if (context.globalAlpha < 1 / 255) {
|
|
23832
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23322
23833
|
// Fast path: don't draw fully transparent
|
|
23323
23834
|
return;
|
|
23324
23835
|
}
|
|
23836
|
+
var context = this.getContext();
|
|
23325
23837
|
|
|
23326
23838
|
this.translate(poly.pos.x, poly.pos.y);
|
|
23327
23839
|
context.beginPath();
|
|
@@ -23360,15 +23872,13 @@ class CanvasRenderer extends Renderer {
|
|
|
23360
23872
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23361
23873
|
*/
|
|
23362
23874
|
strokeRect(x, y, width, height, fill = false) {
|
|
23363
|
-
if (
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
if (this.backBufferContext2D.globalAlpha < 1 / 255) {
|
|
23367
|
-
// Fast path: don't draw fully transparent
|
|
23368
|
-
return;
|
|
23369
|
-
}
|
|
23370
|
-
this.backBufferContext2D.strokeRect(x, y, width, height);
|
|
23875
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23876
|
+
// Fast path: don't draw fully transparent
|
|
23877
|
+
return;
|
|
23371
23878
|
}
|
|
23879
|
+
var context = this.getContext();
|
|
23880
|
+
|
|
23881
|
+
context[fill === true ? "fillRect" : "strokeRect"](x, y, width, height);
|
|
23372
23882
|
}
|
|
23373
23883
|
|
|
23374
23884
|
/**
|
|
@@ -23382,11 +23892,46 @@ class CanvasRenderer extends Renderer {
|
|
|
23382
23892
|
* @param {number} height
|
|
23383
23893
|
*/
|
|
23384
23894
|
fillRect(x, y, width, height) {
|
|
23385
|
-
|
|
23895
|
+
this.strokeRect(x, y, width, height, true);
|
|
23896
|
+
}
|
|
23897
|
+
|
|
23898
|
+
/**
|
|
23899
|
+
* Stroke a rounded rectangle at the specified coordinates
|
|
23900
|
+
* @name strokeRoundRect
|
|
23901
|
+
* @memberof CanvasRenderer.prototype
|
|
23902
|
+
* @function
|
|
23903
|
+
* @param {number} x
|
|
23904
|
+
* @param {number} y
|
|
23905
|
+
* @param {number} width
|
|
23906
|
+
* @param {number} height
|
|
23907
|
+
* @param {number} radius
|
|
23908
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23909
|
+
*/
|
|
23910
|
+
strokeRoundRect(x, y, width, height, radius, fill = false) {
|
|
23911
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23386
23912
|
// Fast path: don't draw fully transparent
|
|
23387
23913
|
return;
|
|
23388
23914
|
}
|
|
23389
|
-
this.
|
|
23915
|
+
var context = this.getContext();
|
|
23916
|
+
|
|
23917
|
+
context.beginPath();
|
|
23918
|
+
context.roundRect(x, y, width, height, radius);
|
|
23919
|
+
context[fill === true ? "fill" : "stroke"]();
|
|
23920
|
+
}
|
|
23921
|
+
|
|
23922
|
+
/**
|
|
23923
|
+
* Draw a rounded filled rectangle at the specified coordinates
|
|
23924
|
+
* @name fillRoundRect
|
|
23925
|
+
* @memberof CanvasRenderer.prototype
|
|
23926
|
+
* @function
|
|
23927
|
+
* @param {number} x
|
|
23928
|
+
* @param {number} y
|
|
23929
|
+
* @param {number} width
|
|
23930
|
+
* @param {number} height
|
|
23931
|
+
* @param {number} radius
|
|
23932
|
+
*/
|
|
23933
|
+
fillRoundRect(x, y, width, height, radius) {
|
|
23934
|
+
this.strokeRoundRect(x, y, width, height, radius, true);
|
|
23390
23935
|
}
|
|
23391
23936
|
|
|
23392
23937
|
|
|
@@ -23428,7 +23973,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23428
23973
|
*/
|
|
23429
23974
|
restore() {
|
|
23430
23975
|
this.backBufferContext2D.restore();
|
|
23431
|
-
this.currentColor.glArray[3] = this.
|
|
23976
|
+
this.currentColor.glArray[3] = this.getGlobalAlpha();
|
|
23432
23977
|
this.currentScissor[0] = 0;
|
|
23433
23978
|
this.currentScissor[1] = 0;
|
|
23434
23979
|
this.currentScissor[2] = this.backBufferCanvas.width;
|
|
@@ -23476,7 +24021,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23476
24021
|
}
|
|
23477
24022
|
|
|
23478
24023
|
/**
|
|
23479
|
-
* Set the global alpha
|
|
24024
|
+
* Set the global alpha
|
|
23480
24025
|
* @name setGlobalAlpha
|
|
23481
24026
|
* @memberof CanvasRenderer.prototype
|
|
23482
24027
|
* @function
|
|
@@ -23486,6 +24031,17 @@ class CanvasRenderer extends Renderer {
|
|
|
23486
24031
|
this.backBufferContext2D.globalAlpha = this.currentColor.glArray[3] = alpha;
|
|
23487
24032
|
}
|
|
23488
24033
|
|
|
24034
|
+
/**
|
|
24035
|
+
* Return the global alpha
|
|
24036
|
+
* @name getGlobalAlpha
|
|
24037
|
+
* @memberof CanvasRenderer.prototype
|
|
24038
|
+
* @function
|
|
24039
|
+
* @returns {number} global alpha value
|
|
24040
|
+
*/
|
|
24041
|
+
getGlobalAlpha() {
|
|
24042
|
+
return this.backBufferContext2D.globalAlpha;
|
|
24043
|
+
}
|
|
24044
|
+
|
|
23489
24045
|
/**
|
|
23490
24046
|
* Set the line width on the context
|
|
23491
24047
|
* @name setLineWidth
|
|
@@ -23592,14 +24148,16 @@ class CanvasRenderer extends Renderer {
|
|
|
23592
24148
|
* @name setMask
|
|
23593
24149
|
* @memberof CanvasRenderer.prototype
|
|
23594
24150
|
* @function
|
|
23595
|
-
* @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
24151
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
23596
24152
|
*/
|
|
23597
24153
|
setMask(mask) {
|
|
23598
|
-
var context = this.
|
|
24154
|
+
var context = this.getContext();
|
|
23599
24155
|
var _x = mask.pos.x, _y = mask.pos.y;
|
|
23600
24156
|
|
|
23601
24157
|
context.save();
|
|
23602
24158
|
|
|
24159
|
+
context.beginPath();
|
|
24160
|
+
|
|
23603
24161
|
// https://github.com/melonjs/melonJS/issues/648
|
|
23604
24162
|
if (mask instanceof Ellipse) {
|
|
23605
24163
|
var hw = mask.radiusV.x,
|
|
@@ -23616,14 +24174,14 @@ class CanvasRenderer extends Renderer {
|
|
|
23616
24174
|
ymin = _y - ymagic,
|
|
23617
24175
|
ymax = _y + ymagic;
|
|
23618
24176
|
|
|
23619
|
-
context.beginPath();
|
|
23620
24177
|
context.moveTo(_x, ty);
|
|
23621
24178
|
context.bezierCurveTo(xmax, ty, rx, ymin, rx, _y);
|
|
23622
24179
|
context.bezierCurveTo(rx, ymax, xmax, by, _x, by);
|
|
23623
24180
|
context.bezierCurveTo(xmin, by, lx, ymax, lx, _y);
|
|
23624
24181
|
context.bezierCurveTo(lx, ymin, xmin, ty, _x, ty);
|
|
24182
|
+
} else if (mask instanceof RoundRect) {
|
|
24183
|
+
context.roundRect(_x, _y, mask.width, mask.height, mask.radius);
|
|
23625
24184
|
} else {
|
|
23626
|
-
context.beginPath();
|
|
23627
24185
|
context.moveTo(_x + mask.points[0].x, _y + mask.points[0].y);
|
|
23628
24186
|
var point;
|
|
23629
24187
|
for (var i = 1; i < mask.points.length; i++) {
|
|
@@ -23643,7 +24201,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23643
24201
|
* @function
|
|
23644
24202
|
*/
|
|
23645
24203
|
clearMask() {
|
|
23646
|
-
this.
|
|
24204
|
+
this.getContext().restore();
|
|
23647
24205
|
}
|
|
23648
24206
|
|
|
23649
24207
|
}
|
|
@@ -23942,9 +24500,9 @@ class TMXLayer extends Renderable {
|
|
|
23942
24500
|
var tile = null;
|
|
23943
24501
|
|
|
23944
24502
|
if (this.contains(x, y)) {
|
|
23945
|
-
var coord = this.getRenderer().pixelToTileCoords(x, y, pull("Vector2d"));
|
|
24503
|
+
var coord = this.getRenderer().pixelToTileCoords(x, y, pool$1.pull("Vector2d"));
|
|
23946
24504
|
tile = this.cellAt(coord.x, coord.y);
|
|
23947
|
-
push(coord);
|
|
24505
|
+
pool$1.push(coord);
|
|
23948
24506
|
}
|
|
23949
24507
|
return tile;
|
|
23950
24508
|
}
|
|
@@ -24086,6 +24644,8 @@ class Bounds {
|
|
|
24086
24644
|
* @param {Vector2d[]} [vertices] an array of me.Vector2d points
|
|
24087
24645
|
*/
|
|
24088
24646
|
constructor(vertices) {
|
|
24647
|
+
// @ignore
|
|
24648
|
+
this._center = new Vector2d();
|
|
24089
24649
|
this.onResetEvent(vertices);
|
|
24090
24650
|
}
|
|
24091
24651
|
|
|
@@ -24102,9 +24662,6 @@ class Bounds {
|
|
|
24102
24662
|
if (typeof vertices !== "undefined") {
|
|
24103
24663
|
this.update(vertices);
|
|
24104
24664
|
}
|
|
24105
|
-
|
|
24106
|
-
// @ignore
|
|
24107
|
-
this._center = new Vector2d();
|
|
24108
24665
|
}
|
|
24109
24666
|
|
|
24110
24667
|
/**
|
|
@@ -24526,11 +25083,11 @@ class Bounds {
|
|
|
24526
25083
|
* @returns {Polygon} a new Polygon that represents this bounds.
|
|
24527
25084
|
*/
|
|
24528
25085
|
toPolygon () {
|
|
24529
|
-
return
|
|
24530
|
-
|
|
24531
|
-
|
|
24532
|
-
|
|
24533
|
-
|
|
25086
|
+
return pool$1.pull("Polygon", this.x, this.y, [
|
|
25087
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
25088
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
25089
|
+
pool$1.pull("Vector2d", this.width, this.height),
|
|
25090
|
+
pool$1.pull("Vector2d", 0, this.height)
|
|
24534
25091
|
]);
|
|
24535
25092
|
}
|
|
24536
25093
|
|
|
@@ -24587,7 +25144,7 @@ class TMXRenderer {
|
|
|
24587
25144
|
* @returns {Bounds}
|
|
24588
25145
|
*/
|
|
24589
25146
|
getBounds(layer) {
|
|
24590
|
-
var bounds = layer instanceof TMXLayer ? pull("Bounds") : this.bounds;
|
|
25147
|
+
var bounds = layer instanceof TMXLayer ? pool$1.pull("Bounds") : this.bounds;
|
|
24591
25148
|
bounds.setMinMax(
|
|
24592
25149
|
0, 0,
|
|
24593
25150
|
this.cols * this.tilewidth,
|
|
@@ -24746,13 +25303,13 @@ class TMXOrthogonalRenderer extends TMXRenderer {
|
|
|
24746
25303
|
var start = this.pixelToTileCoords(
|
|
24747
25304
|
Math.max(rect.pos.x - (layer.maxTileSize.width - layer.tilewidth), 0),
|
|
24748
25305
|
Math.max(rect.pos.y - (layer.maxTileSize.height - layer.tileheight), 0),
|
|
24749
|
-
pull("Vector2d")
|
|
25306
|
+
pool$1.pull("Vector2d")
|
|
24750
25307
|
).floorSelf();
|
|
24751
25308
|
|
|
24752
25309
|
var end = this.pixelToTileCoords(
|
|
24753
25310
|
rect.pos.x + rect.width + this.tilewidth,
|
|
24754
25311
|
rect.pos.y + rect.height + this.tileheight,
|
|
24755
|
-
pull("Vector2d")
|
|
25312
|
+
pool$1.pull("Vector2d")
|
|
24756
25313
|
).ceilSelf();
|
|
24757
25314
|
|
|
24758
25315
|
//ensure we are in the valid tile range
|
|
@@ -24790,8 +25347,8 @@ class TMXOrthogonalRenderer extends TMXRenderer {
|
|
|
24790
25347
|
}
|
|
24791
25348
|
}
|
|
24792
25349
|
|
|
24793
|
-
push(start);
|
|
24794
|
-
push(end);
|
|
25350
|
+
pool$1.push(start);
|
|
25351
|
+
pool$1.push(end);
|
|
24795
25352
|
}
|
|
24796
25353
|
}
|
|
24797
25354
|
|
|
@@ -24837,7 +25394,7 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
24837
25394
|
* @returns {Bounds}
|
|
24838
25395
|
*/
|
|
24839
25396
|
getBounds(layer) {
|
|
24840
|
-
var bounds = layer instanceof TMXLayer ? pull("Bounds") : this.bounds;
|
|
25397
|
+
var bounds = layer instanceof TMXLayer ? pool$1.pull("Bounds") : this.bounds;
|
|
24841
25398
|
bounds.setMinMax(
|
|
24842
25399
|
0, 0,
|
|
24843
25400
|
(this.cols + this.rows) * (this.tilewidth / 2),
|
|
@@ -24878,14 +25435,14 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
24878
25435
|
adjustPosition(obj) {
|
|
24879
25436
|
var tileX = obj.x / this.hTilewidth;
|
|
24880
25437
|
var tileY = obj.y / this.tileheight;
|
|
24881
|
-
var isoPos = pull("Vector2d");
|
|
25438
|
+
var isoPos = pool$1.pull("Vector2d");
|
|
24882
25439
|
|
|
24883
25440
|
this.tileToPixelCoords(tileX, tileY, isoPos);
|
|
24884
25441
|
|
|
24885
25442
|
obj.x = isoPos.x;
|
|
24886
25443
|
obj.y = isoPos.y;
|
|
24887
25444
|
|
|
24888
|
-
push(isoPos);
|
|
25445
|
+
pool$1.push(isoPos);
|
|
24889
25446
|
}
|
|
24890
25447
|
|
|
24891
25448
|
/**
|
|
@@ -24915,18 +25472,18 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
24915
25472
|
var rowItr = this.pixelToTileCoords(
|
|
24916
25473
|
rect.pos.x - tileset.tilewidth,
|
|
24917
25474
|
rect.pos.y - tileset.tileheight,
|
|
24918
|
-
pull("Vector2d")
|
|
25475
|
+
pool$1.pull("Vector2d")
|
|
24919
25476
|
).floorSelf();
|
|
24920
25477
|
var tileEnd = this.pixelToTileCoords(
|
|
24921
25478
|
rect.pos.x + rect.width + tileset.tilewidth,
|
|
24922
25479
|
rect.pos.y + rect.height + tileset.tileheight,
|
|
24923
|
-
pull("Vector2d")
|
|
25480
|
+
pool$1.pull("Vector2d")
|
|
24924
25481
|
).ceilSelf();
|
|
24925
25482
|
|
|
24926
|
-
var rectEnd = this.tileToPixelCoords(tileEnd.x, tileEnd.y, pull("Vector2d"));
|
|
25483
|
+
var rectEnd = this.tileToPixelCoords(tileEnd.x, tileEnd.y, pool$1.pull("Vector2d"));
|
|
24927
25484
|
|
|
24928
25485
|
// Determine the tile and pixel coordinates to start at
|
|
24929
|
-
var startPos = this.tileToPixelCoords(rowItr.x, rowItr.y, pull("Vector2d"));
|
|
25486
|
+
var startPos = this.tileToPixelCoords(rowItr.x, rowItr.y, pool$1.pull("Vector2d"));
|
|
24930
25487
|
startPos.x -= this.hTilewidth;
|
|
24931
25488
|
startPos.y += this.tileheight;
|
|
24932
25489
|
|
|
@@ -24993,11 +25550,11 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
24993
25550
|
}
|
|
24994
25551
|
}
|
|
24995
25552
|
|
|
24996
|
-
push(columnItr);
|
|
24997
|
-
push(rowItr);
|
|
24998
|
-
push(tileEnd);
|
|
24999
|
-
push(rectEnd);
|
|
25000
|
-
push(startPos);
|
|
25553
|
+
pool$1.push(columnItr);
|
|
25554
|
+
pool$1.push(rowItr);
|
|
25555
|
+
pool$1.push(tileEnd);
|
|
25556
|
+
pool$1.push(rectEnd);
|
|
25557
|
+
pool$1.push(startPos);
|
|
25001
25558
|
}
|
|
25002
25559
|
}
|
|
25003
25560
|
|
|
@@ -25082,7 +25639,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25082
25639
|
* @returns {Bounds}
|
|
25083
25640
|
*/
|
|
25084
25641
|
getBounds(layer) {
|
|
25085
|
-
var bounds = layer instanceof TMXLayer ? pull("Bounds") : this.bounds;
|
|
25642
|
+
var bounds = layer instanceof TMXLayer ? pool$1.pull("Bounds") : this.bounds;
|
|
25086
25643
|
|
|
25087
25644
|
// The map size is the same regardless of which indexes are shifted.
|
|
25088
25645
|
if (this.staggerX) {
|
|
@@ -25233,13 +25790,13 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25233
25790
|
}
|
|
25234
25791
|
|
|
25235
25792
|
// Start with the coordinates of a grid-aligned tile
|
|
25236
|
-
var referencePoint = pull("Vector2d",
|
|
25793
|
+
var referencePoint = pool$1.pull("Vector2d",
|
|
25237
25794
|
Math.floor(x / (this.columnwidth * 2)),
|
|
25238
25795
|
Math.floor((y / (this.rowheight * 2)))
|
|
25239
25796
|
);
|
|
25240
25797
|
|
|
25241
25798
|
// Relative x and y position on the base square of the grid-aligned tile
|
|
25242
|
-
var rel = pull("Vector2d",
|
|
25799
|
+
var rel = pool$1.pull("Vector2d",
|
|
25243
25800
|
x - referencePoint.x * (this.columnwidth * 2),
|
|
25244
25801
|
y - referencePoint.y * (this.rowheight * 2)
|
|
25245
25802
|
);
|
|
@@ -25298,8 +25855,8 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25298
25855
|
referencePoint.y + offsets[nearest].y
|
|
25299
25856
|
);
|
|
25300
25857
|
|
|
25301
|
-
push(referencePoint);
|
|
25302
|
-
push(rel);
|
|
25858
|
+
pool$1.push(referencePoint);
|
|
25859
|
+
pool$1.push(rel);
|
|
25303
25860
|
|
|
25304
25861
|
return ret;
|
|
25305
25862
|
}
|
|
@@ -25350,7 +25907,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25350
25907
|
*/
|
|
25351
25908
|
drawTile(renderer, x, y, tmxTile) {
|
|
25352
25909
|
var tileset = tmxTile.tileset;
|
|
25353
|
-
var point = this.tileToPixelCoords(x, y, pull("Vector2d"));
|
|
25910
|
+
var point = this.tileToPixelCoords(x, y, pool$1.pull("Vector2d"));
|
|
25354
25911
|
|
|
25355
25912
|
// draw the tile
|
|
25356
25913
|
tileset.drawTile(
|
|
@@ -25360,7 +25917,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25360
25917
|
tmxTile
|
|
25361
25918
|
);
|
|
25362
25919
|
|
|
25363
|
-
push(point);
|
|
25920
|
+
pool$1.push(point);
|
|
25364
25921
|
}
|
|
25365
25922
|
|
|
25366
25923
|
/**
|
|
@@ -25374,7 +25931,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25374
25931
|
var startTile = this.pixelToTileCoords(
|
|
25375
25932
|
rect.pos.x,
|
|
25376
25933
|
rect.pos.y,
|
|
25377
|
-
pull("Vector2d")
|
|
25934
|
+
pool$1.pull("Vector2d")
|
|
25378
25935
|
);
|
|
25379
25936
|
|
|
25380
25937
|
// Compensate for the layer position
|
|
@@ -25384,7 +25941,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25384
25941
|
var startPos = this.tileToPixelCoords(
|
|
25385
25942
|
startTile.x + layer.pos.x,
|
|
25386
25943
|
startTile.y + layer.pos.y,
|
|
25387
|
-
pull("Vector2d")
|
|
25944
|
+
pool$1.pull("Vector2d")
|
|
25388
25945
|
);
|
|
25389
25946
|
|
|
25390
25947
|
var rowTile = startTile.clone();
|
|
@@ -25447,8 +26004,8 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25447
26004
|
|
|
25448
26005
|
startPos.y += this.rowheight;
|
|
25449
26006
|
}
|
|
25450
|
-
push(rowTile);
|
|
25451
|
-
push(rowPos);
|
|
26007
|
+
pool$1.push(rowTile);
|
|
26008
|
+
pool$1.push(rowPos);
|
|
25452
26009
|
|
|
25453
26010
|
} else {
|
|
25454
26011
|
//ensure we are in the valid tile range
|
|
@@ -25484,12 +26041,12 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25484
26041
|
}
|
|
25485
26042
|
startPos.y += this.rowheight;
|
|
25486
26043
|
}
|
|
25487
|
-
push(rowTile);
|
|
25488
|
-
push(rowPos);
|
|
26044
|
+
pool$1.push(rowTile);
|
|
26045
|
+
pool$1.push(rowPos);
|
|
25489
26046
|
}
|
|
25490
26047
|
|
|
25491
|
-
push(startTile);
|
|
25492
|
-
push(startPos);
|
|
26048
|
+
pool$1.push(startTile);
|
|
26049
|
+
pool$1.push(startPos);
|
|
25493
26050
|
}
|
|
25494
26051
|
}
|
|
25495
26052
|
|
|
@@ -25528,7 +26085,7 @@ class TMXStaggeredRenderer extends TMXHexagonalRenderer {
|
|
|
25528
26085
|
}
|
|
25529
26086
|
|
|
25530
26087
|
// Start with the coordinates of a grid-aligned tile
|
|
25531
|
-
var referencePoint = pull("Vector2d",
|
|
26088
|
+
var referencePoint = pool$1.pull("Vector2d",
|
|
25532
26089
|
Math.floor(alignedX / this.tilewidth),
|
|
25533
26090
|
Math.floor(alignedY / this.tileheight)
|
|
25534
26091
|
);
|
|
@@ -25547,7 +26104,7 @@ class TMXStaggeredRenderer extends TMXHexagonalRenderer {
|
|
|
25547
26104
|
}
|
|
25548
26105
|
|
|
25549
26106
|
// Relative x and y position on the base square of the grid-aligned tile
|
|
25550
|
-
var rel = pull("Vector2d",
|
|
26107
|
+
var rel = pool$1.pull("Vector2d",
|
|
25551
26108
|
alignedX - referencePoint.x * this.tilewidth,
|
|
25552
26109
|
alignedY - referencePoint.y * this.tileheight
|
|
25553
26110
|
);
|
|
@@ -25580,8 +26137,8 @@ class TMXStaggeredRenderer extends TMXHexagonalRenderer {
|
|
|
25580
26137
|
|
|
25581
26138
|
ret.div(this.tilewidth / Math.sqrt(2)).rotate(degToRad(-45)).add(referencePoint);
|
|
25582
26139
|
|
|
25583
|
-
push(referencePoint);
|
|
25584
|
-
push(rel);
|
|
26140
|
+
pool$1.push(referencePoint);
|
|
26141
|
+
pool$1.push(rel);
|
|
25585
26142
|
|
|
25586
26143
|
return ret;
|
|
25587
26144
|
}
|
|
@@ -26209,7 +26766,7 @@ class TMXObject {
|
|
|
26209
26766
|
// add an ellipse shape
|
|
26210
26767
|
if (this.isEllipse === true) {
|
|
26211
26768
|
// ellipse coordinates are the center position, so set default to the corresonding radius
|
|
26212
|
-
shapes.push((
|
|
26769
|
+
shapes.push((pool$1.pull("Ellipse",
|
|
26213
26770
|
this.width / 2,
|
|
26214
26771
|
this.height / 2,
|
|
26215
26772
|
this.width,
|
|
@@ -26219,7 +26776,7 @@ class TMXObject {
|
|
|
26219
26776
|
|
|
26220
26777
|
// add a polygon
|
|
26221
26778
|
if (this.isPolygon === true) {
|
|
26222
|
-
var _polygon =
|
|
26779
|
+
var _polygon = pool$1.pull("Polygon", 0, 0, this.points);
|
|
26223
26780
|
// make sure it's a convex polygon
|
|
26224
26781
|
if (_polygon.isConvex() === false ) {
|
|
26225
26782
|
throw new Error("collision polygones in Tiled should be defined as Convex");
|
|
@@ -26235,22 +26792,22 @@ class TMXObject {
|
|
|
26235
26792
|
for (i = 0; i < segments; i++) {
|
|
26236
26793
|
// clone the value before, as [i + 1]
|
|
26237
26794
|
// is reused later by the next segment
|
|
26238
|
-
p1 =
|
|
26239
|
-
p2 =
|
|
26795
|
+
p1 = pool$1.pull("Vector2d", p[i].x, p[i].y);
|
|
26796
|
+
p2 = pool$1.pull("Vector2d", p[i + 1].x, p[i + 1].y);
|
|
26240
26797
|
if (this.rotation !== 0) {
|
|
26241
26798
|
p1 = p1.rotate(this.rotation);
|
|
26242
26799
|
p2 = p2.rotate(this.rotation);
|
|
26243
26800
|
}
|
|
26244
|
-
shapes.push(
|
|
26801
|
+
shapes.push(pool$1.pull("Line", 0, 0, [ p1, p2 ]));
|
|
26245
26802
|
}
|
|
26246
26803
|
}
|
|
26247
26804
|
|
|
26248
26805
|
// it's a rectangle, returns a polygon object anyway
|
|
26249
26806
|
else {
|
|
26250
|
-
shapes.push((
|
|
26807
|
+
shapes.push((pool$1.pull("Polygon",
|
|
26251
26808
|
0, 0, [
|
|
26252
|
-
|
|
26253
|
-
|
|
26809
|
+
pool$1.pull("Vector2d"), pool$1.pull("Vector2d", this.width, 0),
|
|
26810
|
+
pool$1.pull("Vector2d", this.width, this.height), pool$1.pull("Vector2d", 0, this.height)
|
|
26254
26811
|
]
|
|
26255
26812
|
)).rotate(this.rotation));
|
|
26256
26813
|
}
|
|
@@ -26444,16 +27001,16 @@ function readImageLayer(map, data, z) {
|
|
|
26444
27001
|
applyTMXProperties(data.properties, data);
|
|
26445
27002
|
|
|
26446
27003
|
// create the layer
|
|
26447
|
-
var imageLayer = pull("ImageLayer",
|
|
27004
|
+
var imageLayer = pool$1.pull("ImageLayer",
|
|
26448
27005
|
// x/y is deprecated since 0.15 and replace by offsetx/y
|
|
26449
27006
|
+data.offsetx || +data.x || 0,
|
|
26450
27007
|
+data.offsety || +data.y || 0,
|
|
26451
27008
|
Object.assign({
|
|
26452
27009
|
name: data.name,
|
|
26453
27010
|
image: data.image,
|
|
26454
|
-
ratio : pull("Vector2d", +data.parallaxx || 1.0, +data.parallaxy || 1.0),
|
|
27011
|
+
ratio : pool$1.pull("Vector2d", +data.parallaxx || 1.0, +data.parallaxy || 1.0),
|
|
26455
27012
|
// convert to melonJS color format (note: this should be done earlier when parsing data)
|
|
26456
|
-
tint : typeof (data.tintcolor) !== "undefined" ? (pull("Color")).parseHex(data.tintcolor, true) : undefined,
|
|
27013
|
+
tint : typeof (data.tintcolor) !== "undefined" ? (pool$1.pull("Color")).parseHex(data.tintcolor, true) : undefined,
|
|
26457
27014
|
z: z
|
|
26458
27015
|
}, data.properties)
|
|
26459
27016
|
);
|
|
@@ -26693,7 +27250,7 @@ class TMXTileMap {
|
|
|
26693
27250
|
if (this.background_image) {
|
|
26694
27251
|
// add a new image layer
|
|
26695
27252
|
this.layers.push(
|
|
26696
|
-
pull("ImageLayer",
|
|
27253
|
+
pool$1.pull("ImageLayer",
|
|
26697
27254
|
0, 0, {
|
|
26698
27255
|
name : "background_image",
|
|
26699
27256
|
image : this.background_image,
|
|
@@ -26853,6 +27410,8 @@ class TMXTileMap {
|
|
|
26853
27410
|
var settings = group.objects[o];
|
|
26854
27411
|
// reference to the instantiated object
|
|
26855
27412
|
var obj;
|
|
27413
|
+
// a reference to the default shape
|
|
27414
|
+
var shape;
|
|
26856
27415
|
|
|
26857
27416
|
// Tiled uses 0,0 by default
|
|
26858
27417
|
if (typeof (settings.anchorPoint) === "undefined") {
|
|
@@ -26860,7 +27419,7 @@ class TMXTileMap {
|
|
|
26860
27419
|
}
|
|
26861
27420
|
// convert to melonJS renderable argument name
|
|
26862
27421
|
if (typeof (settings.tintcolor) !== "undefined") {
|
|
26863
|
-
settings.tint = pull("Color");
|
|
27422
|
+
settings.tint = pool$1.pull("Color");
|
|
26864
27423
|
settings.tint.parseHex(settings.tintcolor, true);
|
|
26865
27424
|
}
|
|
26866
27425
|
|
|
@@ -26878,39 +27437,57 @@ class TMXTileMap {
|
|
|
26878
27437
|
settings.text.anchorPoint = settings.anchorPoint;
|
|
26879
27438
|
}
|
|
26880
27439
|
if (settings.text.bitmap === true) {
|
|
26881
|
-
obj = pull("BitmapText", settings.x, settings.y, settings.text);
|
|
27440
|
+
obj = pool$1.pull("BitmapText", settings.x, settings.y, settings.text);
|
|
26882
27441
|
} else {
|
|
26883
|
-
obj = pull("Text", settings.x, settings.y, settings.text);
|
|
27442
|
+
obj = pool$1.pull("Text", settings.x, settings.y, settings.text);
|
|
26884
27443
|
}
|
|
26885
27444
|
// set the obj z order
|
|
26886
27445
|
obj.pos.z = settings.z;
|
|
26887
27446
|
} else if (typeof settings.tile === "object") {
|
|
27447
|
+
// create a default shape if none is specified
|
|
27448
|
+
shape = settings.shapes;
|
|
27449
|
+
if (typeof shape === "undefined") {
|
|
27450
|
+
shape = pool$1.pull("Polygon", 0, 0, [
|
|
27451
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
27452
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
27453
|
+
pool$1.pull("Vector2d", this.width, this.height)
|
|
27454
|
+
]);
|
|
27455
|
+
}
|
|
26888
27456
|
// check if a me.Tile object is embedded
|
|
26889
27457
|
obj = settings.tile.getRenderable(settings);
|
|
26890
|
-
obj.body = new Body(obj,
|
|
27458
|
+
obj.body = new Body(obj, shape);
|
|
26891
27459
|
obj.body.setStatic(true);
|
|
26892
27460
|
// set the obj z order
|
|
26893
27461
|
obj.pos.setMuted(settings.x, settings.y, settings.z);
|
|
26894
27462
|
} else {
|
|
26895
27463
|
// pull the corresponding object from the object pool
|
|
26896
27464
|
if (typeof settings.name !== "undefined" && settings.name !== "") {
|
|
26897
|
-
obj = pull(
|
|
27465
|
+
obj = pool$1.pull(
|
|
26898
27466
|
settings.name,
|
|
26899
27467
|
settings.x, settings.y,
|
|
26900
27468
|
settings
|
|
26901
27469
|
);
|
|
26902
27470
|
} else {
|
|
26903
27471
|
// unnamed shape object
|
|
26904
|
-
obj = pull(
|
|
27472
|
+
obj = pool$1.pull(
|
|
26905
27473
|
"Renderable",
|
|
26906
27474
|
settings.x, settings.y,
|
|
26907
27475
|
settings.width, settings.height
|
|
26908
27476
|
);
|
|
27477
|
+
// create a default shape if none is specified
|
|
27478
|
+
shape = settings.shapes;
|
|
27479
|
+
if (typeof shape === "undefined") {
|
|
27480
|
+
shape = pool$1.pull("Polygon", 0, 0, [
|
|
27481
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
27482
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
27483
|
+
pool$1.pull("Vector2d", this.width, this.height)
|
|
27484
|
+
]);
|
|
27485
|
+
}
|
|
26909
27486
|
obj.anchorPoint.set(0, 0);
|
|
26910
27487
|
obj.name = settings.name;
|
|
26911
27488
|
obj.type = settings.type;
|
|
26912
27489
|
obj.id = settings.id;
|
|
26913
|
-
obj.body = new Body(obj,
|
|
27490
|
+
obj.body = new Body(obj, shape);
|
|
26914
27491
|
obj.body.setStatic(true);
|
|
26915
27492
|
obj.resize(obj.body.getBounds().width, obj.body.getBounds().height);
|
|
26916
27493
|
}
|
|
@@ -27310,7 +27887,7 @@ function checkLoadStatus(onload) {
|
|
|
27310
27887
|
}
|
|
27311
27888
|
}
|
|
27312
27889
|
else {
|
|
27313
|
-
timerId$1 = setTimeout(
|
|
27890
|
+
timerId$1 = setTimeout(() => {
|
|
27314
27891
|
checkLoadStatus(onload);
|
|
27315
27892
|
}, 100);
|
|
27316
27893
|
}
|
|
@@ -27347,7 +27924,7 @@ function preloadImage(img, onload, onerror) {
|
|
|
27347
27924
|
function preloadFontFace(data, onload, onerror) {
|
|
27348
27925
|
var font = new FontFace(data.name, data.src);
|
|
27349
27926
|
// loading promise
|
|
27350
|
-
font.load().then(
|
|
27927
|
+
font.load().then(() => {
|
|
27351
27928
|
// apply the font after the font has finished downloading
|
|
27352
27929
|
document.fonts.add(font);
|
|
27353
27930
|
document.body.style.fontFamily = data.name;
|
|
@@ -27536,12 +28113,12 @@ function preloadJavascript(data, onload, onerror) {
|
|
|
27536
28113
|
}
|
|
27537
28114
|
script.defer = true;
|
|
27538
28115
|
|
|
27539
|
-
script.onload =
|
|
28116
|
+
script.onload = () => {
|
|
27540
28117
|
// callback
|
|
27541
28118
|
onload();
|
|
27542
28119
|
};
|
|
27543
28120
|
|
|
27544
|
-
script.onerror =
|
|
28121
|
+
script.onerror = () => {
|
|
27545
28122
|
// callback
|
|
27546
28123
|
onerror(data.name);
|
|
27547
28124
|
};
|
|
@@ -28787,12 +29364,6 @@ function _checkCapabilities() {
|
|
|
28787
29364
|
// detect device type/platform
|
|
28788
29365
|
_detectDevice();
|
|
28789
29366
|
|
|
28790
|
-
// Mobile browser hacks
|
|
28791
|
-
if (device.isMobile) {
|
|
28792
|
-
// Prevent the webview from moving on a swipe
|
|
28793
|
-
device.enableSwipe(false);
|
|
28794
|
-
}
|
|
28795
|
-
|
|
28796
29367
|
// Touch/Gesture Event feature detection
|
|
28797
29368
|
device.TouchEvent = !!("ontouchstart" in globalThis);
|
|
28798
29369
|
device.PointerEvent = !!globalThis.PointerEvent;
|
|
@@ -28914,6 +29485,13 @@ function _checkCapabilities() {
|
|
|
28914
29485
|
);
|
|
28915
29486
|
}
|
|
28916
29487
|
}
|
|
29488
|
+
|
|
29489
|
+
// Mobile browser hacks
|
|
29490
|
+
if (device.isMobile) {
|
|
29491
|
+
// Prevent the webview from moving on a swipe
|
|
29492
|
+
device.enableSwipe(false);
|
|
29493
|
+
}
|
|
29494
|
+
|
|
28917
29495
|
}
|
|
28918
29496
|
|
|
28919
29497
|
// Initialize me.timer on Boot event
|
|
@@ -29350,13 +29928,14 @@ let device = {
|
|
|
29350
29928
|
* @param {boolean} [enable=true] enable or disable swipe.
|
|
29351
29929
|
*/
|
|
29352
29930
|
enableSwipe(enable) {
|
|
29931
|
+
var moveEvent = device.PointerEvent ? "pointermove" : (device.TouchEvent ? "touchmove" : "mousemove");
|
|
29353
29932
|
if (enable !== false) {
|
|
29354
29933
|
if (swipeEnabled === false) {
|
|
29355
|
-
globalThis.document.removeEventListener(
|
|
29934
|
+
globalThis.document.removeEventListener(moveEvent, _disableSwipeFn);
|
|
29356
29935
|
swipeEnabled = true;
|
|
29357
29936
|
}
|
|
29358
29937
|
} else if (swipeEnabled === true) {
|
|
29359
|
-
globalThis.document.addEventListener(
|
|
29938
|
+
globalThis.document.addEventListener(moveEvent, _disableSwipeFn, { passive: false });
|
|
29360
29939
|
swipeEnabled = false;
|
|
29361
29940
|
}
|
|
29362
29941
|
},
|
|
@@ -29840,6 +30419,29 @@ Object.defineProperty(device, "sound", {
|
|
|
29840
30419
|
|
|
29841
30420
|
var device$1 = device;
|
|
29842
30421
|
|
|
30422
|
+
/**
|
|
30423
|
+
* Hash map of GLSL data types to WebGL Uniform methods
|
|
30424
|
+
* @ignore
|
|
30425
|
+
*/
|
|
30426
|
+
const fnHash = {
|
|
30427
|
+
"bool" : "1i",
|
|
30428
|
+
"int" : "1i",
|
|
30429
|
+
"float" : "1f",
|
|
30430
|
+
"vec2" : "2fv",
|
|
30431
|
+
"vec3" : "3fv",
|
|
30432
|
+
"vec4" : "4fv",
|
|
30433
|
+
"bvec2" : "2iv",
|
|
30434
|
+
"bvec3" : "3iv",
|
|
30435
|
+
"bvec4" : "4iv",
|
|
30436
|
+
"ivec2" : "2iv",
|
|
30437
|
+
"ivec3" : "3iv",
|
|
30438
|
+
"ivec4" : "4iv",
|
|
30439
|
+
"mat2" : "Matrix2fv",
|
|
30440
|
+
"mat3" : "Matrix3fv",
|
|
30441
|
+
"mat4" : "Matrix4fv",
|
|
30442
|
+
"sampler2D" : "1i"
|
|
30443
|
+
};
|
|
30444
|
+
|
|
29843
30445
|
/**
|
|
29844
30446
|
* @ignore
|
|
29845
30447
|
*/
|
|
@@ -29890,7 +30492,7 @@ function extractUniforms(gl, shader) {
|
|
|
29890
30492
|
*/
|
|
29891
30493
|
return function (val) {
|
|
29892
30494
|
var fnv = fn;
|
|
29893
|
-
if (val.length && fn.
|
|
30495
|
+
if (val.length && fn.slice(-1) !== "v") {
|
|
29894
30496
|
fnv += "v";
|
|
29895
30497
|
}
|
|
29896
30498
|
gl[fnv](locations[name], val);
|
|
@@ -29903,6 +30505,7 @@ function extractUniforms(gl, shader) {
|
|
|
29903
30505
|
|
|
29904
30506
|
return uniforms;
|
|
29905
30507
|
}
|
|
30508
|
+
|
|
29906
30509
|
/**
|
|
29907
30510
|
* @ignore
|
|
29908
30511
|
*/
|
|
@@ -29919,6 +30522,7 @@ function extractAttributes(gl, shader) {
|
|
|
29919
30522
|
|
|
29920
30523
|
return attributes;
|
|
29921
30524
|
}
|
|
30525
|
+
|
|
29922
30526
|
/**
|
|
29923
30527
|
* @ignore
|
|
29924
30528
|
*/
|
|
@@ -29977,29 +30581,6 @@ function compileProgram(gl, vertex, fragment, attributes) {
|
|
|
29977
30581
|
return program;
|
|
29978
30582
|
}
|
|
29979
30583
|
|
|
29980
|
-
/**
|
|
29981
|
-
* Hash map of GLSL data types to WebGL Uniform methods
|
|
29982
|
-
* @ignore
|
|
29983
|
-
*/
|
|
29984
|
-
var fnHash = {
|
|
29985
|
-
"bool" : "1i",
|
|
29986
|
-
"int" : "1i",
|
|
29987
|
-
"float" : "1f",
|
|
29988
|
-
"vec2" : "2fv",
|
|
29989
|
-
"vec3" : "3fv",
|
|
29990
|
-
"vec4" : "4fv",
|
|
29991
|
-
"bvec2" : "2iv",
|
|
29992
|
-
"bvec3" : "3iv",
|
|
29993
|
-
"bvec4" : "4iv",
|
|
29994
|
-
"ivec2" : "2iv",
|
|
29995
|
-
"ivec3" : "3iv",
|
|
29996
|
-
"ivec4" : "4iv",
|
|
29997
|
-
"mat2" : "Matrix2fv",
|
|
29998
|
-
"mat3" : "Matrix3fv",
|
|
29999
|
-
"mat4" : "Matrix4fv",
|
|
30000
|
-
"sampler2D" : "1i"
|
|
30001
|
-
};
|
|
30002
|
-
|
|
30003
30584
|
/**
|
|
30004
30585
|
* set precision for the fiven shader source
|
|
30005
30586
|
* won't do anything if the precision is already specified
|
|
@@ -30011,6 +30592,7 @@ function setPrecision(src, precision) {
|
|
|
30011
30592
|
}
|
|
30012
30593
|
return src;
|
|
30013
30594
|
}
|
|
30595
|
+
|
|
30014
30596
|
/**
|
|
30015
30597
|
* clean the given source from space, comments, etc...
|
|
30016
30598
|
* @ignore
|
|
@@ -30027,6 +30609,7 @@ function minify(src) {
|
|
|
30027
30609
|
|
|
30028
30610
|
return src;
|
|
30029
30611
|
}
|
|
30612
|
+
|
|
30030
30613
|
/**
|
|
30031
30614
|
* @classdesc
|
|
30032
30615
|
* a base GL Shader object
|
|
@@ -30170,6 +30753,30 @@ class GLShader {
|
|
|
30170
30753
|
}
|
|
30171
30754
|
}
|
|
30172
30755
|
|
|
30756
|
+
/**
|
|
30757
|
+
* activate the given vertex attribute for this shader
|
|
30758
|
+
* @name setVertexAttributes
|
|
30759
|
+
* @memberof GLShader
|
|
30760
|
+
* @function
|
|
30761
|
+
* @param {WebGLRenderingContext} gl the current WebGL rendering context
|
|
30762
|
+
* @param {object[]} attributes an array of vertex attributes
|
|
30763
|
+
* @param {number} vertexByteSize the size of a single vertex in bytes
|
|
30764
|
+
*/
|
|
30765
|
+
setVertexAttributes(gl, attributes, vertexByteSize) {
|
|
30766
|
+
// set the vertex attributes
|
|
30767
|
+
for (var index = 0; index < attributes.length; ++index) {
|
|
30768
|
+
var element = attributes[index];
|
|
30769
|
+
var location = this.getAttribLocation(element.name);
|
|
30770
|
+
|
|
30771
|
+
if (location !== -1) {
|
|
30772
|
+
gl.enableVertexAttribArray(location);
|
|
30773
|
+
gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexByteSize, element.offset);
|
|
30774
|
+
} else {
|
|
30775
|
+
gl.disableVertexAttribArray(index);
|
|
30776
|
+
}
|
|
30777
|
+
}
|
|
30778
|
+
}
|
|
30779
|
+
|
|
30173
30780
|
/**
|
|
30174
30781
|
* destroy this shader objects resources (program, attributes, uniforms)
|
|
30175
30782
|
* @name destroy
|
|
@@ -30704,20 +31311,7 @@ class WebGLCompositor {
|
|
|
30704
31311
|
this.activeShader = shader;
|
|
30705
31312
|
this.activeShader.bind();
|
|
30706
31313
|
this.activeShader.setUniform("uProjectionMatrix", this.renderer.projectionMatrix);
|
|
30707
|
-
|
|
30708
|
-
// set the vertex attributes
|
|
30709
|
-
for (var index = 0; index < this.attributes.length; ++index) {
|
|
30710
|
-
var gl = this.gl;
|
|
30711
|
-
var element = this.attributes[index];
|
|
30712
|
-
var location = this.activeShader.getAttribLocation(element.name);
|
|
30713
|
-
|
|
30714
|
-
if (location !== -1) {
|
|
30715
|
-
gl.enableVertexAttribArray(location);
|
|
30716
|
-
gl.vertexAttribPointer(location, element.size, element.type, element.normalized, this.vertexByteSize, element.offset);
|
|
30717
|
-
} else {
|
|
30718
|
-
gl.disableVertexAttribArray(index);
|
|
30719
|
-
}
|
|
30720
|
-
}
|
|
31314
|
+
this.activeShader.setVertexAttributes(this.gl, this.attributes, this.vertexByteSize);
|
|
30721
31315
|
}
|
|
30722
31316
|
}
|
|
30723
31317
|
|
|
@@ -30891,7 +31485,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30891
31485
|
/**
|
|
30892
31486
|
* The WebGL version used by this renderer (1 or 2)
|
|
30893
31487
|
* @name WebGLVersion
|
|
30894
|
-
* @memberof WebGLRenderer
|
|
31488
|
+
* @memberof WebGLRenderer#
|
|
30895
31489
|
* @type {number}
|
|
30896
31490
|
* @default 1
|
|
30897
31491
|
* @readonly
|
|
@@ -30901,7 +31495,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30901
31495
|
/**
|
|
30902
31496
|
* The vendor string of the underlying graphics driver.
|
|
30903
31497
|
* @name GPUVendor
|
|
30904
|
-
* @memberof WebGLRenderer
|
|
31498
|
+
* @memberof WebGLRenderer#
|
|
30905
31499
|
* @type {string}
|
|
30906
31500
|
* @default null
|
|
30907
31501
|
* @readonly
|
|
@@ -30911,7 +31505,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30911
31505
|
/**
|
|
30912
31506
|
* The renderer string of the underlying graphics driver.
|
|
30913
31507
|
* @name GPURenderer
|
|
30914
|
-
* @memberof WebGLRenderer
|
|
31508
|
+
* @memberof WebGLRenderer#
|
|
30915
31509
|
* @type {string}
|
|
30916
31510
|
* @default null
|
|
30917
31511
|
* @readonly
|
|
@@ -30921,7 +31515,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30921
31515
|
/**
|
|
30922
31516
|
* The WebGL context
|
|
30923
31517
|
* @name gl
|
|
30924
|
-
* @memberof WebGLRenderer
|
|
31518
|
+
* @memberof WebGLRenderer#
|
|
30925
31519
|
* type {WebGLRenderingContext}
|
|
30926
31520
|
*/
|
|
30927
31521
|
this.context = this.gl = this.getContextGL(this.getScreenCanvas(), options.transparent);
|
|
@@ -30929,7 +31523,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30929
31523
|
/**
|
|
30930
31524
|
* Maximum number of texture unit supported under the current context
|
|
30931
31525
|
* @name maxTextures
|
|
30932
|
-
* @memberof WebGLRenderer
|
|
31526
|
+
* @memberof WebGLRenderer#
|
|
30933
31527
|
* @type {number}
|
|
30934
31528
|
* @readonly
|
|
30935
31529
|
*/
|
|
@@ -30955,16 +31549,6 @@ class WebGLRenderer extends Renderer {
|
|
|
30955
31549
|
*/
|
|
30956
31550
|
this._blendStack = [];
|
|
30957
31551
|
|
|
30958
|
-
/**
|
|
30959
|
-
* @ignore
|
|
30960
|
-
*/
|
|
30961
|
-
this._glPoints = [
|
|
30962
|
-
new Vector2d(),
|
|
30963
|
-
new Vector2d(),
|
|
30964
|
-
new Vector2d(),
|
|
30965
|
-
new Vector2d()
|
|
30966
|
-
];
|
|
30967
|
-
|
|
30968
31552
|
/**
|
|
30969
31553
|
* The current transformation matrix used for transformations on the overall scene
|
|
30970
31554
|
* @name currentTransform
|
|
@@ -30984,7 +31568,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30984
31568
|
/**
|
|
30985
31569
|
* The list of active compositors
|
|
30986
31570
|
* @name compositors
|
|
30987
|
-
* @type {Map}
|
|
31571
|
+
* @type {Map<WebGLCompositor>}
|
|
30988
31572
|
* @memberof WebGLRenderer#
|
|
30989
31573
|
*/
|
|
30990
31574
|
this.compositors = new Map();
|
|
@@ -31198,10 +31782,10 @@ class WebGLRenderer extends Renderer {
|
|
|
31198
31782
|
if (color instanceof Color) {
|
|
31199
31783
|
glArray = color.toArray();
|
|
31200
31784
|
} else {
|
|
31201
|
-
var _color = pull("me.Color");
|
|
31785
|
+
var _color = pool$1.pull("me.Color");
|
|
31202
31786
|
// reuse temporary the renderer default color object
|
|
31203
31787
|
glArray = _color.parseCSS(color).toArray();
|
|
31204
|
-
push(_color);
|
|
31788
|
+
pool$1.push(_color);
|
|
31205
31789
|
}
|
|
31206
31790
|
// clear gl context with the specified color
|
|
31207
31791
|
this.currentCompositor.clearColor(glArray[0], glArray[1], glArray[2], (opaque === true) ? 1.0 : glArray[3]);
|
|
@@ -31493,8 +32077,8 @@ class WebGLRenderer extends Renderer {
|
|
|
31493
32077
|
this.setBlendMode(this._blendStack.pop());
|
|
31494
32078
|
|
|
31495
32079
|
// recycle objects
|
|
31496
|
-
push(color);
|
|
31497
|
-
push(matrix);
|
|
32080
|
+
pool$1.push(color);
|
|
32081
|
+
pool$1.push(matrix);
|
|
31498
32082
|
}
|
|
31499
32083
|
|
|
31500
32084
|
if (this._scissorStack.length !== 0) {
|
|
@@ -31571,6 +32155,17 @@ class WebGLRenderer extends Renderer {
|
|
|
31571
32155
|
this.currentColor.alpha = alpha;
|
|
31572
32156
|
}
|
|
31573
32157
|
|
|
32158
|
+
/**
|
|
32159
|
+
* Return the global alpha
|
|
32160
|
+
* @name getGlobalAlpha
|
|
32161
|
+
* @memberof WebGLRenderer.prototype
|
|
32162
|
+
* @function
|
|
32163
|
+
* @returns {number} global alpha value
|
|
32164
|
+
*/
|
|
32165
|
+
getGlobalAlpha() {
|
|
32166
|
+
return this.currentColor.alpha;
|
|
32167
|
+
}
|
|
32168
|
+
|
|
31574
32169
|
/**
|
|
31575
32170
|
* Set the current fill & stroke style color.
|
|
31576
32171
|
* By default, or upon reset, the value is set to #000000.
|
|
@@ -31609,34 +32204,18 @@ class WebGLRenderer extends Renderer {
|
|
|
31609
32204
|
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
31610
32205
|
* @param {boolean} [fill=false]
|
|
31611
32206
|
*/
|
|
31612
|
-
strokeArc(x, y, radius, start, end, antiClockwise = false, fill) {
|
|
31613
|
-
if (
|
|
31614
|
-
|
|
32207
|
+
strokeArc(x, y, radius, start, end, antiClockwise = false, fill = false) {
|
|
32208
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32209
|
+
// Fast path: don't draw fully transparent
|
|
32210
|
+
return;
|
|
32211
|
+
}
|
|
32212
|
+
this.path2D.beginPath();
|
|
32213
|
+
this.path2D.arc(x, y, radius, start, end, antiClockwise);
|
|
32214
|
+
if (fill === false) {
|
|
32215
|
+
this.currentCompositor.drawVertices(this.gl.LINE_STRIP, this.path2D.points);
|
|
31615
32216
|
} else {
|
|
31616
|
-
|
|
31617
|
-
|
|
31618
|
-
var i, len = Math.floor(24 * Math.sqrt(radius * 2));
|
|
31619
|
-
var theta = (end - start) / (len * 2);
|
|
31620
|
-
var theta2 = theta * 2;
|
|
31621
|
-
var cos_theta = Math.cos(theta);
|
|
31622
|
-
var sin_theta = Math.sin(theta);
|
|
31623
|
-
|
|
31624
|
-
// Grow internal points buffer if necessary
|
|
31625
|
-
for (i = points.length; i < len + 1; i++) {
|
|
31626
|
-
points.push(new Vector2d());
|
|
31627
|
-
}
|
|
31628
|
-
|
|
31629
|
-
// calculate and draw all segments
|
|
31630
|
-
for (i = 0; i < len; i++) {
|
|
31631
|
-
var angle = ((theta) + start + (theta2 * i));
|
|
31632
|
-
var cos = Math.cos(angle);
|
|
31633
|
-
var sin = -Math.sin(angle);
|
|
31634
|
-
|
|
31635
|
-
points[i].x = x + (((cos_theta * cos) + (sin_theta * sin)) * radius);
|
|
31636
|
-
points[i].y = y + (((cos_theta * -sin) + (sin_theta * cos)) * radius);
|
|
31637
|
-
}
|
|
31638
|
-
// batch draw all lines
|
|
31639
|
-
this.currentCompositor.drawVertices(this.gl.LINE_STRIP, points, len);
|
|
32217
|
+
this.path2D.closePath();
|
|
32218
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
31640
32219
|
}
|
|
31641
32220
|
}
|
|
31642
32221
|
|
|
@@ -31652,35 +32231,8 @@ class WebGLRenderer extends Renderer {
|
|
|
31652
32231
|
* @param {number} end end angle in radians
|
|
31653
32232
|
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
31654
32233
|
*/
|
|
31655
|
-
fillArc(x, y, radius, start, end
|
|
31656
|
-
|
|
31657
|
-
var points = this._glPoints;
|
|
31658
|
-
var i, index = 0;
|
|
31659
|
-
var len = Math.floor(24 * Math.sqrt(radius * 2));
|
|
31660
|
-
var theta = (end - start) / (len * 2);
|
|
31661
|
-
var theta2 = theta * 2;
|
|
31662
|
-
var cos_theta = Math.cos(theta);
|
|
31663
|
-
var sin_theta = Math.sin(theta);
|
|
31664
|
-
|
|
31665
|
-
// Grow internal points buffer if necessary
|
|
31666
|
-
for (i = points.length; i < len * 2; i++) {
|
|
31667
|
-
points.push(new Vector2d());
|
|
31668
|
-
}
|
|
31669
|
-
|
|
31670
|
-
// calculate and draw all segments
|
|
31671
|
-
for (i = 0; i < len - 1; i++) {
|
|
31672
|
-
var angle = ((theta) + start + (theta2 * i));
|
|
31673
|
-
var cos = Math.cos(angle);
|
|
31674
|
-
var sin = -Math.sin(angle);
|
|
31675
|
-
|
|
31676
|
-
points[index++].set(x, y);
|
|
31677
|
-
points[index++].set(
|
|
31678
|
-
x - (((cos_theta * cos) + (sin_theta * sin)) * radius),
|
|
31679
|
-
y - (((cos_theta * -sin) + (sin_theta * cos)) * radius)
|
|
31680
|
-
);
|
|
31681
|
-
}
|
|
31682
|
-
// batch draw all triangles
|
|
31683
|
-
this.currentCompositor.drawVertices(this.gl.TRIANGLE_STRIP, points, index);
|
|
32234
|
+
fillArc(x, y, radius, start, end, antiClockwise = false) {
|
|
32235
|
+
this.strokeArc(x, y, radius, start, end, antiClockwise, true);
|
|
31684
32236
|
}
|
|
31685
32237
|
|
|
31686
32238
|
/**
|
|
@@ -31695,28 +32247,17 @@ class WebGLRenderer extends Renderer {
|
|
|
31695
32247
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
31696
32248
|
*/
|
|
31697
32249
|
strokeEllipse(x, y, w, h, fill = false) {
|
|
31698
|
-
if (
|
|
31699
|
-
|
|
32250
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32251
|
+
// Fast path: don't draw fully transparent
|
|
32252
|
+
return;
|
|
32253
|
+
}
|
|
32254
|
+
this.path2D.beginPath();
|
|
32255
|
+
this.path2D.ellipse(x, y, w, h, 0, 0, 360);
|
|
32256
|
+
this.path2D.closePath();
|
|
32257
|
+
if (fill === false) {
|
|
32258
|
+
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, this.path2D.points);
|
|
31700
32259
|
} else {
|
|
31701
|
-
|
|
31702
|
-
var len = Math.floor(24 * Math.sqrt(w)) ||
|
|
31703
|
-
Math.floor(12 * Math.sqrt(w + h));
|
|
31704
|
-
var segment = (TAU) / len;
|
|
31705
|
-
var points = this._glPoints,
|
|
31706
|
-
i;
|
|
31707
|
-
|
|
31708
|
-
// Grow internal points buffer if necessary
|
|
31709
|
-
for (i = points.length; i < len; i++) {
|
|
31710
|
-
points.push(new Vector2d());
|
|
31711
|
-
}
|
|
31712
|
-
|
|
31713
|
-
// calculate and draw all segments
|
|
31714
|
-
for (i = 0; i < len; i++) {
|
|
31715
|
-
points[i].x = x + (Math.sin(segment * -i) * w);
|
|
31716
|
-
points[i].y = y + (Math.cos(segment * -i) * h);
|
|
31717
|
-
}
|
|
31718
|
-
// batch draw all lines
|
|
31719
|
-
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, points, len);
|
|
32260
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
31720
32261
|
}
|
|
31721
32262
|
}
|
|
31722
32263
|
|
|
@@ -31731,28 +32272,7 @@ class WebGLRenderer extends Renderer {
|
|
|
31731
32272
|
* @param {number} h vertical radius of the ellipse
|
|
31732
32273
|
*/
|
|
31733
32274
|
fillEllipse(x, y, w, h) {
|
|
31734
|
-
|
|
31735
|
-
var len = Math.floor(24 * Math.sqrt(w)) ||
|
|
31736
|
-
Math.floor(12 * Math.sqrt(w + h));
|
|
31737
|
-
var segment = (TAU) / len;
|
|
31738
|
-
var points = this._glPoints;
|
|
31739
|
-
var index = 0, i;
|
|
31740
|
-
|
|
31741
|
-
// Grow internal points buffer if necessary
|
|
31742
|
-
for (i = points.length; i < (len + 1) * 2; i++) {
|
|
31743
|
-
points.push(new Vector2d());
|
|
31744
|
-
}
|
|
31745
|
-
|
|
31746
|
-
// draw all vertices vertex coordinates
|
|
31747
|
-
for (i = 0; i < len + 1; i++) {
|
|
31748
|
-
points[index++].set(x, y);
|
|
31749
|
-
points[index++].set(
|
|
31750
|
-
x + (Math.sin(segment * i) * w),
|
|
31751
|
-
y + (Math.cos(segment * i) * h)
|
|
31752
|
-
);
|
|
31753
|
-
}
|
|
31754
|
-
// batch draw all triangles
|
|
31755
|
-
this.currentCompositor.drawVertices(this.gl.TRIANGLE_STRIP, points, index);
|
|
32275
|
+
this.strokeEllipse(x, y, w, h, false);
|
|
31756
32276
|
}
|
|
31757
32277
|
|
|
31758
32278
|
/**
|
|
@@ -31766,12 +32286,14 @@ class WebGLRenderer extends Renderer {
|
|
|
31766
32286
|
* @param {number} endY the end y coordinate
|
|
31767
32287
|
*/
|
|
31768
32288
|
strokeLine(startX, startY, endX, endY) {
|
|
31769
|
-
|
|
31770
|
-
|
|
31771
|
-
|
|
31772
|
-
|
|
31773
|
-
|
|
31774
|
-
this.
|
|
32289
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32290
|
+
// Fast path: don't draw fully transparent
|
|
32291
|
+
return;
|
|
32292
|
+
}
|
|
32293
|
+
this.path2D.beginPath();
|
|
32294
|
+
this.path2D.moveTo(startX, startY);
|
|
32295
|
+
this.path2D.lineTo(endX, endY);
|
|
32296
|
+
this.currentCompositor.drawVertices(this.gl.LINE_STRIP, this.path2D.points);
|
|
31775
32297
|
}
|
|
31776
32298
|
|
|
31777
32299
|
|
|
@@ -31798,25 +32320,27 @@ class WebGLRenderer extends Renderer {
|
|
|
31798
32320
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
31799
32321
|
*/
|
|
31800
32322
|
strokePolygon(poly, fill = false) {
|
|
31801
|
-
if (
|
|
31802
|
-
|
|
32323
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32324
|
+
// Fast path: don't draw fully transparent
|
|
32325
|
+
return;
|
|
32326
|
+
}
|
|
32327
|
+
this.translate(poly.pos.x, poly.pos.y);
|
|
32328
|
+
this.path2D.beginPath();
|
|
32329
|
+
this.path2D.moveTo(poly.points[0].x, poly.points[0].y);
|
|
32330
|
+
var point;
|
|
32331
|
+
for (var i = 1; i < poly.points.length; i++) {
|
|
32332
|
+
point = poly.points[i];
|
|
32333
|
+
this.path2D.lineTo(point.x, point.y);
|
|
32334
|
+
}
|
|
32335
|
+
this.path2D.lineTo(poly.points[0].x, poly.points[0].y);
|
|
32336
|
+
this.path2D.closePath();
|
|
32337
|
+
if (fill === false) {
|
|
32338
|
+
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, this.path2D.points);
|
|
31803
32339
|
} else {
|
|
31804
|
-
|
|
31805
|
-
|
|
31806
|
-
i;
|
|
31807
|
-
|
|
31808
|
-
// Grow internal points buffer if necessary
|
|
31809
|
-
for (i = points.length; i < len; i++) {
|
|
31810
|
-
points.push(new Vector2d());
|
|
31811
|
-
}
|
|
31812
|
-
|
|
31813
|
-
// calculate and draw all segments
|
|
31814
|
-
for (i = 0; i < len; i++) {
|
|
31815
|
-
points[i].x = poly.pos.x + poly.points[i].x;
|
|
31816
|
-
points[i].y = poly.pos.y + poly.points[i].y;
|
|
31817
|
-
}
|
|
31818
|
-
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, points, len);
|
|
32340
|
+
// draw all triangles
|
|
32341
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
31819
32342
|
}
|
|
32343
|
+
this.translate(-poly.pos.x, -poly.pos.y);
|
|
31820
32344
|
}
|
|
31821
32345
|
|
|
31822
32346
|
/**
|
|
@@ -31827,24 +32351,7 @@ class WebGLRenderer extends Renderer {
|
|
|
31827
32351
|
* @param {Polygon} poly the shape to draw
|
|
31828
32352
|
*/
|
|
31829
32353
|
fillPolygon(poly) {
|
|
31830
|
-
|
|
31831
|
-
var glPoints = this._glPoints;
|
|
31832
|
-
var indices = poly.getIndices();
|
|
31833
|
-
var x = poly.pos.x, y = poly.pos.y;
|
|
31834
|
-
var i;
|
|
31835
|
-
|
|
31836
|
-
// Grow internal points buffer if necessary
|
|
31837
|
-
for (i = glPoints.length; i < indices.length; i++) {
|
|
31838
|
-
glPoints.push(new Vector2d());
|
|
31839
|
-
}
|
|
31840
|
-
|
|
31841
|
-
// calculate all vertices
|
|
31842
|
-
for (i = 0; i < indices.length; i++ ) {
|
|
31843
|
-
glPoints[i].set(x + points[indices[i]].x, y + points[indices[i]].y);
|
|
31844
|
-
}
|
|
31845
|
-
|
|
31846
|
-
// draw all triangle
|
|
31847
|
-
this.currentCompositor.drawVertices(this.gl.TRIANGLES, glPoints, indices.length);
|
|
32354
|
+
this.strokePolygon(poly, true);
|
|
31848
32355
|
}
|
|
31849
32356
|
|
|
31850
32357
|
/**
|
|
@@ -31859,19 +32366,16 @@ class WebGLRenderer extends Renderer {
|
|
|
31859
32366
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
31860
32367
|
*/
|
|
31861
32368
|
strokeRect(x, y, width, height, fill = false) {
|
|
31862
|
-
if (
|
|
31863
|
-
|
|
32369
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32370
|
+
// Fast path: don't draw fully transparent
|
|
32371
|
+
return;
|
|
32372
|
+
}
|
|
32373
|
+
this.path2D.beginPath();
|
|
32374
|
+
this.path2D.rect(x, y, width, height);
|
|
32375
|
+
if (fill === false) {
|
|
32376
|
+
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, this.path2D.points);
|
|
31864
32377
|
} else {
|
|
31865
|
-
|
|
31866
|
-
points[0].x = x;
|
|
31867
|
-
points[0].y = y;
|
|
31868
|
-
points[1].x = x + width;
|
|
31869
|
-
points[1].y = y;
|
|
31870
|
-
points[2].x = x + width;
|
|
31871
|
-
points[2].y = y + height;
|
|
31872
|
-
points[3].x = x;
|
|
31873
|
-
points[3].y = y + height;
|
|
31874
|
-
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, points, 4);
|
|
32378
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
31875
32379
|
}
|
|
31876
32380
|
}
|
|
31877
32381
|
|
|
@@ -31886,16 +32390,49 @@ class WebGLRenderer extends Renderer {
|
|
|
31886
32390
|
* @param {number} height
|
|
31887
32391
|
*/
|
|
31888
32392
|
fillRect(x, y, width, height) {
|
|
31889
|
-
|
|
31890
|
-
|
|
31891
|
-
|
|
31892
|
-
|
|
31893
|
-
|
|
31894
|
-
|
|
31895
|
-
|
|
31896
|
-
|
|
31897
|
-
|
|
31898
|
-
|
|
32393
|
+
this.strokeRect(x, y, width, height, true);
|
|
32394
|
+
}
|
|
32395
|
+
|
|
32396
|
+
/**
|
|
32397
|
+
* Stroke a rounded rectangle at the specified coordinates
|
|
32398
|
+
* @name strokeRoundRect
|
|
32399
|
+
* @memberof WebGLRenderer.prototype
|
|
32400
|
+
* @function
|
|
32401
|
+
* @param {number} x
|
|
32402
|
+
* @param {number} y
|
|
32403
|
+
* @param {number} width
|
|
32404
|
+
* @param {number} height
|
|
32405
|
+
* @param {number} radius
|
|
32406
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
32407
|
+
*/
|
|
32408
|
+
strokeRoundRect(x, y, width, height, radius, fill = false) {
|
|
32409
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32410
|
+
// Fast path: don't draw fully transparent
|
|
32411
|
+
return;
|
|
32412
|
+
}
|
|
32413
|
+
this.path2D.beginPath();
|
|
32414
|
+
this.path2D.roundRect(x, y, width, height, radius);
|
|
32415
|
+
if (fill === false) {
|
|
32416
|
+
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, this.path2D.points);
|
|
32417
|
+
} else {
|
|
32418
|
+
this.path2D.closePath();
|
|
32419
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
32420
|
+
}
|
|
32421
|
+
}
|
|
32422
|
+
|
|
32423
|
+
/**
|
|
32424
|
+
* Draw a rounded filled rectangle at the specified coordinates
|
|
32425
|
+
* @name fillRoundRect
|
|
32426
|
+
* @memberof WebGLRenderer.prototype
|
|
32427
|
+
* @function
|
|
32428
|
+
* @param {number} x
|
|
32429
|
+
* @param {number} y
|
|
32430
|
+
* @param {number} width
|
|
32431
|
+
* @param {number} height
|
|
32432
|
+
* @param {number} radius
|
|
32433
|
+
*/
|
|
32434
|
+
fillRoundRect(x, y, width, height, radius) {
|
|
32435
|
+
this.strokeRoundRect(x, y, width, height, radius, true);
|
|
31899
32436
|
}
|
|
31900
32437
|
|
|
31901
32438
|
/**
|
|
@@ -32005,7 +32542,7 @@ class WebGLRenderer extends Renderer {
|
|
|
32005
32542
|
* @name setMask
|
|
32006
32543
|
* @memberof WebGLRenderer.prototype
|
|
32007
32544
|
* @function
|
|
32008
|
-
* @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
32545
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
32009
32546
|
*/
|
|
32010
32547
|
setMask(mask) {
|
|
32011
32548
|
var gl = this.gl;
|
|
@@ -32611,14 +33148,14 @@ var utils = {
|
|
|
32611
33148
|
// never cache if a url is passed as parameter
|
|
32612
33149
|
var index = url.indexOf("#");
|
|
32613
33150
|
if (index !== -1) {
|
|
32614
|
-
url = url.
|
|
33151
|
+
url = url.slice(index, url.length);
|
|
32615
33152
|
} else {
|
|
32616
33153
|
return hash;
|
|
32617
33154
|
}
|
|
32618
33155
|
}
|
|
32619
33156
|
|
|
32620
33157
|
// parse the url
|
|
32621
|
-
url.
|
|
33158
|
+
url.slice(1).split("&").filter(function (value) {
|
|
32622
33159
|
return (value !== "");
|
|
32623
33160
|
}).forEach(function (value) {
|
|
32624
33161
|
var kv = value.split("=");
|
|
@@ -32964,6 +33501,240 @@ if (!requestAnimationFrame || !cancelAnimationFrame) {
|
|
|
32964
33501
|
globalThis.cancelAnimationFrame = cancelAnimationFrame;
|
|
32965
33502
|
}
|
|
32966
33503
|
|
|
33504
|
+
/*
|
|
33505
|
+
* based on https://www.npmjs.com/package/canvas-roundrect-polyfill
|
|
33506
|
+
* @version 0.0.1
|
|
33507
|
+
*/
|
|
33508
|
+
(() => {
|
|
33509
|
+
|
|
33510
|
+
/** @ignore */
|
|
33511
|
+
function roundRect(x, y, w, h, radii) {
|
|
33512
|
+
|
|
33513
|
+
if (!([x, y, w, h].every((input) => Number.isFinite(input)))) {
|
|
33514
|
+
|
|
33515
|
+
return;
|
|
33516
|
+
|
|
33517
|
+
}
|
|
33518
|
+
|
|
33519
|
+
radii = parseRadiiArgument(radii);
|
|
33520
|
+
|
|
33521
|
+
let upperLeft, upperRight, lowerRight, lowerLeft;
|
|
33522
|
+
|
|
33523
|
+
if (radii.length === 4) {
|
|
33524
|
+
|
|
33525
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
33526
|
+
upperRight = toCornerPoint(radii[1]);
|
|
33527
|
+
lowerRight = toCornerPoint(radii[2]);
|
|
33528
|
+
lowerLeft = toCornerPoint(radii[3]);
|
|
33529
|
+
|
|
33530
|
+
} else if (radii.length === 3) {
|
|
33531
|
+
|
|
33532
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
33533
|
+
upperRight = toCornerPoint(radii[1]);
|
|
33534
|
+
lowerLeft = toCornerPoint(radii[1]);
|
|
33535
|
+
lowerRight = toCornerPoint(radii[2]);
|
|
33536
|
+
|
|
33537
|
+
} else if (radii.length === 2) {
|
|
33538
|
+
|
|
33539
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
33540
|
+
lowerRight = toCornerPoint(radii[0]);
|
|
33541
|
+
upperRight = toCornerPoint(radii[1]);
|
|
33542
|
+
lowerLeft = toCornerPoint(radii[1]);
|
|
33543
|
+
|
|
33544
|
+
} else if (radii.length === 1) {
|
|
33545
|
+
|
|
33546
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
33547
|
+
upperRight = toCornerPoint(radii[0]);
|
|
33548
|
+
lowerRight = toCornerPoint(radii[0]);
|
|
33549
|
+
lowerLeft = toCornerPoint(radii[0]);
|
|
33550
|
+
|
|
33551
|
+
} else {
|
|
33552
|
+
|
|
33553
|
+
throw new Error(radii.length + " is not a valid size for radii sequence.");
|
|
33554
|
+
|
|
33555
|
+
}
|
|
33556
|
+
|
|
33557
|
+
const corners = [upperLeft, upperRight, lowerRight, lowerLeft];
|
|
33558
|
+
const negativeCorner = corners.find(({x, y}) => x < 0 || y < 0);
|
|
33559
|
+
//const negativeValue = negativeCorner?.x < 0 ? negativeCorner.x : negativeCorner?.y
|
|
33560
|
+
|
|
33561
|
+
if (corners.some(({x, y}) => !Number.isFinite(x) || !Number.isFinite(y))) {
|
|
33562
|
+
|
|
33563
|
+
return;
|
|
33564
|
+
|
|
33565
|
+
}
|
|
33566
|
+
|
|
33567
|
+
if (negativeCorner) {
|
|
33568
|
+
|
|
33569
|
+
throw new Error("Radius value " + negativeCorner + " is negative.");
|
|
33570
|
+
|
|
33571
|
+
}
|
|
33572
|
+
|
|
33573
|
+
fixOverlappingCorners(corners);
|
|
33574
|
+
|
|
33575
|
+
if (w < 0 && h < 0) {
|
|
33576
|
+
|
|
33577
|
+
this.moveTo(x - upperLeft.x, y);
|
|
33578
|
+
this.ellipse(x + w + upperRight.x, y - upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI * 1.5, -Math.PI);
|
|
33579
|
+
this.ellipse(x + w + lowerRight.x, y + h + lowerRight.y, lowerRight.x, lowerRight.y, 0, -Math.PI, -Math.PI / 2);
|
|
33580
|
+
this.ellipse(x - lowerLeft.x, y + h + lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, -Math.PI / 2, 0);
|
|
33581
|
+
this.ellipse(x - upperLeft.x, y - upperLeft.y, upperLeft.x, upperLeft.y, 0, 0, -Math.PI / 2);
|
|
33582
|
+
|
|
33583
|
+
} else if (w < 0) {
|
|
33584
|
+
|
|
33585
|
+
this.moveTo(x - upperLeft.x, y);
|
|
33586
|
+
this.ellipse(x + w + upperRight.x, y + upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI / 2, -Math.PI, 1);
|
|
33587
|
+
this.ellipse(x + w + lowerRight.x, y + h - lowerRight.y, lowerRight.x, lowerRight.y, 0, -Math.PI, -Math.PI * 1.5, 1);
|
|
33588
|
+
this.ellipse(x - lowerLeft.x, y + h - lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, Math.PI / 2, 0, 1);
|
|
33589
|
+
this.ellipse(x - upperLeft.x, y + upperLeft.y, upperLeft.x, upperLeft.y, 0, 0, -Math.PI / 2, 1);
|
|
33590
|
+
|
|
33591
|
+
} else if (h < 0) {
|
|
33592
|
+
|
|
33593
|
+
this.moveTo(x + upperLeft.x, y);
|
|
33594
|
+
this.ellipse(x + w - upperRight.x, y - upperRight.y, upperRight.x, upperRight.y, 0, Math.PI / 2, 0, 1);
|
|
33595
|
+
this.ellipse(x + w - lowerRight.x, y + h + lowerRight.y, lowerRight.x, lowerRight.y, 0, 0, -Math.PI / 2, 1);
|
|
33596
|
+
this.ellipse(x + lowerLeft.x, y + h + lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, -Math.PI / 2, -Math.PI, 1);
|
|
33597
|
+
this.ellipse(x + upperLeft.x, y - upperLeft.y, upperLeft.x, upperLeft.y, 0, -Math.PI, -Math.PI * 1.5, 1);
|
|
33598
|
+
|
|
33599
|
+
} else {
|
|
33600
|
+
|
|
33601
|
+
this.moveTo(x + upperLeft.x, y);
|
|
33602
|
+
this.ellipse(x + w - upperRight.x, y + upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI / 2, 0);
|
|
33603
|
+
this.ellipse(x + w - lowerRight.x, y + h - lowerRight.y, lowerRight.x, lowerRight.y, 0, 0, Math.PI / 2);
|
|
33604
|
+
this.ellipse(x + lowerLeft.x, y + h - lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, Math.PI / 2, Math.PI);
|
|
33605
|
+
this.ellipse(x + upperLeft.x, y + upperLeft.y, upperLeft.x, upperLeft.y, 0, Math.PI, Math.PI * 1.5);
|
|
33606
|
+
|
|
33607
|
+
}
|
|
33608
|
+
|
|
33609
|
+
this.closePath();
|
|
33610
|
+
this.moveTo(x, y);
|
|
33611
|
+
|
|
33612
|
+
/** @ignore */
|
|
33613
|
+
function toDOMPointInit(value) {
|
|
33614
|
+
|
|
33615
|
+
const {x, y, z, w} = value;
|
|
33616
|
+
return {x, y, z, w};
|
|
33617
|
+
|
|
33618
|
+
}
|
|
33619
|
+
|
|
33620
|
+
/** @ignore */
|
|
33621
|
+
function parseRadiiArgument(value) {
|
|
33622
|
+
|
|
33623
|
+
// https://webidl.spec.whatwg.org/#es-union
|
|
33624
|
+
// with 'optional (unrestricted double or DOMPointInit
|
|
33625
|
+
// or sequence<(unrestricted double or DOMPointInit)>) radii = 0'
|
|
33626
|
+
const type = typeof value;
|
|
33627
|
+
|
|
33628
|
+
if (type === "undefined" || value === null) {
|
|
33629
|
+
|
|
33630
|
+
return [0];
|
|
33631
|
+
|
|
33632
|
+
}
|
|
33633
|
+
if (type === "function") {
|
|
33634
|
+
|
|
33635
|
+
return [NaN];
|
|
33636
|
+
|
|
33637
|
+
}
|
|
33638
|
+
if (type === "object") {
|
|
33639
|
+
|
|
33640
|
+
if (typeof value[Symbol.iterator] === "function") {
|
|
33641
|
+
|
|
33642
|
+
return [...value].map((elem) => {
|
|
33643
|
+
// https://webidl.spec.whatwg.org/#es-union
|
|
33644
|
+
// with '(unrestricted double or DOMPointInit)'
|
|
33645
|
+
const elemType = typeof elem;
|
|
33646
|
+
if (elemType === "undefined" || elem === null) {
|
|
33647
|
+
return 0;
|
|
33648
|
+
}
|
|
33649
|
+
if (elemType === "function") {
|
|
33650
|
+
return NaN;
|
|
33651
|
+
}
|
|
33652
|
+
if (elemType === "object") {
|
|
33653
|
+
return toDOMPointInit(elem);
|
|
33654
|
+
}
|
|
33655
|
+
return toUnrestrictedNumber(elem);
|
|
33656
|
+
});
|
|
33657
|
+
|
|
33658
|
+
}
|
|
33659
|
+
|
|
33660
|
+
return [toDOMPointInit(value)];
|
|
33661
|
+
|
|
33662
|
+
}
|
|
33663
|
+
|
|
33664
|
+
return [toUnrestrictedNumber(value)];
|
|
33665
|
+
|
|
33666
|
+
}
|
|
33667
|
+
|
|
33668
|
+
/** @ignore */
|
|
33669
|
+
function toUnrestrictedNumber(value) {
|
|
33670
|
+
|
|
33671
|
+
return +value;
|
|
33672
|
+
|
|
33673
|
+
}
|
|
33674
|
+
|
|
33675
|
+
/** @ignore */
|
|
33676
|
+
function toCornerPoint(value) {
|
|
33677
|
+
|
|
33678
|
+
const asNumber = toUnrestrictedNumber(value);
|
|
33679
|
+
if (Number.isFinite(asNumber)) {
|
|
33680
|
+
|
|
33681
|
+
return {
|
|
33682
|
+
x: asNumber,
|
|
33683
|
+
y: asNumber
|
|
33684
|
+
};
|
|
33685
|
+
|
|
33686
|
+
}
|
|
33687
|
+
if (Object(value) === value) {
|
|
33688
|
+
|
|
33689
|
+
return {
|
|
33690
|
+
x: toUnrestrictedNumber(value.x || 0),
|
|
33691
|
+
y: toUnrestrictedNumber(value.y || 0)
|
|
33692
|
+
};
|
|
33693
|
+
|
|
33694
|
+
}
|
|
33695
|
+
|
|
33696
|
+
return {
|
|
33697
|
+
x: NaN,
|
|
33698
|
+
y: NaN
|
|
33699
|
+
};
|
|
33700
|
+
|
|
33701
|
+
}
|
|
33702
|
+
|
|
33703
|
+
/** @ignore */
|
|
33704
|
+
function fixOverlappingCorners(corners) {
|
|
33705
|
+
const [upperLeft, upperRight, lowerRight, lowerLeft] = corners;
|
|
33706
|
+
const factors = [
|
|
33707
|
+
Math.abs(w) / (upperLeft.x + upperRight.x),
|
|
33708
|
+
Math.abs(h) / (upperRight.y + lowerRight.y),
|
|
33709
|
+
Math.abs(w) / (lowerRight.x + lowerLeft.x),
|
|
33710
|
+
Math.abs(h) / (upperLeft.y + lowerLeft.y)
|
|
33711
|
+
];
|
|
33712
|
+
const minFactor = Math.min(...factors);
|
|
33713
|
+
if (minFactor <= 1) {
|
|
33714
|
+
corners.forEach((radii) => {
|
|
33715
|
+
radii.x *= minFactor;
|
|
33716
|
+
radii.y *= minFactor;
|
|
33717
|
+
});
|
|
33718
|
+
}
|
|
33719
|
+
}
|
|
33720
|
+
}
|
|
33721
|
+
|
|
33722
|
+
if (typeof Path2D.prototype.roundRect === "undefined") {
|
|
33723
|
+
Path2D.prototype.roundRect = roundRect;
|
|
33724
|
+
}
|
|
33725
|
+
if (globalThis.CanvasRenderingContext2D) {
|
|
33726
|
+
if (typeof globalThis.CanvasRenderingContext2D.prototype.roundRect === "undefined") {
|
|
33727
|
+
globalThis.CanvasRenderingContext2D.prototype.roundRect = roundRect;
|
|
33728
|
+
}
|
|
33729
|
+
}
|
|
33730
|
+
if (globalThis.OffscreenCanvasRenderingContext2D) {
|
|
33731
|
+
if (typeof globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect === "undefined") {
|
|
33732
|
+
globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect = roundRect;
|
|
33733
|
+
}
|
|
33734
|
+
}
|
|
33735
|
+
|
|
33736
|
+
})();
|
|
33737
|
+
|
|
32967
33738
|
/**
|
|
32968
33739
|
* This namespace is a container for all registered plugins.
|
|
32969
33740
|
* @see plugin.register
|
|
@@ -32980,10 +33751,10 @@ class BasePlugin {
|
|
|
32980
33751
|
* this can be overridden by the plugin
|
|
32981
33752
|
* @public
|
|
32982
33753
|
* @type {string}
|
|
32983
|
-
* @default "10.
|
|
33754
|
+
* @default "10.9.0"
|
|
32984
33755
|
* @name plugin.Base#version
|
|
32985
33756
|
*/
|
|
32986
|
-
this.version = "10.
|
|
33757
|
+
this.version = "10.9.0";
|
|
32987
33758
|
}
|
|
32988
33759
|
}
|
|
32989
33760
|
|
|
@@ -34247,10 +35018,10 @@ class Text extends Renderable {
|
|
|
34247
35018
|
this.fillStyle = settings.fillStyle;
|
|
34248
35019
|
} else {
|
|
34249
35020
|
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
34250
|
-
this.fillStyle = pull("Color").parseCSS(settings.fillStyle);
|
|
35021
|
+
this.fillStyle = pool$1.pull("Color").parseCSS(settings.fillStyle);
|
|
34251
35022
|
}
|
|
34252
35023
|
} else {
|
|
34253
|
-
this.fillStyle = pull("Color", 0, 0, 0);
|
|
35024
|
+
this.fillStyle = pool$1.pull("Color", 0, 0, 0);
|
|
34254
35025
|
}
|
|
34255
35026
|
|
|
34256
35027
|
/**
|
|
@@ -34264,10 +35035,10 @@ class Text extends Renderable {
|
|
|
34264
35035
|
this.strokeStyle = settings.strokeStyle;
|
|
34265
35036
|
} else {
|
|
34266
35037
|
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
34267
|
-
this.strokeStyle = pull("Color").parseCSS(settings.strokeStyle);
|
|
35038
|
+
this.strokeStyle = pool$1.pull("Color").parseCSS(settings.strokeStyle);
|
|
34268
35039
|
}
|
|
34269
35040
|
} else {
|
|
34270
|
-
this.strokeStyle = pull("Color", 0, 0, 0);
|
|
35041
|
+
this.strokeStyle = pool$1.pull("Color", 0, 0, 0);
|
|
34271
35042
|
}
|
|
34272
35043
|
|
|
34273
35044
|
/**
|
|
@@ -34609,8 +35380,8 @@ class Text extends Renderable {
|
|
|
34609
35380
|
* @ignore
|
|
34610
35381
|
*/
|
|
34611
35382
|
destroy() {
|
|
34612
|
-
push(this.fillStyle);
|
|
34613
|
-
push(this.strokeStyle);
|
|
35383
|
+
pool$1.push(this.fillStyle);
|
|
35384
|
+
pool$1.push(this.strokeStyle);
|
|
34614
35385
|
this.fillStyle = this.strokeStyle = undefined;
|
|
34615
35386
|
this.metrics = undefined;
|
|
34616
35387
|
this._text.length = 0;
|
|
@@ -34703,7 +35474,7 @@ class BitmapText extends Renderable {
|
|
|
34703
35474
|
* scaled font size
|
|
34704
35475
|
* @private
|
|
34705
35476
|
*/
|
|
34706
|
-
this.fontScale = pull("Vector2d", 1.0, 1.0);
|
|
35477
|
+
this.fontScale = pool$1.pull("Vector2d", 1.0, 1.0);
|
|
34707
35478
|
|
|
34708
35479
|
/**
|
|
34709
35480
|
* font image
|
|
@@ -34717,9 +35488,9 @@ class BitmapText extends Renderable {
|
|
|
34717
35488
|
* @private
|
|
34718
35489
|
*/
|
|
34719
35490
|
// use settings.font to retreive the data from the loader
|
|
34720
|
-
this.fontData = pull("BitmapTextData", loader.getBinary(settings.font));
|
|
35491
|
+
this.fontData = pool$1.pull("BitmapTextData", loader.getBinary(settings.font));
|
|
34721
35492
|
} else {
|
|
34722
|
-
this.fontData = pull("BitmapTextData",
|
|
35493
|
+
this.fontData = pool$1.pull("BitmapTextData",
|
|
34723
35494
|
// if starting/includes "info face" the whole data string was passed as parameter
|
|
34724
35495
|
(settings.fontData.includes("info face")) ? settings.fontData : loader.getBinary(settings.fontData)
|
|
34725
35496
|
);
|
|
@@ -34948,9 +35719,9 @@ class BitmapText extends Renderable {
|
|
|
34948
35719
|
* @ignore
|
|
34949
35720
|
*/
|
|
34950
35721
|
destroy() {
|
|
34951
|
-
push(this.fontScale);
|
|
35722
|
+
pool$1.push(this.fontScale);
|
|
34952
35723
|
this.fontScale = undefined;
|
|
34953
|
-
push(this.fontData);
|
|
35724
|
+
pool$1.push(this.fontData);
|
|
34954
35725
|
this.fontData = undefined;
|
|
34955
35726
|
this._text.length = 0;
|
|
34956
35727
|
this.metrics = undefined;
|
|
@@ -35228,7 +35999,7 @@ class ColorLayer extends Renderable {
|
|
|
35228
35999
|
* @name color
|
|
35229
36000
|
* @memberof ColorLayer#
|
|
35230
36001
|
*/
|
|
35231
|
-
this.color = pull("Color").parseCSS(color);
|
|
36002
|
+
this.color = pool$1.pull("Color").parseCSS(color);
|
|
35232
36003
|
|
|
35233
36004
|
this.onResetEvent(name, color, z);
|
|
35234
36005
|
|
|
@@ -35263,7 +36034,7 @@ class ColorLayer extends Renderable {
|
|
|
35263
36034
|
* @ignore
|
|
35264
36035
|
*/
|
|
35265
36036
|
destroy() {
|
|
35266
|
-
push(this.color);
|
|
36037
|
+
pool$1.push(this.color);
|
|
35267
36038
|
this.color = undefined;
|
|
35268
36039
|
super.destroy();
|
|
35269
36040
|
}
|
|
@@ -35315,7 +36086,7 @@ class ImageLayer extends Sprite {
|
|
|
35315
36086
|
* @default <1.0,1.0>
|
|
35316
36087
|
* @name ImageLayer#ratio
|
|
35317
36088
|
*/
|
|
35318
|
-
this.ratio = pull("Vector2d", 1.0, 1.0);
|
|
36089
|
+
this.ratio = pool$1.pull("Vector2d", 1.0, 1.0);
|
|
35319
36090
|
|
|
35320
36091
|
if (typeof(settings.ratio) !== "undefined") {
|
|
35321
36092
|
// little hack for backward compatiblity
|
|
@@ -35556,7 +36327,7 @@ class ImageLayer extends Sprite {
|
|
|
35556
36327
|
* @ignore
|
|
35557
36328
|
*/
|
|
35558
36329
|
destroy() {
|
|
35559
|
-
push(this.ratio);
|
|
36330
|
+
pool$1.push(this.ratio);
|
|
35560
36331
|
this.ratio = undefined;
|
|
35561
36332
|
off(ONCONTEXT_RESTORED, this.createPattern);
|
|
35562
36333
|
super.destroy();
|
|
@@ -36036,7 +36807,15 @@ class Collectable extends Sprite {
|
|
|
36036
36807
|
this.id = settings.id;
|
|
36037
36808
|
|
|
36038
36809
|
// add and configure the physic body
|
|
36039
|
-
|
|
36810
|
+
var shape = settings.shapes;
|
|
36811
|
+
if (typeof shape === "undefined") {
|
|
36812
|
+
shape = pool.pull("Polygon", 0, 0, [
|
|
36813
|
+
pool.pull("Vector2d", 0, 0),
|
|
36814
|
+
pool.pull("Vector2d", this.width, 0),
|
|
36815
|
+
pool.pull("Vector2d", this.width, this.height)
|
|
36816
|
+
]);
|
|
36817
|
+
}
|
|
36818
|
+
this.body = new Body(this, shape);
|
|
36040
36819
|
this.body.collisionType = collision.types.COLLECTABLE_OBJECT;
|
|
36041
36820
|
// by default only collides with PLAYER_OBJECT
|
|
36042
36821
|
this.body.setCollisionMask(collision.types.PLAYER_OBJECT);
|
|
@@ -36115,9 +36894,16 @@ class Trigger extends Renderable {
|
|
|
36115
36894
|
}
|
|
36116
36895
|
}.bind(this));
|
|
36117
36896
|
|
|
36118
|
-
|
|
36119
|
-
|
|
36120
|
-
|
|
36897
|
+
// add and configure the physic body
|
|
36898
|
+
var shape = settings.shapes;
|
|
36899
|
+
if (typeof shape === "undefined") {
|
|
36900
|
+
shape = pool.pull("Polygon", 0, 0, [
|
|
36901
|
+
pool.pull("Vector2d", 0, 0),
|
|
36902
|
+
pool.pull("Vector2d", this.width, 0),
|
|
36903
|
+
pool.pull("Vector2d", this.width, this.height)
|
|
36904
|
+
]);
|
|
36905
|
+
}
|
|
36906
|
+
this.body = new Body(this, shape);
|
|
36121
36907
|
this.body.collisionType = collision.types.ACTION_OBJECT;
|
|
36122
36908
|
// by default only collides with PLAYER_OBJECT
|
|
36123
36909
|
this.body.setCollisionMask(collision.types.PLAYER_OBJECT);
|
|
@@ -36736,14 +37522,17 @@ class ParticleEmitter extends Container {
|
|
|
36736
37522
|
* @param {number} y y position of the particle emitter
|
|
36737
37523
|
* @param {ParticleEmitterSettings} [settings=ParticleEmitterSettings] the settings for the particle emitter.
|
|
36738
37524
|
* @example
|
|
36739
|
-
* // Create a
|
|
36740
|
-
* var emitter = new ParticleEmitter(100, 100
|
|
36741
|
-
*
|
|
36742
|
-
*
|
|
36743
|
-
*
|
|
36744
|
-
*
|
|
36745
|
-
*
|
|
36746
|
-
*
|
|
37525
|
+
* // Create a particle emitter at position 100, 100
|
|
37526
|
+
* var emitter = new ParticleEmitter(100, 100, {
|
|
37527
|
+
* width: 16,
|
|
37528
|
+
* height : 16,
|
|
37529
|
+
* tint: "#f00",
|
|
37530
|
+
* totalParticles: 32,
|
|
37531
|
+
* angle: 0,
|
|
37532
|
+
* angleVariation: 6.283185307179586,
|
|
37533
|
+
* maxLife: 5,
|
|
37534
|
+
* speed: 3
|
|
37535
|
+
* });
|
|
36747
37536
|
*
|
|
36748
37537
|
* // Add the emitter to the game world
|
|
36749
37538
|
* me.game.world.addChild(emitter);
|
|
@@ -36766,6 +37555,15 @@ class ParticleEmitter extends Container {
|
|
|
36766
37555
|
settings.height | 1
|
|
36767
37556
|
);
|
|
36768
37557
|
|
|
37558
|
+
/**
|
|
37559
|
+
* the current (active) emitter settings
|
|
37560
|
+
* @public
|
|
37561
|
+
* @type {ParticleEmitterSettings}
|
|
37562
|
+
* @name settings
|
|
37563
|
+
* @memberof ParticleEmitter
|
|
37564
|
+
*/
|
|
37565
|
+
this.settings = {};
|
|
37566
|
+
|
|
36769
37567
|
// center the emitter around the given coordinates
|
|
36770
37568
|
this.centerOn(x, y);
|
|
36771
37569
|
|
|
@@ -36796,9 +37594,6 @@ class ParticleEmitter extends Container {
|
|
|
36796
37594
|
// count the updates
|
|
36797
37595
|
this._updateCount = 0;
|
|
36798
37596
|
|
|
36799
|
-
// the emitter settings
|
|
36800
|
-
this.settings = {};
|
|
36801
|
-
|
|
36802
37597
|
// internally store how much time was skipped when frames are skipped
|
|
36803
37598
|
this._dt = 0;
|
|
36804
37599
|
|
|
@@ -36810,7 +37605,7 @@ class ParticleEmitter extends Container {
|
|
|
36810
37605
|
|
|
36811
37606
|
/**
|
|
36812
37607
|
* Reset the emitter with particle emitter settings.
|
|
36813
|
-
* @param {
|
|
37608
|
+
* @param {ParticleEmitterSettings} settings [optional] object with emitter settings. See {@link ParticleEmitterSettings}
|
|
36814
37609
|
*/
|
|
36815
37610
|
reset(settings = {}) {
|
|
36816
37611
|
Object.assign(this.settings, ParticleEmitterSettings, settings);
|
|
@@ -36844,9 +37639,9 @@ class ParticleEmitter extends Container {
|
|
|
36844
37639
|
// Add count particles in the game world
|
|
36845
37640
|
/** @ignore */
|
|
36846
37641
|
addParticles(count) {
|
|
36847
|
-
for (var i = 0; i <
|
|
37642
|
+
for (var i = 0; i < count; i++) {
|
|
36848
37643
|
// Add particle to the container
|
|
36849
|
-
this.addChild(pull("Particle", this), this.pos.z);
|
|
37644
|
+
this.addChild(pool$1.pull("Particle", this), this.pos.z);
|
|
36850
37645
|
}
|
|
36851
37646
|
this.isDirty = true;
|
|
36852
37647
|
}
|
|
@@ -36985,9 +37780,10 @@ class Particle extends Renderable {
|
|
|
36985
37780
|
emitter.settings.image.width,
|
|
36986
37781
|
emitter.settings.image.height
|
|
36987
37782
|
);
|
|
37783
|
+
this.currentTransform.identity();
|
|
36988
37784
|
} else {
|
|
36989
37785
|
// particle velocity
|
|
36990
|
-
this.vel =
|
|
37786
|
+
this.vel = pool$1.pull("Vector2d");
|
|
36991
37787
|
}
|
|
36992
37788
|
|
|
36993
37789
|
this.image = emitter.settings.image;
|
|
@@ -37221,11 +38017,11 @@ class Entity extends Renderable {
|
|
|
37221
38017
|
*/
|
|
37222
38018
|
// initialize the default body
|
|
37223
38019
|
if (typeof settings.shapes === "undefined") {
|
|
37224
|
-
settings.shapes =
|
|
37225
|
-
|
|
37226
|
-
|
|
37227
|
-
|
|
37228
|
-
|
|
38020
|
+
settings.shapes = pool$1.pull("Polygon", 0, 0, [
|
|
38021
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
38022
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
38023
|
+
pool$1.pull("Vector2d", this.width, this.height),
|
|
38024
|
+
pool$1.pull("Vector2d", 0, this.height)
|
|
37229
38025
|
]);
|
|
37230
38026
|
}
|
|
37231
38027
|
this.body = new Body(this, settings.shapes, this.onBodyUpdate.bind(this));
|
|
@@ -37432,7 +38228,7 @@ device$1.turnOffPointerLock = function () {
|
|
|
37432
38228
|
/**
|
|
37433
38229
|
* @public
|
|
37434
38230
|
* @name Texture
|
|
37435
|
-
* @memberof Renderer
|
|
38231
|
+
* @memberof Renderer#
|
|
37436
38232
|
* @deprecated since 10.4.0
|
|
37437
38233
|
* @see TextureAtlas
|
|
37438
38234
|
*/
|
|
@@ -37495,7 +38291,7 @@ class DroptargetEntity extends DropTarget {
|
|
|
37495
38291
|
* @name version
|
|
37496
38292
|
* @type {string}
|
|
37497
38293
|
*/
|
|
37498
|
-
const version = "10.
|
|
38294
|
+
const version = "10.9.0";
|
|
37499
38295
|
|
|
37500
38296
|
|
|
37501
38297
|
/**
|
|
@@ -37530,58 +38326,60 @@ function boot() {
|
|
|
37530
38326
|
}
|
|
37531
38327
|
|
|
37532
38328
|
// register all built-ins objects into the object pool
|
|
37533
|
-
register("me.Entity", Entity);
|
|
37534
|
-
register("me.Collectable", Collectable);
|
|
37535
|
-
register("me.Trigger", Trigger);
|
|
37536
|
-
register("me.Tween", Tween, true);
|
|
37537
|
-
register("me.Color", Color, true);
|
|
37538
|
-
register("me.Particle", Particle, true);
|
|
37539
|
-
register("me.Sprite", Sprite);
|
|
37540
|
-
register("me.NineSliceSprite", NineSliceSprite);
|
|
37541
|
-
register("me.Renderable", Renderable);
|
|
37542
|
-
register("me.Text", Text, true);
|
|
37543
|
-
register("me.BitmapText", BitmapText);
|
|
37544
|
-
register("me.BitmapTextData", BitmapTextData, true);
|
|
37545
|
-
register("me.ImageLayer", ImageLayer);
|
|
37546
|
-
register("me.ColorLayer", ColorLayer, true);
|
|
37547
|
-
register("me.Vector2d", Vector2d, true);
|
|
37548
|
-
register("me.Vector3d", Vector3d, true);
|
|
37549
|
-
register("me.ObservableVector2d", ObservableVector2d, true);
|
|
37550
|
-
register("me.ObservableVector3d", ObservableVector3d, true);
|
|
37551
|
-
register("me.Matrix2d", Matrix2d, true);
|
|
37552
|
-
register("me.Matrix3d", Matrix3d, true);
|
|
37553
|
-
register("me.Rect", Rect, true);
|
|
37554
|
-
register("me.
|
|
37555
|
-
register("me.
|
|
37556
|
-
register("me.
|
|
37557
|
-
register("me.
|
|
38329
|
+
pool$1.register("me.Entity", Entity);
|
|
38330
|
+
pool$1.register("me.Collectable", Collectable);
|
|
38331
|
+
pool$1.register("me.Trigger", Trigger);
|
|
38332
|
+
pool$1.register("me.Tween", Tween, true);
|
|
38333
|
+
pool$1.register("me.Color", Color, true);
|
|
38334
|
+
pool$1.register("me.Particle", Particle, true);
|
|
38335
|
+
pool$1.register("me.Sprite", Sprite);
|
|
38336
|
+
pool$1.register("me.NineSliceSprite", NineSliceSprite);
|
|
38337
|
+
pool$1.register("me.Renderable", Renderable);
|
|
38338
|
+
pool$1.register("me.Text", Text, true);
|
|
38339
|
+
pool$1.register("me.BitmapText", BitmapText);
|
|
38340
|
+
pool$1.register("me.BitmapTextData", BitmapTextData, true);
|
|
38341
|
+
pool$1.register("me.ImageLayer", ImageLayer);
|
|
38342
|
+
pool$1.register("me.ColorLayer", ColorLayer, true);
|
|
38343
|
+
pool$1.register("me.Vector2d", Vector2d, true);
|
|
38344
|
+
pool$1.register("me.Vector3d", Vector3d, true);
|
|
38345
|
+
pool$1.register("me.ObservableVector2d", ObservableVector2d, true);
|
|
38346
|
+
pool$1.register("me.ObservableVector3d", ObservableVector3d, true);
|
|
38347
|
+
pool$1.register("me.Matrix2d", Matrix2d, true);
|
|
38348
|
+
pool$1.register("me.Matrix3d", Matrix3d, true);
|
|
38349
|
+
pool$1.register("me.Rect", Rect, true);
|
|
38350
|
+
pool$1.register("me.RoundRect", RoundRect, true);
|
|
38351
|
+
pool$1.register("me.Polygon", Polygon, true);
|
|
38352
|
+
pool$1.register("me.Line", Line, true);
|
|
38353
|
+
pool$1.register("me.Ellipse", Ellipse, true);
|
|
38354
|
+
pool$1.register("me.Bounds", Bounds$1, true);
|
|
37558
38355
|
|
|
37559
38356
|
// duplicate all entries if use with no namespace (e.g. es6)
|
|
37560
|
-
register("Entity", Entity);
|
|
37561
|
-
register("Collectable", Collectable);
|
|
37562
|
-
register("Trigger", Trigger);
|
|
37563
|
-
register("Tween", Tween, true);
|
|
37564
|
-
register("Color", Color, true);
|
|
37565
|
-
register("Particle", Particle, true);
|
|
37566
|
-
register("Sprite", Sprite);
|
|
37567
|
-
register("NineSliceSprite", NineSliceSprite);
|
|
37568
|
-
register("Renderable", Renderable);
|
|
37569
|
-
register("Text", Text, true);
|
|
37570
|
-
register("BitmapText", BitmapText);
|
|
37571
|
-
register("BitmapTextData", BitmapTextData, true);
|
|
37572
|
-
register("ImageLayer", ImageLayer);
|
|
37573
|
-
register("ColorLayer", ColorLayer, true);
|
|
37574
|
-
register("Vector2d", Vector2d, true);
|
|
37575
|
-
register("Vector3d", Vector3d, true);
|
|
37576
|
-
register("ObservableVector2d", ObservableVector2d, true);
|
|
37577
|
-
register("ObservableVector3d", ObservableVector3d, true);
|
|
37578
|
-
register("Matrix2d", Matrix2d, true);
|
|
37579
|
-
register("Matrix3d", Matrix3d, true);
|
|
37580
|
-
register("Rect", Rect, true);
|
|
37581
|
-
register("
|
|
37582
|
-
register("
|
|
37583
|
-
register("
|
|
37584
|
-
register("
|
|
38357
|
+
pool$1.register("Entity", Entity);
|
|
38358
|
+
pool$1.register("Collectable", Collectable);
|
|
38359
|
+
pool$1.register("Trigger", Trigger);
|
|
38360
|
+
pool$1.register("Tween", Tween, true);
|
|
38361
|
+
pool$1.register("Color", Color, true);
|
|
38362
|
+
pool$1.register("Particle", Particle, true);
|
|
38363
|
+
pool$1.register("Sprite", Sprite);
|
|
38364
|
+
pool$1.register("NineSliceSprite", NineSliceSprite);
|
|
38365
|
+
pool$1.register("Renderable", Renderable);
|
|
38366
|
+
pool$1.register("Text", Text, true);
|
|
38367
|
+
pool$1.register("BitmapText", BitmapText);
|
|
38368
|
+
pool$1.register("BitmapTextData", BitmapTextData, true);
|
|
38369
|
+
pool$1.register("ImageLayer", ImageLayer);
|
|
38370
|
+
pool$1.register("ColorLayer", ColorLayer, true);
|
|
38371
|
+
pool$1.register("Vector2d", Vector2d, true);
|
|
38372
|
+
pool$1.register("Vector3d", Vector3d, true);
|
|
38373
|
+
pool$1.register("ObservableVector2d", ObservableVector2d, true);
|
|
38374
|
+
pool$1.register("ObservableVector3d", ObservableVector3d, true);
|
|
38375
|
+
pool$1.register("Matrix2d", Matrix2d, true);
|
|
38376
|
+
pool$1.register("Matrix3d", Matrix3d, true);
|
|
38377
|
+
pool$1.register("Rect", Rect, true);
|
|
38378
|
+
pool$1.register("RoundRect", RoundRect, true);
|
|
38379
|
+
pool$1.register("Polygon", Polygon, true);
|
|
38380
|
+
pool$1.register("Line", Line, true);
|
|
38381
|
+
pool$1.register("Ellipse", Ellipse, true);
|
|
38382
|
+
pool$1.register("Bounds", Bounds$1, true);
|
|
37585
38383
|
|
|
37586
38384
|
// publish Boot notification
|
|
37587
38385
|
emit(BOOT);
|
|
@@ -37602,4 +38400,4 @@ device$1.onReady(function () {
|
|
|
37602
38400
|
}
|
|
37603
38401
|
});
|
|
37604
38402
|
|
|
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,
|
|
38403
|
+
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, RoundRect, 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, pool$1 as pool, save, skipAutoInit, state, timer$1 as timer, utils, version, video, warning };
|