dacha 0.18.0-alpha.3 → 0.18.0-alpha.5
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/build/contrib/components/character-body/index.d.ts +66 -0
- package/build/contrib/components/character-body/index.js +81 -0
- package/build/contrib/components/collider/index.d.ts +14 -14
- package/build/contrib/components/collider/index.js +10 -7
- package/build/contrib/components/index.d.ts +1 -0
- package/build/contrib/components/index.js +1 -0
- package/build/contrib/components/rigid-body/index.d.ts +53 -7
- package/build/contrib/components/rigid-body/index.js +63 -7
- package/build/contrib/events/index.d.ts +29 -0
- package/build/contrib/events/index.js +9 -0
- package/build/contrib/systems/character-controller/index.d.ts +32 -0
- package/build/contrib/systems/character-controller/index.js +262 -0
- package/build/contrib/systems/character-controller/utils.d.ts +2 -0
- package/build/contrib/systems/character-controller/utils.js +9 -0
- package/build/contrib/systems/index.d.ts +1 -0
- package/build/contrib/systems/index.js +1 -0
- package/build/contrib/systems/physics-system/api.d.ts +61 -19
- package/build/contrib/systems/physics-system/api.js +61 -20
- package/build/contrib/systems/physics-system/physics-system.d.ts +1 -0
- package/build/contrib/systems/physics-system/physics-system.js +23 -3
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-box-cast-aabb.d.ts +2 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-box-cast-aabb.js +18 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-capsule-cast-aabb.d.ts +2 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-capsule-cast-aabb.js +21 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-circle-cast-aabb.d.ts +2 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-circle-cast-aabb.js +15 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/index.js +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-cast-geometry.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-cast-geometry.js +27 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-geometry.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-geometry.js +16 -16
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-cast-geometry.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-cast-geometry.js +47 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-geometry.d.ts +4 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-geometry.js +50 -13
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-cast-geometry.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-cast-geometry.js +13 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-geometry.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-geometry.js +20 -14
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-point-geometry.js +1 -1
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-ray-geometry.js +1 -1
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-segment-geometry.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-segment-geometry.js +9 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/index.d.ts +8 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/index.js +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/index.d.ts +10 -7
- package/build/contrib/systems/physics-system/subsystems/collision-detection/index.js +56 -11
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-box/check-boxes-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-box/check-boxes-intersection.js +1 -3
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-capsule/check-box-and-capsule-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-capsule/check-box-and-capsule-intersection.js +1 -3
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-capsule/utils.js +10 -10
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-circle/check-box-and-circle-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-circle/check-box-and-circle-intersection.js +3 -6
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-segment/check-box-and-segment-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-segment/check-box-and-segment-intersection.js +2 -4
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-segment/utils.js +8 -8
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/capsule-capsule/check-capsules-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/capsule-capsule/check-capsules-intersection.js +1 -3
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-capsule/check-circle-and-capsule-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-capsule/check-circle-and-capsule-intersection.js +3 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-circle/check-circles-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-circle/check-circles-intersection.js +5 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-segment/check-circle-and-segment-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-segment/check-circle-and-segment-intersection.js +3 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/capsule.js +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/cast.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/cast.js +9 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/points.js +2 -3
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/projections.js +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/segment-distance.js +6 -6
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/index.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/index.js +0 -10
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-box/check-point-and-box-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-box/check-point-and-box-intersection.js +4 -6
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-capsule/check-point-and-capsule-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-capsule/check-point-and-capsule-intersection.js +3 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-circle/check-point-and-circle-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-circle/check-point-and-circle-intersection.js +3 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-segment/check-point-and-segment-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-segment/check-point-and-segment-intersection.js +3 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/segment-capsule/check-segment-and-capsule-intersection.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/segment-capsule/check-segment-and-capsule-intersection.js +1 -3
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/tests/helpers.d.ts +3 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/tests/helpers.js +38 -28
- package/build/contrib/systems/physics-system/subsystems/collision-detection/query-utils.d.ts +15 -7
- package/build/contrib/systems/physics-system/subsystems/collision-detection/query-utils.js +123 -18
- package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/index.d.ts +2 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/index.js +12 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-box/check-ray-and-box-intersection.d.ts +3 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-box/check-ray-and-box-intersection.js +8 -12
- package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/ray-capsule/check-ray-and-capsule-intersection.d.ts +20 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-capsule/check-ray-and-capsule-intersection.js +27 -39
- package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-circle/check-ray-and-circle-intersection.d.ts +3 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-circle/check-ray-and-circle-intersection.js +8 -10
- package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-segment/check-ray-and-segment-intersection.d.ts +3 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-segment/check-ray-and-segment-intersection.js +9 -13
- package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/types.d.ts +4 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/types.js +1 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-collider.js +1 -4
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/get-orientation-data.js +1 -4
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-box/check-box-cast-and-box.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-box/check-box-cast-and-box.js +12 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-capsule/check-box-cast-and-capsule.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-capsule/check-box-cast-and-capsule.js +12 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-circle/check-box-cast-and-circle.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-circle/check-box-cast-and-circle.js +12 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-segment/check-box-cast-and-segment.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-segment/check-box-cast-and-segment.js +15 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-utils.d.ts +7 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-utils.js +146 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-box/check-capsule-cast-and-box.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-box/check-capsule-cast-and-box.js +22 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-capsule/check-capsule-cast-and-capsule.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-capsule/check-capsule-cast-and-capsule.js +21 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-circle/check-capsule-cast-and-circle.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-circle/check-capsule-cast-and-circle.js +20 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-segment/check-capsule-cast-and-segment.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-segment/check-capsule-cast-and-segment.js +21 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-utils.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-utils.js +16 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-box/check-circle-cast-and-box.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-box/check-circle-cast-and-box.js +22 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-capsule/check-circle-cast-and-capsule.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-capsule/check-circle-cast-and-capsule.js +18 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-circle/check-circle-cast-and-circle.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-circle/check-circle-cast-and-circle.js +22 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-segment/check-circle-cast-and-segment.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-segment/check-circle-cast-and-segment.js +18 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/index.d.ts +2 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/index.js +32 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/tests/helpers.d.ts +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/tests/helpers.js +39 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/types.d.ts +4 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/types.js +1 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/utils.d.ts +4 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/utils.js +11 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/types.d.ts +16 -1
- package/build/contrib/systems/physics-system/subsystems/collision-detection/utils.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/utils.js +6 -0
- package/build/contrib/systems/physics-system/subsystems/constraint-solver/index.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/constraint-solver/index.js +32 -5
- package/build/contrib/systems/physics-system/subsystems/physics/index.d.ts +11 -3
- package/build/contrib/systems/physics-system/subsystems/physics/index.js +51 -10
- package/build/contrib/systems/physics-system/tests/helpers.d.ts +20 -0
- package/build/contrib/systems/physics-system/tests/helpers.js +130 -0
- package/build/contrib/systems/physics-system/types.d.ts +109 -6
- package/build/contrib/utils/one-way-validator.d.ts +12 -0
- package/build/contrib/utils/one-way-validator.js +53 -0
- package/build/engine/math-lib/vector/ops.d.ts +9 -1
- package/build/engine/math-lib/vector/ops.js +15 -0
- package/build/engine/template/template-collection.js +3 -0
- package/build/events/index.d.ts +2 -2
- package/build/events/index.js +1 -1
- package/package.json +1 -1
- package/build/contrib/systems/physics-system/consts.d.ts +0 -4
- package/build/contrib/systems/physics-system/consts.js +0 -4
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/ray-capsule/check-ray-and-capsule-intersection.d.ts +0 -11
- /package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-segment/utils.d.ts +0 -0
- /package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-segment/utils.js +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Component } from '../../../engine/component';
|
|
2
|
+
import { Vector2 } from '../../../engine/math-lib';
|
|
3
|
+
import type { Actor } from '../../../engine/actor';
|
|
4
|
+
export type CharacterMotionMode = 'surface' | 'free';
|
|
5
|
+
export interface CharacterBodyConfig {
|
|
6
|
+
motionMode?: CharacterMotionMode;
|
|
7
|
+
upDirectionX?: number;
|
|
8
|
+
upDirectionY?: number;
|
|
9
|
+
skinWidth?: number;
|
|
10
|
+
maxSlopeAngle?: number;
|
|
11
|
+
maxSlides?: number;
|
|
12
|
+
maxRecoveries?: number;
|
|
13
|
+
groundSnapDistance?: number;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Kinematic character controller state and movement settings.
|
|
18
|
+
*
|
|
19
|
+
* The controller system consumes `velocity` during fixed updates, performs
|
|
20
|
+
* sweep/slide collision handling, and writes the resulting target through the
|
|
21
|
+
* actor's kinematic rigid body.
|
|
22
|
+
*
|
|
23
|
+
* @category Components
|
|
24
|
+
*/
|
|
25
|
+
export declare class CharacterBody extends Component {
|
|
26
|
+
private _up;
|
|
27
|
+
/** @internal Pending one-step displacement consumed by CharacterController */
|
|
28
|
+
_displacement: Vector2;
|
|
29
|
+
/** Controls contact classification and whether ground snapping is enabled. */
|
|
30
|
+
motionMode: CharacterMotionMode;
|
|
31
|
+
/** Desired character velocity in world units per second */
|
|
32
|
+
velocity: Vector2;
|
|
33
|
+
/** Small distance kept between the character shape and blocking colliders */
|
|
34
|
+
skinWidth: number;
|
|
35
|
+
/** Maximum walkable ground angle in radians, measured from upDirection */
|
|
36
|
+
maxSlopeAngle: number;
|
|
37
|
+
/** Maximum sweep/slide collision iterations used during one fixed update */
|
|
38
|
+
maxSlides: number;
|
|
39
|
+
/** Maximum overlap depenetration iterations used before sweep/slide movement */
|
|
40
|
+
maxRecoveries: number;
|
|
41
|
+
/** Distance used to probe opposite upDirection and keep ground contact over small gaps */
|
|
42
|
+
groundSnapDistance: number;
|
|
43
|
+
/** Whether the controller should be ignored by CharacterController */
|
|
44
|
+
disabled: boolean;
|
|
45
|
+
/** Whether the controller is standing on walkable ground after the last fixed update */
|
|
46
|
+
onGround: boolean;
|
|
47
|
+
/** Whether movement hit a side wall or non-walkable surface during the last fixed update */
|
|
48
|
+
onWall: boolean;
|
|
49
|
+
/** Whether movement hit a ceiling during the last fixed update */
|
|
50
|
+
onCeiling: boolean;
|
|
51
|
+
/** Normal of the current walkable ground surface, updated by CharacterController */
|
|
52
|
+
groundNormal: Vector2;
|
|
53
|
+
/** Actor providing the current walkable ground, or null when not grounded */
|
|
54
|
+
groundActor: Actor | null;
|
|
55
|
+
constructor(config?: CharacterBodyConfig);
|
|
56
|
+
/** Direction treated as up for ground, ceiling, slopes, ground probes, and jumps */
|
|
57
|
+
get upDirection(): Vector2;
|
|
58
|
+
set upDirection(value: Vector2);
|
|
59
|
+
/**
|
|
60
|
+
* Adds a one-step world-space displacement request.
|
|
61
|
+
*
|
|
62
|
+
* The displacement is consumed by CharacterController on the next fixed
|
|
63
|
+
* update and is already expected to be scaled by delta time.
|
|
64
|
+
*/
|
|
65
|
+
move(displacement: Vector2): void;
|
|
66
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Component } from '../../../engine/component';
|
|
2
|
+
import { MathOps, Vector2 } from '../../../engine/math-lib';
|
|
3
|
+
/**
|
|
4
|
+
* Kinematic character controller state and movement settings.
|
|
5
|
+
*
|
|
6
|
+
* The controller system consumes `velocity` during fixed updates, performs
|
|
7
|
+
* sweep/slide collision handling, and writes the resulting target through the
|
|
8
|
+
* actor's kinematic rigid body.
|
|
9
|
+
*
|
|
10
|
+
* @category Components
|
|
11
|
+
*/
|
|
12
|
+
export class CharacterBody extends Component {
|
|
13
|
+
_up;
|
|
14
|
+
/** @internal Pending one-step displacement consumed by CharacterController */
|
|
15
|
+
_displacement;
|
|
16
|
+
/** Controls contact classification and whether ground snapping is enabled. */
|
|
17
|
+
motionMode;
|
|
18
|
+
/** Desired character velocity in world units per second */
|
|
19
|
+
velocity;
|
|
20
|
+
/** Small distance kept between the character shape and blocking colliders */
|
|
21
|
+
skinWidth;
|
|
22
|
+
/** Maximum walkable ground angle in radians, measured from upDirection */
|
|
23
|
+
maxSlopeAngle;
|
|
24
|
+
/** Maximum sweep/slide collision iterations used during one fixed update */
|
|
25
|
+
maxSlides;
|
|
26
|
+
/** Maximum overlap depenetration iterations used before sweep/slide movement */
|
|
27
|
+
maxRecoveries;
|
|
28
|
+
/** Distance used to probe opposite upDirection and keep ground contact over small gaps */
|
|
29
|
+
groundSnapDistance;
|
|
30
|
+
/** Whether the controller should be ignored by CharacterController */
|
|
31
|
+
disabled;
|
|
32
|
+
/** Whether the controller is standing on walkable ground after the last fixed update */
|
|
33
|
+
onGround;
|
|
34
|
+
/** Whether movement hit a side wall or non-walkable surface during the last fixed update */
|
|
35
|
+
onWall;
|
|
36
|
+
/** Whether movement hit a ceiling during the last fixed update */
|
|
37
|
+
onCeiling;
|
|
38
|
+
/** Normal of the current walkable ground surface, updated by CharacterController */
|
|
39
|
+
groundNormal;
|
|
40
|
+
/** Actor providing the current walkable ground, or null when not grounded */
|
|
41
|
+
groundActor;
|
|
42
|
+
constructor(config = {}) {
|
|
43
|
+
super();
|
|
44
|
+
this._up = new Vector2(0, -1);
|
|
45
|
+
this._displacement = new Vector2(0, 0);
|
|
46
|
+
this.upDirection = new Vector2(config.upDirectionX ?? 0, config.upDirectionY ?? -1);
|
|
47
|
+
this.motionMode = config.motionMode ?? 'surface';
|
|
48
|
+
this.disabled = config.disabled ?? false;
|
|
49
|
+
this.velocity = new Vector2(0, 0);
|
|
50
|
+
this.skinWidth = config.skinWidth ?? 0.1;
|
|
51
|
+
this.maxSlopeAngle = MathOps.degToRad(config.maxSlopeAngle ?? 45);
|
|
52
|
+
this.maxSlides = config.maxSlides ?? 4;
|
|
53
|
+
this.maxRecoveries = config.maxRecoveries ?? 3;
|
|
54
|
+
this.groundSnapDistance = config.groundSnapDistance ?? 1;
|
|
55
|
+
this.onGround = false;
|
|
56
|
+
this.onWall = false;
|
|
57
|
+
this.onCeiling = false;
|
|
58
|
+
this.groundNormal = this.upDirection.clone();
|
|
59
|
+
this.groundActor = null;
|
|
60
|
+
}
|
|
61
|
+
/** Direction treated as up for ground, ceiling, slopes, ground probes, and jumps */
|
|
62
|
+
get upDirection() {
|
|
63
|
+
return this._up;
|
|
64
|
+
}
|
|
65
|
+
set upDirection(value) {
|
|
66
|
+
this._up = value.clone().normalize();
|
|
67
|
+
if (this._up.magnitude === 0) {
|
|
68
|
+
throw new Error('Character controller upDirection must be non-zero');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Adds a one-step world-space displacement request.
|
|
73
|
+
*
|
|
74
|
+
* The displacement is consumed by CharacterController on the next fixed
|
|
75
|
+
* update and is already expected to be scaled by delta time.
|
|
76
|
+
*/
|
|
77
|
+
move(displacement) {
|
|
78
|
+
this._displacement.add(displacement);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
CharacterBody.componentName = 'CharacterBody';
|
|
@@ -7,30 +7,28 @@ export interface BaseColliderConfig {
|
|
|
7
7
|
offsetY: number;
|
|
8
8
|
layer: string;
|
|
9
9
|
debugColor?: string;
|
|
10
|
+
disabled: boolean;
|
|
10
11
|
}
|
|
11
12
|
export interface BoxColliderConfig extends BaseColliderConfig {
|
|
12
13
|
type: 'box';
|
|
13
|
-
sizeX
|
|
14
|
-
sizeY
|
|
14
|
+
sizeX?: number;
|
|
15
|
+
sizeY?: number;
|
|
15
16
|
}
|
|
16
17
|
export interface CircleColliderConfig extends BaseColliderConfig {
|
|
17
18
|
type: 'circle';
|
|
18
|
-
radius
|
|
19
|
+
radius?: number;
|
|
19
20
|
}
|
|
20
21
|
export interface SegmentColliderConfig extends BaseColliderConfig {
|
|
21
22
|
type: 'segment';
|
|
22
|
-
point1X
|
|
23
|
-
point1Y
|
|
24
|
-
point2X
|
|
25
|
-
point2Y
|
|
23
|
+
point1X?: number;
|
|
24
|
+
point1Y?: number;
|
|
25
|
+
point2X?: number;
|
|
26
|
+
point2Y?: number;
|
|
26
27
|
}
|
|
27
28
|
export interface CapsuleColliderConfig extends BaseColliderConfig {
|
|
28
29
|
type: 'capsule';
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
point2X: number;
|
|
32
|
-
point2Y: number;
|
|
33
|
-
radius: number;
|
|
30
|
+
height?: number;
|
|
31
|
+
radius?: number;
|
|
34
32
|
}
|
|
35
33
|
export type ColliderConfig = BoxColliderConfig | CircleColliderConfig | SegmentColliderConfig | CapsuleColliderConfig;
|
|
36
34
|
export interface BoxColliderShape {
|
|
@@ -48,8 +46,7 @@ export interface SegmentColliderShape {
|
|
|
48
46
|
}
|
|
49
47
|
export interface CapsuleColliderShape {
|
|
50
48
|
type: 'capsule';
|
|
51
|
-
|
|
52
|
-
point2: Point;
|
|
49
|
+
height: number;
|
|
53
50
|
radius: number;
|
|
54
51
|
}
|
|
55
52
|
export type ColliderShape = BoxColliderShape | CircleColliderShape | SegmentColliderShape | CapsuleColliderShape;
|
|
@@ -69,6 +66,7 @@ export type ColliderShape = BoxColliderShape | CircleColliderShape | SegmentColl
|
|
|
69
66
|
* sizeX: 64,
|
|
70
67
|
* sizeY: 64,
|
|
71
68
|
* layer: 'default',
|
|
69
|
+
* disabled: false,
|
|
72
70
|
* });
|
|
73
71
|
*
|
|
74
72
|
* // Create a circle collider
|
|
@@ -78,6 +76,7 @@ export type ColliderShape = BoxColliderShape | CircleColliderShape | SegmentColl
|
|
|
78
76
|
* offsetY: 0,
|
|
79
77
|
* radius: 32,
|
|
80
78
|
* layer: 'default',
|
|
79
|
+
* disabled: false,
|
|
81
80
|
* });
|
|
82
81
|
*
|
|
83
82
|
* // Add to actor
|
|
@@ -90,6 +89,7 @@ export declare class Collider extends Component {
|
|
|
90
89
|
offset: Point;
|
|
91
90
|
layer: string;
|
|
92
91
|
debugColor?: string;
|
|
92
|
+
disabled: boolean;
|
|
93
93
|
shape: ColliderShape;
|
|
94
94
|
constructor(config: ColliderConfig);
|
|
95
95
|
}
|
|
@@ -15,6 +15,7 @@ import { Component } from '../../../engine/component';
|
|
|
15
15
|
* sizeX: 64,
|
|
16
16
|
* sizeY: 64,
|
|
17
17
|
* layer: 'default',
|
|
18
|
+
* disabled: false,
|
|
18
19
|
* });
|
|
19
20
|
*
|
|
20
21
|
* // Create a circle collider
|
|
@@ -24,6 +25,7 @@ import { Component } from '../../../engine/component';
|
|
|
24
25
|
* offsetY: 0,
|
|
25
26
|
* radius: 32,
|
|
26
27
|
* layer: 'default',
|
|
28
|
+
* disabled: false,
|
|
27
29
|
* });
|
|
28
30
|
*
|
|
29
31
|
* // Add to actor
|
|
@@ -36,38 +38,39 @@ export class Collider extends Component {
|
|
|
36
38
|
offset;
|
|
37
39
|
layer;
|
|
38
40
|
debugColor;
|
|
41
|
+
disabled;
|
|
39
42
|
shape;
|
|
40
43
|
constructor(config) {
|
|
41
44
|
super();
|
|
42
45
|
this.offset = { x: config.offsetX, y: config.offsetY };
|
|
43
46
|
this.layer = config.layer;
|
|
44
47
|
this.debugColor = config.debugColor;
|
|
48
|
+
this.disabled = config.disabled;
|
|
45
49
|
switch (config.type) {
|
|
46
50
|
case 'box':
|
|
47
51
|
this.shape = {
|
|
48
52
|
type: config.type,
|
|
49
|
-
size: { x: config.sizeX, y: config.sizeY },
|
|
53
|
+
size: { x: config.sizeX ?? 0, y: config.sizeY ?? 0 },
|
|
50
54
|
};
|
|
51
55
|
break;
|
|
52
56
|
case 'circle':
|
|
53
57
|
this.shape = {
|
|
54
58
|
type: config.type,
|
|
55
|
-
radius: config.radius,
|
|
59
|
+
radius: config.radius ?? 0,
|
|
56
60
|
};
|
|
57
61
|
break;
|
|
58
62
|
case 'segment':
|
|
59
63
|
this.shape = {
|
|
60
64
|
type: config.type,
|
|
61
|
-
point1: { x: config.point1X, y: config.point1Y },
|
|
62
|
-
point2: { x: config.point2X, y: config.point2Y },
|
|
65
|
+
point1: { x: config.point1X ?? 0, y: config.point1Y ?? 0 },
|
|
66
|
+
point2: { x: config.point2X ?? 0, y: config.point2Y ?? 0 },
|
|
63
67
|
};
|
|
64
68
|
break;
|
|
65
69
|
case 'capsule':
|
|
66
70
|
this.shape = {
|
|
67
71
|
type: config.type,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
radius: config.radius,
|
|
72
|
+
height: config.height ?? 0,
|
|
73
|
+
radius: config.radius ?? 0,
|
|
71
74
|
};
|
|
72
75
|
}
|
|
73
76
|
}
|
|
@@ -2,6 +2,7 @@ export { Camera, type CameraConfig } from './camera';
|
|
|
2
2
|
export { KeyboardControl, type KeyboardControlConfig, } from './keyboard-control';
|
|
3
3
|
export { Collider, type ColliderConfig, type ColliderShape, type ColliderType, type BoxColliderShape, type CircleColliderShape, type SegmentColliderShape, type CapsuleColliderShape, } from './collider';
|
|
4
4
|
export { RigidBody, type RigidBodyConfig } from './rigid-body';
|
|
5
|
+
export { CharacterBody, type CharacterBodyConfig } from './character-body';
|
|
5
6
|
export { Animatable, type AnimatableConfig } from './animatable';
|
|
6
7
|
export { Sprite, type SpriteConfig } from './sprite';
|
|
7
8
|
export { Transform, type TransformConfig } from './transform';
|
|
@@ -2,6 +2,7 @@ export { Camera } from './camera';
|
|
|
2
2
|
export { KeyboardControl, } from './keyboard-control';
|
|
3
3
|
export { Collider, } from './collider';
|
|
4
4
|
export { RigidBody } from './rigid-body';
|
|
5
|
+
export { CharacterBody } from './character-body';
|
|
5
6
|
export { Animatable } from './animatable';
|
|
6
7
|
export { Sprite } from './sprite';
|
|
7
8
|
export { Transform } from './transform';
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Component } from '../../../engine/component';
|
|
2
2
|
import { Vector2 } from '../../../engine/math-lib';
|
|
3
|
-
export type RigidBodyType = 'dynamic' | 'static';
|
|
3
|
+
export type RigidBodyType = 'dynamic' | 'static' | 'kinematic';
|
|
4
4
|
export interface RigidBodyConfig {
|
|
5
5
|
type: RigidBodyType;
|
|
6
|
-
mass
|
|
7
|
-
gravityScale
|
|
8
|
-
linearDamping
|
|
6
|
+
mass?: number;
|
|
7
|
+
gravityScale?: number;
|
|
8
|
+
linearDamping?: number;
|
|
9
9
|
disabled: boolean;
|
|
10
|
+
oneWay: boolean;
|
|
11
|
+
oneWayNormalX?: number;
|
|
12
|
+
oneWayNormalY?: number;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
15
|
* RigidBody component for defining rigid body physics.
|
|
@@ -37,9 +40,10 @@ export interface RigidBodyConfig {
|
|
|
37
40
|
export declare class RigidBody extends Component {
|
|
38
41
|
private _mass;
|
|
39
42
|
private _inverseMass;
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
+
/** @internal Pending one-step kinematic movement target */
|
|
44
|
+
_movementTarget: Vector2 | null;
|
|
45
|
+
/** Body type that defines how the rigid body participates in simulation */
|
|
46
|
+
readonly type: RigidBodyType;
|
|
43
47
|
/** Gravity scale of the rigid body */
|
|
44
48
|
gravityScale: number;
|
|
45
49
|
/** Linear damping value used to slow down movement over time */
|
|
@@ -50,19 +54,61 @@ export declare class RigidBody extends Component {
|
|
|
50
54
|
disabled: boolean;
|
|
51
55
|
/** Whether rigid body is sleeping */
|
|
52
56
|
sleeping: boolean;
|
|
57
|
+
/** Force applied to the rigid body */
|
|
53
58
|
force: Vector2;
|
|
59
|
+
/** Impulse applied to the rigid body */
|
|
54
60
|
impulse: Vector2;
|
|
61
|
+
/** Whether contacts should only be resolved from one side */
|
|
62
|
+
oneWay: boolean;
|
|
63
|
+
/** Local-space normal that points toward the blocking side */
|
|
64
|
+
oneWayNormal?: Vector2;
|
|
55
65
|
/**
|
|
56
66
|
* Creates a new RigidBody component.
|
|
57
67
|
* @param config - Configuration for the rigid body
|
|
58
68
|
*/
|
|
59
69
|
constructor(config: RigidBodyConfig);
|
|
60
70
|
get mass(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Sets the mass used by dynamic bodies.
|
|
73
|
+
*
|
|
74
|
+
* Non-positive values make the body immovable by forces and impulses.
|
|
75
|
+
*/
|
|
61
76
|
set mass(value: number);
|
|
77
|
+
/**
|
|
78
|
+
* Returns the inverse mass.
|
|
79
|
+
*
|
|
80
|
+
* Bodies with zero or negative mass return `0`.
|
|
81
|
+
*/
|
|
62
82
|
get inverseMass(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Adds a continuous force to a dynamic body for the next physics step.
|
|
85
|
+
*
|
|
86
|
+
* Affects only active dynamic bodies.
|
|
87
|
+
*/
|
|
63
88
|
applyForce(force: Vector2): void;
|
|
89
|
+
/**
|
|
90
|
+
* Adds an instantaneous impulse to a dynamic body for the next physics step.
|
|
91
|
+
*
|
|
92
|
+
* Affects only active dynamic bodies.
|
|
93
|
+
*/
|
|
64
94
|
applyImpulse(impulse: Vector2): void;
|
|
95
|
+
/**
|
|
96
|
+
* Marks the rigid body as awake so it can be simulated.
|
|
97
|
+
*/
|
|
65
98
|
wakeUp(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Marks the rigid body as sleeping so dynamic integration can skip it.
|
|
101
|
+
*/
|
|
66
102
|
sleep(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Clears all accumulated force and impulse values.
|
|
105
|
+
*/
|
|
67
106
|
clearForces(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Moves a kinematic body to a target position on the next physics step.
|
|
109
|
+
*
|
|
110
|
+
* The physics system computes a one-step velocity from the current position
|
|
111
|
+
* to this target so contacts can react to the kinematic movement.
|
|
112
|
+
*/
|
|
113
|
+
movePosition(position: Vector2): void;
|
|
68
114
|
}
|
|
@@ -29,9 +29,10 @@ import { Vector2 } from '../../../engine/math-lib';
|
|
|
29
29
|
export class RigidBody extends Component {
|
|
30
30
|
_mass;
|
|
31
31
|
_inverseMass;
|
|
32
|
-
/**
|
|
32
|
+
/** @internal Pending one-step kinematic movement target */
|
|
33
|
+
_movementTarget;
|
|
34
|
+
/** Body type that defines how the rigid body participates in simulation */
|
|
33
35
|
type;
|
|
34
|
-
/** Mass of the rigid body */
|
|
35
36
|
/** Gravity scale of the rigid body */
|
|
36
37
|
gravityScale;
|
|
37
38
|
/** Linear damping value used to slow down movement over time */
|
|
@@ -42,8 +43,14 @@ export class RigidBody extends Component {
|
|
|
42
43
|
disabled;
|
|
43
44
|
/** Whether rigid body is sleeping */
|
|
44
45
|
sleeping;
|
|
46
|
+
/** Force applied to the rigid body */
|
|
45
47
|
force;
|
|
48
|
+
/** Impulse applied to the rigid body */
|
|
46
49
|
impulse;
|
|
50
|
+
/** Whether contacts should only be resolved from one side */
|
|
51
|
+
oneWay;
|
|
52
|
+
/** Local-space normal that points toward the blocking side */
|
|
53
|
+
oneWayNormal;
|
|
47
54
|
/**
|
|
48
55
|
* Creates a new RigidBody component.
|
|
49
56
|
* @param config - Configuration for the rigid body
|
|
@@ -52,49 +59,98 @@ export class RigidBody extends Component {
|
|
|
52
59
|
super();
|
|
53
60
|
this._mass = 0;
|
|
54
61
|
this._inverseMass = 0;
|
|
62
|
+
this._movementTarget = null;
|
|
55
63
|
this.type = config.type;
|
|
56
|
-
this.mass = config.mass;
|
|
57
|
-
this.gravityScale = config.gravityScale;
|
|
58
|
-
this.linearDamping = config.linearDamping;
|
|
64
|
+
this.mass = config.mass ?? 0;
|
|
65
|
+
this.gravityScale = config.gravityScale ?? 0;
|
|
66
|
+
this.linearDamping = config.linearDamping ?? 0;
|
|
59
67
|
this.linearVelocity = new Vector2(0, 0);
|
|
60
68
|
this.disabled = config.disabled;
|
|
61
69
|
this.sleeping = false;
|
|
62
70
|
this.force = new Vector2(0, 0);
|
|
63
71
|
this.impulse = new Vector2(0, 0);
|
|
72
|
+
this.oneWay = config.oneWay ?? false;
|
|
73
|
+
if (this.oneWay) {
|
|
74
|
+
this.oneWayNormal = new Vector2(config.oneWayNormalX ?? 0, config.oneWayNormalY ?? 0).normalize();
|
|
75
|
+
if (this.oneWayNormal.magnitude === 0) {
|
|
76
|
+
throw new Error('One-way rigid body normal must be non-zero');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
64
79
|
}
|
|
65
80
|
get mass() {
|
|
66
81
|
return this._mass;
|
|
67
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Sets the mass used by dynamic bodies.
|
|
85
|
+
*
|
|
86
|
+
* Non-positive values make the body immovable by forces and impulses.
|
|
87
|
+
*/
|
|
68
88
|
set mass(value) {
|
|
69
89
|
this._mass = value;
|
|
70
90
|
this._inverseMass = value > 0 ? 1 / value : 0;
|
|
71
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns the inverse mass.
|
|
94
|
+
*
|
|
95
|
+
* Bodies with zero or negative mass return `0`.
|
|
96
|
+
*/
|
|
72
97
|
get inverseMass() {
|
|
73
98
|
return this._inverseMass;
|
|
74
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Adds a continuous force to a dynamic body for the next physics step.
|
|
102
|
+
*
|
|
103
|
+
* Affects only active dynamic bodies.
|
|
104
|
+
*/
|
|
75
105
|
applyForce(force) {
|
|
76
|
-
if (this.disabled || this.type
|
|
106
|
+
if (this.disabled || this.type !== 'dynamic') {
|
|
77
107
|
return;
|
|
78
108
|
}
|
|
79
109
|
this.wakeUp();
|
|
80
110
|
this.force.add(force);
|
|
81
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Adds an instantaneous impulse to a dynamic body for the next physics step.
|
|
114
|
+
*
|
|
115
|
+
* Affects only active dynamic bodies.
|
|
116
|
+
*/
|
|
82
117
|
applyImpulse(impulse) {
|
|
83
|
-
if (this.disabled || this.type
|
|
118
|
+
if (this.disabled || this.type !== 'dynamic') {
|
|
84
119
|
return;
|
|
85
120
|
}
|
|
86
121
|
this.wakeUp();
|
|
87
122
|
this.impulse.add(impulse);
|
|
88
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Marks the rigid body as awake so it can be simulated.
|
|
126
|
+
*/
|
|
89
127
|
wakeUp() {
|
|
90
128
|
this.sleeping = false;
|
|
91
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Marks the rigid body as sleeping so dynamic integration can skip it.
|
|
132
|
+
*/
|
|
92
133
|
sleep() {
|
|
93
134
|
this.sleeping = true;
|
|
94
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Clears all accumulated force and impulse values.
|
|
138
|
+
*/
|
|
95
139
|
clearForces() {
|
|
96
140
|
this.force.multiplyNumber(0);
|
|
97
141
|
this.impulse.multiplyNumber(0);
|
|
98
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Moves a kinematic body to a target position on the next physics step.
|
|
145
|
+
*
|
|
146
|
+
* The physics system computes a one-step velocity from the current position
|
|
147
|
+
* to this target so contacts can react to the kinematic movement.
|
|
148
|
+
*/
|
|
149
|
+
movePosition(position) {
|
|
150
|
+
if (this.disabled || this.type !== 'kinematic') {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
this._movementTarget = position.clone();
|
|
154
|
+
}
|
|
99
155
|
}
|
|
100
156
|
RigidBody.componentName = 'RigidBody';
|
|
@@ -56,6 +56,15 @@ export declare const CollisionStay = "CollisionStay";
|
|
|
56
56
|
* @category Events
|
|
57
57
|
*/
|
|
58
58
|
export declare const CollisionLeave = "CollisionLeave";
|
|
59
|
+
/**
|
|
60
|
+
* Dispatched when a character body hits a blocking actor
|
|
61
|
+
*
|
|
62
|
+
* @event
|
|
63
|
+
* @type {CharacterHitEvent}
|
|
64
|
+
*
|
|
65
|
+
* @category Events
|
|
66
|
+
*/
|
|
67
|
+
export declare const CharacterHit = "CharacterHit";
|
|
59
68
|
/**
|
|
60
69
|
* Dispatched to play audio on an actor
|
|
61
70
|
*
|
|
@@ -155,6 +164,25 @@ export type CollisionStayEvent = CollisionStateEvent;
|
|
|
155
164
|
* @category Events
|
|
156
165
|
*/
|
|
157
166
|
export type CollisionLeaveEvent = CollisionStateEvent;
|
|
167
|
+
/** Event signature for the {@link CharacterHit} event
|
|
168
|
+
*
|
|
169
|
+
* @category Events
|
|
170
|
+
*/
|
|
171
|
+
export type CharacterHitEvent = ActorEvent<{
|
|
172
|
+
/** Actor hit by the character body */
|
|
173
|
+
actor: Actor;
|
|
174
|
+
/** Hit point in world space */
|
|
175
|
+
point: {
|
|
176
|
+
x: number;
|
|
177
|
+
y: number;
|
|
178
|
+
};
|
|
179
|
+
/** Hit normal pointing from the hit actor to the character */
|
|
180
|
+
normal: Vector2;
|
|
181
|
+
/** Distance from the cast origin to the hit */
|
|
182
|
+
distance: number;
|
|
183
|
+
/** Surface classification used by the character controller */
|
|
184
|
+
kind: 'ground' | 'wall' | 'ceiling';
|
|
185
|
+
}>;
|
|
158
186
|
/** Event signature for the {@link SetAudioVolume} event when used on actor level
|
|
159
187
|
*
|
|
160
188
|
* @category Events
|
|
@@ -174,6 +202,7 @@ declare module '../../types/events' {
|
|
|
174
202
|
[CollisionEnter]: CollisionEnterEvent;
|
|
175
203
|
[CollisionStay]: CollisionStayEvent;
|
|
176
204
|
[CollisionLeave]: CollisionLeaveEvent;
|
|
205
|
+
[CharacterHit]: CharacterHitEvent;
|
|
177
206
|
[PlayAudio]: ActorEvent;
|
|
178
207
|
[StopAudio]: ActorEvent;
|
|
179
208
|
[SetAudioVolume]: SetAudioSourceVolumeEvent;
|
|
@@ -52,6 +52,15 @@ export const CollisionStay = 'CollisionStay';
|
|
|
52
52
|
* @category Events
|
|
53
53
|
*/
|
|
54
54
|
export const CollisionLeave = 'CollisionLeave';
|
|
55
|
+
/**
|
|
56
|
+
* Dispatched when a character body hits a blocking actor
|
|
57
|
+
*
|
|
58
|
+
* @event
|
|
59
|
+
* @type {CharacterHitEvent}
|
|
60
|
+
*
|
|
61
|
+
* @category Events
|
|
62
|
+
*/
|
|
63
|
+
export const CharacterHit = 'CharacterHit';
|
|
55
64
|
/**
|
|
56
65
|
* Dispatched to play audio on an actor
|
|
57
66
|
*
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SceneSystem } from '../../../engine/system';
|
|
2
|
+
import type { SceneSystemOptions, UpdateOptions } from '../../../engine/system';
|
|
3
|
+
/**
|
|
4
|
+
* Kinematic character controller system with sweep/slide collision movement.
|
|
5
|
+
*
|
|
6
|
+
* The system expects actors to have `CharacterBody`, `Transform`,
|
|
7
|
+
* `Collider`, and a kinematic `RigidBody`. Put this system before
|
|
8
|
+
* `PhysicsSystem` in system configuration so `movePosition()` targets are
|
|
9
|
+
* consumed by physics in the same fixed step.
|
|
10
|
+
*
|
|
11
|
+
* @category Systems
|
|
12
|
+
*/
|
|
13
|
+
export declare class CharacterController extends SceneSystem {
|
|
14
|
+
private actorQuery;
|
|
15
|
+
private world;
|
|
16
|
+
private oneWayValidator;
|
|
17
|
+
constructor(options: SceneSystemOptions);
|
|
18
|
+
onSceneDestroy(): void;
|
|
19
|
+
private isBlockingHit;
|
|
20
|
+
private isWalkable;
|
|
21
|
+
private isRecoverableOverlap;
|
|
22
|
+
private resetGroundState;
|
|
23
|
+
private resetState;
|
|
24
|
+
private castAll;
|
|
25
|
+
private cast;
|
|
26
|
+
private castGround;
|
|
27
|
+
private recoverOverlaps;
|
|
28
|
+
private handleHit;
|
|
29
|
+
private move;
|
|
30
|
+
private updateGroundState;
|
|
31
|
+
fixedUpdate(options: UpdateOptions): void;
|
|
32
|
+
}
|