Destruction
Skill ferret-destruction · download all skills · SKILL.md
When to use#
Parts that must dent, crack, snap, shatter or come off: cars, windows, fences, crates, brick walls. Not for the whole-body break and joints of the simple kind (ferret-physics-strength), not for blasts and craters (ferret-physics-combustion-explosions, whose events it reads).
The model#
A hit becomes energy 1/2 mu v^2 (1 - e^2); a failure model of the part's material kind spends it into a ledger (crush, fracture, kinetic, heat, sound) that balances. Ductile parts crush along a force-depth curve, glass breaks by plate stress, wood by bending, stone by cells. Rolling and overturning come out of the rigid dynamics. A style changes numbers or swaps models; physical is the default.
Steps#
const service = new DestructionService({ maxPieces }); a thing:defineThing(block)(parts, links, crush zones, glass panes) ordefineCar(id, 'crown-victoria-cpd87' | 'corvette-c4-87-conv', nodes).- Physics: register
destruction(service)on the host (needs a rigid-body kernel for boxes and cars),bind(id, body). - Look:
installDestructionView(world, service, { nodeOf })(dents, crack stars, shards, detached parts, one sound per break). - Behaviour:
destruction.style {scope:'world'|'level'|'zone'|'entity', name}; presetsphysical,cartoon,hollywood,brittle-world,rigid-world; your own bydestruction.define. - Ask why:
destruction.explain {entity}(style, energy in, where it went, or why nothing broke). - Net and save: send the break record,
replay(record)on the peer;save()/load(). - Motion language:
linkMotion(service, bridge), then(destruction-break who part energy x y z),(destruction-style who name), sensors(damage who), eventsdestruction:*. - Look at it:
?destructionviewer (destruction.stage,.camera,.screenshot,.capture,.launch).
Check afterwards#
balanced(outcome.ledger) is true for every hit; the same seed gives the same pieces; a replay equals the owner's outcome; the piece cap holds; a car at rest stays at rest.
What usually goes wrong#
- Nothing breaks: the kernel has no rigid bodies (light kernel moves spheres only), or the style is
rigid-world, or the energy is below what the part holds (explain). - A car is driven twice: it is bound to a body; the view skips bound things by default.
- Too many shards: far and unseen breaks make none; raise
maxPiecesonly on purpose. - A style does not conserve:
conserve:falseis shown byexplain; that is the style's choice. - A model name in
overrideis unregistered: register it withStyleBook.registerModelfirst.
Files#
reference/destruction.md— Cars that crumple and roll, glass that cracks and shatters, planks that snap, bricks and crates that fly apart; by physics unless a style says otherwise (cartoon, hollywood, rigid-world); the energy ledger, replication by seed, the ?destruction viewer.reference/api-destruction.md— every export of@ferret/destructionwith signature and doc commentreference/api-destruction-2.md— every export of@ferret/destructionwith signature and doc commentreference/api-destruction-3.md— every export of@ferret/destructionwith signature and doc comment