@realsee/dnalogel 3.78.0-alpha.4 → 3.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +40 -10
  2. package/dist/DigitalPerformancePlugin/controller/index.d.ts +224 -0
  3. package/dist/DigitalPerformancePlugin/core/DigitalHuman.d.ts +55 -0
  4. package/dist/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +40 -0
  5. package/dist/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +150 -0
  6. package/dist/DigitalPerformancePlugin/core/Trace.d.ts +9 -0
  7. package/dist/DigitalPerformancePlugin/index.d.ts +11 -0
  8. package/dist/DigitalPerformancePlugin/mock.d.ts +76 -0
  9. package/dist/DigitalPerformancePlugin/typings/index.d.ts +79 -0
  10. package/dist/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +0 -6
  11. package/dist/PanoTagPlugin/typings/tag/TagConfig.d.ts +20 -2
  12. package/dist/Sculpt/Meshes/Line.d.ts +4 -0
  13. package/dist/Sculpt/Objects/Base/Editor.d.ts +9 -2
  14. package/dist/index.cjs.js +95 -82
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +14187 -12436
  17. package/dist/index.umd.js +87 -74
  18. package/dist/shared-utils/five/getFiveFromParentChain.d.ts +8 -0
  19. package/libs/AreaMakerPlugin/Controller.js +3 -2
  20. package/libs/AreaMakerPlugin/index.js +3 -2
  21. package/libs/AreaMakerPlugin/utils/Item.js +3 -2
  22. package/libs/CSS3DRenderPlugin/Controller.js +3 -2
  23. package/libs/CSS3DRenderPlugin/index.js +6 -5
  24. package/libs/CSS3DRenderPlugin/utils/three/CSS3DObject.js +39 -38
  25. package/libs/CSS3DRenderPlugin/utils/three/CSS3DRender.js +10 -9
  26. package/libs/CruisePlugin/BaseController.js +5 -4
  27. package/libs/CruisePlugin/Move.js +3 -2
  28. package/libs/CruisePlugin/Work.js +3 -2
  29. package/libs/CruisePlugin/index.js +7 -6
  30. package/libs/CurrentPanoImagePlugin/Controller.js +15 -14
  31. package/libs/CurrentPanoImagePlugin/index.js +4 -3
  32. package/libs/DigitalPerformancePlugin/controller/index.d.ts +2 -2
  33. package/libs/DigitalPerformancePlugin/controller/index.js +164 -173
  34. package/libs/DigitalPerformancePlugin/core/DigitalHuman.d.ts +16 -6
  35. package/libs/DigitalPerformancePlugin/core/DigitalHuman.js +128 -102
  36. package/libs/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +11 -5
  37. package/libs/DigitalPerformancePlugin/core/DigitalPlayground.js +84 -74
  38. package/libs/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +7 -0
  39. package/libs/DigitalPerformancePlugin/mock.d.ts +6 -0
  40. package/libs/DigitalPerformancePlugin/mock.js +272 -274
  41. package/libs/GuideLinePlugin/Controller.js +7 -6
  42. package/libs/GuideLinePlugin/GuideLineItem.js +5 -4
  43. package/libs/GuideLinePlugin/GuideLineModeItem/index.js +51 -48
  44. package/libs/GuideLinePlugin/GuideLineModeItem.js +5 -2
  45. package/libs/GuideLinePlugin/index.js +7 -6
  46. package/libs/MeasurePlugin/Controller.js +11 -10
  47. package/libs/MeasurePlugin/index.js +5 -4
  48. package/libs/MeasurePlugin/utils/MeasureMesh.js +3 -2
  49. package/libs/ModelChassisCompassPlugin/Plugin.js +4 -3
  50. package/libs/ModelChassisCompassPlugin/index.js +1 -0
  51. package/libs/ModelEntryDoorGuidePlugin/Plugin.js +6 -5
  52. package/libs/ModelEntryDoorGuidePlugin/index.js +1 -0
  53. package/libs/ModelMakerPlugin/Controller.js +3 -2
  54. package/libs/ModelMakerPlugin/index.js +3 -2
  55. package/libs/ModelMakerPlugin/item/baseItem.js +3 -2
  56. package/libs/ModelMakerPlugin/item/boxItem.js +3 -2
  57. package/libs/ModelMakerPlugin/item/polygonItem.js +3 -2
  58. package/libs/ModelMakerPlugin/item/prismItem.js +3 -2
  59. package/libs/ModelTVVideoPlugin/Plugin.js +4 -3
  60. package/libs/ModelTVVideoPlugin/index.js +3 -2
  61. package/libs/ModelViewPlugin/Plugin.js +20 -19
  62. package/libs/ModelViewPlugin/index.js +1 -0
  63. package/libs/Object3DHelperPlugin/Controller.js +3 -2
  64. package/libs/Object3DHelperPlugin/index.js +6 -5
  65. package/libs/PanoCompassPlugin/Controller.js +3 -2
  66. package/libs/PanoCompassPlugin/index.js +4 -3
  67. package/libs/PanoDoorLabelPlugin/Controller.js +24 -23
  68. package/libs/PanoDoorLabelPlugin/index.js +4 -3
  69. package/libs/PanoMeasurePlugin/Components/Controller0.js +3 -2
  70. package/libs/PanoMeasurePlugin/Components/Controller1.js +3 -2
  71. package/libs/PanoMeasurePlugin/Controller/EditController.js +3 -2
  72. package/libs/PanoMeasurePlugin/Controller/WatchController.js +3 -2
  73. package/libs/PanoMeasurePlugin/Controller/index.js +3 -2
  74. package/libs/PanoMeasurePlugin/Model/area.js +3 -2
  75. package/libs/PanoMeasurePlugin/Modules/Magnifier.js +1 -0
  76. package/libs/PanoMeasurePlugin/Modules/UIController/index.js +16 -15
  77. package/libs/PanoMeasurePlugin/index.js +14 -13
  78. package/libs/PanoMeasurePlugin/utils/dom/areaDom.js +3 -2
  79. package/libs/PanoRulerProPlugin/Controller.js +3 -2
  80. package/libs/PanoRulerProPlugin/RulerItems.js +42 -41
  81. package/libs/PanoRulerProPlugin/index.js +4 -3
  82. package/libs/PanoSpatialTagPlugin/Plugin.js +34 -33
  83. package/libs/PanoSpatialTagPlugin/index.js +1 -0
  84. package/libs/PanoTagPlugin/Components/Common/TagPoint.js +141 -138
  85. package/libs/PanoTagPlugin/Components/Common/TagPopover/PopoverContent.js +3 -2
  86. package/libs/PanoTagPlugin/Components/Common/TagPopover/TagPopoverToolBar.js +3 -2
  87. package/libs/PanoTagPlugin/Components/Common/TagPopover/index.js +3 -2
  88. package/libs/PanoTagPlugin/Components/Tag/MarketingTag.js +3 -2
  89. package/libs/PanoTagPlugin/Components/Tag/index.js +3 -2
  90. package/libs/PanoTagPlugin/Components/TagContainer.js +3 -2
  91. package/libs/PanoTagPlugin/Components/TagItem.js +131 -122
  92. package/libs/PanoTagPlugin/controller/Tag/BaseTag.js +3 -2
  93. package/libs/PanoTagPlugin/controller/Tag/BoxTag.js +3 -2
  94. package/libs/PanoTagPlugin/controller/Tag/MaskTag.js +1 -0
  95. package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +0 -6
  96. package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.js +2 -90
  97. package/libs/PanoTagPlugin/controller/Tag/ModelTag.js +3 -2
  98. package/libs/PanoTagPlugin/controller/Tag/PlaneTag.js +3 -2
  99. package/libs/PanoTagPlugin/controller/Tag/PointTag.js +3 -2
  100. package/libs/PanoTagPlugin/controller/Tag/PolygonTag.js +31 -29
  101. package/libs/PanoTagPlugin/controller/TagRender.js +3 -2
  102. package/libs/PanoTagPlugin/controller/TagUtil.js +3 -2
  103. package/libs/PanoTagPlugin/controller/index.js +30 -29
  104. package/libs/PanoTagPlugin/index.js +12 -11
  105. package/libs/PanoTagPlugin/typings/tag/TagConfig.d.ts +20 -2
  106. package/libs/PanoTagPlugin/utils/tag/calculateTagConfig.js +3 -2
  107. package/libs/PanoTagPlugin/utils/tag/format.js +3 -2
  108. package/libs/PanoVideoPlugin/Controller.js +9 -8
  109. package/libs/PanoVideoPlugin/VideoMeshController.js +3 -2
  110. package/libs/PanoVideoPlugin/index.js +6 -5
  111. package/libs/PipelinePlugin/Controller.js +3 -2
  112. package/libs/PipelinePlugin/index.js +4 -3
  113. package/libs/PipelinePlugin/utils/Objects/FlowPipe.js +3 -2
  114. package/libs/PipelinePlugin/utils/Objects/HighlightPipe.js +3 -2
  115. package/libs/PipelinePlugin/utils/Objects/Pipe.js +1 -0
  116. package/libs/Sculpt/Meshes/Line.d.ts +4 -0
  117. package/libs/Sculpt/Meshes/Line.js +85 -76
  118. package/libs/Sculpt/Meshes/Point.js +28 -28
  119. package/libs/Sculpt/Meshes/Polygon.js +43 -43
  120. package/libs/Sculpt/Objects/Base/Editor.d.ts +9 -2
  121. package/libs/Sculpt/Objects/Base/Editor.js +72 -63
  122. package/libs/Sculpt/index.js +1 -1
  123. package/libs/Sculpt/utils/Modules/Cursor.js +7 -7
  124. package/libs/base/BasePlugin.js +5 -5
  125. package/libs/floorplan/FloorplanGuidePlugin/Controller.js +3 -2
  126. package/libs/floorplan/FloorplanGuidePlugin/index.js +4 -3
  127. package/libs/floorplan/MapviewFloorplanPlugin/Controller.js +3 -2
  128. package/libs/floorplan/MapviewFloorplanPlugin/index.js +4 -3
  129. package/libs/floorplan/ModelFloorplanPlugin/Controller.js +3 -2
  130. package/libs/floorplan/ModelFloorplanPlugin/index.js +4 -3
  131. package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +3 -2
  132. package/libs/floorplan/PanoFloorplanRadarPlugin/index.js +4 -3
  133. package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +3 -2
  134. package/libs/floorplan/TopviewFloorplanPlugin/index.js +4 -3
  135. package/libs/index.d.ts +1 -0
  136. package/libs/index.js +162 -150
  137. package/libs/shared-utils/five/getFiveFromParentChain.d.ts +8 -0
  138. package/libs/shared-utils/five/getFiveFromParentChain.js +20 -0
  139. package/libs/shared-utils/logger.js +1 -1
  140. package/libs/shared-utils/three/PointSelector/utils/PointHelper2.js +1 -0
  141. package/libs/shared-utils/url/replace-static-prefix.js +12 -7
  142. package/package.json +3 -3
  143. package/libs/PanoTagPlugin/controller/Tag/MaskTag1.d.ts +0 -202
  144. package/libs/PanoTagPlugin/controller/Tag/MaskTag1.js +0 -617
