UNPKG

@realsee/dnalogel

Version:
139 lines (138 loc) 4.8 kB
var S = Object.defineProperty; var w = Object.getOwnPropertySymbols; var k = Object.prototype.hasOwnProperty, b = Object.prototype.propertyIsEnumerable; var c = (o, e, t) => e in o ? S(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, g = (o, e) => { for (var t in e || (e = {})) k.call(e, t) && c(o, t, e[t]); if (w) for (var t of w(e)) b.call(e, t) && c(o, t, e[t]); return o; }; var s = (o, e, t) => (c(o, typeof e != "symbol" ? e + "" : e, t), t); var d = (o, e, t) => new Promise((n, i) => { var u = (r) => { try { a(t.next(r)); } catch (m) { i(m); } }, l = (r) => { try { a(t.throw(r)); } catch (m) { i(m); } }, a = (r) => r.done ? n(r.value) : Promise.resolve(r.value).then(u, l); a((t = t.apply(o, e)).next()); }); import { GuideLineModeItem as v } from "../GuideLineModeItem/index.js"; import { logError as x } from "../../shared-utils/log.js"; import { to as y } from "../../shared-utils/to.js"; import { Subscribe as G } from "@realsee/five"; import { changeMode as L } from "../../shared-utils/five/changeMode.js"; import P from "../../CruisePlugin/Move.js"; import M from "../../CruisePlugin/Work.js"; class C { constructor(e) { s(this, "id"); s(this, "renderID"); s(this, "isGuideLine", !0); s(this, "panoramaItem"); s(this, "modelItem"); s(this, "hooks", new G()); s(this, "_visible", !0); s(this, "plugin"); s(this, "five"); s(this, "logError", (e) => x("GuideLineItem: ", e)); this.id = e.id, this.five = e.five, this.plugin = e.plugin, this.panoramaItem = new v(this.five, { mode: "panorama", plugin: this.plugin, parent: this }), this.modelItem = new v(this.five, { mode: "model", plugin: this.plugin, parent: this }); } get visible() { return this._visible; } setData(e) { this.setDataByMode("panorama", e), this.setDataByMode("model", e); } setDataByMode(e, t) { var m; const n = e === "panorama" ? this.panoramaItem : this.modelItem, i = e === "panorama" ? t.panorama_style : t.model_style, u = t.path, l = i, a = i, r = i; if (t.pano_group) { const h = e === "panorama" && t.panorama_style.skip_group !== !1; n.setGeometryByPanoGroup(t.pano_group, g({ skipPanoGroup: h }, l)); } else t.path && n.setGeometryByPath(u, l); n.name = t.name, n.setMeshStyle(r), n.setMartial(a), n.setVisibleFloorIndexes((m = t.visible_floor_indexes) != null ? m : null), n.setStartTag(i == null ? void 0 : i.start_tag), n.setEndTag(i == null ? void 0 : i.end_tag); } show() { this._visible = !0, this.hooks.emit("show", { userAction: !0 }); } hide() { this._visible = !1, this.hooks.emit("hide", { userAction: !0 }); } dispose() { this.panoramaItem.dispose(), this.modelItem.dispose(); } walk(e) { return d(this, null, function* () { if (this.hooks.emit("walkStart", { userAction: !0 }), this.panoramaItem.panoGroup.length) { const t = g({ panoIndexList: this.panoramaItem.panoGroup }, e), [n] = yield y(A(this.five, t)); if (n) return this.logError(n.message); } else { const t = { path: this.panoramaItem.curvePath }, [n] = yield y(E(this.five, t)); if (n) return this.logError(n.message); } this.hooks.emit("walkEnded", { userAction: !0 }); }); } } function E(o, e) { return d(this, null, function* () { const t = new P(o); yield t.load(e), t.playFromStart(); }); } function A(o, e) { return d(this, null, function* () { if (e.panoIndexList.length === 0) return; const t = o.getCurrentState(); t.mode !== "Panorama" && (yield L(o, ["Panorama", { longitude: t.longitude, latitude: 0, panoIndex: e.panoIndexList[0] }])); const n = new M(o); yield n.load(e), yield new Promise((i, u) => { const l = o.getCurrentState(); let a = e.panoIndexList.slice(); l.panoIndex === a[0] && m(l.panoIndex), n.playFromStart(); function r(p) { if (p !== "Panorama") return f(new Error("mode not match")); } function m(p) { const I = a[0]; if (a = a.slice(1), p !== I) return f(new Error("panoIndex not match, wanted: " + I + ", got: " + p)); if (a.length === 0) return _(); } function h() { o.off("modeChange", r), o.off("panoArrived", m); } function f(p) { h(), u(p); } function _() { h(), i(); } o.on("modeChange", r), o.on("panoArrived", m); }); }); } const V = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, GuideLineItem: C }, Symbol.toStringTag, { value: "Module" })); export { C as GuideLineItem, V as GuideLineItem$1 };