@realsee/dnalogel
Version:
160 lines (159 loc) • 5.7 kB
JavaScript
var g = Object.defineProperty, m = Object.defineProperties;
var b = Object.getOwnPropertyDescriptors;
var p = Object.getOwnPropertySymbols;
var M = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable;
var l = (o, r, e) => r in o ? g(o, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[r] = e, a = (o, r) => {
for (var e in r || (r = {}))
M.call(r, e) && l(o, e, r[e]);
if (p)
for (var e of p(r))
W.call(r, e) && l(o, e, r[e]);
return o;
}, d = (o, r) => m(o, b(r));
var s = (o, r, e) => (l(o, typeof r != "symbol" ? r + "" : r, e), e);
import { VideoMeshController as c } from "./VideoMeshController.js";
import { Controller as _ } from "../base/BasePlugin.js";
import "./utils/shader.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 "../shared-utils/Subscribe.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/animationFrame/index.js";
import "./utils/index.js";
import "animejs";
import "../shared-utils/url/absoluteUrl.js";
class T extends _ {
constructor(e) {
super(e);
s(this, "enabled", !0);
s(this, "controllerMap", /* @__PURE__ */ new Map());
s(this, "_disposed", !1);
this.five = e;
}
/** 插件 State */
get state() {
return {
enabled: this.enabled
};
}
/** 插件是否已被销毁 */
get disposed() {
return this._disposed;
}
/** 加载点位视频数据,加载数据并不代表会加载点位视频。 */
load(e, t) {
var i;
if (this.disposed)
return this.logWarning("插件已被销毁");
typeof ((i = t == null ? void 0 : t.initialState) == null ? void 0 : i.enabled) != "undefined" && t.initialState.enabled !== this.enabled && (t.initialState.enabled ? this.enable() : this.disable()), e.list.forEach((n) => {
const f = n.pano_index, u = n.render_id;
n.video_list.forEach((h) => {
this.controllerMap.set(
h.render_id,
new c(this.five, d(a({}, h), {
panoIndex: f,
renderID: u,
initialState: { enabled: this.enabled }
}))
);
});
});
}
/** 开启插件功能。 */
enable(e) {
var i;
if (this.disposed)
return this.logWarning("插件已被销毁");
if (this.enabled)
return;
this.enabled = !0, Array.from(this.controllerMap.values()).forEach((n) => n.enable());
const t = (i = e == null ? void 0 : e.userAction) != null ? i : !0;
this.hooks.emit("enable", { userAction: t });
}
/** 禁用插件功能。 */
disable(e) {
var i;
if (this.disposed)
return this.logWarning("插件已被销毁");
if (!this.enabled)
return;
this.enabled = !1, Array.from(this.controllerMap.values()).forEach((n) => n.disable());
const t = (i = e == null ? void 0 : e.userAction) != null ? i : !0;
this.hooks.emit("disable", { userAction: t });
}
/** 看向某个视频。
* - 会自动切换到全景模式。
* - 如果遇到不能自动播放的问题,需要放到用户交互事件中调用。
*/
lookAtVideoItemByRenderID(e) {
if (this.disposed)
return this.logWarning("插件已被销毁");
const t = this.controllerMap.get(e);
if (!t)
return this.logWarning(`ID 为 ${e} 的点位视频不存在`);
t.lookAtVideo();
}
/** 为一个点位添加视频(可以是多条)。 */
add(e, t) {
if (this.disposed)
return this.logWarning("插件已被销毁");
t.forEach((i) => {
if (this.controllerMap.get(i.render_id))
return this.logWarning(`ID 为 ${i.render_id} 的点位视频已存在`);
const n = i.render_id;
this.controllerMap.set(
i.render_id,
new c(this.five, d(a({}, i), {
panoIndex: e,
renderID: n,
initialState: { enabled: this.enabled }
}))
);
});
}
/** 根据 VideoItem render_id 删除某个视频。 */
removeByRenderID(e) {
if (this.disposed)
return this.logWarning("插件已被销毁");
const t = this.controllerMap.get(e);
if (!t)
return this.logWarning(`ID 为 ${e} 的点位视频不存在`);
t.dispose(), this.controllerMap.delete(e);
}
/** 清空现有数据 */
clear() {
if (this.disposed)
return this.logWarning("插件已被销毁");
Array.from(this.controllerMap.values()).forEach((e) => e.dispose()), this.controllerMap.clear();
}
/** 销毁插件 */
dispose() {
if (this.disposed)
return this.logWarning("插件已被销毁");
this._disposed = !0, Array.from(this.controllerMap.values()).forEach((e) => e.dispose()), this.controllerMap.clear();
}
/** 控制台打印警告 */
// TODO: 全局函数 curry 化
logWarning(e) {
console.warn("⛔ ==> [PanoVideoPluginController]:", e);
}
}
export {
T as PanoVideoPluginController
};