addBody
addBody(physicsApi : Object, type : string, meshOrCollideBox : THREE.Mesh|THREE.Group|THREE.InstancedMesh|THREE.BatchedMesh, properties : Object, bodyProps : Object, options : Object) : Promise<(Object|Array<Object>)>Add a physics body from a mesh or pre-created collideBox. For BatchedMesh/InstancedMesh without instanceMatrixIndex, automatically batches ALL instances.
Parameters
physicsApiObjectThe physics worker API (physics.api).
typestringBody type: 'static', 'dynamic', 'kinematic', 'zone'.
meshOrCollideBoxTHREE.Mesh | THREE.Group | THREE.InstancedMesh | THREE.BatchedMeshMesh, group, InstancedMesh, or BatchedMesh to create physics for, or a pre-created collideBox.
propertiesoptionalObjectPhysics properties (friction, mass, pFrom, pTo, etc.).
Default is
Default is
{}.bodyPropsoptionalObjectBody properties (capsuleRadius, capsuleLength, initialPosition, etc.).
Default is
Default is
{}.optionsoptionalObjectOptional settings.
Default is
Default is
{}.hitboxoptionalTHREE.MeshCustom hitbox mesh (overrides auto-generated collision).debugMaterialoptionalTHREE.MaterialMaterial for debug visualization.sideoptionalnumberBVH side (e.g., THREE.DoubleSide).instanceMatrixIndexoptionalnumberFor InstancedMesh/BatchedMesh: which instance to use. If omitted, ALL instances are batched automatically.sourceGeometryoptionalTHREE.BufferGeometryFor BatchedMesh single instance: optional original geometry (skips extraction from internal buffers).sourceGeometriesoptionalObjectFor BatchedMesh batch mode: optional map of geometryId -> BufferGeometry (skips extraction, slightly faster).customGeometryToBVHScriptoptionalfunctionCustom geometry processing function.
Returns
Promise<(Object|Array<Object>)> — The body API object(s). Returns array for batched BatchedMesh/InstancedMesh.