@@ -1,617 +0,0 @@
1
- var U = Object.defineProperty;
2
- var E = Object.getOwnPropertySymbols;
3
- var I = Object.prototype.hasOwnProperty, P = Object.prototype.propertyIsEnumerable;
4
- var w = (n, r, e) => r in n ? U(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e, M = (n, r) => {
5
- for (var e in r || (r = {}))
6
- I.call(r, e) && w(n, e, r[e]);
7
- if (E)
8
- for (var e of E(r))
9
- P.call(r, e) && w(n, e, r[e]);
10
- return n;
11
- };
12
- var c = (n, r, e) => (w(n, typeof r != "symbol" ? r + "" : r, e), e);
13
- var v = (n, r, e) => new Promise((t, s) => {
14
- var a = (l) => {
15
- try {
16
- i(e.next(l));
17
- } catch (u) {
18
- s(u);
19
- }
20
- }, o = (l) => {
21
- try {
22
- i(e.throw(l));
23
- } catch (u) {
24
- s(u);
25
- }
26
- }, i = (l) => l.done ? t(l.value) : Promise.resolve(l.value).then(a, o);
27
- i((e = e.apply(n, r)).next());
28
- });
29
- import { BaseTag as F } from "./BaseTag.js";
30
- import * as m from "three";
31
- import { maskVertexShader as V, maskFragmentShader as R } from "./MaskTag.shaders.js";
32
- import { transformPosition as $ } from "../../../shared-utils/five/transformPosition.js";
33
- import "../../../shared-utils/Subscribe.js";
34
- import "../../utils/tag/calculateTagConfig.js";
35
- import "../../../vendor/object-assign-deep/objectAssignDeep.js";
36
- import "../../../shared-utils/typescript/entries.js";
37
- import "../../utils/tag/adaptConfig.js";
38
- import "../../typings/tag/TagConfig.js";
39
- import "@realsee/five";
40
- import "../../../shared-utils/tag.js";
41
- import "../../../shared-utils/positionToVector3.js";
42
- import "../../../shared-utils/five/vector3ToScreen.js";
43
- import "../../../shared-utils/five/getFiveModel.js";
44
- import "../../../shared-utils/Utils/FiveUtil.js";
45
- import "../../../shared-utils/Utils/BaseUtil.js";
46
- import "../../../shared-utils/Utils/WorkUtil.js";
47
- import "../../../shared-utils/three/temp.js";
48
- import "../../../shared-utils/three/core/Raycaster.js";
49
- import "../../../shared-utils/dom/resizeObserver.js";
50
- import "../../../shared-utils/five/fiveEveryReadyListener.js";
51
- import "../../../shared-utils/throttle.js";
52
- import "../../../vendor/hammerjs/hammer.js";
53
- import "../../../shared-utils/three/PointSelector/index.js";
54
- import "../../../shared-utils/three/PointSelector/utils/PointSelectorHelper.js";
55
- import "../../../shared-utils/three/Magnifier.js";
56
- import "../../../shared-utils/three/PointSelector/utils/PointHelper.js";
57
- import "../../../shared-utils/three/Assets/index.js";
58
- import "../../../CSS3DRenderPlugin/utils/three/CSS3DObject.js";
59
- import "../../../shared-utils/even.js";
60
- import "../../../shared-utils/CSS3DRender/OpacityMesh.js";
61
- import "../../../shared-utils/three/centerPoint.js";
62
- import "../../../shared-utils/three/getObjectVisible.js";
63
- import "../../../shared-utils/three/CSS3DRenderer/index.js";
64
- import "../../../CSS3DRenderPlugin/utils/generateBehindFiveElement.js";
65
- import "@realsee/five/line";
66
- import "../../../shared-utils/isNil.js";
67
- import "../../../shared-utils/three/core/Five_LineMaterial2.js";
68
- import "../../../shared-utils/three/core/Sphere.js";
69
- import "../../../shared-utils/three/blink.js";
70
- import "../../../vendor/animejs/lib/anime.es.js";
71
- import "../../../shared-utils/util.js";
72
- import "../../../vendor/@tweenjs/tween/dist/tween.esm.js.js";
73
- import "../../../CSS3DRenderPlugin/utils/three/CSS3DRender.js";
74
- import "../../../shared-utils/CSS3DRender/CSS3DRenderer.js";
75
- import "../../../shared-utils/createResizeObserver.js";
76
- import "../../../CSS3DRenderPlugin/utils/three/CSS3DScene.js";
77
- import "../../../CSS3DRenderPlugin/utils/getAllCSS3DObject.js";
78
- import "../../../CSS3DRenderPlugin/utils/three/CSS3DGroup.js";
79
- import "../../../shared-utils/three/PointSelector/utils/html.js";
80
- import "../../../shared-utils/CSS3DRender/index.js";
81
- import "../../../shared-utils/five/fiveModelLoad.js";
82
- import "../../../shared-utils/three/PointSelector/utils/PointHelper2.js";
83
- import "../../../Sculpt/Meshes/Line.js";
84
- import "../../../Sculpt/typings/style.js";
85
- import "../../../shared-utils/three/IObject3D.js";
86
- import "../../../Sculpt/utils/Meshes/getLengthHTML.js";
87
- import "../../../shared-utils/three/applyObjectMatrixWorld.js";
88
- import "../../../shared-utils/three/core/LineGeometry.js";
89
- import "../../../shared-utils/three/core/LineMaterial.js";
90
- import "../../../shared-utils/three/core/Line2.js";
91
- import "../../../shared-utils/three/core/LineMaterial2.js";
92
- import "../../../Sculpt/utils/unit.js";
93
- import "../../../Sculpt/utils/renderDom.js";
94
- import "../../../vendor/earcut/src/earcut.js";
95
- import "../../../shared-utils/five/FivePuppet.js";
96
- import "../../../CSS3DRenderPlugin/utils/three/CSS3DSprite.js";
97
- import "../../../shared-utils/isTouchDevice.js";
98
- import "../../../shared-utils/five/getPosition.js";
99
- import "../../../shared-utils/five/getRaycasterByNdcPosition.js";
100
- import "../../../shared-utils/three/PointSelector/utils/contents.js";
101
- import "../../../Sculpt/utils/three/rayOnLine.js";
102
- import "../../../shared-utils/five/mode.js";
103
- import "../../utils/tag/format.js";
104
- import "../../../shared-utils/url/defaultUrls.js";
105
- import "../../../shared-utils/vectorToCoordinate.js";
106
- import "../../../shared-utils/formatRad.js";
107
- import "../../../shared-utils/five/lookPoint.js";
108
- import "../../../shared-utils/uuid.js";
109
- import "../../utils/tagPosition.js";
110
- import "../../utils/tag/tagCheck.js";
111
- import "../../utils/checkRange.js";
112
- import "../../../shared-utils/url/getUrl.js";
113
- import "../../../shared-utils/five/getFloorIndex.js";
114
- import "../../../shared-utils/safeObj.js";
115
- import "../../utils/Cache.js";
116
- import "../../../shared-utils/promise/withResolvers.js";
117
- function C(n) {
118
- if (Array.isArray(n))
119
- return n;
120
- if (typeof n == "number")
121
- return [n >> 16 & 255, n >> 8 & 255, n & 255];
122
- if (typeof n == "string") {
123
- let r = n.trim().replace(/^#/, "");
124
- if (r.length === 3 && (r = r[0] + r[0] + r[1] + r[1] + r[2] + r[2]), r.length === 6) {
125
- const e = parseInt(r.substring(0, 2), 16), t = parseInt(r.substring(2, 4), 16), s = parseInt(r.substring(4, 6), 16);
126
- if (!isNaN(e) && !isNaN(t) && !isNaN(s))
127
- return [e, t, s];
128
- }
129
- console.warn("[MaskTag] Invalid hex color string:", n);
130
- }
131
- return [0, 0, 0];
132
- }
133
- const h = class extends F {
134
- constructor(e, t) {
135
- super(e, t);
136
- /**
137
- * mask 图片 URL 或 Canvas 元素(2:1 全景图格式)
138
- */
139
- c(this, "maskUrl");
140
- /**
141
- * 目标颜色(RGB 格式)
142
- */
143
- c(this, "targetColor");
144
- /**
145
- * mask 渲染的 mesh 对象(使用 Sphere)
146
- */
147
- c(this, "maskMesh");
148
- /**
149
- * mask 纹理对象
150
- */
151
- c(this, "maskTexture");
152
- /**
153
- * 是否正在加载 mask
154
- */
155
- c(this, "loadingMask", !1);
156
- /**
157
- * 资源是否已释放
158
- */
159
- c(this, "_disposed", !1);
160
- /**
161
- * 标签样式配置
162
- */
163
- c(this, "tagStyle");
164
- /**
165
- * 点击事件清理函数
166
- */
167
- c(this, "clickEventDispose");
168
- const s = t.maskUrl;
169
- s instanceof HTMLCanvasElement ? this.maskUrl = s : typeof s == "string" && s ? this.maskUrl = s : this.maskUrl = "";
170
- const a = t.color;
171
- this.targetColor = C(a), a || console.warn(`[MaskTag] No color provided for tag ${t.id}, using default [0, 0, 0]`), this.tagStyle = t.style, this.updateVisible(), this.currentVisible ? this.initializeMaskMesh() : console.log(`[MaskTag] Tag ${t.id} is not visible initially`);
172
- }
173
- /**
174
- * 计算法向量
175
- * Mask 标签返回向上的法向量(因为是贴在 cube 面上)
176
- */
177
- computeNormal() {
178
- return new m.Vector3(0, 1, 0);
179
- }
180
- /**
181
- * 获取额外的闪烁目标
182
- * 返回 maskMesh 用于 blink 动画
183
- */
184
- getAdditionalBlinkTargets() {
185
- return this.maskMesh || null;
186
- }
187
- /**
188
- * 更新标签数据
189
- */
190
- set(e, t = !0) {
191
- var a, o;
192
- super.set(e, t), e.style && (this.tagStyle = M(M({}, this.tagStyle), e.style), (a = e.style) != null && a.mask && this.updateMaskStyle());
193
- const s = (o = e.mask) != null ? o : e.maskUrl;
194
- if (s) {
195
- const i = this.maskUrl;
196
- this.maskUrl = s, this.reloadMask(i);
197
- }
198
- e.color !== void 0 && (this.targetColor = C(e.color), this.updateMaskStyle());
199
- }
200
- /**
201
- * 重写 getVisible 方法
202
- * Mask 标签仅在当前点位可见
203
- */
204
- getVisible(e) {
205
- var t;
206
- try {
207
- if (!this.enabled || !this.plugin.state.enabled || !this.fiveUtil.model || !this.maskUrl)
208
- return !1;
209
- const s = M(M({}, this.five.getCurrentState()), e), { panoIndex: a } = s;
210
- return a !== ((t = this.fiveState) == null ? void 0 : t.panoIndex) ? !1 : super.getVisible(s);
211
- } catch (s) {
212
- return !1;
213
- }
214
- }
215
- /**
216
- * 重写 computeVisible 方法
217
- * 增加 Mask 特有的可见性检查逻辑,用于 whyHide 功能
218
- */
219
- computeVisible(e) {
220
- var a, o, i;
221
- const t = M(M({}, this.five.getCurrentState()), e), { panoIndex: s } = t;
222
- return this.maskUrl ? s !== ((a = this.fiveState) == null ? void 0 : a.panoIndex) ? {
223
- value: !1,
224
- reason: {
225
- type: "panoIndex mismatch",
226
- detail: `Mask 标签仅在当前点位可见。当前点位: ${s}, 标签点位: ${(o = this.fiveState) == null ? void 0 : o.panoIndex}`,
227
- currentPanoIndex: s,
228
- tagPanoIndex: (i = this.fiveState) == null ? void 0 : i.panoIndex
229
- }
230
- } : super.computeVisible(e) : {
231
- value: !1,
232
- reason: {
233
- type: "maskUrl invalid",
234
- detail: `Mask 标签 ${this.id} 的 maskUrl 无效`,
235
- maskUrl: this.maskUrl
236
- }
237
- };
238
- }
239
- /**
240
- * 点击事件处理
241
- */
242
- onClick(e) {
243
- e.target === "TagMaskModel" && this.unfoldAndFoldOthers();
244
- }
245
- /**
246
- * 展开自己,收起其他标签
247
- */
248
- unfoldAndFoldOthers() {
249
- if (this.isPopoverConfigEnabled())
250
- return;
251
- const e = this.can("fold"), t = this.can("unfold");
252
- e && t && (this.state.unfolded = !this.state.unfolded, this.manuallyOperated = !0, this.plugin.addRenderQueue({ type: "TagContainerSvelte", keys: ["tags"] }), this.state.unfolded && this.plugin.tags.forEach((s) => {
253
- s.id !== this.id && s.fold();
254
- }));
255
- }
256
- /**
257
- * 展开标签详情
258
- */
259
- unfold() {
260
- this.isPopoverConfigEnabled() || this.setUnfold(!0);
261
- }
262
- /**
263
- * 折叠标签详情
264
- */
265
- fold() {
266
- this.isPopoverConfigEnabled() || this.setUnfold(!1);
267
- }
268
- /**
269
- * 设置展开/折叠状态
270
- */
271
- setUnfold(e) {
272
- if (this.isPopoverConfigEnabled())
273
- return;
274
- const t = this.can("fold"), s = this.can("unfold");
275
- t && s && (this.state.unfolded = e, this.hooks.emit(e ? "unfolded" : "folded"), this.plugin.addRenderQueue({ type: "TagContainerSvelte", keys: ["tags"] }));
276
- }
277
- /**
278
- * 更新屏幕位置
279
- */
280
- updateScreenPosition() {
281
- if (!this.currentVisible || !this.position || !Array.isArray(this.position)) {
282
- this.screenPosition = null, this.plugin.addRenderQueue({ type: "TagContainerSvelte", keys: ["tags"] });
283
- return;
284
- }
285
- const t = new m.Vector3(...this.position).clone().project(this.five.camera);
286
- if (this.five.renderer) {
287
- const s = this.five.renderer.getSize(new m.Vector2());
288
- this.screenPosition = {
289
- leftPx: (t.x + 1) / 2 * s.x,
290
- topPx: (-t.y + 1) / 2 * s.y,
291
- scale: 1
292
- };
293
- }
294
- this.plugin.addRenderQueue({ type: "TagContainerSvelte", keys: ["tags"] });
295
- }
296
- /**
297
- * 应用可见性变化
298
- */
299
- applyVisible() {
300
- try {
301
- if (!this.maskUrl) {
302
- console.warn(`[MaskTag] ${this.id} cannot apply visible: maskUrl is invalid`);
303
- return;
304
- }
305
- this.visible && !this.maskMesh && !this.loadingMask && this.initializeMaskMesh(), this.maskMesh && (this.maskMesh.visible = this.visible, this.updateMeshTransform()), this.updateScreenPosition();
306
- } catch (e) {
307
- console.error(`[MaskTag] Error in applyVisible for tag ${this.id}:`, e);
308
- }
309
- }
310
- /**
311
- * 更新 mesh 的位置和旋转(跟随观察者)
312
- * 参考 itemMask 实现
313
- */
314
- updateMeshTransform() {
315
- var s;
316
- if (!this.maskMesh)
317
- return;
318
- const e = (s = this.fiveState) == null ? void 0 : s.panoIndex;
319
- if (e === void 0)
320
- return;
321
- const t = this.workUtil.getObserver(e);
322
- t && (this.maskMesh.position.copy($(t.position, this.workUtil.transform)), this.maskMesh.quaternion.copy(t.quaternion), this.five.needsRender = !0);
323
- }
324
- /**
325
- * 初始化 Mask Mesh(使用 Sphere)
326
- */
327
- initializeMaskMesh() {
328
- return v(this, null, function* () {
329
- if (this.maskMesh || this.loadingMask || !this.maskUrl)
330
- return;
331
- this.loadingMask = !0;
332
- const e = performance.now();
333
- try {
334
- this.maskTexture = yield h.loadMaskTexture(this.maskUrl), this.maskMesh = this.createSphereMesh(this.maskTexture), this.plugin.imagePlaneGroup.add(this.maskMesh), this.applyVisible(), this.five.needsRender = !0, this.setupClickEvents(), this.updateScreenPosition();
335
- const t = performance.now() - e;
336
- console.log(`[MaskTag Performance] Mesh initialized in ${t.toFixed(2)}ms for tag ${this.id}`);
337
- } catch (t) {
338
- console.error("[MaskTag] Failed to initialize mask mesh:", t);
339
- } finally {
340
- this.loadingMask = !1;
341
- }
342
- });
343
- }
344
- /**
345
- * 创建 Sphere mesh(参考 itemMask 实现)
346
- */
347
- createSphereMesh(e) {
348
- const t = this.getMaskStyle(), s = new m.Vector4(this.targetColor[0] / 255, this.targetColor[1] / 255, this.targetColor[2] / 255, 1), a = new m.ShaderMaterial({
349
- vertexShader: V,
350
- fragmentShader: R,
351
- uniforms: {
352
- map: { value: e },
353
- color: { value: s },
354
- tolerance: { value: t.tolerance / 255 },
355
- // 归一化容差
356
- highlightColor: {
357
- value: new m.Vector3(t.highlightColor[0] / 255, t.highlightColor[1] / 255, t.highlightColor[2] / 255)
358
- },
359
- opacity: { value: t.opacity }
360
- },
361
- depthWrite: !1,
362
- depthTest: !1,
363
- transparent: !0
364
- }), o = new m.SphereGeometry(1, 60, 40);
365
- o.rotateY(-Math.PI / 2), o.scale(-1, 1, 1);
366
- const i = new m.Mesh(o, a);
367
- i.renderOrder = -1e3;
368
- let l = null;
369
- const u = () => {
370
- if (l)
371
- return l;
372
- if (!e.image)
373
- return null;
374
- try {
375
- const f = document.createElement("canvas"), d = f.getContext("2d");
376
- if (!d)
377
- return null;
378
- const p = e.image;
379
- return f.width = p.width, f.height = p.height, d.drawImage(p, 0, 0), l = d.getImageData(0, 0, p.width, p.height), l;
380
- } catch (f) {
381
- return console.error("[MaskTag] Failed to get image data:", f), null;
382
- }
383
- }, g = i.raycast.bind(i);
384
- return i.raycast = (f, d) => {
385
- const p = [];
386
- if (g(f, p), p.length > 0) {
387
- const y = p[0];
388
- if (y.uv && e.image) {
389
- const k = u();
390
- if (k) {
391
- const S = Math.floor(y.uv.x * k.width), T = (Math.floor((1 - y.uv.y) * k.height) * k.width + S) * 4, b = [k.data[T], k.data[T + 1], k.data[T + 2]];
392
- Math.abs(b[0] / 255 - this.targetColor[0] / 255) + Math.abs(b[1] / 255 - this.targetColor[1] / 255) + Math.abs(b[2] / 255 - this.targetColor[2] / 255) < t.tolerance && d.push(y);
393
- }
394
- }
395
- }
396
- }, i.__maskTag = this.id, i.__maskMesh = !0, i;
397
- }
398
- /**
399
- * 获取 Mask 样式配置(合并用户配置和默认值)
400
- */
401
- getMaskStyle() {
402
- var s, a, o;
403
- const e = ((s = this.tagStyle) == null ? void 0 : s.mask) || {};
404
- let t = [255, 255, 255];
405
- return e.color !== void 0 ? t = C(e.color) : e.highlightColor !== void 0 && (t = C(e.highlightColor)), {
406
- tolerance: (a = e.tolerance) != null ? a : 1e-3,
407
- // 参考 itemMask 默认 0.001(归一化后的值)
408
- highlightColor: t,
409
- opacity: (o = e.opacity) != null ? o : 0.6
410
- // 默认 0.6(用于填充区域)
411
- };
412
- }
413
- /**
414
- * 设置点击事件
415
- */
416
- setupClickEvents() {
417
- if (!this.maskMesh || this.config.clickable === !1)
418
- return;
419
- this.cleanupClickEvents();
420
- const e = (t) => {
421
- this.plugin.hooks.emit("click", { event: t, target: "TagMaskModel", tag: this });
422
- };
423
- requestAnimationFrame(() => {
424
- !this.maskMesh || !this.plugin.domEvents || (this.clickEventDispose = this.addObjectClickHandler(this, this.maskMesh, e));
425
- });
426
- }
427
- /**
428
- * 清理点击事件
429
- */
430
- cleanupClickEvents() {
431
- this.clickEventDispose && (this.clickEventDispose(), this.clickEventDispose = void 0);
432
- }
433
- /**
434
- * 重新加载 mask 图
435
- * @param oldMaskUrl 旧的 mask 源,用于正确释放纹理缓存(调用 set 时已更新 this.maskUrl,需传入旧值)
436
- */
437
- reloadMask(e) {
438
- return v(this, null, function* () {
439
- this.maskMesh && (this.maskMesh.parent && this.maskMesh.parent.remove(this.maskMesh), this.maskMesh.geometry.dispose(), this.maskMesh.material && (Array.isArray(this.maskMesh.material) ? this.maskMesh.material.forEach((s) => s.dispose()) : this.maskMesh.material.dispose()), this.maskMesh = void 0);
440
- const t = e != null ? e : this.maskUrl;
441
- this.maskTexture && t && (h.releaseMaskTexture(t), this.maskTexture = void 0), yield this.initializeMaskMesh();
442
- });
443
- }
444
- /**
445
- * 更新 mask 样式
446
- */
447
- updateMaskStyle() {
448
- if (!this.maskMesh)
449
- return;
450
- const e = this.getMaskStyle(), t = this.maskMesh.material;
451
- t.uniforms && (t.uniforms.color.value.set(this.targetColor[0] / 255, this.targetColor[1] / 255, this.targetColor[2] / 255, 1), t.uniforms.tolerance.value = e.tolerance / 255, t.uniforms.highlightColor.value.set(
452
- e.highlightColor[0] / 255,
453
- e.highlightColor[1] / 255,
454
- e.highlightColor[2] / 255
455
- ), t.uniforms.opacity.value = e.opacity), this.five.needsRender = !0;
456
- }
457
- /**
458
- * 更新 Canvas 纹理(仅当 maskUrl 为 Canvas 时有效)
459
- * 当 canvas 内容发生变化时,调用此方法更新渲染
460
- */
461
- updateCanvasTexture() {
462
- if (!this.maskTexture || typeof this.maskUrl == "string") {
463
- console.warn("[MaskTag] updateCanvasTexture only works for Canvas-based masks");
464
- return;
465
- }
466
- this.maskTexture instanceof m.CanvasTexture && (this.maskTexture.needsUpdate = !0, this.five.needsRender = !0, console.log("[MaskTag] Canvas texture updated"));
467
- }
468
- /**
469
- * 清理 MaskTag 特有的资源(内部方法,避免重复调用)
470
- */
471
- disposeMaskResources() {
472
- this._disposed || (this._disposed = !0, this.cleanupClickEvents(), this.maskMesh && (this.maskMesh.parent && this.maskMesh.parent.remove(this.maskMesh), this.maskMesh.geometry.dispose(), this.maskMesh.material && (Array.isArray(this.maskMesh.material) ? this.maskMesh.material.forEach((e) => e.dispose()) : this.maskMesh.material.dispose()), this.maskMesh = void 0), this.maskTexture && this.maskUrl && (h.releaseMaskTexture(this.maskUrl), this.maskTexture = void 0));
473
- }
474
- /**
475
- * 清理 MaskTag 特有的资源(公开方法)
476
- */
477
- dispose() {
478
- this.disposeMaskResources();
479
- }
480
- /**
481
- * 禁用标签(重写父类方法)
482
- */
483
- disable() {
484
- this.maskMesh && (this.maskMesh.visible = !1), super.disable();
485
- }
486
- /**
487
- * 销毁标签(重写父类方法)
488
- */
489
- destroy() {
490
- this.disposeMaskResources(), super.destroy();
491
- }
492
- /**
493
- * 获取 mask 的缓存 key
494
- * @param maskSource mask URL 或 Canvas
495
- * @returns 缓存 key
496
- */
497
- static getMaskCacheKey(e) {
498
- if (typeof e == "string")
499
- return e;
500
- {
501
- let t = h.canvasSymbolMap.get(e);
502
- return t || (t = Symbol("canvas-mask"), h.canvasSymbolMap.set(e, t)), t;
503
- }
504
- }
505
- /**
506
- * 加载 Mask 纹理(静态方法,支持缓存和引用计数)
507
- * @param maskSource mask 图片 URL 或 Canvas 元素
508
- * @returns Promise<THREE.Texture>
509
- */
510
- static loadMaskTexture(e) {
511
- return v(this, null, function* () {
512
- const t = h.getMaskCacheKey(e), s = h.maskTextureCache.get(t);
513
- if (s)
514
- return s.refCount++, s.texture;
515
- const a = performance.now(), o = new AbortController();
516
- try {
517
- let i;
518
- if (typeof e == "string") {
519
- const g = new m.TextureLoader();
520
- i = yield new Promise((f, d) => {
521
- if (o.signal.aborted) {
522
- d(new Error("Load aborted"));
523
- return;
524
- }
525
- g.load(
526
- e,
527
- (p) => {
528
- o.signal.aborted ? (p.dispose(), d(new Error("Load aborted"))) : f(p);
529
- },
530
- void 0,
531
- (p) => {
532
- d(p);
533
- }
534
- ), o.signal.addEventListener("abort", () => {
535
- d(new Error("Load aborted"));
536
- });
537
- });
538
- } else
539
- i = new m.CanvasTexture(e), i.needsUpdate = !0, console.log("[MaskTag] Created texture from canvas, size:", e.width, "x", e.height);
540
- i.wrapS = m.ClampToEdgeWrapping, i.wrapT = m.ClampToEdgeWrapping, i.minFilter = m.LinearFilter, i.magFilter = m.LinearFilter, i.anisotropy = 4, i instanceof m.CanvasTexture && (i.needsUpdate = !0), h.maskTextureCache.set(t, {
541
- texture: i,
542
- refCount: 1,
543
- abortController: o
544
- });
545
- const l = performance.now() - a, u = typeof e == "string" ? e.substring(0, 50) : "Canvas";
546
- if (console.log(`[MaskTag Performance] Texture loaded in ${l.toFixed(2)}ms, source: ${u}`), i.image) {
547
- const g = (i.image.width * i.image.height * 4 / 1048576).toFixed(2);
548
- console.log(`[MaskTag Memory] Texture size: ${i.image.width}x${i.image.height}, estimated memory: ${g}MB`);
549
- }
550
- return i;
551
- } catch (i) {
552
- throw console.error("[MaskTag] Failed to load mask texture:", typeof e == "string" ? e : "Canvas", i), i;
553
- }
554
- });
555
- }
556
- /**
557
- * 释放 Mask 纹理(静态方法)
558
- * @param maskSource mask 图片 URL 或 Canvas 元素
559
- */
560
- static releaseMaskTexture(e) {
561
- var a;
562
- const t = h.getMaskCacheKey(e), s = h.maskTextureCache.get(t);
563
- if (s && (s.refCount--, s.refCount <= 0)) {
564
- const o = typeof e == "string" ? e.substring(0, 50) : "Canvas";
565
- console.log(`[MaskTag Memory] Releasing texture (refCount=0): ${o}`), (a = s.abortController) == null || a.abort(), s.texture.dispose(), h.maskTextureCache.delete(t);
566
- }
567
- }
568
- /**
569
- * 获取当前缓存的纹理统计信息(用于性能监控和调试)
570
- * @returns 缓存统计信息
571
- */
572
- static getCacheStats() {
573
- let e = 0, t = 0;
574
- const s = [];
575
- return h.maskTextureCache.forEach((a, o) => {
576
- e += a.refCount;
577
- let i = 0;
578
- if (a.texture.image) {
579
- const u = a.texture.image.width || 0, g = a.texture.image.height || 0;
580
- i = u * g * 4 / (1024 * 1024), t += i;
581
- }
582
- const l = typeof o == "string" ? o.substring(0, 80) : "[Canvas]";
583
- s.push({
584
- source: l,
585
- refCount: a.refCount,
586
- sizeMB: parseFloat(i.toFixed(2))
587
- });
588
- }), {
589
- totalCached: h.maskTextureCache.size,
590
- totalRefCount: e,
591
- estimatedMemoryMB: parseFloat(t.toFixed(2)),
592
- cacheEntries: s
593
- };
594
- }
595
- /**
596
- * 强制清理所有缓存的纹理(用于内存管理,谨慎使用)
597
- * 注意:这会释放所有纹理,即使它们仍在使用中
598
- */
599
- static clearAllCache() {
600
- console.warn("[MaskTag] Clearing all texture cache"), h.maskTextureCache.forEach((e) => {
601
- var t;
602
- (t = e.abortController) == null || t.abort(), e.texture.dispose();
603
- }), h.maskTextureCache.clear();
604
- }
605
- };
606
- let x = h;
607
- /**
608
- * Mask 纹理缓存(静态,所有 MaskTag 实例共享)
609
- * key: mask URL 或 canvas 的 symbol, value: { texture: THREE.Texture, refCount: number, abortController?: AbortController }
610
- */
611
- c(x, "maskTextureCache", /* @__PURE__ */ new Map()), /**
612
- * Canvas 到 Symbol 的映射(用于缓存 canvas 纹理)
613
- */
614
- c(x, "canvasSymbolMap", /* @__PURE__ */ new WeakMap());
615
- export {
616
- x as MaskTag
617
- };