melonjs 14.5.0 → 15.1.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/LICENSE.md +1 -1
- package/README.md +6 -6
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
- package/dist/melonjs.mjs/_virtual/howler.js +1 -1
- package/dist/melonjs.mjs/_virtual/index.js +7 -3
- package/dist/melonjs.mjs/_virtual/index2.js +1 -1
- package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
- package/dist/melonjs.mjs/application/application.js +27 -17
- package/dist/melonjs.mjs/application/header.js +6 -5
- package/dist/melonjs.mjs/application/resize.js +20 -20
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +18 -20
- package/dist/melonjs.mjs/camera/camera2d.js +10 -10
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +4 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +6 -6
- package/dist/melonjs.mjs/geometries/line.js +9 -9
- package/dist/melonjs.mjs/geometries/path2d.js +56 -56
- package/dist/melonjs.mjs/geometries/point.js +2 -2
- package/dist/melonjs.mjs/geometries/poly.js +29 -29
- package/dist/melonjs.mjs/geometries/rectangle.js +8 -8
- package/dist/melonjs.mjs/geometries/roundrect.js +6 -6
- package/dist/melonjs.mjs/index.js +8 -6
- package/dist/melonjs.mjs/input/gamepad.js +30 -30
- package/dist/melonjs.mjs/input/input.js +2 -2
- package/dist/melonjs.mjs/input/keyboard.js +15 -15
- package/dist/melonjs.mjs/input/pointer.js +2 -2
- package/dist/melonjs.mjs/input/pointerevent.js +59 -59
- package/dist/melonjs.mjs/lang/console.js +3 -3
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +9 -9
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +31 -31
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +19 -19
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +15 -15
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +46 -41
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +30 -30
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +21 -21
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +10 -10
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +6 -6
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +1 -1
- package/dist/melonjs.mjs/loader/loader.js +7 -7
- package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +13 -13
- package/dist/melonjs.mjs/loader/settings.js +3 -3
- package/dist/melonjs.mjs/math/color.js +25 -24
- package/dist/melonjs.mjs/math/math.js +2 -2
- package/dist/melonjs.mjs/math/matrix2.js +22 -22
- package/dist/melonjs.mjs/math/matrix3.js +52 -52
- package/dist/melonjs.mjs/math/observable_vector2.js +12 -12
- package/dist/melonjs.mjs/math/observable_vector3.js +22 -22
- package/dist/melonjs.mjs/math/vector2.js +11 -11
- package/dist/melonjs.mjs/math/vector3.js +21 -21
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +45 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +130 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +5 -5
- package/dist/melonjs.mjs/particles/particle.js +8 -8
- package/dist/melonjs.mjs/particles/settings.js +3 -3
- package/dist/melonjs.mjs/physics/body.js +17 -17
- package/dist/melonjs.mjs/physics/bounds.js +12 -12
- package/dist/melonjs.mjs/physics/collision.js +3 -3
- package/dist/melonjs.mjs/physics/detector.js +14 -14
- package/dist/melonjs.mjs/physics/quadtree.js +19 -19
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +60 -60
- package/dist/melonjs.mjs/physics/world.js +4 -4
- package/dist/melonjs.mjs/plugin/plugin.js +11 -11
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +77 -59
- package/dist/melonjs.mjs/renderable/dragndrop.js +5 -5
- package/dist/melonjs.mjs/renderable/imagelayer.js +7 -6
- package/dist/melonjs.mjs/renderable/light2d.js +6 -6
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +12 -12
- package/dist/melonjs.mjs/renderable/renderable.js +35 -13
- package/dist/melonjs.mjs/renderable/sprite.js +25 -25
- package/dist/melonjs.mjs/renderable/trigger.js +11 -9
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +97 -27
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +25 -25
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +83 -65
- package/dist/melonjs.mjs/state/stage.js +7 -7
- package/dist/melonjs.mjs/state/state.js +15 -15
- package/dist/melonjs.mjs/system/device.js +3 -3
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +2 -2
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +9 -9
- package/dist/melonjs.mjs/system/save.js +6 -6
- package/dist/melonjs.mjs/system/timer.js +16 -12
- package/dist/melonjs.mjs/text/bitmaptext.js +20 -20
- package/dist/melonjs.mjs/text/bitmaptextdata.js +22 -22
- package/dist/melonjs.mjs/text/glyph.js +3 -3
- package/dist/melonjs.mjs/text/text.js +63 -92
- package/dist/melonjs.mjs/text/textmetrics.js +15 -15
- package/dist/melonjs.mjs/text/textstyle.js +4 -6
- package/dist/melonjs.mjs/tweens/easing.js +4 -4
- package/dist/melonjs.mjs/tweens/interpolation.js +8 -8
- package/dist/melonjs.mjs/tweens/tween.js +11 -11
- package/dist/melonjs.mjs/utils/agent.js +6 -6
- package/dist/melonjs.mjs/utils/array.js +4 -4
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +5 -5
- package/dist/melonjs.mjs/utils/string.js +3 -3
- package/dist/melonjs.mjs/utils/utils.js +16 -16
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +41 -119
- package/dist/melonjs.mjs/video/renderer.js +70 -14
- package/dist/melonjs.mjs/video/texture/atlas.js +39 -45
- package/dist/melonjs.mjs/video/texture/cache.js +9 -10
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +63 -3
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +2 -2
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +23 -19
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +80 -80
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +77 -0
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +252 -0
- package/dist/melonjs.mjs/video/webgl/compositors/webgl_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/glshader.js +7 -7
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/program.js +7 -7
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +4 -4
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +188 -181
- package/dist/melonjs.module.js +25040 -25193
- package/dist/types/application/application.d.ts +11 -8
- package/dist/types/audio/audio.d.ts +3 -3
- package/dist/types/entity/entity.d.ts +1 -1
- package/dist/types/index.d.ts +7 -4
- package/dist/types/input/input.d.ts +1 -1
- package/dist/types/input/keyboard.d.ts +1 -1
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/level.d.ts +2 -2
- package/dist/types/level/tiled/TMXLayer.d.ts +4 -4
- package/dist/types/level/tiled/TMXTileMap.d.ts +2 -2
- package/dist/types/level/tiled/TMXUtils.d.ts +5 -4
- package/dist/types/loader/loader.d.ts +2 -2
- package/dist/types/loader/settings.d.ts +2 -2
- package/dist/types/particles/emitter.d.ts +1 -1
- package/dist/types/physics/collision.d.ts +1 -1
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/plugin/plugin.d.ts +2 -2
- package/dist/types/renderable/container.d.ts +21 -17
- package/dist/types/renderable/renderable.d.ts +6 -0
- package/dist/types/renderable/sprite.d.ts +11 -11
- package/dist/types/renderable/trigger.d.ts +1 -1
- package/dist/types/renderable/ui/uibaseelement.d.ts +28 -6
- package/dist/types/renderable/ui/uispriteelement.d.ts +12 -14
- package/dist/types/renderable/ui/uitextbutton.d.ts +52 -12
- package/dist/types/state/stage.d.ts +1 -1
- package/dist/types/system/device.d.ts +1 -1
- package/dist/types/system/pooling.d.ts +3 -3
- package/dist/types/system/timer.d.ts +5 -5
- package/dist/types/text/bitmaptext.d.ts +1 -1
- package/dist/types/text/text.d.ts +7 -21
- package/dist/types/text/textstyle.d.ts +1 -1
- package/dist/types/utils/array.d.ts +2 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +8 -81
- package/dist/types/video/renderer.d.ts +48 -4
- package/dist/types/video/texture/atlas.d.ts +3 -3
- package/dist/types/video/texture/canvas_texture.d.ts +40 -0
- package/dist/types/video/webgl/buffer/vertex.d.ts +3 -3
- package/dist/types/video/webgl/compositors/compositor.d.ts +38 -32
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +22 -0
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +72 -0
- package/dist/types/video/webgl/glshader.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +47 -37
- package/package.json +16 -17
- package/src/application/application.js +26 -16
- package/src/application/header.js +5 -4
- package/src/application/resize.js +19 -19
- package/src/audio/audio.js +17 -19
- package/src/camera/camera2d.js +9 -9
- package/src/entity/entity.js +3 -3
- package/src/geometries/ellipse.js +5 -5
- package/src/geometries/line.js +8 -8
- package/src/geometries/path2d.js +55 -55
- package/src/geometries/point.js +1 -1
- package/src/geometries/poly.js +28 -28
- package/src/geometries/rectangle.js +7 -7
- package/src/geometries/roundrect.js +5 -5
- package/src/index.js +9 -4
- package/src/input/gamepad.js +29 -29
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -14
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +52 -52
- package/src/lang/console.js +2 -2
- package/src/lang/deprecated.js +1 -1
- package/src/level/level.js +8 -8
- package/src/level/tiled/TMXGroup.js +2 -2
- package/src/level/tiled/TMXLayer.js +30 -30
- package/src/level/tiled/TMXObject.js +7 -7
- package/src/level/tiled/TMXTile.js +7 -7
- package/src/level/tiled/TMXTileMap.js +18 -18
- package/src/level/tiled/TMXTileset.js +14 -14
- package/src/level/tiled/TMXTilesetGroup.js +2 -2
- package/src/level/tiled/TMXUtils.js +45 -40
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +29 -29
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +20 -20
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +9 -9
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +5 -5
- package/src/loader/loader.js +6 -6
- package/src/loader/loadingscreen.js +1 -1
- package/src/loader/parser.js +12 -12
- package/src/loader/settings.js +2 -2
- package/src/math/color.js +24 -23
- package/src/math/math.js +1 -1
- package/src/math/matrix2.js +21 -21
- package/src/math/matrix3.js +51 -51
- package/src/math/observable_vector2.js +11 -11
- package/src/math/observable_vector3.js +21 -21
- package/src/math/vector2.js +10 -10
- package/src/math/vector3.js +20 -20
- package/src/particles/emitter.js +4 -4
- package/src/particles/particle.js +7 -7
- package/src/particles/settings.js +2 -2
- package/src/physics/body.js +16 -16
- package/src/physics/bounds.js +11 -11
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +18 -18
- package/src/physics/sat.js +59 -59
- package/src/physics/world.js +3 -3
- package/src/plugin/plugin.js +8 -8
- package/src/polyfill/index.js +0 -2
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/container.js +76 -58
- package/src/renderable/dragndrop.js +4 -4
- package/src/renderable/imagelayer.js +6 -5
- package/src/renderable/light2d.js +5 -5
- package/src/renderable/nineslicesprite.js +11 -11
- package/src/renderable/renderable.js +34 -12
- package/src/renderable/sprite.js +24 -24
- package/src/renderable/trigger.js +10 -8
- package/src/renderable/ui/uibaseelement.js +96 -26
- package/src/renderable/ui/uispriteelement.js +24 -24
- package/src/renderable/ui/uitextbutton.js +85 -67
- package/src/state/stage.js +6 -6
- package/src/state/state.js +14 -14
- package/src/system/device.js +2 -2
- package/src/system/event.js +1 -1
- package/src/system/pooling.js +8 -8
- package/src/system/save.js +5 -5
- package/src/system/timer.js +15 -11
- package/src/text/bitmaptext.js +19 -19
- package/src/text/bitmaptextdata.js +21 -21
- package/src/text/glyph.js +2 -2
- package/src/text/text.js +62 -91
- package/src/text/textmetrics.js +14 -14
- package/src/text/textstyle.js +3 -5
- package/src/tweens/easing.js +3 -3
- package/src/tweens/interpolation.js +7 -7
- package/src/tweens/tween.js +10 -10
- package/src/utils/agent.js +5 -5
- package/src/utils/array.js +3 -3
- package/src/utils/function.js +4 -4
- package/src/utils/string.js +2 -2
- package/src/utils/utils.js +15 -15
- package/src/video/canvas/canvas_renderer.js +39 -117
- package/src/video/renderer.js +68 -12
- package/src/video/texture/atlas.js +38 -44
- package/src/video/texture/cache.js +6 -6
- package/src/video/texture/canvas_texture.js +62 -2
- package/src/video/video.js +1 -1
- package/src/video/webgl/buffer/vertex.js +22 -18
- package/src/video/webgl/compositors/compositor.js +79 -80
- package/src/video/webgl/compositors/primitive_compositor.js +68 -0
- package/src/video/webgl/compositors/{webgl_compositor.js → quad_compositor.js} +52 -109
- package/src/video/webgl/glshader.js +6 -6
- package/src/video/webgl/shaders/primitive.vert +2 -5
- package/src/video/webgl/shaders/quad.vert +3 -1
- package/src/video/webgl/utils/attributes.js +1 -1
- package/src/video/webgl/utils/program.js +6 -6
- package/src/video/webgl/utils/uniforms.js +3 -3
- package/src/video/webgl/webgl_renderer.js +186 -179
- package/dist/melonjs.mjs/_virtual/make-built-in.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-define-property.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-descriptor.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-names.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-symbols.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-property-is-enumerable.js +0 -10
- package/dist/melonjs.mjs/_virtual/shared.js +0 -10
- package/dist/melonjs.mjs/game.js +0 -29
- package/dist/melonjs.mjs/polyfill/console.js +0 -18
- package/dist/melonjs.mjs/polyfill/performance.js +0 -27
- package/dist/melonjs.mjs/polyfill/requestAnimationFrame.js +0 -46
- package/dist/melonjs.mjs/polyfill/roundrect.js +0 -242
- package/dist/melonjs.mjs/renderable/re_container.js +0 -1016
- package/dist/melonjs.mjs/video/utils/resize.js +0 -116
- package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +0 -494
- package/src/polyfill/performance.js +0 -20
- package/src/polyfill/requestAnimationFrame.js +0 -39
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -64,12 +64,12 @@ let globalFloatingCounter = 0;
|
|
|
64
64
|
this.children = undefined;
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* The property of the child object that should be used to sort on
|
|
67
|
+
* The property of the child object that should be used to sort on this container
|
|
68
68
|
* value : "x", "y", "z"
|
|
69
69
|
* @type {string}
|
|
70
|
-
* @default
|
|
70
|
+
* @default "z"
|
|
71
71
|
*/
|
|
72
|
-
this.sortOn =
|
|
72
|
+
this.sortOn = "z";
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Specify if the children list should be automatically sorted when adding a new child
|
|
@@ -157,8 +157,8 @@ let globalFloatingCounter = 0;
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// delete all children
|
|
160
|
-
|
|
161
|
-
for (
|
|
160
|
+
let children = this.getChildren();
|
|
161
|
+
for (let i = children.length, child; i >= 0; (child = children[--i])) {
|
|
162
162
|
// don't remove it if a persistent object
|
|
163
163
|
if (child && child.isPersistent !== true) {
|
|
164
164
|
this.removeChildNow(child);
|
|
@@ -177,9 +177,9 @@ let globalFloatingCounter = 0;
|
|
|
177
177
|
* Add a child to the container <br>
|
|
178
178
|
* if auto-sort is disable, the object will be appended at the bottom of the list.
|
|
179
179
|
* Adding a child to the container will automatically remove it from its other container.
|
|
180
|
-
* Meaning a child can only have one parent.
|
|
181
|
-
* to a container then add it to the
|
|
182
|
-
* orginal container. Then when the
|
|
180
|
+
* Meaning a child can only have one parent. This is important if you add a renderable
|
|
181
|
+
* to a container then add it to the World container it will move it out of the
|
|
182
|
+
* orginal container. Then when the World container reset() method is called the renderable
|
|
183
183
|
* will not be in any container. <br>
|
|
184
184
|
* if the given child implements a onActivateEvent method, that method will be called
|
|
185
185
|
* once the child is added to this container.
|
|
@@ -226,7 +226,7 @@ let globalFloatingCounter = 0;
|
|
|
226
226
|
|
|
227
227
|
// force repaint in case this is a static non-animated object
|
|
228
228
|
if (this.isAttachedToRoot() === true) {
|
|
229
|
-
|
|
229
|
+
this.isDirty = true;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
// force bounds update if required
|
|
@@ -236,7 +236,7 @@ let globalFloatingCounter = 0;
|
|
|
236
236
|
|
|
237
237
|
// if a physic body is defined, add it to the game world
|
|
238
238
|
if (child.body instanceof Body) {
|
|
239
|
-
|
|
239
|
+
this.getRootAncestor().addBody(child.body);
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
// triggered callback if defined
|
|
@@ -275,7 +275,7 @@ let globalFloatingCounter = 0;
|
|
|
275
275
|
|
|
276
276
|
// force repaint in case this is a static non-animated object
|
|
277
277
|
if (this.isAttachedToRoot() === true) {
|
|
278
|
-
|
|
278
|
+
this.isDirty = true;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
// force bounds update if required
|
|
@@ -285,7 +285,7 @@ let globalFloatingCounter = 0;
|
|
|
285
285
|
|
|
286
286
|
// if a physic body is defined, add it to the game world
|
|
287
287
|
if (child.body instanceof Body) {
|
|
288
|
-
|
|
288
|
+
this.getRootAncestor().addBody(child.body);
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
// triggered callback if defined
|
|
@@ -307,20 +307,20 @@ let globalFloatingCounter = 0;
|
|
|
307
307
|
* @param {Function} callback - fnction to execute on each element
|
|
308
308
|
* @param {object} [thisArg] - value to use as this(i.e reference Object) when executing callback.
|
|
309
309
|
* @example
|
|
310
|
-
* // iterate through all children of
|
|
311
|
-
*
|
|
310
|
+
* // iterate through all children of this container
|
|
311
|
+
* container.forEach((child) => {
|
|
312
312
|
* // do something with the child
|
|
313
313
|
* child.doSomething();
|
|
314
314
|
* });
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
315
|
+
* container.forEach((child, index) => { ... });
|
|
316
|
+
* container.forEach((child, index, array) => { ... });
|
|
317
|
+
* container.forEach((child, index, array) => { ... }, thisArg);
|
|
318
318
|
*/
|
|
319
319
|
forEach(callback, thisArg) {
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
let context = this, i = 0;
|
|
321
|
+
let children = this.getChildren();
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
let len = children.length;
|
|
324
324
|
|
|
325
325
|
if (typeof callback !== "function") {
|
|
326
326
|
throw new Error(callback + " is not a function");
|
|
@@ -342,12 +342,12 @@ let globalFloatingCounter = 0;
|
|
|
342
342
|
* @param {Renderable} child2
|
|
343
343
|
*/
|
|
344
344
|
swapChildren(child, child2) {
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
let index = this.getChildIndex(child);
|
|
346
|
+
let index2 = this.getChildIndex(child2);
|
|
347
347
|
|
|
348
348
|
if ((index !== -1) && (index2 !== -1)) {
|
|
349
349
|
// swap z index
|
|
350
|
-
|
|
350
|
+
let _z = child.pos.z;
|
|
351
351
|
child.pos.z = child2.pos.z;
|
|
352
352
|
child2.pos.z = _z;
|
|
353
353
|
// swap the positions..
|
|
@@ -390,7 +390,7 @@ let globalFloatingCounter = 0;
|
|
|
390
390
|
* @returns {Renderable} child
|
|
391
391
|
*/
|
|
392
392
|
getNextChild(child) {
|
|
393
|
-
|
|
393
|
+
let index = this.getChildren().indexOf(child) - 1;
|
|
394
394
|
if (index >= 0 && index < this.getChildren().length) {
|
|
395
395
|
return this.getChildAt(index);
|
|
396
396
|
}
|
|
@@ -415,27 +415,27 @@ let globalFloatingCounter = 0;
|
|
|
415
415
|
* @returns {Renderable[]} Array of childs
|
|
416
416
|
* @example
|
|
417
417
|
* // get the first child object called "mainPlayer" in a specific container :
|
|
418
|
-
*
|
|
418
|
+
* let ent = myContainer.getChildByProp("name", "mainPlayer");
|
|
419
419
|
*
|
|
420
420
|
* // or query the whole world :
|
|
421
|
-
*
|
|
421
|
+
* let ent = container.getChildByProp("name", "mainPlayer");
|
|
422
422
|
*
|
|
423
423
|
* // partial property matches are also allowed by using a RegExp.
|
|
424
424
|
* // the following matches "redCOIN", "bluecoin", "bagOfCoins", etc :
|
|
425
|
-
*
|
|
425
|
+
* let allCoins = container.getChildByProp("name", /coin/i);
|
|
426
426
|
*
|
|
427
427
|
* // searching for numbers or other data types :
|
|
428
|
-
*
|
|
429
|
-
*
|
|
428
|
+
* let zIndex10 = container.getChildByProp("z", 10);
|
|
429
|
+
* let inViewport = container.getChildByProp("inViewport", true);
|
|
430
430
|
*/
|
|
431
431
|
getChildByProp(prop, value) {
|
|
432
|
-
|
|
432
|
+
let objList = [];
|
|
433
433
|
|
|
434
434
|
/**
|
|
435
435
|
* @ignore
|
|
436
436
|
*/
|
|
437
437
|
function compare(obj, prop) {
|
|
438
|
-
|
|
438
|
+
let v = obj[prop];
|
|
439
439
|
if (value instanceof RegExp && typeof(v) === "string") {
|
|
440
440
|
if (value.test(v)) {
|
|
441
441
|
objList.push(obj);
|
|
@@ -462,7 +462,7 @@ let globalFloatingCounter = 0;
|
|
|
462
462
|
* @returns {Renderable[]} Array of children
|
|
463
463
|
*/
|
|
464
464
|
getChildByType(classType) {
|
|
465
|
-
|
|
465
|
+
let objList = [];
|
|
466
466
|
|
|
467
467
|
this.forEach((child) => {
|
|
468
468
|
if (child instanceof classType) {
|
|
@@ -496,7 +496,7 @@ let globalFloatingCounter = 0;
|
|
|
496
496
|
* @returns {Renderable} corresponding child or null
|
|
497
497
|
*/
|
|
498
498
|
getChildByGUID(guid) {
|
|
499
|
-
|
|
499
|
+
let obj = this.getChildByProp("GUID", guid);
|
|
500
500
|
return (obj.length > 0) ? obj[0] : null;
|
|
501
501
|
}
|
|
502
502
|
|
|
@@ -518,7 +518,7 @@ let globalFloatingCounter = 0;
|
|
|
518
518
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
519
519
|
*/
|
|
520
520
|
updateBounds(absolute = true) {
|
|
521
|
-
|
|
521
|
+
let bounds = this.getBounds();
|
|
522
522
|
|
|
523
523
|
// call parent method
|
|
524
524
|
super.updateBounds(absolute);
|
|
@@ -526,7 +526,7 @@ let globalFloatingCounter = 0;
|
|
|
526
526
|
if (this.enableChildBoundsUpdate === true) {
|
|
527
527
|
this.forEach((child) => {
|
|
528
528
|
if (child.isRenderable) {
|
|
529
|
-
|
|
529
|
+
let childBounds = child.getBounds();
|
|
530
530
|
if (childBounds.isFinite()) {
|
|
531
531
|
bounds.addBounds(childBounds);
|
|
532
532
|
}
|
|
@@ -538,14 +538,13 @@ let globalFloatingCounter = 0;
|
|
|
538
538
|
|
|
539
539
|
/**
|
|
540
540
|
* Checks if this container is root or if it's attached to the root container.
|
|
541
|
-
* @private
|
|
542
541
|
* @returns {boolean}
|
|
543
542
|
*/
|
|
544
543
|
isAttachedToRoot() {
|
|
545
544
|
if (this.root === true) {
|
|
546
545
|
return true;
|
|
547
546
|
} else {
|
|
548
|
-
|
|
547
|
+
let ancestor = this.ancestor;
|
|
549
548
|
while (ancestor) {
|
|
550
549
|
if (ancestor.root === true) {
|
|
551
550
|
return true;
|
|
@@ -556,6 +555,25 @@ let globalFloatingCounter = 0;
|
|
|
556
555
|
}
|
|
557
556
|
}
|
|
558
557
|
|
|
558
|
+
/**
|
|
559
|
+
* Returns the instance of the root container (i.e. the current application World container).
|
|
560
|
+
* @returns {Container}
|
|
561
|
+
*/
|
|
562
|
+
getRootAncestor() {
|
|
563
|
+
if (this.root === true) {
|
|
564
|
+
return this;
|
|
565
|
+
} else {
|
|
566
|
+
let ancestor = this.ancestor;
|
|
567
|
+
while (ancestor) {
|
|
568
|
+
if (ancestor.root === true) {
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
ancestor = ancestor.ancestor;
|
|
572
|
+
}
|
|
573
|
+
return ancestor;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
559
577
|
/**
|
|
560
578
|
* update the cointainer's bounding rect (private)
|
|
561
579
|
* @ignore
|
|
@@ -617,7 +635,7 @@ let globalFloatingCounter = 0;
|
|
|
617
635
|
// remove the body first to avoid a condition where a body can be detached
|
|
618
636
|
// from its parent, before the body is removed from the game world
|
|
619
637
|
if (child.body instanceof Body) {
|
|
620
|
-
|
|
638
|
+
this.getRootAncestor().removeBody(child.body);
|
|
621
639
|
}
|
|
622
640
|
|
|
623
641
|
if (!keepalive) {
|
|
@@ -632,7 +650,7 @@ let globalFloatingCounter = 0;
|
|
|
632
650
|
|
|
633
651
|
// Don't cache the child index; another element might have been removed
|
|
634
652
|
// by the child's `onDeactivateEvent` or `destroy` methods
|
|
635
|
-
|
|
653
|
+
let childIndex = this.getChildIndex(child);
|
|
636
654
|
if (childIndex >= 0) {
|
|
637
655
|
this.getChildren().splice(childIndex, 1);
|
|
638
656
|
child.ancestor = undefined;
|
|
@@ -640,7 +658,7 @@ let globalFloatingCounter = 0;
|
|
|
640
658
|
|
|
641
659
|
// force repaint in case this is a static non-animated object
|
|
642
660
|
if (this.isAttachedToRoot() === true) {
|
|
643
|
-
|
|
661
|
+
this.isDirty = true;
|
|
644
662
|
}
|
|
645
663
|
|
|
646
664
|
// force bounds update if required
|
|
@@ -673,7 +691,7 @@ let globalFloatingCounter = 0;
|
|
|
673
691
|
* @param {Renderable} child
|
|
674
692
|
*/
|
|
675
693
|
moveUp(child) {
|
|
676
|
-
|
|
694
|
+
let childIndex = this.getChildIndex(child);
|
|
677
695
|
if (childIndex - 1 >= 0) {
|
|
678
696
|
// note : we use an inverted loop
|
|
679
697
|
this.swapChildren(child, this.getChildAt(childIndex - 1));
|
|
@@ -687,7 +705,7 @@ let globalFloatingCounter = 0;
|
|
|
687
705
|
* @param {Renderable} child
|
|
688
706
|
*/
|
|
689
707
|
moveDown(child) {
|
|
690
|
-
|
|
708
|
+
let childIndex = this.getChildIndex(child);
|
|
691
709
|
if (childIndex >= 0 && (childIndex + 1) < this.getChildren().length) {
|
|
692
710
|
// note : we use an inverted loop
|
|
693
711
|
this.swapChildren(child, this.getChildAt(childIndex + 1));
|
|
@@ -701,9 +719,9 @@ let globalFloatingCounter = 0;
|
|
|
701
719
|
* @param {Renderable} child
|
|
702
720
|
*/
|
|
703
721
|
moveToTop(child) {
|
|
704
|
-
|
|
722
|
+
let childIndex = this.getChildIndex(child);
|
|
705
723
|
if (childIndex > 0) {
|
|
706
|
-
|
|
724
|
+
let children = this.getChildren();
|
|
707
725
|
// note : we use an inverted loop
|
|
708
726
|
children.splice(0, 0, children.splice(childIndex, 1)[0]);
|
|
709
727
|
// increment our child z value based on the previous child depth
|
|
@@ -718,8 +736,8 @@ let globalFloatingCounter = 0;
|
|
|
718
736
|
* @param {Renderable} child
|
|
719
737
|
*/
|
|
720
738
|
moveToBottom(child) {
|
|
721
|
-
|
|
722
|
-
|
|
739
|
+
let childIndex = this.getChildIndex(child);
|
|
740
|
+
let children = this.getChildren();
|
|
723
741
|
if (childIndex >= 0 && childIndex < (children.length - 1)) {
|
|
724
742
|
// note : we use an inverted loop
|
|
725
743
|
children.splice((children.length - 1), 0, children.splice(childIndex, 1)[0]);
|
|
@@ -753,7 +771,7 @@ let globalFloatingCounter = 0;
|
|
|
753
771
|
// clear the defer id
|
|
754
772
|
this.pendingSort = null;
|
|
755
773
|
// make sure we redraw everything
|
|
756
|
-
|
|
774
|
+
this.isDirty = true;
|
|
757
775
|
}, this);
|
|
758
776
|
}
|
|
759
777
|
}
|
|
@@ -793,7 +811,7 @@ let globalFloatingCounter = 0;
|
|
|
793
811
|
if (!b.pos || !a.pos) {
|
|
794
812
|
return (a.pos ? -Infinity : Infinity);
|
|
795
813
|
}
|
|
796
|
-
|
|
814
|
+
let result = b.pos.z - a.pos.z;
|
|
797
815
|
return (result ? result : (b.pos.x - a.pos.x));
|
|
798
816
|
}
|
|
799
817
|
|
|
@@ -805,7 +823,7 @@ let globalFloatingCounter = 0;
|
|
|
805
823
|
if (!b.pos || !a.pos) {
|
|
806
824
|
return (a.pos ? -Infinity : Infinity);
|
|
807
825
|
}
|
|
808
|
-
|
|
826
|
+
let result = b.pos.z - a.pos.z;
|
|
809
827
|
return (result ? result : (b.pos.y - a.pos.y));
|
|
810
828
|
}
|
|
811
829
|
|
|
@@ -822,17 +840,17 @@ let globalFloatingCounter = 0;
|
|
|
822
840
|
|
|
823
841
|
/**
|
|
824
842
|
* container update function. <br>
|
|
825
|
-
* automatically called by the
|
|
843
|
+
* automatically called by the application update loop {@link Application}
|
|
826
844
|
* @protected
|
|
827
845
|
* @param {number} dt - time since the last update in milliseconds.
|
|
828
846
|
* @returns {boolean} true if the Container is dirty
|
|
829
847
|
*/
|
|
830
848
|
update(dt) {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
849
|
+
let isFloating = false;
|
|
850
|
+
let isPaused = state.isPaused();
|
|
851
|
+
let children = this.getChildren();
|
|
834
852
|
|
|
835
|
-
for (
|
|
853
|
+
for (let i = children.length, obj; i--, (obj = children[i]);) {
|
|
836
854
|
if (isPaused && (!obj.updateWhenPaused)) {
|
|
837
855
|
// skip this object
|
|
838
856
|
continue;
|
|
@@ -877,8 +895,8 @@ let globalFloatingCounter = 0;
|
|
|
877
895
|
* @param {Camera2d} [viewport] - the viewport to (re)draw
|
|
878
896
|
*/
|
|
879
897
|
draw(renderer, viewport) {
|
|
880
|
-
|
|
881
|
-
|
|
898
|
+
let isFloating = false;
|
|
899
|
+
let bounds = this.getBounds();
|
|
882
900
|
|
|
883
901
|
this.drawCount = 0;
|
|
884
902
|
|
|
@@ -900,8 +918,8 @@ let globalFloatingCounter = 0;
|
|
|
900
918
|
renderer.clearColor(this.backgroundColor);
|
|
901
919
|
}
|
|
902
920
|
|
|
903
|
-
|
|
904
|
-
for (
|
|
921
|
+
let children = this.getChildren();
|
|
922
|
+
for (let i = children.length, obj; i--, (obj = children[i]);) {
|
|
905
923
|
if (obj.isRenderable) {
|
|
906
924
|
|
|
907
925
|
isFloating = obj.floating === true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -43,10 +43,10 @@ class Draggable extends Renderable {
|
|
|
43
43
|
* @private
|
|
44
44
|
*/
|
|
45
45
|
initEvents() {
|
|
46
|
-
registerPointerEvent("pointerdown", this, (e) =>
|
|
47
|
-
registerPointerEvent("pointerup", this, (e) =>
|
|
48
|
-
registerPointerEvent("pointercancel", this, (e) =>
|
|
49
|
-
on(POINTERMOVE, this.dragMove
|
|
46
|
+
registerPointerEvent("pointerdown", this, (e) => emit(DRAGSTART, e, this));
|
|
47
|
+
registerPointerEvent("pointerup", this, (e) => emit(DRAGEND, e, this));
|
|
48
|
+
registerPointerEvent("pointercancel", this, (e) => emit(DRAGEND, e, this));
|
|
49
|
+
on(POINTERMOVE, (e) => this.dragMove(e));
|
|
50
50
|
on(DRAGSTART, (e, draggable) => {
|
|
51
51
|
if (draggable === this) {
|
|
52
52
|
this.dragStart(e);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -189,7 +189,7 @@ import { isNumeric } from '../utils/string.js';
|
|
|
189
189
|
* @ignore
|
|
190
190
|
*/
|
|
191
191
|
updateLayer(vpos) {
|
|
192
|
-
|
|
192
|
+
const rx = this.ratio.x,
|
|
193
193
|
ry = this.ratio.y;
|
|
194
194
|
|
|
195
195
|
if (rx === 0 && ry === 0) {
|
|
@@ -197,7 +197,7 @@ import { isNumeric } from '../utils/string.js';
|
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
const width = this.width,
|
|
201
201
|
height = this.height,
|
|
202
202
|
bw = game.viewport.bounds.width,
|
|
203
203
|
bh = game.viewport.bounds.height,
|
|
@@ -263,13 +263,14 @@ import { isNumeric } from '../utils/string.js';
|
|
|
263
263
|
* @param {Camera2d} [viewport] - the viewport to (re)draw
|
|
264
264
|
*/
|
|
265
265
|
draw(renderer, viewport) {
|
|
266
|
-
|
|
266
|
+
const width = this.width,
|
|
267
267
|
height = this.height,
|
|
268
268
|
bw = viewport.bounds.width,
|
|
269
269
|
bh = viewport.bounds.height,
|
|
270
270
|
ax = this.anchorPoint.x,
|
|
271
|
-
ay = this.anchorPoint.y
|
|
272
|
-
|
|
271
|
+
ay = this.anchorPoint.y;
|
|
272
|
+
|
|
273
|
+
let x = this.pos.x,
|
|
273
274
|
y = this.pos.y;
|
|
274
275
|
|
|
275
276
|
if (this.ratio.x === 0 && this.ratio.y === 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -10,16 +10,16 @@ import Renderable from './renderable.js';
|
|
|
10
10
|
|
|
11
11
|
/** @ignore */
|
|
12
12
|
function createGradient(light) {
|
|
13
|
-
|
|
13
|
+
let context = light.texture.context;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
let x1 = light.texture.width / 2,
|
|
16
16
|
y1 = light.texture.height / 2;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
let radiusX = light.radiusX,
|
|
19
19
|
radiusY = light.radiusY;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
let scaleX, scaleY, invScaleX, invScaleY;
|
|
22
|
+
let gradient;
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
light.texture.clear();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -93,18 +93,18 @@ import Sprite from './sprite.js';
|
|
|
93
93
|
*/
|
|
94
94
|
draw(renderer) {
|
|
95
95
|
// the frame to draw
|
|
96
|
-
|
|
96
|
+
let frame = this.current;
|
|
97
97
|
|
|
98
98
|
// cache the current position and size
|
|
99
|
-
|
|
99
|
+
let dx = this.pos.x,
|
|
100
100
|
dy = this.pos.y;
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
let w = frame.width,
|
|
103
103
|
h = frame.height;
|
|
104
104
|
|
|
105
105
|
// frame offset in the texture/atlas
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
let frame_offset = frame.offset;
|
|
107
|
+
let g_offset = this.offset;
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
// remove image's TexturePacker/ShoeBox rotation
|
|
@@ -116,11 +116,11 @@ import Sprite from './sprite.js';
|
|
|
116
116
|
h = frame.width;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
let sx = g_offset.x + frame_offset.x,
|
|
120
120
|
sy = g_offset.y + frame_offset.y;
|
|
121
121
|
|
|
122
122
|
// should this be configurable ?
|
|
123
|
-
|
|
123
|
+
let corner_width = this.insetx || w / 4,
|
|
124
124
|
corner_height = this.insety || h / 4;
|
|
125
125
|
|
|
126
126
|
// OPTIMIZE ME !
|
|
@@ -170,11 +170,11 @@ import Sprite from './sprite.js';
|
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
// DRAW SIDES and CENTER
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
let image_center_width = w - (corner_width << 1);
|
|
174
|
+
let image_center_height = h - (corner_height << 1);
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
let target_center_width = this.nss_width - (corner_width << 1);
|
|
177
|
+
let target_center_height = this.nss_height - (corner_height << 1);
|
|
178
178
|
|
|
179
179
|
//Top center
|
|
180
180
|
renderer.drawImage(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -213,6 +213,13 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
213
213
|
*/
|
|
214
214
|
this.mask = undefined;
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* (Experimental) an optional shader, to be used instead of the default built-in one, when drawing this renderable (WebGL only)
|
|
218
|
+
* @type {GLShader}
|
|
219
|
+
* @default undefined
|
|
220
|
+
*/
|
|
221
|
+
this.shader = undefined;
|
|
222
|
+
|
|
216
223
|
/**
|
|
217
224
|
* the blend mode to be applied to this renderable (see renderer setBlendMode for available blend mode)
|
|
218
225
|
* @type {string}
|
|
@@ -426,11 +433,11 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
426
433
|
* @returns {number} angle in radians
|
|
427
434
|
*/
|
|
428
435
|
angleTo(target) {
|
|
429
|
-
|
|
430
|
-
|
|
436
|
+
let a = this.getBounds();
|
|
437
|
+
let ax, ay;
|
|
431
438
|
|
|
432
439
|
if (target instanceof Renderable) {
|
|
433
|
-
|
|
440
|
+
let b = target.getBounds();
|
|
434
441
|
ax = b.centerX - a.centerX;
|
|
435
442
|
ay = b.centerY - a.centerY;
|
|
436
443
|
} else { // vector object
|
|
@@ -447,11 +454,11 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
447
454
|
* @returns {number} distance
|
|
448
455
|
*/
|
|
449
456
|
distanceTo(target) {
|
|
450
|
-
|
|
451
|
-
|
|
457
|
+
let a = this.getBounds();
|
|
458
|
+
let dx, dy;
|
|
452
459
|
|
|
453
460
|
if (target instanceof Renderable) {
|
|
454
|
-
|
|
461
|
+
let b = target.getBounds();
|
|
455
462
|
dx = a.centerX - b.centerX;
|
|
456
463
|
dy = a.centerY - b.centerY;
|
|
457
464
|
} else { // vector object
|
|
@@ -468,7 +475,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
468
475
|
* @returns {Renderable} Reference to this object for method chaining
|
|
469
476
|
*/
|
|
470
477
|
lookAt(target) {
|
|
471
|
-
|
|
478
|
+
let position;
|
|
472
479
|
|
|
473
480
|
if (target instanceof Renderable) {
|
|
474
481
|
position = target.pos;
|
|
@@ -476,7 +483,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
476
483
|
position = target;
|
|
477
484
|
}
|
|
478
485
|
|
|
479
|
-
|
|
486
|
+
let angle = this.angleTo(position);
|
|
480
487
|
|
|
481
488
|
this.rotate(angle);
|
|
482
489
|
|
|
@@ -541,7 +548,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
541
548
|
*/
|
|
542
549
|
updateBounds(absolute = true) {
|
|
543
550
|
if (this.isRenderable) {
|
|
544
|
-
|
|
551
|
+
let bounds = this.getBounds();
|
|
545
552
|
|
|
546
553
|
bounds.clear();
|
|
547
554
|
|
|
@@ -627,9 +634,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
627
634
|
// manually update the anchor point (required for updateBoundsPos)
|
|
628
635
|
this.anchorPoint.setMuted(x, y);
|
|
629
636
|
// then call updateBounds
|
|
630
|
-
//this.updateBoundsPos(this.pos.x, this.pos.y);
|
|
631
637
|
this.updateBounds();
|
|
632
|
-
//console.log("hello");
|
|
633
638
|
this.isDirty = true;
|
|
634
639
|
}
|
|
635
640
|
|
|
@@ -641,7 +646,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
641
646
|
* @param {CanvasRenderer|WebGLRenderer} renderer - a renderer object
|
|
642
647
|
*/
|
|
643
648
|
preDraw(renderer) {
|
|
644
|
-
|
|
649
|
+
let ax = this.width * this.anchorPoint.x,
|
|
645
650
|
ay = this.height * this.anchorPoint.y;
|
|
646
651
|
|
|
647
652
|
// save renderer context
|
|
@@ -657,6 +662,11 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
657
662
|
renderer.translate(-this.pos.x, -this.pos.y);
|
|
658
663
|
}
|
|
659
664
|
|
|
665
|
+
// use this renderable shader if defined
|
|
666
|
+
if (typeof this.shader === "object" && typeof renderer.gl !== "undefined") {
|
|
667
|
+
renderer.customShader = this.shader;
|
|
668
|
+
}
|
|
669
|
+
|
|
660
670
|
if ((this.autoTransform === true) && (!this.currentTransform.isIdentity())) {
|
|
661
671
|
// apply the renderable transformation matrix
|
|
662
672
|
renderer.translate(this.pos.x, this.pos.y);
|
|
@@ -708,6 +718,12 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
708
718
|
renderer.clearMask();
|
|
709
719
|
}
|
|
710
720
|
|
|
721
|
+
// revert to the default shader if defined
|
|
722
|
+
if (typeof this.shader === "object" && typeof renderer.gl !== "undefined") {
|
|
723
|
+
renderer.customShader = undefined;
|
|
724
|
+
//renderer.setCompositor("quad");
|
|
725
|
+
}
|
|
726
|
+
|
|
711
727
|
// restore the context
|
|
712
728
|
renderer.restore();
|
|
713
729
|
|
|
@@ -787,6 +803,12 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
787
803
|
|
|
788
804
|
// call the user defined destroy method
|
|
789
805
|
this.onDestroyEvent.apply(this, arguments);
|
|
806
|
+
|
|
807
|
+
// destroy any shader object if not done by the user through onDestroyEvent()
|
|
808
|
+
if (typeof this.shader === "object") {
|
|
809
|
+
this.shader.destroy();
|
|
810
|
+
this.shader = undefined;
|
|
811
|
+
}
|
|
790
812
|
}
|
|
791
813
|
|
|
792
814
|
/**
|