@galacean/engine-design 2.0.0-alpha.2 → 2.0.0-alpha.20
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.
|
|
3
|
+
"version": "2.0.0-alpha.20",
|
|
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.
|
|
20
|
+
"@galacean/engine-math": "2.0.0-alpha.20"
|
|
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
27
|
*/
|
|
35
|
-
createPhysicsScene(physicsManager: IPhysicsManager
|
|
28
|
+
createPhysicsScene(physicsManager: IPhysicsManager): IPhysicsScene;
|
|
36
29
|
/**
|
|
37
30
|
* Create dynamic collider.
|
|
38
31
|
* @param position - The global position
|
|
@@ -89,13 +82,13 @@ export interface IPhysics {
|
|
|
89
82
|
/**
|
|
90
83
|
* Create mesh collider shape.
|
|
91
84
|
* @param uniqueID - Shape unique id
|
|
92
|
-
* @param
|
|
93
|
-
* @param vertexCount - Number of vertices
|
|
85
|
+
* @param positions - Vertex positions
|
|
94
86
|
* @param indices - Index array (null for convex mesh)
|
|
95
87
|
* @param isConvex - Whether to create convex mesh (true) or triangle mesh (false)
|
|
96
88
|
* @param material - The material of this shape
|
|
89
|
+
* @param cookingFlags - Cooking flags
|
|
97
90
|
*/
|
|
98
|
-
createMeshColliderShape(uniqueID: number,
|
|
91
|
+
createMeshColliderShape(uniqueID: number, positions: Vector3[], indices: Uint8Array | Uint16Array | Uint32Array | null, isConvex: boolean, material: IPhysicsMaterial, cookingFlags: number): IMeshColliderShape | null;
|
|
99
92
|
/**
|
|
100
93
|
* Create fixed joint.
|
|
101
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
|
*/
|
package/types/physics/index.d.ts
CHANGED
|
@@ -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";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Vector3 } from "@galacean/engine-math";
|
|
1
2
|
import { IColliderShape } from "./IColliderShape";
|
|
2
3
|
/**
|
|
3
4
|
* Interface for mesh collider shape.
|
|
@@ -5,22 +6,11 @@ import { IColliderShape } from "./IColliderShape";
|
|
|
5
6
|
export interface IMeshColliderShape extends IColliderShape {
|
|
6
7
|
/**
|
|
7
8
|
* Set mesh data for this collider shape.
|
|
8
|
-
* @param
|
|
9
|
-
* @param vertexCount - Number of vertices
|
|
9
|
+
* @param positions - Vertex positions
|
|
10
10
|
* @param indices - The index array (Uint16Array or Uint32Array), required for triangle mesh
|
|
11
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
|
|
12
14
|
*/
|
|
13
|
-
setMeshData(
|
|
14
|
-
/**
|
|
15
|
-
* Set whether the triangle mesh should be double-sided for collision detection.
|
|
16
|
-
* Only applies to triangle mesh (non-convex). Default: false
|
|
17
|
-
* @param value - Whether to enable double-sided collision
|
|
18
|
-
*/
|
|
19
|
-
setDoubleSided(value: boolean): void;
|
|
20
|
-
/**
|
|
21
|
-
* Set whether to use tight bounds for convex mesh.
|
|
22
|
-
* Only applies to convex mesh. Default: true
|
|
23
|
-
* @param value - Whether to enable tight bounds
|
|
24
|
-
*/
|
|
25
|
-
setTightBounds(value: boolean): void;
|
|
15
|
+
setMeshData(positions: Vector3[], indices: Uint8Array | Uint16Array | Uint32Array | null, isConvex: boolean, cookingFlags: number): boolean;
|
|
26
16
|
}
|