@galacean/engine-design 0.9.0-beta.80
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/LICENSE +21 -0
- package/README.md +1 -0
- package/package.json +22 -0
- package/types/IClone.d.ts +15 -0
- package/types/index.d.ts +3 -0
- package/types/physics/ICharacterController.d.ts +44 -0
- package/types/physics/ICollider.d.ts +20 -0
- package/types/physics/IDynamicCollider.d.ts +113 -0
- package/types/physics/IPhysics.d.ts +92 -0
- package/types/physics/IPhysicsManager.d.ts +58 -0
- package/types/physics/IPhysicsMaterial.d.ts +34 -0
- package/types/physics/IStaticCollider.d.ts +19 -0
- package/types/physics/index.d.ts +9 -0
- package/types/physics/joints/IFixedJoint.d.ts +3 -0
- package/types/physics/joints/IHingeJoint.d.ts +59 -0
- package/types/physics/joints/IJoint.d.ts +40 -0
- package/types/physics/joints/ISpringJoint.d.ts +36 -0
- package/types/physics/joints/index.d.ts +4 -0
- package/types/physics/shape/IBoxColliderShape.d.ts +12 -0
- package/types/physics/shape/ICapsuleColliderShape.d.ts +21 -0
- package/types/physics/shape/IColliderShape.d.ts +41 -0
- package/types/physics/shape/IPlaneColliderShape.d.ts +6 -0
- package/types/physics/shape/ISphereColliderShape.d.ts +11 -0
- package/types/physics/shape/index.d.ts +5 -0
- package/types/renderingHardwareInterface/IPlatformPrimitive.d.ts +15 -0
- package/types/renderingHardwareInterface/index.d.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2020-2023 Galacean authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
A subpackage of `@galacean/engine`.
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@galacean/engine-design",
|
|
3
|
+
"version": "0.9.0-beta.80",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"registry": "https://registry.npmjs.org"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"main": "dist/main.js",
|
|
10
|
+
"module": "dist/module.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**/*",
|
|
13
|
+
"types/**/*"
|
|
14
|
+
],
|
|
15
|
+
"types": "types/index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@galacean/engine-math": "0.9.0-beta.80"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"b:types": "tsc"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clone interface.
|
|
3
|
+
*/
|
|
4
|
+
export interface IClone {
|
|
5
|
+
/**
|
|
6
|
+
* Clone and return object.
|
|
7
|
+
* @returns Clone object
|
|
8
|
+
*/
|
|
9
|
+
clone(): Object;
|
|
10
|
+
/**
|
|
11
|
+
* Clone to the target object.
|
|
12
|
+
* @param target - Target object
|
|
13
|
+
*/
|
|
14
|
+
cloneTo(target: Object): void;
|
|
15
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Vector3 } from "@galacean/engine-math";
|
|
2
|
+
import { ICollider } from "./ICollider";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for character controllers.
|
|
5
|
+
*/
|
|
6
|
+
export interface ICharacterController extends ICollider {
|
|
7
|
+
/**
|
|
8
|
+
* Moves the character using a "collide-and-slide" algorithm.
|
|
9
|
+
* @param disp Displacement vector
|
|
10
|
+
* @param minDist The minimum travelled distance to consider.
|
|
11
|
+
* @param elapsedTime Time elapsed since last call
|
|
12
|
+
*/
|
|
13
|
+
move(disp: Vector3, minDist: number, elapsedTime: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* Sets controller's world position.
|
|
16
|
+
* @param position The new (center) position for the controller.
|
|
17
|
+
*/
|
|
18
|
+
setWorldPosition(position: Vector3): void;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve the world position of the controller.
|
|
21
|
+
* @param position The controller's center position
|
|
22
|
+
*/
|
|
23
|
+
getWorldPosition(position: Vector3): void;
|
|
24
|
+
/**
|
|
25
|
+
* The step height.
|
|
26
|
+
* @param offset The new step offset for the controller.
|
|
27
|
+
*/
|
|
28
|
+
setStepOffset(offset: number): void;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the non-walkable mode for the CCT.
|
|
31
|
+
* @param flag The new value of the non-walkable mode.
|
|
32
|
+
*/
|
|
33
|
+
setNonWalkableMode(flag: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the 'up' direction.
|
|
36
|
+
* @param up The up direction for the controller.
|
|
37
|
+
*/
|
|
38
|
+
setUpDirection(up: Vector3): void;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the slope limit.
|
|
41
|
+
* @param slopeLimit The slope limit for the controller.
|
|
42
|
+
*/
|
|
43
|
+
setSlopeLimit(slopeLimit: number): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IColliderShape } from "./shape";
|
|
2
|
+
/**
|
|
3
|
+
* Interface of physics collider.
|
|
4
|
+
*/
|
|
5
|
+
export interface ICollider {
|
|
6
|
+
/**
|
|
7
|
+
* Add collider shape on collider.
|
|
8
|
+
* @param shape - The collider shape attached
|
|
9
|
+
*/
|
|
10
|
+
addShape(shape: IColliderShape): void;
|
|
11
|
+
/**
|
|
12
|
+
* Remove collider shape on collider.
|
|
13
|
+
* @param shape - The collider shape attached
|
|
14
|
+
*/
|
|
15
|
+
removeShape(shape: IColliderShape): void;
|
|
16
|
+
/**
|
|
17
|
+
* Deletes the collider.
|
|
18
|
+
*/
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Quaternion, Vector3 } from "@galacean/engine-math";
|
|
2
|
+
import { ICollider } from "./ICollider";
|
|
3
|
+
/**
|
|
4
|
+
* Interface of physics dynamic collider.
|
|
5
|
+
*/
|
|
6
|
+
export interface IDynamicCollider extends ICollider {
|
|
7
|
+
/**
|
|
8
|
+
* Set global transform of collider.
|
|
9
|
+
* @param position - The global position
|
|
10
|
+
* @param rotation - The global rotation
|
|
11
|
+
*/
|
|
12
|
+
setWorldTransform(position: Vector3, rotation: Quaternion): void;
|
|
13
|
+
/**
|
|
14
|
+
* Get global transform of collider.
|
|
15
|
+
* @param outPosition - The global position
|
|
16
|
+
* @param outRotation - The global rotation
|
|
17
|
+
*/
|
|
18
|
+
getWorldTransform(outPosition: Vector3, outRotation: Quaternion): void;
|
|
19
|
+
/**
|
|
20
|
+
* Sets the linear damping coefficient.
|
|
21
|
+
* @param value - Linear damping coefficient.
|
|
22
|
+
*/
|
|
23
|
+
setLinearDamping(value: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Sets the angular damping coefficient.
|
|
26
|
+
* @param value - Angular damping coefficient.
|
|
27
|
+
*/
|
|
28
|
+
setAngularDamping(value: number): void;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the linear velocity of the actor.
|
|
31
|
+
* @param value - New linear velocity of actor.
|
|
32
|
+
*/
|
|
33
|
+
setLinearVelocity(value: Vector3): void;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the angular velocity of the actor.
|
|
36
|
+
* @param value - New angular velocity of actor.
|
|
37
|
+
*/
|
|
38
|
+
setAngularVelocity(value: Vector3): void;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the mass of a dynamic actor.
|
|
41
|
+
* @param value - New mass value for the actor.
|
|
42
|
+
*/
|
|
43
|
+
setMass(value: number): void;
|
|
44
|
+
/**
|
|
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.
|
|
47
|
+
*/
|
|
48
|
+
setCenterOfMass(value: Vector3): void;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the inertia tensor, using a parameter specified in mass space coordinates.
|
|
51
|
+
* @param value - New mass space inertia tensor for the actor.
|
|
52
|
+
*/
|
|
53
|
+
setInertiaTensor(value: Vector3): void;
|
|
54
|
+
/**
|
|
55
|
+
* Set the maximum angular velocity permitted for this actor.
|
|
56
|
+
* @param value - Max allowable angular velocity for actor.
|
|
57
|
+
*/
|
|
58
|
+
setMaxAngularVelocity(value: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* Sets the maximum depenetration velocity permitted to be introduced by the solver.
|
|
61
|
+
* @param value - The maximum velocity to de-penetrate
|
|
62
|
+
*/
|
|
63
|
+
setMaxDepenetrationVelocity(value: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* 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.
|
|
67
|
+
*/
|
|
68
|
+
setSleepThreshold(value: number): void;
|
|
69
|
+
/**
|
|
70
|
+
* Sets the solver iteration counts for the body.
|
|
71
|
+
* @param value - Number of position iterations the solver should perform for this body.
|
|
72
|
+
*/
|
|
73
|
+
setSolverIterations(value: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* Sets the colliders' collision detection mode.
|
|
76
|
+
* @param value - rigid body flag
|
|
77
|
+
*/
|
|
78
|
+
setCollisionDetectionMode(value: number): void;
|
|
79
|
+
/**
|
|
80
|
+
* Controls whether physics affects the dynamic collider.
|
|
81
|
+
* @param value - is or not
|
|
82
|
+
*/
|
|
83
|
+
setIsKinematic(value: boolean): void;
|
|
84
|
+
/**
|
|
85
|
+
* Raises or clears a particular rigid dynamic lock flag.
|
|
86
|
+
* @param flags - the flag to raise(set) or clear.
|
|
87
|
+
*/
|
|
88
|
+
setConstraints(flags: number): void;
|
|
89
|
+
/**
|
|
90
|
+
* Apply a force to the dynamic collider.
|
|
91
|
+
* @param force - The force make the collider move
|
|
92
|
+
*/
|
|
93
|
+
addForce(force: Vector3): void;
|
|
94
|
+
/**
|
|
95
|
+
* Apply a torque to the dynamic collider.
|
|
96
|
+
* @param torque - The force make the collider rotate
|
|
97
|
+
*/
|
|
98
|
+
addTorque(torque: Vector3): void;
|
|
99
|
+
/**
|
|
100
|
+
* Moves kinematically controlled dynamic actors through the game world.
|
|
101
|
+
* @param positionOrRotation - The desired position or rotation for the kinematic actor
|
|
102
|
+
* @param rotation - The desired rotation for the kinematic actor
|
|
103
|
+
*/
|
|
104
|
+
move(positionOrRotation: Vector3 | Quaternion, rotation?: Quaternion): void;
|
|
105
|
+
/**
|
|
106
|
+
* Forces a collider to sleep at least one frame.
|
|
107
|
+
*/
|
|
108
|
+
sleep(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Forces a collider to wake up.
|
|
111
|
+
*/
|
|
112
|
+
wakeUp(): void;
|
|
113
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IPhysicsMaterial } from "./IPhysicsMaterial";
|
|
2
|
+
import { IPhysicsManager } from "./IPhysicsManager";
|
|
3
|
+
import { IBoxColliderShape, ISphereColliderShape, ICapsuleColliderShape, IPlaneColliderShape } from "./shape";
|
|
4
|
+
import { IDynamicCollider } from "./IDynamicCollider";
|
|
5
|
+
import { IStaticCollider } from "./IStaticCollider";
|
|
6
|
+
import { Quaternion, Vector3 } from "@galacean/engine-math";
|
|
7
|
+
import { ICollider } from "./ICollider";
|
|
8
|
+
import { ICharacterController } from "./ICharacterController";
|
|
9
|
+
import { IFixedJoint, IHingeJoint, ISpringJoint } from "./joints";
|
|
10
|
+
/**
|
|
11
|
+
* The interface of physics creation.
|
|
12
|
+
*/
|
|
13
|
+
export interface IPhysics {
|
|
14
|
+
/**
|
|
15
|
+
* Create physics manager.
|
|
16
|
+
* @param onContactEnter - Function called when contact begin
|
|
17
|
+
* @param onContactExit - Function called when contact end
|
|
18
|
+
* @param onContactStay - Function called when contact stay
|
|
19
|
+
* @param onTriggerEnter - Function called when trigger begin
|
|
20
|
+
* @param onTriggerExit - Function called when trigger end
|
|
21
|
+
* @param onTriggerStay - Function called when trigger stay
|
|
22
|
+
*/
|
|
23
|
+
createPhysicsManager(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): IPhysicsManager;
|
|
24
|
+
/**
|
|
25
|
+
* Create dynamic collider.
|
|
26
|
+
* @param position - The global position
|
|
27
|
+
* @param rotation - The global rotation
|
|
28
|
+
*/
|
|
29
|
+
createDynamicCollider(position: Vector3, rotation: Quaternion): IDynamicCollider;
|
|
30
|
+
/**
|
|
31
|
+
* Create static collider.
|
|
32
|
+
* @param position - The global position
|
|
33
|
+
* @param rotation - The global rotation
|
|
34
|
+
*/
|
|
35
|
+
createStaticCollider(position: Vector3, rotation: Quaternion): IStaticCollider;
|
|
36
|
+
/**
|
|
37
|
+
* Create character controller.
|
|
38
|
+
*/
|
|
39
|
+
createCharacterController(): ICharacterController;
|
|
40
|
+
/**
|
|
41
|
+
* Create physics material.
|
|
42
|
+
* @param staticFriction - Static friction
|
|
43
|
+
* @param dynamicFriction - Dynamic friction
|
|
44
|
+
* @param bounciness - Restitution
|
|
45
|
+
* @param frictionCombine - The mode to combine the friction of collider
|
|
46
|
+
* @param bounceCombine - The mode to combine the bounce of collider
|
|
47
|
+
*/
|
|
48
|
+
createPhysicsMaterial(staticFriction: number, dynamicFriction: number, bounciness: number, frictionCombine: number, bounceCombine: number): IPhysicsMaterial;
|
|
49
|
+
/**
|
|
50
|
+
* Create box collider shape.
|
|
51
|
+
* @param uniqueID - Shape unique id
|
|
52
|
+
* @param size - Size of the box
|
|
53
|
+
* @param material - The material of this shape
|
|
54
|
+
*/
|
|
55
|
+
createBoxColliderShape(uniqueID: number, size: Vector3, material: IPhysicsMaterial): IBoxColliderShape;
|
|
56
|
+
/**
|
|
57
|
+
* Create sphere collider shape.
|
|
58
|
+
* @param uniqueID - Shape unique id
|
|
59
|
+
* @param radius - Radius of the sphere
|
|
60
|
+
* @param material - The material of this shape
|
|
61
|
+
*/
|
|
62
|
+
createSphereColliderShape(uniqueID: number, radius: number, material: IPhysicsMaterial): ISphereColliderShape;
|
|
63
|
+
/**
|
|
64
|
+
* Create plane collider shape.
|
|
65
|
+
* @param uniqueID - Shape unique id
|
|
66
|
+
* @param material - The material of this shape
|
|
67
|
+
*/
|
|
68
|
+
createPlaneColliderShape(uniqueID: number, material: IPhysicsMaterial): IPlaneColliderShape;
|
|
69
|
+
/**
|
|
70
|
+
* Create capsule collider shape.
|
|
71
|
+
* @param uniqueID - Shape unique id
|
|
72
|
+
* @param radius - Radius of capsule
|
|
73
|
+
* @param height - Height of capsule
|
|
74
|
+
* @param material - The material of this shape
|
|
75
|
+
*/
|
|
76
|
+
createCapsuleColliderShape(uniqueID: number, radius: number, height: number, material: IPhysicsMaterial): ICapsuleColliderShape;
|
|
77
|
+
/**
|
|
78
|
+
* Create fixed joint.
|
|
79
|
+
* @param collider - Affector of joint
|
|
80
|
+
*/
|
|
81
|
+
createFixedJoint(collider: ICollider): IFixedJoint;
|
|
82
|
+
/**
|
|
83
|
+
* Create hinge joint.
|
|
84
|
+
* @param collider - Affector of joint
|
|
85
|
+
*/
|
|
86
|
+
createHingeJoint(collider: ICollider): IHingeJoint;
|
|
87
|
+
/**
|
|
88
|
+
* Create spring joint
|
|
89
|
+
* @param collider - Affector of joint
|
|
90
|
+
*/
|
|
91
|
+
createSpringJoint(collider: ICollider): ISpringJoint;
|
|
92
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Ray, Vector3 } from "@galacean/engine-math";
|
|
2
|
+
import { ICharacterController } from "./ICharacterController";
|
|
3
|
+
import { ICollider } from "./ICollider";
|
|
4
|
+
import { IColliderShape } from "./shape";
|
|
5
|
+
/**
|
|
6
|
+
* Interface for physics manager.
|
|
7
|
+
*/
|
|
8
|
+
export interface IPhysicsManager {
|
|
9
|
+
/**
|
|
10
|
+
* Set gravity.
|
|
11
|
+
* @param gravity - Physics gravity
|
|
12
|
+
*/
|
|
13
|
+
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
|
+
/**
|
|
25
|
+
* Add ICollider into the manager.
|
|
26
|
+
* @param collider - StaticCollider or DynamicCollider.
|
|
27
|
+
*/
|
|
28
|
+
addCollider(collider: ICollider): void;
|
|
29
|
+
/**
|
|
30
|
+
* Remove ICollider.
|
|
31
|
+
* @param collider - StaticCollider or DynamicCollider.
|
|
32
|
+
*/
|
|
33
|
+
removeCollider(collider: ICollider): void;
|
|
34
|
+
/**
|
|
35
|
+
* Add ICharacterController into the manager.
|
|
36
|
+
* @param characterController The Character Controller.
|
|
37
|
+
*/
|
|
38
|
+
addCharacterController(characterController: ICharacterController): void;
|
|
39
|
+
/**
|
|
40
|
+
* Remove ICharacterController.
|
|
41
|
+
* @param characterController The Character Controller.
|
|
42
|
+
*/
|
|
43
|
+
removeCharacterController(characterController: ICharacterController): void;
|
|
44
|
+
/**
|
|
45
|
+
* Call on every frame to update pose of objects.
|
|
46
|
+
* @param elapsedTime - Step time of update.
|
|
47
|
+
*/
|
|
48
|
+
update(elapsedTime: number): void;
|
|
49
|
+
/**
|
|
50
|
+
* Casts a ray through the Scene and returns the first hit.
|
|
51
|
+
* @param ray - The ray
|
|
52
|
+
* @param distance - The max distance the ray should check
|
|
53
|
+
* @param onRaycast - The raycast result callback which prefilter result
|
|
54
|
+
* @param outHitResult - If true is returned, outHitResult will contain more detailed collision information
|
|
55
|
+
* @returns Returns True if the ray intersects with a collider, otherwise false
|
|
56
|
+
*/
|
|
57
|
+
raycast(ray: Ray, distance: number, onRaycast: (obj: number) => boolean, outHitResult?: (shapeUniqueID: number, distance: number, point: Vector3, normal: Vector3) => void): boolean;
|
|
58
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface of physics material.
|
|
3
|
+
*/
|
|
4
|
+
export interface IPhysicsMaterial {
|
|
5
|
+
/**
|
|
6
|
+
* Set the coefficient of bounciness.
|
|
7
|
+
* @param value - The bounciness
|
|
8
|
+
*/
|
|
9
|
+
setBounciness(value: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* Set the coefficient of dynamic friction.
|
|
12
|
+
* @param value - The dynamic friction
|
|
13
|
+
*/
|
|
14
|
+
setDynamicFriction(value: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* Set the coefficient of static friction.
|
|
17
|
+
* @param value - The static friction
|
|
18
|
+
*/
|
|
19
|
+
setStaticFriction(value: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* Set the bounciness combine mode.
|
|
22
|
+
* @param value - The combine mode
|
|
23
|
+
*/
|
|
24
|
+
setBounceCombine(value: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Set the friction combine mode.
|
|
27
|
+
* @param value - The combine mode
|
|
28
|
+
*/
|
|
29
|
+
setFrictionCombine(value: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Decrements the reference count of a material and releases it if the new reference count is zero.
|
|
32
|
+
*/
|
|
33
|
+
destroy(): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Quaternion, Vector3 } from "@galacean/engine-math";
|
|
2
|
+
import { ICollider } from "./ICollider";
|
|
3
|
+
/**
|
|
4
|
+
* Interface of physics static collider.
|
|
5
|
+
*/
|
|
6
|
+
export interface IStaticCollider extends ICollider {
|
|
7
|
+
/**
|
|
8
|
+
* Set global transform of collider.
|
|
9
|
+
* @param position - The global position
|
|
10
|
+
* @param rotation - The global rotation
|
|
11
|
+
*/
|
|
12
|
+
setWorldTransform(position: Vector3, rotation: Quaternion): void;
|
|
13
|
+
/**
|
|
14
|
+
* Get global transform of collider.
|
|
15
|
+
* @param outPosition - The global position
|
|
16
|
+
* @param outRotation - The global rotation
|
|
17
|
+
*/
|
|
18
|
+
getWorldTransform(outPosition: Vector3, outRotation: Quaternion): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { IPhysics } from "./IPhysics";
|
|
2
|
+
export type { IPhysicsManager } from "./IPhysicsManager";
|
|
3
|
+
export type { ICollider } from "./ICollider";
|
|
4
|
+
export type { IStaticCollider } from "./IStaticCollider";
|
|
5
|
+
export type { IDynamicCollider } from "./IDynamicCollider";
|
|
6
|
+
export type { IPhysicsMaterial } from "./IPhysicsMaterial";
|
|
7
|
+
export type { ICharacterController } from "./ICharacterController";
|
|
8
|
+
export * from "./shape/index";
|
|
9
|
+
export * from "./joints/index";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { IJoint } from "./IJoint";
|
|
2
|
+
import { Vector3 } from "@galacean/engine-math";
|
|
3
|
+
/**
|
|
4
|
+
* A joint which behaves in a similar way to a hinge or axle.
|
|
5
|
+
*/
|
|
6
|
+
export interface IHingeJoint extends IJoint {
|
|
7
|
+
/**
|
|
8
|
+
* The anchor rotation.
|
|
9
|
+
*/
|
|
10
|
+
setAxis(value: Vector3): void;
|
|
11
|
+
/**
|
|
12
|
+
* The swing offset.
|
|
13
|
+
*/
|
|
14
|
+
setSwingOffset(value: Vector3): void;
|
|
15
|
+
/**
|
|
16
|
+
* The current angle in degrees of the joint relative to its rest position.
|
|
17
|
+
*/
|
|
18
|
+
getAngle(): number;
|
|
19
|
+
/**
|
|
20
|
+
* The angular velocity of the joint in degrees per second.
|
|
21
|
+
*/
|
|
22
|
+
getVelocity(): Readonly<Vector3>;
|
|
23
|
+
/**
|
|
24
|
+
* Set a cone hard limit.
|
|
25
|
+
* @param lowerLimit The lower angle of the limit
|
|
26
|
+
* @param upperLimit The upper angle of the limit
|
|
27
|
+
* @param contactDist The distance from the limit at which it becomes active. Default is the lesser of 0.1 radians, and 0.49 * the lower of the limit angles
|
|
28
|
+
*/
|
|
29
|
+
setHardLimit(lowerLimit: number, upperLimit: number, contactDist: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Set a cone soft limit.
|
|
32
|
+
* @param lowerLimit The lower angle of the limit
|
|
33
|
+
* @param upperLimit The upper angle of the limit
|
|
34
|
+
* @param stiffness the spring strength of the drive
|
|
35
|
+
* @param damping the damping strength of the drive
|
|
36
|
+
*/
|
|
37
|
+
setSoftLimit(lowerLimit: number, upperLimit: number, stiffness: number, damping: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* set the target velocity for the drive model.
|
|
40
|
+
* @param velocity the drive target velocity
|
|
41
|
+
*/
|
|
42
|
+
setDriveVelocity(velocity: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* sets the maximum torque the drive can exert.
|
|
45
|
+
* @param limit the maximum torque
|
|
46
|
+
*/
|
|
47
|
+
setDriveForceLimit(limit: number): void;
|
|
48
|
+
/**
|
|
49
|
+
* sets the gear ratio for the drive.
|
|
50
|
+
* @param ratio the gear ratio
|
|
51
|
+
*/
|
|
52
|
+
setDriveGearRatio(ratio: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* sets a single flag specific to a Hinge Joint.
|
|
55
|
+
* @param flag The flag to set or clear.
|
|
56
|
+
* @param value the value to which to set the flag
|
|
57
|
+
*/
|
|
58
|
+
setHingeJointFlag(flag: number, value: boolean): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Vector3 } from "@galacean/engine-math";
|
|
2
|
+
import { ICollider } from "../ICollider";
|
|
3
|
+
/**
|
|
4
|
+
* a base interface providing common functionality for joints.
|
|
5
|
+
*/
|
|
6
|
+
export interface IJoint {
|
|
7
|
+
/**
|
|
8
|
+
* The connected collider.
|
|
9
|
+
*/
|
|
10
|
+
setConnectedCollider(value: ICollider): void;
|
|
11
|
+
/**
|
|
12
|
+
* The connected anchor position.
|
|
13
|
+
* @remarks If connectedCollider is set, this anchor is relative offset, or the anchor is world position.
|
|
14
|
+
*/
|
|
15
|
+
setConnectedAnchor(value: Vector3): void;
|
|
16
|
+
/**
|
|
17
|
+
* The scale to apply to the inverse mass of collider 0 for resolving this constraint.
|
|
18
|
+
*/
|
|
19
|
+
setConnectedMassScale(value: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* The scale to apply to the inverse inertia of collider0 for resolving this constraint.
|
|
22
|
+
*/
|
|
23
|
+
setConnectedInertiaScale(value: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* The scale to apply to the inverse mass of collider 1 for resolving this constraint.
|
|
26
|
+
*/
|
|
27
|
+
setMassScale(value: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* The scale to apply to the inverse inertia of collider1 for resolving this constraint.
|
|
30
|
+
*/
|
|
31
|
+
setInertiaScale(value: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* The maximum force the joint can apply before breaking.
|
|
34
|
+
*/
|
|
35
|
+
setBreakForce(value: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* The maximum torque the joint can apply before breaking.
|
|
38
|
+
*/
|
|
39
|
+
setBreakTorque(value: number): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IJoint } from "./IJoint";
|
|
2
|
+
import { Vector3 } from "@galacean/engine-math";
|
|
3
|
+
/**
|
|
4
|
+
* a joint that maintains an upper or lower bound (or both) on the distance between two points on different objects
|
|
5
|
+
*/
|
|
6
|
+
export interface ISpringJoint extends IJoint {
|
|
7
|
+
/**
|
|
8
|
+
* The swing offset.
|
|
9
|
+
*/
|
|
10
|
+
setSwingOffset(value: Vector3): void;
|
|
11
|
+
/**
|
|
12
|
+
* Set the allowed minimum distance for the joint.
|
|
13
|
+
* @param distance the minimum distance
|
|
14
|
+
*/
|
|
15
|
+
setMinDistance(distance: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* Set the allowed maximum distance for the joint.
|
|
18
|
+
* @param distance the maximum distance
|
|
19
|
+
*/
|
|
20
|
+
setMaxDistance(distance: number): void;
|
|
21
|
+
/**
|
|
22
|
+
* Set the error tolerance of the joint.
|
|
23
|
+
* @param tolerance the distance beyond the allowed range at which the joint becomes active
|
|
24
|
+
*/
|
|
25
|
+
setTolerance(tolerance: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Set the strength of the joint spring.
|
|
28
|
+
* @param stiffness the spring strength of the joint
|
|
29
|
+
*/
|
|
30
|
+
setStiffness(stiffness: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* Set the damping of the joint spring.
|
|
33
|
+
* @param damping the degree of damping of the joint spring of the joint
|
|
34
|
+
*/
|
|
35
|
+
setDamping(damping: number): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IColliderShape } from "./IColliderShape";
|
|
2
|
+
import { Vector3 } from "@galacean/engine-math";
|
|
3
|
+
/**
|
|
4
|
+
* Interface of physics box collider shape.
|
|
5
|
+
*/
|
|
6
|
+
export interface IBoxColliderShape extends IColliderShape {
|
|
7
|
+
/**
|
|
8
|
+
* Set size of Box Shape.
|
|
9
|
+
* @param size - The size
|
|
10
|
+
*/
|
|
11
|
+
setSize(size: Vector3): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IColliderShape } from "./IColliderShape";
|
|
2
|
+
/**
|
|
3
|
+
* Interface of physics capsule collider shape.
|
|
4
|
+
*/
|
|
5
|
+
export interface ICapsuleColliderShape extends IColliderShape {
|
|
6
|
+
/**
|
|
7
|
+
* Set radius of capsule.
|
|
8
|
+
* @param radius - The radius
|
|
9
|
+
*/
|
|
10
|
+
setRadius(radius: number): void;
|
|
11
|
+
/**
|
|
12
|
+
* Set height of capsule.
|
|
13
|
+
* @param height - The height
|
|
14
|
+
*/
|
|
15
|
+
setHeight(height: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* Set up axis of capsule.
|
|
18
|
+
* @param upAxis - The up axis
|
|
19
|
+
*/
|
|
20
|
+
setUpAxis(upAxis: number): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Vector3 } from "@galacean/engine-math";
|
|
2
|
+
import { IPhysicsMaterial } from "../IPhysicsMaterial";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for physics collider shape.
|
|
5
|
+
*/
|
|
6
|
+
export interface IColliderShape {
|
|
7
|
+
/**
|
|
8
|
+
* Set local rotation.
|
|
9
|
+
* @param rotation - The local rotation
|
|
10
|
+
*/
|
|
11
|
+
setRotation(rotation: Vector3): void;
|
|
12
|
+
/**
|
|
13
|
+
* Set local position.
|
|
14
|
+
* @param position - The local position
|
|
15
|
+
*/
|
|
16
|
+
setPosition(position: Vector3): void;
|
|
17
|
+
/**
|
|
18
|
+
* Set world scale of shape.
|
|
19
|
+
* @param scale - The scale
|
|
20
|
+
*/
|
|
21
|
+
setWorldScale(scale: Vector3): void;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the contact offset.
|
|
24
|
+
* @param offset - contact offset
|
|
25
|
+
*/
|
|
26
|
+
setContactOffset(offset: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Set physics material on shape.
|
|
29
|
+
* @param material - The physics material
|
|
30
|
+
*/
|
|
31
|
+
setMaterial(material: IPhysicsMaterial): void;
|
|
32
|
+
/**
|
|
33
|
+
* Set trigger or not.
|
|
34
|
+
* @param value - True for TriggerShape, false for SimulationShape
|
|
35
|
+
*/
|
|
36
|
+
setIsTrigger(value: boolean): void;
|
|
37
|
+
/**
|
|
38
|
+
* Decrements the reference count of a shape and releases it if the new reference count is zero.
|
|
39
|
+
*/
|
|
40
|
+
destroy(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IColliderShape } from "./IColliderShape";
|
|
2
|
+
/**
|
|
3
|
+
* Interface of physics sphere collider shape.
|
|
4
|
+
*/
|
|
5
|
+
export interface ISphereColliderShape extends IColliderShape {
|
|
6
|
+
/**
|
|
7
|
+
* Set radius of sphere.
|
|
8
|
+
* @param radius - The radius
|
|
9
|
+
*/
|
|
10
|
+
setRadius(radius: number): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { IColliderShape } from "./IColliderShape";
|
|
2
|
+
export type { IBoxColliderShape } from "./IBoxColliderShape";
|
|
3
|
+
export type { ICapsuleColliderShape } from "./ICapsuleColliderShape";
|
|
4
|
+
export type { ISphereColliderShape } from "./ISphereColliderShape";
|
|
5
|
+
export type { IPlaneColliderShape } from "./IPlaneColliderShape";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform primitive interface.
|
|
3
|
+
*/
|
|
4
|
+
export interface IPlatformPrimitive {
|
|
5
|
+
/**
|
|
6
|
+
* Draw primitive.
|
|
7
|
+
* @param tech - Shader
|
|
8
|
+
* @param subPrimitive - Sub primitive
|
|
9
|
+
*/
|
|
10
|
+
draw(tech: any, subPrimitive: any): void;
|
|
11
|
+
/**
|
|
12
|
+
* Destroy.
|
|
13
|
+
*/
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { IPlatformPrimitive } from "./IPlatformPrimitive";
|