@realsee/dnalogel
Version:
619 lines (618 loc) • 29.1 kB
JavaScript
var V = Object.defineProperty, E = Object.defineProperties;
var R = Object.getOwnPropertyDescriptors;
var D = Object.getOwnPropertySymbols;
var F = Object.prototype.hasOwnProperty, O = Object.prototype.propertyIsEnumerable;
var v = (h, d, e) => d in h ? V(h, d, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[d] = e, m = (h, d) => {
for (var e in d || (d = {}))
F.call(d, e) && v(h, e, d[e]);
if (D)
for (var e of D(d))
O.call(d, e) && v(h, e, d[e]);
return h;
}, T = (h, d) => E(h, R(d));
var f = (h, d, e) => (v(h, typeof d != "symbol" ? d + "" : d, e), e);
var c = (h, d, e) => new Promise((t, i) => {
var s = (n) => {
try {
r(e.next(n));
} catch (a) {
i(a);
}
}, o = (n) => {
try {
r(e.throw(n));
} catch (a) {
i(a);
}
}, r = (n) => n.done ? t(n.value) : Promise.resolve(n.value).then(s, o);
r((e = e.apply(h, d)).next());
});
import * as y from "three";
import { Subscribe as M } from "@realsee/five";
import { objectAssignDeepExports as g } from "../../vendor/object-assign-deep/objectAssignDeep.js";
import { addDebugPoints as _ } from "../utils/addDebugPoints.js";
import { arrayPositionToVector3 as S } from "../../shared-utils/positionToVector3.js";
import { isMediaModelTag as L, isModelTag as N } from "../utils/tag/tagCheck.js";
import { debounce as G } from "../utils/debounce.js";
import { throttle as w } from "../utils/throttle.js";
import z, { getTagStickType as W } from "../utils/tag/format.js";
import { generateBlankAudio as x, AudioNamespace as $ } from "../../shared-utils/audio.js";
import { resizeObserver as k } from "../../shared-utils/dom/resizeObserver.js";
import { TagRender as j } from "./TagRender.js";
import { uuid as J } from "../../shared-utils/uuid.js";
import { isModelLike as q } from "../../shared-utils/five/mode.js";
import "hammerjs";
import "../../vendor/@tweenjs/tween/dist/tween.esm.js.js";
import "../../CSS3DRenderPlugin/utils/three/CSS3DRender.js";
import "../../CSS3DRenderPlugin/utils/generateBehindFiveElement.js";
import { blink as H, reblink as Q } from "../../shared-utils/three/blink.js";
import { tweenProgress as Y } from "../../shared-utils/animationFrame/BetterTween.js";
import { waitFiveModelLoaded as Z } from "../../shared-utils/five/fiveModelLoad.js";
import { DebugUtil as K } from "../utils/DebugUtil.js";
import { safeObj as I } from "../../shared-utils/safeObj.js";
import { sleep as X } from "../../CruisePlugin/utils/sleep.js";
import "./TagComputer.js";
import "../utils/tagPosition.js";
import "../../shared-utils/three/centerPoint.js";
import "../utils/checkRange.js";
import "animejs";
import "../../shared-utils/util.js";
import "../../shared-utils/isNil.js";
import "./TagUtil.js";
import "../typings/tag/TagConfig.js";
import "../tag.config.js";
import "../utils/planeNormal.js";
import "../utils/normalPositionToPositions.js";
import "./TagCache.js";
import "../../base/BasePlugin.js";
import "../../shared-utils/Subscribe.js";
import "../../shared-utils/url/absoluteUrl.js";
import "../../CSS3DRenderPlugin/utils/three/CSS3DRenderer.js";
import "three/examples/jsm/renderers/CSS3DRenderer";
import "../../CSS3DRenderPlugin/utils/getAllCSS3DObject.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/getObjectVisible.js";
import "../../CSS3DRenderPlugin/utils/three/CSS3DScene.js";
import "../../CSS3DRenderPlugin/utils/three/CSS3DGroup.js";
import "../../vendor/svelte/store/index.js";
import "../../vendor/svelte/internal/index.js";
import "../../shared-utils/device.js";
import "../utils/model/mediaPlane.js";
import "../../shared-utils/three/loadTexture.js";
import "../../shared-utils/three/Quadrangle.js";
import "../../shared-utils/math/pointIsRectangle.js";
import "../../shared-utils/three/loadVideoTexture.js";
import "../Assets/Icon.js";
import "../../shared-utils/three/getPositionsByObjectFit.js";
import "../../shared-utils/three/FragmentTransparencyMaterial.js";
import "../../shared-utils/three/getNormal.js";
import "../../shared-utils/five/FiveDomEvents.js";
import "../../shared-utils/five/calculateThreeMouse.js";
import "../utils/tag/adaptConfig.js";
import "../../shared-utils/typescript/entries.js";
import "../../shared-utils/url/getUrl.js";
import "../../shared-utils/five/transformPosition.js";
import "../../shared-utils/Utils/WorkUtil.js";
import "../../shared-utils/Utils/BaseUtil.js";
import "../../shared-utils/five/getFloorIndex.js";
import "../Components/TagContainer.js";
import "../Components/TagItem.js";
import "../Components/Tag/index.js";
import "../Components/Tag/TextTag/index.js";
import "../Components/Tag/TextTag/TextTag.js";
import "../Components/Common/Line/Straight.js";
import "../../vendor/svelte/transition/index.js";
import "../../vendor/svelte/easing/index.js";
import "../Components/Common/Shadow.js";
import "../Components/Common/Text/FlyMText.js";
import "../Components/Common/Text/FlyText.js";
import "../utils/search.js";
import "../utils/constants.js";
import "../Components/Common/Arrow.js";
import "../utils/doUtil.js";
import "../../shared-utils/svelte/resizeObserver.js";
import "../../vendor/resize-observer-polyfill/dist/ResizeObserver.es.js";
import "../Components/Tag/TextTag/TextPlaneTag.js";
import "../Components/Common/Text/MText.js";
import "../utils/px2rem.js";
import "../Components/Tag/ImageTextTag.js";
import "../Components/Common/Line/Polyline.js";
import "../Components/Common/Media.js";
import "../../vendor/svelte-carousel/src/components/Carousel/Carousel.js";
import "../../vendor/svelte-carousel/src/components/Dots/Dots.js";
import "../../vendor/svelte-carousel/src/components/Dot/Dot.js";
import "../../vendor/svelte-carousel/src/components/Arrow/Arrow.js";
import "../../vendor/svelte-carousel/src/direction.js";
import "../../vendor/svelte-carousel/src/components/Progress/Progress.js";
import "../../vendor/svelte-carousel/src/actions/swipeable/swipeable.js";
import "../../vendor/svelte-carousel/src/actions/swipeable/event.js";
import "../../vendor/svelte-carousel/src/utils/event.js";
import "../../vendor/svelte-carousel/src/units.js";
import "../../vendor/svelte-carousel/src/actions/hoverable/hoverable.js";
import "../../vendor/svelte-carousel/src/actions/hoverable/event.js";
import "../../vendor/svelte-carousel/src/actions/tappable/tappable.js";
import "../../vendor/svelte-carousel/src/utils/math.js";
import "../../vendor/svelte-carousel/src/actions/tappable/event.js";
import "../../vendor/svelte-carousel/src/utils/page.js";
import "../../vendor/svelte-carousel/src/utils/clones.js";
import "../../vendor/svelte-carousel/src/utils/object.js";
import "../../vendor/svelte-carousel/src/components/Carousel/createCarousel.js";
import "../../vendor/easy-reactive/src/simply-reactive.js";
import "../../vendor/lodash.get/index.js";
import "../../_commonjsHelpers.js";
import "../../vendor/lodash.clonedeep/index.js";
import "../../vendor/easy-reactive/src/utils/subscription.js";
import "../../vendor/easy-reactive/src/utils/object.js";
import "../../vendor/lodash.isequal/index.js";
import "../../vendor/easy-reactive/src/utils/watcher.js";
import "../../vendor/svelte-carousel/src/utils/lazy.js";
import "../../vendor/svelte-carousel/src/utils/ProgressManager.js";
import "../../vendor/svelte-carousel/src/utils/interval.js";
import "../Components/Common/MediaItem.js";
import "../Components/Tag/MarketingTag.js";
import "../utils/noTypecheck.js";
import "../Components/Tag/AudioTag/index.js";
import "../Components/Tag/AudioTag/AudioTag.js";
import "../Components/Common/Audio.js";
import "../utils/audio/SharedAudio.js";
import "../Components/Common/Icon/audioIcon.js";
import "../Components/Tag/AudioTag/AudioPlaneTag.js";
import "../Components/Tag/MediaPlane.js";
import "../Components/Tag/LinkTag.js";
import "../Components/Common/Icon/Icon.js";
import "../utils/getImageInfo.js";
import "../Components/Tag/PanoramaTag.js";
import "../Components/Tag/CustomTag.js";
import "../../vendor/classnames/index.js";
import "../Components/Common/TagPoint.js";
import "../../CSS3DRenderPlugin/index.js";
import "../../CSS3DRenderPlugin/Controller.js";
import "../../CSS3DRenderPlugin/utils/waitFiveModelLoaded.js";
import "../../shared-utils/three/GLTFLoader.js";
import "@realsee/five/gltf-loader";
import "../../shared-utils/animationFrame/index.js";
const U = "Dnalogel-PanoTagPlugin", Gi = (h) => `${U}--${h}`;
class zi extends j {
constructor(e, t) {
super(e);
/** state */
f(this, "state", { enabled: !0, visible: !0 });
/** 插件参数 */
f(this, "params");
/** debug */
f(this, "debug");
f(this, "debugUtil", new K(this));
/** 更改 tag 模型 */
f(this, "changeTagModel", (e, t) => c(this, null, function* () {
e.data = g({}, e.data, t), yield this.loadModel(e), this.updateRenderAllTags();
}));
f(this, "whyHide", (e) => {
var i, s, o;
if (!this.state.enabled)
return { reason: `plugin.state.enabled is ${this.state.enabled}` };
if (!this.state.visible)
return { reason: `plugin.state.visible is ${this.state.visible}` };
const t = this.getTagById(e);
if (!t)
return { reason: `tag ${e} not found` };
if (!t.enabled)
return { reason: `tag ${e} enabled is ${t.enabled}` };
if (t.stickType === "Model" || t.stickType === "Plane")
return { reason: "maybe blocked by the five model" };
if (!t.state.visible) {
const r = (s = (i = this.getPanoIndexCache({ panoIndex: this.five.panoIndex, id: e })) == null ? void 0 : i.__debug_visible_reason__) == null ? void 0 : s.reason;
return { reason: (o = r == null ? void 0 : r.type) != null ? o : r, reasonObj: r };
}
return { reason: "check your eyes" };
});
f(this, "updateVisible", () => {
const e = this.five.getCurrentState().mode;
this.tags.forEach((t) => {
L(t) && e !== "Panorama" && this.changeTagMode(t, "behind");
}), this.setVisible(), this.updateRenderAllTags();
});
f(this, "handleFiveWantsMoveToPano", (e) => {
this.tags.forEach((t) => {
this.getVisible(t, { panoIndex: e }) && (t.state.visible = !0);
const s = this.getTagConfig(t);
typeof s.visibleConfig == "object" && t.temporaryState && (s.visibleConfig.keep ? t.temporaryState.visible = s.visibleConfig.keep === "visible" : t.temporaryState.visible = !!s.visibleConfig.alwaysShowWhenMovePano);
}), this.updateTagContainerVisible(), this.updateRenderImagePlane(), this.updateRenderVideoPlane();
});
/**
* @description 走点/切换模型后显示
*/
// private temporaryShow({ withAnimation }: { withAnimation?: boolean } = { withAnimation: false }) {
// this.temporaryState.visible = true
// this.updateTagContainerVisible()
// }
/**
* @description 走点/切换模型时临时隐藏
*/
// private temporaryHide({ withAnimation }: { withAnimation?: boolean } = { withAnimation: false }) {
// this.temporaryState.visible = false
// this.updateTagContainerVisible()
// }
f(this, "clickhandler", (e) => {
if (e.target !== "TagPoint")
return;
if (!e.tag.state)
return console.warn("Clickhandler: params.tag.state is undefined");
const t = this.can("fold", e.tag), i = this.can("unfold", e.tag);
t && i && (e.tag.state.unfolded = !e.tag.state.unfolded, e.tag.state.unfolded && this.tags.forEach((s) => {
s.id !== e.tag.id && s.state && this.can("fold", s) && (s.state.unfolded = !1);
}), this.updateRenderAllTags());
});
f(this, "handleFiveCameraUpdate", () => {
this.updatePointTagPosition();
});
f(this, "handleFivePanoArrived", () => c(this, null, function* () {
this.setVisible(), this.updatePointTagPosition(), yield this.setVisibleAndUnfolded(), this.tags.forEach((e) => {
e.temporaryState = T(m({}, e.temporaryState), { visible: !0 });
}), this.tags.filter(N).filter((e) => {
var t;
return (t = this.getTagConfig(e).modelConfig) == null ? void 0 : t.autoLookAtEnabled;
}).forEach((e) => {
var a;
const t = new y.Mesh(new y.BoxGeometry(), new y.MeshBasicMaterial()), i = (a = e.model) == null ? void 0 : a.object;
if (!i)
return;
t.position.copy(i.position), t.quaternion.copy(i.quaternion);
const s = this.five.camera.position;
t.lookAt(s.clone().setY(t.position.y));
const o = i.quaternion.clone(), r = t.quaternion.clone(), n = Y();
n.onUpdate(({ progress: l }) => {
i.quaternion.copy(o.clone().slerp(r, l));
}), n.play();
}), this.store.visibleWithAnimation = !0, this.updateTagContainerVisible(), this.updateRenderAllTags();
}));
/** 楼层切换时,需要更新标签可见性 */
f(this, "handleFiveModelShownFloorChange", () => {
this.setVisible(), this.updateRenderAllTags();
});
f(this, "onFiveEveryReady", () => {
this.setUnfoldedByCamera(), q(this.five.getCurrentState().mode) && (this.setTagZIndex(this.filterPointTag), this.setVisible(), this.setPointTagPosition()), this.updateDomView({ withAnimation: !0 }), this.updateRenderVideoPlane(), this.updateRenderImagePlane(), this.updateTagModelVisible();
});
this.params = g({}, { debug: !1, config: this.config }, m({}, t)), this.debug = this.params.debug, this.config = this.params.config, x(1, { namespace: $.PlayAudio });
try {
const i = window;
Array.isArray(i.__PANOTAGPLUGIN_DEBUG_LIST__) || (i.__PANOTAGPLUGIN_DEBUG_LIST__ = []), i.__PANOTAGPLUGIN_DEBUG_LIST__.push(this), i.__PANOTAGPLUGIN_DEBUG__ = this;
} catch (i) {
}
}
/**
* @description 加载数据
*/
load(e, t) {
return c(this, null, function* () {
var s, o;
this.clearTags(), console.debug(U, " load:", { data: JSON.parse(JSON.stringify(e)) }), this.config = g({}, this.config, {
globalConfig: (s = e.globalConfig) != null ? s : {},
contentTypeConfig: (o = e.contentTypeConfig) != null ? o : {}
}), this.store.visibleWithAnimation = !0;
const i = yield this.addTag(e.tagList, t);
if (this.store.visibleWithAnimation = void 0, this.debug)
try {
_(this.five, this.tags);
} catch (r) {
console.error(r);
}
return i;
});
}
/**
* @description 添加标签
*/
addTag(e, t) {
return c(this, null, function* () {
const s = (Array.isArray(e) ? e : [e]).filter((o) => o.position).map((o) => {
var b, C, A, P;
o.stickType = W(o);
const r = JSON.parse(JSON.stringify(o.data)), n = (b = o.initialConfig) != null ? b : o.config ? JSON.parse(JSON.stringify(o.config)) : {};
o.initialConfig = n;
const a = this.calculateTagConfig(o), l = this.getTagConfig(o);
o.config = l;
const p = T(m({}, o), {
enabled: (C = o.enabled) != null ? C : !0,
id: (A = o.id) != null ? A : J(),
data: (P = l.initialData) != null && P.important ? g(o.data, r, l.initialData) : g(o.data, l.initialData, r),
state: m({
visible: void 0,
unfolded: !this.can("fold", o)
}, l.initialState),
hooks: new M(),
originPosition: o.position,
position: (() => {
const u = this.getTransformedPostion(o.position);
return Array.isArray(u) ? u.map((B) => B.toArray()) : u.toArray();
})(),
initialConfig: n,
computedConfig: a,
config: l,
unfold: () => this.changeUnfoldedById(p.id, !0),
fold: () => this.changeUnfoldedById(p.id, !1),
enable: () => this.changeEnabledById(p.id, !0),
disable: () => this.changeEnabledById(p.id, !1),
destroy: () => this.destroyTagById(p.id),
changeData: (u) => this.changeDataById(p.id, u),
changePosition: (u) => this.changePositionById(p.id, u),
blink: (u) => this.blinkTagById(p.id, u)
});
return p;
});
return s.forEach(z), this.tags.push(...s), this.tagsLengthWillUpdate = !0, Z(this.five).then(() => c(this, null, function* () {
var o, r, n;
this.store.eventListenerDisposer && ((r = (o = this.store).eventListenerDisposer) == null || r.call(o)), this.state.enabled && this.handleEnable(), this.addResizeListener(), this.clearUnusedPanelTag(), this.addMediaModelTag(s), this.setVisibleAndUnfolded({ withAnimation: (n = t == null ? void 0 : t.withAnimation) != null ? n : !0 }), this.updatePointTagPosition(), this.updateRenderAllTags();
}));
});
}
/**
* @description 改变配置
*/
changeConfig(e, t = !0) {
t ? this.config = g({}, this.config, e) : this.config = e, this.updateTagConfig(), this.setVisible(), this.updateRenderAllTags();
}
/**
* @description 改变全局配置
*/
changeGlobalConfig(e, t = !0) {
t ? this.config.globalConfig = g({}, this.config.globalConfig, e) : this.config.globalConfig = e, this.updateTagConfig(), this.setVisible(), this.updateRenderAllTags();
}
/**
* @description 改变类型配置
*/
changeContentTypeConfig(e, t, i = !0) {
this.config.contentTypeConfig || (this.config.contentTypeConfig = {}), i ? this.config.contentTypeConfig[e] = g({}, this.config.contentTypeConfig[e], t) : this.config.contentTypeConfig[e] = t, this.updateTagConfig(), this.setVisible(), this.updateRenderAllTags();
}
show(e) {
return c(this, null, function* () {
if (this.checkDisposed())
return;
const { userAction: t = !0, withAnimation: i = !1 } = e != null ? e : {};
this.setState({ visible: !0 }, { userAction: t, visibleWithAnimation: i }), this.hooks.emit("show", { userAction: t, withAnimation: i });
});
}
hide(e) {
return c(this, null, function* () {
if (this.checkDisposed())
return;
const { userAction: t = !0, withAnimation: i = !1 } = e != null ? e : {};
this.setState({ visible: !1 }, { userAction: t, visibleWithAnimation: i }), this.hooks.emit("hide", { userAction: t, withAnimation: i });
});
}
enable(e) {
if (this.checkDisposed())
return;
const { userAction: t = !0 } = e != null ? e : {};
this.setState({ enabled: !0 }, { userAction: t }), this.hooks.emit("enable", { userAction: t });
}
disable(e) {
if (this.checkDisposed())
return;
const { userAction: t = !0 } = e != null ? e : {};
this.setState({ enabled: !1 }, { userAction: t }), this.hooks.emit("disable", { userAction: t });
}
setState(e, t) {
if (this.checkDisposed())
return;
const { userAction: i = !0, visibleWithAnimation: s = !1 } = t != null ? t : {}, o = m({}, this.state);
this.state = Object.assign(this.state, e), this.store.visibleWithAnimation = s, o.visible !== this.state.visible && (e.visible ? this.handleShow() : this.handleHide()), o.enabled !== this.state.enabled && (e.enabled ? this.handleEnable() : this.handleDisable()), this.hooks.emit("stateChange", { state: this.state, prevState: o, userAction: i });
}
/**
* @description 销毁
*/
dispose() {
var e, t, i, s, o, r;
this.pauseCurrentMedia(), this.disposeAllCSS3DContainer(), (e = this.TagContainerSvelte) == null || e.$destroy(), this.filterCSS3DTag.forEach((n) => {
var a;
return (a = n.tag3DContentSvelte) == null ? void 0 : a.svelteApp.$destroy();
}), this.tags = [], (t = this.store.disposers) == null || t.forEach((n) => n == null ? void 0 : n()), this.store.disposers = [], (s = (i = this.store).eventListenerDisposer) == null || s.call(i), this.store.eventListenerDisposer = void 0, (r = (o = this.store).resizeObserverDisposer) == null || r.call(o), this.store.resizeObserverDisposer = void 0, this.store.resizeObserverDisposerAdding = !1, this.five.scene.remove(this.group), this.group.remove(...this.group.children), this.gltfObjectGroup.remove(...this.gltfObjectGroup.children), this.imagePlaneGroup.remove(...this.imagePlaneGroup.children), this.clearCache(), this.five.needsRender = !0, this.store.disposed = !0, this.hooks.emit("dispose");
}
/**
* @description 闪烁标签
* @param {TagId} id
* @param {Partial<anime.AnimeParams>} animeConfig
*/
blinkTagById(e, t) {
return c(this, null, function* () {
var n;
const i = this.getTagById(e);
if (!i)
return;
const s = (n = i.state) == null ? void 0 : n.visible;
s === !1 && (i.state.visible = !0, this.setPointTagPosition(), this.updateDomView(), yield X(1));
const o = (() => {
var l, p, b;
const a = [];
return a.push((p = (l = i.dom) == null ? void 0 : l.getElementsByClassName("wrapper")) == null ? void 0 : p[0]), i.stickType !== "2DPoint" && a.push(i.contentDom), a.push((b = i.model) == null ? void 0 : b.object), a.push(i.mediaPlane), a.filter(Boolean);
})();
if (!o.length)
return;
yield (s ? H : Q)(o, m({
updateRender: () => {
this.five.needsRender = !0;
}
}, t)), s === !1 && (this.setVisible(i), this.updateDomView());
});
}
/**
* @description 展开/收起指定id的标签
* @param {TagId} id
* @param {boolean} unfolded
*/
changeUnfoldedById(e, t) {
var r;
const i = this.getTagById(e);
if (!i)
return;
const s = this.can("fold", i), o = this.can("unfold", i);
if (s && o) {
i.state.unfolded = t;
const n = this.filterPointTag;
(r = this.TagContainerSvelte) == null || r.$set({ tags: n });
} else
console.warn(`tag ${e} cannot be ${t ? "unfolded" : "folded"}`);
}
/**
* @description 启用/停用指定id的标签
* @param {TagId} id
* @param {boolean} enabled
*/
changeEnabledById(e, t) {
var s;
const i = this.getTagById(e);
i && (i.enabled = t, (s = i.hooks) == null || s.emit(t ? "enable" : "disable"), this.updateRenderAllTags());
}
/**
* @description 修改3D标签normal
* @param {TagId} id
* @param {ArrayPosition} normal
*/
changeTagNormalById(e, t) {
const i = this.getTagById(e);
i && i.tag3DContentSvelte && (i.tag3DContentSvelte.currentNormal = S(t));
}
/**
* @description 改变data
*/
changePositionById(e, t) {
const i = this.getTagById(e);
if (!i)
return;
i.originPosition = t, i.position = t, this.clearCacheById(e);
const s = this.getVisible(i);
i.state && (i.state.visible = s), i.stickType === "2DPoint" || i.stickType === "3DPoint" ? this.updatePointTagPosition() : this.updateRenderAllTags();
}
/**
* @description 改变data
*/
changeDataById(e, t, i = !0) {
const s = this.getTagById(e);
let o = !1;
s && (s.data && (o = !0), i ? s.data = g(s.data, t) : s.data = m(m({}, s.data), t), this.clearUnusedPanelTag(), this.updateRenderAllTags(), o && s.hooks.emit("dataChanged", s.data));
}
/**
* @description 改变tag的stickType
*/
changeStickTypeById(e, t, i = !0) {
this.changeTagById(e, t, i);
}
/**
* @description 改变tag任意属性
*/
changeTagById(e, t, i = !0) {
const s = this.getTagById(e);
let o = !1;
t && (this.tagsLengthWillUpdate = !0, t.data && (o = !0), i ? g(s, t) : Object.assign(s, t), s != null && s.tag3DContentSvelte && (t != null && t.normal) && (s.tag3DContentSvelte.currentNormal = S(t.normal)), this.clearCacheById(e), this.setVisible(), this.updateRenderAllTags(), this.clearUnusedPanelTag(), o && s.hooks.emit("dataChanged", s.data));
}
/**
* @description 销毁tag
*/
destroyTagById(e) {
(Array.isArray(e) ? e : [e]).forEach((i) => {
const s = this.tags.findIndex((o) => o.id === i);
s !== -1 && this.tags.splice(s, 1);
}), this.tagsLengthWillUpdate = !0, this.updateRenderAllTags(), this.updateDomView();
}
/**
* @description 设置 visible 和 unfolded
*/
setVisibleAndUnfolded() {
return c(this, arguments, function* ({ withAnimation: e } = { withAnimation: !1 }) {
return this.store.visibleWithAnimation = e, this.setVisible(), e ? new Promise((t) => {
setTimeout(() => {
this.setUnfoldedByPanoIndex(), t();
}, 10);
}) : (this.setUnfoldedByPanoIndex(), Promise.resolve());
});
}
handleShow() {
this.state.visible = !0, this.group.visible = !0, this.updateTagContainerVisible(), this.updateTagModelVisible(), this.five.needsRender = !0;
}
handleHide() {
this.pauseCurrentMedia(), this.state.visible = !1, this.group.visible = !1, this.updateTagContainerVisible(), this.updateTagModelVisible(), this.five.needsRender = !0;
}
handleEnable() {
this.state.enabled = !0, this.store.eventListenerDisposer = this.addEventListener(), this.five.scene.children.includes(this.group) || this.five.scene.add(this.group), this.group.traverse((e) => {
var t;
(t = e == null ? void 0 : e.updateTagCss3DObjectMatrix) == null || t.call(e);
}), this.updateRenderAllTags(), this.five.needsRender = !0;
}
handleDisable() {
var e, t, i;
this.pauseCurrentMedia(), this.state.enabled = !1, (t = (e = this.store).eventListenerDisposer) == null || t.call(e), this.five.scene.remove(this.group), (i = this.TagContainerSvelte) == null || i.$set({ tags: [] }), this.filterCSS3DTag.forEach((s) => {
var o;
(o = s.tag3DContentSvelte) == null || o.dispose(), s.tag3DContentSvelte = void 0;
}), this.five.needsRender = !0;
}
/**
* @description 添加 cameraUpdate, panoArrived 等事件监听
*/
addEventListener() {
const { five: e, hooks: t } = this;
let i = !1;
const s = w(() => {
i || (i = !0, e.ready().then(() => {
this.onFiveEveryReady(), i = !1;
}));
}, 150);
return e.on("cameraUpdate", s), this.updateVisible(), this.handleFivePanoArrived(), e.on("wantsMoveToPano", this.handleFiveWantsMoveToPano), e.on("modeChange", this.updateVisible), e.on("initAnimationEnded", this.updateVisible), e.on("modelShownFloorChange", this.handleFiveModelShownFloorChange), e.on("cameraUpdate", this.handleFiveCameraUpdate), e.on("panoArrived", this.handleFivePanoArrived), e.on("panoArrived", this.loadVideoFirstFrame), t.on("click", this.clickhandler), () => {
e.off("wantsMoveToPano", this.handleFiveWantsMoveToPano), e.off("modeChange", this.updateVisible), e.off("initAnimationEnded", this.updateVisible), e.off("modelShownFloorChange", this.handleFiveModelShownFloorChange), e.off("cameraUpdate", this.handleFiveCameraUpdate), e.off("cameraUpdate", s), e.off("panoArrived", this.handleFivePanoArrived), e.off("panoArrived", this.loadVideoFirstFrame), t.off("click", this.clickhandler), this.store.eventListenerDisposer = void 0;
};
}
addResizeListener() {
if (!this.store.resizeObserverDisposer && !this.store.resizeObserverDisposerAdding) {
const e = this.addResizeObserver();
this.store.resizeObserverDisposerAdding = !0, setTimeout(() => {
this.store.resizeObserverDisposer = e, this.store.resizeObserverDisposerAdding = !1;
}, 200);
}
}
addResizeObserver() {
if (!this.store.disposed)
return;
const e = this.five.getElement(), t = () => {
this.state.enabled && (this.show(), this.updateRenderAllTags());
}, i = () => {
this.state.enabled && this.hide();
}, { observe: s, unobserve: o } = k(
w(() => {
this.store.resizeObserverDisposer && i();
}, 500),
e
), { observe: r, unobserve: n } = k(
G(() => t(), 400),
e
);
return s(), r(), () => {
o(), n();
};
}
setUnfoldedByCamera() {
let e = !1;
this.filterPointTag.forEach((t) => {
const i = this.getUnfoldedByCamera(t);
if (t.state && i !== void 0) {
if (i === !0 && t.screenPosition) {
const s = this.getTagConfig(t).unfoldedConfig;
I(s).keep !== "unfolded" && (e = !0);
}
t.state.unfolded = i;
}
}), e && this.filterPointTag.forEach((t) => {
const i = this.getTagConfig(t).unfoldedConfig;
typeof i == "object" && (i.autoUnfold || i.autoUnfold === !1 || I(i.autoUnfold).enable === !1 || i.keep) || t.state && (t.state.unfolded = !1);
});
}
changeTagMode(e, t) {
var i, s, o, r, n, a;
((i = e.config) == null ? void 0 : i.renderType) !== "Mesh" && ((r = (o = (s = e.tag3DContentSvelte) == null ? void 0 : s.css3DInstance) == null ? void 0 : o.css3DObject) == null ? void 0 : r.mode) !== t && ((n = e.config) != null && n.tag3DConfig ? e.config.tag3DConfig.mode = t : e.config ? e.config.tag3DConfig = { mode: t } : e.config = { tag3DConfig: { mode: t } }, (a = this.store.css3DRenderDisposer.get(e.id)) == null || a.forEach((l) => l == null ? void 0 : l()), e.tag3DContentSvelte = void 0);
}
}
export {
zi as PanoTagPluginController,
zi as default,
Gi as pluginFlag
};