dacha 0.15.1 → 0.15.2
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/collider/index.d.ts +19 -0
- package/build/contrib/components/collider/index.js +29 -0
- package/build/contrib/components/index.d.ts +2 -2
- package/build/contrib/components/index.js +1 -1
- package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/index.js +2 -2
- 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 +3 -3
- 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 +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/index.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/index.js +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/index.js +19 -19
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/check-box-and-circle-intersection.js +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/index.js +6 -6
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-collider.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-collider.js +3 -5
- package/build/contrib/systems/physics-system/subsystems/collision-solver/index.d.ts +1 -1
- package/build/contrib/systems/physics-system/subsystems/collision-solver/index.js +4 -4
- package/build/contrib/systems/physics-system/subsystems/physics/index.d.ts +1 -1
- package/build/contrib/systems/physics-system/subsystems/physics/index.js +5 -5
- package/build/contrib/systems/physics-system/types.d.ts +1 -1
- package/build/engine/system/index.d.ts +1 -1
- package/build/index.d.ts +1 -1
- package/package.json +1 -1
- package/build/contrib/components/collider-container/box-collider.d.ts +0 -7
- package/build/contrib/components/collider-container/box-collider.js +0 -12
- package/build/contrib/components/collider-container/circle-collider.d.ts +0 -6
- package/build/contrib/components/collider-container/circle-collider.js +0 -10
- package/build/contrib/components/collider-container/index.d.ts +0 -13
- package/build/contrib/components/collider-container/index.js +0 -28
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component } from '../../../engine/component';
|
|
2
|
+
export interface ColliderConfig {
|
|
3
|
+
type: 'box' | 'circle';
|
|
4
|
+
centerX: number;
|
|
5
|
+
centerY: number;
|
|
6
|
+
sizeX?: number;
|
|
7
|
+
sizeY?: number;
|
|
8
|
+
radius?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class Collider extends Component {
|
|
11
|
+
type: 'box' | 'circle';
|
|
12
|
+
centerX: number;
|
|
13
|
+
centerY: number;
|
|
14
|
+
sizeX?: number;
|
|
15
|
+
sizeY?: number;
|
|
16
|
+
radius?: number;
|
|
17
|
+
constructor(config: ColliderConfig);
|
|
18
|
+
clone(): Collider;
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component } from '../../../engine/component';
|
|
2
|
+
export class Collider extends Component {
|
|
3
|
+
type;
|
|
4
|
+
centerX;
|
|
5
|
+
centerY;
|
|
6
|
+
sizeX;
|
|
7
|
+
sizeY;
|
|
8
|
+
radius;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super();
|
|
11
|
+
this.type = config.type;
|
|
12
|
+
this.centerX = config.centerX;
|
|
13
|
+
this.centerY = config.centerY;
|
|
14
|
+
this.sizeX = config.sizeX;
|
|
15
|
+
this.sizeY = config.sizeY;
|
|
16
|
+
this.radius = config.radius;
|
|
17
|
+
}
|
|
18
|
+
clone() {
|
|
19
|
+
return new Collider({
|
|
20
|
+
type: this.type,
|
|
21
|
+
centerX: this.centerX,
|
|
22
|
+
centerY: this.centerY,
|
|
23
|
+
sizeX: this.sizeX,
|
|
24
|
+
sizeY: this.sizeY,
|
|
25
|
+
radius: this.radius,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
Collider.componentName = 'Collider';
|
|
@@ -2,8 +2,8 @@ export { Camera } from './camera';
|
|
|
2
2
|
export type { CameraConfig } from './camera';
|
|
3
3
|
export { KeyboardControl } from './keyboard-control';
|
|
4
4
|
export type { KeyboardControlConfig } from './keyboard-control';
|
|
5
|
-
export {
|
|
6
|
-
export type {
|
|
5
|
+
export { Collider } from './collider';
|
|
6
|
+
export type { ColliderConfig } from './collider';
|
|
7
7
|
export { RigidBody } from './rigid-body';
|
|
8
8
|
export type { RigidBodyConfig } from './rigid-body';
|
|
9
9
|
export { Animatable } from './animatable';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Camera } from './camera';
|
|
2
2
|
export { KeyboardControl } from './keyboard-control';
|
|
3
|
-
export {
|
|
3
|
+
export { Collider } from './collider';
|
|
4
4
|
export { RigidBody } from './rigid-body';
|
|
5
5
|
export { Animatable } from './animatable';
|
|
6
6
|
export { Sprite } from './sprite';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Collider, Transform } from '../../../../../components';
|
|
2
2
|
import type { BoxGeometry } from '../types';
|
|
3
|
-
export declare const buildBoxGeometry: (
|
|
3
|
+
export declare const buildBoxGeometry: (collider: Collider, transform: Transform) => BoxGeometry;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { VectorOps } from '../../../../../../engine/math-lib';
|
|
2
|
-
export const buildBoxGeometry = (
|
|
2
|
+
export const buildBoxGeometry = (collider, transform) => {
|
|
3
3
|
const { offsetX, offsetY, scaleX, scaleY, rotation, } = transform;
|
|
4
|
-
let { centerX, centerY } =
|
|
5
|
-
const { sizeX, sizeY } =
|
|
4
|
+
let { centerX, centerY } = collider;
|
|
5
|
+
const { sizeX, sizeY } = collider;
|
|
6
6
|
const x1 = -(sizeX / 2);
|
|
7
7
|
const x2 = (sizeX / 2);
|
|
8
8
|
const y1 = -(sizeY / 2);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Collider, Transform } from '../../../../../components';
|
|
2
2
|
import type { CircleGeometry } from '../types';
|
|
3
|
-
export declare const buildCircleGeometry: (
|
|
3
|
+
export declare const buildCircleGeometry: (collider: Collider, transform: Transform) => CircleGeometry;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const buildCircleGeometry = (
|
|
1
|
+
export const buildCircleGeometry = (collider, transform) => {
|
|
2
2
|
const { offsetX, offsetY, scaleX, scaleY, } = transform;
|
|
3
|
-
const { centerX, centerY, radius } =
|
|
3
|
+
const { centerX, centerY, radius } = collider;
|
|
4
4
|
const center = {
|
|
5
5
|
x: centerX + offsetX,
|
|
6
6
|
y: centerY + offsetY,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Collider, Transform } from '../../../../../components';
|
|
2
2
|
import type { Geometry } from '../types';
|
|
3
|
-
export type BuildGeometryFn = (
|
|
3
|
+
export type BuildGeometryFn = (collider: Collider, transform: Transform) => Geometry;
|
|
4
4
|
export declare const geometryBuilders: Record<string, BuildGeometryFn>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildBoxGeometry } from './build-box-geometry';
|
|
2
2
|
import { buildCircleGeometry } from './build-circle-geometry';
|
|
3
3
|
export const geometryBuilders = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
box: buildBoxGeometry,
|
|
5
|
+
circle: buildCircleGeometry,
|
|
6
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActorCollection } from '../../../../../engine/actor';
|
|
2
|
-
import { Transform,
|
|
2
|
+
import { Transform, Collider, RigidBody, } from '../../../../components';
|
|
3
3
|
import { AddActor, RemoveActor } from '../../../../../engine/events';
|
|
4
4
|
import { Collision } from '../../../../events';
|
|
5
5
|
import { insertionSort } from '../../../../../engine/data-lib';
|
|
@@ -18,7 +18,7 @@ export class CollisionDetectionSubsystem {
|
|
|
18
18
|
constructor(options) {
|
|
19
19
|
this.actorCollection = new ActorCollection(options.scene, {
|
|
20
20
|
components: [
|
|
21
|
-
|
|
21
|
+
Collider,
|
|
22
22
|
Transform,
|
|
23
23
|
],
|
|
24
24
|
});
|
|
@@ -56,14 +56,14 @@ export class CollisionDetectionSubsystem {
|
|
|
56
56
|
return true;
|
|
57
57
|
}
|
|
58
58
|
const transform = actor.getComponent(Transform);
|
|
59
|
-
const
|
|
59
|
+
const collider = actor.getComponent(Collider);
|
|
60
60
|
const transformOld = entry.orientationData.transform;
|
|
61
61
|
const colliderOld = entry.orientationData.collider;
|
|
62
|
-
return checkTransform(transform, transformOld) || checkCollider(
|
|
62
|
+
return checkTransform(transform, transformOld) || checkCollider(collider, colliderOld);
|
|
63
63
|
}
|
|
64
64
|
getOrientationData(actor) {
|
|
65
65
|
const transform = actor.getComponent(Transform);
|
|
66
|
-
const
|
|
66
|
+
const collider = actor.getComponent(Collider);
|
|
67
67
|
return {
|
|
68
68
|
transform: {
|
|
69
69
|
offsetX: transform.offsetX,
|
|
@@ -73,20 +73,20 @@ export class CollisionDetectionSubsystem {
|
|
|
73
73
|
scaleY: transform.scaleY,
|
|
74
74
|
},
|
|
75
75
|
collider: {
|
|
76
|
-
type:
|
|
77
|
-
centerX:
|
|
78
|
-
centerY:
|
|
79
|
-
sizeX:
|
|
80
|
-
sizeY:
|
|
81
|
-
radius:
|
|
76
|
+
type: collider.type,
|
|
77
|
+
centerX: collider.centerX,
|
|
78
|
+
centerY: collider.centerY,
|
|
79
|
+
sizeX: collider.sizeX,
|
|
80
|
+
sizeY: collider.sizeY,
|
|
81
|
+
radius: collider.radius,
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
addCollisionEntry(actor) {
|
|
86
86
|
const transform = actor.getComponent(Transform);
|
|
87
|
-
const
|
|
88
|
-
const geometry = geometryBuilders[
|
|
89
|
-
const aabb = aabbBuilders[
|
|
87
|
+
const collider = actor.getComponent(Collider);
|
|
88
|
+
const geometry = geometryBuilders[collider.type](collider, transform);
|
|
89
|
+
const aabb = aabbBuilders[collider.type](geometry);
|
|
90
90
|
const entry = {
|
|
91
91
|
actor,
|
|
92
92
|
aabb,
|
|
@@ -101,9 +101,9 @@ export class CollisionDetectionSubsystem {
|
|
|
101
101
|
}
|
|
102
102
|
updateCollisionEntry(actor) {
|
|
103
103
|
const transform = actor.getComponent(Transform);
|
|
104
|
-
const
|
|
105
|
-
const geometry = geometryBuilders[
|
|
106
|
-
const aabb = aabbBuilders[
|
|
104
|
+
const collider = actor.getComponent(Collider);
|
|
105
|
+
const geometry = geometryBuilders[collider.type](collider, transform);
|
|
106
|
+
const aabb = aabbBuilders[collider.type](geometry);
|
|
107
107
|
const entry = this.entriesMap.get(actor.id);
|
|
108
108
|
const prevAABB = entry.aabb;
|
|
109
109
|
entry.aabb = aabb;
|
|
@@ -181,8 +181,8 @@ export class CollisionDetectionSubsystem {
|
|
|
181
181
|
}
|
|
182
182
|
checkOnIntersection(pair) {
|
|
183
183
|
const [arg1, arg2] = pair;
|
|
184
|
-
const type1 = arg1.actor.getComponent(
|
|
185
|
-
const type2 = arg2.actor.getComponent(
|
|
184
|
+
const type1 = arg1.actor.getComponent(Collider).type;
|
|
185
|
+
const type2 = arg2.actor.getComponent(Collider).type;
|
|
186
186
|
return intersectionCheckers[type1][type2](arg1, arg2);
|
|
187
187
|
}
|
|
188
188
|
sendCollisionEvent(actor1, actor2, intersection) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Collider } from '../../../../../components';
|
|
2
2
|
import { MathOps, Vector2, VectorOps } from '../../../../../../engine/math-lib';
|
|
3
3
|
const getMtvs = (axis, overlap, point1, point2) => {
|
|
4
4
|
axis.multiplyNumber((1 / axis.magnitude) * overlap);
|
|
@@ -28,7 +28,7 @@ const getMtvs = (axis, overlap, point1, point2) => {
|
|
|
28
28
|
export const checkBoxAndCircleIntersection = (arg1, arg2) => {
|
|
29
29
|
let box;
|
|
30
30
|
let circle;
|
|
31
|
-
if (arg1.actor.getComponent(
|
|
31
|
+
if (arg1.actor.getComponent(Collider).type === 'box') {
|
|
32
32
|
box = arg1.geometry;
|
|
33
33
|
circle = arg2.geometry;
|
|
34
34
|
}
|
|
@@ -2,12 +2,12 @@ import { checkBoxAndCircleIntersection } from './check-box-and-circle-intersecti
|
|
|
2
2
|
import { checkBoxesIntersection } from './check-boxes-intersection';
|
|
3
3
|
import { checkCirclesIntersection } from './check-circles-intersection';
|
|
4
4
|
export const intersectionCheckers = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
box: {
|
|
6
|
+
box: checkBoxesIntersection,
|
|
7
|
+
circle: checkBoxAndCircleIntersection,
|
|
8
8
|
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
circle: {
|
|
10
|
+
circle: checkCirclesIntersection,
|
|
11
|
+
box: checkBoxAndCircleIntersection,
|
|
12
12
|
},
|
|
13
13
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Collider } from '../../../../../components';
|
|
2
2
|
import type { OrientationData } from '../types';
|
|
3
|
-
export declare const checkCollider: (
|
|
3
|
+
export declare const checkCollider: (collider: Collider, colliderOld: OrientationData['collider']) => boolean;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
export const checkCollider = (
|
|
2
|
-
if (
|
|
1
|
+
export const checkCollider = (collider, colliderOld) => {
|
|
2
|
+
if (collider.type !== colliderOld.type) {
|
|
3
3
|
return true;
|
|
4
4
|
}
|
|
5
|
-
if (
|
|
6
|
-
const collider = colliderContainer.collider;
|
|
5
|
+
if (collider.type === 'box') {
|
|
7
6
|
return collider.centerX !== colliderOld.centerX
|
|
8
7
|
|| collider.centerY !== colliderOld.centerY
|
|
9
8
|
|| collider.sizeX !== colliderOld.sizeX
|
|
10
9
|
|| collider.sizeY !== colliderOld.sizeY;
|
|
11
10
|
}
|
|
12
|
-
const collider = colliderContainer.collider;
|
|
13
11
|
return collider.centerX !== colliderOld.centerX
|
|
14
12
|
|| collider.centerY !== colliderOld.centerY
|
|
15
13
|
|| collider.radius !== colliderOld.radius;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SceneSystemOptions } from '../../../../../engine/system';
|
|
2
2
|
export declare class CollisionSolver {
|
|
3
3
|
private scene;
|
|
4
|
-
private
|
|
4
|
+
private gravity;
|
|
5
5
|
constructor(options: SceneSystemOptions);
|
|
6
6
|
destroy(): void;
|
|
7
7
|
private handleCollision;
|
|
@@ -6,11 +6,11 @@ const REACTION_FORCE_VECTOR_X = 0;
|
|
|
6
6
|
const REACTION_FORCE_VECTOR_Y = -1;
|
|
7
7
|
export class CollisionSolver {
|
|
8
8
|
scene;
|
|
9
|
-
|
|
9
|
+
gravity;
|
|
10
10
|
constructor(options) {
|
|
11
|
-
const { scene,
|
|
11
|
+
const { scene, gravity } = options;
|
|
12
12
|
this.scene = scene;
|
|
13
|
-
this.
|
|
13
|
+
this.gravity = gravity;
|
|
14
14
|
this.scene.addEventListener(Collision, this.handleCollision);
|
|
15
15
|
}
|
|
16
16
|
destroy() {
|
|
@@ -40,7 +40,7 @@ export class CollisionSolver {
|
|
|
40
40
|
const { useGravity, mass } = rigidBody;
|
|
41
41
|
if (useGravity && mtv.y && Math.sign(mtv.y) === -1 && !mtv.x) {
|
|
42
42
|
const reactionForce = new Vector2(REACTION_FORCE_VECTOR_X, REACTION_FORCE_VECTOR_Y);
|
|
43
|
-
reactionForce.multiplyNumber(mass * this.
|
|
43
|
+
reactionForce.multiplyNumber(mass * this.gravity);
|
|
44
44
|
actor.dispatchEventImmediately(AddForce, {
|
|
45
45
|
value: reactionForce,
|
|
46
46
|
});
|
|
@@ -2,7 +2,7 @@ import type { SceneSystemOptions, UpdateOptions } from '../../../../../engine/sy
|
|
|
2
2
|
export declare class PhysicsSubsystem {
|
|
3
3
|
private scene;
|
|
4
4
|
private actorCollection;
|
|
5
|
-
private
|
|
5
|
+
private gravity;
|
|
6
6
|
private actorVectors;
|
|
7
7
|
constructor(options: SceneSystemOptions);
|
|
8
8
|
destroy(): void;
|
|
@@ -13,10 +13,10 @@ const DIRECTION_VECTOR = {
|
|
|
13
13
|
export class PhysicsSubsystem {
|
|
14
14
|
scene;
|
|
15
15
|
actorCollection;
|
|
16
|
-
|
|
16
|
+
gravity;
|
|
17
17
|
actorVectors;
|
|
18
18
|
constructor(options) {
|
|
19
|
-
const {
|
|
19
|
+
const { gravity, scene, } = options;
|
|
20
20
|
this.scene = scene;
|
|
21
21
|
this.actorCollection = new ActorCollection(scene, {
|
|
22
22
|
components: [
|
|
@@ -24,7 +24,7 @@ export class PhysicsSubsystem {
|
|
|
24
24
|
Transform,
|
|
25
25
|
],
|
|
26
26
|
});
|
|
27
|
-
this.
|
|
27
|
+
this.gravity = gravity;
|
|
28
28
|
this.actorVectors = {};
|
|
29
29
|
this.actorCollection.addEventListener(RemoveActor, this.handleActorRemove);
|
|
30
30
|
this.scene.addEventListener(StopMovement, this.handleStopMovement);
|
|
@@ -77,7 +77,7 @@ export class PhysicsSubsystem {
|
|
|
77
77
|
}
|
|
78
78
|
const velocitySignX = Math.sign(velocity.x);
|
|
79
79
|
const velocitySignY = Math.sign(velocity.y);
|
|
80
|
-
const reactionForceValue = mass * this.
|
|
80
|
+
const reactionForceValue = mass * this.gravity;
|
|
81
81
|
const dragForceValue = -1 * drag * reactionForceValue;
|
|
82
82
|
const forceToVelocityMultiplier = deltaTime / mass;
|
|
83
83
|
const slowdownValue = dragForceValue * forceToVelocityMultiplier;
|
|
@@ -94,7 +94,7 @@ export class PhysicsSubsystem {
|
|
|
94
94
|
const gravityVector = new Vector2(0, 0);
|
|
95
95
|
if (useGravity) {
|
|
96
96
|
gravityVector.add(DIRECTION_VECTOR.DOWN);
|
|
97
|
-
gravityVector.multiplyNumber(mass * this.
|
|
97
|
+
gravityVector.multiplyNumber(mass * this.gravity);
|
|
98
98
|
}
|
|
99
99
|
return gravityVector;
|
|
100
100
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { SceneSystem, WorldSystem } from './system';
|
|
2
|
-
export type { SystemConstructor, SceneSystemOptions, WorldSystemOptions, UpdateOptions, } from './system';
|
|
2
|
+
export type { System, SystemConstructor, SceneSystemOptions, WorldSystemOptions, UpdateOptions, } from './system';
|
package/build/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { VectorOps, MathOps, Vector2 } from './engine/math-lib';
|
|
|
4
4
|
export * from './engine/consts';
|
|
5
5
|
export * from './engine/types';
|
|
6
6
|
export { WorldSystem, SceneSystem } from './engine/system';
|
|
7
|
-
export type { WorldSystemOptions, SceneSystemOptions, UpdateOptions, } from './engine/system';
|
|
7
|
+
export type { System, WorldSystemOptions, SceneSystemOptions, UpdateOptions, } from './engine/system';
|
|
8
8
|
export type { ActorCollectionFilter, ActorSpawner, } from './engine/actor';
|
|
9
9
|
export type { EventTarget, Event, EventType, EventPayload, ListenerFn, } from './engine/event-target';
|
|
10
10
|
export type { Scene } from './engine/scene';
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Component } from '../../../engine/component';
|
|
2
|
-
import { BoxCollider } from './box-collider';
|
|
3
|
-
import { CircleCollider } from './circle-collider';
|
|
4
|
-
export interface ColliderContainerConfig {
|
|
5
|
-
type: 'boxCollider' | 'circleCollider';
|
|
6
|
-
collider: Record<string, number>;
|
|
7
|
-
}
|
|
8
|
-
export declare class ColliderContainer extends Component {
|
|
9
|
-
type: 'boxCollider' | 'circleCollider';
|
|
10
|
-
collider: BoxCollider | CircleCollider;
|
|
11
|
-
constructor(config: ColliderContainerConfig);
|
|
12
|
-
clone(): ColliderContainer;
|
|
13
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Component } from '../../../engine/component';
|
|
2
|
-
import { BoxCollider } from './box-collider';
|
|
3
|
-
import { CircleCollider } from './circle-collider';
|
|
4
|
-
const COLLIDER_MAP = {
|
|
5
|
-
boxCollider: BoxCollider,
|
|
6
|
-
circleCollider: CircleCollider,
|
|
7
|
-
};
|
|
8
|
-
export class ColliderContainer extends Component {
|
|
9
|
-
type;
|
|
10
|
-
collider;
|
|
11
|
-
constructor(config) {
|
|
12
|
-
super();
|
|
13
|
-
const colliderContainerConfig = config;
|
|
14
|
-
this.type = colliderContainerConfig.type;
|
|
15
|
-
if (!COLLIDER_MAP[this.type]) {
|
|
16
|
-
throw new Error(`Not found collider with same type: ${this.type}`);
|
|
17
|
-
}
|
|
18
|
-
const Collider = COLLIDER_MAP[this.type];
|
|
19
|
-
this.collider = new Collider(colliderContainerConfig.collider);
|
|
20
|
-
}
|
|
21
|
-
clone() {
|
|
22
|
-
return new ColliderContainer({
|
|
23
|
-
type: this.type,
|
|
24
|
-
collider: this.collider,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
ColliderContainer.componentName = 'ColliderContainer';
|