@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
120 lines (119 loc) • 3.52 kB
TypeScript
import type { Skeleton } from "../../Bones/skeleton.js";
import { Vector3 } from "../../Maths/math.vector.js";
import { PhysicsAggregate } from "./physicsAggregate.js";
import { PhysicsConstraint } from "./physicsConstraint.js";
import type { Mesh } from "../../Meshes/mesh.js";
import { PhysicsConstraintType } from "./IPhysicsEnginePlugin.js";
import { TransformNode } from "../../Meshes/transformNode.js";
/**
* Ragdoll bone properties
* @experimental
*/
export declare class RagdollBoneProperties {
/**
* Width of the box shape
*/
width?: number;
/**
* depth of the box shape
*/
depth?: number;
/**
* height of the box shape
*/
height?: number;
/**
* size that will be used of width, depth and height of the shape box
*/
size?: number;
/**
* Type of Physics Constraint used between bones
*/
joint?: number | undefined | PhysicsConstraintType;
/**
* Main rotation axis used by the constraint, in local space
*/
rotationAxis?: Vector3;
/**
* Minimum rotation angle value
*/
min?: number;
/**
* Maximum rotation angle value
*/
max?: number;
/**
* Offset along local axis
*/
boxOffset?: number;
/**
* Axis that need an offset
*/
boneOffsetAxis?: Vector3;
}
/**
* Ragdoll for Physics V2
* @experimental
*/
export declare class Ragdoll {
private _skeleton;
private _scene;
private _rootTransformNode;
private _config;
private _boxConfigs;
private _constraints;
private _bones;
private _initialRotation;
private _initialRotation2;
private _boneNames;
private _transforms;
private _aggregates;
private _ragdollMode;
private _rootBoneName;
private _rootBoneIndex;
private _mass;
private _restitution;
/**
* Pause synchronization between physics and bone position/orientation
*/
pauseSync: boolean;
private _putBoxesInBoneCenter;
private _defaultJoint;
private _defaultJointMin;
private _defaultJointMax;
/**
* Construct a new Ragdoll object. Once ready, it can be made dynamic by calling `Ragdoll` method
* @param skeleton The skeleton containing bones to be physicalized
* @param rootTransformNode The mesh or its transform used by the skeleton
* @param config an array of `RagdollBoneProperties` corresponding to bones and their properties used to instanciate physics bodies
*/
constructor(skeleton: Skeleton, rootTransformNode: Mesh | TransformNode, config: RagdollBoneProperties[]);
/**
* returns an array of created constraints
* @returns array of created constraints
*/
getConstraints(): Array<PhysicsConstraint>;
/**
* Returns the aggregate corresponding to the ragdoll bone index
* @param index ragdoll bone aggregate index
* @returns the aggregate for the bone index for the root aggregate if index is invalid
*/
getAggregate(index: number): PhysicsAggregate;
private _createColliders;
private _initJoints;
private _syncBonesToPhysics;
private _setBoneOrientationToBody;
private _syncBonesAndBoxes;
private _setBodyOrientationToBone;
private _defineRootBone;
private _findNearestParent;
private _init;
/**
* Enable ragdoll mode. Create physics objects and make them dynamic.
*/
ragdoll(): void;
/**
* Dispose resources and remove physics objects
*/
dispose(): void;
}