bard-legends-framework 0.9.6 → 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.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 +4 -10
|
@@ -3,20 +3,20 @@ import { Vec2 } from 'helpers-lib';
|
|
|
3
3
|
import { CollisionReport } from '../interfaces';
|
|
4
4
|
export type OnCollisionCallbackFunciton = (collision: CollisionReport) => void;
|
|
5
5
|
export declare class PhysicsCollision {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
private p2BodyIdtoOnCollisionCallback;
|
|
7
|
+
private p2World;
|
|
8
|
+
private closestAvailableSpaceHelper?;
|
|
9
|
+
private mapSize;
|
|
10
|
+
constructor(p2World: p2.World, mapsize: Vec2);
|
|
11
|
+
update(time: number, delta: number): void;
|
|
12
|
+
isCollidingWithAnything(p2Body: p2.Body): boolean;
|
|
13
|
+
findClosestAvailableSpace(body: p2.Body): Vec2 | undefined;
|
|
14
|
+
onBodyAdded(body: p2.Body, onCollisionCallback: OnCollisionCallbackFunciton, markOnGrid: boolean): void;
|
|
15
|
+
onBodyRemoved(body: p2.Body): void;
|
|
16
|
+
private createClosestAvailableSpaceHelper;
|
|
17
|
+
private handleSpeedLimit;
|
|
18
|
+
private handleCollision;
|
|
19
|
+
private calculateImpactSeverity;
|
|
20
|
+
private getContactPointsOfCollision;
|
|
21
|
+
private getContactPointOfCollision;
|
|
22
22
|
}
|
|
@@ -1,135 +1,155 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
2
|
exports.PhysicsCollision = void 0;
|
|
4
|
-
const helpers_lib_1 = require(
|
|
5
|
-
const p2js_helper_1 = require(
|
|
6
|
-
const closest_available_space_helper_1 = require(
|
|
7
|
-
const movable_physics_entity_1 = require(
|
|
3
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
4
|
+
const p2js_helper_1 = require('../helpers/p2js.helper');
|
|
5
|
+
const closest_available_space_helper_1 = require('../helpers/closest-available-space.helper');
|
|
6
|
+
const movable_physics_entity_1 = require('../entitity-types/movable-physics-entity');
|
|
8
7
|
const GRID_SIZE = 80;
|
|
9
8
|
const HALF_DAMAGE_STIFFNESS = 100;
|
|
10
9
|
const SPEED_LIMIT = 0.8;
|
|
11
10
|
const ANGULAR_SPEED_LIMIT = 0.01;
|
|
12
11
|
class PhysicsCollision {
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
12
|
+
constructor(p2World, mapsize) {
|
|
13
|
+
this.p2BodyIdtoOnCollisionCallback = new Map();
|
|
14
|
+
this.p2World = p2World;
|
|
15
|
+
this.mapSize = mapsize;
|
|
16
|
+
this.p2World.on('beginContact', event => {
|
|
17
|
+
const bodyA = event.bodyA;
|
|
18
|
+
const bodyB = event.bodyB;
|
|
19
|
+
const { contactPointA, contactPointB } = this.getContactPointsOfCollision(event);
|
|
20
|
+
const relativeVelocity = helpers_lib_1.Vector.getLength({
|
|
21
|
+
x: bodyA.velocity[0] - bodyB.velocity[0],
|
|
22
|
+
y: bodyA.velocity[1] - bodyB.velocity[1]
|
|
23
|
+
});
|
|
24
|
+
const stiffness = event.contactEquations[0].stiffness;
|
|
25
|
+
this.handleCollision(
|
|
26
|
+
{
|
|
27
|
+
body: bodyA,
|
|
28
|
+
contactPoint: contactPointA,
|
|
29
|
+
rotation: bodyA.angle,
|
|
30
|
+
mass: bodyA.mass
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
body: bodyB,
|
|
34
|
+
contactPoint: contactPointB,
|
|
35
|
+
rotation: bodyB.angle,
|
|
36
|
+
mass: bodyB.mass
|
|
37
|
+
},
|
|
38
|
+
relativeVelocity,
|
|
39
|
+
stiffness
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
this.p2World.on('endContact', event => {
|
|
43
|
+
this.handleSpeedLimit(event.bodyA);
|
|
44
|
+
this.handleSpeedLimit(event.bodyB);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
update(time, delta) {
|
|
48
|
+
this.closestAvailableSpaceHelper = undefined;
|
|
49
|
+
}
|
|
50
|
+
isCollidingWithAnything(p2Body) {
|
|
51
|
+
p2Body.aabbNeedsUpdate = true;
|
|
52
|
+
p2Body.updateAABB();
|
|
53
|
+
const overlappingBodies = this.p2World.broadphase.aabbQuery(this.p2World, p2Body.aabb);
|
|
54
|
+
return !!overlappingBodies.length;
|
|
55
|
+
}
|
|
56
|
+
findClosestAvailableSpace(body) {
|
|
57
|
+
if (!this.closestAvailableSpaceHelper) {
|
|
58
|
+
this.createClosestAvailableSpaceHelper();
|
|
50
59
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
body.aabbNeedsUpdate = true;
|
|
61
|
+
body.updateAABB();
|
|
62
|
+
const changeVector = this.closestAvailableSpaceHelper?.findClosestAvailableSpace(
|
|
63
|
+
p2js_helper_1.P2JSHelper.aabbToBoundingBox(body.aabb)
|
|
64
|
+
);
|
|
65
|
+
return changeVector;
|
|
66
|
+
}
|
|
67
|
+
onBodyAdded(body, onCollisionCallback, markOnGrid) {
|
|
68
|
+
this.p2BodyIdtoOnCollisionCallback.set(body.id, onCollisionCallback);
|
|
69
|
+
if (markOnGrid && this.closestAvailableSpaceHelper) {
|
|
70
|
+
body.aabbNeedsUpdate = true;
|
|
71
|
+
body.updateAABB();
|
|
72
|
+
this.closestAvailableSpaceHelper.markObjectOnGrid(p2js_helper_1.P2JSHelper.aabbToBoundingBox(body.aabb));
|
|
58
73
|
}
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
}
|
|
75
|
+
onBodyRemoved(body) {
|
|
76
|
+
this.p2BodyIdtoOnCollisionCallback.delete(body.id);
|
|
77
|
+
}
|
|
78
|
+
createClosestAvailableSpaceHelper() {
|
|
79
|
+
const closestAvailableSpaceHelper = new closest_available_space_helper_1.ClosestAvailableSpaceHelper(
|
|
80
|
+
this.mapSize.x,
|
|
81
|
+
this.mapSize.y,
|
|
82
|
+
GRID_SIZE
|
|
83
|
+
);
|
|
84
|
+
this.p2World.bodies.forEach(body => {
|
|
85
|
+
body.updateAABB();
|
|
86
|
+
closestAvailableSpaceHelper.markObjectOnGrid(p2js_helper_1.P2JSHelper.aabbToBoundingBox(body.aabb));
|
|
87
|
+
});
|
|
88
|
+
this.closestAvailableSpaceHelper = closestAvailableSpaceHelper;
|
|
89
|
+
}
|
|
90
|
+
handleSpeedLimit(body) {
|
|
91
|
+
let velocity = p2js_helper_1.P2JSHelper.arrayToVec2(body.velocity);
|
|
92
|
+
if (helpers_lib_1.Vector.getLength(velocity) > SPEED_LIMIT) {
|
|
93
|
+
velocity = helpers_lib_1.Vector.normalize(velocity, SPEED_LIMIT);
|
|
94
|
+
body.velocity = p2js_helper_1.P2JSHelper.vec2ToArray(velocity);
|
|
61
95
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
96
|
+
body.angularVelocity = Math.min(Math.max(body.angularVelocity, -ANGULAR_SPEED_LIMIT), ANGULAR_SPEED_LIMIT);
|
|
97
|
+
}
|
|
98
|
+
handleCollision(objectA, objectB, relativeVelocity, stiffness) {
|
|
99
|
+
const callbackA = this.p2BodyIdtoOnCollisionCallback.get(objectA.body.id);
|
|
100
|
+
const callbackB = this.p2BodyIdtoOnCollisionCallback.get(objectB.body.id);
|
|
101
|
+
const bodyA = movable_physics_entity_1.MovablePhysicsEntity.getFromP2BodyId(objectA.body.id);
|
|
102
|
+
const bodyB = movable_physics_entity_1.MovablePhysicsEntity.getFromP2BodyId(objectB.body.id);
|
|
103
|
+
if ((callbackA || callbackB) && bodyA && bodyB) {
|
|
104
|
+
const objectACollisionDetails = {
|
|
105
|
+
body: bodyA.convertToDTO(),
|
|
106
|
+
getPositionReletiveToObject: () =>
|
|
107
|
+
helpers_lib_1.Vector.rotate(objectA.contactPoint, helpers_lib_1.Radian.radianToVector(-objectA.rotation)),
|
|
108
|
+
getSeverity: () => this.calculateImpactSeverity(relativeVelocity, stiffness, objectA.mass, objectB.mass),
|
|
109
|
+
position: objectA.contactPoint
|
|
110
|
+
};
|
|
111
|
+
const objectBCollisionDetails = {
|
|
112
|
+
body: bodyB.convertToDTO(),
|
|
113
|
+
getPositionReletiveToObject: () =>
|
|
114
|
+
helpers_lib_1.Vector.rotate(objectB.contactPoint, helpers_lib_1.Radian.radianToVector(-objectB.rotation)),
|
|
115
|
+
getSeverity: () => this.calculateImpactSeverity(relativeVelocity, stiffness, objectB.mass, objectA.mass),
|
|
116
|
+
position: objectB.contactPoint
|
|
117
|
+
};
|
|
118
|
+
if (callbackA) {
|
|
119
|
+
callbackA({
|
|
120
|
+
self: objectACollisionDetails,
|
|
121
|
+
target: objectBCollisionDetails
|
|
67
122
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
body.angularVelocity = Math.min(Math.max(body.angularVelocity, -ANGULAR_SPEED_LIMIT), ANGULAR_SPEED_LIMIT);
|
|
77
|
-
}
|
|
78
|
-
handleCollision(objectA, objectB, relativeVelocity, stiffness) {
|
|
79
|
-
let callbackA = this.p2BodyIdtoOnCollisionCallback.get(objectA.body.id);
|
|
80
|
-
let callbackB = this.p2BodyIdtoOnCollisionCallback.get(objectB.body.id);
|
|
81
|
-
let bodyA = movable_physics_entity_1.MovablePhysicsEntity.getFromP2BodyId(objectA.body.id);
|
|
82
|
-
let bodyB = movable_physics_entity_1.MovablePhysicsEntity.getFromP2BodyId(objectB.body.id);
|
|
83
|
-
if ((callbackA || callbackB) && bodyA && bodyB) {
|
|
84
|
-
let objectACollisionDetails = {
|
|
85
|
-
body: bodyA.convertToDTO(),
|
|
86
|
-
getPositionReletiveToObject: () => helpers_lib_1.Vector.rotate(objectA.contactPoint, helpers_lib_1.Radian.radianToVector(-objectA.rotation)),
|
|
87
|
-
getSeverity: () => this.calculateImpactSeverity(relativeVelocity, stiffness, objectA.mass, objectB.mass),
|
|
88
|
-
position: objectA.contactPoint
|
|
89
|
-
};
|
|
90
|
-
let objectBCollisionDetails = {
|
|
91
|
-
body: bodyB.convertToDTO(),
|
|
92
|
-
getPositionReletiveToObject: () => helpers_lib_1.Vector.rotate(objectB.contactPoint, helpers_lib_1.Radian.radianToVector(-objectB.rotation)),
|
|
93
|
-
getSeverity: () => this.calculateImpactSeverity(relativeVelocity, stiffness, objectB.mass, objectA.mass),
|
|
94
|
-
position: objectB.contactPoint
|
|
95
|
-
};
|
|
96
|
-
if (callbackA) {
|
|
97
|
-
callbackA({
|
|
98
|
-
self: objectACollisionDetails,
|
|
99
|
-
target: objectBCollisionDetails
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
if (callbackB) {
|
|
103
|
-
callbackB({
|
|
104
|
-
self: objectBCollisionDetails,
|
|
105
|
-
target: objectACollisionDetails
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
calculateImpactSeverity(relativeVelocity, stiffness, objectMass, targetMass) {
|
|
111
|
-
let massRatio = Math.min(targetMass / objectMass, Number.MAX_SAFE_INTEGER);
|
|
112
|
-
let impactMomentum = (2 * massRatio * relativeVelocity) / (1 + massRatio);
|
|
113
|
-
let stiffnessMultiplier = stiffness / (HALF_DAMAGE_STIFFNESS + stiffness);
|
|
114
|
-
return impactMomentum * stiffnessMultiplier;
|
|
115
|
-
}
|
|
116
|
-
getContactPointsOfCollision(event) {
|
|
117
|
-
return {
|
|
118
|
-
contactPointA: this.getContactPointOfCollision(event, event.bodyA.id),
|
|
119
|
-
contactPointB: this.getContactPointOfCollision(event, event.bodyB.id)
|
|
120
|
-
};
|
|
123
|
+
}
|
|
124
|
+
if (callbackB) {
|
|
125
|
+
callbackB({
|
|
126
|
+
self: objectBCollisionDetails,
|
|
127
|
+
target: objectACollisionDetails
|
|
128
|
+
});
|
|
129
|
+
}
|
|
121
130
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
}
|
|
132
|
+
calculateImpactSeverity(relativeVelocity, stiffness, objectMass, targetMass) {
|
|
133
|
+
const massRatio = Math.min(targetMass / objectMass, Number.MAX_SAFE_INTEGER);
|
|
134
|
+
const impactMomentum = (2 * massRatio * relativeVelocity) / (1 + massRatio);
|
|
135
|
+
const stiffnessMultiplier = stiffness / (HALF_DAMAGE_STIFFNESS + stiffness);
|
|
136
|
+
return impactMomentum * stiffnessMultiplier;
|
|
137
|
+
}
|
|
138
|
+
getContactPointsOfCollision(event) {
|
|
139
|
+
return {
|
|
140
|
+
contactPointA: this.getContactPointOfCollision(event, event.bodyA.id),
|
|
141
|
+
contactPointB: this.getContactPointOfCollision(event, event.bodyB.id)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
getContactPointOfCollision(event, bodyId) {
|
|
145
|
+
if (event.contactEquations[0].bodyA.id === bodyId) {
|
|
146
|
+
return p2js_helper_1.P2JSHelper.arrayToVec2(event.contactEquations[0].contactPointA);
|
|
147
|
+
} else if (event.contactEquations[0].bodyB.id === bodyId) {
|
|
148
|
+
return p2js_helper_1.P2JSHelper.arrayToVec2(event.contactEquations[0].contactPointB);
|
|
149
|
+
} else {
|
|
150
|
+
throw new Error('Collision bodyA are not matching contact equations.');
|
|
132
151
|
}
|
|
152
|
+
}
|
|
133
153
|
}
|
|
134
154
|
exports.PhysicsCollision = PhysicsCollision;
|
|
135
|
-
//# sourceMappingURL=physics-collision.js.map
|
|
155
|
+
//# sourceMappingURL=physics-collision.js.map
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import p2 from 'p2';
|
|
2
2
|
import { BorderProperties, MaterialContactDefinition, MaterialDefinition } from '../interfaces';
|
|
3
3
|
export declare class PhysicsMaterials {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
private borderMaterial;
|
|
5
|
+
private materials;
|
|
6
|
+
private materialDefinitions;
|
|
7
|
+
constructor(
|
|
8
|
+
p2World: p2.World,
|
|
9
|
+
borderProperties: BorderProperties,
|
|
10
|
+
materialDefinitions: ReadonlyArray<MaterialDefinition>,
|
|
11
|
+
materialContactDefinitions: ReadonlyArray<MaterialContactDefinition>
|
|
12
|
+
);
|
|
13
|
+
getBorderMaterial(): p2.Material;
|
|
14
|
+
getMaterial(name: string): p2.Material;
|
|
15
|
+
getMaterialDefinition(name: string): MaterialDefinition;
|
|
16
|
+
private addContactMaterials;
|
|
17
|
+
private getFullListOfMaterialContactDefinitions;
|
|
18
|
+
private addContactMaterialsWithBorder;
|
|
14
19
|
}
|
|
@@ -1,107 +1,108 @@
|
|
|
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.PhysicsMaterials = void 0;
|
|
7
|
-
const p2_1 = __importDefault(require(
|
|
8
|
-
const interfaces_1 = require(
|
|
4
|
+
const p2_1 = __importDefault(require('p2'));
|
|
5
|
+
const interfaces_1 = require('../interfaces');
|
|
9
6
|
class PhysicsMaterials {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
constructor(p2World, borderProperties, materialDefinitions, materialContactDefinitions) {
|
|
8
|
+
this.borderMaterial = new p2_1.default.Material();
|
|
9
|
+
this.materials = new Map();
|
|
10
|
+
this.materialDefinitions = new Map();
|
|
11
|
+
materialDefinitions.forEach(materialDefinition => {
|
|
12
|
+
this.materials.set(materialDefinition.name, new p2_1.default.Material());
|
|
13
|
+
this.materialDefinitions.set(materialDefinition.name, materialDefinition);
|
|
14
|
+
});
|
|
15
|
+
this.addContactMaterials(p2World, borderProperties, materialDefinitions, materialContactDefinitions);
|
|
16
|
+
}
|
|
17
|
+
getBorderMaterial() {
|
|
18
|
+
return this.borderMaterial;
|
|
19
|
+
}
|
|
20
|
+
getMaterial(name) {
|
|
21
|
+
if (name === interfaces_1.BorderMaterialName) {
|
|
22
|
+
return this.borderMaterial;
|
|
23
|
+
} else {
|
|
24
|
+
const material = this.materials.get(name);
|
|
25
|
+
if (!material) {
|
|
26
|
+
throw new Error(`Could not find material with name ${name}.`);
|
|
27
|
+
}
|
|
28
|
+
return material;
|
|
19
29
|
}
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
}
|
|
31
|
+
getMaterialDefinition(name) {
|
|
32
|
+
if (name === interfaces_1.BorderMaterialName) {
|
|
33
|
+
return {
|
|
34
|
+
name: interfaces_1.BorderMaterialName,
|
|
35
|
+
density: Number.MAX_SAFE_INTEGER,
|
|
36
|
+
velocityDrag: 1,
|
|
37
|
+
rotationalDrag: 1
|
|
38
|
+
};
|
|
39
|
+
} else {
|
|
40
|
+
const materialDefinition = this.materialDefinitions.get(name);
|
|
41
|
+
if (!materialDefinition) {
|
|
42
|
+
throw new Error(`Could not find material definition with name ${name}.`);
|
|
43
|
+
}
|
|
44
|
+
return materialDefinition;
|
|
22
45
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
46
|
+
}
|
|
47
|
+
addContactMaterials(p2World, borderProperties, materialDefinitions, materialContactDefinitions) {
|
|
48
|
+
this.getFullListOfMaterialContactDefinitions(
|
|
49
|
+
materialDefinitions.map(definition => definition.name),
|
|
50
|
+
materialContactDefinitions
|
|
51
|
+
).forEach(contactDefinition => {
|
|
52
|
+
const materialA = this.getMaterial(contactDefinition.materialA);
|
|
53
|
+
const materialB = this.getMaterial(contactDefinition.materialB);
|
|
54
|
+
p2World.addContactMaterial(
|
|
55
|
+
new p2_1.default.ContactMaterial(materialA, materialB, {
|
|
56
|
+
friction: contactDefinition.friction,
|
|
57
|
+
restitution: contactDefinition.bounciness,
|
|
58
|
+
stiffness: contactDefinition.stiffness
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
this.addContactMaterialsWithBorder(p2World, borderProperties, materialDefinitions);
|
|
63
|
+
}
|
|
64
|
+
getFullListOfMaterialContactDefinitions(materialNames, materialContactDefinitions) {
|
|
65
|
+
const definedCombinations = new Map();
|
|
66
|
+
materialContactDefinitions.forEach(contactDefinition => {
|
|
67
|
+
let materialAMap = definedCombinations.get(contactDefinition.materialA);
|
|
68
|
+
if (!materialAMap) {
|
|
69
|
+
materialAMap = new Map();
|
|
70
|
+
definedCombinations.set(contactDefinition.materialA, materialAMap);
|
|
71
|
+
}
|
|
72
|
+
materialAMap.set(contactDefinition.materialB, contactDefinition);
|
|
73
|
+
});
|
|
74
|
+
const fullList = [];
|
|
75
|
+
materialNames.forEach((materialA, index) => {
|
|
76
|
+
for (let i = index; i < materialNames.length; i++) {
|
|
77
|
+
const materialB = materialNames[i];
|
|
78
|
+
const contactDefinition = definedCombinations.get(materialA)?.get(materialB);
|
|
79
|
+
if (contactDefinition) {
|
|
80
|
+
fullList.push(contactDefinition);
|
|
81
|
+
} else {
|
|
82
|
+
fullList.push({
|
|
83
|
+
materialA,
|
|
84
|
+
materialB,
|
|
85
|
+
friction: 0,
|
|
86
|
+
bounciness: 0,
|
|
87
|
+
stiffness: 1e6 // default p2js stiffness
|
|
88
|
+
});
|
|
26
89
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
let materialDefinition = this.materialDefinitions.get(name);
|
|
46
|
-
if (!materialDefinition) {
|
|
47
|
-
throw new Error(`Could not find material definition with name ${name}.`);
|
|
48
|
-
}
|
|
49
|
-
return materialDefinition;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
addContactMaterials(p2World, borderProperties, materialDefinitions, materialContactDefinitions) {
|
|
53
|
-
this.getFullListOfMaterialContactDefinitions(materialDefinitions.map(definition => definition.name), materialContactDefinitions).forEach(contactDefinition => {
|
|
54
|
-
let materialA = this.getMaterial(contactDefinition.materialA);
|
|
55
|
-
let materialB = this.getMaterial(contactDefinition.materialB);
|
|
56
|
-
p2World.addContactMaterial(new p2_1.default.ContactMaterial(materialA, materialB, {
|
|
57
|
-
friction: contactDefinition.friction,
|
|
58
|
-
restitution: contactDefinition.bounciness,
|
|
59
|
-
stiffness: contactDefinition.stiffness
|
|
60
|
-
}));
|
|
61
|
-
});
|
|
62
|
-
this.addContactMaterialsWithBorder(p2World, borderProperties, materialDefinitions);
|
|
63
|
-
}
|
|
64
|
-
getFullListOfMaterialContactDefinitions(materialNames, materialContactDefinitions) {
|
|
65
|
-
let definedCombinations = new Map();
|
|
66
|
-
materialContactDefinitions.forEach(contactDefinition => {
|
|
67
|
-
let materialAMap = definedCombinations.get(contactDefinition.materialA);
|
|
68
|
-
if (!materialAMap) {
|
|
69
|
-
materialAMap = new Map();
|
|
70
|
-
definedCombinations.set(contactDefinition.materialA, materialAMap);
|
|
71
|
-
}
|
|
72
|
-
materialAMap.set(contactDefinition.materialB, contactDefinition);
|
|
73
|
-
});
|
|
74
|
-
let fullList = [];
|
|
75
|
-
materialNames.forEach((materialA, index) => {
|
|
76
|
-
for (let i = index; i < materialNames.length; i++) {
|
|
77
|
-
let materialB = materialNames[i];
|
|
78
|
-
let contactDefinition = definedCombinations.get(materialA)?.get(materialB);
|
|
79
|
-
if (contactDefinition) {
|
|
80
|
-
fullList.push(contactDefinition);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
fullList.push({
|
|
84
|
-
materialA,
|
|
85
|
-
materialB,
|
|
86
|
-
friction: 0,
|
|
87
|
-
bounciness: 0,
|
|
88
|
-
stiffness: 1e6 // default p2js stiffness
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
return fullList;
|
|
94
|
-
}
|
|
95
|
-
addContactMaterialsWithBorder(p2World, borderProperties, materialDefinitions) {
|
|
96
|
-
materialDefinitions.forEach(materialDefinition => {
|
|
97
|
-
let materialA = this.getMaterial(materialDefinition.name);
|
|
98
|
-
p2World.addContactMaterial(new p2_1.default.ContactMaterial(materialA, this.borderMaterial, {
|
|
99
|
-
friction: borderProperties.friction,
|
|
100
|
-
restitution: borderProperties.bounciness,
|
|
101
|
-
stiffness: borderProperties.stiffness
|
|
102
|
-
}));
|
|
103
|
-
});
|
|
104
|
-
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return fullList;
|
|
93
|
+
}
|
|
94
|
+
addContactMaterialsWithBorder(p2World, borderProperties, materialDefinitions) {
|
|
95
|
+
materialDefinitions.forEach(materialDefinition => {
|
|
96
|
+
const materialA = this.getMaterial(materialDefinition.name);
|
|
97
|
+
p2World.addContactMaterial(
|
|
98
|
+
new p2_1.default.ContactMaterial(materialA, this.borderMaterial, {
|
|
99
|
+
friction: borderProperties.friction,
|
|
100
|
+
restitution: borderProperties.bounciness,
|
|
101
|
+
stiffness: borderProperties.stiffness
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
105
106
|
}
|
|
106
107
|
exports.PhysicsMaterials = PhysicsMaterials;
|
|
107
|
-
//# sourceMappingURL=physics-materials.js.map
|
|
108
|
+
//# sourceMappingURL=physics-materials.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vec2 } from 'helpers-lib';
|
|
2
2
|
import { PhysicsWorld } from '../physics-world';
|
|
3
3
|
export declare class PhysicsWorldBorders {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
static createBorders(physicsWorld: PhysicsWorld, mapSize: Vec2): void;
|
|
5
|
+
private static createBorder;
|
|
6
6
|
}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
2
|
exports.PhysicsWorldBorders = void 0;
|
|
4
|
-
const interfaces_1 = require(
|
|
5
|
-
const physics_world_1 = require(
|
|
6
|
-
const physics_body_groups_1 = require(
|
|
3
|
+
const interfaces_1 = require('../interfaces');
|
|
4
|
+
const physics_world_1 = require('../physics-world');
|
|
5
|
+
const physics_body_groups_1 = require('./physics-body-groups');
|
|
7
6
|
class PhysicsWorldBorders {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
static createBorders(physicsWorld, mapSize) {
|
|
8
|
+
PhysicsWorldBorders.createBorder(physicsWorld, { x: mapSize.x / 2, y: -50 }, { x: mapSize.x + 200, y: 100 }); // Top border
|
|
9
|
+
PhysicsWorldBorders.createBorder(physicsWorld, { x: mapSize.x / 2, y: mapSize.y + 50 }, { x: mapSize.x + 200, y: 100 }); // Bottom border
|
|
10
|
+
PhysicsWorldBorders.createBorder(physicsWorld, { x: -50, y: mapSize.y / 2 }, { x: 100, y: mapSize.y + 200 }); // Left border
|
|
11
|
+
PhysicsWorldBorders.createBorder(physicsWorld, { x: mapSize.x + 50, y: mapSize.y / 2 }, { x: 100, y: mapSize.y + 200 }); // Right border
|
|
12
|
+
}
|
|
13
|
+
static createBorder(physicsWorld, position, size) {
|
|
14
|
+
return new physics_world_1.BorderEntity(physicsWorld, {
|
|
15
|
+
shapeDefinition: {
|
|
16
|
+
materialName: interfaces_1.BorderMaterialName,
|
|
17
|
+
group: physics_body_groups_1.PhysicsBodyGroup.border,
|
|
18
|
+
shapeType: interfaces_1.PhysicsShapeType.rectangle,
|
|
19
|
+
shapeData: { size }
|
|
20
|
+
},
|
|
21
|
+
position,
|
|
22
|
+
rotation: 0,
|
|
23
|
+
addInEmptySpace: false,
|
|
24
|
+
includeOnPathfinding: true
|
|
25
|
+
}).attach(physicsWorld);
|
|
26
|
+
}
|
|
28
27
|
}
|
|
29
28
|
exports.PhysicsWorldBorders = PhysicsWorldBorders;
|
|
30
|
-
//# sourceMappingURL=physics-world-borders.js.map
|
|
29
|
+
//# sourceMappingURL=physics-world-borders.js.map
|
|
@@ -2,15 +2,19 @@ import { Vector } from 'helpers-lib';
|
|
|
2
2
|
import { RayCast, RayCastResult } from './ray-cast';
|
|
3
3
|
import { PhysicsEntity } from '../../entitity-types/physics-entity';
|
|
4
4
|
export declare class PhysicsBodyExplosionHit {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
static convertRaysToBodyExplosionHits(
|
|
6
|
+
rays: RayCast[],
|
|
7
|
+
centerOfExplosion: Vector,
|
|
8
|
+
totalCountOfRays: number
|
|
9
|
+
): PhysicsBodyExplosionHit[];
|
|
10
|
+
private static groupRayResultsByBody;
|
|
11
|
+
readonly body: PhysicsEntity;
|
|
12
|
+
readonly isExternal: boolean;
|
|
13
|
+
readonly normal: Vector;
|
|
14
|
+
readonly fraction: number;
|
|
15
|
+
readonly ratioOfHits: number;
|
|
16
|
+
readonly raycastResults: ReadonlyArray<RayCastResult>;
|
|
17
|
+
readonly getHitPosition: () => Vector;
|
|
18
|
+
readonly getHitDistance: () => number;
|
|
19
|
+
private constructor();
|
|
16
20
|
}
|