UNPKG

@realsee/dnalogel

Version:
245 lines (244 loc) 7.97 kB
var c = Object.defineProperty; var f = Object.getOwnPropertySymbols; var v = Object.prototype.hasOwnProperty, S = Object.prototype.propertyIsEnumerable; var p = (a, s, e) => s in a ? c(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e, g = (a, s) => { for (var e in s || (s = {})) v.call(s, e) && p(a, e, s[e]); if (f) for (var e of f(s)) S.call(s, e) && p(a, e, s[e]); return a; }; var d = (a, s, e) => (p(a, typeof s != "symbol" ? s + "" : s, e), e); var u = (a, s, e) => new Promise((i, t) => { var r = (l) => { try { o(e.next(l)); } catch (n) { t(n); } }, b = (l) => { try { o(e.throw(l)); } catch (n) { t(n); } }, o = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(r, b); o((e = e.apply(a, s)).next()); }); import { Controller as w } from "../base/BasePlugin.js"; import { equal as C } from "../shared-utils/equal.js"; import { objectAssignDeepExports as y } from "../vendor/object-assign-deep/objectAssignDeep.js"; import { FiveUtil as L } from "../shared-utils/Utils/FiveUtil.js"; import "../shared-utils/Subscribe.js"; import "hammerjs"; import "three"; import "@realsee/five"; import "../vendor/@tweenjs/tween/dist/tween.esm.js.js"; import "../CSS3DRenderPlugin/utils/three/CSS3DRender.js"; import "../shared-utils/positionToVector3.js"; import "../CSS3DRenderPlugin/utils/three/CSS3DRenderer.js"; import "three/examples/jsm/renderers/CSS3DRenderer"; import "../CSS3DRenderPlugin/utils/getAllCSS3DObject.js"; import "../shared-utils/util.js"; import "../CSS3DRenderPlugin/utils/createResizeObserver.js"; import "../CSS3DRenderPlugin/utils/even.js"; import "../CSS3DRenderPlugin/utils/three/CSS3DObject.js"; import "../CSS3DRenderPlugin/utils/three/OpacityMesh.js"; import "../shared-utils/three/centerPoint.js"; import "../shared-utils/three/getObjectVisible.js"; import "../CSS3DRenderPlugin/utils/three/CSS3DScene.js"; import "../CSS3DRenderPlugin/utils/three/CSS3DGroup.js"; import "../CSS3DRenderPlugin/utils/generateBehindFiveElement.js"; import "../shared-utils/url/absoluteUrl.js"; import "../shared-utils/isTruelyObject.js"; import "../shared-utils/Utils/BaseUtil.js"; import "../shared-utils/Utils/WorkUtil.js"; import "../shared-utils/five/transformPosition.js"; const m = "CruisePlugin", h = `${m}`, ee = (a) => `${h}--${a}`; class ie extends w { constructor(e, i) { super(e, i); d(this, "state", { visible: !0, enabled: !0, disposed: !1, playing: !1, speed: 1 }); d(this, "fiveUtil", new L(this.five)); d(this, "workUtil", this.fiveUtil.workUtil); d(this, "data"); d(this, "config"); d(this, "pauseDataMap", /* @__PURE__ */ new Map()); d(this, "privateState", { playing: !1, broke: !1, modeChanging: !1 }); d(this, "GuideLine"); d(this, "disposedErrorLog", () => { console.error(`${h} is disposed`); }); d(this, "disableWarnLog", () => { console.warn(`${h} is disabled`); }); d(this, "disableErrorLog", () => { console.error(`${h} is disabled`); }); this.config = i, Object.assign(window, { [`__${m}_DEBUG__`]: this }); } set workCode(e) { this.fiveUtil.workUtil.workCode = e; } get workCode() { return this.fiveUtil.workUtil.workCode; } /** * @description Play | Continue play. if have been paused, continue play from the pause position; if playing, do nothing */ play(e) { this.setState({ playing: !0 }, e); } /** * @description Pause */ pause(e) { this.setState({ playing: !1 }, e); } /** * @description Show guide line */ show(e) { return u(this, null, function* () { this.setState({ visible: !0 }, e); }); } /** * @description Hide guide line */ hide(e) { return u(this, null, function* () { this.setState({ visible: !1 }, e); }); } /** * @description Enable */ enable(e) { this.setState({ enabled: !0 }, e); } /** * @description Disable */ disable(e) { this.setState({ enabled: !1 }, e); } /** * @description Dispose */ dispose() { this.setState({ disposed: !0 }); } /** * @description Set state */ setState(e, i) { var r; if (this.state.disposed) return this.disposedErrorLog(); if (!this.state.enabled && e.enabled !== !0 && e.disposed !== !0) return this.disableErrorLog(); const t = g({}, this.state); this.state = y({}, this.state, e), e.disposed !== void 0 && e.disposed !== t.disposed && e.disposed && this.handleDispose(), e.visible !== void 0 && e.visible !== t.visible && this.handleVisible(e.visible, i == null ? void 0 : i.userAction), e.enabled !== void 0 && e.enabled !== t.enabled && this.handleEnable(e.enabled, i == null ? void 0 : i.userAction), e.playing !== void 0 && e.playing !== t.playing && this.changePlayState(e.playing, i), e.speed !== void 0 && e.speed !== t.speed && this.changeSpeed(e.speed), C(t, this.state, { deep: !0 }) || this.hooks.emit("stateChange", { state: this.state, prevState: t, userAction: (r = i == null ? void 0 : i.userAction) != null ? r : !0 }); } /** * @description Clear pause data */ clearPauseData() { var e, i; if ((e = this.data) != null && e.id) return this.pauseDataMap.delete((i = this.data) == null ? void 0 : i.id); } changePlayState(e, i) { this.actionIfStateIsEnabled( () => { var t; return this.hooks.emit("playStateChange", e ? "playing" : "pause", { userAction: (t = i == null ? void 0 : i.userAction) != null ? t : !0 }); } ), e ? this.handlePlay(i) : this.handlePause(i), this.state.playing = e; } handleEnable(e, i = !0) { var t, r; e ? ((t = this.GuideLine) == null || t.enable(), this.hooks.emit("enable", { userAction: i })) : ((r = this.GuideLine) == null || r.disable(), this.changePlayState(!1, { userAction: i }), this.hooks.emit("disable", { userAction: i })), this.state.enabled = e; } handleVisible(e, i = !0) { var t, r; e ? ((t = this.GuideLine) == null || t.show(), this.actionIfStateIsEnabled(() => this.hooks.emit("show", { userAction: i }))) : ((r = this.GuideLine) == null || r.hide(), this.actionIfStateIsEnabled(() => this.hooks.emit("hide", { userAction: i }))), this.state.visible = e; } /** * @description: listen interupted by five gesture */ addInterruptListener(e) { const i = () => { this.privateState.modeChanging || e(); }, t = (r) => { r !== "mouseMove" && (e(), this.five.off("gesture", t)); }; return this.five.on("gesture", t), this.five.once("wantsChangeMode", i), () => { this.five.off("gesture", t), this.five.off("wantsChangeMode", i); }; } /** * @description Get duration by speed */ getSpeededDuration(e) { return e / this.state.speed; } /** * @description Force interupt five updateCamera */ forceInteruptUpdateCamera() { this.five.updateCamera({}, 0); } getPauseData() { var e; if ((e = this.data) != null && e.id) return this.pauseDataMap.get(this.data.id); } /** * @description Set pause data */ setPauseData() { var i; const e = (i = this.data) == null ? void 0 : i.id; if (e) return this.pauseDataMap.set(e, { fiveState: this.five.getCurrentState(), playedProgress: this.getProgress() }); } /** * @description: Restore state that before loaded */ clear() { this.clearPauseData(); } // TODO handleDispose() { var e; this.setState({ playing: !1 }), this.clearPauseData(), this.clear(), (e = this.GuideLine) == null || e.dispose(), this.GuideLine = void 0; } /** * @description Action function if plugin is enable */ actionIfStateIsEnabled(e, i) { if (this.state.enabled) return e(); i != null && i.warnLog && this.disableWarnLog(); } } export { ie as default, ee as pluginFlag };