|
@@ -12,15 +12,15 @@
|
|
|
|
|
|
<p class="desc">
|
|
<p class="desc">
|
|
A loader for Rhinoceros 3d files and objects. <br /><br />
|
|
A loader for Rhinoceros 3d files and objects. <br /><br />
|
|
- Rhinoceros is a 3D modeler used to create, edit, analyze, document, render, animate, and translate NURBS curves, surfaces, solids, point clouds, as well as polygon meshes and SubD objects.
|
|
|
|
|
|
+ Rhinoceros is a 3D modeler used to create, edit, analyze, document, render, animate, and translate NURBS curves, surfaces, breps, extrusions, point clouds, as well as polygon meshes and SubD objects.
|
|
[link:https://github.com/mcneel/rhino3dm rhino3dm.js] is compiled to WebAssembly from the open source geometry library [link:https://github.com/mcneel/opennurbs openNURBS].
|
|
[link:https://github.com/mcneel/rhino3dm rhino3dm.js] is compiled to WebAssembly from the open source geometry library [link:https://github.com/mcneel/opennurbs openNURBS].
|
|
- Currently uses rhino3dm.js 0.13.0
|
|
|
|
|
|
+ The loader currently uses <a href="https://www.npmjs.com/package/rhino3dm/v/0.15.0-beta">rhino3dm.js 0.15.0-beta.</a>
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<h2>Supported Conversions</h2>
|
|
<h2>Supported Conversions</h2>
|
|
|
|
|
|
<p>
|
|
<p>
|
|
- [name] loads the following objects to a respective three.js type:
|
|
|
|
|
|
+ The [name] converts Rhino objects to the following three.js types:
|
|
</p>
|
|
</p>
|
|
|
|
|
|
<table>
|
|
<table>
|
|
@@ -42,7 +42,7 @@
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<td>Curve</td>
|
|
<td>Curve</td>
|
|
- <td>[page:Line Line] <sup>1</sup></td>
|
|
|
|
|
|
+ <td>[page:Line Line] <sup> 1</sup></td>
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<td>Mesh</td>
|
|
<td>Mesh</td>
|
|
@@ -50,15 +50,15 @@
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<td>Extrusion</td>
|
|
<td>Extrusion</td>
|
|
- <td>[page:Mesh Mesh] <sup> 2</sup></td>
|
|
|
|
|
|
+ <td>[page:Mesh Mesh]<sup> 2</sup></td>
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<td>BREP</td>
|
|
<td>BREP</td>
|
|
- <td>[page:Object3D Object3D] <sup>2, 3</sup></td>
|
|
|
|
|
|
+ <td>[page:Mesh Mesh]<sup> 2</sup></td>
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<td>SubD</td>
|
|
<td>SubD</td>
|
|
- <td>[page:Mesh Mesh] <sup>4</sup></td>
|
|
|
|
|
|
+ <td>[page:Mesh Mesh]<sup> 3</sup></td>
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<td>InstanceReferences</td>
|
|
<td>InstanceReferences</td>
|
|
@@ -80,19 +80,26 @@
|
|
<td>SpotLight</td>
|
|
<td>SpotLight</td>
|
|
<td>[page:SpotLight SpotLight]</td>
|
|
<td>[page:SpotLight SpotLight]</td>
|
|
</tr>
|
|
</tr>
|
|
|
|
+ <tr>
|
|
|
|
+ <td>File3dm</td>
|
|
|
|
+ <td>[page:Object3D Object3D]<sup> 4</sup></td>
|
|
|
|
+ </tr>
|
|
</table>
|
|
</table>
|
|
|
|
|
|
<p><i>
|
|
<p><i>
|
|
<sup>1</sup> NURBS curves are discretized to a hardcoded resolution.
|
|
<sup>1</sup> NURBS curves are discretized to a hardcoded resolution.
|
|
</i></p>
|
|
</i></p>
|
|
<p><i>
|
|
<p><i>
|
|
- <sup>2</sup> Types which are based on BREPs and NURBS surfaces are represented with their "Render Mesh".
|
|
|
|
|
|
+ <sup>2</sup> Types which are based on BREPs and NURBS surfaces are represented with their "Render Mesh". Render meshes might not be associated with these objects if they have not been displayed in an appropriate display mode in Rhino (i.e. "Shaded", "Rendered", etc), or are created programmatically, for example, via Grasshopper or directly with the rhino3dm library.
|
|
|
|
+ </i></p>
|
|
|
|
+ <p><i>
|
|
|
|
+ <sup>3</sup> SubD objects are represented by subdividing their control net.
|
|
</i></p>
|
|
</i></p>
|
|
<p><i>
|
|
<p><i>
|
|
- <sup>3</sup> BREPS are converted to an Object3D with it's children array populated with BREP Faces
|
|
|
|
|
|
+ <sup>4</sup> Whether a Rhino Document (File3dm) is loaded or parsed, the returned object is an [page:Object3D Object3D] with all Rhino objects (File3dmObject) as children.
|
|
</i></p>
|
|
</i></p>
|
|
<p><i>
|
|
<p><i>
|
|
- <sup>4</sup> SubD objects are represented by subdividing their control net.
|
|
|
|
|
|
+ <sup>5</sup> All resulting three.js objects have useful properties from the Rhino object (i.e. layer index, name, etc.) populated in their userData object.
|
|
</i></p>
|
|
</i></p>
|
|
|
|
|
|
<h2>Code Example</h2>
|
|
<h2>Code Example</h2>
|
|
@@ -101,8 +108,9 @@
|
|
// Instantiate a loader
|
|
// Instantiate a loader
|
|
const loader = new Rhino3dmLoader();
|
|
const loader = new Rhino3dmLoader();
|
|
|
|
|
|
- // Specify path to a folder containing WASM/JS libraries.
|
|
|
|
- loader.setLibraryPath( '/examples/jsm/libs/rhino3dm/' );
|
|
|
|
|
|
+ // Specify path to a folder containing WASM/JS libraries or a CDN.
|
|
|
|
+ //loader.setLibraryPath( '/path_to_library/rhino3dm/' );
|
|
|
|
+ loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/[email protected]/' );
|
|
|
|
|
|
// Load a 3DM file
|
|
// Load a 3DM file
|
|
loader.load(
|
|
loader.load(
|
|
@@ -161,13 +169,66 @@
|
|
[page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
|
|
[page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
|
|
</p>
|
|
</p>
|
|
<p>
|
|
<p>
|
|
- Begin loading from url and call the <em>onLoad</em> function with the geometry.
|
|
|
|
|
|
+ Begin loading from url and call the <em>onLoad</em> function with the resulting Object3d.
|
|
|
|
+ </p>
|
|
|
|
+
|
|
|
|
+ <h3>[method:null parse]( [param:ArrayBuffer buffer], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
|
|
|
|
+ <p>
|
|
|
|
+ [page:ArrayBuffer buffer] — An ArrayBuffer representing the Rhino <em>File3dm</em> document.<br />
|
|
|
|
+ [page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
|
|
|
|
+ [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
|
|
|
|
+ </p>
|
|
|
|
+ <p>
|
|
|
|
+ Parse a File3dm ArrayBuffer and call the <em>onLoad</em> function with the resulting Object3d.
|
|
|
|
+ See <a href="https://github.com/mcneel/rhino-developer-samples/tree/7/rhino3dm/js/SampleParse3dmObjects">this example</a> for further reference.
|
|
</p>
|
|
</p>
|
|
|
|
|
|
|
|
+ <code>
|
|
|
|
+ import rhino3dm from 'https://cdn.jsdelivr.net/npm/[email protected]/rhino3dm.module.js'
|
|
|
|
+
|
|
|
|
+ // Instantiate a loader
|
|
|
|
+ const loader = new Rhino3dmLoader();
|
|
|
|
+
|
|
|
|
+ // Specify path to a folder containing WASM/JS libraries or a CDN.
|
|
|
|
+ loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/[email protected]/' );
|
|
|
|
+
|
|
|
|
+ rhino3dm().then(async m => {
|
|
|
|
+
|
|
|
|
+ console.log('Loaded rhino3dm.');
|
|
|
|
+ const rhino = m; // global
|
|
|
|
+
|
|
|
|
+ // create Rhino Document and add a point to it
|
|
|
|
+ const doc = new rhino.File3dm();
|
|
|
|
+ const ptA = [0, 0, 0];
|
|
|
|
+ const point = new rhino.Point( ptA );
|
|
|
|
+ doc.objects().add( point, null );
|
|
|
|
+
|
|
|
|
+ // create a copy of the doc.toByteArray data to get an ArrayBuffer
|
|
|
|
+ const buffer = new Uint8Array( doc.toByteArray() ).buffer;
|
|
|
|
+
|
|
|
|
+ loader.parse( buffer, function ( object ) {
|
|
|
|
+
|
|
|
|
+ scene.add( object );
|
|
|
|
+
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ </code>
|
|
|
|
+
|
|
<h3>[method:this setLibraryPath]( [param:String value] )</h3>
|
|
<h3>[method:this setLibraryPath]( [param:String value] )</h3>
|
|
<p>
|
|
<p>
|
|
[page:String value] — Path to folder containing the JS and WASM libraries.
|
|
[page:String value] — Path to folder containing the JS and WASM libraries.
|
|
</p>
|
|
</p>
|
|
|
|
+ <code>
|
|
|
|
+ // Instantiate a loader
|
|
|
|
+ const loader = new Rhino3dmLoader();
|
|
|
|
+
|
|
|
|
+ // Specify path to a folder containing the WASM/JS library:
|
|
|
|
+ loader.setLibraryPath( '/path_to_library/rhino3dm/' );
|
|
|
|
+ // or from a CDN:
|
|
|
|
+ loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/[email protected]/' );
|
|
|
|
+ </code>
|
|
|
|
|
|
<h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>
|
|
<h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>
|
|
<p>
|
|
<p>
|