1
import {Controller} from "../Controller.js";
4
class HideTool extends Controller {
6
constructor(parent, cfg) {
10
if (!cfg.buttonElement) {
11
throw "Missing config: buttonElement";
14
const buttonElement = cfg.buttonElement;
16
this.on("enabled", (enabled) => {
18
buttonElement.classList.add("disabled");
20
buttonElement.classList.remove("disabled");
24
this.on("active", (active) => {
26
buttonElement.classList.add("active");
27
this.viewer.cameraControl.doublePickFlyTo = false;
28
this._onPick = this.viewer.cameraControl.on("picked", (pickResult) => {
29
if (!pickResult.entity) {
32
pickResult.entity.visible = false;
35
buttonElement.classList.remove("active");
36
this.viewer.cameraControl.doublePickFlyTo = false;
37
if (this._onPick !== undefined) {
38
this.viewer.cameraControl.off(this._onPick);
39
this._onPick = undefined;
44
buttonElement.addEventListener("click", (event) => {
45
if (this.getEnabled()) {
46
this.bimViewer._sectionTool.hideControl();
47
const active = this.getActive();
48
this.setActive(!active);
50
event.preventDefault();
53
this.bimViewer.on("reset", () => {
54
this.setActive(false);