Variable: PhysicsShape
constPhysicsShape:Component<{_engineShape: {default:number;type:Float64; };density: {default:number;type:Float32; };dimensions: {default: [number,number,number];type:Vec3; };friction: {default:number;type:Float32; };restitution: {default:number;type:Float32; };shape: {default:"Auto";enum: {Auto:"Auto";Box:"Box";Capsules:"Capsules";ConvexHull:"ConvexHull";Cylinder:"Cylinder";Sphere:"Sphere";TriMesh:"TriMesh"; };type:Enum; }; }>
Defined in: packages/core/src/physics/physicsShape.ts:80
Component for defining the collision shape and material properties of a physics entity.
Remarks
- Material properties (density, restitution, friction) affect physics behavior.
- Higher density increases mass, affecting how the object responds to forces.
Examples
ts
entity.addComponent(PhysicsShape, {
shape: PhysicsShapeType.Auto
})ts
entity.addComponent(PhysicsShape, {
shape: PhysicsShapeType.Sphere,
dimensions: [0.5, 0, 0], // radius = 0.5
restitution: 0.8, // bouncy
friction: 0.1 // low friction
})ts
entity.addComponent(PhysicsShape, {
shape: PhysicsShapeType.Box,
dimensions: [2, 1, 1], // 2x1x1 meters
density: 5.0, // high density
friction: 0.9 // high friction
})