@realsee/dnalogel
Version:
561 lines (560 loc) • 26.5 kB
JavaScript
var D = Object.defineProperty, T = Object.defineProperties;
var R = Object.getOwnPropertyDescriptors;
var P = Object.getOwnPropertySymbols;
var k = Object.prototype.hasOwnProperty, H = Object.prototype.propertyIsEnumerable;
var w = (l, h, t) => h in l ? D(l, h, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[h] = t, d = (l, h) => {
for (var t in h || (h = {}))
k.call(h, t) && w(l, t, h[t]);
if (P)
for (var t of P(h))
H.call(h, t) && w(l, t, h[t]);
return l;
}, u = (l, h) => T(l, R(h));
var o = (l, h, t) => (w(l, typeof h != "symbol" ? h + "" : h, t), t);
var c = (l, h, t) => new Promise((e, i) => {
var s = (a) => {
try {
r(t.next(a));
} catch (m) {
i(m);
}
}, n = (a) => {
try {
r(t.throw(a));
} catch (m) {
i(m);
}
}, r = (a) => a.done ? e(a.value) : Promise.resolve(a.value).then(s, n);
r((t = t.apply(l, h)).next());
});
import S from "./items.js";
import * as v from "three";
import { to as U } from "../../shared-utils/to.js";
import { equal as z } from "../../shared-utils/equal.js";
import { Main as W } from "../Components/Main.js";
import { formatData as x } from "../utils/formatData.js";
import { CAMERA_IMAGE as N } from "../Assets/camera.js";
import { omit as A } from "../../shared-utils/filter.js";
import { FLOOR_PLAN_ATTACHED_TO as G } from "../constant.js";
import { Controller as j } from "../../base/BasePluginWithData.js";
import { getPxmm as B, getAttachedY as C } from "../../shared-utils/getPxmm.js";
import { correctFiveState as V } from "../utils/correctFiveState.js";
import { changeModelCanvasOpacity as I } from "../../shared-utils/changeModelCanvasOpacity.js";
import { FloorplanErrorType as f, SHOW_ANIME_DURATION as Z } from "../utils/constant.js";
import "../../shared-utils/tag.js";
import "../../vendor/hammerjs/hammer.js";
import "../../shared-utils/three/PointSelector/index.js";
import "../../shared-utils/three/CSS3DRenderer/index.js";
import { waitFiveModelLoaded as $ } from "../../shared-utils/five/fiveModelLoad.js";
import "../../CSS3DRenderPlugin/utils/generateBehindFiveElement.js";
import "@realsee/five/line";
import { isNil as Y } from "../../shared-utils/isNil.js";
import "../../shared-utils/three/core/Five_LineMaterial2.js";
import "../../shared-utils/three/core/Sphere.js";
import "../../shared-utils/three/blink.js";
import "../../vendor/@tweenjs/tween/dist/tween.esm.js.js";
import "../../CSS3DRenderPlugin/utils/three/CSS3DRender.js";
import "../../vendor/earcut/src/earcut.js";
import { FLOORPLAN_DEFAULT_IMAGE as q } from "../../shared-utils/url/defaultUrls.js";
import { replaceStaticPrefix as J } from "../../shared-utils/url/replace-static-prefix.js";
import "../../shared-utils/five/FivePuppet.js";
import "../../shared-utils/isTruelyObject.js";
import "../../vendor/svelte/internal/index.js";
import "../../vendor/svelte/transition/index.js";
import "../../vendor/svelte/easing/index.js";
import "../Components/CurrentFloor.js";
import "../../vendor/svelte/store/index.js";
import "../Components/BaseImage.js";
import "../Components/Normalmage.js";
import "../Components/SvgImage.js";
import "../Components/Items/Items.js";
import "../Components/Items/Item.js";
import "../../shared-utils/svelte/resizeObserver.js";
import "../../vendor/resize-observer-polyfill/dist/ResizeObserver.es.js";
import "../Components/RoomLabels/RoomLabels.js";
import "../Components/RoomLabels/RoomLabel.js";
import "../../shared-utils/fontSize.js";
import "../../shared-utils/px2rem.js";
import "../Components/RuleLabels/RuleLabels.js";
import "../Components/RuleLabels/RuleItem.js";
import "../Components/RoomMaterials/RoomMaterial.js";
import "../utils/formatPosition.js";
import "../Components/RoomMaterials/RoomMaterial_0.js";
import "../Components/RoomMaterials/RoomMaterial_1.js";
import "../Components/RoomMaterials/RoomMaterial_2.js";
import "../Components/RoomMaterials/RoomTriangle.js";
import "../Components/RoomHighlight/RoomHighlight.js";
import "../Components/RoomHighlight/Room.js";
import "../Components/MissingFloor.js";
import "../Components/Camera.js";
import "../../shared-utils/math/rad2Deg.js";
import "../Components/Compass.js";
import "../Assets/compass.js";
import "../Assets/floorplanExtraObject.js";
import "../../shared-utils/tap.js";
import "../../base/BasePlugin.js";
import "../../shared-utils/Subscribe.js";
import "../../shared-utils/Utils/FiveUtil.js";
import "../../shared-utils/Utils/BaseUtil.js";
import "../../shared-utils/Utils/WorkUtil.js";
import "../../shared-utils/five/transformPosition.js";
import "../../shared-utils/five/getFiveModel.js";
import "../../shared-utils/nearlyEqual.js";
import "../../shared-utils/five/changeMode.js";
import "../../shared-utils/translateMode/getDistanceFromModel.js";
import "../../shared-utils/positionToVector3.js";
import "../../shared-utils/five/vector3ToScreen.js";
import "../../shared-utils/three/temp.js";
import "../../shared-utils/three/core/Raycaster.js";
import "../../shared-utils/dom/resizeObserver.js";
import "../../shared-utils/five/fiveEveryReadyListener.js";
import "../../shared-utils/throttle.js";
import "../../shared-utils/three/PointSelector/utils/PointSelectorHelper.js";
import "../../shared-utils/three/Magnifier.js";
import "../../shared-utils/three/PointSelector/utils/PointHelper.js";
import "../../shared-utils/three/Assets/index.js";
import "../../CSS3DRenderPlugin/utils/three/CSS3DObject.js";
import "../../shared-utils/even.js";
import "../../shared-utils/CSS3DRender/OpacityMesh.js";
import "../../shared-utils/three/centerPoint.js";
import "../../shared-utils/three/getObjectVisible.js";
import "../../shared-utils/three/PointSelector/utils/html.js";
import "../../shared-utils/CSS3DRender/index.js";
import "../../shared-utils/CSS3DRender/CSS3DRenderer.js";
import "../../shared-utils/createResizeObserver.js";
import "../../shared-utils/three/PointSelector/utils/PointHelper2.js";
import "../../Sculpt/Meshes/Line.js";
import "../../Sculpt/typings/style.js";
import "../../shared-utils/three/IObject3D.js";
import "../../Sculpt/utils/Meshes/getLengthHTML.js";
import "../../shared-utils/three/applyObjectMatrixWorld.js";
import "../../shared-utils/util.js";
import "../../shared-utils/five/getFiveFromParentChain.js";
import "../../shared-utils/three/core/LineGeometry.js";
import "../../shared-utils/three/core/LineMaterial.js";
import "../../shared-utils/three/core/Line2.js";
import "../../shared-utils/three/core/LineMaterial2.js";
import "../../Sculpt/utils/unit.js";
import "../../Sculpt/utils/renderDom.js";
import "../../CSS3DRenderPlugin/utils/three/CSS3DSprite.js";
import "../../shared-utils/isTouchDevice.js";
import "../../shared-utils/five/getPosition.js";
import "../../shared-utils/five/getRaycasterByNdcPosition.js";
import "../../shared-utils/three/PointSelector/utils/contents.js";
import "../../Sculpt/utils/three/rayOnLine.js";
import "../../vendor/animejs/lib/anime.es.js";
import "../../CSS3DRenderPlugin/utils/three/CSS3DScene.js";
import "../../CSS3DRenderPlugin/utils/getAllCSS3DObject.js";
import "../../CSS3DRenderPlugin/utils/three/CSS3DGroup.js";
import "@realsee/five";
import "../../shared-utils/url/absoluteUrl.js";
const X = "//vr-image-4.realsee-cdn.cn/release/static/image/doctorstrange/0.6.201-beta/";
function K(l) {
const { latitude: h, longitude: t } = l, e = Math.abs(h - Math.PI / 2) > 5 * Math.PI / 180, i = t > 5 * (Math.PI / 180) && t < 355 * (Math.PI / 180);
return e || i;
}
function Q(l) {
const { latitude: h, longitude: t } = l, e = Math.abs(h - Math.PI / 2) < 10 * Math.PI / 180, i = t < 30 * (Math.PI / 180) || t > 330 * (Math.PI / 180);
return e && i;
}
class ci extends j {
constructor(t, e) {
var a, m;
super(t);
// =============== public properties =================
o(this, "name", "modelFloorplanPlugin");
o(this, "state");
// =============== private properties =================
o(this, "data");
/** 展示户型图时,需要正确的状态 */
o(this, "showState");
/** show 动画的公共 Promise */
o(this, "showPromise");
o(this, "app");
o(this, "panoIndex", 0);
o(this, "floorIndex", 0);
o(this, "selector");
/** 公共 Promise 的 reject 方法 */
o(this, "showRejection");
/** 户型图父容器 */
o(this, "wrapper");
/** 户型图主容器 */
o(this, "container", document.createElement("div"));
/** 展示户型图图前,Five 的 Panorama Longitude */
o(this, "lastPanoramaLongitude", 0);
/** 户型图大小 */
o(this, "size", { width: 0, height: 0 });
o(this, "defaultMissingFloorConfig");
/** 是否已经执行过事件监听 */
o(this, "hasAddedEventListener", !1);
/** 上一次隐藏是否是用户调用了 hide 导致的 */
o(this, "isHiddenByHideFunc", !1);
/** 高亮区域 */
o(this, "highlightData", {});
o(this, "items");
o(this, "store", { roomOnMouse: null });
/** 销毁插件 */
o(this, "dispose", () => {
var t, e;
this.removeEventListener(), (t = this.app) == null || t.$destroy(), this.app = void 0, (e = this.container) == null || e.remove(), this.data = void 0, this.wrapper = void 0, this.selector = void 0, this.hooks.emit("dispose");
});
/** 展示户型图
* 1. show 函数大部分情况下需要耗时
* 2. 如果当前已经在展示中,将不会触发任何事件
* 3. 如果展示过程被中断,将抛出错误
* 4. 多次调用 show 方法,只会触发一次 showAnimationEnded 事件,但是展示结果会取决于最后一次调用参数
* 5. 如果多次调用 show 方法,参数与上次参数不一致时,上次 show Promise 会被 reject
* @param opts.floorIndex 楼层
* @param opts.modelOpacity 模型透明度
* @param opts.immediately 是否立即展示
* @param opts.isAutoShow 是否是自动展示
* @param opts.userAction 是否是用户行为
*/
o(this, "show", (...e) => c(this, [...e], function* (t = {}) {
if (!this.state.enabled || !this.showPromise && this.state.visible)
return;
const i = t.userAction !== void 0 ? t.userAction : !0;
this.updateState({ visible: !0 }, i), this._show(t);
}));
/** 隐藏户型图 */
o(this, "hide", (...e) => c(this, [...e], function* (t = {}) {
this.state.enabled && (this.isHiddenByHideFunc = !0, this.state.visible !== !1 && (this.updateState({ visible: !1 }, t.userAction || !0), this._hide(t)));
}));
/** 更新户型图大小 */
o(this, "updateSize", () => {
if (!this.data || !this.container || !this.wrapper)
return !1;
const { min: t, max: e } = this.data.bounding, i = e.x - t.x, s = e.y - t.y, n = this.getPxmmWithRotation(), r = Math.ceil(i * n), a = Math.ceil(s * n);
return this.size.width === r && this.size.height === a || (this.container.style.width = r + "px", this.container.style.height = a + "px", this.size = { width: r, height: a }), !0;
});
o(this, "highlight", (t) => {
this.state.config.highlightEnable && (this.highlightData = t, this.render());
});
o(this, "unhighlight", () => {
this.highlightData = {}, this.render();
});
/** 更新展示状态
* @description 可以更新 longitude、latitude、offset 等参数
* @param showState 需要更新的状态,会与现有状态合并
* @example
* // 更新 longitude
* plugin.updateShowState({ longitude: Math.PI / 2 })
*/
o(this, "updateShowState", (t) => {
this.showState = d(d({}, this.showState), t);
});
o(this, "_disable", (t) => {
var i, s, n;
const { userAction: e } = t;
this.hooks.emit("disable", { userAction: e }), (i = this.showRejection) == null || i.call(this, f.BreakOffByDisable), this.showPromise = void 0, (s = this.app) == null || s.$destroy(), this.app = void 0, (n = this.container) == null || n.remove(), this.removeEventListener();
});
o(this, "_enable", (t) => {
const { userAction: e } = t;
this.addEventListener(), this.wrapper && (this.wrapper.append(this.container), this.hooks.emit("enable", { userAction: e }), this.state.visible && this._show({ userAction: e }));
});
o(this, "_show", (t) => c(this, null, function* () {
var n;
if (!this.state.enabled)
return;
if (!((n = this.fiveUtil.model) != null && n.loaded))
throw new Error(f.ModelNotLoaded);
if (!this.data)
throw new Error(f.DataNotLoaded);
if (this.showPromise)
return this.showPromise;
const e = {
floorIndex: this.floorIndex,
modelOpacity: this.state.config.modelOpacity,
immediately: !1,
isAutoShow: !1,
userAction: !0
}, i = d(d({}, e), t), s = () => c(this, null, function* () {
this.hooks.emit("show", { userAction: i.userAction, auto: i.isAutoShow });
let r = !1, a;
this.showRejection = (g) => {
r = !0, a = g;
};
const [m] = yield U(V(this.five, this.showState, i.userAction));
if (m)
throw m;
if (r)
throw a ? new Error(a) : new Error(f.UnknownError);
if (!this.updateSize())
throw new Error(f.UpdateSizeError);
this.updatePosition(), this.floorIndex = i.floorIndex, this.fiveUtil.model.show(this.floorIndex);
});
return this.isHiddenByHideFunc = !1, this.showPromise = s().then(() => {
this.showPromise = void 0, this.showRejection = void 0;
const r = i.modelOpacity, a = i.immediately ? 0 : Z;
I(this.five, r, a), this.render(a), this.hooks.emit("showAnimationEnded", {
auto: i.isAutoShow,
userAction: i.userAction
});
}).catch((r) => {
if (this.showPromise = void 0, this.showRejection = void 0, this.updateState({ visible: !1 }, i.userAction), !i.isAutoShow && r instanceof Error)
throw r;
}), this.showPromise;
}));
o(this, "_hide", (t) => {
var s;
(s = this.showRejection) == null || s.call(this, f.BreakOffByHide), this.showPromise = void 0;
const i = d(d({}, {
userAction: !0,
isAutoHide: !1
}), t);
I(this.five, 1, 0), this.hooks.emit("hide", { auto: i.isAutoHide, userAction: i.userAction }), this.render();
});
o(this, "handleClick", () => {
if (!this.state.visible)
return;
if (this.hooks.emit("click", this.store.roomOnMouse))
return !1;
});
/** modelLoaded 之后自动执行 append container 操作 */
o(this, "onFiveModelLoaded", () => {
const i = this.five.models.find((n) => n.name === this.five.state.workCode).bounding.getCenter(new v.Vector3());
if (this.showState.offset = i, this.state.enabled === !1 || this.wrapper || !this.selector)
return;
const s = this.selector instanceof Element ? this.selector : document.querySelector(this.selector);
if (!s)
throw new Error("不正确的父容器选择器");
this.wrapper = s, s.append(this.container);
});
/** 更改模型时,自动隐藏户型图 */
o(this, "onFiveModeChange", (t) => {
t !== this.showState.mode && (this.updateState({ visible: !1 }, !1), this._hide({ userAction: !1 }));
});
/** 惯性结束后,判断能否自动展示户型图 */
o(this, "onFiveInteriaPan", (t, e) => {
if (!e || this.state.visible || this.state.config.autoShowEnable === !1 || this.isHiddenByHideFunc)
return;
const i = this.five.getCurrentState();
if (i.mode !== this.showState.mode)
return;
const s = this.getRelativePose(i);
Q(s) && (this.updateState({ visible: !0 }, !0), this._show({ isAutoShow: !0 }));
});
/** panoIndex 改变时,更新 floorIndex */
o(this, "onFivePanoArrived", (t) => {
var e;
(e = this.five) != null && e.work && (this.panoIndex = t, this.floorIndex = this.workUtil.observers[t].floorIndex);
});
/** cameraUpdate 时判断户型图是否应该自动隐藏 */
o(this, "onFiveCameraUpdate", (t, e) => {
if (!this.state.visible || this.showPromise)
return;
const i = this.five.getCurrentState();
this.updatePosition(), this.updateSize();
const s = this.getRelativePose(i);
K(s) && (this.updateState({ visible: !1 }, e), this._hide({ userAction: e }));
});
/** 户型图展示中,转动三维模型,结束时应该自动修复模型状态 */
o(this, "onFiveWantsPanGesture", (t, e) => {
if (this.five.getCurrentState().mode === this.showState.mode && this.state.config.autoShowEnable !== !1 && e && this.state.visible)
return this.five.updateCamera(A(this.showState, ["offset"]), 0), !1;
});
/** 阻止点击分间走点 */
o(this, "onFiveWantsTapGesture", () => this.handleClick());
/** 从 Panorama 切换到其他模态时,记录当前的相机水平视角 */
o(this, "onFiveWantsChangeMode", (t, e) => {
e === "Panorama" && t === this.showState.mode && (this.lastPanoramaLongitude = this.five.getCurrentState().longitude);
});
/** 模型楼层高亮改变时,自动进行楼层切换 */
o(this, "onModelShownFloorChange", (t) => {
if (this.floorIndex !== t) {
if (t === null) {
const e = this.five.getCurrentState().panoIndex;
this.floorIndex = this.workUtil.observers[e].floorIndex;
return;
}
this.floorIndex = t, this.updateSize(), this.render();
}
});
e != null && e.selector && (this.selector = e.selector, console.warn("不推荐继续使用 params.selector 配置父容器,请使用 appendTo 方法")), this.showState = d({
mode: "Mapview",
longitude: 0,
latitude: Math.PI / 2
}, e == null ? void 0 : e.showState), this.defaultMissingFloorConfig = {
imageURL: J(e == null ? void 0 : e.staticPrefix, q),
imageWidth: 200,
imageHeight: 120,
text: (m = (a = e.i18n) == null ? void 0 : a.call(e, "暂无平面图")) != null ? m : "暂无平面图",
textFontSize: 14
};
const i = {
northDesc: "北",
modelOpacity: 1,
cameraEnable: !0,
highlightEnable: !1,
hoverEnable: !0,
compassEnable: !0,
autoShowEnable: !0,
ruleLabelsEnable: !0,
roomLabelsEnable: !0,
roomAreaEnable: !0,
roomNameEnable: !0,
roomNameOtherTypeEnable: !0,
roomDimensionEnable: !0,
cameraImageUrl: N,
attachedTo: G.BOUNDING_CENTER,
getLabelElement: void 0,
adaptiveRoomLabelVisibleEnable: !0,
missingFloorConfig: d(d({}, this.defaultMissingFloorConfig), e.missingFloorConfig),
i18n: (p) => p,
getRoomAreaText: (p) => (p / 1e6).toFixed(1) + "㎡",
getRoomDimensionText: (p, g) => (p / 1e3).toFixed(1) + "m × " + (g / 1e3).toFixed(1) + "m",
getRuleDistanceText: (p) => p.toString()
}, s = e ? A(e, ["selector", "scale"]) : {}, n = d(d({}, i.missingFloorConfig), s.missingFloorConfig), r = u(d(d({}, i), s), { missingFloorConfig: n });
this.state = { enabled: !0, visible: !1, config: r }, this.panoIndex = t.getCurrentState().panoIndex, this.initContainer(), $(t).then(this.onFiveModelLoaded), t.once("dispose", this.dispose), this.addEventListener();
}
load(t, e, i = !0) {
return c(this, null, function* () {
function s(p) {
return Object.prototype.hasOwnProperty.apply(p, ["version"]);
}
const n = t;
n && Y(n.version) && console.warn("传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数");
const r = JSON.parse(JSON.stringify(t)), a = s(r) ? r.data : r, m = this.data;
this.data = yield x(a), this.hooks.emit("dataLoaded", this.data), this.hooks.emit("dataChange", this.data, m), e && this.updateState(e, i), this.render();
});
}
loadItems(t) {
const { min: e, max: i } = this.data.bounding, s = i.x - e.x, n = i.y - e.y;
this.data.floorDatas.forEach((r, a) => {
r.items = t[a].filter((m) => m.displayName === "Item-SimpleItem").map((m) => {
const { x: p, y: g, width: F, height: M, notes: E, type: b, id: y, rotateX: L, rotateY: _, rotateZ: O = 0 } = m;
return {
id: y,
positionInImage: { x: (p - e.x) / s, y: (i.y - g) / n },
width: F / s,
height: M / n,
src: X + S[b].href.replace(/\{\{\stheme\s\}\}/, "realsee"),
notes: E || S[b].description,
rotateX: L,
rotateY: _,
rotateZ: O
};
});
});
}
/** 把插件的渲染DOM插入到对应的容器中去 */
appendTo(t) {
if (this.wrapper = t, !!this.state.enabled)
return t.appendChild(this.container), this.render(), this;
}
/** 启用插件 */
enable(t = {}) {
if (this.state.enabled)
return;
const e = t.userAction !== void 0 ? t.userAction : !0;
this.updateState({ enabled: !0 }, t.userAction || e), this._enable({ userAction: e });
}
/** 禁用插件 */
disable(t = {}) {
if (!this.state.enabled)
return;
const e = t.userAction !== void 0 ? t.userAction : !0;
this.updateState({ enabled: !1 }, t.userAction || e), this._disable({ userAction: e });
}
/** 更改插件 State */
setState(t, e = {}) {
const i = this.state, s = e.userAction !== void 0 ? e.userAction : !0;
if (this.updateState(t, s), t.enabled !== void 0 && i.enabled !== t.enabled && (t.enabled ? this._enable({ userAction: s }) : this._disable({ userAction: s })), t.visible !== void 0 && i.visible !== t.visible) {
const n = { userAction: s };
t.visible ? this._show(n) : this._hide(n);
}
}
changeConfigs(t, e = !0) {
this.updateState({ config: t }, e), this.render();
}
/** 根据旋转角度计算 pxmm
* @description 当 longitude 大于 45° 或小于 -45°(相对于基准方向)时,使用 Z 轴计算
*/
getPxmmWithRotation() {
if (!this.wrapper)
return 0;
const t = this.state.config.attachedTo ? { attachedTo: this.state.config.attachedTo } : void 0, e = this.showState.longitude, i = Math.abs((e % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI));
return i > Math.PI / 4 && i < 3 * Math.PI / 4 || i > 5 * Math.PI / 4 && i < 7 * Math.PI / 4 ? this.getPxmmZAxis(t) : B(this.five, this.wrapper, this.floorIndex, t);
}
/** 使用 Z 轴计算 pxmm
* @description 当相机旋转导致 X 轴接近垂直于屏幕时,改用 Z 轴计算
*/
getPxmmZAxis(t) {
if (!this.wrapper)
return 0;
const e = C(this.five, this.floorIndex, t == null ? void 0 : t.attachedTo), i = new v.Vector3(0, e, 0), s = new v.Vector3(0, e, 1), n = i.clone().project(this.five.camera), r = s.clone().project(this.five.camera);
return Math.abs((r.x - n.x) / 1e3) * (this.wrapper.getBoundingClientRect().width / 2);
}
/** 更新户型图位置 */
updatePosition() {
var r;
const t = C(this.five, this.floorIndex, this.state.config.attachedTo), e = (r = this.fiveUtil.model) == null ? void 0 : r.bounding.getCenter(new v.Vector3()).setY(t);
if (!e)
return;
const i = e.clone().project(this.five.camera), s = (i.x + 1) / 2, n = -(i.y - 1) / 2;
this.container.style.left = s * 100 + "%", this.container.style.top = n * 100 + "%";
}
formatData(t) {
return c(this, null, function* () {
return yield x(t.data);
});
}
updateState(t, e) {
var r;
const i = this.state, s = (r = t.config) != null && r.missingFloorConfig ? d(d({}, i.config.missingFloorConfig), t.config.missingFloorConfig) : i.config.missingFloorConfig, n = t.config ? u(d(d({}, i.config), t.config), { missingFloorConfig: s }) : i.config;
this.state = u(d(d({}, this.state), t), { config: n }), !z(this.state, i, { deep: !0 }) && this.hooks.emit("stateChange", { state: this.state, prevState: i, userAction: e });
}
/** 如果用户是通过 selector 设置父容器,需要在 modelLoaded 之后把 container 自动放到父容器里
*
* - TODO: 等 selector 功能下掉之后删除这个逻辑
*/
initContainer() {
this.container.classList.add("floorplan-plugin"), Object.assign(this.container.style, {
position: "absolute",
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
zIndex: 10,
pointerEvents: "none"
}), this.five.addExtraElement(this.container);
}
addEventListener() {
if (!this.state.enabled || this.hasAddedEventListener)
return;
const t = this.five;
t.on("modeChange", this.onFiveModeChange), t.on("interiaPan", this.onFiveInteriaPan), t.on("panoArrived", this.onFivePanoArrived), t.on("cameraUpdate", this.onFiveCameraUpdate), t.on("wantsPanGesture", this.onFiveWantsPanGesture), t.on("wantsTapGesture", this.onFiveWantsTapGesture), t.on("wantsChangeMode", this.onFiveWantsChangeMode), t.on("modelShownFloorChange", this.onModelShownFloorChange);
}
removeEventListener() {
const t = this.five;
this.hasAddedEventListener = !1, t.off("modelLoaded", this.onFiveModelLoaded), t.off("modeChange", this.onFiveModeChange), t.off("panoArrived", this.onFivePanoArrived), t.off("cameraUpdate", this.onFiveCameraUpdate), t.off("wantsPanGesture", this.onFiveWantsPanGesture), t.off("wantsTapGesture", this.onFiveWantsTapGesture), t.off("wantsChangeMode", this.onFiveWantsChangeMode), t.off("modelShownFloorChange", this.onModelShownFloorChange);
}
/** 获取相对于 showState 的 pose 偏差
* @description 将当前相机状态的 longitude 减去 showState.longitude,归一化后返回
* 这样自动隐藏逻辑会检查相对偏差,而不是绝对值
*/
getRelativePose(t) {
const e = this.showState.longitude || 0, s = ((t.longitude - e) % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI);
return u(d({}, t), { longitude: s });
}
render(t) {
if (!this.state.enabled || !this.container || !this.data || this.size.width === 0 || this.showPromise)
return;
const e = u(d({}, this.state.config), {
visible: this.state.visible,
duration: t != null ? t : 0,
panoIndex: this.panoIndex,
floorIndex: this.floorIndex,
floorplanData: this.data,
lastPanoramaLongitude: this.lastPanoramaLongitude,
highlightData: this.highlightData,
items: this.items,
store: this.store
});
if (this.app)
return this.app.$set(e);
this.app = new W({ target: this.container, intro: !0, props: e });
}
}
export {
ci as Controller
};