@inweb/viewer-three
Version:
JavaScript library for rendering CAD and BIM files in a browser using Three.js
2 lines (1 loc) • 1.31 kB
JavaScript
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,(function(e,i){"use strict";class s{constructor(i){this.syncHelper=()=>{this.boxHelper.removeFromParent(),this.viewer.extents.isEmpty()||(this.boxHelper.box=this.viewer.extents.clone(),this.viewer.helpers.add(this.boxHelper))},this.boxHelper=new e.Box3Helper(new e.Box3,"#ff0000"),this.viewer=i,this.viewer.on("geometryend",this.syncHelper),this.viewer.on("clear",this.syncHelper),this.viewer.on("explode",this.syncHelper),this.viewer.on("hide",this.syncHelper),this.viewer.on("isolate",this.syncHelper),this.viewer.on("show",this.syncHelper),this.viewer.on("showall",this.syncHelper)}dispose(){this.boxHelper.removeFromParent(),this.boxHelper.dispose(),this.viewer.off("geometryend",this.syncHelper),this.viewer.off("clear",this.syncHelper),this.viewer.off("explode",this.syncHelper),this.viewer.off("hide",this.syncHelper),this.viewer.off("isolate",this.syncHelper),this.viewer.off("show",this.syncHelper),this.viewer.off("showall",this.syncHelper)}}i.components.registerComponent("ExtentsHelperComponent",(e=>new s(e)))}));