@vpmedia/phaser 1.11.0 → 1.13.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/README.md +1 -1
- package/package.json +8 -5
- package/src/index.js +19 -19
- package/src/phaser/core/animation.js +12 -9
- package/src/phaser/core/animation_manager.js +16 -6
- package/src/phaser/core/animation_parser.js +40 -17
- package/src/phaser/core/array_set.js +3 -5
- package/src/phaser/core/cache.js +12 -12
- package/src/phaser/core/const.js +1 -1
- package/src/phaser/core/device.js +2 -4
- package/src/phaser/core/device_util.js +50 -17
- package/src/phaser/core/dom.js +36 -27
- package/src/phaser/core/event_manager.js +47 -19
- package/src/phaser/core/factory.js +34 -12
- package/src/phaser/core/frame.js +3 -5
- package/src/phaser/core/frame_data.js +2 -4
- package/src/phaser/core/frame_util.js +11 -9
- package/src/phaser/core/game.js +22 -19
- package/src/phaser/core/input.js +24 -16
- package/src/phaser/core/input_handler.js +102 -28
- package/src/phaser/core/input_mouse.js +12 -16
- package/src/phaser/core/input_mspointer.js +11 -10
- package/src/phaser/core/input_pointer.js +61 -20
- package/src/phaser/core/input_touch.js +7 -9
- package/src/phaser/core/loader.js +171 -54
- package/src/phaser/core/loader_parser.js +29 -22
- package/src/phaser/core/raf.js +2 -4
- package/src/phaser/core/scale_manager.js +75 -31
- package/src/phaser/core/scene.js +2 -4
- package/src/phaser/core/scene_manager.js +9 -6
- package/src/phaser/core/signal.js +19 -11
- package/src/phaser/core/signal_binding.js +12 -7
- package/src/phaser/core/sound.js +23 -14
- package/src/phaser/core/sound_manager.js +62 -26
- package/src/phaser/core/sound_sprite.js +34 -34
- package/src/phaser/core/stage.js +4 -7
- package/src/phaser/core/time.js +3 -5
- package/src/phaser/core/timer.js +27 -10
- package/src/phaser/core/timer_event.js +1 -3
- package/src/phaser/core/tween.js +36 -12
- package/src/phaser/core/tween_data.js +17 -9
- package/src/phaser/core/tween_easing.js +87 -83
- package/src/phaser/core/tween_manager.js +34 -16
- package/src/phaser/core/world.js +3 -5
- package/src/phaser/display/bitmap_text.js +25 -14
- package/src/phaser/display/button.js +35 -8
- package/src/phaser/display/canvas/buffer.js +1 -3
- package/src/phaser/display/canvas/graphics.js +30 -15
- package/src/phaser/display/canvas/masker.js +7 -5
- package/src/phaser/display/canvas/pool.js +18 -11
- package/src/phaser/display/canvas/renderer.js +40 -20
- package/src/phaser/display/canvas/tinter.js +61 -19
- package/src/phaser/display/canvas/util.js +44 -35
- package/src/phaser/display/display_object.js +42 -24
- package/src/phaser/display/graphics.js +72 -39
- package/src/phaser/display/graphics_data.js +3 -4
- package/src/phaser/display/graphics_data_util.js +15 -5
- package/src/phaser/display/group.js +15 -9
- package/src/phaser/display/image.js +17 -9
- package/src/phaser/display/sprite_batch.js +8 -4
- package/src/phaser/display/sprite_util.js +67 -26
- package/src/phaser/display/text.js +92 -31
- package/src/phaser/display/webgl/abstract_filter.js +1 -3
- package/src/phaser/display/webgl/base_texture.js +8 -5
- package/src/phaser/display/webgl/blend_manager.js +1 -3
- package/src/phaser/display/webgl/earcut.js +170 -129
- package/src/phaser/display/webgl/earcut_node.js +1 -3
- package/src/phaser/display/webgl/fast_sprite_batch.js +48 -47
- package/src/phaser/display/webgl/filter_manager.js +1 -3
- package/src/phaser/display/webgl/filter_texture.js +17 -6
- package/src/phaser/display/webgl/graphics.js +72 -50
- package/src/phaser/display/webgl/graphics_data.js +2 -4
- package/src/phaser/display/webgl/mask_manager.js +17 -7
- package/src/phaser/display/webgl/render_texture.js +19 -10
- package/src/phaser/display/webgl/renderer.js +41 -9
- package/src/phaser/display/webgl/shader/complex.js +1 -3
- package/src/phaser/display/webgl/shader/fast.js +9 -4
- package/src/phaser/display/webgl/shader/normal.js +43 -15
- package/src/phaser/display/webgl/shader/primitive.js +1 -3
- package/src/phaser/display/webgl/shader/strip.js +1 -3
- package/src/phaser/display/webgl/shader_manager.js +1 -3
- package/src/phaser/display/webgl/sprite_batch.js +14 -15
- package/src/phaser/display/webgl/stencil_manager.js +19 -21
- package/src/phaser/display/webgl/texture.js +14 -10
- package/src/phaser/display/webgl/texture_util.js +11 -9
- package/src/phaser/display/webgl/util.js +21 -18
- package/src/phaser/geom/circle.js +27 -11
- package/src/phaser/geom/ellipse.js +26 -10
- package/src/phaser/geom/line.js +31 -13
- package/src/phaser/geom/matrix.js +14 -5
- package/src/phaser/geom/point.js +18 -13
- package/src/phaser/geom/polygon.js +13 -8
- package/src/phaser/geom/rectangle.js +57 -14
- package/src/phaser/geom/rounded_rectangle.js +12 -4
- package/src/phaser/geom/util/circle.js +40 -32
- package/src/phaser/geom/util/ellipse.js +10 -18
- package/src/phaser/geom/util/line.js +46 -37
- package/src/phaser/geom/util/matrix.js +11 -9
- package/src/phaser/geom/util/point.js +101 -79
- package/src/phaser/geom/util/polygon.js +7 -15
- package/src/phaser/geom/util/rectangle.js +95 -69
- package/src/phaser/geom/util/rounded_rectangle.js +7 -15
- package/src/phaser/util/math.js +123 -89
- package/types/global.d.ts +7 -0
- package/types/index.d.ts +22 -0
- package/types/index.d.ts.map +1 -0
- package/types/phaser/core/animation.d.ts +55 -0
- package/types/phaser/core/animation.d.ts.map +1 -0
- package/types/phaser/core/animation_manager.d.ts +35 -0
- package/types/phaser/core/animation_manager.d.ts.map +1 -0
- package/types/phaser/core/animation_parser.d.ts +22 -0
- package/types/phaser/core/animation_parser.d.ts.map +1 -0
- package/types/phaser/core/array_set.d.ts +23 -0
- package/types/phaser/core/array_set.d.ts.map +1 -0
- package/types/phaser/core/cache.d.ts +106 -0
- package/types/phaser/core/cache.d.ts.map +1 -0
- package/types/phaser/core/const.d.ts +81 -0
- package/types/phaser/core/const.d.ts.map +1 -0
- package/types/phaser/core/device.d.ts +36 -0
- package/types/phaser/core/device.d.ts.map +1 -0
- package/types/phaser/core/device_util.d.ts +58 -0
- package/types/phaser/core/device_util.d.ts.map +1 -0
- package/types/phaser/core/dom.d.ts +63 -0
- package/types/phaser/core/dom.d.ts.map +1 -0
- package/types/phaser/core/event_manager.d.ts +53 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -0
- package/types/phaser/core/factory.d.ts +12 -0
- package/types/phaser/core/factory.d.ts.map +1 -0
- package/types/phaser/core/frame.d.ts +30 -0
- package/types/phaser/core/frame.d.ts.map +1 -0
- package/types/phaser/core/frame_data.d.ts +14 -0
- package/types/phaser/core/frame_data.d.ts.map +1 -0
- package/types/phaser/core/frame_util.d.ts +17 -0
- package/types/phaser/core/frame_util.d.ts.map +1 -0
- package/types/phaser/core/game.d.ts +57 -0
- package/types/phaser/core/game.d.ts.map +1 -0
- package/types/phaser/core/input.d.ts +92 -0
- package/types/phaser/core/input.d.ts.map +1 -0
- package/types/phaser/core/input_handler.d.ts +111 -0
- package/types/phaser/core/input_handler.d.ts.map +1 -0
- package/types/phaser/core/input_mouse.d.ts +39 -0
- package/types/phaser/core/input_mouse.d.ts.map +1 -0
- package/types/phaser/core/input_mspointer.d.ts +34 -0
- package/types/phaser/core/input_mspointer.d.ts.map +1 -0
- package/types/phaser/core/input_pointer.d.ts +68 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -0
- package/types/phaser/core/input_touch.d.ts +37 -0
- package/types/phaser/core/input_touch.d.ts.map +1 -0
- package/types/phaser/core/loader.d.ts +94 -0
- package/types/phaser/core/loader.d.ts.map +1 -0
- package/types/phaser/core/loader_parser.d.ts +39 -0
- package/types/phaser/core/loader_parser.d.ts.map +1 -0
- package/types/phaser/core/raf.d.ts +15 -0
- package/types/phaser/core/raf.d.ts.map +1 -0
- package/types/phaser/core/scale_manager.d.ts +137 -0
- package/types/phaser/core/scale_manager.d.ts.map +1 -0
- package/types/phaser/core/scene.d.ts +17 -0
- package/types/phaser/core/scene.d.ts.map +1 -0
- package/types/phaser/core/scene_manager.d.ts +39 -0
- package/types/phaser/core/scene_manager.d.ts.map +1 -0
- package/types/phaser/core/signal.d.ts +25 -0
- package/types/phaser/core/signal.d.ts.map +1 -0
- package/types/phaser/core/signal_binding.d.ts +26 -0
- package/types/phaser/core/signal_binding.d.ts.map +1 -0
- package/types/phaser/core/sound.d.ts +72 -0
- package/types/phaser/core/sound.d.ts.map +1 -0
- package/types/phaser/core/sound_manager.d.ts +50 -0
- package/types/phaser/core/sound_manager.d.ts.map +1 -0
- package/types/phaser/core/sound_sprite.d.ts +18 -0
- package/types/phaser/core/sound_sprite.d.ts.map +1 -0
- package/types/phaser/core/stage.d.ts +23 -0
- package/types/phaser/core/stage.d.ts.map +1 -0
- package/types/phaser/core/time.d.ts +49 -0
- package/types/phaser/core/time.d.ts.map +1 -0
- package/types/phaser/core/timer.d.ts +49 -0
- package/types/phaser/core/timer.d.ts.map +1 -0
- package/types/phaser/core/timer_event.d.ts +18 -0
- package/types/phaser/core/timer_event.d.ts.map +1 -0
- package/types/phaser/core/tween.d.ts +52 -0
- package/types/phaser/core/tween.d.ts.map +1 -0
- package/types/phaser/core/tween_data.d.ts +37 -0
- package/types/phaser/core/tween_data.d.ts.map +1 -0
- package/types/phaser/core/tween_easing.d.ts +192 -0
- package/types/phaser/core/tween_easing.d.ts.map +1 -0
- package/types/phaser/core/tween_manager.d.ts +94 -0
- package/types/phaser/core/tween_manager.d.ts.map +1 -0
- package/types/phaser/core/world.d.ts +6 -0
- package/types/phaser/core/world.d.ts.map +1 -0
- package/types/phaser/display/bitmap_text.d.ts +59 -0
- package/types/phaser/display/bitmap_text.d.ts.map +1 -0
- package/types/phaser/display/button.d.ts +47 -0
- package/types/phaser/display/button.d.ts.map +1 -0
- package/types/phaser/display/canvas/buffer.d.ts +11 -0
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -0
- package/types/phaser/display/canvas/graphics.d.ts +21 -0
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
- package/types/phaser/display/canvas/masker.d.ts +14 -0
- package/types/phaser/display/canvas/masker.d.ts.map +1 -0
- package/types/phaser/display/canvas/pool.d.ts +52 -0
- package/types/phaser/display/canvas/pool.d.ts.map +1 -0
- package/types/phaser/display/canvas/renderer.d.ts +28 -0
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -0
- package/types/phaser/display/canvas/tinter.d.ts +41 -0
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
- package/types/phaser/display/canvas/util.d.ts +79 -0
- package/types/phaser/display/canvas/util.d.ts.map +1 -0
- package/types/phaser/display/display_object.d.ts +83 -0
- package/types/phaser/display/display_object.d.ts.map +1 -0
- package/types/phaser/display/graphics.d.ts +60 -0
- package/types/phaser/display/graphics.d.ts.map +1 -0
- package/types/phaser/display/graphics_data.d.ts +15 -0
- package/types/phaser/display/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/graphics_data_util.d.ts +8 -0
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
- package/types/phaser/display/group.d.ts +49 -0
- package/types/phaser/display/group.d.ts.map +1 -0
- package/types/phaser/display/image.d.ts +52 -0
- package/types/phaser/display/image.d.ts.map +1 -0
- package/types/phaser/display/sprite_batch.d.ts +11 -0
- package/types/phaser/display/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/sprite_util.d.ts +40 -0
- package/types/phaser/display/sprite_util.d.ts.map +1 -0
- package/types/phaser/display/text.d.ts +125 -0
- package/types/phaser/display/text.d.ts.map +1 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts +17 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -0
- package/types/phaser/display/webgl/base_texture.d.ts +20 -0
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/blend_manager.d.ts +14 -0
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut.d.ts +215 -0
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut_node.d.ts +19 -0
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +34 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_manager.d.ts +21 -0
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_texture.d.ts +13 -0
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics.d.ts +80 -0
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics_data.d.ts +23 -0
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/webgl/mask_manager.d.ts +15 -0
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/render_texture.d.ts +25 -0
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/renderer.d.ts +44 -0
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/complex.d.ts +22 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/fast.d.ts +25 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/normal.d.ts +25 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts +21 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/strip.d.ts +22 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader_manager.d.ts +24 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts +36 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts +12 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture.d.ts +30 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture_util.d.ts +17 -0
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
- package/types/phaser/display/webgl/util.d.ts +45 -0
- package/types/phaser/display/webgl/util.d.ts.map +1 -0
- package/types/phaser/geom/circle.d.ts +46 -0
- package/types/phaser/geom/circle.d.ts.map +1 -0
- package/types/phaser/geom/ellipse.d.ts +26 -0
- package/types/phaser/geom/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/line.d.ts +45 -0
- package/types/phaser/geom/line.d.ts.map +1 -0
- package/types/phaser/geom/matrix.d.ts +35 -0
- package/types/phaser/geom/matrix.d.ts.map +1 -0
- package/types/phaser/geom/point.d.ts +43 -0
- package/types/phaser/geom/point.d.ts.map +1 -0
- package/types/phaser/geom/polygon.d.ts +17 -0
- package/types/phaser/geom/polygon.d.ts.map +1 -0
- package/types/phaser/geom/rectangle.d.ts +71 -0
- package/types/phaser/geom/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/rounded_rectangle.d.ts +21 -0
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/circle.d.ts +64 -0
- package/types/phaser/geom/util/circle.d.ts.map +1 -0
- package/types/phaser/geom/util/ellipse.d.ts +16 -0
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/util/line.d.ts +49 -0
- package/types/phaser/geom/util/line.d.ts.map +1 -0
- package/types/phaser/geom/util/matrix.d.ts +22 -0
- package/types/phaser/geom/util/matrix.d.ts.map +1 -0
- package/types/phaser/geom/util/point.d.ts +179 -0
- package/types/phaser/geom/util/point.d.ts.map +1 -0
- package/types/phaser/geom/util/polygon.d.ts +10 -0
- package/types/phaser/geom/util/polygon.d.ts.map +1 -0
- package/types/phaser/geom/util/rectangle.d.ts +141 -0
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts +10 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/util/math.d.ts +182 -0
- package/types/phaser/util/math.d.ts.map +1 -0
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/util/circle
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
|
-
import Circle from
|
|
7
|
-
import Point from '../point';
|
|
7
|
+
import { Circle } from '../circle';
|
|
8
|
+
import { Point } from '../point';
|
|
8
9
|
import { degToRad, distance } from '../../util/math';
|
|
9
10
|
|
|
10
11
|
/**
|
|
12
|
+
* TBD.
|
|
11
13
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @returns {
|
|
14
|
+
* @param {Circle} input - TBD.
|
|
15
|
+
* @param {Circle} output - TBD.
|
|
16
|
+
* @returns {Circle} TBD.
|
|
15
17
|
*/
|
|
16
18
|
export function clone(input, output = null) {
|
|
17
19
|
const result = output || new Circle();
|
|
@@ -22,48 +24,52 @@ export function clone(input, output = null) {
|
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
27
|
+
* TBD.
|
|
25
28
|
*
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {number} x TBD
|
|
28
|
-
* @param {number} y TBD
|
|
29
|
-
* @returns {boolean} TBD
|
|
29
|
+
* @param {Circle} a - TBD.
|
|
30
|
+
* @param {number} x - TBD.
|
|
31
|
+
* @param {number} y - TBD.
|
|
32
|
+
* @returns {boolean} TBD.
|
|
30
33
|
*/
|
|
31
34
|
export function contains(a, x, y) {
|
|
32
35
|
if (a.radius > 0 && x >= a.left && x <= a.right && y >= a.top && y <= a.bottom) {
|
|
33
36
|
const dx = (a.x - x) * (a.x - x);
|
|
34
37
|
const dy = (a.y - y) * (a.y - y);
|
|
35
|
-
return
|
|
38
|
+
return dx + dy <= a.radius * a.radius;
|
|
36
39
|
}
|
|
37
40
|
return false;
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
/**
|
|
44
|
+
* TBD.
|
|
41
45
|
*
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {
|
|
44
|
-
* @returns {boolean} TBD
|
|
46
|
+
* @param {Circle} a - TBD.
|
|
47
|
+
* @param {Circle} b - TBD.
|
|
48
|
+
* @returns {boolean} TBD.
|
|
45
49
|
*/
|
|
46
50
|
export function equals(a, b) {
|
|
47
|
-
return
|
|
51
|
+
return a.x === b.x && a.y === b.y && a.diameter === b.diameter;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
/**
|
|
55
|
+
* TBD.
|
|
51
56
|
*
|
|
52
|
-
* @param {
|
|
53
|
-
* @param {
|
|
54
|
-
* @returns {boolean} TBD
|
|
57
|
+
* @param {Circle} a - TBD.
|
|
58
|
+
* @param {Circle} b - TBD.
|
|
59
|
+
* @returns {boolean} TBD.
|
|
55
60
|
*/
|
|
56
61
|
export function intersects(a, b) {
|
|
57
|
-
return distance(a.x, a.y, b.x, b.y) <=
|
|
62
|
+
return distance(a.x, a.y, b.x, b.y) <= a.radius + b.radius;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
/**
|
|
66
|
+
* TBD.
|
|
61
67
|
*
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {number} angle TBD
|
|
64
|
-
* @param {boolean} asDegrees TBD
|
|
65
|
-
* @param {
|
|
66
|
-
* @returns {
|
|
68
|
+
* @param {Circle} a - TBD.
|
|
69
|
+
* @param {number} angle - TBD.
|
|
70
|
+
* @param {boolean} asDegrees - TBD.
|
|
71
|
+
* @param {Circle} output - TBD.
|
|
72
|
+
* @returns {Circle} TBD.
|
|
67
73
|
*/
|
|
68
74
|
export function circumferencePoint(a, angle, asDegrees = false, output = null) {
|
|
69
75
|
const result = output || new Point();
|
|
@@ -76,12 +82,13 @@ export function circumferencePoint(a, angle, asDegrees = false, output = null) {
|
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
/**
|
|
85
|
+
* TBD.
|
|
79
86
|
*
|
|
80
|
-
* @param {
|
|
81
|
-
* @param {number} angle TBD
|
|
82
|
-
* @param {boolean} asDegrees TBD
|
|
83
|
-
* @param {
|
|
84
|
-
* @returns {
|
|
87
|
+
* @param {Circle} a - TBD.
|
|
88
|
+
* @param {number} angle - TBD.
|
|
89
|
+
* @param {boolean} asDegrees - TBD.
|
|
90
|
+
* @param {Point} output - TBD.
|
|
91
|
+
* @returns {Point} TBD.
|
|
85
92
|
*/
|
|
86
93
|
export function intersectsPoint(a, angle, asDegrees = false, output = null) {
|
|
87
94
|
const result = output || new Point();
|
|
@@ -94,10 +101,11 @@ export function intersectsPoint(a, angle, asDegrees = false, output = null) {
|
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
/**
|
|
104
|
+
* TBD.
|
|
97
105
|
*
|
|
98
|
-
* @param {
|
|
99
|
-
* @param {object} r TBD
|
|
100
|
-
* @returns {boolean} TBD
|
|
106
|
+
* @param {Circle} c - TBD.
|
|
107
|
+
* @param {object} r - TBD.
|
|
108
|
+
* @returns {boolean} TBD.
|
|
101
109
|
*/
|
|
102
110
|
export function intersectsRectangle(c, r) {
|
|
103
111
|
const cx = Math.abs(c.x - r.x - r.halfWidth);
|
|
@@ -1,34 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/util/ellipse
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
* TBD
|
|
9
|
-
*
|
|
10
|
-
* @deprecated
|
|
11
|
-
* @returns {boolean} TBD
|
|
12
|
-
*/
|
|
13
|
-
export default function () {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
9
|
+
* TBD.
|
|
18
10
|
*
|
|
19
|
-
* @param {object} a TBD
|
|
20
|
-
* @param {number} x TBD
|
|
21
|
-
* @param {number} y TBD
|
|
22
|
-
* @returns {boolean} TBD
|
|
11
|
+
* @param {object} a - TBD.
|
|
12
|
+
* @param {number} x - TBD.
|
|
13
|
+
* @param {number} y - TBD.
|
|
14
|
+
* @returns {boolean} TBD.
|
|
23
15
|
*/
|
|
24
16
|
export function contains(a, x, y) {
|
|
25
17
|
if (a.width <= 0 || a.height <= 0) {
|
|
26
18
|
return false;
|
|
27
19
|
}
|
|
28
20
|
// Normalize the coords to an ellipse with center 0,0 and a radius of 0.5
|
|
29
|
-
let normx = (
|
|
30
|
-
let normy = (
|
|
21
|
+
let normx = (x - a.x) / a.width - 0.5;
|
|
22
|
+
let normy = (y - a.y) / a.height - 0.5;
|
|
31
23
|
normx *= normx;
|
|
32
24
|
normy *= normy;
|
|
33
|
-
return
|
|
25
|
+
return normx + normy < 0.25;
|
|
34
26
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/util/line
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
|
-
import Point from '../point';
|
|
7
|
-
import Line from
|
|
7
|
+
import { Point } from '../point';
|
|
8
|
+
import { Line } from '../line';
|
|
8
9
|
import { intersects as intersectsRect } from './rectangle';
|
|
9
10
|
|
|
10
11
|
/**
|
|
12
|
+
* TBD.
|
|
11
13
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @returns {
|
|
14
|
+
* @param {Line} input - TBD.
|
|
15
|
+
* @param {Line} output - TBD.
|
|
16
|
+
* @returns {Line} TBD.
|
|
15
17
|
*/
|
|
16
18
|
export function clone(input, output = null) {
|
|
17
19
|
const result = output || new Line();
|
|
@@ -23,14 +25,15 @@ export function clone(input, output = null) {
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/**
|
|
28
|
+
* TBD.
|
|
26
29
|
*
|
|
27
|
-
* @param {object} a TBD
|
|
28
|
-
* @param {object} b TBD
|
|
29
|
-
* @param {object} e TBD
|
|
30
|
-
* @param {object} f TBD
|
|
31
|
-
* @param {boolean} asSegment TBD
|
|
32
|
-
* @param {
|
|
33
|
-
* @returns {boolean} TBD
|
|
30
|
+
* @param {object} a - TBD.
|
|
31
|
+
* @param {object} b - TBD.
|
|
32
|
+
* @param {object} e - TBD.
|
|
33
|
+
* @param {object} f - TBD.
|
|
34
|
+
* @param {boolean} asSegment - TBD.
|
|
35
|
+
* @param {Point} output - TBD.
|
|
36
|
+
* @returns {boolean} TBD.
|
|
34
37
|
*/
|
|
35
38
|
export function intersectsPoints(a, b, e, f, asSegment = true, output = null) {
|
|
36
39
|
const result = output || new Point();
|
|
@@ -38,18 +41,18 @@ export function intersectsPoints(a, b, e, f, asSegment = true, output = null) {
|
|
|
38
41
|
const a2 = f.y - e.y;
|
|
39
42
|
const b1 = a.x - b.x;
|
|
40
43
|
const b2 = e.x - f.x;
|
|
41
|
-
const c1 =
|
|
42
|
-
const c2 =
|
|
43
|
-
const denom =
|
|
44
|
+
const c1 = b.x * a.y - a.x * b.y;
|
|
45
|
+
const c2 = f.x * e.y - e.x * f.y;
|
|
46
|
+
const denom = a1 * b2 - a2 * b1;
|
|
44
47
|
if (denom === 0) {
|
|
45
48
|
return null;
|
|
46
49
|
}
|
|
47
|
-
result.x = (
|
|
48
|
-
result.y = (
|
|
50
|
+
result.x = (b1 * c2 - b2 * c1) / denom;
|
|
51
|
+
result.y = (a2 * c1 - a1 * c2) / denom;
|
|
49
52
|
if (asSegment) {
|
|
50
|
-
const uc = (
|
|
51
|
-
const ua = ((
|
|
52
|
-
const ub = ((
|
|
53
|
+
const uc = (f.y - e.y) * (b.x - a.x) - (f.x - e.x) * (b.y - a.y);
|
|
54
|
+
const ua = ((f.x - e.x) * (a.y - e.y) - (f.y - e.y) * (a.x - e.x)) / uc;
|
|
55
|
+
const ub = ((b.x - a.x) * (a.y - e.y) - (b.y - a.y) * (a.x - e.x)) / uc;
|
|
53
56
|
if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) {
|
|
54
57
|
return result;
|
|
55
58
|
}
|
|
@@ -59,22 +62,24 @@ export function intersectsPoints(a, b, e, f, asSegment = true, output = null) {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
/**
|
|
65
|
+
* TBD.
|
|
62
66
|
*
|
|
63
|
-
* @param {object} a TBD
|
|
64
|
-
* @param {object} b TBD
|
|
65
|
-
* @param {boolean} asSegment TBD
|
|
66
|
-
* @param {object} result TBD
|
|
67
|
-
* @returns {boolean} TBD
|
|
67
|
+
* @param {object} a - TBD.
|
|
68
|
+
* @param {object} b - TBD.
|
|
69
|
+
* @param {boolean} asSegment - TBD.
|
|
70
|
+
* @param {object} result - TBD.
|
|
71
|
+
* @returns {boolean} TBD.
|
|
68
72
|
*/
|
|
69
73
|
export function intersects(a, b, asSegment, result) {
|
|
70
74
|
return intersectsPoints(a.start, a.end, b.start, b.end, asSegment, result);
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
/**
|
|
78
|
+
* TBD.
|
|
74
79
|
*
|
|
75
|
-
* @param {object} line TBD
|
|
76
|
-
* @param {object} rect TBD
|
|
77
|
-
* @returns {boolean} TBD
|
|
80
|
+
* @param {object} line - TBD.
|
|
81
|
+
* @param {object} rect - TBD.
|
|
82
|
+
* @returns {boolean} TBD.
|
|
78
83
|
*/
|
|
79
84
|
export function intersectsRectangle(line, rect) {
|
|
80
85
|
// Quick bail out of the Line and Rect bounds don't intersect
|
|
@@ -92,31 +97,34 @@ export function intersectsRectangle(line, rect) {
|
|
|
92
97
|
let t = 0;
|
|
93
98
|
// If the start or end of the line is inside the rect then we assume
|
|
94
99
|
// collision, as rects are solid for our use-case.
|
|
95
|
-
if (
|
|
100
|
+
if (
|
|
101
|
+
(x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) ||
|
|
102
|
+
(x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)
|
|
103
|
+
) {
|
|
96
104
|
return true;
|
|
97
105
|
}
|
|
98
106
|
if (x1 < bx1 && x2 >= bx1) {
|
|
99
107
|
// Left edge
|
|
100
|
-
t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1);
|
|
108
|
+
t = y1 + ((y2 - y1) * (bx1 - x1)) / (x2 - x1);
|
|
101
109
|
if (t > by1 && t <= by2) {
|
|
102
110
|
return true;
|
|
103
111
|
}
|
|
104
112
|
} else if (x1 > bx2 && x2 <= bx2) {
|
|
105
113
|
// Right edge
|
|
106
|
-
t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1);
|
|
114
|
+
t = y1 + ((y2 - y1) * (bx2 - x1)) / (x2 - x1);
|
|
107
115
|
if (t >= by1 && t <= by2) {
|
|
108
116
|
return true;
|
|
109
117
|
}
|
|
110
118
|
}
|
|
111
119
|
if (y1 < by1 && y2 >= by1) {
|
|
112
120
|
// Top edge
|
|
113
|
-
t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1);
|
|
121
|
+
t = x1 + ((x2 - x1) * (by1 - y1)) / (y2 - y1);
|
|
114
122
|
if (t >= bx1 && t <= bx2) {
|
|
115
123
|
return true;
|
|
116
124
|
}
|
|
117
125
|
} else if (y1 > by2 && y2 <= by2) {
|
|
118
126
|
// Bottom edge
|
|
119
|
-
t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1);
|
|
127
|
+
t = x1 + ((x2 - x1) * (by2 - y1)) / (y2 - y1);
|
|
120
128
|
if (t >= bx1 && t <= bx2) {
|
|
121
129
|
return true;
|
|
122
130
|
}
|
|
@@ -125,10 +133,11 @@ export function intersectsRectangle(line, rect) {
|
|
|
125
133
|
}
|
|
126
134
|
|
|
127
135
|
/**
|
|
136
|
+
* TBD.
|
|
128
137
|
*
|
|
129
|
-
* @param {object} a TBD
|
|
130
|
-
* @param {object} b TBD
|
|
131
|
-
* @returns {number} TBD
|
|
138
|
+
* @param {object} a - TBD.
|
|
139
|
+
* @param {object} b - TBD.
|
|
140
|
+
* @returns {number} TBD.
|
|
132
141
|
*/
|
|
133
142
|
export function reflect(a, b) {
|
|
134
143
|
return 2 * b.normalAngle - 3.141592653589793 - a.angle;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/util/matrix
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
|
-
import Matrix from
|
|
7
|
+
import { Matrix } from '../matrix';
|
|
7
8
|
|
|
8
9
|
/**
|
|
10
|
+
* TBD.
|
|
9
11
|
*
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
12
|
-
* @returns {
|
|
12
|
+
* @param {Matrix} input - TBD.
|
|
13
|
+
* @param {Matrix} output - TBD.
|
|
14
|
+
* @returns {Matrix} TBD.
|
|
13
15
|
*/
|
|
14
16
|
export function clone(input, output = null) {
|
|
15
17
|
const result = output || new Matrix();
|
|
@@ -23,9 +25,9 @@ export function clone(input, output = null) {
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
|
-
* TBD
|
|
28
|
+
* TBD.
|
|
27
29
|
*
|
|
28
|
-
* @returns {
|
|
30
|
+
* @returns {Matrix} TBD.
|
|
29
31
|
*/
|
|
30
32
|
export function getIdentityMatrix() {
|
|
31
33
|
if (!window.PhaserRegistry) {
|
|
@@ -38,9 +40,9 @@ export function getIdentityMatrix() {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
|
-
* TBD
|
|
43
|
+
* TBD.
|
|
42
44
|
*
|
|
43
|
-
* @returns {
|
|
45
|
+
* @returns {Matrix} TBD.
|
|
44
46
|
*/
|
|
45
47
|
export function getTempMatrix() {
|
|
46
48
|
if (!window.PhaserRegistry) {
|