| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>ConvexObjectBreaker - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <h1 translate="no">ConvexObjectBreaker</h1>
- <section>
- <header>
- <div class="class-description"><p>This class can be used to subdivide a convex Geometry object into pieces.</p>
- <p>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.</p>
- <p>Requisites for the object:</p>
- <ul>
- <li>Mesh object must have a buffer geometry and a material.</li>
- <li>Vertex normals must be planar (not smoothed).</li>
- <li>The geometry must be convex (this is not checked in the library). You can create convex
- geometries with <a href="ConvexGeometry.html">ConvexGeometry</a>. The <a href="BoxGeometry.html">BoxGeometry</a>, <a href="SphereGeometry.html">SphereGeometry</a> and other
- convex primitives can also be used.</li>
- </ul>
- <p>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.</p></div>
- </header>
- <article>
- <h2 class="subsection-title">Import</h2>
- <p><span translate="no">ConvexObjectBreaker</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
- <pre><code class="language-js">import { ConvexObjectBreaker } from 'three/addons/misc/ConvexObjectBreaker.js';</code></pre>
- <div class="container-overview">
- <h2>Constructor</h2>
- <h3 class="name name-method" id="ConvexObjectBreaker" translate="no">new <a href="#ConvexObjectBreaker">ConvexObjectBreaker</a><span class="signature">( minSizeForBreak : <span class="param-type">number</span>, smallDelta : <span class="param-type">number</span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Constructs a new convex object breaker.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>minSizeForBreak</strong>
- </td>
- <td class="description last">
- <p>Min size a debris can have to break.</p>
- <p>Default is <code>1.4</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>smallDelta</strong>
- </td>
- <td class="description last">
- <p>Max distance to consider that a point belongs to a plane.</p>
- <p>Default is <code>0.0001</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="cutByPlane" translate="no">.<a href="#cutByPlane">cutByPlane</a><span class="signature">( object : <span class="param-type"><a href="Object3D.html">Object3D</a></span>, plane : <span class="param-type"><a href="Plane.html">Plane</a></span>, output : <span class="param-type">Object</span> )</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Subdivides the given 3D object into pieces by a plane.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>object</strong>
- </td>
- <td class="description last">
- <p>The 3D object to subdivide.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>plane</strong>
- </td>
- <td class="description last">
- <p>The plane to cut the 3D object.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>output</strong>
- </td>
- <td class="description last">
- <p>An object that stores the pieces.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The number of pieces.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="prepareBreakableObject" translate="no">.<a href="#prepareBreakableObject">prepareBreakableObject</a><span class="signature">( object : <span class="param-type"><a href="Object3D.html">Object3D</a></span>, mass : <span class="param-type">number</span>, velocity : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, angularVelocity : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, breakable : <span class="param-type">boolean</span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Must be called for all 3D objects that should be breakable.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>object</strong>
- </td>
- <td class="description last">
- <p>The 3D object. It must have a convex geometry.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>mass</strong>
- </td>
- <td class="description last">
- <p>The 3D object's mass in kg. Must be greater than <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>velocity</strong>
- </td>
- <td class="description last">
- <p>The 3D object's velocity.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>angularVelocity</strong>
- </td>
- <td class="description last">
- <p>The 3D object's angular velocity.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>breakable</strong>
- </td>
- <td class="description last">
- <p>Whether the 3D object is breakable or not.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <h3 class="name name-method" id="subdivideByImpact" translate="no">.<a href="#subdivideByImpact">subdivideByImpact</a><span class="signature">( object : <span class="param-type"><a href="Object3D.html">Object3D</a></span>, pointOfImpact : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, normal : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, maxRadialIterations : <span class="param-type">number</span>, maxRandomIterations : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.<<a href="Object3D.html">Object3D</a>></span> </h3>
- <div class="method">
- <div class="description">
- <p>Subdivides the given 3D object into pieces by an impact (meaning another object hits
- the given 3D object at a certain surface point).</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>object</strong>
- </td>
- <td class="description last">
- <p>The 3D object to subdivide.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>pointOfImpact</strong>
- </td>
- <td class="description last">
- <p>The point of impact.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>normal</strong>
- </td>
- <td class="description last">
- <p>The impact normal.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>maxRadialIterations</strong>
- </td>
- <td class="description last">
- <p>Iterations for radial cuts.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>maxRandomIterations</strong>
- </td>
- <td class="description last">
- <p>Max random iterations for not-radial cuts.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The array of pieces.</dt>
- </dl>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/misc/ConvexObjectBreaker.js" translate="no" target="_blank" rel="noopener">examples/jsm/misc/ConvexObjectBreaker.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|