angular-three-rapier 2.2.0
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/README.md +7 -0
- package/esm2022/angular-three-rapier.mjs +5 -0
- package/esm2022/index.mjs +7 -0
- package/esm2022/lib/colliders.mjs +355 -0
- package/esm2022/lib/debug.mjs +46 -0
- package/esm2022/lib/frame-stepper.mjs +46 -0
- package/esm2022/lib/instanced-rigid-bodies.mjs +185 -0
- package/esm2022/lib/joints.mjs +111 -0
- package/esm2022/lib/mesh-collider.mjs +69 -0
- package/esm2022/lib/physics.mjs +362 -0
- package/esm2022/lib/rigid-body.mjs +536 -0
- package/esm2022/lib/shared.mjs +10 -0
- package/esm2022/lib/types.mjs +2 -0
- package/esm2022/lib/utils.mjs +151 -0
- package/fesm2022/angular-three-rapier.mjs +1831 -0
- package/fesm2022/angular-three-rapier.mjs.map +1 -0
- package/index.d.ts +7 -0
- package/lib/colliders.d.ts +93 -0
- package/lib/debug.d.ts +9 -0
- package/lib/frame-stepper.d.ts +10 -0
- package/lib/instanced-rigid-bodies.d.ts +46 -0
- package/lib/joints.d.ts +64 -0
- package/lib/mesh-collider.d.ts +23 -0
- package/lib/physics.d.ts +50 -0
- package/lib/rigid-body.d.ts +104 -0
- package/lib/shared.d.ts +9 -0
- package/lib/types.d.ts +500 -0
- package/lib/utils.d.ts +26 -0
- package/package.json +51 -0
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { ActiveCollisionTypes, CoefficientCombineRule, Collider, ColliderHandle, InteractionGroups, RigidBody, RigidBodyHandle, Rotation, TempContactManifold, Vector, World } from '@dimforge/rapier3d-compat';
|
|
2
|
+
import { NgtObject3D, NgtQuaternion, NgtVector3 } from 'angular-three';
|
|
3
|
+
import { Matrix4, Object3D, Vector3, Vector3Tuple } from 'three';
|
|
4
|
+
export type NgtrRigidBodyAutoCollider = 'ball' | 'cuboid' | 'hull' | 'trimesh' | false;
|
|
5
|
+
export interface NgtrPhysicsOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Set the gravity of the physics world
|
|
8
|
+
* @defaultValue [0, -9.81, 0]
|
|
9
|
+
*/
|
|
10
|
+
gravity: Vector3Tuple;
|
|
11
|
+
/**
|
|
12
|
+
* Amount of penetration the engine wont attempt to correct
|
|
13
|
+
* @defaultValue 0.001
|
|
14
|
+
*/
|
|
15
|
+
allowedLinearError: number;
|
|
16
|
+
/**
|
|
17
|
+
* The number of solver iterations run by the constraints solver for calculating forces.
|
|
18
|
+
* The greater this value is, the most rigid and realistic the physics simulation will be.
|
|
19
|
+
* However a greater number of iterations is more computationally intensive.
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue 4
|
|
22
|
+
*/
|
|
23
|
+
numSolverIterations: number;
|
|
24
|
+
/**
|
|
25
|
+
* Number of addition friction resolution iteration run during the last solver sub-step.
|
|
26
|
+
* The greater this value is, the most realistic friction will be.
|
|
27
|
+
* However a greater number of iterations is more computationally intensive.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue 4
|
|
30
|
+
*/
|
|
31
|
+
numAdditionalFrictionIterations: number;
|
|
32
|
+
/**
|
|
33
|
+
* Number of internal Project Gauss Seidel (PGS) iterations run at each solver iteration.
|
|
34
|
+
* Increasing this parameter will improve stability of the simulation. It will have a lesser effect than
|
|
35
|
+
* increasing `numSolverIterations` but is also less computationally expensive.
|
|
36
|
+
*
|
|
37
|
+
* @defaultValue 1
|
|
38
|
+
*/
|
|
39
|
+
numInternalPgsIterations: number;
|
|
40
|
+
/**
|
|
41
|
+
* The maximal distance separating two objects that will generate predictive contacts
|
|
42
|
+
*
|
|
43
|
+
* @defaultValue 0.002
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
predictionDistance: number;
|
|
47
|
+
/**
|
|
48
|
+
* Minimum number of dynamic bodies in each active island
|
|
49
|
+
*
|
|
50
|
+
* @defaultValue 128
|
|
51
|
+
*/
|
|
52
|
+
minIslandSize: number;
|
|
53
|
+
/**
|
|
54
|
+
* Maximum number of substeps performed by the solver
|
|
55
|
+
*
|
|
56
|
+
* @defaultValue 1
|
|
57
|
+
*/
|
|
58
|
+
maxCcdSubsteps: number;
|
|
59
|
+
/**
|
|
60
|
+
* The Error Reduction Parameter in between 0 and 1, is the proportion of the positional error to be corrected at each time step.
|
|
61
|
+
*
|
|
62
|
+
* @defaultValue 0.8
|
|
63
|
+
*/
|
|
64
|
+
erp: number;
|
|
65
|
+
/**
|
|
66
|
+
* The approximate size of most dynamic objects in the scene.
|
|
67
|
+
*
|
|
68
|
+
* This value is used internally to estimate some length-based tolerance.
|
|
69
|
+
* This value can be understood as the number of units-per-meter in your physical world compared to a human-sized world in meter.
|
|
70
|
+
*
|
|
71
|
+
* @defaultValue 1
|
|
72
|
+
*/
|
|
73
|
+
lengthUnit: number;
|
|
74
|
+
/**
|
|
75
|
+
* Set the base automatic colliders for this physics world
|
|
76
|
+
* All Meshes inside RigidBodies will generate a collider
|
|
77
|
+
* based on this value, if not overridden.
|
|
78
|
+
*/
|
|
79
|
+
colliders?: NgtrRigidBodyAutoCollider;
|
|
80
|
+
/**
|
|
81
|
+
* Set the timestep for the simulation.
|
|
82
|
+
* Setting this to a number (eg. 1/60) will run the
|
|
83
|
+
* simulation at that framerate. Alternatively, you can set this to
|
|
84
|
+
* "vary", which will cause the simulation to always synchronize with
|
|
85
|
+
* the current frame delta times.
|
|
86
|
+
*
|
|
87
|
+
* @defaultValue 1/60
|
|
88
|
+
*/
|
|
89
|
+
timeStep: number | 'vary';
|
|
90
|
+
/**
|
|
91
|
+
* Pause the physics simulation
|
|
92
|
+
*
|
|
93
|
+
* @defaultValue false
|
|
94
|
+
*/
|
|
95
|
+
paused: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Interpolate the world transform using the frame delta times.
|
|
98
|
+
* Has no effect if timeStep is set to "vary".
|
|
99
|
+
*
|
|
100
|
+
* @defaultValue true
|
|
101
|
+
**/
|
|
102
|
+
interpolate: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* The update priority at which the physics simulation should run.
|
|
105
|
+
* Only used when `updateLoop` is set to "follow".
|
|
106
|
+
*
|
|
107
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#taking-over-the-render-loop
|
|
108
|
+
* @defaultValue undefined
|
|
109
|
+
*/
|
|
110
|
+
updatePriority?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Set the update loop strategy for the physics world.
|
|
113
|
+
*
|
|
114
|
+
* If set to "follow", the physics world will be stepped
|
|
115
|
+
* in a `useFrame` callback, managed by @react-three/fiber.
|
|
116
|
+
* You can use `updatePriority` prop to manage the scheduling.
|
|
117
|
+
*
|
|
118
|
+
* If set to "independent", the physics world will be stepped
|
|
119
|
+
* in a separate loop, not tied to the render loop.
|
|
120
|
+
* This is useful when using the "demand" `frameloop` strategy for the
|
|
121
|
+
* @react-three/fiber `<Canvas />`.
|
|
122
|
+
*
|
|
123
|
+
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
|
|
124
|
+
* @defaultValue "follow"
|
|
125
|
+
*/
|
|
126
|
+
updateLoop: 'follow' | 'independent';
|
|
127
|
+
/**
|
|
128
|
+
* Enable debug rendering of the physics world.
|
|
129
|
+
* @defaultValue false
|
|
130
|
+
*/
|
|
131
|
+
debug: boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface NgtrRigidBodyState {
|
|
134
|
+
meshType: 'instancedMesh' | 'mesh';
|
|
135
|
+
rigidBody: RigidBody;
|
|
136
|
+
object: Object3D;
|
|
137
|
+
invertedWorldMatrix: Matrix4;
|
|
138
|
+
setMatrix: (matrix: Matrix4) => void;
|
|
139
|
+
getMatrix: (matrix: Matrix4) => Matrix4;
|
|
140
|
+
/**
|
|
141
|
+
* Required for instanced rigid bodies.
|
|
142
|
+
*/
|
|
143
|
+
scale: Vector3;
|
|
144
|
+
isSleeping: boolean;
|
|
145
|
+
}
|
|
146
|
+
export type NgtrRigidBodyStateMap = Map<RigidBody['handle'], NgtrRigidBodyState>;
|
|
147
|
+
export interface NgtrColliderState {
|
|
148
|
+
collider: Collider;
|
|
149
|
+
object: Object3D;
|
|
150
|
+
/**
|
|
151
|
+
* The parent of which this collider needs to base its
|
|
152
|
+
* world position on, can be empty
|
|
153
|
+
*/
|
|
154
|
+
worldParent?: Object3D;
|
|
155
|
+
}
|
|
156
|
+
export type NgtrColliderStateMap = Map<Collider['handle'], NgtrColliderState>;
|
|
157
|
+
export interface NgtrCollisionTarget {
|
|
158
|
+
rigidBody?: RigidBody;
|
|
159
|
+
collider: Collider;
|
|
160
|
+
rigidBodyObject?: Object3D;
|
|
161
|
+
colliderObject?: Object3D;
|
|
162
|
+
}
|
|
163
|
+
export interface NgtrCollisionPayload {
|
|
164
|
+
/** the object firing the event */
|
|
165
|
+
target: NgtrCollisionTarget;
|
|
166
|
+
/** the other object involved in the event */
|
|
167
|
+
other: NgtrCollisionTarget;
|
|
168
|
+
}
|
|
169
|
+
export interface NgtrCollisionEnterPayload extends NgtrCollisionPayload {
|
|
170
|
+
manifold: TempContactManifold;
|
|
171
|
+
flipped: boolean;
|
|
172
|
+
}
|
|
173
|
+
export interface NgtrCollisionExitPayload extends NgtrCollisionPayload {
|
|
174
|
+
}
|
|
175
|
+
export interface NgtrIntersectionEnterPayload extends NgtrCollisionPayload {
|
|
176
|
+
}
|
|
177
|
+
export interface NgtrIntersectionExitPayload extends NgtrCollisionPayload {
|
|
178
|
+
}
|
|
179
|
+
export interface NgtrContactForcePayload extends NgtrCollisionPayload {
|
|
180
|
+
totalForce: Vector;
|
|
181
|
+
totalForceMagnitude: number;
|
|
182
|
+
maxForceDirection: Vector;
|
|
183
|
+
maxForceMagnitude: number;
|
|
184
|
+
}
|
|
185
|
+
export type NgtrCollisionEnterHandler = (payload: NgtrCollisionEnterPayload) => void;
|
|
186
|
+
export type NgtrCollisionExitHandler = (payload: NgtrCollisionExitPayload) => void;
|
|
187
|
+
export type NgtrIntersectionEnterHandler = (payload: NgtrIntersectionEnterPayload) => void;
|
|
188
|
+
export type NgtrIntersectionExitHandler = (payload: NgtrIntersectionExitPayload) => void;
|
|
189
|
+
export type NgtrContactForceHandler = (payload: NgtrContactForcePayload) => void;
|
|
190
|
+
export interface NgtrEventMapValue {
|
|
191
|
+
onSleep?(): void;
|
|
192
|
+
onWake?(): void;
|
|
193
|
+
onCollisionEnter?: NgtrCollisionEnterHandler;
|
|
194
|
+
onCollisionExit?: NgtrCollisionExitHandler;
|
|
195
|
+
onIntersectionEnter?: NgtrIntersectionEnterHandler;
|
|
196
|
+
onIntersectionExit?: NgtrIntersectionExitHandler;
|
|
197
|
+
onContactForce?: NgtrContactForceHandler;
|
|
198
|
+
}
|
|
199
|
+
export type NgtrEventMap = Map<ColliderHandle | RigidBodyHandle, NgtrEventMapValue>;
|
|
200
|
+
export type NgtrWorldStepCallback = (world: World) => void;
|
|
201
|
+
export type NgtrWorldStepCallbackSet = Set<NgtrWorldStepCallback>;
|
|
202
|
+
export interface NgtrCollisionSource {
|
|
203
|
+
collider: {
|
|
204
|
+
object: Collider;
|
|
205
|
+
events?: NgtrEventMapValue;
|
|
206
|
+
state?: NgtrColliderState;
|
|
207
|
+
};
|
|
208
|
+
rigidBody: {
|
|
209
|
+
object?: RigidBody;
|
|
210
|
+
events?: NgtrEventMapValue;
|
|
211
|
+
state?: NgtrRigidBodyState;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
export type NgtrColliderShape = 'cuboid' | 'trimesh' | 'ball' | 'capsule' | 'convexHull' | 'heightfield' | 'polyline' | 'roundCuboid' | 'cylinder' | 'roundCylinder' | 'cone' | 'roundCone' | 'convexMesh' | 'roundConvexHull' | 'roundConvexMesh';
|
|
215
|
+
export interface NgtrColliderOptions {
|
|
216
|
+
/**
|
|
217
|
+
* The optional name passed to THREE's Object3D
|
|
218
|
+
*/
|
|
219
|
+
name?: string;
|
|
220
|
+
/**
|
|
221
|
+
* Principal angular inertia of this rigid body
|
|
222
|
+
*/
|
|
223
|
+
principalAngularInertia?: Vector3Tuple;
|
|
224
|
+
/**
|
|
225
|
+
* Restitution controls how elastic (aka. bouncy) a contact is. Le elasticity of a contact is controlled by the restitution coefficient
|
|
226
|
+
*/
|
|
227
|
+
restitution?: number;
|
|
228
|
+
/**
|
|
229
|
+
* What happens when two bodies meet. See https://rapier.rs/docs/user_guides/javascript/colliders#friction.
|
|
230
|
+
*/
|
|
231
|
+
restitutionCombineRule?: CoefficientCombineRule;
|
|
232
|
+
/**
|
|
233
|
+
* Friction is a force that opposes the relative tangential motion between two rigid-bodies with colliders in contact.
|
|
234
|
+
* A friction coefficient of 0 implies no friction at all (completely sliding contact) and a coefficient
|
|
235
|
+
* greater or equal to 1 implies a very strong friction. Values greater than 1 are allowed.
|
|
236
|
+
*/
|
|
237
|
+
friction?: number;
|
|
238
|
+
/**
|
|
239
|
+
* What happens when two bodies meet. See https://rapier.rs/docs/user_guides/javascript/colliders#friction.
|
|
240
|
+
*/
|
|
241
|
+
frictionCombineRule?: CoefficientCombineRule;
|
|
242
|
+
/**
|
|
243
|
+
* The bit mask configuring the groups and mask for collision handling.
|
|
244
|
+
*/
|
|
245
|
+
collisionGroups?: InteractionGroups;
|
|
246
|
+
/**
|
|
247
|
+
* The bit mask configuring the groups and mask for solver handling.
|
|
248
|
+
*/
|
|
249
|
+
solverGroups?: InteractionGroups;
|
|
250
|
+
/**
|
|
251
|
+
* The collision types active for this collider.
|
|
252
|
+
*
|
|
253
|
+
* Use `ActiveCollisionTypes` to specify which collision types should be active for this collider.
|
|
254
|
+
*
|
|
255
|
+
* @see https://rapier.rs/javascript3d/classes/Collider.html#setActiveCollisionTypes
|
|
256
|
+
* @see https://rapier.rs/javascript3d/enums/ActiveCollisionTypes.html
|
|
257
|
+
*/
|
|
258
|
+
activeCollisionTypes?: ActiveCollisionTypes;
|
|
259
|
+
/**
|
|
260
|
+
* Sets the uniform density of this collider.
|
|
261
|
+
* If this is set, other mass-properties like the angular inertia tensor are computed
|
|
262
|
+
* automatically from the collider's shape.
|
|
263
|
+
* Cannot be used at the same time as the mass or massProperties values.
|
|
264
|
+
* More info https://rapier.rs/docs/user_guides/javascript/colliders#mass-properties
|
|
265
|
+
*/
|
|
266
|
+
density?: number;
|
|
267
|
+
/**
|
|
268
|
+
* The mass of this collider.
|
|
269
|
+
* Generally, it's not recommended to adjust the mass properties as it could lead to
|
|
270
|
+
* unexpected behaviors.
|
|
271
|
+
* Cannot be used at the same time as the density or massProperties values.
|
|
272
|
+
* More info https://rapier.rs/docs/user_guides/javascript/colliders#mass-properties
|
|
273
|
+
*/
|
|
274
|
+
mass?: number;
|
|
275
|
+
/**
|
|
276
|
+
* The mass properties of this rigid body.
|
|
277
|
+
* Cannot be used at the same time as the density or mass values.
|
|
278
|
+
*/
|
|
279
|
+
massProperties?: {
|
|
280
|
+
mass: number;
|
|
281
|
+
centerOfMass: Vector;
|
|
282
|
+
principalAngularInertia: Vector;
|
|
283
|
+
angularInertiaLocalFrame: Rotation;
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* The contact skin of the collider.
|
|
287
|
+
*
|
|
288
|
+
* The contact skin acts as if the collider was enlarged with a skin of width contactSkin around it, keeping objects further apart when colliding.
|
|
289
|
+
*
|
|
290
|
+
* A non-zero contact skin can increase performance, and in some cases, stability.
|
|
291
|
+
* However it creates a small gap between colliding object (equal to the sum of their skin).
|
|
292
|
+
* If the skin is sufficiently small, this might not be visually significant or can be hidden by the rendering assets.
|
|
293
|
+
*
|
|
294
|
+
* @defaultValue 0
|
|
295
|
+
*/
|
|
296
|
+
contactSkin: number;
|
|
297
|
+
/**
|
|
298
|
+
* Sets whether or not this collider is a sensor.
|
|
299
|
+
*/
|
|
300
|
+
sensor?: boolean;
|
|
301
|
+
}
|
|
302
|
+
export type NgtrRigidBodyType = 'fixed' | 'dynamic' | 'kinematicPosition' | 'kinematicVelocity';
|
|
303
|
+
export interface NgtrRigidBodyOptions extends NgtrColliderOptions {
|
|
304
|
+
/**
|
|
305
|
+
* Whether or not this body can sleep.
|
|
306
|
+
* @defaultValue true
|
|
307
|
+
*/
|
|
308
|
+
canSleep: boolean;
|
|
309
|
+
/** The linear damping coefficient of this rigid-body.*/
|
|
310
|
+
linearDamping?: number;
|
|
311
|
+
/** The angular damping coefficient of this rigid-body.*/
|
|
312
|
+
angularDamping?: number;
|
|
313
|
+
/**
|
|
314
|
+
* The initial linear velocity of this body.
|
|
315
|
+
* @defaultValue [0,0,0]
|
|
316
|
+
*/
|
|
317
|
+
linearVelocity: Vector3Tuple;
|
|
318
|
+
/**
|
|
319
|
+
* The initial angular velocity of this body.
|
|
320
|
+
* @defaultValue [0,0,0]
|
|
321
|
+
*/
|
|
322
|
+
angularVelocity: Vector3Tuple;
|
|
323
|
+
/**
|
|
324
|
+
* The scaling factor applied to the gravity affecting the rigid-body.
|
|
325
|
+
* @defaultValue 1.0
|
|
326
|
+
*/
|
|
327
|
+
gravityScale: number;
|
|
328
|
+
/**
|
|
329
|
+
* The dominance group of this RigidBody. If a rigid body has a higher domiance group,
|
|
330
|
+
* on collision it will be immune to forces originating from the other bodies.
|
|
331
|
+
* https://rapier.rs/docs/user_guides/javascript/rigid_bodies#dominance
|
|
332
|
+
* Default: 0
|
|
333
|
+
*/
|
|
334
|
+
dominanceGroup: number;
|
|
335
|
+
/**
|
|
336
|
+
* Whether or not Continous Collision Detection is enabled for this rigid-body.
|
|
337
|
+
* https://rapier.rs/docs/user_guides/javascript/rigid_bodies#continuous-collision-detection
|
|
338
|
+
* @defaultValue false
|
|
339
|
+
*/
|
|
340
|
+
ccd: boolean;
|
|
341
|
+
/**
|
|
342
|
+
* The maximum prediction distance Soft Continuous Collision-Detection.
|
|
343
|
+
*
|
|
344
|
+
* When set to 0, soft-CCD is disabled.
|
|
345
|
+
*
|
|
346
|
+
* Soft-CCD helps prevent tunneling especially of slow-but-thin to moderately fast objects.
|
|
347
|
+
* The soft CCD prediction distance indicates how far in the object’s path the CCD algorithm is allowed to inspect.
|
|
348
|
+
* Large values can impact performance badly by increasing the work needed from the broad-phase.
|
|
349
|
+
*
|
|
350
|
+
* It is a generally cheaper variant of regular CCD since it relies on predictive constraints instead of shape-cast and substeps.
|
|
351
|
+
*
|
|
352
|
+
* @defaultValue 0
|
|
353
|
+
*/
|
|
354
|
+
softCcdPrediction: number;
|
|
355
|
+
/**
|
|
356
|
+
* Initial position of the RigidBody
|
|
357
|
+
*/
|
|
358
|
+
position?: NgtObject3D['position'];
|
|
359
|
+
/**
|
|
360
|
+
* Initial rotation of the RigidBody
|
|
361
|
+
*/
|
|
362
|
+
rotation?: NgtObject3D['rotation'];
|
|
363
|
+
/**
|
|
364
|
+
* Automatically generate colliders based on meshes inside this
|
|
365
|
+
* rigid body.
|
|
366
|
+
*
|
|
367
|
+
* You can change the default setting globally by setting the colliders
|
|
368
|
+
* prop on the <Physics /> component.
|
|
369
|
+
*
|
|
370
|
+
* Setting this to false will disable automatic colliders.
|
|
371
|
+
*/
|
|
372
|
+
colliders?: NgtrRigidBodyAutoCollider | false;
|
|
373
|
+
/**
|
|
374
|
+
* Set the friction of auto-generated colliders.
|
|
375
|
+
* This does not affect any non-automatic child collider-components.
|
|
376
|
+
*/
|
|
377
|
+
friction?: number;
|
|
378
|
+
/**
|
|
379
|
+
* Set the restitution (bounciness) of auto-generated colliders.
|
|
380
|
+
* This does not affect any non-automatic child collider-components.
|
|
381
|
+
*/
|
|
382
|
+
restitution?: number;
|
|
383
|
+
/**
|
|
384
|
+
* Sets the number of additional solver iterations that will be run for this
|
|
385
|
+
* rigid-body and everything that interacts with it directly or indirectly
|
|
386
|
+
* through contacts or joints.
|
|
387
|
+
*
|
|
388
|
+
* Compared to increasing the global `World.numSolverIteration`, setting this
|
|
389
|
+
* value lets you increase accuracy on only a subset of the scene, resulting in reduced
|
|
390
|
+
* performance loss.
|
|
391
|
+
*/
|
|
392
|
+
additionalSolverIterations?: number;
|
|
393
|
+
/**
|
|
394
|
+
* The default collision groups bitmask for all colliders in this rigid body.
|
|
395
|
+
* Can be customized per-collider.
|
|
396
|
+
*/
|
|
397
|
+
collisionGroups?: InteractionGroups;
|
|
398
|
+
/**
|
|
399
|
+
* The default solver groups bitmask for all colliders in this rigid body.
|
|
400
|
+
* Can be customized per-collider.
|
|
401
|
+
*/
|
|
402
|
+
solverGroups?: InteractionGroups;
|
|
403
|
+
/**
|
|
404
|
+
* The default active collision types for all colliders in this rigid body.
|
|
405
|
+
* Can be customized per-collider.
|
|
406
|
+
*
|
|
407
|
+
* Use `ActiveCollisionTypes` to specify which collision types should be active for this collider.
|
|
408
|
+
*
|
|
409
|
+
* @see https://rapier.rs/javascript3d/classes/Collider.html#setActiveCollisionTypes
|
|
410
|
+
* @see https://rapier.rs/javascript3d/enums/ActiveCollisionTypes.html
|
|
411
|
+
*/
|
|
412
|
+
activeCollisionTypes?: ActiveCollisionTypes;
|
|
413
|
+
/**
|
|
414
|
+
* Locks all rotations that would have resulted from forces on the created rigid-body.
|
|
415
|
+
*/
|
|
416
|
+
lockRotations?: boolean;
|
|
417
|
+
/**
|
|
418
|
+
* Locks all translations that would have resulted from forces on the created rigid-body.
|
|
419
|
+
*/
|
|
420
|
+
lockTranslations?: boolean;
|
|
421
|
+
/**
|
|
422
|
+
* Allow rotation of this rigid-body only along specific axes.
|
|
423
|
+
*/
|
|
424
|
+
enabledRotations?: [x: boolean, y: boolean, z: boolean];
|
|
425
|
+
/**
|
|
426
|
+
* Allow translation of this rigid-body only along specific axes.
|
|
427
|
+
*/
|
|
428
|
+
enabledTranslations?: [x: boolean, y: boolean, z: boolean];
|
|
429
|
+
/**
|
|
430
|
+
* Passed down to the object3d representing this collider.
|
|
431
|
+
*/
|
|
432
|
+
userData?: NgtObject3D['userData'];
|
|
433
|
+
/**
|
|
434
|
+
* Include invisible objects on the collider creation estimation.
|
|
435
|
+
*/
|
|
436
|
+
includeInvisible?: boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Transform the RigidBodyState
|
|
439
|
+
* @internal Do not use. Used internally by the InstancedRigidBodies to alter the RigidBody State
|
|
440
|
+
*/
|
|
441
|
+
transformState?: (state: NgtrRigidBodyState) => NgtrRigidBodyState;
|
|
442
|
+
}
|
|
443
|
+
export type NgtrCuboidArgs = [halfWidth: number, halfHeight: number, halfDepth: number];
|
|
444
|
+
export type NgtrBallArgs = [radius: number];
|
|
445
|
+
export type NgtrCapsuleArgs = [halfHeight: number, radius: number];
|
|
446
|
+
export type NgtrConvexHullArgs = [vertices: ArrayLike<number>];
|
|
447
|
+
export type NgtrHeightfieldArgs = [
|
|
448
|
+
width: number,
|
|
449
|
+
height: number,
|
|
450
|
+
heights: number[],
|
|
451
|
+
scale: {
|
|
452
|
+
x: number;
|
|
453
|
+
y: number;
|
|
454
|
+
z: number;
|
|
455
|
+
}
|
|
456
|
+
];
|
|
457
|
+
export type NgtrTrimeshArgs = [vertices: ArrayLike<number>, indices: ArrayLike<number>];
|
|
458
|
+
export type NgtrPolylineArgs = [vertices: Float32Array, indices: Uint32Array];
|
|
459
|
+
export type NgtrRoundCuboidArgs = [halfWidth: number, halfHeight: number, halfDepth: number, borderRadius: number];
|
|
460
|
+
export type NgtrCylinderArgs = [halfHeight: number, radius: number];
|
|
461
|
+
export type NgtrRoundCylinderArgs = [halfHeight: number, radius: number, borderRadius: number];
|
|
462
|
+
export type NgtrConeArgs = [halfHeight: number, radius: number];
|
|
463
|
+
export type NgtrRoundConeArgs = [halfHeight: number, radius: number, borderRadius: number];
|
|
464
|
+
export type NgtrConvexMeshArgs = [vertices: ArrayLike<number>, indices: ArrayLike<number>];
|
|
465
|
+
export type NgtrRoundConvexHullArgs = [vertices: ArrayLike<number>, indices: ArrayLike<number>, borderRadius: number];
|
|
466
|
+
export type NgtrRoundConvexMeshArgs = [vertices: ArrayLike<number>, indices: ArrayLike<number>, borderRadius: number];
|
|
467
|
+
export interface NgtrSphericalJointParams {
|
|
468
|
+
body1Anchor: NgtVector3;
|
|
469
|
+
body2Anchor: NgtVector3;
|
|
470
|
+
}
|
|
471
|
+
export interface NgtrFixedJointParams {
|
|
472
|
+
body1Anchor: NgtVector3;
|
|
473
|
+
body1LocalFrame: NgtQuaternion;
|
|
474
|
+
body2Anchor: NgtVector3;
|
|
475
|
+
body2LocalFrame: NgtQuaternion;
|
|
476
|
+
}
|
|
477
|
+
export interface NgtrPrismaticJointParams {
|
|
478
|
+
body1Anchor: NgtVector3;
|
|
479
|
+
body2Anchor: NgtVector3;
|
|
480
|
+
axis: NgtVector3;
|
|
481
|
+
limits?: [min: number, max: number];
|
|
482
|
+
}
|
|
483
|
+
export interface NgtrRevoluteJointParams {
|
|
484
|
+
body1Anchor: NgtVector3;
|
|
485
|
+
body2Anchor: NgtVector3;
|
|
486
|
+
axis: NgtVector3;
|
|
487
|
+
limits?: [min: number, max: number];
|
|
488
|
+
}
|
|
489
|
+
export interface NgtrRopeJointParams {
|
|
490
|
+
body1Anchor: NgtVector3;
|
|
491
|
+
body2Anchor: NgtVector3;
|
|
492
|
+
length: number;
|
|
493
|
+
}
|
|
494
|
+
export interface NgtrSpringJointParams {
|
|
495
|
+
body1Anchor: NgtVector3;
|
|
496
|
+
body2Anchor: NgtVector3;
|
|
497
|
+
restLength: number;
|
|
498
|
+
stiffness: number;
|
|
499
|
+
damping: number;
|
|
500
|
+
}
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Quaternion as RapierQuaternion, Vector3 as RapierVector3 } from '@dimforge/rapier3d-compat';
|
|
2
|
+
import { NgtEuler, NgtQuaternion, NgtVector3 } from 'angular-three';
|
|
3
|
+
import { Object3D } from 'three';
|
|
4
|
+
import { NgtrColliderOptions, NgtrColliderShape, NgtrRigidBodyOptions } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a proxy that will create a singleton instance of the given class
|
|
7
|
+
* when a property is accessed, and not before.
|
|
8
|
+
*
|
|
9
|
+
* @returns A proxy and a reset function, so that the instance can created again
|
|
10
|
+
*/
|
|
11
|
+
export declare const createSingletonProxy: <SingletonClass extends object, CreationFn extends () => SingletonClass = () => SingletonClass>(createInstance: CreationFn) => {
|
|
12
|
+
proxy: SingletonClass;
|
|
13
|
+
reset: () => void;
|
|
14
|
+
set: (newInstance: SingletonClass) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function rapierQuaternionToQuaternion({ x, y, z, w }: RapierQuaternion): import("three").Quaternion;
|
|
17
|
+
export declare function vector3ToRapierVector(v: NgtVector3): RapierVector3;
|
|
18
|
+
export declare function quaternionToRapierQuaternion(v: NgtQuaternion): RapierQuaternion;
|
|
19
|
+
export declare function createColliderOptions(object: Object3D, options: NgtrRigidBodyOptions, ignoreMeshColliders?: boolean): {
|
|
20
|
+
colliderOptions: NgtrColliderOptions;
|
|
21
|
+
args: unknown[];
|
|
22
|
+
shape: NgtrColliderShape;
|
|
23
|
+
rotation: NgtEuler;
|
|
24
|
+
position: NgtVector3;
|
|
25
|
+
scale: NgtVector3;
|
|
26
|
+
}[];
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "angular-three-rapier",
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/angular-threejs/angular-three/tree/main/libs/rapier"
|
|
10
|
+
},
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "Chau Tran",
|
|
13
|
+
"email": "nartc7789@gmail.com",
|
|
14
|
+
"url": "https://nartc.me"
|
|
15
|
+
},
|
|
16
|
+
"description": "Physics Rapier for Angular Three",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"angular",
|
|
19
|
+
"threejs",
|
|
20
|
+
"renderer",
|
|
21
|
+
"rapier",
|
|
22
|
+
"physics"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@angular/common": ">=18.0.0 <19.0.0",
|
|
27
|
+
"@angular/core": ">=18.0.0 <19.0.0",
|
|
28
|
+
"@dimforge/rapier3d-compat": "~0.14.0",
|
|
29
|
+
"three": ">=0.148.0 <0.169.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"tslib": "^2.7.0"
|
|
33
|
+
},
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"web-types": [
|
|
36
|
+
"../../node_modules/angular-three/web-types.json"
|
|
37
|
+
],
|
|
38
|
+
"module": "fesm2022/angular-three-rapier.mjs",
|
|
39
|
+
"typings": "index.d.ts",
|
|
40
|
+
"exports": {
|
|
41
|
+
"./package.json": {
|
|
42
|
+
"default": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
".": {
|
|
45
|
+
"types": "./index.d.ts",
|
|
46
|
+
"esm2022": "./esm2022/angular-three-rapier.mjs",
|
|
47
|
+
"esm": "./esm2022/angular-three-rapier.mjs",
|
|
48
|
+
"default": "./fesm2022/angular-three-rapier.mjs"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|