FERRETGame engine over Babylon.js
Ferret

@ferret/physics-strength

finite strength: bodies that take damage and break into pieces, links that break.

6 exports · source in packages/physics-strength/src

Functions

strength function

function strength(): StrengthCapability

packages/physics-strength/src/index.ts:66

Interfaces

BreakEvent interface

interface BreakEvent

seed: the same seed on another machine (breakNow(target, point, seed)) gives the same pieces and the same scatter.

entity?: Entity
body: Body
point: Vec3
impulse: number
pieces: Entity[]
seed: number

packages/physics-strength/src/index.ts:39

DamageEvent interface

interface DamageEvent
entity?: Entity
body: Body
amount: number
health: number

packages/physics-strength/src/index.ts:37

JointDef interface

interface JointDef
type: ConstraintType
a: Entity | Body
b: Entity | Body
length?: number
stiffness?: number
damping?: number
tensile?: numbertensile strength of the material, Pa; with area it gives the force the joint holds: σ·A
area?: numbercross-section, m²
maxForce?: numberthe force held, N, when it is not given as strength and area
userData?: unknown

packages/physics-strength/src/index.ts:22

StrengthCapability interface

interface StrengthCapability extends Capability
joint(def: JointDef): ConstraintJoin two bodies with a link that breaks.
damage(target: Entity | Body, amount: number, point?: Vec3): numberTake damage off a body (an explosion, a command); breaks it at zero.
breakNow(target: Entity | Body, point?: Vec3, seed?: number): voidBreak a body now, whatever its toughness (a blast that passed its rupture limit).
health(target: Entity | Body): numberWhat a body has left (its toughness when untouched; Infinity when unbreakable).

packages/physics-strength/src/index.ts:41

Constants

STRENGTH_DEFAULTS const

const STRENGTH_DEFAULTS: { toughness: number; threshold: number; scale: number; pieces: number; burst: number; maxPieces: number; }

maxPieces: pieces alive at once over the whole world; past it a body still breaks (the event) but leaves no new pieces.

packages/physics-strength/src/index.ts:20