@galacean/engine-design 0.0.0-experimental-backup.5 → 0.0.0-experimental-2.0-game

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": "0.0.0-experimental-backup.5",
3
+ "version": "0.0.0-experimental-2.0-game",
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": "0.0.0-experimental-backup.5"
20
+ "@galacean/engine-math": "0.0.0-experimental-2.0-game"
21
21
  },
22
22
  "scripts": {
23
23
  "b:types": "tsc"
@@ -7,8 +7,7 @@ import { IPhysicsMaterial } from "./IPhysicsMaterial";
7
7
  import { IPhysicsScene } from "./IPhysicsScene";
8
8
  import { IStaticCollider } from "./IStaticCollider";
9
9
  import { IFixedJoint, IHingeJoint, ISpringJoint } from "./joints";
10
- import { IBoxColliderShape, ICapsuleColliderShape, IPlaneColliderShape, ISphereColliderShape } from "./shape";
11
- import { ICollision } from "./ICollision";
10
+ import { IBoxColliderShape, ICapsuleColliderShape, IMeshColliderShape, IPlaneColliderShape, ISphereColliderShape } from "./shape";
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
27
  */
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;
28
+ createPhysicsScene(physicsManager: IPhysicsManager): IPhysicsScene;
36
29
  /**
37
30
  * Create dynamic collider.
38
31
  * @param position - The global position
@@ -86,6 +79,16 @@ export interface IPhysics {
86
79
  * @param material - The material of this shape
87
80
  */
88
81
  createCapsuleColliderShape(uniqueID: number, radius: number, height: number, material: IPhysicsMaterial): ICapsuleColliderShape;
82
+ /**
83
+ * Create mesh collider shape.
84
+ * @param uniqueID - Shape unique id
85
+ * @param positions - Vertex positions
86
+ * @param indices - Index array (null for convex mesh)
87
+ * @param isConvex - Whether to create convex mesh (true) or triangle mesh (false)
88
+ * @param material - The material of this shape
89
+ * @param cookingFlags - Cooking flags
90
+ */
91
+ createMeshColliderShape(uniqueID: number, positions: Vector3[], indices: Uint8Array | Uint16Array | Uint32Array | null, isConvex: boolean, material: IPhysicsMaterial, cookingFlags: number): IMeshColliderShape | null;
89
92
  /**
90
93
  * Create fixed joint.
91
94
  * @param collider - collider of joint
@@ -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";
@@ -0,0 +1,16 @@
1
+ import { Vector3 } from "@galacean/engine-math";
2
+ import { IColliderShape } from "./IColliderShape";
3
+ /**
4
+ * Interface for mesh collider shape.
5
+ */
6
+ export interface IMeshColliderShape extends IColliderShape {
7
+ /**
8
+ * Set mesh data for this collider shape.
9
+ * @param positions - Vertex positions
10
+ * @param indices - The index array (Uint16Array or Uint32Array), required for triangle mesh
11
+ * @param isConvex - Whether to use convex mesh (true) or triangle mesh (false)
12
+ * @param cookingFlags - Cooking flags
13
+ * @returns Whether the mesh data was successfully set
14
+ */
15
+ setMeshData(positions: Vector3[], indices: Uint8Array | Uint16Array | Uint32Array | null, isConvex: boolean, cookingFlags: number): boolean;
16
+ }
@@ -3,3 +3,4 @@ export type { IBoxColliderShape } from "./IBoxColliderShape";
3
3
  export type { ICapsuleColliderShape } from "./ICapsuleColliderShape";
4
4
  export type { ISphereColliderShape } from "./ISphereColliderShape";
5
5
  export type { IPlaneColliderShape } from "./IPlaneColliderShape";
6
+ export type { IMeshColliderShape } from "./IMeshColliderShape";