/
Rhino3dmLoadPlugin.ts
55 lines (50 loc) · 2.29 KB
/
Rhino3dmLoadPlugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
*/
@uiFolderContainer('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)
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}
*/
@onChange(Rhino3dmLoadPlugin.prototype._refresh) @uiToggle()
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}
*/
@onChange(Rhino3dmLoadPlugin.prototype._refresh) @uiToggle()
forceLayerMaterials = false
/**
* Replace meshes with instanced meshes if they have the same parent, geometry and material
* Same as {@link Rhino3dmLoader2.ReplaceWithInstancedMesh}
*/
@onChange(Rhino3dmLoadPlugin.prototype._refresh) @uiToggle()
replaceWithInstancedMesh = false
/**
* Hide all lines, line segments and points in the file
* Same as {@link Rhino3dmLoader2.HideLineMesh}
*/
@onChange(Rhino3dmLoadPlugin.prototype._refresh) @uiToggle()
hideLineMesh = false
protected _refresh() {
Rhino3dmLoader2.ImportMaterials = this.importMaterials
Rhino3dmLoader2.ForceLayerMaterials = this.forceLayerMaterials
Rhino3dmLoader2.ReplaceWithInstancedMesh = this.replaceWithInstancedMesh
Rhino3dmLoader2.HideLineMesh = this.hideLineMesh
}
onAdded(viewer: ThreeViewer) {
if (!window.WebAssembly) throw new Error('Rhino3dmLoadPlugin requires WebAssembly support')
super.onAdded(viewer)
this._refresh()
}
}