UNPKG

@realsee/dnalogel

Version:
316 lines (315 loc) 13.1 kB
var b = Object.defineProperty; var w = Object.getOwnPropertySymbols; var T = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable; var p = (s, e, t) => e in s ? b(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, h = (s, e) => { for (var t in e || (e = {})) T.call(e, t) && p(s, t, e[t]); if (w) for (var t of w(e)) U.call(e, t) && p(s, t, e[t]); return s; }; var i = (s, e, t) => (p(s, typeof e != "symbol" ? e + "" : e, t), t); import l from "./EditController.js"; import P from "./ViewController.js"; import v from "./WatchController.js"; import a from "./MixedController.js"; import { omit as k } from "../../shared-utils/filter.js"; import { Group as D } from "three"; import { Model as E } from "../Model/index.js"; import { Subscribe as x } from "@realsee/five"; import { getMouseGroup as G } from "../utils/mouseGroup.js"; import { UIController as S } from "../Modules/UIController/index.js"; import { GuideController as L } from "../Modules/GuideController.js"; import { ShortcutKeyController as O } from "./ShortcutKeyController.js"; import { safeObj as I } from "../../shared-utils/safeObj.js"; import { Magnifier as A } from "../../shared-utils/three/Magnifier.js"; import "../../vendor/@tweenjs/tween/dist/tween.esm.js.js"; import "../../CSS3DRenderPlugin/utils/three/CSS3DRender.js"; import "../../CSS3DRenderPlugin/utils/generateBehindFiveElement.js"; import { isTouchDevice as B } from "../../shared-utils/isTouchDevice.js"; import "../Model/line.js"; import "../../shared-utils/uuid.js"; import "../utils/line.js"; import "@realsee/five/line"; import "../utils/constants.js"; import "../utils/dom/distanceItem.js"; import "../utils/dom/base.js"; import "../utils/isNDCPointInScreen.js"; import "../../shared-utils/three/centerPoint.js"; import "../Model/point.js"; import "../../shared-utils/throttle.js"; import "./BaseController.js"; import "../utils/ironbox.js"; import "../Model/polyline.js"; import "../Model/area.js"; import "../Model/polygon.js"; import "../../shared-utils/three/IObject3D.js"; import "../utils/generatePolygonGeometry.js"; import "earcut"; import "../utils/dom/areaDom.js"; import "../utils/geometryUtil.js"; import "hammerjs"; import "../../shared-utils/isNil.js"; import "../utils/isIntersecting.js"; import "../../shared-utils/three/PointSelector.js"; import "../../shared-utils/three/PointSelectorHelper.js"; import "../../shared-utils/three/PointHelper.js"; import "../../shared-utils/three/Assets/index.js"; import "../../shared-utils/three/PointDomHelper.js"; import "../Modules/rangePiece/html.js"; import "../../CSS3DRenderPlugin/index.js"; import "../../CSS3DRenderPlugin/Controller.js"; import "../../CSS3DRenderPlugin/utils/waitFiveModelLoaded.js"; import "../../shared-utils/url/absoluteUrl.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/getObjectVisible.js"; import "../../CSS3DRenderPlugin/utils/three/CSS3DScene.js"; import "../../CSS3DRenderPlugin/utils/three/CSS3DGroup.js"; import "../../shared-utils/animationFrame/BetterTween.js"; import "../../shared-utils/animationFrame/index.js"; import "../../shared-utils/getIntersectionFromEvent.js"; import "../../shared-utils/getPointFromHammerEvent.js"; import "../../shared-utils/three/getIntersect.js"; import "../Modules/DeleteDom/index.js"; import "../Modules/DeleteDom/_Assets/delete.svg.js"; import "../Modules/DeleteDom/_Assets/delete_bg.png.js"; import "../Modules/DeleteDom/_Assets/delete_hover_bg.png.js"; import "../utils/math.js"; import "../utils/findClosestPoint.js"; import "../utils/ndc2Screen.js"; import "../Modules/rangePiece/index.js"; import "../../shared-utils/noop.js"; import "../utils/calculateThreeMouse.js"; import "../../shared-utils/tap.js"; import "../Modules/UIController/HTML.js"; import "../Modules/UIController/mobileHTML.js"; import "../Modules/UIController/style.js"; import "../Modules/UIController/MainBtnController.js"; import "../Modules/UIController/mobileMainBtnController.js"; import "../Modules/UIController/Revoke/index.js"; import "../Components/Controller0.js"; import "../../vendor/svelte/internal/index.js"; import "../Components/Common/Switcher0.js"; import "../Components/Common/Exit.js"; import "../Components/Common/icons/index.js"; import "../Components/Controller1.js"; import "../Components/Common/Switcher1.js"; import "../Components/Common/CircleButton.js"; import "../../vendor/svelte/transition/index.js"; import "../../vendor/svelte/easing/index.js"; import "../../vendor/object-assign-deep/objectAssignDeep.js"; import "../Components/Tip.js"; class Et { constructor(e, t) { i(this, "hasOpen", !1); i(this, "hook", new x()); i(this, "magnifier"); i(this, "controller", null); /** 允许的测量类型 */ i(this, "allowMeasureType"); /** 当前的测量类型 */ i(this, "currentMeasureType"); i(this, "five"); i(this, "model"); i(this, "group"); i(this, "config"); i(this, "isMobile"); i(this, "useUIController"); i(this, "params"); i(this, "useGuideController"); i(this, "container", document.createElement("div")); i(this, "shortcutKeyController"); /** 关闭插件功能 * @description 清除标尺线条 * @description 还原点位展示和默认鼠标 UI */ i(this, "disable", () => { var e, t, r, o; this.hasOpen = !1, this.container.style.opacity = "0", (e = this.controller) == null || e.dispose(), (t = this.useUIController) == null || t.hide(), (r = this.useGuideController) == null || r.hide(), (o = this.shortcutKeyController) == null || o.dispose(), this.controller = null, this.five.helperVisible = !0, this.five.scene.remove(this.group), this.five.needsRender = !0, this.hook.emit("disable", !0); }); i(this, "getCurrentMode", () => this.controller instanceof l ? "Edit" : this.controller instanceof v ? "Watch" : this.controller instanceof a ? "Mixed" : this.controller instanceof P ? "View" : null); /** 变更场景 * @description 如果从编辑场景改变到观看场景,不会自动保存,默认丢弃所有改动 */ i(this, "changeMode", (e) => { var o; if (!this.hasOpen || this.getCurrentMode() === e) return; (o = this.controller) == null || o.dispose(); const t = { View: P, Watch: v, Edit: l, Mixed: a }; if (!t[e]) throw new Error("不存在的 Mode"); const r = this.createControllerParams(); this.controller = new t[e](r), this.hook.emit("modeChange", e); }); /** * @description: 切换测量的类型 */ i(this, "changeMeasureType", (e) => { this.currentMeasureType = e, this.hook.emit("measureTypeChange", e); }); var n, c, u, d, f, g, M, y, C; this.five = e, this.params = t, this.config = k(t, ["openParams", "magnifierParams"]), this.model = new E(this.config), this.isMobile = (c = (n = t == null ? void 0 : t.openParams) == null ? void 0 : n.isMobile) != null ? c : !1, this.magnifier = new A(e, (u = t.magnifierParams) != null ? u : { width: 190, height: 190, scale: 2 }), this.allowMeasureType = Array.from(new Set((f = (d = t.editParams) == null ? void 0 : d.allowMeasureType) != null ? f : ["line"])), this.currentMeasureType = (g = this.allowMeasureType[0]) != null ? g : "line", this.group = new D(), this.group.name = "plugin-measure-group", this.container.classList.add("five-plugin-measure-container"), this.container.style.position = "absolute", this.container.style.left = "0", this.container.style.top = "0", this.container.style.pointerEvents = "none", this.container.style.width = "100%", this.container.style.height = "100%", this.container.style.opacity = "0"; const r = (y = (M = t.editParams) == null ? void 0 : M.pointSelectorMode) != null ? y : B ? "fixed" : "cursor", o = (C = this.params.openParams) != null ? C : {}; if (this.params.useUIController !== !1) { const m = h({ container: this.container, openParams: o, i18n: t.i18n, pointSelectorMode: r, useNewUI: this.allowMeasureType.length > 1 }, I(this.params.useUIController)); this.useUIController = new S(this, m); } if (this.params.useGuideController !== !1) { const m = h({ container: this.container, pointSelectorMode: r, i18n: t.i18n }, I(this.params.useGuideController)); this.useGuideController = new L(this, m); } } appendTo(e) { e.append(this.container); } clear() { this.model.clear(); } dispose() { var e, t; this.disable(), this.clear(), (e = this.useUIController) == null || e.dispose(), (t = this.magnifier) == null || t.dispose(), this.five.needsRender = !0; } /** 加载数据 * @description 数据加载时会覆盖当前已保存的数据 * @description 如果当前正在编辑中,会自动退出并保存编辑 */ load(e) { this.model.parse(e), this.save(); } /** 插件功能入口 * @description 会隐藏鼠标的默认聚焦环 * @description 会隐藏当前 VR 内的点位展示 */ enable(e) { var t; this.hasOpen || (this.hasOpen = !0, this.five.scene.add(this.group), this.container.style.opacity = "1", e != null && e.mode ? this.changeMode(e.mode) : this.isMobile ? this.changeMode("Mixed") : this.changeMode("Watch"), (t = this.useUIController) == null || t.show(), this.shortcutKeyController = new O(this, this.five), this.hook.emit("enable", !0)); } /** 进入编辑模式 */ edit(e) { e && this.changeMeasureType(e); const t = this.isMobile ? "Mixed" : "Edit"; this.changeMode(t); } /** 撤销编辑 */ revoke() { this.controller instanceof l && this.controller.revoke(); } removePolyline(e) { this.model.removePolyline(e); } removeArea(e) { this.model.removeArea(e); } removePolylineByID(e) { const t = this.model.getPolylineByID(e); t && this.model.removePolyline(t); } getPolylineByID(e) { return this.model.getPolylineByID(e); } getEditedPolyline() { } /** * 高亮当前线段 */ highlightLine(e) { if (this.getCurrentMode() !== "Watch") return !1; const t = this.model.getLineByID(e); return t ? (this.controller.highlightLine(t), !0) : !1; } clearHighlightLines() { return this.getCurrentMode() !== "Watch" ? !1 : (this.controller.clearHighlightLines(), !0); } /** 保存编辑 * @description 以下情况可能报错 */ save(e) { var o; if (!(this.controller instanceof l) && !(this.controller instanceof a)) return this; const t = (o = e == null ? void 0 : e.mode) != null ? o : "View", r = this.controller.model.areas; return this.controller instanceof l ? this.controller.complete() : r.forEach((n) => { n.showArea(), this.model.addArea(n); }), this.changeMode(t), this; } /** Mixed 模式才有用,添加起点 */ addStartPoint() { this.controller instanceof a && this.hook.emit("willChangeState", "watching", "editing"); } /** Mixed 模式才有用,添加终点 */ addEndPoint() { this.controller instanceof a && this.hook.emit("willChangeState", "editing", "watching"); } /** 导出数据 */ toJson() { return this.model.toJson(); } /** * @deprecated 暂不支持 * @description 改变插件的模式(pc端模式或移动端模式) * @param isMobile true为移动端模式,false为pc端 */ changeIsMobile(e) { } changeConfigs(e) { var t, r; Object.assign(this.config, e), (t = this.controller) == null || t.updateDistanceUI(), (r = this.controller) == null || r.updateAreaUI(); } /** 设置线段的文本 */ setCustomText(e, t) { var o; const r = this.model.getLineByID(e); if (!r) throw new Error("不存在的线段"); r.setText(t), (o = this.controller) == null || o.updateDistanceUI(); } createControllerParams() { var r, o; const e = (r = this.params.openParams) != null ? r : {}, t = (o = this.params.editParams) != null ? o : {}; return e.isMobile = this.isMobile, { five: this.five, hook: this.hook, group: this.group, model: this.model, config: this.config, magnifier: this.magnifier, container: this.container, openParams: e, editParams: t, magnifierParams: this.params.magnifierParams, getMeasureType: () => this.currentMeasureType, mouseGroup: G(h({}, e.crossHairParameter)), userDistanceItemCreator: this.params.userDistanceItemCreator }; } } export { Et as default };