Capítulo 530 de 859
This class can be used to subdivide a convex Geometry object into pieces.
Use the function prepareBreakableObject to prepare a Mesh object to be broken. Then, call the various functions to subdivide the object (subdivideByImpact, cutByPlane). Sub-objects that are product of subdivision don't need prepareBreakableObject to be called on them.
Requisites for the object:
Note: This lib adds member variables to object's userData member (see prepareBreakableObject function) Use with caution and read the code when using with other libs.
import { ConvexObjectBreaker } from 'three/addons/misc/ConvexObjectBreaker.js';
Constructor
| Signature |
|---|
new ConvexObjectBreaker( minSizeForBreak : number, smallDelta : number ) |
Methods
| Method | Description |
|---|---|
.cutByPlane( object : Object3D, plane : Plane, output : Object ) : number | Subdivides the given 3D object into pieces by a plane. |
.prepareBreakableObject( object : Object3D, mass : number, velocity : Vector3, angularVelocity : Vector3, breakable : boolean ) | Must be called for all 3D objects that should be breakable. |
.subdivideByImpact( object : Object3D, pointOfImpact : Vector3, normal : Vector3, maxRadialIterations : number, maxRandomIterations : number ) : Array.<Object3D> | Subdivides the given 3D object into pieces by an impact (meaning another object hits the given 3D object at a certain surface point). |