@perplexdotgg/bounce 1.7.0 → 1.8.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 +1 -1
- package/build/bounce.d.ts +309 -114
- package/build/bounce.js +14586 -15766
- package/docs/documentation.md +14 -16
- package/package.json +5 -5
- package/tsconfig.json +2 -2
- package/vite.config.js +0 -1
package/build/bounce.d.ts
CHANGED
|
@@ -274,65 +274,155 @@ scale: number;
|
|
|
274
274
|
|
|
275
275
|
declare class Body_2 extends Body_base {
|
|
276
276
|
world: World | null;
|
|
277
|
+
/** The current shape of the body. */
|
|
277
278
|
get shape(): Shape | null;
|
|
278
279
|
set shape(newShape: Shape);
|
|
279
|
-
|
|
280
|
+
/** Mainly for internal use. Sets the shape of the body. Typically you should use body.shape = newShape; */
|
|
281
|
+
setShape(newShape: Shape | null, shouldUpdateBody?: boolean): void;
|
|
280
282
|
/**
|
|
281
|
-
*
|
|
283
|
+
* Mainly for internal use. Integrates the linear velocity of a body
|
|
282
284
|
*/
|
|
283
285
|
applyLinearVelocityIntegration(timeStepSizeSeconds: number): void;
|
|
284
286
|
applyAngularVelocityIntegration(timeStepSizeSeconds: number): void;
|
|
285
287
|
/**
|
|
286
|
-
*
|
|
288
|
+
* Mainly for internal use. Applies gravity to a body
|
|
287
289
|
*/
|
|
288
290
|
applyAccelerationIntegration(timeStepSizeSeconds: number, gravity: Vec3, isGravityEnabled: boolean, linearDamping: number, angularDamping: number, maxLinearSpeed: number, maxLinearSpeedSquared: number, maxAngularSpeed: number, maxAngularSpeedSquared: number): void;
|
|
291
|
+
/**
|
|
292
|
+
* Mainly for internal use. Subtracts a rotation delta from the body's orientation.
|
|
293
|
+
*/
|
|
289
294
|
subRotationDelta(rotationDelta: Vec3): void;
|
|
290
295
|
addRotationDelta(rotationDelta: Vec3): void;
|
|
296
|
+
/** Mainly for internal use. Applies a rotation impulse to the body. */
|
|
291
297
|
addRotationPositionImpulse(impulse: Vec3, inverseEffectiveMass: Mat3): void;
|
|
298
|
+
/** Mainly for internal use. Subtracts a rotation impulse from the body's orientation. */
|
|
292
299
|
subRotationPositionImpulse(impulse: Vec3, inverseEffectiveMass: Mat3): void;
|
|
300
|
+
/** Computes the velocity of a point on the body, mainly for internal use but can be useful for spawning debris with the right velocity as well. */
|
|
293
301
|
computePointVelocity(out: Vec3, point: Vec3): void;
|
|
302
|
+
/** Mainly for internal use. Computes the effective inverse inertia vector of the body. */
|
|
294
303
|
computeEffectiveInverseInertiaVector(out: Vec3, rotation: Quat, axis: Vec3): void;
|
|
304
|
+
/** Mainly for internal use. Computes the inverse inertia tensor of the body. */
|
|
295
305
|
computeInverseInertiaTensor(out: Mat3): void;
|
|
306
|
+
/** Mainly for internal use. Computes the velocity of a point relative to the center of mass. */
|
|
296
307
|
computeVelocityOfPointRelativeToCenterOfMass(out: Vec3, point: Vec3): void;
|
|
308
|
+
/** Mainly for internal use. Computes the inverse effective mass of the body in a given direction. */
|
|
297
309
|
computeInverseEffectiveMass(direction: Vec3): number;
|
|
310
|
+
/** Mainly for internal use. Damps the linear velocity of the body. */
|
|
298
311
|
dampLinearVelocity(timeStepSizeSeconds: number, linearDamping: number): void;
|
|
312
|
+
/** Mainly for internal use. Damps the angular velocity of the body. */
|
|
299
313
|
dampAngularVelocity(timeStepSizeSeconds: number, angularDamping: number): void;
|
|
314
|
+
/** Mainly for internal use. Clamps the linear velocity of the body. */
|
|
300
315
|
clampLinearVelocity(maxSpeed: number, maxSpeedSquared: number): void;
|
|
316
|
+
/** Mainly for internal use. Clamps the angular velocity of the body. */
|
|
301
317
|
clampAngularVelocity(maxSpeed: number, maxSpeedSquared: number): void;
|
|
302
|
-
/**
|
|
303
|
-
* direction is in world space
|
|
304
|
-
*/
|
|
318
|
+
/** Mainly for internal use. Computes the supporting face of the body in a given direction. */
|
|
305
319
|
computeSupportingFace(out: Face, subShapeId: number, direction: Vec3, baseOffset: Vec3): void;
|
|
320
|
+
/** Mainly for internal use. Computes the world space surface normal of the body at a given position. */
|
|
306
321
|
computeWorldSpaceSurfaceNormal(outWorldSpaceNormal: Vec3, inWorldSpacePosition: Vec3, subShapeId?: number): void;
|
|
322
|
+
/** Mainly for internal use. Checks if the body has changed since the last commit. */
|
|
307
323
|
hasChanged(): boolean;
|
|
324
|
+
/** Commits the changes of the body, you should call this after changing the position, orientation or mass properties */
|
|
308
325
|
commitChanges(): void;
|
|
326
|
+
/** Applies a linear force to the body. */
|
|
309
327
|
applyLinearForce(force: Vec3): void;
|
|
328
|
+
/** Applies an angular force to the body. */
|
|
310
329
|
applyAngularForce(force: Vec3): void;
|
|
330
|
+
/** Applies a force to the body at a given point. useLocalFrame determines if the point is in local or world space (defaults to world space). */
|
|
311
331
|
applyForce(force: Vec3, point: Vec3, useLocalFrame?: boolean): void;
|
|
332
|
+
/** Applies a linear impulse to the body. */
|
|
312
333
|
applyLinearImpulse(impulse: Vec3): void;
|
|
334
|
+
/** Applies an angular impulse to the body. */
|
|
313
335
|
applyAngularImpulse(impulse: Vec3): void;
|
|
336
|
+
/** Applies an impulse to the body at a given point. useLocalFrame determines if the point is in local or world space (defaults to world space). */
|
|
314
337
|
applyImpulse(impulse: Vec3, point: Vec3, useLocalFrame?: boolean): void;
|
|
338
|
+
/** Clears the linear forces applied to the body. */
|
|
315
339
|
clearLinearForces(): void;
|
|
340
|
+
/** Clears the angular forces applied to the body. */
|
|
316
341
|
clearAngularForces(): void;
|
|
342
|
+
/** Clears both linear and angular forces applied to the body. */
|
|
317
343
|
clearForces(): void;
|
|
344
|
+
/** Mainly for internal use.Checks if the body is ready to sleep based on the sleep time threshold. */
|
|
318
345
|
isReadyToSleep(sleepTimeThreshold: number): boolean;
|
|
319
346
|
sleep(): void;
|
|
320
347
|
wakeUp(): void;
|
|
321
348
|
markBodyAsDirty(): void;
|
|
349
|
+
updateCenterOfMassPosition(): void;
|
|
350
|
+
updateWorldBounds(): void;
|
|
322
351
|
}
|
|
323
352
|
export { Body_2 as Body }
|
|
324
353
|
|
|
325
354
|
declare const Body_base: Monomorph<Body_2, ConvertedInputPropertyDefinitionMap<{
|
|
355
|
+
/** BodyType.static, BodyType.kinematic or BodyType.dynamic */
|
|
326
356
|
type: PropertyDefinition_2<BodyType, true>;
|
|
357
|
+
/** Position of the body's center in world space
|
|
358
|
+
* @default { x: 0, y: 0, z: 0 }
|
|
359
|
+
*/
|
|
327
360
|
position: typeof Vec3;
|
|
361
|
+
/** Orientation of the body in world space. Accepts both quat and eul angle (treated as XYZ order) as input when using .create(), .set() and .reset().
|
|
362
|
+
* @default { x: 0, y: 0, z: 0, w: 1 }
|
|
363
|
+
*/
|
|
328
364
|
orientation: typeof Quat;
|
|
365
|
+
/** Linear velocity of the body
|
|
366
|
+
* @default { x: 0, y: 0, z: 0 }
|
|
367
|
+
*/
|
|
329
368
|
linearVelocity: typeof Vec3;
|
|
369
|
+
/** Angular velocity of the body
|
|
370
|
+
* @default { x: 0, y: 0, z: 0 }
|
|
371
|
+
*/
|
|
330
372
|
angularVelocity: typeof Vec3;
|
|
373
|
+
/** Coefficient of friction of the body, typically between 0 and 1.
|
|
374
|
+
* @default the friction value set in the world options (which itself defaults to 0.5)
|
|
375
|
+
*/
|
|
376
|
+
friction: number;
|
|
377
|
+
/** Whether to use the minimum, maximum or average (default) value for friction between the two bodies involved in a collision
|
|
378
|
+
* @default CoefficientFunctionType.average
|
|
379
|
+
*/
|
|
380
|
+
frictionFunction: PropertyDefinition_2<CoefficientFunctionType, true>;
|
|
381
|
+
/** Coefficient of restitution of the body, typically between 0 and 1. 0 means no bounciness or elasticity. 1 means full bouncy or elastic.
|
|
382
|
+
* @default the restitution value set in the world options (which itself defaults to 0.5)
|
|
383
|
+
*/
|
|
384
|
+
restitution: number;
|
|
385
|
+
/** Whether to use the minimum, maximum or average (default) value for restitution between the two bodies involved in a collision
|
|
386
|
+
* @default CoefficientFunctionType.average
|
|
387
|
+
*/
|
|
388
|
+
restitutionFunction: PropertyDefinition_2<CoefficientFunctionType, true>;
|
|
389
|
+
/** Whether the body is currently sleeping (this is automatically managed) */
|
|
390
|
+
isSleeping: PropertyDefinitionBoolean<true>;
|
|
391
|
+
/** Scale factor for gravity applied to the body. Set to 0 to disable gravity on this body. */
|
|
392
|
+
gravityScale: number;
|
|
393
|
+
/** Density of the body in kilograms per cubic meter. If unspecified, density will be derived from the body's mass and its shape's volume */
|
|
394
|
+
density: number;
|
|
395
|
+
/** Mass of the body in kilograms. Mass is automatically derived from the body's density and its shape's volume, unless the density is set to 0, in which case, the density is derived from the mass. */
|
|
396
|
+
mass: number;
|
|
397
|
+
/** Collision groups the body belongs to
|
|
398
|
+
* @default AllFlag, which means the body belongs to all groups
|
|
399
|
+
*/
|
|
400
|
+
belongsToGroups: PropertyDefinitionNumber<true>;
|
|
401
|
+
/** Collision groups the body can collide with
|
|
402
|
+
* @default AllFlag, which means the body can collide with all groups
|
|
403
|
+
*/
|
|
404
|
+
collidesWithGroups: PropertyDefinitionNumber<true>;
|
|
405
|
+
/** Whether the body is allowed to sleep
|
|
406
|
+
* @default true
|
|
407
|
+
*/
|
|
408
|
+
isSleepingEnabled: PropertyDefinitionBoolean<true>;
|
|
409
|
+
/** Linear damping applied to the body. Set to a negative value to use the world's default linear damping
|
|
410
|
+
* @default -1, which means to use the world's default linear damping
|
|
411
|
+
*/
|
|
412
|
+
linearDamping: number;
|
|
413
|
+
/** Angular damping applied to the body. Set to a negative value to use the world's default angular damping.
|
|
414
|
+
* @default -1, which means to use the world's default angular damping
|
|
415
|
+
*/
|
|
416
|
+
angularDamping: number;
|
|
417
|
+
/** Mainly for internal use. Time the body has been without moving, automatically maintained and used for sleep detection */
|
|
418
|
+
timeWithoutMoving: PropertyDefinitionNumber<true>;
|
|
419
|
+
/** Mainly for internal use. Computed center of mass position in world space. This is automatically updated when the body's shape, position or orientation changes (after commitChanged is called) */
|
|
331
420
|
computedCenterOfMassPosition: PropertyDefinition_2<NoInfer<number[] | {
|
|
332
421
|
x?: number;
|
|
333
422
|
y?: number;
|
|
334
423
|
z?: number;
|
|
335
424
|
} | undefined>, true, typeof Vec3>;
|
|
425
|
+
/** Mainly for internal use. Computed axis-aligned bounding box of the body in world space. This is automatically updated when the body's shape, position or orientation changes (after commitChanged is called) */
|
|
336
426
|
computedBounds: PropertyDefinition_2<NoInfer<PropertyDefinitionMapInput<ConvertedInputPropertyDefinitionMap<{
|
|
337
427
|
min: typeof Vec3;
|
|
338
428
|
max: typeof Vec3;
|
|
@@ -342,6 +432,7 @@ y?: number;
|
|
|
342
432
|
z?: number;
|
|
343
433
|
} | undefined>, true, typeof Vec3>;
|
|
344
434
|
}>> | undefined>, true, typeof Aabb>;
|
|
435
|
+
/** Mainly for internal use. Computed expanded axis-aligned bounding box of the body in world space. This is automatically updated when the body's shape, position or orientation changes (after commitChanged is called) */
|
|
345
436
|
computedExpandedBounds: PropertyDefinition_2<NoInfer<PropertyDefinitionMapInput<ConvertedInputPropertyDefinitionMap<{
|
|
346
437
|
min: typeof Vec3;
|
|
347
438
|
max: typeof Vec3;
|
|
@@ -351,21 +442,31 @@ y?: number;
|
|
|
351
442
|
z?: number;
|
|
352
443
|
} | undefined>, true, typeof Vec3>;
|
|
353
444
|
}>> | undefined>, true, typeof Aabb>;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
445
|
+
/** Mainly for internal use. */
|
|
446
|
+
/** Mainly for internal use. */
|
|
447
|
+
/** Mainly for internal use. This is the type of the current shape, e.g. sphere, box, etc */
|
|
448
|
+
shapeType: PropertyDefinition_2<ShapeType, true>;
|
|
449
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
450
|
+
shape0: PropertyDefinitionReference<Box | null, true>;
|
|
451
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
452
|
+
shape1: PropertyDefinitionReference<Capsule | null, true>;
|
|
453
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
454
|
+
shape2: PropertyDefinitionReference<CompoundShape | null, true>;
|
|
455
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
456
|
+
shape3: PropertyDefinitionReference<ConvexHull | null, true>;
|
|
457
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
458
|
+
shape4: PropertyDefinitionReference<Cylinder | null, true>;
|
|
459
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
460
|
+
shape5: PropertyDefinitionReference<HeightMap | null, true>;
|
|
461
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
462
|
+
shape6: PropertyDefinitionReference<Sphere | null, true>;
|
|
463
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
464
|
+
shape7: PropertyDefinitionReference<TriangleMesh | null, true>;
|
|
465
|
+
/** Mainly for internal use. Used for tracking sleep islands */
|
|
466
|
+
sleepVisitGeneration: PropertyDefinitionNumber<true>;
|
|
467
|
+
/** Mainly for internal use. Inverse mass of the body in kilograms. This is automatically derived from the body's mass. */
|
|
368
468
|
inverseMass: PropertyDefinitionNumber<true>;
|
|
469
|
+
/** Mainly for internal use. Computed local inverse inertia tensor of the body. This is automatically updated when the body's shape changes (after commitChanged is called) */
|
|
369
470
|
computedLocalInverseInertia: PropertyDefinition_2<NoInfer<PropertyDefinitionMapInput<ConvertedInputPropertyDefinitionMap<{
|
|
370
471
|
e0: number;
|
|
371
472
|
e1: number;
|
|
@@ -377,6 +478,7 @@ e6: number;
|
|
|
377
478
|
e7: number;
|
|
378
479
|
e8: number;
|
|
379
480
|
}>> | undefined>, true, typeof Mat3>;
|
|
481
|
+
/** Mainly for internal use. Computed world inverse inertia tensor of the body. This is automatically updated when the body's shape, position or orientation changes (after commitChanged is called) */
|
|
380
482
|
computedWorldInverseInertia: PropertyDefinition_2<NoInfer<PropertyDefinitionMapInput<ConvertedInputPropertyDefinitionMap<{
|
|
381
483
|
e0: number;
|
|
382
484
|
e1: number;
|
|
@@ -388,48 +490,96 @@ e6: number;
|
|
|
388
490
|
e7: number;
|
|
389
491
|
e8: number;
|
|
390
492
|
}>> | undefined>, true, typeof Mat3>;
|
|
391
|
-
|
|
392
|
-
gravityScale: number;
|
|
493
|
+
/** Mainly for internal use. Accumulated linear forces applied to the body. Typically you would use applyForce or applyImpulse instead of directly modifying this property. */
|
|
393
494
|
linearForces: PropertyDefinition_2<NoInfer<number[] | {
|
|
394
495
|
x?: number;
|
|
395
496
|
y?: number;
|
|
396
497
|
z?: number;
|
|
397
498
|
} | undefined>, true, typeof Vec3>;
|
|
499
|
+
/** Mainly for internal use. Accumulated angular forces applied to the body.Typically you would use applyForce or applyImpulse instead of directly modifying this property. */
|
|
398
500
|
angularForces: PropertyDefinition_2<NoInfer<number[] | {
|
|
399
501
|
x?: number;
|
|
400
502
|
y?: number;
|
|
401
503
|
z?: number;
|
|
402
504
|
} | undefined>, true, typeof Vec3>;
|
|
505
|
+
/** Mainly for internal use. Copy of the body used to check what has changed when commiting changes. */
|
|
403
506
|
copyForDiff: PropertyDefinitionReference<NoInfer<Body_2> | null, true>;
|
|
507
|
+
/** Mainly for internal use. A linked list of contact pair references for the body, to allow us to quickly destroy them when the body is destroyed. */
|
|
404
508
|
firstPotentialPairEdge: PropertyDefinitionReference<NoInfer<BodyPairEdge> | null, true>;
|
|
405
|
-
|
|
406
|
-
collidesWithGroups: PropertyDefinitionNumber<true>;
|
|
407
|
-
node: PropertyDefinitionReference<NoInfer<BvhNode> | null, true>;
|
|
408
|
-
shapeType: PropertyDefinition_2<ShapeType, true>;
|
|
409
|
-
shape0: PropertyDefinitionReference<Box | null, true>;
|
|
410
|
-
shape1: PropertyDefinitionReference<Capsule | null, true>;
|
|
411
|
-
shape2: PropertyDefinitionReference<CompoundShape | null, true>;
|
|
412
|
-
shape3: PropertyDefinitionReference<ConvexHull | null, true>;
|
|
413
|
-
shape4: PropertyDefinitionReference<Cylinder | null, true>;
|
|
414
|
-
shape5: PropertyDefinitionReference<HeightMap | null, true>;
|
|
415
|
-
shape6: PropertyDefinitionReference<Sphere | null, true>;
|
|
416
|
-
shape7: PropertyDefinitionReference<TriangleMesh | null, true>;
|
|
417
|
-
isSleepingEnabled: PropertyDefinitionBoolean<true>;
|
|
418
|
-
linearDamping: number;
|
|
419
|
-
angularDamping: number;
|
|
509
|
+
/** Mainly for internal use. A linked list of constraint pair references for the body, to allow us to quickly destroy them when the body is destroyed. */
|
|
420
510
|
firstPotentialConstraintPairEdge: PropertyDefinitionReference<NoInfer<ConstraintPairEdge> | null, true>;
|
|
421
|
-
visitGeneration: PropertyDefinitionNumber<true>;
|
|
422
511
|
}>, PropertyDefinitionMapInput<ConvertedInputPropertyDefinitionMap<{
|
|
512
|
+
/** BodyType.static, BodyType.kinematic or BodyType.dynamic */
|
|
423
513
|
type: PropertyDefinition_2<BodyType, true>;
|
|
514
|
+
/** Position of the body's center in world space
|
|
515
|
+
* @default { x: 0, y: 0, z: 0 }
|
|
516
|
+
*/
|
|
424
517
|
position: typeof Vec3;
|
|
518
|
+
/** Orientation of the body in world space. Accepts both quat and eul angle (treated as XYZ order) as input when using .create(), .set() and .reset().
|
|
519
|
+
* @default { x: 0, y: 0, z: 0, w: 1 }
|
|
520
|
+
*/
|
|
425
521
|
orientation: typeof Quat;
|
|
522
|
+
/** Linear velocity of the body
|
|
523
|
+
* @default { x: 0, y: 0, z: 0 }
|
|
524
|
+
*/
|
|
426
525
|
linearVelocity: typeof Vec3;
|
|
526
|
+
/** Angular velocity of the body
|
|
527
|
+
* @default { x: 0, y: 0, z: 0 }
|
|
528
|
+
*/
|
|
427
529
|
angularVelocity: typeof Vec3;
|
|
530
|
+
/** Coefficient of friction of the body, typically between 0 and 1.
|
|
531
|
+
* @default the friction value set in the world options (which itself defaults to 0.5)
|
|
532
|
+
*/
|
|
533
|
+
friction: number;
|
|
534
|
+
/** Whether to use the minimum, maximum or average (default) value for friction between the two bodies involved in a collision
|
|
535
|
+
* @default CoefficientFunctionType.average
|
|
536
|
+
*/
|
|
537
|
+
frictionFunction: PropertyDefinition_2<CoefficientFunctionType, true>;
|
|
538
|
+
/** Coefficient of restitution of the body, typically between 0 and 1. 0 means no bounciness or elasticity. 1 means full bouncy or elastic.
|
|
539
|
+
* @default the restitution value set in the world options (which itself defaults to 0.5)
|
|
540
|
+
*/
|
|
541
|
+
restitution: number;
|
|
542
|
+
/** Whether to use the minimum, maximum or average (default) value for restitution between the two bodies involved in a collision
|
|
543
|
+
* @default CoefficientFunctionType.average
|
|
544
|
+
*/
|
|
545
|
+
restitutionFunction: PropertyDefinition_2<CoefficientFunctionType, true>;
|
|
546
|
+
/** Whether the body is currently sleeping (this is automatically managed) */
|
|
547
|
+
isSleeping: PropertyDefinitionBoolean<true>;
|
|
548
|
+
/** Scale factor for gravity applied to the body. Set to 0 to disable gravity on this body. */
|
|
549
|
+
gravityScale: number;
|
|
550
|
+
/** Density of the body in kilograms per cubic meter. If unspecified, density will be derived from the body's mass and its shape's volume */
|
|
551
|
+
density: number;
|
|
552
|
+
/** Mass of the body in kilograms. Mass is automatically derived from the body's density and its shape's volume, unless the density is set to 0, in which case, the density is derived from the mass. */
|
|
553
|
+
mass: number;
|
|
554
|
+
/** Collision groups the body belongs to
|
|
555
|
+
* @default AllFlag, which means the body belongs to all groups
|
|
556
|
+
*/
|
|
557
|
+
belongsToGroups: PropertyDefinitionNumber<true>;
|
|
558
|
+
/** Collision groups the body can collide with
|
|
559
|
+
* @default AllFlag, which means the body can collide with all groups
|
|
560
|
+
*/
|
|
561
|
+
collidesWithGroups: PropertyDefinitionNumber<true>;
|
|
562
|
+
/** Whether the body is allowed to sleep
|
|
563
|
+
* @default true
|
|
564
|
+
*/
|
|
565
|
+
isSleepingEnabled: PropertyDefinitionBoolean<true>;
|
|
566
|
+
/** Linear damping applied to the body. Set to a negative value to use the world's default linear damping
|
|
567
|
+
* @default -1, which means to use the world's default linear damping
|
|
568
|
+
*/
|
|
569
|
+
linearDamping: number;
|
|
570
|
+
/** Angular damping applied to the body. Set to a negative value to use the world's default angular damping.
|
|
571
|
+
* @default -1, which means to use the world's default angular damping
|
|
572
|
+
*/
|
|
573
|
+
angularDamping: number;
|
|
574
|
+
/** Mainly for internal use. Time the body has been without moving, automatically maintained and used for sleep detection */
|
|
575
|
+
timeWithoutMoving: PropertyDefinitionNumber<true>;
|
|
576
|
+
/** Mainly for internal use. Computed center of mass position in world space. This is automatically updated when the body's shape, position or orientation changes (after commitChanged is called) */
|
|
428
577
|
computedCenterOfMassPosition: PropertyDefinition_2<NoInfer<number[] | {
|
|
429
578
|
x?: number;
|
|
430
579
|
y?: number;
|
|
431
580
|
z?: number;
|
|
432
581
|
} | undefined>, true, typeof Vec3>;
|
|
582
|
+
/** Mainly for internal use. Computed axis-aligned bounding box of the body in world space. This is automatically updated when the body's shape, position or orientation changes (after commitChanged is called) */
|
|
433
583
|
computedBounds: PropertyDefinition_2<NoInfer<PropertyDefinitionMapInput<ConvertedInputPropertyDefinitionMap<{
|
|
434
584
|
min: typeof Vec3;
|
|
435
585
|
max: typeof Vec3;
|
|
@@ -439,6 +589,7 @@ y?: number;
|
|
|
439
589
|
z?: number;
|
|
440
590
|
} | undefined>, true, typeof Vec3>;
|
|
441
591
|
}>> | undefined>, true, typeof Aabb>;
|
|
592
|
+
/** Mainly for internal use. Computed expanded axis-aligned bounding box of the body in world space. This is automatically updated when the body's shape, position or orientation changes (after commitChanged is called) */
|
|
442
593
|
computedExpandedBounds: PropertyDefinition_2<NoInfer<PropertyDefinitionMapInput<ConvertedInputPropertyDefinitionMap<{
|
|
443
594
|
min: typeof Vec3;
|
|
444
595
|
max: typeof Vec3;
|
|
@@ -448,21 +599,31 @@ y?: number;
|
|
|
448
599
|
z?: number;
|
|
449
600
|
} | undefined>, true, typeof Vec3>;
|
|
450
601
|
}>> | undefined>, true, typeof Aabb>;
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
602
|
+
/** Mainly for internal use. */
|
|
603
|
+
/** Mainly for internal use. */
|
|
604
|
+
/** Mainly for internal use. This is the type of the current shape, e.g. sphere, box, etc */
|
|
605
|
+
shapeType: PropertyDefinition_2<ShapeType, true>;
|
|
606
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
607
|
+
shape0: PropertyDefinitionReference<Box | null, true>;
|
|
608
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
609
|
+
shape1: PropertyDefinitionReference<Capsule | null, true>;
|
|
610
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
611
|
+
shape2: PropertyDefinitionReference<CompoundShape | null, true>;
|
|
612
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
613
|
+
shape3: PropertyDefinitionReference<ConvexHull | null, true>;
|
|
614
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
615
|
+
shape4: PropertyDefinitionReference<Cylinder | null, true>;
|
|
616
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
617
|
+
shape5: PropertyDefinitionReference<HeightMap | null, true>;
|
|
618
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
619
|
+
shape6: PropertyDefinitionReference<Sphere | null, true>;
|
|
620
|
+
/** Mainly for internal use. References to the specific shape instances based on the shape type */
|
|
621
|
+
shape7: PropertyDefinitionReference<TriangleMesh | null, true>;
|
|
622
|
+
/** Mainly for internal use. Used for tracking sleep islands */
|
|
623
|
+
sleepVisitGeneration: PropertyDefinitionNumber<true>;
|
|
624
|
+
/** Mainly for internal use. Inverse mass of the body in kilograms. This is automatically derived from the body's mass. */
|
|
465
625
|
inverseMass: PropertyDefinitionNumber<true>;
|
|
626
|
+
/** Mainly for internal use. Computed local inverse inertia tensor of the body. This is automatically updated when the body's shape changes (after commitChanged is called) */
|
|
466
627
|
computedLocalInverseInertia: PropertyDefinition_2<NoInfer<PropertyDefinitionMapInput<ConvertedInputPropertyDefinitionMap<{
|
|
467
628
|
e0: number;
|
|
468
629
|
e1: number;
|
|
@@ -474,6 +635,7 @@ e6: number;
|
|
|
474
635
|
e7: number;
|
|
475
636
|
e8: number;
|
|
476
637
|
}>> | undefined>, true, typeof Mat3>;
|
|
638
|
+
/** Mainly for internal use. Computed world inverse inertia tensor of the body. This is automatically updated when the body's shape, position or orientation changes (after commitChanged is called) */
|
|
477
639
|
computedWorldInverseInertia: PropertyDefinition_2<NoInfer<PropertyDefinitionMapInput<ConvertedInputPropertyDefinitionMap<{
|
|
478
640
|
e0: number;
|
|
479
641
|
e1: number;
|
|
@@ -485,37 +647,24 @@ e6: number;
|
|
|
485
647
|
e7: number;
|
|
486
648
|
e8: number;
|
|
487
649
|
}>> | undefined>, true, typeof Mat3>;
|
|
488
|
-
|
|
489
|
-
gravityScale: number;
|
|
650
|
+
/** Mainly for internal use. Accumulated linear forces applied to the body. Typically you would use applyForce or applyImpulse instead of directly modifying this property. */
|
|
490
651
|
linearForces: PropertyDefinition_2<NoInfer<number[] | {
|
|
491
652
|
x?: number;
|
|
492
653
|
y?: number;
|
|
493
654
|
z?: number;
|
|
494
655
|
} | undefined>, true, typeof Vec3>;
|
|
656
|
+
/** Mainly for internal use. Accumulated angular forces applied to the body.Typically you would use applyForce or applyImpulse instead of directly modifying this property. */
|
|
495
657
|
angularForces: PropertyDefinition_2<NoInfer<number[] | {
|
|
496
658
|
x?: number;
|
|
497
659
|
y?: number;
|
|
498
660
|
z?: number;
|
|
499
661
|
} | undefined>, true, typeof Vec3>;
|
|
662
|
+
/** Mainly for internal use. Copy of the body used to check what has changed when commiting changes. */
|
|
500
663
|
copyForDiff: PropertyDefinitionReference<NoInfer<Body_2> | null, true>;
|
|
664
|
+
/** Mainly for internal use. A linked list of contact pair references for the body, to allow us to quickly destroy them when the body is destroyed. */
|
|
501
665
|
firstPotentialPairEdge: PropertyDefinitionReference<NoInfer<BodyPairEdge> | null, true>;
|
|
502
|
-
|
|
503
|
-
collidesWithGroups: PropertyDefinitionNumber<true>;
|
|
504
|
-
node: PropertyDefinitionReference<NoInfer<BvhNode> | null, true>;
|
|
505
|
-
shapeType: PropertyDefinition_2<ShapeType, true>;
|
|
506
|
-
shape0: PropertyDefinitionReference<Box | null, true>;
|
|
507
|
-
shape1: PropertyDefinitionReference<Capsule | null, true>;
|
|
508
|
-
shape2: PropertyDefinitionReference<CompoundShape | null, true>;
|
|
509
|
-
shape3: PropertyDefinitionReference<ConvexHull | null, true>;
|
|
510
|
-
shape4: PropertyDefinitionReference<Cylinder | null, true>;
|
|
511
|
-
shape5: PropertyDefinitionReference<HeightMap | null, true>;
|
|
512
|
-
shape6: PropertyDefinitionReference<Sphere | null, true>;
|
|
513
|
-
shape7: PropertyDefinitionReference<TriangleMesh | null, true>;
|
|
514
|
-
isSleepingEnabled: PropertyDefinitionBoolean<true>;
|
|
515
|
-
linearDamping: number;
|
|
516
|
-
angularDamping: number;
|
|
666
|
+
/** Mainly for internal use. A linked list of constraint pair references for the body, to allow us to quickly destroy them when the body is destroyed. */
|
|
517
667
|
firstPotentialConstraintPairEdge: PropertyDefinitionReference<NoInfer<ConstraintPairEdge> | null, true>;
|
|
518
|
-
visitGeneration: PropertyDefinitionNumber<true>;
|
|
519
668
|
}>> & {
|
|
520
669
|
shape: Shape;
|
|
521
670
|
world?: World | null;
|
|
@@ -600,16 +749,6 @@ export declare const enum BodyType {
|
|
|
600
749
|
static = 2
|
|
601
750
|
}
|
|
602
751
|
|
|
603
|
-
declare interface BodyVisitor {
|
|
604
|
-
shouldExit: boolean;
|
|
605
|
-
visit(body: Body_2): void;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
declare interface BodyVisitor_2 {
|
|
609
|
-
shouldExit: boolean;
|
|
610
|
-
visit(body: Body_2): void;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
752
|
export declare class Box extends Box_base implements ConvexShapeInterface {
|
|
614
753
|
type: ShapeType.box;
|
|
615
754
|
world: World | null;
|
|
@@ -735,6 +874,7 @@ declare interface BuildTriangleMeshParams {
|
|
|
735
874
|
declare class BvhModule {
|
|
736
875
|
_intersectTargetBody: Body_2 | null;
|
|
737
876
|
_createPairCallback(bodyB: Body_2): boolean;
|
|
877
|
+
bvhNodePool: PoolClass<BvhNode>;
|
|
738
878
|
world: World;
|
|
739
879
|
options: BvhModuleOptions;
|
|
740
880
|
dynamicTree: BvhTree;
|
|
@@ -742,6 +882,7 @@ declare class BvhModule {
|
|
|
742
882
|
pairs: BodyPairsModule;
|
|
743
883
|
bodiesThatDidRefit: Set<Body_2>;
|
|
744
884
|
constructor(world: World, options?: Partial<BvhModuleOptions>);
|
|
885
|
+
removeBody(body: WithPool<Body_2>): void;
|
|
745
886
|
toArray(array: NumberArray, startOffset: number): number;
|
|
746
887
|
fromArray(array: NumberArray, startOffset: number): number;
|
|
747
888
|
markStaticBodyAsDirty(body: WithPool<Body_2>): void;
|
|
@@ -754,9 +895,9 @@ declare class BvhModule {
|
|
|
754
895
|
removeKinematicBody(body: WithPool<Body_2>): void;
|
|
755
896
|
removeStaticBody(body: WithPool<Body_2>): void;
|
|
756
897
|
iteratePairs(): Generator<BodyPairNode, void, unknown>;
|
|
757
|
-
visitBodiesWithCollision(
|
|
758
|
-
visitBodiesWithCast(
|
|
759
|
-
raycastBodies(
|
|
898
|
+
visitBodiesWithCollision(visitCallback: VisitBodyCallback, aabb: Aabb, belongsToGroups: number, collidesWithGroups: number): void;
|
|
899
|
+
visitBodiesWithCast(visitCallback: VisitBodyCallback, aabb: Aabb, displacement: Vec3, belongsToGroups: number, collidesWithGroups: number): void;
|
|
900
|
+
raycastBodies(visitCallback: VisitBodyCallback, ray: Ray, belongsToGroups: number, collidesWithGroups: number): void;
|
|
760
901
|
}
|
|
761
902
|
|
|
762
903
|
declare interface BvhModuleOptions {
|
|
@@ -803,7 +944,8 @@ objects: PropertyDefinitionReferenceList<Body_2, ReferenceListInputType<typeof B
|
|
|
803
944
|
|
|
804
945
|
export declare class BvhTree {
|
|
805
946
|
options: BvhTreeOptions;
|
|
806
|
-
|
|
947
|
+
bvhTreeNodes: typeof BvhNode.ReferenceList;
|
|
948
|
+
bodyToBvhNodeMap: typeof BvhNode.ReferenceList;
|
|
807
949
|
bodyPool: typeof Body_2.Pool;
|
|
808
950
|
root: BvhNode | null;
|
|
809
951
|
optimizeQueue: BvhNode[];
|
|
@@ -817,6 +959,8 @@ export declare class BvhTree {
|
|
|
817
959
|
rebalance(node: BvhNode): BvhNode;
|
|
818
960
|
refit(node: BvhNode | null): boolean;
|
|
819
961
|
optimizeOncePerFrame(maxNodesToCheck: number): void;
|
|
962
|
+
getBodyNode(body: Body_2): WithPool<BvhNode> | null;
|
|
963
|
+
setBodyNode(body: Body_2 | WithPool<Body_2>, node: BvhNode | WithPool<BvhNode> | null): void;
|
|
820
964
|
splitObjects(outLeft: BvhNode, outRight: BvhNode, nodeToSplit: BvhNode): void;
|
|
821
965
|
createBvhNode(): MonomorphInstanceWithPool<ConvertedInputPropertyDefinitionMap< {
|
|
822
966
|
parent: PropertyDefinitionReference<NoInfer<BvhNode> | null, true>;
|
|
@@ -850,16 +994,16 @@ export declare class BvhTree {
|
|
|
850
994
|
objects: PropertyDefinitionReferenceList<Body_2, ReferenceListInputType<typeof Body_2>>;
|
|
851
995
|
}>> | undefined, BvhNode>;
|
|
852
996
|
destroyBvhNode(node: WithPool<BvhNode>): void;
|
|
853
|
-
insert(
|
|
854
|
-
remove(
|
|
997
|
+
insert(bodyToInsert: WithPool<Body_2>): boolean;
|
|
998
|
+
remove(bodyToRemove: WithPool<Body_2>, shouldRemoveFromDirtyObjects?: boolean): boolean | undefined;
|
|
855
999
|
update(object: WithPool<Body_2>, shouldUpdateDirtyObjects?: boolean): boolean;
|
|
856
1000
|
intersectBody(onHit: (Body: Body_2) => boolean | undefined, bodyToIntersect: Body_2, shouldUpdateDirtyObjects?: boolean): void;
|
|
857
1001
|
intersectAabb(onHit: (Body: Body_2) => boolean, bounds: Aabb, shouldUpdateDirtyObjects?: boolean): void;
|
|
858
1002
|
walk(onNode: (node: BvhNode) => boolean): void;
|
|
859
1003
|
isEmpty(): boolean;
|
|
860
|
-
visitBodiesWithCollision(
|
|
861
|
-
raycastBodies(
|
|
862
|
-
visitBodiesWithCast(
|
|
1004
|
+
visitBodiesWithCollision(visitCallback: VisitBodyCallback, bounds: Aabb, belongsToGroups: number, collidesWithGroups: number, shouldUpdateDirtyObjects?: boolean): void;
|
|
1005
|
+
raycastBodies(visitCallback: VisitBodyCallback, ray: Ray, belongsToGroups: number, collidesWithGroups: number, shouldUpdateDirtyObjects?: boolean): void;
|
|
1006
|
+
visitBodiesWithCast(visitCallback: VisitBodyCallback, bounds: Aabb, displacement: Vec3, belongsToGroups: number, collidesWithGroups: number, shouldUpdateDirtyObjects?: boolean): void;
|
|
863
1007
|
}
|
|
864
1008
|
|
|
865
1009
|
export declare type BvhTreeOptions = {
|
|
@@ -972,7 +1116,6 @@ radius: number;
|
|
|
972
1116
|
|
|
973
1117
|
export declare class CastCollector {
|
|
974
1118
|
static initialEarlyOutFraction: number;
|
|
975
|
-
static shouldEarlyOutFraction: number;
|
|
976
1119
|
earlyOutFraction: number;
|
|
977
1120
|
body2: Body_2 | null;
|
|
978
1121
|
getEarlyOutFraction(): number;
|
|
@@ -983,11 +1126,6 @@ export declare class CastCollector {
|
|
|
983
1126
|
addMiss(): void;
|
|
984
1127
|
}
|
|
985
1128
|
|
|
986
|
-
export declare interface CastRayResult {
|
|
987
|
-
body: Body_2;
|
|
988
|
-
fraction: number;
|
|
989
|
-
}
|
|
990
|
-
|
|
991
1129
|
export declare class CastResult extends CastResult_base {
|
|
992
1130
|
/**
|
|
993
1131
|
* swaps the A and B data
|
|
@@ -1102,7 +1240,8 @@ declare class CollideBodiesModule {
|
|
|
1102
1240
|
collideBodies(bodyA: Body_2, bodyB: Body_2, collideShapesSettings: CollisionSettings, collideBodiesSettings: CollideBodiesSettings, timeStepSizeSeconds: number, isWarmStartingEnabled: boolean, minVelocityForElasticContact: number): void;
|
|
1103
1241
|
collideShape(inShape: Shape, inShapeScale: number, inCenterOfMassTransform: Isometry, ioCollector: CollisionCollector, inCollideShapeSettings: CollisionSettings, inbaseTranslation?: Vec3, mask?: number): void;
|
|
1104
1242
|
castShape(inShape: Shape, inShapeScale: number, inCenterOfMassTransform: Isometry, inDisplacement: Vec3, inShapeCastSettings: CastSettings, inbaseTranslation: Vec3, ioCollector: CastCollector, mask?: number): void;
|
|
1105
|
-
|
|
1243
|
+
castRayApproximate(onHit: (body: Body_2) => boolean | undefined, ray: Ray, belongsToGroups?: number, collidesWithGroups?: number): void;
|
|
1244
|
+
castRay(onHit: (result: CastResult) => boolean | undefined, ray: Ray, returnClosestOnly?: boolean, belongsToGroups?: number, collidesWithGroups?: number): void;
|
|
1106
1245
|
estimateCollisionResponse(result: EstimateCollisionResponseResult, bodyA: Body_2, bodyB: Body_2, timeStepSizeSeconds: number): void;
|
|
1107
1246
|
}
|
|
1108
1247
|
|
|
@@ -1111,10 +1250,7 @@ declare interface CollideBodiesSettings {
|
|
|
1111
1250
|
}
|
|
1112
1251
|
|
|
1113
1252
|
export declare const enum ColliderType {
|
|
1114
|
-
|
|
1115
|
-
findContactManifoldOnly = 1,
|
|
1116
|
-
resolveContact = 2,
|
|
1117
|
-
attractor = 3
|
|
1253
|
+
resolveContact = 0
|
|
1118
1254
|
}
|
|
1119
1255
|
|
|
1120
1256
|
export declare class CollideShapesModule {
|
|
@@ -1125,7 +1261,6 @@ export declare class CollideShapesModule {
|
|
|
1125
1261
|
|
|
1126
1262
|
export declare class CollisionCollector {
|
|
1127
1263
|
static initialEarlyOutFraction: number;
|
|
1128
|
-
static shouldEarlyOutFraction: number;
|
|
1129
1264
|
earlyOutFraction: number;
|
|
1130
1265
|
body2: Body_2 | null;
|
|
1131
1266
|
getEarlyOutFraction(): number;
|
|
@@ -1183,6 +1318,9 @@ faceB: typeof Face;
|
|
|
1183
1318
|
}>> | undefined>;
|
|
1184
1319
|
|
|
1185
1320
|
export declare interface CollisionSettings {
|
|
1321
|
+
/** maximum separation in meters between shapes that will generate collision information. increasing this can improve performance of fast-moving objects at the cost of accuracy and can cause jitter when resting on surfaces. decreasing it can improve accuracy and reduce jitter but may cause fast-moving objects to tunnel through thin geometry or miss collisions, especially if the `speculativeContactDistance` is also small.
|
|
1322
|
+
* @default 0.02
|
|
1323
|
+
*/
|
|
1186
1324
|
maxSeparation: number;
|
|
1187
1325
|
collisionTolerance: number;
|
|
1188
1326
|
activeEdgeMode: ActiveEdgeMode;
|
|
@@ -3400,11 +3538,6 @@ direction: typeof Vec3;
|
|
|
3400
3538
|
length: number;
|
|
3401
3539
|
}>> | undefined>;
|
|
3402
3540
|
|
|
3403
|
-
declare interface RayCastSettings {
|
|
3404
|
-
precision?: QueryPrecision;
|
|
3405
|
-
returnClosestOnly?: boolean;
|
|
3406
|
-
}
|
|
3407
|
-
|
|
3408
3541
|
export declare const enum ReferenceFrame {
|
|
3409
3542
|
local = 0,
|
|
3410
3543
|
world = 1
|
|
@@ -4231,6 +4364,8 @@ declare type Vec3Input = {
|
|
|
4231
4364
|
z?: number;
|
|
4232
4365
|
} | number[] | undefined;
|
|
4233
4366
|
|
|
4367
|
+
declare type VisitBodyCallback = (body: Body_2) => boolean | undefined | void;
|
|
4368
|
+
|
|
4234
4369
|
/**
|
|
4235
4370
|
* a container and API for a physics simulation
|
|
4236
4371
|
*/
|
|
@@ -4248,9 +4383,6 @@ export declare class World {
|
|
|
4248
4383
|
convexHullBuilder: ConvexHullBuilder;
|
|
4249
4384
|
triangleMeshBuilder: TriangleMeshBuilder;
|
|
4250
4385
|
constraintSolver: ConstraintSolver;
|
|
4251
|
-
dynamicBodyCopies: typeof Body_2.ReferenceList;
|
|
4252
|
-
kinematicBodyCopies: typeof Body_2.ReferenceList;
|
|
4253
|
-
staticBodyCopies: typeof Body_2.ReferenceList;
|
|
4254
4386
|
dynamicBodies: typeof Body_2.ReferenceList;
|
|
4255
4387
|
kinematicBodies: typeof Body_2.ReferenceList;
|
|
4256
4388
|
staticBodies: typeof Body_2.ReferenceList;
|
|
@@ -4282,7 +4414,6 @@ export declare class World {
|
|
|
4282
4414
|
triangleMeshCopy: typeof TriangleMesh.Pool;
|
|
4283
4415
|
compoundShapeCopy: typeof CompoundShape.Pool;
|
|
4284
4416
|
heightMapCopy: typeof HeightMap.Pool;
|
|
4285
|
-
bvhNodes: typeof BvhNode.Pool;
|
|
4286
4417
|
constraintPairNode: typeof ConstraintPairNode.Pool;
|
|
4287
4418
|
constraintPairEdge: typeof ConstraintPairEdge.Pool;
|
|
4288
4419
|
body: typeof Body_2.Pool;
|
|
@@ -4299,7 +4430,6 @@ export declare class World {
|
|
|
4299
4430
|
constructor(options?: PartialRecursive<WorldOptions>);
|
|
4300
4431
|
collideBodiesWithBroadphase(timeStepSizeSeconds: number, isWarmStartingEnabled: boolean, minVelocityForElasticContact: number): void;
|
|
4301
4432
|
iterateOverBodyPairsBruteForce(): Generator<NoInfer<[WithPool<Body_2>, WithPool<Body_2>]>, void, unknown>;
|
|
4302
|
-
collideBodiesWithoutBroadphase(timeStepSizeSeconds: number, isWarmStartingEnabled: boolean, minVelocityForElasticContact: number): void;
|
|
4303
4433
|
/**
|
|
4304
4434
|
* integrates the acceleration of all bodies
|
|
4305
4435
|
*/
|
|
@@ -4360,7 +4490,8 @@ export declare class World {
|
|
|
4360
4490
|
didBodiesCollide(bodyA: Body_2, bodyB: Body_2): boolean;
|
|
4361
4491
|
iterateContactManifolds(bodyA?: Body_2, bodyB?: Body_2): Generator<ContactManifold, void, unknown>;
|
|
4362
4492
|
intersectShape(onHit: (result: CollisionResult) => boolean | undefined, shape: Shape, transform: BasicTransform | InputType<BasicTransform>, settings?: ShapeIntersectSettings): void;
|
|
4363
|
-
|
|
4493
|
+
castRayApproximate(onHit: (body: Body_2) => boolean | undefined, ray: Ray, belongsToGroups?: number, collidesWithGroups?: number): void;
|
|
4494
|
+
castRay(onHit: (result: CastResult) => boolean | undefined, ray: Ray, returnClosestOnly?: boolean, belongsToGroups?: number, collidesWithGroups?: number): void;
|
|
4364
4495
|
castShape(onHit: (result: CastShapeResult) => boolean, shape: Shape, transform: BasicTransform, displacementOrEndPosition: Vec3, settings?: ShapeCastSettings): void;
|
|
4365
4496
|
estimateCollisionResponse(result: EstimateCollisionResponseResult, bodyA: Body_2, bodyB: Body_2, settings?: Partial<EstimateCollisionResponseSettings>): void;
|
|
4366
4497
|
toArray(array: number[] | Float32Array | Float64Array, startOffset?: number): number;
|
|
@@ -4373,31 +4504,95 @@ export declare class World {
|
|
|
4373
4504
|
}
|
|
4374
4505
|
|
|
4375
4506
|
declare interface WorldOptions {
|
|
4507
|
+
/** gravity in m/s^2
|
|
4508
|
+
* @default earth gravity ([0, -9.80665, 0])
|
|
4509
|
+
*/
|
|
4376
4510
|
gravity: InputType<Vec3>;
|
|
4377
|
-
|
|
4511
|
+
/** enables/disables gravity on the whole world
|
|
4512
|
+
* @default true
|
|
4513
|
+
*/
|
|
4378
4514
|
isGravityEnabled: boolean;
|
|
4515
|
+
/** default restitution (how elastic/bouncy collisions will be) for created/reset bodies, if unspecified on the body.
|
|
4516
|
+
* @default 0.2
|
|
4517
|
+
*/
|
|
4379
4518
|
restitution: number;
|
|
4519
|
+
/** default friction for created/reset bodies, if unspecified on the body
|
|
4520
|
+
* @default 0.5
|
|
4521
|
+
*/
|
|
4380
4522
|
friction: number;
|
|
4523
|
+
/** the number of iterations to solve velocity constraints. lower is more performant, higher has better results, especially for stacks or conflicting constraints.
|
|
4524
|
+
* @default 6
|
|
4525
|
+
*/
|
|
4381
4526
|
solveVelocityIterations: number;
|
|
4527
|
+
/** the number of iterations to solve position constraints. lower is more performant, higher has better results, especially for stacks or conflicting constraints.
|
|
4528
|
+
* @default 2
|
|
4529
|
+
*/
|
|
4382
4530
|
solvePositionIterations: number;
|
|
4531
|
+
/** default linear damping for created/reset bodies, if unspecified on the body
|
|
4532
|
+
* @default 0.05
|
|
4533
|
+
* @note this is not applied as a constant factor each step, but rather integrated as part of the velocity integration, so it should be stable across different time step sizes
|
|
4534
|
+
*/
|
|
4383
4535
|
linearDamping: number;
|
|
4536
|
+
/** default angular damping for created/reset bodies, if unspecified on the body
|
|
4537
|
+
* @default 0.05
|
|
4538
|
+
* @note this is not applied as a constant factor each step, but rather integrated as part of the velocity integration, so it should be stable across different time step sizes
|
|
4539
|
+
*/
|
|
4384
4540
|
angularDamping: number;
|
|
4541
|
+
/** default friction function for created/reset bodies, if unspecified on the body
|
|
4542
|
+
* @default CoefficientFunctionType.max
|
|
4543
|
+
*/
|
|
4385
4544
|
frictionFunction: CoefficientFunctionType;
|
|
4545
|
+
/** default restitution function for created/reset bodies, if unspecified on the body
|
|
4546
|
+
* @default CoefficientFunctionType.max
|
|
4547
|
+
*/
|
|
4386
4548
|
restitutionFunction: CoefficientFunctionType;
|
|
4549
|
+
/** minimum velocity in m/s for a contact to be treated as elastic instead of inelastic. this is used to prevent jittery resting contacts, while still allowing for elastic collisions at higher speeds. tuning this can help with the stability of stacks and resting contacts. if you are seeing jittery behavior in resting contacts, try increasing this value. if you are seeing objects that should be bouncing not bounce, try decreasing this value.
|
|
4550
|
+
* @default 2
|
|
4551
|
+
*/
|
|
4387
4552
|
minVelocityForElasticContact: number;
|
|
4553
|
+
/** the baumgarte factor to use for position correction. higher values will correct positions faster, but can lead to instability if too high. lower values will be more stable, but can lead to more noticeable sinking and jitter. tuning this can help with the stability of stacks and resting contacts. if you are seeing sinking or noticeable jitter in resting contacts, try increasing this value. if you are seeing instability, try decreasing this value.
|
|
4554
|
+
* @default 0.2
|
|
4555
|
+
*/
|
|
4388
4556
|
baumgarte: number;
|
|
4557
|
+
/** the penetration slop in meters. this is the distance that contact points can penetrate before the solver starts to apply correction. having a small penetration slop can help with the stability of stacks and resting contacts, but can lead to more noticeable jitter. tuning this can help with the stability of stacks and resting contacts. if you are seeing sinking or noticeable jitter in resting contacts, try increasing this value. if you are seeing instability, try decreasing this value.
|
|
4558
|
+
* @default 0.02
|
|
4559
|
+
*/
|
|
4389
4560
|
penetrationSlop: number;
|
|
4561
|
+
/** the maximum penetration distance in meters. this is the maximum distance that the solver will apply correction for penetrations in one solver step.
|
|
4562
|
+
* @default 0.2
|
|
4563
|
+
*/
|
|
4390
4564
|
maxPenetrationDistance: number;
|
|
4565
|
+
/** the speculative contact distance in meters. basically this is the minimum distance two bodies need to be apart before they can be considered to be in contact, to reduce the chance of tunneling, or missed collisions from tiny bounces when at rest.
|
|
4566
|
+
* @default 0.02
|
|
4567
|
+
*/
|
|
4391
4568
|
speculativeContactDistance: number;
|
|
4392
|
-
|
|
4569
|
+
/** maximum linear speed in m/s, used to avoid excessively high speeds that can cause instability in the solver and tunneling through collision geometry. applied during acceleration integration and velocity clamping.
|
|
4570
|
+
* @default 30
|
|
4571
|
+
*/
|
|
4393
4572
|
maxLinearSpeed: number;
|
|
4573
|
+
/** maximum angular speed in rad/s, used to avoid excessively high angular speeds that can cause instability in the solver and tunneling through collision geometry. applied during acceleration integration and velocity clamping.
|
|
4574
|
+
* @default 20
|
|
4575
|
+
*/
|
|
4394
4576
|
maxAngularSpeed: number;
|
|
4577
|
+
/** enables warm starting of contact and constraint impulses by reusing cached lambdas between steps. improves stacking stability but can add jitter if contacts change rapidly.
|
|
4578
|
+
* @default true
|
|
4579
|
+
*/
|
|
4395
4580
|
isWarmStartingEnabled: boolean;
|
|
4581
|
+
/** base collision settings for narrowphase shape-vs-shape tests. `maxSeparation` and active-edge movement direction are overwritten per-pair in the collide-bodies pass.
|
|
4582
|
+
* @default { maxSeparation: 0.02, collisionTolerance: 1e-4, activeEdgeMode: ActiveEdgeMode.CollideOnlyWithActive, collectFacesMode: CollectFacesMode.NoFaces, penetrationTolerance: 1e-4, activeEdgeMovementDirectionX: 0, activeEdgeMovementDirectionY: 0, activeEdgeMovementDirectionZ: 0, backFaceMode: BackFaceMode.IgnoreBackFaces }
|
|
4583
|
+
*/
|
|
4396
4584
|
collideShapeSettings: CollisionSettings;
|
|
4585
|
+
/** fixed time step size in seconds used by `takeOneStep`, `advanceTime`, and collision response estimation. Ignored if `takeOneStep` is called with a specific time step size. A smaller time step size can lead to a more stable simulation, but will be more computationally expensive.
|
|
4586
|
+
* @default 1 / 60
|
|
4587
|
+
*/
|
|
4397
4588
|
timeStepSizeSeconds: number;
|
|
4589
|
+
/** maximum real-time delta to simulate in a single `advanceTime` call to prevent spiral-of-death on slow frames.
|
|
4590
|
+
* @default .2
|
|
4591
|
+
*/
|
|
4398
4592
|
maxTimeToSimulateSeconds: number;
|
|
4399
4593
|
sleepOptions?: PartialRecursive<SleepOptions>;
|
|
4400
4594
|
contactManifoldOptions?: PartialRecursive<ManifoldCacheOptions>;
|
|
4595
|
+
broadphaseOptions: PartialRecursive<BvhModuleOptions>;
|
|
4401
4596
|
}
|
|
4402
4597
|
|
|
4403
4598
|
export { }
|