Skip to main content

soft_body_events

The tears applied during a step, whether they were generated by the simulation itself or requested with SoftBody.tearEdge, are reported the same way as the collision events: by giving an event queue (EventQueue.drainSoftBodyTearEvents) to the step. Each event (a SoftBodyTearEvent) identifies the soft-body that tore and gives the pieces it was split into, so the rendering of the scene can be updated accordingly:

// Tears applied during a step are reported through the event queue.
let eventQueue = new RAPIER.EventQueue(true);
world.step(eventQueue);
eventQueue.drainSoftBodyTearEvents((event) => {
console.log("Soft body", event.softBody(), "tore:", event.numPieces(), "pieces split off");
});