BIMviewer

Форк
0
/
HideTool.js 
59 строк · 1.7 Кб
1
import {Controller} from "../Controller.js";
2

3
/** @private */
4
class HideTool extends Controller {
5

6
    constructor(parent, cfg) {
7

8
        super(parent, cfg);
9

10
        if (!cfg.buttonElement) {
11
            throw "Missing config: buttonElement";
12
        }
13

14
        const buttonElement = cfg.buttonElement;
15

16
        this.on("enabled", (enabled) => {
17
            if (!enabled) {
18
                buttonElement.classList.add("disabled");
19
            } else {
20
                buttonElement.classList.remove("disabled");
21
            }
22
        });
23

24
        this.on("active", (active) => {
25
            if (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) {
30
                        return;
31
                    }
32
                    pickResult.entity.visible = false;
33
                });
34
            } else {
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;
40
                }
41
            }
42
        });
43

44
        buttonElement.addEventListener("click", (event) => {
45
            if (this.getEnabled()) {
46
                this.bimViewer._sectionTool.hideControl();
47
                const active = this.getActive();
48
                this.setActive(!active);
49
            }
50
            event.preventDefault();
51
        });
52

53
        this.bimViewer.on("reset", () => {
54
            this.setActive(false);
55
        });
56
    }
57
}
58

59
export {HideTool};

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.