Loader →

Rhino3dmLoader

A loader for Rhinoceros 3D files and 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. rhino3dm.js is compiled to WebAssembly from the open source geometry library openNURBS. The loader currently uses rhino3dm.js 8.32.1.

Code Example

const loader = new Rhino3dmLoader();
loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/rhino3dm@8.32.1/' );
const object = await loader.loadAsync( 'models/3dm/Rhino_Logo.3dm' );
scene.add( object );

Import

Rhino3dmLoader is an addon, and must be imported explicitly, see Installation#Addons.

import { Rhino3dmLoader } from 'three/addons/loaders/3DMLoader.js';

Constructor

new Rhino3dmLoader( manager : LoadingManager )

Constructs a new Rhino 3DM loader.

manager

The loading manager.

Methods

._geometryFromData()

Builds a BufferGeometry from a worker payload. Meshes decoded via the fast path arrive as transferable typed arrays (format: 'buffers') and are assembled directly; everything else falls back to the three.js BufferGeometry JSON produced by toThreejsJSON() (older rhino3dm, point clouds, curves, …).

.debug()

Prints debug messages to the browser console.

.decodeObjects( buffer : ArrayBuffer, url : string ) : Promise.<Object3D>

Decodes the 3DM asset data with a Web Worker.

buffer

The raw 3DM asset data as an array buffer.

url

The asset URL.

Returns: A Promise that resolved with the decoded 3D object.

.dispose()

Frees internal resources. This method should be called when the loader is no longer required.

.load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )

Starts loading from the given URL and passes the loaded 3DM asset to the onLoad() callback.

url

The path/URL of the file to be loaded. This can also be a data URI.

onLoad

Executed when the loading process has been finished.

onProgress

Executed while the loading is in progress.

onError

Executed when errors occur.

Overrides: Loader#load

.parse( data : ArrayBuffer, onLoad : function, onError : onErrorCallback )

Parses the given 3DM data and passes the loaded 3DM asset to the onLoad() callback.

data

The raw 3DM asset data as an array buffer.

onLoad

Executed when the loading process has been finished.

onError

Executed when errors occur.

Overrides: Loader#parse

.parseAsync( data : ArrayBuffer ) : Promise.<Object3D>

Parses the given 3DM data and returns a Promise that resolves with the loaded asset.

data

The raw 3DM asset data as an array buffer.

Returns: A Promise that resolves with the decoded 3D object.

.setLibraryPath( path : string ) : Rhino3dmLoader

Path to a folder containing the JS and WASM libraries.

path

The library path to set.

Returns: A reference to this loader.

.setSubdivisionLevel( level : number ) : Rhino3dmLoader

Sets the number of global subdivisions applied to SubD objects before they are meshed for display. The default is 3. Large models with many SubD objects may benefit from a lower value to keep vertex counts manageable.

level

The subdivision level.

Returns: A reference to this loader.

.setWorkerLimit( workerLimit : number ) : Rhino3dmLoader

Sets the maximum number of Web Workers to be used during decoding. A lower limit may be preferable if workers are also for other tasks in the application.

workerLimit

The worker limit.

Returns: A reference to this loader.

Source

examples/jsm/loaders/3DMLoader.js