threepipe
Version:
A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.
72 lines (65 loc) • 2.84 kB
text/typescript
import {onChange} from 'ts-browser-helpers'
import {Importer, Rhino3dmLoader2} from '../../assetmanager'
import {BaseImporterPlugin} from '../base/BaseImporterPlugin'
import {IUiConfigContainer, uiFolderContainer, UiObjectConfig, uiToggle} from 'uiconfig.js'
import {ThreeViewer} from '../../viewer'
/**
* Adds support for loading Rhino `.3dm`, `model/vnd.3dm`, `model/3dm` files and data uris.
* @category Plugins
*/
('Rhino 3dm Loader')
export class Rhino3dmLoadPlugin extends BaseImporterPlugin implements IUiConfigContainer {
public static readonly PluginType = 'Rhino3dmLoadPlugin'
protected _importer = new Importer(Rhino3dmLoader2, ['3dm'], ['model/vnd.3dm', 'model/3dm'], true)
declare uiConfig: UiObjectConfig
/**
* Import materials from the file based on material source and color source. If false, a default material will be used
* Same as {@link Rhino3dmLoader2.ImportMaterials}
*/
(Rhino3dmLoadPlugin.prototype._refresh) ()
importMaterials = true
/**
* Force layer materials even if material/color source is not from layer. Only works if {@link importMaterials} is true
* Same as {@link Rhino3dmLoader2.ForceLayerMaterials}
*/
(Rhino3dmLoadPlugin.prototype._refresh) ()
forceLayerMaterials = false
/**
* Replace meshes with instanced meshes if they have the same parent, geometry and material
* Same as {@link Rhino3dmLoader2.ReplaceWithInstancedMesh}
*/
(Rhino3dmLoadPlugin.prototype._refresh) ()
replaceWithInstancedMesh = false
/**
* Hide all lines, line segments and points in the file
* Same as {@link Rhino3dmLoader2.HideLineMesh}
*/
(Rhino3dmLoadPlugin.prototype._refresh) ()
hideLineMesh = false
/**
* Hide all points in the file
*/
(Rhino3dmLoadPlugin.prototype._refresh)
()
hidePointMesh = true
/**
* Remove strings from userData
*/
(Rhino3dmLoadPlugin.prototype._refresh)
()
loadUserDataStrings = true
protected _refresh() {
Rhino3dmLoader2.ImportMaterials = this.importMaterials
Rhino3dmLoader2.ForceLayerMaterials = this.forceLayerMaterials
Rhino3dmLoader2.ReplaceWithInstancedMesh = this.replaceWithInstancedMesh
Rhino3dmLoader2.HideLineMesh = this.hideLineMesh
Rhino3dmLoader2.HidePointMesh = this.hidePointMesh
Rhino3dmLoader2.LoadUserDataStrings = this.loadUserDataStrings
Rhino3dmLoader2.LoadUserDataWarnings = false
}
onAdded(viewer: ThreeViewer) {
if (!window.WebAssembly) throw new Error('Rhino3dmLoadPlugin requires WebAssembly support')
super.onAdded(viewer)
this._refresh()
}
}