bard-legends-framework 0.9.5 → 0.9.7
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/_interfaces/index.d.ts +2 -2
- package/dist/_interfaces/index.js +2 -3
- package/dist/game-entities/attachable/attachable.d.ts +6 -6
- package/dist/game-entities/attachable/attachable.js +28 -30
- package/dist/game-entities/attachable/attachable.spec.js +129 -128
- package/dist/game-entities/attachable/attachable.store.d.ts +5 -5
- package/dist/game-entities/attachable/attachable.store.js +34 -32
- package/dist/game-entities/attachable/attachable.test.js +132 -131
- package/dist/game-entities/attachable/destroyable.d.ts +13 -13
- package/dist/game-entities/attachable/destroyable.js +64 -69
- package/dist/game-entities/attachable/helpers/decorate-actions-lib.d.ts +15 -15
- package/dist/game-entities/attachable/helpers/decorate-actions-lib.js +125 -116
- package/dist/game-entities/attachable/helpers/referance-variable.d.ts +15 -15
- package/dist/game-entities/attachable/helpers/referance-variable.js +47 -48
- package/dist/game-entities/attachable/interfaces.d.ts +6 -6
- package/dist/game-entities/attachable/interfaces.js +2 -3
- package/dist/game-entities/base/helpers/decorate-actions-lib.js +0 -1
- package/dist/game-entities/controller/controller.js +0 -1
- package/dist/game-entities/controller/controller.spec.js +128 -125
- package/dist/game-entities/entity/entity.spec.js +263 -293
- package/dist/game-entities/entity/helpers/view-creation.helper.d.ts +7 -7
- package/dist/game-entities/entity/helpers/view-creation.helper.js +48 -48
- package/dist/game-entities/scene/scene.spec.js +219 -223
- package/dist/game-entities/service/service.js +0 -4
- package/dist/game-entities/service/service.spec.js +265 -237
- package/dist/game-entities/service/service.test.js +4 -2
- package/dist/game-entities/update-loop.d.ts +18 -18
- package/dist/game-entities/update-loop.js +46 -28
- package/dist/game-entities/view/view.js +1 -1
- package/dist/game-entities/view/view.spec.js +490 -506
- package/dist/game-entities/view/view.test.js +1 -1
- package/dist/lib/animator/animations.d.ts +13 -13
- package/dist/lib/animator/animations.js +43 -40
- package/dist/lib/animator/animator.d.ts +41 -41
- package/dist/lib/animator/animator.js +194 -197
- package/dist/lib/animator/animator.spec.js +699 -612
- package/dist/lib/animator/index.js +24 -19
- package/dist/lib/libraries/animator/animations.d.ts +13 -13
- package/dist/lib/libraries/animator/animations.js +43 -40
- package/dist/lib/libraries/animator/animator.d.ts +41 -41
- package/dist/lib/libraries/animator/animator.js +194 -197
- package/dist/lib/libraries/animator/animator.spec.js +699 -612
- package/dist/lib/libraries/animator/index.js +24 -19
- package/dist/lib/libraries/path-finder/path-finder.d.ts +2 -2
- package/dist/lib/libraries/path-finder/path-finder.js +19 -20
- package/dist/lib/path-finder/path-finder.d.ts +2 -2
- package/dist/lib/path-finder/path-finder.js +19 -20
- package/dist/lib/services/keyboard/keyboard.d.ts +4 -4
- package/dist/lib/services/keyboard/keyboard.js +39 -31
- package/dist/lib/services/mouse/mouse.service.d.ts +8 -8
- package/dist/lib/services/mouse/mouse.service.js +65 -53
- package/dist/lib/services/mouse/mouser-target-focus.service.d.ts +11 -11
- package/dist/lib/services/mouse/mouser-target-focus.service.js +83 -81
- package/dist/lib/update-loop.d.ts +10 -10
- package/dist/lib/update-loop.js +35 -27
- package/dist/physics/entitity-types/immovable-physics-entity.d.ts +6 -6
- package/dist/physics/entitity-types/immovable-physics-entity.js +23 -24
- package/dist/physics/entitity-types/movable-entity.d.ts +6 -6
- package/dist/physics/entitity-types/movable-entity.js +21 -22
- package/dist/physics/entitity-types/movable-physics-entity.d.ts +14 -14
- package/dist/physics/entitity-types/movable-physics-entity.js +83 -88
- package/dist/physics/entitity-types/physics-entity.d.ts +23 -23
- package/dist/physics/entitity-types/physics-entity.js +97 -88
- package/dist/physics/helpers/closest-available-space.helper.d.ts +16 -16
- package/dist/physics/helpers/closest-available-space.helper.js +98 -96
- package/dist/physics/helpers/closest-available-space.helper.spec.js +115 -68
- package/dist/physics/helpers/p2js.helper.d.ts +3 -3
- package/dist/physics/helpers/p2js.helper.js +21 -22
- package/dist/physics/helpers/shape-factory.d.ts +9 -4
- package/dist/physics/helpers/shape-factory.js +99 -75
- package/dist/physics/libs/p2js.helper.js +1 -1
- package/dist/physics/libs/position-to-grid-position-converter.d.ts +3 -3
- package/dist/physics/libs/position-to-grid-position-converter.js +15 -13
- package/dist/physics/module//360/237/223/220services/availability-grid.service.d.ts +10 -5
- package/dist/physics/module//360/237/223/220services/availability-grid.service.js +77 -57
- package/dist/physics/module//360/237/223/220services/border.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/border.service.js +57 -37
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/collisions.service.d.ts +7 -7
- package/dist/physics/module//360/237/223/220services/collisions.service.js +110 -98
- package/dist/physics/module//360/237/223/220services/debug-visuals.service.d.ts +28 -6
- package/dist/physics/module//360/237/223/220services/debug-visuals.service.js +121 -89
- package/dist/physics/module//360/237/223/220services/eliptic-explosion.service.d.ts +15 -7
- package/dist/physics/module//360/237/223/220services/eliptic-explosion.service.js +117 -93
- package/dist/physics/module//360/237/223/220services/explosion.service.d.ts +14 -7
- package/dist/physics/module//360/237/223/220services/explosion.service.js +102 -77
- package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.d.ts +15 -7
- package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.js +117 -93
- package/dist/physics/module//360/237/223/220services/explosions/explosion.service.d.ts +14 -7
- package/dist/physics/module//360/237/223/220services/explosions/explosion.service.js +102 -77
- package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.js +71 -67
- package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.js +71 -67
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/materials.service.d.ts +16 -11
- package/dist/physics/module//360/237/223/220services/materials.service.js +118 -108
- package/dist/physics/module//360/237/223/220services/path-finder.service.d.ts +19 -8
- package/dist/physics/module//360/237/223/220services/path-finder.service.js +121 -82
- package/dist/physics/module//360/237/223/220services/physics-world.service.d.ts +30 -15
- package/dist/physics/module//360/237/223/220services/physics-world.service.js +122 -100
- package/dist/physics/module//360/237/223/220services/ray-casting.service.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/ray-casting.service.js +87 -86
- package/dist/physics/module//360/237/223/220services/shape-creation.service.d.ts +9 -4
- package/dist/physics/module//360/237/223/220services/shape-creation.service.js +113 -84
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +2 -1
- package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.d.ts +8 -8
- package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.js +32 -33
- package/dist/physics/physics-world.d.ts +50 -34
- package/dist/physics/physics-world.js +142 -133
- package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.d.ts +3 -3
- package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.js +15 -13
- package/dist/physics/sub-elements/available-spaces/physics-availability-grid.d.ts +9 -9
- package/dist/physics/sub-elements/available-spaces/physics-availability-grid.js +82 -77
- package/dist/physics/sub-elements/available-spaces/physics-available-spaces.d.ts +18 -14
- package/dist/physics/sub-elements/available-spaces/physics-available-spaces.js +91 -79
- package/dist/physics/sub-elements/collisions/contact-equation-orginiser.d.ts +11 -11
- package/dist/physics/sub-elements/collisions/contact-equation-orginiser.js +84 -76
- package/dist/physics/sub-elements/collisions/physics-collision.d.ts +7 -7
- package/dist/physics/sub-elements/collisions/physics-collision.js +43 -44
- package/dist/physics/sub-elements/elements/physics-body-groups.d.ts +11 -11
- package/dist/physics/sub-elements/elements/physics-body-groups.js +54 -54
- package/dist/physics/sub-elements/elements/physics-materials.d.ts +15 -10
- package/dist/physics/sub-elements/elements/physics-materials.js +101 -100
- package/dist/physics/sub-elements/elements/physics-world-borders.d.ts +3 -3
- package/dist/physics/sub-elements/elements/physics-world-borders.js +69 -45
- package/dist/physics/sub-elements/physics-body-groups.d.ts +8 -8
- package/dist/physics/sub-elements/physics-body-groups.js +41 -42
- package/dist/physics/sub-elements/physics-collision.d.ts +16 -16
- package/dist/physics/sub-elements/physics-collision.js +141 -121
- package/dist/physics/sub-elements/physics-materials.d.ts +15 -10
- package/dist/physics/sub-elements/physics-materials.js +101 -100
- package/dist/physics/sub-elements/physics-world-borders.d.ts +2 -2
- package/dist/physics/sub-elements/physics-world-borders.js +25 -26
- package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.d.ts +15 -11
- package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.js +59 -59
- package/dist/physics/sub-elements/raycasting/physics-explosion.d.ts +13 -6
- package/dist/physics/sub-elements/raycasting/physics-explosion.js +108 -73
- package/dist/physics/sub-elements/raycasting/ray-cast.d.ts +19 -19
- package/dist/physics/sub-elements/raycasting/ray-cast.js +93 -98
- package/dist/pixi/display-object/components/filters.d.ts +18 -18
- package/dist/pixi/display-object/components/filters.js +106 -81
- package/dist/pixi/display-object/components/glow-effect.d.ts +8 -8
- package/dist/pixi/display-object/components/glow-effect.js +33 -36
- package/dist/pixi/display-object/components/glow-filter.d.ts +8 -8
- package/dist/pixi/display-object/components/glow-filter.js +33 -36
- package/dist/pixi/display-object/container-attributes.js +1 -1
- package/dist/pixi/display-object/display-object-attributes.d.ts +41 -41
- package/dist/pixi/display-object/display-object-attributes.js +148 -150
- package/dist/pixi/display-object/display-object.d.ts +17 -17
- package/dist/pixi/display-object/display-object.js +79 -75
- package/dist/pixi/display-object/filters/base-filters/alpha-primer-color.filter.d.ts +9 -4
- package/dist/pixi/display-object/filters/base-filters/alpha-primer-color.filter.js +89 -77
- package/dist/pixi/display-object/filters/base-filters/blur.filter.js +30 -30
- package/dist/pixi/display-object/filters/base-filters/contrast-filter.d.ts +9 -4
- package/dist/pixi/display-object/filters/base-filters/contrast-filter.js +62 -53
- package/dist/pixi/display-object/filters/base-filters/expand-with-alpha-color.d.ts +10 -5
- package/dist/pixi/display-object/filters/base-filters/expand-with-alpha-color.js +93 -81
- package/dist/pixi/display-object/filters/base-filters/expand-with-color-gradient.d.ts +12 -7
- package/dist/pixi/display-object/filters/base-filters/expand-with-color-gradient.js +120 -109
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.d.ts +10 -5
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +32 -32
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.js +92 -85
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +28 -28
- package/dist/pixi/display-object/filters/templates/plane.template.js +20 -20
- package/dist/pixi/display-object/filters.js +20 -4
- package/dist/pixi/display-object/objects/components/filters.d.ts +18 -18
- package/dist/pixi/display-object/objects/components/filters.js +106 -81
- package/dist/pixi/display-object/objects/container.d.ts +2 -2
- package/dist/pixi/display-object/objects/container.js +39 -30
- package/dist/pixi/display-object/objects/graphics.d.ts +28 -28
- package/dist/pixi/display-object/objects/graphics.js +218 -202
- package/dist/pixi/display-object/objects/helpers/filters.d.ts +25 -25
- package/dist/pixi/display-object/objects/helpers/filters.js +150 -124
- package/dist/pixi/display-object/objects/helpers/glow-sprite-generator.d.ts +7 -7
- package/dist/pixi/display-object/objects/helpers/glow-sprite-generator.js +114 -95
- package/dist/pixi/display-object/objects/premade-objects/sprite-with-glowing-shapes.d.ts +5 -5
- package/dist/pixi/display-object/objects/premade-objects/sprite-with-glowing-shapes.js +81 -57
- package/dist/pixi/display-object/objects/sprite.d.ts +43 -43
- package/dist/pixi/display-object/objects/sprite.js +248 -233
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +1 -1
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +9 -9
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +1 -1
- package/dist/pixi/display-object/objects/text.d.ts +25 -25
- package/dist/pixi/display-object/objects/text.js +111 -102
- package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.d.ts +13 -9
- package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.js +96 -67
- package/dist/pixi/game.d.ts +1 -1
- package/dist/pixi/game.js +2 -2
- package/dist/pixi/helpers/glow-sprite-generator.d.ts +6 -6
- package/dist/pixi/helpers/glow-sprite-generator.js +99 -84
- package/dist/pixi/helpers/pixi-container.helper.d.ts +1 -1
- package/dist/pixi/helpers/pixi-container.helper.js +10 -8
- package/dist/pixi/helpers/screen-position-to-stage.helper.d.ts +1 -1
- package/dist/pixi/helpers/screen-position-to-stage.helper.js +12 -12
- package/dist/pixi/helpers/screen-position-to-stage.helper.test.js +174 -79
- package/dist/pixi/modules/CAMERA/index.d.ts +1 -1
- package/dist/pixi/modules/CAMERA/index.js +3 -3
- package/dist/services/keyboard/keyboard.d.ts +4 -4
- package/dist/services/keyboard/keyboard.js +39 -31
- package/dist/services/mouse/mouse.service.d.ts +8 -8
- package/dist/services/mouse/mouse.service.js +65 -53
- package/dist/services/mouse/mouser-target-focus.service.d.ts +11 -11
- package/dist/services/mouse/mouser-target-focus.service.js +83 -81
- package/dist/utilities/libraries/animator/animating-content/state-animation.d.ts +29 -26
- package/dist/utilities/libraries/animator/animating-content/state-animation.js +159 -165
- package/dist/utilities/libraries/animator/animating-content/state-animation.test.js +386 -375
- package/dist/utilities/libraries/animator/animator.spec.js +765 -656
- package/dist/utilities/libraries/binary-heap/binary-heap.d.ts +11 -11
- package/dist/utilities/libraries/binary-heap/binary-heap.js +79 -81
- package/dist/utilities/libraries/data-structures/binary-heap/binary-heap.d.ts +11 -11
- package/dist/utilities/libraries/data-structures/binary-heap/binary-heap.js +79 -81
- package/dist/utilities/libraries/data-structures/grid/grid.d.ts +35 -31
- package/dist/utilities/libraries/data-structures/grid/grid.js +128 -117
- package/dist/utilities/libraries/data-structures/grid/grid.spec.js +176 -138
- package/dist/utilities/libraries/data-structures/grid/grid.test.js +218 -141
- package/dist/utilities/libraries/data-structures/grid/position-to-grid-position-converter.d.ts +3 -3
- package/dist/utilities/libraries/data-structures/grid/position-to-grid-position-converter.js +15 -13
- package/dist/utilities/libraries/data-structures/queue/queue.d.ts +21 -21
- package/dist/utilities/libraries/data-structures/queue/queue.js +63 -66
- package/dist/utilities/libraries/data-structures/queue/queue.test.js +54 -55
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.spec.js +122 -68
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.spec.js +140 -135
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.spec.js +293 -229
- package/dist/utilities/libraries/path-finder/path-finder.d.ts +7 -7
- package/dist/utilities/libraries/path-finder/path-finder.js +113 -109
- package/dist/utilities/libraries/path-finder/path-finder.spec.js +131 -106
- package/dist/utilities/services/keyboard/keyboard.d.ts +4 -4
- package/dist/utilities/services/keyboard/keyboard.js +42 -34
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.d.ts +1 -1
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.js +12 -12
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.test.js +168 -73
- package/dist/utilities/services/mouse/mouse-target-focus.service.d.ts +15 -15
- package/dist/utilities/services/mouse/mouse-target-focus.service.js +79 -76
- package/dist/utilities/services/mouse/mouse.service.d.ts +9 -9
- package/dist/utilities/services/mouse/mouse.service.js +86 -72
- package/dist/utilities/services/mouse/mouser-target-focus.service.d.ts +11 -11
- package/dist/utilities/services/mouse/mouser-target-focus.service.js +83 -81
- package/package.json +6 -12
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
2
|
exports.PhysicsBodyExplosionHit = void 0;
|
|
4
|
-
const helpers_lib_1 = require(
|
|
5
|
-
const physics_entity_1 = require(
|
|
6
|
-
const p2js_helper_1 = require(
|
|
3
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
4
|
+
const physics_entity_1 = require('../../entitity-types/physics-entity');
|
|
5
|
+
const p2js_helper_1 = require('../../helpers/p2js.helper');
|
|
7
6
|
class PhysicsBodyExplosionHit {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
return bodyToHitResults;
|
|
41
|
-
}
|
|
42
|
-
constructor(rayResultGroupOfABody, centerOfExplosion, totalCountOfRays) {
|
|
43
|
-
this.ratioOfHits = rayResultGroupOfABody.hitCount / totalCountOfRays;
|
|
44
|
-
this.raycastResults = rayResultGroupOfABody.raycastResults;
|
|
45
|
-
if (rayResultGroupOfABody.isExternal) {
|
|
46
|
-
this.body = physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(rayResultGroupOfABody.closestRaycastResult.body.id);
|
|
47
|
-
this.getHitPosition = rayResultGroupOfABody.closestRaycastResult.hitPosition;
|
|
48
|
-
this.getHitDistance = rayResultGroupOfABody.closestRaycastResult.hitDistance;
|
|
49
|
-
this.isExternal = true;
|
|
50
|
-
this.normal = rayResultGroupOfABody.closestRaycastResult.normal;
|
|
51
|
-
this.fraction = rayResultGroupOfABody.closestRaycastResult.fraction;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
let bodyPosition = p2js_helper_1.P2JSHelper.arrayToVector(rayResultGroupOfABody.closestRaycastResult.body.position);
|
|
55
|
-
this.body = physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(rayResultGroupOfABody.closestRaycastResult.body.id);
|
|
56
|
-
this.getHitPosition = () => centerOfExplosion;
|
|
57
|
-
this.getHitDistance = () => 0;
|
|
58
|
-
this.isExternal = false;
|
|
59
|
-
this.normal = helpers_lib_1.Vector.fromTo(bodyPosition, centerOfExplosion).normalize();
|
|
60
|
-
this.fraction = 0;
|
|
7
|
+
static convertRaysToBodyExplosionHits(rays, centerOfExplosion, totalCountOfRays) {
|
|
8
|
+
const rayResultGroupOfBodies = PhysicsBodyExplosionHit.groupRayResultsByBody(rays);
|
|
9
|
+
return [...rayResultGroupOfBodies.values()].map(
|
|
10
|
+
rayResultGroupOfABody => new PhysicsBodyExplosionHit(rayResultGroupOfABody, centerOfExplosion, totalCountOfRays)
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
static groupRayResultsByBody(rayCasts) {
|
|
14
|
+
const bodyToHitResults = new Map();
|
|
15
|
+
rayCasts.forEach(ray => {
|
|
16
|
+
ray.results.forEach(rayCastResult => {
|
|
17
|
+
const previousRecord = bodyToHitResults.get(rayCastResult.body);
|
|
18
|
+
if (previousRecord) {
|
|
19
|
+
const closestRaycastResult =
|
|
20
|
+
rayCastResult.fraction < previousRecord.closestRaycastResult.fraction
|
|
21
|
+
? rayCastResult
|
|
22
|
+
: previousRecord.closestRaycastResult;
|
|
23
|
+
previousRecord.raycastResults.push(rayCastResult);
|
|
24
|
+
bodyToHitResults.set(rayCastResult.body, {
|
|
25
|
+
hitCount: previousRecord.hitCount + 1,
|
|
26
|
+
closestRaycastResult,
|
|
27
|
+
raycastResults: previousRecord.raycastResults,
|
|
28
|
+
isExternal: previousRecord.isExternal
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
const isExternal = rayCastResult.isExternal();
|
|
32
|
+
bodyToHitResults.set(rayCastResult.body, {
|
|
33
|
+
hitCount: 1,
|
|
34
|
+
closestRaycastResult: rayCastResult,
|
|
35
|
+
raycastResults: [rayCastResult],
|
|
36
|
+
isExternal
|
|
37
|
+
});
|
|
61
38
|
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
return bodyToHitResults;
|
|
42
|
+
}
|
|
43
|
+
constructor(rayResultGroupOfABody, centerOfExplosion, totalCountOfRays) {
|
|
44
|
+
this.ratioOfHits = rayResultGroupOfABody.hitCount / totalCountOfRays;
|
|
45
|
+
this.raycastResults = rayResultGroupOfABody.raycastResults;
|
|
46
|
+
if (rayResultGroupOfABody.isExternal) {
|
|
47
|
+
this.body = physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(rayResultGroupOfABody.closestRaycastResult.body.id);
|
|
48
|
+
this.getHitPosition = rayResultGroupOfABody.closestRaycastResult.hitPosition;
|
|
49
|
+
this.getHitDistance = rayResultGroupOfABody.closestRaycastResult.hitDistance;
|
|
50
|
+
this.isExternal = true;
|
|
51
|
+
this.normal = rayResultGroupOfABody.closestRaycastResult.normal;
|
|
52
|
+
this.fraction = rayResultGroupOfABody.closestRaycastResult.fraction;
|
|
53
|
+
} else {
|
|
54
|
+
const bodyPosition = p2js_helper_1.P2JSHelper.arrayToVector(rayResultGroupOfABody.closestRaycastResult.body.position);
|
|
55
|
+
this.body = physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(rayResultGroupOfABody.closestRaycastResult.body.id);
|
|
56
|
+
this.getHitPosition = () => centerOfExplosion;
|
|
57
|
+
this.getHitDistance = () => 0;
|
|
58
|
+
this.isExternal = false;
|
|
59
|
+
this.normal = helpers_lib_1.Vector.fromTo(bodyPosition, centerOfExplosion).normalize();
|
|
60
|
+
this.fraction = 0;
|
|
62
61
|
}
|
|
62
|
+
}
|
|
63
63
|
}
|
|
64
64
|
exports.PhysicsBodyExplosionHit = PhysicsBodyExplosionHit;
|
|
65
|
-
//# sourceMappingURL=physics-body-explosion-hit.js.map
|
|
65
|
+
//# sourceMappingURL=physics-body-explosion-hit.js.map
|
|
@@ -4,10 +4,17 @@ import { PhysicsExplosionOptions } from '../../interfaces';
|
|
|
4
4
|
import { PhysicsBodyExplosionHit } from './physics-body-explosion-hit';
|
|
5
5
|
import { PhysicsBodyGroup } from '../elements/physics-body-groups';
|
|
6
6
|
export declare class PhysicsExplosion {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
static createExplosion(
|
|
8
|
+
centerOfExplosion: Vector,
|
|
9
|
+
radius: number,
|
|
10
|
+
physicsBodyGroup: PhysicsBodyGroup,
|
|
11
|
+
severity: number,
|
|
12
|
+
physicsWorld: PhysicsWorld,
|
|
13
|
+
options?: PhysicsExplosionOptions
|
|
14
|
+
): PhysicsBodyExplosionHit[];
|
|
15
|
+
private static createRays;
|
|
16
|
+
private static applyForcesToBodies;
|
|
17
|
+
private static pushBody;
|
|
18
|
+
private static createExplosionDebugVisual;
|
|
19
|
+
private static getTotalCountOfRays;
|
|
13
20
|
}
|
|
@@ -1,80 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
2
|
exports.PhysicsExplosion = void 0;
|
|
4
|
-
const helpers_lib_1 = require(
|
|
5
|
-
const pixi_1 = require(
|
|
6
|
-
const utilities_1 = require(
|
|
7
|
-
const p2js_helper_1 = require(
|
|
8
|
-
const ray_cast_1 = require(
|
|
9
|
-
const physics_body_explosion_hit_1 = require(
|
|
3
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
4
|
+
const pixi_1 = require('../../../pixi');
|
|
5
|
+
const utilities_1 = require('../../../utilities');
|
|
6
|
+
const p2js_helper_1 = require('../../helpers/p2js.helper');
|
|
7
|
+
const ray_cast_1 = require('./ray-cast');
|
|
8
|
+
const physics_body_explosion_hit_1 = require('./physics-body-explosion-hit');
|
|
10
9
|
class PhysicsExplosion {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
static createExplosion(centerOfExplosion, radius, physicsBodyGroup, severity, physicsWorld, options) {
|
|
11
|
+
const totalCountOfRays = PhysicsExplosion.getTotalCountOfRays(radius);
|
|
12
|
+
const rayCasts = PhysicsExplosion.createRays(
|
|
13
|
+
centerOfExplosion,
|
|
14
|
+
radius,
|
|
15
|
+
physicsBodyGroup,
|
|
16
|
+
totalCountOfRays,
|
|
17
|
+
options?.hitOnlyClosest === true,
|
|
18
|
+
physicsWorld
|
|
19
|
+
);
|
|
20
|
+
const bodyExplosionHits = physics_body_explosion_hit_1.PhysicsBodyExplosionHit.convertRaysToBodyExplosionHits(
|
|
21
|
+
rayCasts,
|
|
22
|
+
centerOfExplosion,
|
|
23
|
+
totalCountOfRays
|
|
24
|
+
);
|
|
25
|
+
PhysicsExplosion.applyForcesToBodies(centerOfExplosion, radius, severity, totalCountOfRays, bodyExplosionHits);
|
|
26
|
+
if (options?.printRaysOn) {
|
|
27
|
+
PhysicsExplosion.createExplosionDebugVisual(
|
|
28
|
+
rayCasts,
|
|
29
|
+
centerOfExplosion,
|
|
30
|
+
radius,
|
|
31
|
+
options.printRaysOn,
|
|
32
|
+
physicsWorld,
|
|
33
|
+
options.debugRayDuration
|
|
34
|
+
);
|
|
20
35
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
return bodyExplosionHits;
|
|
37
|
+
}
|
|
38
|
+
static createRays(centerOfExplosion, radius, physicsBodyGroup, totalCountOfRays, hitOnlyClosest, physicsWorld) {
|
|
39
|
+
const radianPerLine = helpers_lib_1.Radian.get360 / totalCountOfRays;
|
|
40
|
+
let directionVector = new helpers_lib_1.Vector(0, -radius);
|
|
41
|
+
const rotationVector = helpers_lib_1.Radian.toVector(radianPerLine);
|
|
42
|
+
return helpers_lib_1.ArrayHelper.createEmptyArray(totalCountOfRays).map(() => {
|
|
43
|
+
const to = centerOfExplosion.add(directionVector);
|
|
44
|
+
directionVector = directionVector.rotate(rotationVector);
|
|
45
|
+
const ray = new ray_cast_1.RayCast(centerOfExplosion, to, physicsWorld);
|
|
46
|
+
hitOnlyClosest ? ray.castClosest(physicsBodyGroup) : ray.castAllFirstContacts(physicsBodyGroup);
|
|
47
|
+
return ray;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
static applyForcesToBodies(centerOfExplosion, radius, severity, totalCountOfRays, PhysicsBodyExplosionHits) {
|
|
51
|
+
PhysicsBodyExplosionHits.forEach(physicsBodyExplosionHit => {
|
|
52
|
+
if (physicsBodyExplosionHit.isExternal) {
|
|
53
|
+
physicsBodyExplosionHit.raycastResults.forEach(rayCastResult => {
|
|
54
|
+
const force = severity * (1 - rayCastResult.fraction);
|
|
55
|
+
PhysicsExplosion.pushBody(
|
|
56
|
+
rayCastResult.body,
|
|
57
|
+
rayCastResult.hitPosition(),
|
|
58
|
+
rayCastResult.fraction,
|
|
59
|
+
rayCastResult.rayCast.fromTo,
|
|
60
|
+
force
|
|
61
|
+
);
|
|
31
62
|
});
|
|
63
|
+
} else {
|
|
64
|
+
const p2Body = physicsBodyExplosionHit.body['p2Body'];
|
|
65
|
+
const vectorToCenter = helpers_lib_1.Vector.fromTo(
|
|
66
|
+
centerOfExplosion,
|
|
67
|
+
p2js_helper_1.P2JSHelper.arrayToVector(p2Body.position)
|
|
68
|
+
);
|
|
69
|
+
const fractionToCenter = vectorToCenter.length / radius;
|
|
70
|
+
const force = (severity * totalCountOfRays * fractionToCenter) / 2;
|
|
71
|
+
PhysicsExplosion.pushBody(
|
|
72
|
+
p2Body,
|
|
73
|
+
physicsBodyExplosionHit.getHitPosition(),
|
|
74
|
+
physicsBodyExplosionHit.fraction,
|
|
75
|
+
vectorToCenter,
|
|
76
|
+
force
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
static pushBody(body, hitPosition, fraction, fromTo, severity) {
|
|
82
|
+
const force = fromTo.normalize(severity * (1 - fraction));
|
|
83
|
+
const relativePoint = [hitPosition.x - body.position[0], hitPosition.y - body.position[1]];
|
|
84
|
+
body.applyImpulse(p2js_helper_1.P2JSHelper.vectorToArray(force), relativePoint);
|
|
85
|
+
}
|
|
86
|
+
static createExplosionDebugVisual(rayCasts, position, radius, testLayerId, physicsWorld, duration = 300) {
|
|
87
|
+
const lineContainer = pixi_1.Container.create().parent(testLayerId).setAlpha(0.5).attach(physicsWorld);
|
|
88
|
+
pixi_1.Graphics.createCircle(radius, helpers_lib_1.ColorHelper.blue)
|
|
89
|
+
.parent(lineContainer)
|
|
90
|
+
.setPosition(position)
|
|
91
|
+
.setAlpha(0.5)
|
|
92
|
+
.attach(physicsWorld);
|
|
93
|
+
rayCasts.forEach(ray => {
|
|
94
|
+
const color = ray.results.length > 0 ? helpers_lib_1.ColorHelper.red : helpers_lib_1.ColorHelper.white;
|
|
95
|
+
pixi_1.Graphics.createVector(position, ray.to, color).parent(lineContainer).attach(physicsWorld);
|
|
96
|
+
});
|
|
97
|
+
new utilities_1.Animator(lineContainer, 'alpha', {
|
|
98
|
+
duration,
|
|
99
|
+
animation: new utilities_1.AnimationEaseIn()
|
|
100
|
+
})
|
|
101
|
+
.animate({ alpha: 0 })
|
|
102
|
+
.then(() => {
|
|
103
|
+
lineContainer.destroy();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
static getTotalCountOfRays(radius) {
|
|
107
|
+
if (radius > 100) {
|
|
108
|
+
return Math.floor(radius * 0.3);
|
|
109
|
+
} else {
|
|
110
|
+
return Math.floor(radius * 0.26 + 4);
|
|
32
111
|
}
|
|
33
|
-
|
|
34
|
-
PhysicsBodyExplosionHits.forEach(physicsBodyExplosionHit => {
|
|
35
|
-
if (physicsBodyExplosionHit.isExternal) {
|
|
36
|
-
physicsBodyExplosionHit.raycastResults.forEach(rayCastResult => {
|
|
37
|
-
let force = severity * (1 - rayCastResult.fraction);
|
|
38
|
-
this.pushBody(rayCastResult.body, rayCastResult.hitPosition(), rayCastResult.fraction, rayCastResult.rayCast.fromTo, force);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
let p2Body = physicsBodyExplosionHit.body['p2Body'];
|
|
43
|
-
let vectorToCenter = helpers_lib_1.Vector.fromTo(centerOfExplosion, p2js_helper_1.P2JSHelper.arrayToVector(p2Body.position));
|
|
44
|
-
let fractionToCenter = vectorToCenter.length / radius;
|
|
45
|
-
let force = (severity * totalCountOfRays * fractionToCenter) / 2;
|
|
46
|
-
this.pushBody(p2Body, physicsBodyExplosionHit.getHitPosition(), physicsBodyExplosionHit.fraction, vectorToCenter, force);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
static pushBody(body, hitPosition, fraction, fromTo, severity) {
|
|
51
|
-
let force = fromTo.normalize(severity * (1 - fraction));
|
|
52
|
-
let relativePoint = [hitPosition.x - body.position[0], hitPosition.y - body.position[1]];
|
|
53
|
-
body.applyImpulse(p2js_helper_1.P2JSHelper.vectorToArray(force), relativePoint);
|
|
54
|
-
}
|
|
55
|
-
static createExplosionDebugVisual(rayCasts, position, radius, testLayerId, physicsWorld, duration = 300) {
|
|
56
|
-
let lineContainer = pixi_1.Container.create().parent(testLayerId).setAlpha(0.5).attach(physicsWorld);
|
|
57
|
-
pixi_1.Graphics.createCircle(radius, helpers_lib_1.ColorHelper.blue)
|
|
58
|
-
.parent(lineContainer)
|
|
59
|
-
.setPosition(position)
|
|
60
|
-
.setAlpha(0.5)
|
|
61
|
-
.attach(physicsWorld);
|
|
62
|
-
rayCasts.forEach(ray => {
|
|
63
|
-
let color = ray.results.length > 0 ? helpers_lib_1.ColorHelper.red : helpers_lib_1.ColorHelper.white;
|
|
64
|
-
pixi_1.Graphics.createVector(position, ray.to, color).parent(lineContainer).attach(physicsWorld);
|
|
65
|
-
});
|
|
66
|
-
new utilities_1.Animator(lineContainer, 'alpha', { duration, animation: new utilities_1.AnimationEaseIn() }).animate({ alpha: 0 }).then(() => {
|
|
67
|
-
lineContainer.destroy();
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
static getTotalCountOfRays(radius) {
|
|
71
|
-
if (radius > 100) {
|
|
72
|
-
return Math.floor(radius * 0.3);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return Math.floor(radius * 0.26 + 4);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
112
|
+
}
|
|
78
113
|
}
|
|
79
114
|
exports.PhysicsExplosion = PhysicsExplosion;
|
|
80
|
-
//# sourceMappingURL=physics-explosion.js.map
|
|
115
|
+
//# sourceMappingURL=physics-explosion.js.map
|
|
@@ -3,25 +3,25 @@ import p2 from 'p2';
|
|
|
3
3
|
import { PhysicsWorld } from '../../physics-world';
|
|
4
4
|
import { PhysicsBodyGroup } from '../elements/physics-body-groups';
|
|
5
5
|
export interface RayCastResult {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
readonly body: p2.Body;
|
|
7
|
+
readonly hitPosition: () => Vector;
|
|
8
|
+
readonly hitDistance: () => number;
|
|
9
|
+
readonly isExternal: () => boolean;
|
|
10
|
+
readonly normal: Vector;
|
|
11
|
+
readonly fraction: number;
|
|
12
|
+
readonly rayCast: RayCast;
|
|
13
13
|
}
|
|
14
14
|
export declare class RayCast {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
readonly from: Vector;
|
|
16
|
+
readonly to: Vector;
|
|
17
|
+
private physicsWorld;
|
|
18
|
+
private _fromTo;
|
|
19
|
+
get fromTo(): Vector;
|
|
20
|
+
get length(): number;
|
|
21
|
+
private _results;
|
|
22
|
+
get results(): RayCastResult[];
|
|
23
|
+
constructor(from: Vector, to: Vector, physicsWorld: PhysicsWorld);
|
|
24
|
+
castClosest(physicsBodyGroup: PhysicsBodyGroup): RayCastResult | undefined;
|
|
25
|
+
castAllFirstContacts(physicsBodyGroup: PhysicsBodyGroup): RayCastResult[];
|
|
26
|
+
private convertP2RaycastResultToRaycastResult;
|
|
27
27
|
}
|
|
@@ -1,106 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
var __importDefault = (this && this.__importDefault) || (mod => (mod && mod.__esModule ? mod : { default: mod }));
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
3
|
exports.RayCast = void 0;
|
|
7
|
-
const helpers_lib_1 = require(
|
|
8
|
-
const p2_1 = __importDefault(require(
|
|
9
|
-
const p2js_helper_1 = require(
|
|
10
|
-
const physics_body_groups_1 = require(
|
|
4
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
5
|
+
const p2_1 = __importDefault(require('p2'));
|
|
6
|
+
const p2js_helper_1 = require('../../helpers/p2js.helper');
|
|
7
|
+
const physics_body_groups_1 = require('../elements/physics-body-groups');
|
|
11
8
|
class RayCast {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return this._fromTo;
|
|
17
|
-
}
|
|
18
|
-
get length() {
|
|
19
|
-
return this.fromTo.length;
|
|
9
|
+
get fromTo() {
|
|
10
|
+
if (this._fromTo === undefined) {
|
|
11
|
+
this._fromTo = helpers_lib_1.Vector.fromTo(this.from, this.to);
|
|
20
12
|
}
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
return this._fromTo;
|
|
14
|
+
}
|
|
15
|
+
get length() {
|
|
16
|
+
return this.fromTo.length;
|
|
17
|
+
}
|
|
18
|
+
get results() {
|
|
19
|
+
return this._results;
|
|
20
|
+
}
|
|
21
|
+
constructor(from, to, physicsWorld) {
|
|
22
|
+
this._results = [];
|
|
23
|
+
this.from = from;
|
|
24
|
+
this.to = to;
|
|
25
|
+
this.physicsWorld = physicsWorld;
|
|
26
|
+
}
|
|
27
|
+
castClosest(physicsBodyGroup) {
|
|
28
|
+
const p2RaycastResult = new p2_1.default.RaycastResult();
|
|
29
|
+
const p2Ray = new p2_1.default.Ray({
|
|
30
|
+
mode: p2_1.default.Ray.CLOSEST,
|
|
31
|
+
from: p2js_helper_1.P2JSHelper.vectorToArray(this.from),
|
|
32
|
+
to: p2js_helper_1.P2JSHelper.vectorToArray(this.to),
|
|
33
|
+
collisionGroup: physics_body_groups_1.PhysicsBodyGroups.getGroupConstant(physicsBodyGroup),
|
|
34
|
+
collisionMask: physics_body_groups_1.PhysicsBodyGroups.getMaskConstant(physicsBodyGroup)
|
|
35
|
+
});
|
|
36
|
+
this.physicsWorld['p2World'].raycast(p2RaycastResult, p2Ray);
|
|
37
|
+
if (p2RaycastResult.hasHit()) {
|
|
38
|
+
const rayCastResult = this.convertP2RaycastResultToRaycastResult(p2RaycastResult);
|
|
39
|
+
this._results = [rayCastResult];
|
|
40
|
+
return rayCastResult;
|
|
41
|
+
} else {
|
|
42
|
+
this._results = [];
|
|
23
43
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (p2RaycastResult.hasHit()) {
|
|
41
|
-
let rayCastResult = this.convertP2RaycastResultToRaycastResult(p2RaycastResult);
|
|
42
|
-
this._results = [rayCastResult];
|
|
43
|
-
return rayCastResult;
|
|
44
|
+
}
|
|
45
|
+
castAllFirstContacts(physicsBodyGroup) {
|
|
46
|
+
const p2BodyToClosestRaycastResult = new Map();
|
|
47
|
+
const p2Ray = new p2_1.default.Ray({
|
|
48
|
+
mode: p2_1.default.Ray.ALL,
|
|
49
|
+
from: p2js_helper_1.P2JSHelper.vectorToArray(this.from),
|
|
50
|
+
to: p2js_helper_1.P2JSHelper.vectorToArray(this.to),
|
|
51
|
+
collisionGroup: physics_body_groups_1.PhysicsBodyGroups.getGroupConstant(physicsBodyGroup),
|
|
52
|
+
collisionMask: physics_body_groups_1.PhysicsBodyGroups.getMaskConstant(physicsBodyGroup),
|
|
53
|
+
callback: callbackResult => {
|
|
54
|
+
const previousItem = p2BodyToClosestRaycastResult.get(callbackResult.body);
|
|
55
|
+
if (!p2BodyToClosestRaycastResult.has(callbackResult.body) || callbackResult.fraction < previousItem.fraction) {
|
|
56
|
+
p2BodyToClosestRaycastResult.set(callbackResult.body, this.convertP2RaycastResultToRaycastResult(callbackResult));
|
|
57
|
+
} else if (callbackResult.fraction === previousItem.fraction && previousItem.isExternal()) {
|
|
58
|
+
// If the raycast starts from inside an object with multiple shapes, there is a chance that first hit is wrongfuly seen as external hit.
|
|
59
|
+
p2BodyToClosestRaycastResult.set(callbackResult.body, this.convertP2RaycastResultToRaycastResult(callbackResult));
|
|
44
60
|
}
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
this.physicsWorld['p2World'].raycast(new p2_1.default.RaycastResult(), p2Ray);
|
|
64
|
+
const rayCastResults = Array.from(p2BodyToClosestRaycastResult.values());
|
|
65
|
+
this._results = rayCastResults;
|
|
66
|
+
return rayCastResults;
|
|
67
|
+
}
|
|
68
|
+
convertP2RaycastResultToRaycastResult(p2RaycastResult) {
|
|
69
|
+
const fraction = p2RaycastResult.fraction;
|
|
70
|
+
const normal = p2js_helper_1.P2JSHelper.arrayToVector(p2RaycastResult.normal);
|
|
71
|
+
let hitPosition;
|
|
72
|
+
let hitDistance;
|
|
73
|
+
let isExternal;
|
|
74
|
+
return {
|
|
75
|
+
body: p2RaycastResult.body,
|
|
76
|
+
hitPosition: () => {
|
|
77
|
+
if (hitPosition === undefined) {
|
|
78
|
+
hitPosition = this.from.lerp(this.to, fraction);
|
|
47
79
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
this.physicsWorld['p2World'].raycast(new p2_1.default.RaycastResult(), p2Ray);
|
|
69
|
-
let rayCastResults = Array.from(p2BodyToClosestRaycastResult.values());
|
|
70
|
-
this._results = rayCastResults;
|
|
71
|
-
return rayCastResults;
|
|
72
|
-
}
|
|
73
|
-
convertP2RaycastResultToRaycastResult(p2RaycastResult) {
|
|
74
|
-
let fraction = p2RaycastResult.fraction;
|
|
75
|
-
let normal = p2js_helper_1.P2JSHelper.arrayToVector(p2RaycastResult.normal);
|
|
76
|
-
let hitPosition;
|
|
77
|
-
let hitDistance;
|
|
78
|
-
let isExternal;
|
|
79
|
-
return {
|
|
80
|
-
body: p2RaycastResult.body,
|
|
81
|
-
hitPosition: () => {
|
|
82
|
-
if (hitPosition === undefined) {
|
|
83
|
-
hitPosition = this.from.lerp(this.to, fraction);
|
|
84
|
-
}
|
|
85
|
-
return hitPosition;
|
|
86
|
-
},
|
|
87
|
-
hitDistance: () => {
|
|
88
|
-
if (hitDistance === undefined) {
|
|
89
|
-
hitDistance = this.length * fraction;
|
|
90
|
-
}
|
|
91
|
-
return hitDistance;
|
|
92
|
-
},
|
|
93
|
-
isExternal: () => {
|
|
94
|
-
if (isExternal === undefined) {
|
|
95
|
-
isExternal = this.fromTo.dotProduct(normal) < 0;
|
|
96
|
-
}
|
|
97
|
-
return isExternal;
|
|
98
|
-
},
|
|
99
|
-
normal,
|
|
100
|
-
fraction,
|
|
101
|
-
rayCast: this
|
|
102
|
-
};
|
|
103
|
-
}
|
|
80
|
+
return hitPosition;
|
|
81
|
+
},
|
|
82
|
+
hitDistance: () => {
|
|
83
|
+
if (hitDistance === undefined) {
|
|
84
|
+
hitDistance = this.length * fraction;
|
|
85
|
+
}
|
|
86
|
+
return hitDistance;
|
|
87
|
+
},
|
|
88
|
+
isExternal: () => {
|
|
89
|
+
if (isExternal === undefined) {
|
|
90
|
+
isExternal = this.fromTo.dotProduct(normal) < 0;
|
|
91
|
+
}
|
|
92
|
+
return isExternal;
|
|
93
|
+
},
|
|
94
|
+
normal,
|
|
95
|
+
fraction,
|
|
96
|
+
rayCast: this
|
|
97
|
+
};
|
|
98
|
+
}
|
|
104
99
|
}
|
|
105
100
|
exports.RayCast = RayCast;
|
|
106
|
-
//# sourceMappingURL=ray-cast.js.map
|
|
101
|
+
//# sourceMappingURL=ray-cast.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import * as PIXI from 'pixi.js';
|
|
2
2
|
export declare class Filters {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
private container;
|
|
4
|
+
private colorMatrix;
|
|
5
|
+
private _red;
|
|
6
|
+
private _green;
|
|
7
|
+
private _blue;
|
|
8
|
+
private _brightness;
|
|
9
|
+
get brightness(): number;
|
|
10
|
+
set brightness(value: number);
|
|
11
|
+
get red(): number;
|
|
12
|
+
set red(value: number);
|
|
13
|
+
get green(): number;
|
|
14
|
+
set green(value: number);
|
|
15
|
+
get blue(): number;
|
|
16
|
+
set blue(value: number);
|
|
17
|
+
constructor(container: PIXI.Container);
|
|
18
|
+
removeColorFilter(): void;
|
|
19
|
+
private refreshColorMatrix;
|
|
20
|
+
private onFilterChange;
|
|
21
21
|
}
|