@galacean/engine-physics-lite 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 +34 -0
- package/dist/browser.js +1259 -0
- package/dist/browser.min.js +1 -0
- package/dist/main.js +1256 -0
- package/dist/main.js.map +1 -0
- package/dist/miniprogram.js +36332 -0
- package/dist/module.js +1254 -0
- package/dist/module.js.map +1 -0
- package/package.json +28 -0
- package/types/DisorderedArray.d.ts +18 -0
- package/types/LiteCollider.d.ts +29 -0
- package/types/LiteDynamicCollider.d.ts +90 -0
- package/types/LiteHitResult.d.ts +1 -0
- package/types/LitePhysics.d.ts +54 -0
- package/types/LitePhysicsManager.d.ts +79 -0
- package/types/LitePhysicsMaterial.d.ts +31 -0
- package/types/LiteStaticCollider.d.ts +15 -0
- package/types/LiteTransform.d.ts +118 -0
- package/types/LiteUpdateFlag.d.ts +19 -0
- package/types/LiteUpdateFlagManager.d.ts +1 -0
- package/types/StaticInterfaceImplement.d.ts +5 -0
- package/types/index.d.ts +1 -0
- package/types/shape/LiteBoxColliderShape.d.ts +32 -0
- package/types/shape/LiteColliderShape.d.ts +46 -0
- package/types/shape/LiteSphereColliderShape.d.ts +28 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Matrix, Quaternion, Vector3 } from "@galacean/engine";
|
|
2
|
+
import { LiteCollider } from "./LiteCollider";
|
|
3
|
+
import { LiteUpdateFlag } from "./LiteUpdateFlag";
|
|
4
|
+
import { LiteColliderShape } from "./shape/LiteColliderShape";
|
|
5
|
+
/**
|
|
6
|
+
* Used to implement transformation related functions.
|
|
7
|
+
*/
|
|
8
|
+
export declare class LiteTransform {
|
|
9
|
+
private static _tempQuat0;
|
|
10
|
+
private static _tempMat42;
|
|
11
|
+
private _position;
|
|
12
|
+
private _rotation;
|
|
13
|
+
private _rotationQuaternion;
|
|
14
|
+
private _scale;
|
|
15
|
+
private _worldRotationQuaternion;
|
|
16
|
+
private _localMatrix;
|
|
17
|
+
private _worldMatrix;
|
|
18
|
+
private _updateFlagManager;
|
|
19
|
+
private _isParentDirty;
|
|
20
|
+
private _parentTransformCache;
|
|
21
|
+
private _dirtyFlag;
|
|
22
|
+
private _owner;
|
|
23
|
+
set owner(value: LiteColliderShape | LiteCollider);
|
|
24
|
+
/**
|
|
25
|
+
* Local position.
|
|
26
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
27
|
+
*/
|
|
28
|
+
get position(): Vector3;
|
|
29
|
+
set position(value: Vector3);
|
|
30
|
+
/**
|
|
31
|
+
* Local rotation, defining the rotation by using a unit quaternion.
|
|
32
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
33
|
+
*/
|
|
34
|
+
get rotationQuaternion(): Quaternion;
|
|
35
|
+
set rotationQuaternion(value: Quaternion);
|
|
36
|
+
/**
|
|
37
|
+
* World rotation, defining the rotation by using a unit quaternion.
|
|
38
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
39
|
+
*/
|
|
40
|
+
get worldRotationQuaternion(): Quaternion;
|
|
41
|
+
set worldRotationQuaternion(value: Quaternion);
|
|
42
|
+
/**
|
|
43
|
+
* Local scaling.
|
|
44
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
45
|
+
*/
|
|
46
|
+
get scale(): Vector3;
|
|
47
|
+
set scale(value: Vector3);
|
|
48
|
+
/**
|
|
49
|
+
* Local matrix.
|
|
50
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
51
|
+
*/
|
|
52
|
+
get localMatrix(): Matrix;
|
|
53
|
+
set localMatrix(value: Matrix);
|
|
54
|
+
/**
|
|
55
|
+
* World matrix.
|
|
56
|
+
* @remarks Need to re-assign after modification to ensure that the modification takes effect.
|
|
57
|
+
*/
|
|
58
|
+
get worldMatrix(): Matrix;
|
|
59
|
+
set worldMatrix(value: Matrix);
|
|
60
|
+
/**
|
|
61
|
+
* Set local position by X, Y, Z value.
|
|
62
|
+
* @param x - X coordinate
|
|
63
|
+
* @param y - Y coordinate
|
|
64
|
+
* @param z - Z coordinate
|
|
65
|
+
*/
|
|
66
|
+
setPosition(x: number, y: number, z: number): void;
|
|
67
|
+
/**
|
|
68
|
+
* Set local rotation by the X, Y, Z, and W components of the quaternion.
|
|
69
|
+
* @param x - X component of quaternion
|
|
70
|
+
* @param y - Y component of quaternion
|
|
71
|
+
* @param z - Z component of quaternion
|
|
72
|
+
* @param w - W component of quaternion
|
|
73
|
+
*/
|
|
74
|
+
setRotationQuaternion(x: number, y: number, z: number, w: number): void;
|
|
75
|
+
/**
|
|
76
|
+
* Set local scaling by scaling values along X, Y, Z axis.
|
|
77
|
+
* @param x - Scaling along X axis
|
|
78
|
+
* @param y - Scaling along Y axis
|
|
79
|
+
* @param z - Scaling along Z axis
|
|
80
|
+
*/
|
|
81
|
+
setScale(x: number, y: number, z: number): void;
|
|
82
|
+
/**
|
|
83
|
+
* Register world transform change flag.
|
|
84
|
+
* @returns Change flag
|
|
85
|
+
*/
|
|
86
|
+
registerWorldChangeFlag(): LiteUpdateFlag;
|
|
87
|
+
/**
|
|
88
|
+
* Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
|
|
89
|
+
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
90
|
+
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
|
|
91
|
+
*/
|
|
92
|
+
private _updateWorldPositionFlag;
|
|
93
|
+
/**
|
|
94
|
+
* Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
|
|
95
|
+
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
96
|
+
* Get worldRotationQuaternion: Will trigger the world rotation (in quaternion) update of itself and all parent entities.
|
|
97
|
+
* Get worldRotation: Will trigger the world rotation(in euler and quaternion) update of itself and world rotation(in quaternion) update of all parent entities.
|
|
98
|
+
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix or worldRotationQuaternion) to be false.
|
|
99
|
+
*/
|
|
100
|
+
private _updateWorldRotationFlag;
|
|
101
|
+
/**
|
|
102
|
+
* Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
|
|
103
|
+
* Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
|
|
104
|
+
* Get worldScale: Will trigger the scaling update of itself and all parent entities.
|
|
105
|
+
* In summary, any update of related variables will cause the dirty mark of one of the full process (worldMatrix) to be false.
|
|
106
|
+
*/
|
|
107
|
+
private _updateWorldScaleFlag;
|
|
108
|
+
/**
|
|
109
|
+
* Update all world transform property dirty flag, the principle is the same as above.
|
|
110
|
+
*/
|
|
111
|
+
private _updateAllWorldFlag;
|
|
112
|
+
private _getParentTransform;
|
|
113
|
+
private _isContainDirtyFlags;
|
|
114
|
+
private _isContainDirtyFlag;
|
|
115
|
+
private _setDirtyFlagTrue;
|
|
116
|
+
private _setDirtyFlagFalse;
|
|
117
|
+
private _worldAssociatedChange;
|
|
118
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fastly remove an element from array.
|
|
3
|
+
* @param array - Array
|
|
4
|
+
* @param item - Element
|
|
5
|
+
*/
|
|
6
|
+
export declare function removeFromArray(array: any[], item: any): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Used to update tags.
|
|
9
|
+
*/
|
|
10
|
+
export declare class LiteUpdateFlag {
|
|
11
|
+
private _flags;
|
|
12
|
+
/** Flag. */
|
|
13
|
+
flag: boolean;
|
|
14
|
+
constructor(_flags?: LiteUpdateFlag[]);
|
|
15
|
+
/**
|
|
16
|
+
* Destroy.
|
|
17
|
+
*/
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LitePhysics } from "./LitePhysics";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IBoxColliderShape } from "@galacean/engine-design";
|
|
2
|
+
import { Vector3 } from "@galacean/engine";
|
|
3
|
+
import { LiteColliderShape } from "./LiteColliderShape";
|
|
4
|
+
import { LitePhysicsMaterial } from "../LitePhysicsMaterial";
|
|
5
|
+
/**
|
|
6
|
+
* Box collider shape in Lite.
|
|
7
|
+
*/
|
|
8
|
+
export declare class LiteBoxColliderShape extends LiteColliderShape implements IBoxColliderShape {
|
|
9
|
+
private static _tempBox;
|
|
10
|
+
private _halfSize;
|
|
11
|
+
private _scale;
|
|
12
|
+
/**
|
|
13
|
+
* Init Box Shape.
|
|
14
|
+
* @param uniqueID - UniqueID mark Shape.
|
|
15
|
+
* @param size - Size of Shape.
|
|
16
|
+
* @param material - Material of PhysXCollider.
|
|
17
|
+
*/
|
|
18
|
+
constructor(uniqueID: number, size: Vector3, material: LitePhysicsMaterial);
|
|
19
|
+
/**
|
|
20
|
+
* {@inheritDoc IColliderShape.setPosition }
|
|
21
|
+
*/
|
|
22
|
+
setPosition(position: Vector3): void;
|
|
23
|
+
/**
|
|
24
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
25
|
+
*/
|
|
26
|
+
setWorldScale(scale: Vector3): void;
|
|
27
|
+
/**
|
|
28
|
+
* {@inheritDoc IBoxColliderShape.setSize }
|
|
29
|
+
*/
|
|
30
|
+
setSize(value: Vector3): void;
|
|
31
|
+
private _setBondingBox;
|
|
32
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { IColliderShape, IPhysicsMaterial } from "@galacean/engine-design";
|
|
2
|
+
import { Ray, Vector3 } from "@galacean/engine";
|
|
3
|
+
import { LiteHitResult } from "../LiteHitResult";
|
|
4
|
+
/**
|
|
5
|
+
* Abstract class for collider shapes.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class LiteColliderShape implements IColliderShape {
|
|
8
|
+
private static _ray;
|
|
9
|
+
private static _tempPoint;
|
|
10
|
+
protected constructor();
|
|
11
|
+
/**
|
|
12
|
+
* {@inheritDoc IColliderShape.setRotation }
|
|
13
|
+
*/
|
|
14
|
+
setRotation(rotation: Vector3): void;
|
|
15
|
+
/**
|
|
16
|
+
* {@inheritDoc IColliderShape.setPosition }
|
|
17
|
+
*/
|
|
18
|
+
setPosition(position: Vector3): void;
|
|
19
|
+
/**
|
|
20
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
21
|
+
*/
|
|
22
|
+
abstract setWorldScale(scale: Vector3): void;
|
|
23
|
+
/**
|
|
24
|
+
* {@inheritDoc IColliderShape.setContactOffset }
|
|
25
|
+
*/
|
|
26
|
+
setContactOffset(offset: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* {@inheritDoc IColliderShape.setMaterial }
|
|
29
|
+
*/
|
|
30
|
+
setMaterial(material: IPhysicsMaterial): void;
|
|
31
|
+
/**
|
|
32
|
+
* {@inheritDoc IColliderShape.setUniqueID }
|
|
33
|
+
*/
|
|
34
|
+
setUniqueID(id: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* {@inheritDoc IColliderShape.setIsTrigger }
|
|
37
|
+
*/
|
|
38
|
+
setIsTrigger(value: boolean): void;
|
|
39
|
+
/**
|
|
40
|
+
* {@inheritDoc IColliderShape.destroy }
|
|
41
|
+
*/
|
|
42
|
+
destroy(): void;
|
|
43
|
+
protected _updateHitResult(ray: Ray, rayDistance: number, outHit: LiteHitResult, origin: Vector3, isWorldRay?: boolean): void;
|
|
44
|
+
protected _getLocalRay(ray: Ray): Ray;
|
|
45
|
+
private _getInvModelMatrix;
|
|
46
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ISphereColliderShape } from "@galacean/engine-design";
|
|
2
|
+
import { LiteColliderShape } from "./LiteColliderShape";
|
|
3
|
+
import { Vector3 } from "@galacean/engine";
|
|
4
|
+
import { LitePhysicsMaterial } from "../LitePhysicsMaterial";
|
|
5
|
+
/**
|
|
6
|
+
* Sphere collider shape in Lite.
|
|
7
|
+
*/
|
|
8
|
+
export declare class LiteSphereColliderShape extends LiteColliderShape implements ISphereColliderShape {
|
|
9
|
+
private static _tempSphere;
|
|
10
|
+
private _radius;
|
|
11
|
+
private _maxScale;
|
|
12
|
+
get worldRadius(): number;
|
|
13
|
+
/**
|
|
14
|
+
* Init sphere shape.
|
|
15
|
+
* @param uniqueID - UniqueID mark collider
|
|
16
|
+
* @param radius - Size of SphereCollider
|
|
17
|
+
* @param material - Material of PhysXCollider
|
|
18
|
+
*/
|
|
19
|
+
constructor(uniqueID: number, radius: number, material: LitePhysicsMaterial);
|
|
20
|
+
/**
|
|
21
|
+
* {@inheritDoc ISphereColliderShape.setRadius }
|
|
22
|
+
*/
|
|
23
|
+
setRadius(value: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
26
|
+
*/
|
|
27
|
+
setWorldScale(scale: Vector3): void;
|
|
28
|
+
}
|