UNPKG

@realsee/dnalogel

Version:
63 lines (62 loc) 2.44 kB
var d = Object.defineProperty; var l = (s, i, e) => i in s ? d(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e; var t = (s, i, e) => (l(s, typeof i != "symbol" ? i + "" : i, e), e); import * as m from "three"; import { addIfNotExists as a } from "../../shared-utils/three/addIfNotExists.js"; import { Subscribe as v } from "../../shared-utils/Subscribe.js"; import { tag as f } from "../../shared-utils/tag.js"; import { boundingBox as b } from "../../shared-utils/Object3DHelper/utils/boundingBox.js"; import { getFiveDomEvent as c } from "../utils/getFiveDomEvent.js"; import "../../shared-utils/positionToVector3.js"; import "../../shared-utils/five/vector3ToScreen.js"; import "../../shared-utils/five/FiveDomEvents.js"; import "../../shared-utils/three/getObjectVisible.js"; import "../../shared-utils/five/calculateThreeMouse.js"; class B extends v { constructor(e) { var o, r, h; super(); t(this, "type"); t(this, "tag"); t(this, "rawData"); t(this, "model"); t(this, "five"); t(this, "group"); t(this, "enabled", !1); t(this, "fiveDomEvents"); this.five = e.five, this.model = e.model, this.group = e.group, this.type = e.type, this.rawData = e.rawData, this.fiveDomEvents = c(this.five); const n = (h = (r = (o = e.position) != null ? o : this.model.worldCenter) != null ? r : this.model.center) != null ? h : b(this.model).getCenter(new m.Vector3()); this.tag = f(this.five, n); } get container() { return this.tag.container; } get state() { return { visible: this.model.visible, enabled: this.enabled }; } show() { this.tag.show(), this.model.visible = !0, this.five.needsRender = !0, this.emit("show"); } hide() { this.tag.hide(), this.model.visible = !1, this.five.needsRender = !0, this.emit("hide"); } enable() { if (this.enabled) return; this.enabled = !0, a(this.group, this.model), this.five.needsRender = !0, this.tag.enable(); const e = this.onClick.bind(this); this.fiveDomEvents.addEventListener(this.model, "click", e), this.emit("enable"); } disable() { this.enabled && (this.enabled = !1, this.group.remove(this.model), this.five.needsRender = !0, this.tag.disable(), this.fiveDomEvents.removeEventListener(this.model, "click"), this.emit("disable")); } onClick() { return this.emit("click", this); } } export { B as ModelMakerBaseItem };