@realsee/dnalogel
Version:
104 lines (103 loc) • 3.44 kB
JavaScript
var m = Object.defineProperty;
var f = Object.getOwnPropertySymbols;
var v = Object.prototype.hasOwnProperty, b = Object.prototype.propertyIsEnumerable;
var p = (i, e, t) => e in i ? m(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, c = (i, e) => {
for (var t in e || (e = {}))
v.call(e, t) && p(i, t, e[t]);
if (f)
for (var t of f(e))
b.call(e, t) && p(i, t, e[t]);
return i;
};
var r = (i, e, t) => (p(i, typeof e != "symbol" ? e + "" : e, t), t);
var d = (i, e, t) => new Promise((a, o) => {
var n = (s) => {
try {
h(t.next(s));
} catch (u) {
o(u);
}
}, l = (s) => {
try {
h(t.throw(s));
} catch (u) {
o(u);
}
}, h = (s) => s.done ? a(s.value) : Promise.resolve(s.value).then(n, l);
h((t = t.apply(i, e)).next());
});
import I from "./RulerItems.js";
import "../vendor/svelte/internal/index.js";
import "@realsee/five";
import "../shared-utils/animationFrame/index.js";
import "../vendor/@tweenjs/tween/dist/tween.esm.js.js";
import "../shared-utils/equal.js";
import "../shared-utils/isTruelyObject.js";
import "../shared-utils/math/planimetry.js";
import "../shared-utils/throttle.js";
import "three";
import "./RulerItem.js";
class A {
constructor(e, t) {
r(this, "five");
r(this, "container", document.createElement("div"));
r(this, "panoRulerProData");
r(this, "rulerItems");
r(this, "state", {
enabled: !1,
loaded: !1,
options: {
className: "",
distanceText: (e) => `${e.toFixed(1)}m`
}
});
var a, o;
this.five = e, this.container.classList.add("panoRulerProPlugin-container"), this.container.setAttribute(
"style",
"position: absolute;pointer-events: none;width: 100%;height: 100%;left: 0;top: 0;overflow: hidden;"
), t && (t.data && this.load(t.data), this.state.options = c(c({}, this.state.options), t.options || {}), (a = t.options) != null && a.className && this.container.classList.add((o = t.options) == null ? void 0 : o.className)), this.five.once("modelLoaded", () => d(this, null, function* () {
var n, l;
(l = (n = this.five.getElement()) == null ? void 0 : n.parentNode) == null || l.append(this.container);
})), this.five.once("dispose", () => this.dispose());
}
load(e) {
return d(this, null, function* () {
if (!this.five.work)
return;
const t = e.data;
if (!t)
throw new Error("标尺数据依赖不齐全!");
this.panoRulerProData = t, this.state.loaded = !0;
});
}
enable() {
return this.state.loaded ? (this.state.enabled || (this.state.enabled = !0, this.render()), !0) : !1;
}
disable() {
return this.state.enabled && (this.state.enabled = !1, this.render()), !0;
}
render() {
return d(this, null, function* () {
var e;
if (this.state.enabled) {
if (!this.panoRulerProData || !this.container)
return;
this.rulerItems = new I({
target: this.container,
props: {
five: this.five,
rulerDatas: this.panoRulerProData,
options: this.state.options
}
});
} else
(e = this.rulerItems) == null || e.$destroy(), this.rulerItems = void 0;
});
}
dispose() {
this.container && (this.rulerItems.$destroy(), this.rulerItems = void 0), this.container.remove();
}
}
export {
A as default
};