UNPKG

@inweb/viewer-three

Version:

JavaScript library for rendering CAD and BIM files in a browser using Three.js

38 lines (34 loc) 1.5 kB
import { Box3Helper, Box3 } from "three"; import { components } from "@inweb/viewer-three"; class ExtentsHelperComponent { constructor(viewer) { this.syncHelper = () => { this.boxHelper.removeFromParent(); if (this.viewer.extents.isEmpty()) return; this.boxHelper.box = this.viewer.extents.clone(); this.viewer.helpers.add(this.boxHelper); }; this.boxHelper = new Box3Helper(new Box3, "#ff0000"); this.viewer = viewer; 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); } } components.registerComponent("ExtentsHelperComponent", (viewer => new ExtentsHelperComponent(viewer))); //# sourceMappingURL=ExtentsHelperComponent.module.js.map