threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Rhino3dmLoadPlugin.ts 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import {onChange} from 'ts-browser-helpers'
  2. import {Importer, Rhino3dmLoader2} from '../../assetmanager'
  3. import {BaseImporterPlugin} from '../base/BaseImporterPlugin'
  4. import {IUiConfigContainer, uiFolderContainer, UiObjectConfig, uiToggle} from 'uiconfig.js'
  5. import {ThreeViewer} from '../../viewer'
  6. /**
  7. * Adds support for loading Rhino `.3dm`, `model/vnd.3dm`, `model/3dm` files and data uris.
  8. * @category Plugins
  9. */
  10. @uiFolderContainer('Rhino 3dm Loader')
  11. export class Rhino3dmLoadPlugin extends BaseImporterPlugin implements IUiConfigContainer {
  12. public static readonly PluginType = 'Rhino3dmLoadPlugin'
  13. protected _importer = new Importer(Rhino3dmLoader2, ['3dm'], ['model/vnd.3dm', 'model/3dm'], true)
  14. uiConfig!: UiObjectConfig
  15. /**
  16. * Import materials from the file based on material source and color source. If false, a default material will be used
  17. * Same as {@link Rhino3dmLoader2.ImportMaterials}
  18. */
  19. @onChange(Rhino3dmLoadPlugin.prototype._refresh) @uiToggle()
  20. importMaterials = true
  21. /**
  22. * Force layer materials even if material/color source is not from layer. Only works if {@link importMaterials} is true
  23. * Same as {@link Rhino3dmLoader2.ForceLayerMaterials}
  24. */
  25. @onChange(Rhino3dmLoadPlugin.prototype._refresh) @uiToggle()
  26. forceLayerMaterials = false
  27. /**
  28. * Replace meshes with instanced meshes if they have the same parent, geometry and material
  29. * Same as {@link Rhino3dmLoader2.ReplaceWithInstancedMesh}
  30. */
  31. @onChange(Rhino3dmLoadPlugin.prototype._refresh) @uiToggle()
  32. replaceWithInstancedMesh = false
  33. /**
  34. * Hide all lines, line segments and points in the file
  35. * Same as {@link Rhino3dmLoader2.HideLineMesh}
  36. */
  37. @onChange(Rhino3dmLoadPlugin.prototype._refresh) @uiToggle()
  38. hideLineMesh = false
  39. protected _refresh() {
  40. Rhino3dmLoader2.ImportMaterials = this.importMaterials
  41. Rhino3dmLoader2.ForceLayerMaterials = this.forceLayerMaterials
  42. Rhino3dmLoader2.ReplaceWithInstancedMesh = this.replaceWithInstancedMesh
  43. Rhino3dmLoader2.HideLineMesh = this.hideLineMesh
  44. }
  45. onAdded(viewer: ThreeViewer) {
  46. super.onAdded(viewer)
  47. this._refresh()
  48. }
  49. }