@galacean/engine-design 2.0.0-alpha.18 → 2.0.0-alpha.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-design",
3
- "version": "2.0.0-alpha.18",
3
+ "version": "2.0.0-alpha.19",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "types": "types/index.d.ts",
19
19
  "dependencies": {
20
- "@galacean/engine-math": "2.0.0-alpha.18"
20
+ "@galacean/engine-math": "2.0.0-alpha.19"
21
21
  },
22
22
  "scripts": {
23
23
  "b:types": "tsc"
@@ -8,7 +8,6 @@ import { IPhysicsScene } from "./IPhysicsScene";
8
8
  import { IStaticCollider } from "./IStaticCollider";
9
9
  import { IFixedJoint, IHingeJoint, ISpringJoint } from "./joints";
10
10
  import { IBoxColliderShape, ICapsuleColliderShape, IMeshColliderShape, IPlaneColliderShape, ISphereColliderShape } from "./shape";
11
- import { ICollision } from "./ICollision";
12
11
  /**
13
12
  * The interface of physics creation.
14
13
  */
@@ -25,14 +24,8 @@ export interface IPhysics {
25
24
  /**
26
25
  * Create physics scene.
27
26
  * @param physicsManager - The physics manager
28
- * @param onContactEnter - Function called when contact begin
29
- * @param onContactExit - Function called when contact end
30
- * @param onContactStay - Function called when contact stay
31
- * @param onTriggerEnter - Function called when trigger begin
32
- * @param onTriggerExit - Function called when trigger end
33
- * @param onTriggerStay - Function called when trigger stay
34
- */
35
- createPhysicsScene(physicsManager: IPhysicsManager, onContactEnter?: (collision: ICollision) => void, onContactExit?: (collision: ICollision) => void, onContactStay?: (collision: ICollision) => void, onTriggerEnter?: (obj1: number, obj2: number) => void, onTriggerExit?: (obj1: number, obj2: number) => void, onTriggerStay?: (obj1: number, obj2: number) => void): IPhysicsScene;
27
+ */
28
+ createPhysicsScene(physicsManager: IPhysicsManager): IPhysicsScene;
36
29
  /**
37
30
  * Create dynamic collider.
38
31
  * @param position - The global position
@@ -0,0 +1,25 @@
1
+ import { ICollision } from "./ICollision";
2
+ /**
3
+ * A buffered contact event from the physics backend.
4
+ */
5
+ export interface IContactEvent extends ICollision {
6
+ /** 0 = Enter, 1 = Stay, 2 = Exit */
7
+ state: number;
8
+ }
9
+ /**
10
+ * A buffered trigger event from the physics backend.
11
+ */
12
+ export interface ITriggerEvent {
13
+ index1: number;
14
+ index2: number;
15
+ /** The state snapshot for dispatch. 0 = Enter, 1 = Stay, 2 = Exit */
16
+ dispatchState: number;
17
+ }
18
+ /**
19
+ * Physics events returned by IPhysicsScene.updateEvents().
20
+ */
21
+ export interface IPhysicsEvents {
22
+ contactEvents: ReadonlyArray<IContactEvent>;
23
+ contactEventCount: number;
24
+ triggerEvents: ReadonlyArray<ITriggerEvent>;
25
+ }
@@ -1,6 +1,7 @@
1
1
  import { Quaternion, Ray, Vector3 } from "@galacean/engine-math";
2
2
  import { ICharacterController } from "./ICharacterController";
3
3
  import { ICollider } from "./ICollider";
4
+ import { IPhysicsEvents } from "./IPhysicsEvents";
4
5
  /**
5
6
  * Interface for physics manager.
6
7
  */
@@ -35,6 +36,11 @@ export interface IPhysicsScene {
35
36
  * @param elapsedTime - Step time of update.
36
37
  */
37
38
  update(elapsedTime: number): void;
39
+ /**
40
+ * Collect buffered collision and trigger events.
41
+ * Must be called after update() and after syncing transforms back from physics.
42
+ */
43
+ updateEvents(): IPhysicsEvents;
38
44
  /**
39
45
  * Casts a ray through the Scene and returns the first hit.
40
46
  * @param ray - The ray
@@ -71,6 +77,10 @@ export interface IPhysicsScene {
71
77
  * Returns an array of shape unique IDs.
72
78
  */
73
79
  overlapCapsuleAll(center: Vector3, radius: number, height: number, orientation: Quaternion, onOverlap: (obj: number) => boolean): number[];
80
+ /**
81
+ * Trim internal object pools after a GC cycle.
82
+ */
83
+ gc(): void;
74
84
  /**
75
85
  * Destroy the physics scene.
76
86
  */
@@ -7,5 +7,6 @@ export type { IPhysicsScene } from "./IPhysicsScene";
7
7
  export type { IPhysicsManager } from "./IPhysicsManager";
8
8
  export type { IStaticCollider } from "./IStaticCollider";
9
9
  export type { ICollision } from "./ICollision";
10
+ export type { IContactEvent, ITriggerEvent, IPhysicsEvents } from "./IPhysicsEvents";
10
11
  export * from "./joints/index";
11
12
  export * from "./shape/index";