@galacean/engine-design 1.4.0-alpha.0 → 1.4.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-design",
3
- "version": "1.4.0-alpha.0",
3
+ "version": "1.4.0-alpha.2",
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": "1.4.0-alpha.0"
20
+ "@galacean/engine-math": "1.4.0-alpha.2"
21
21
  },
22
22
  "scripts": {
23
23
  "b:types": "tsc"
@@ -37,7 +37,7 @@ export interface ICharacterController extends ICollider {
37
37
  */
38
38
  setUpDirection(up: Vector3): void;
39
39
  /**
40
- * Sets the slope limit.
40
+ * Sets the slope limit in degrees.
41
41
  * @param slopeLimit The slope limit for the controller.
42
42
  */
43
43
  setSlopeLimit(slopeLimit: number): void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Interface of collision.
3
+ */
4
+ export interface ICollision {
5
+ /** The unique id of the first collider. */
6
+ shape0Id: number;
7
+ /** The unique id of the second collider. */
8
+ shape1Id: number;
9
+ /** Count of contact points. */
10
+ contactCount: number;
11
+ /** Get contact points. */
12
+ getContacts(): VectorContactPairPoint;
13
+ }
14
+ interface VectorContactPairPoint {
15
+ size(): number;
16
+ get(index: number): IContactPoint;
17
+ }
18
+ interface IContactPoint {
19
+ position: {
20
+ x: number;
21
+ y: number;
22
+ z: number;
23
+ };
24
+ normal: {
25
+ x: number;
26
+ y: number;
27
+ z: number;
28
+ };
29
+ impulse: {
30
+ x: number;
31
+ y: number;
32
+ z: number;
33
+ };
34
+ separation: number;
35
+ }
36
+ export {};
@@ -16,44 +16,79 @@ export interface IDynamicCollider extends ICollider {
16
16
  * @param outRotation - The global rotation
17
17
  */
18
18
  getWorldTransform(outPosition: Vector3, outRotation: Quaternion): void;
19
+ /**
20
+ * Get the linear damping coefficient.
21
+ */
22
+ getLinearDamping(): number;
19
23
  /**
20
24
  * Sets the linear damping coefficient.
21
- * @param value - Linear damping coefficient.
25
+ * @param value - Linear damping coefficient
22
26
  */
23
27
  setLinearDamping(value: number): void;
28
+ /**
29
+ * Get the angular damping coefficient.
30
+ */
31
+ getAngularDamping(): number;
24
32
  /**
25
33
  * Sets the angular damping coefficient.
26
- * @param value - Angular damping coefficient.
34
+ * @param value - Angular damping coefficient
27
35
  */
28
36
  setAngularDamping(value: number): void;
37
+ /**
38
+ * Get the linear velocity of the actor.
39
+ * @param out - The linear velocity of the actor
40
+ */
41
+ getLinearVelocity(out: Vector3): Vector3;
29
42
  /**
30
43
  * Sets the linear velocity of the actor.
31
- * @param value - New linear velocity of actor.
44
+ * @param value - New linear velocity of actor
32
45
  */
33
46
  setLinearVelocity(value: Vector3): void;
47
+ /**
48
+ * Get the angular velocity of the actor.
49
+ * @param out - The angular velocity of the actor
50
+ */
51
+ getAngularVelocity(out: Vector3): Vector3;
34
52
  /**
35
53
  * Sets the angular velocity of the actor.
36
- * @param value - New angular velocity of actor.
54
+ * @param value - New angular velocity of actor
37
55
  */
38
56
  setAngularVelocity(value: Vector3): void;
39
57
  /**
40
58
  * Sets the mass of a dynamic actor.
41
- * @param value - New mass value for the actor.
59
+ * @param value - New mass value for the actor
42
60
  */
43
61
  setMass(value: number): void;
44
62
  /**
45
- * Sets the pose of the center of mass relative to the actor.
46
- * @param value - Mass frame offset transform relative to the actor frame.
63
+ * Sets the center of mass relative to the actor.
64
+ * @param value - Mass frame offset transform relative to the actor frame
47
65
  */
48
66
  setCenterOfMass(value: Vector3): void;
67
+ /**
68
+ * Gets the center of mass relative to the actor.
69
+ * @param out - The center of mass of the actor
70
+ */
71
+ getCenterOfMass(out: Vector3): Vector3;
49
72
  /**
50
73
  * Sets the inertia tensor, using a parameter specified in mass space coordinates.
51
- * @param value - New mass space inertia tensor for the actor.
74
+ * @param value - New mass space inertia tensor for the actor
52
75
  */
53
76
  setInertiaTensor(value: Vector3): void;
77
+ /**
78
+ * Gets the inertia tensor of the actor.
79
+ * @param out - The mass space inertia tensor of the actor
80
+ */
81
+ getInertiaTensor(out: Vector3): Vector3;
82
+ /**
83
+ * Sets the mass of a dynamic actor and automatically updates its inertia tensor.
84
+ * @param mass - New mass value for the actor
85
+ * @remarks This differs from setMass() by automatically updating
86
+ * the inertia tensor and center of mass based on the new mass value.
87
+ */
88
+ setMassAndUpdateInertia(mass: number): void;
54
89
  /**
55
90
  * Set the maximum angular velocity permitted for this actor.
56
- * @param value - Max allowable angular velocity for actor.
91
+ * @param value - Max allowable angular velocity for actor
57
92
  */
58
93
  setMaxAngularVelocity(value: number): void;
59
94
  /**
@@ -63,12 +98,12 @@ export interface IDynamicCollider extends ICollider {
63
98
  setMaxDepenetrationVelocity(value: number): void;
64
99
  /**
65
100
  * Sets the mass-normalized kinetic energy threshold below which an actor may go to sleep.
66
- * @param value - Energy below which an actor may go to sleep.
101
+ * @param value - Energy below which an actor may go to sleep
67
102
  */
68
103
  setSleepThreshold(value: number): void;
69
104
  /**
70
105
  * Sets the solver iteration counts for the body.
71
- * @param value - Number of position iterations the solver should perform for this body.
106
+ * @param value - Number of position iterations the solver should perform for this body
72
107
  */
73
108
  setSolverIterations(value: number): void;
74
109
  /**
@@ -76,6 +111,10 @@ export interface IDynamicCollider extends ICollider {
76
111
  * @param value - rigid body flag
77
112
  */
78
113
  setCollisionDetectionMode(value: number): void;
114
+ /**
115
+ * Whether the collider is affected by gravity.
116
+ */
117
+ setUseGravity(value: boolean): void;
79
118
  /**
80
119
  * Controls whether physics affects the dynamic collider.
81
120
  * @param value - is or not
@@ -83,7 +122,7 @@ export interface IDynamicCollider extends ICollider {
83
122
  setIsKinematic(value: boolean): void;
84
123
  /**
85
124
  * Raises or clears a particular rigid dynamic lock flag.
86
- * @param flags - the flag to raise(set) or clear.
125
+ * @param flags - the flag to raise(set) or clear
87
126
  */
88
127
  setConstraints(flags: number): void;
89
128
  /**
@@ -106,6 +145,10 @@ export interface IDynamicCollider extends ICollider {
106
145
  * Forces a collider to sleep at least one frame.
107
146
  */
108
147
  sleep(): void;
148
+ /**
149
+ * Returns whether the collider is sleeping.
150
+ */
151
+ isSleeping(): boolean;
109
152
  /**
110
153
  * Forces a collider to wake up.
111
154
  */
@@ -8,6 +8,7 @@ import { IPhysicsScene } from "./IPhysicsScene";
8
8
  import { IStaticCollider } from "./IStaticCollider";
9
9
  import { IFixedJoint, IHingeJoint, ISpringJoint } from "./joints";
10
10
  import { IBoxColliderShape, ICapsuleColliderShape, IPlaneColliderShape, ISphereColliderShape } from "./shape";
11
+ import { ICollision } from "./ICollision";
11
12
  /**
12
13
  * The interface of physics creation.
13
14
  */
@@ -31,7 +32,7 @@ export interface IPhysics {
31
32
  * @param onTriggerExit - Function called when trigger end
32
33
  * @param onTriggerStay - Function called when trigger stay
33
34
  */
34
- createPhysicsScene(physicsManager: IPhysicsManager, onContactEnter?: (obj1: number, obj2: number) => void, onContactExit?: (obj1: number, obj2: number) => void, onContactStay?: (obj1: number, obj2: number) => void, onTriggerEnter?: (obj1: number, obj2: number) => void, onTriggerExit?: (obj1: number, obj2: number) => void, onTriggerStay?: (obj1: number, obj2: number) => void): IPhysicsScene;
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;
35
36
  /**
36
37
  * Create dynamic collider.
37
38
  * @param position - The global position
@@ -1,7 +1,6 @@
1
1
  import { Ray, Vector3 } from "@galacean/engine-math";
2
2
  import { ICharacterController } from "./ICharacterController";
3
3
  import { ICollider } from "./ICollider";
4
- import { IColliderShape } from "./shape";
5
4
  /**
6
5
  * Interface for physics manager.
7
6
  */
@@ -11,16 +10,6 @@ export interface IPhysicsScene {
11
10
  * @param gravity - Physics gravity
12
11
  */
13
12
  setGravity(gravity: Vector3): void;
14
- /**
15
- * Add IColliderShape into the manager.
16
- * @param colliderShape - The Collider Shape.
17
- */
18
- addColliderShape(colliderShape: IColliderShape): void;
19
- /**
20
- * Remove IColliderShape.
21
- * @param colliderShape - The Collider Shape.
22
- */
23
- removeColliderShape(colliderShape: IColliderShape): void;
24
13
  /**
25
14
  * Add ICollider into the manager.
26
15
  * @param collider - StaticCollider or DynamicCollider.
@@ -6,5 +6,6 @@ export type { IPhysicsMaterial } from "./IPhysicsMaterial";
6
6
  export type { IPhysicsScene } from "./IPhysicsScene";
7
7
  export type { IPhysicsManager } from "./IPhysicsManager";
8
8
  export type { IStaticCollider } from "./IStaticCollider";
9
+ export type { ICollision } from "./ICollision";
9
10
  export * from "./joints/index";
10
11
  export * from "./shape/index";
@@ -8,10 +8,6 @@ export interface IHingeJoint extends IJoint {
8
8
  * The anchor rotation.
9
9
  */
10
10
  setAxis(value: Vector3): void;
11
- /**
12
- * The swing offset.
13
- */
14
- setSwingOffset(value: Vector3): void;
15
11
  /**
16
12
  * The current angle in degrees of the joint relative to its rest position.
17
13
  */
@@ -14,20 +14,24 @@ export interface IJoint {
14
14
  */
15
15
  setConnectedAnchor(value: Vector3): void;
16
16
  /**
17
- * The scale to apply to the inverse mass of collider 0 for resolving this constraint.
17
+ * The anchor position.
18
18
  */
19
- setConnectedMassScale(value: number): void;
19
+ setAnchor(value: Vector3): void;
20
20
  /**
21
- * The scale to apply to the inverse inertia of collider0 for resolving this constraint.
21
+ * The scale to apply to the inverse mass of collider1 for resolving this constraint.
22
22
  */
23
- setConnectedInertiaScale(value: number): void;
23
+ setConnectedMassScale(value: number): void;
24
24
  /**
25
- * The scale to apply to the inverse mass of collider 1 for resolving this constraint.
25
+ * The scale to apply to the inverse mass of collider0 for resolving this constraint.
26
26
  */
27
27
  setMassScale(value: number): void;
28
28
  /**
29
29
  * The scale to apply to the inverse inertia of collider1 for resolving this constraint.
30
30
  */
31
+ setConnectedInertiaScale(value: number): void;
32
+ /**
33
+ * The scale to apply to the inverse inertia of collider0 for resolving this constraint.
34
+ */
31
35
  setInertiaScale(value: number): void;
32
36
  /**
33
37
  * The maximum force the joint can apply before breaking.
@@ -37,4 +41,8 @@ export interface IJoint {
37
41
  * The maximum torque the joint can apply before breaking.
38
42
  */
39
43
  setBreakTorque(value: number): void;
44
+ /**
45
+ * Destroy the joint.
46
+ */
47
+ destroy(): void;
40
48
  }
@@ -1,13 +1,8 @@
1
1
  import { IJoint } from "./IJoint";
2
- import { Vector3 } from "@galacean/engine-math";
3
2
  /**
4
3
  * a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects
5
4
  */
6
5
  export interface ISpringJoint extends IJoint {
7
- /**
8
- * The swing offset.
9
- */
10
- setSwingOffset(value: Vector3): void;
11
6
  /**
12
7
  * Set the allowed minimum distance for the joint.
13
8
  * @param distance the minimum distance
@@ -1,4 +1,4 @@
1
- import { Vector3 } from "@galacean/engine-math";
1
+ import { Vector3, Vector4 } from "@galacean/engine-math";
2
2
  import { IPhysicsMaterial } from "../IPhysicsMaterial";
3
3
  /**
4
4
  * Interface for physics collider shape.
@@ -34,6 +34,13 @@ export interface IColliderShape {
34
34
  * @param value - True for TriggerShape, false for SimulationShape
35
35
  */
36
36
  setIsTrigger(value: boolean): void;
37
+ /**
38
+ * Get the distance between a point and the shape.
39
+ * @param point - Location in world space you want to find the closest point to
40
+ * @returns The x, y, and z components of the Vector4 represent the closest point on the shape in world space,
41
+ * and the w component represents the distance between the point and the shape
42
+ */
43
+ pointDistance(point: Vector3): Vector4;
37
44
  /**
38
45
  * Decrements the reference count of a shape and releases it if the new reference count is zero.
39
46
  */