@realsee/dnalogel 3.77.5 → 3.77.7

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 (145) hide show
  1. package/CHANGELOG.md +17 -11
  2. package/dist/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
  3. package/dist/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
  4. package/dist/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
  5. package/dist/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
  6. package/dist/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
  7. package/dist/PanoTagPlugin/controller/TagRender.d.ts +1 -1
  8. package/dist/PanoTagPlugin/controller/index.d.ts +55 -2
  9. package/dist/PanoTagPlugin/typings/controller.d.ts +10 -0
  10. package/dist/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
  11. package/dist/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
  12. package/dist/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
  13. package/dist/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
  14. package/dist/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
  15. package/dist/Sculpt/Meshes/Line.d.ts +4 -0
  16. package/dist/index.cjs.js +178 -95
  17. package/dist/index.js +11378 -9801
  18. package/dist/index.umd.js +173 -90
  19. package/dist/shared-utils/five/getFiveFromParentChain.d.ts +7 -0
  20. package/libs/AreaMakerPlugin/Controller.js +3 -2
  21. package/libs/AreaMakerPlugin/index.js +3 -2
  22. package/libs/AreaMakerPlugin/utils/Item.js +3 -2
  23. package/libs/CSS3DRenderPlugin/Controller.js +3 -2
  24. package/libs/CSS3DRenderPlugin/index.js +6 -5
  25. package/libs/CSS3DRenderPlugin/utils/three/CSS3DObject.js +39 -38
  26. package/libs/CSS3DRenderPlugin/utils/three/CSS3DRender.js +10 -9
  27. package/libs/CruisePlugin/BaseController.js +5 -4
  28. package/libs/CruisePlugin/Move.js +8 -2
  29. package/libs/CruisePlugin/Work.js +8 -2
  30. package/libs/CruisePlugin/index.js +12 -6
  31. package/libs/CurrentPanoImagePlugin/Controller.js +15 -14
  32. package/libs/CurrentPanoImagePlugin/index.js +4 -3
  33. package/libs/GuideLinePlugin/Controller.js +10 -4
  34. package/libs/GuideLinePlugin/GuideLineItem.js +8 -2
  35. package/libs/GuideLinePlugin/GuideLineModeItem.js +8 -2
  36. package/libs/GuideLinePlugin/index.js +12 -6
  37. package/libs/MeasurePlugin/Controller.js +11 -10
  38. package/libs/MeasurePlugin/index.js +5 -4
  39. package/libs/MeasurePlugin/utils/MeasureMesh.js +3 -2
  40. package/libs/ModelChassisCompassPlugin/Plugin.js +4 -3
  41. package/libs/ModelChassisCompassPlugin/index.js +1 -0
  42. package/libs/ModelEntryDoorGuidePlugin/Plugin.js +6 -5
  43. package/libs/ModelEntryDoorGuidePlugin/index.js +1 -0
  44. package/libs/ModelMakerPlugin/Controller.js +3 -2
  45. package/libs/ModelMakerPlugin/index.js +3 -2
  46. package/libs/ModelMakerPlugin/item/baseItem.js +3 -2
  47. package/libs/ModelMakerPlugin/item/boxItem.js +3 -2
  48. package/libs/ModelMakerPlugin/item/polygonItem.js +3 -2
  49. package/libs/ModelMakerPlugin/item/prismItem.js +3 -2
  50. package/libs/ModelTVVideoPlugin/Plugin.js +4 -3
  51. package/libs/ModelTVVideoPlugin/index.js +3 -2
  52. package/libs/ModelViewPlugin/Plugin.js +20 -19
  53. package/libs/ModelViewPlugin/index.js +1 -0
  54. package/libs/Object3DHelperPlugin/Controller.js +3 -2
  55. package/libs/Object3DHelperPlugin/index.js +6 -5
  56. package/libs/PanoCompassPlugin/Controller.js +3 -2
  57. package/libs/PanoCompassPlugin/index.js +4 -3
  58. package/libs/PanoDoorLabelPlugin/Controller.js +24 -23
  59. package/libs/PanoDoorLabelPlugin/index.js +4 -3
  60. package/libs/PanoMeasurePlugin/Components/Controller0.js +3 -2
  61. package/libs/PanoMeasurePlugin/Components/Controller1.js +3 -2
  62. package/libs/PanoMeasurePlugin/Controller/EditController.js +3 -2
  63. package/libs/PanoMeasurePlugin/Controller/WatchController.js +3 -2
  64. package/libs/PanoMeasurePlugin/Controller/index.js +3 -2
  65. package/libs/PanoMeasurePlugin/Model/area.js +3 -2
  66. package/libs/PanoMeasurePlugin/Modules/Magnifier.js +1 -0
  67. package/libs/PanoMeasurePlugin/Modules/UIController/index.js +16 -15
  68. package/libs/PanoMeasurePlugin/index.js +14 -13
  69. package/libs/PanoMeasurePlugin/utils/dom/areaDom.js +3 -2
  70. package/libs/PanoRulerProPlugin/Controller.js +3 -2
  71. package/libs/PanoRulerProPlugin/RulerItems.js +42 -41
  72. package/libs/PanoRulerProPlugin/index.js +4 -3
  73. package/libs/PanoSpatialTagPlugin/Plugin.js +34 -33
  74. package/libs/PanoSpatialTagPlugin/index.js +1 -0
  75. package/libs/PanoTagPlugin/Components/Common/TagPoint.js +3 -2
  76. package/libs/PanoTagPlugin/Components/Common/TagPopover/PopoverContent.js +3 -2
  77. package/libs/PanoTagPlugin/Components/Common/TagPopover/TagPopoverToolBar.js +3 -2
  78. package/libs/PanoTagPlugin/Components/Common/TagPopover/index.js +3 -2
  79. package/libs/PanoTagPlugin/Components/Tag/MarketingTag.js +3 -2
  80. package/libs/PanoTagPlugin/Components/Tag/index.js +3 -2
  81. package/libs/PanoTagPlugin/Components/TagContainer.js +3 -2
  82. package/libs/PanoTagPlugin/Components/TagItem.js +125 -124
  83. package/libs/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
  84. package/libs/PanoTagPlugin/controller/Tag/BaseTag.js +321 -289
  85. package/libs/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
  86. package/libs/PanoTagPlugin/controller/Tag/BoxTag.js +516 -0
  87. package/libs/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
  88. package/libs/PanoTagPlugin/controller/Tag/MaskTag.js +816 -0
  89. package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
  90. package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.js +94 -0
  91. package/libs/PanoTagPlugin/controller/Tag/ModelTag.js +3 -2
  92. package/libs/PanoTagPlugin/controller/Tag/PlaneTag.js +3 -2
  93. package/libs/PanoTagPlugin/controller/Tag/PointTag.js +3 -2
  94. package/libs/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
  95. package/libs/PanoTagPlugin/controller/Tag/PolygonTag.js +479 -0
  96. package/libs/PanoTagPlugin/controller/TagRender.d.ts +1 -1
  97. package/libs/PanoTagPlugin/controller/TagRender.js +3 -2
  98. package/libs/PanoTagPlugin/controller/TagUtil.js +22 -19
  99. package/libs/PanoTagPlugin/controller/index.d.ts +55 -2
  100. package/libs/PanoTagPlugin/controller/index.js +243 -129
  101. package/libs/PanoTagPlugin/index.js +17 -11
  102. package/libs/PanoTagPlugin/typings/controller.d.ts +10 -0
  103. package/libs/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
  104. package/libs/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
  105. package/libs/PanoTagPlugin/utils/addDebugPoints.js +27 -13
  106. package/libs/PanoTagPlugin/utils/index.js +29 -26
  107. package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
  108. package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.js +18 -0
  109. package/libs/PanoTagPlugin/utils/tag/calculateTagConfig.js +3 -2
  110. package/libs/PanoTagPlugin/utils/tag/format.js +3 -2
  111. package/libs/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
  112. package/libs/PanoTagPlugin/utils/tag/tagCheck.js +26 -14
  113. package/libs/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
  114. package/libs/PanoTagPlugin/utils/tagPosition.js +49 -16
  115. package/libs/PanoVideoPlugin/Controller.js +9 -8
  116. package/libs/PanoVideoPlugin/VideoMeshController.js +3 -2
  117. package/libs/PanoVideoPlugin/index.js +6 -5
  118. package/libs/PipelinePlugin/Controller.js +3 -2
  119. package/libs/PipelinePlugin/index.js +4 -3
  120. package/libs/PipelinePlugin/utils/Objects/FlowPipe.js +3 -2
  121. package/libs/PipelinePlugin/utils/Objects/HighlightPipe.js +3 -2
  122. package/libs/PipelinePlugin/utils/Objects/Pipe.js +1 -0
  123. package/libs/Sculpt/Meshes/Line.d.ts +4 -0
  124. package/libs/Sculpt/Meshes/Line.js +85 -76
  125. package/libs/Sculpt/Meshes/Point.js +28 -28
  126. package/libs/Sculpt/Meshes/Polygon.js +43 -43
  127. package/libs/Sculpt/index.js +1 -1
  128. package/libs/Sculpt/utils/Modules/Cursor.js +7 -7
  129. package/libs/base/BasePlugin.js +1 -1
  130. package/libs/floorplan/FloorplanGuidePlugin/Controller.js +3 -2
  131. package/libs/floorplan/FloorplanGuidePlugin/index.js +4 -3
  132. package/libs/floorplan/MapviewFloorplanPlugin/Controller.js +3 -2
  133. package/libs/floorplan/MapviewFloorplanPlugin/index.js +4 -3
  134. package/libs/floorplan/ModelFloorplanPlugin/Controller.js +3 -2
  135. package/libs/floorplan/ModelFloorplanPlugin/index.js +4 -3
  136. package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +3 -2
  137. package/libs/floorplan/PanoFloorplanRadarPlugin/index.js +4 -3
  138. package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +3 -2
  139. package/libs/floorplan/TopviewFloorplanPlugin/index.js +4 -3
  140. package/libs/index.js +164 -158
  141. package/libs/shared-utils/five/getFiveFromParentChain.d.ts +7 -0
  142. package/libs/shared-utils/five/getFiveFromParentChain.js +15 -0
  143. package/libs/shared-utils/logger.js +1 -1
  144. package/libs/shared-utils/three/PointSelector/utils/PointHelper2.js +1 -0
  145. package/package.json +1 -1
@@ -0,0 +1,816 @@
1
+ var F = Object.defineProperty;
2
+ var R = Object.getOwnPropertySymbols;
3
+ var B = Object.prototype.hasOwnProperty, A = Object.prototype.propertyIsEnumerable;
4
+ var E = (m, c, e) => c in m ? F(m, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[c] = e, v = (m, c) => {
5
+ for (var e in c || (c = {}))
6
+ B.call(c, e) && E(m, e, c[e]);
7
+ if (R)
8
+ for (var e of R(c))
9
+ A.call(c, e) && E(m, e, c[e]);
10
+ return m;
11
+ };
12
+ var x = (m, c, e) => (E(m, typeof c != "symbol" ? c + "" : c, e), e);
13
+ var S = (m, c, e) => new Promise((s, t) => {
14
+ var o = (l) => {
15
+ try {
16
+ r(e.next(l));
17
+ } catch (n) {
18
+ t(n);
19
+ }
20
+ }, i = (l) => {
21
+ try {
22
+ r(e.throw(l));
23
+ } catch (n) {
24
+ t(n);
25
+ }
26
+ }, r = (l) => l.done ? s(l.value) : Promise.resolve(l.value).then(o, i);
27
+ r((e = e.apply(m, c)).next());
28
+ });
29
+ import { BaseTag as D } from "./BaseTag.js";
30
+ import * as g from "three";
31
+ import { anime as $ } from "../../../vendor/animejs/lib/anime.es.js";
32
+ import { maskVertexShader as z, maskFragmentShaderMulti as G } from "./MaskTag.shaders.js";
33
+ import { transformPosition as L } from "../../../shared-utils/five/transformPosition.js";
34
+ import "../../../shared-utils/Subscribe.js";
35
+ import "../../utils/tag/calculateTagConfig.js";
36
+ import "../../../vendor/object-assign-deep/objectAssignDeep.js";
37
+ import "../../../shared-utils/typescript/entries.js";
38
+ import "../../utils/tag/adaptConfig.js";
39
+ import "../../typings/tag/TagConfig.js";
40
+ import "@realsee/five";
41
+ import "../../../shared-utils/tag.js";
42
+ import "../../../shared-utils/positionToVector3.js";
43
+ import "../../../shared-utils/five/vector3ToScreen.js";
44
+ import "../../../shared-utils/five/getFiveModel.js";
45
+ import "../../../shared-utils/Utils/FiveUtil.js";
46
+ import "../../../shared-utils/Utils/BaseUtil.js";
47
+ import "../../../shared-utils/Utils/WorkUtil.js";
48
+ import "../../../shared-utils/three/temp.js";
49
+ import "../../../shared-utils/three/core/Raycaster.js";
50
+ import "../../../shared-utils/dom/resizeObserver.js";
51
+ import "../../../shared-utils/five/fiveEveryReadyListener.js";
52
+ import "../../../shared-utils/throttle.js";
53
+ import "../../../vendor/hammerjs/hammer.js";
54
+ import "../../../shared-utils/three/PointSelector/index.js";
55
+ import "../../../shared-utils/three/PointSelector/utils/PointSelectorHelper.js";
56
+ import "../../../shared-utils/three/Magnifier.js";
57
+ import "../../../shared-utils/three/PointSelector/utils/PointHelper.js";
58
+ import "../../../shared-utils/three/Assets/index.js";
59
+ import "../../../CSS3DRenderPlugin/utils/three/CSS3DObject.js";
60
+ import "../../../shared-utils/even.js";
61
+ import "../../../shared-utils/CSS3DRender/OpacityMesh.js";
62
+ import "../../../shared-utils/three/centerPoint.js";
63
+ import "../../../shared-utils/three/getObjectVisible.js";
64
+ import "../../../shared-utils/three/CSS3DRenderer/index.js";
65
+ import "../../../CSS3DRenderPlugin/utils/generateBehindFiveElement.js";
66
+ import "@realsee/five/line";
67
+ import "../../../shared-utils/isNil.js";
68
+ import "../../../shared-utils/three/core/Five_LineMaterial2.js";
69
+ import "../../../shared-utils/three/core/Sphere.js";
70
+ import "../../../shared-utils/three/blink.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/five/getFiveFromParentChain.js";
89
+ import "../../../shared-utils/three/core/LineGeometry.js";
90
+ import "../../../shared-utils/three/core/LineMaterial.js";
91
+ import "../../../shared-utils/three/core/Line2.js";
92
+ import "../../../shared-utils/three/core/LineMaterial2.js";
93
+ import "../../../Sculpt/utils/unit.js";
94
+ import "../../../Sculpt/utils/renderDom.js";
95
+ import "../../../vendor/earcut/src/earcut.js";
96
+ import "../../../shared-utils/five/FivePuppet.js";
97
+ import "../../../CSS3DRenderPlugin/utils/three/CSS3DSprite.js";
98
+ import "../../../shared-utils/isTouchDevice.js";
99
+ import "../../../shared-utils/five/getPosition.js";
100
+ import "../../../shared-utils/five/getRaycasterByNdcPosition.js";
101
+ import "../../../shared-utils/three/PointSelector/utils/contents.js";
102
+ import "../../../Sculpt/utils/three/rayOnLine.js";
103
+ import "../../../shared-utils/five/mode.js";
104
+ import "../../utils/tag/format.js";
105
+ import "../../../shared-utils/url/defaultUrls.js";
106
+ import "../../../shared-utils/vectorToCoordinate.js";
107
+ import "../../../shared-utils/formatRad.js";
108
+ import "../../../shared-utils/five/lookPoint.js";
109
+ import "../../../shared-utils/uuid.js";
110
+ import "../../utils/tagPosition.js";
111
+ import "../../utils/tag/tagCheck.js";
112
+ import "../../utils/checkRange.js";
113
+ import "../../../shared-utils/url/getUrl.js";
114
+ import "../../../shared-utils/five/getFloorIndex.js";
115
+ import "../../../shared-utils/safeObj.js";
116
+ import "../../utils/Cache.js";
117
+ import "../../../shared-utils/promise/withResolvers.js";
118
+ function w(m) {
119
+ if (Array.isArray(m))
120
+ return m;
121
+ if (typeof m == "number")
122
+ return [m >> 16 & 255, m >> 8 & 255, m & 255];
123
+ if (typeof m == "string") {
124
+ let c = m.trim().replace(/^#/, "");
125
+ if (c.length === 3 && (c = c[0] + c[0] + c[1] + c[1] + c[2] + c[2]), c.length === 6) {
126
+ const e = parseInt(c.substring(0, 2), 16), s = parseInt(c.substring(2, 4), 16), t = parseInt(c.substring(4, 6), 16);
127
+ if (!isNaN(e) && !isNaN(s) && !isNaN(t))
128
+ return [e, s, t];
129
+ }
130
+ console.warn("[MaskTag] Invalid hex color string:", m);
131
+ }
132
+ return [0, 0, 0];
133
+ }
134
+ const h = class extends D {
135
+ constructor(e, s) {
136
+ var i;
137
+ super(e, s);
138
+ /**
139
+ * mask 图片 URL 或 Canvas 元素(2:1 全景图格式)
140
+ */
141
+ x(this, "maskUrl");
142
+ /**
143
+ * 目标颜色(RGB 格式)
144
+ */
145
+ x(this, "targetColor");
146
+ /**
147
+ * mask 渲染的 mesh 对象(使用 Sphere)
148
+ */
149
+ x(this, "maskMesh");
150
+ /**
151
+ * mask 纹理对象
152
+ */
153
+ x(this, "maskTexture");
154
+ /**
155
+ * 是否正在加载 mask
156
+ */
157
+ x(this, "loadingMask", !1);
158
+ /**
159
+ * 资源是否已释放
160
+ */
161
+ x(this, "_disposed", !1);
162
+ /**
163
+ * 标签样式配置
164
+ */
165
+ x(this, "tagStyle");
166
+ /**
167
+ * 点击事件清理函数
168
+ */
169
+ x(this, "clickEventDispose");
170
+ /** 当前 tag 在共享 style 纹理中的下标(color 即 id) */
171
+ x(this, "sharedStyleIndex", -1);
172
+ /** 共享 mesh 的 registry key,用于 updateMaskStyle / dispose 查找 entry */
173
+ x(this, "_sharedMeshKey", null);
174
+ const t = (i = s.mask) != null ? i : s.maskUrl;
175
+ this.maskUrl = t instanceof HTMLCanvasElement || typeof t == "string" && t ? t : "";
176
+ const o = s.color;
177
+ this.targetColor = w(o), o || console.warn(`[MaskTag] No color provided for tag ${s.id}, using default [0, 0, 0]`), this.tagStyle = s.style, this.updateVisible(), this.currentVisible && this.initializeMaskMesh();
178
+ }
179
+ getColorKey() {
180
+ return `${this.targetColor[0]},${this.targetColor[1]},${this.targetColor[2]}`;
181
+ }
182
+ /** 同点位共用一个 mesh,key 仅用 panoIndex(string/canvas 切换时不会因 key 不同而重复创建) */
183
+ static getMeshKey(e) {
184
+ return String(e);
185
+ }
186
+ /**
187
+ * 初始化/挂载到同点位共享 mesh,用 appendStyleToMaterial 注册本 tag 的 style(color 即 id)
188
+ */
189
+ initializeMaskMesh() {
190
+ return S(this, null, function* () {
191
+ var s;
192
+ if (this._disposed || !this.maskUrl)
193
+ return;
194
+ const e = (s = this.fiveState) == null ? void 0 : s.panoIndex;
195
+ if (typeof e == "number") {
196
+ this.loadingMask = !0;
197
+ try {
198
+ const t = yield h.loadMaskTexture(this.maskUrl);
199
+ this.maskTexture = t;
200
+ const o = h.getMeshKey(e);
201
+ this._sharedMeshKey = o;
202
+ let i = h.sharedMeshRegistry.get(o);
203
+ const r = this.getColorKey(), l = this.buildStyleForMaterial();
204
+ i ? i.maskSource !== this.maskUrl && (h.releaseMaskTexture(i.maskSource), i.maskTexture = t, i.maskSource = this.maskUrl, i.material.uniforms.map.value = t) : (i = h.createSharedMesh(t, this.maskUrl, this.plugin), h.sharedMeshRegistry.set(o, i), this.plugin.imagePlaneGroup.add(i.mesh));
205
+ const n = i.styleIndexByColorKey.get(r);
206
+ n !== void 0 ? (this.sharedStyleIndex = n, this.maskMesh = i.mesh, this.updateStyleSlotInMaterial(i.material, n, l)) : (i.tagsByColorKey.set(r, this), this.appendStyleToMaterial(i.material, l), this.sharedStyleIndex = i.tagsByColorKey.size - 1, i.styleIndexByColorKey.set(r, this.sharedStyleIndex), this.maskMesh = i.mesh), this.setupSharedMeshRaycast(i), this.updateMeshTransform(), this.setupClickEvents(), this.updateScreenPosition(), i.mesh.visible = !0;
207
+ } finally {
208
+ this.loadingMask = !1;
209
+ }
210
+ }
211
+ });
212
+ }
213
+ /** 构建用于 mergedTexture 的 style 对象(color 作 id),tolerance 0–255 */
214
+ buildStyleForMaterial() {
215
+ const e = this.getMaskStyle(), s = e.tolerance, t = s <= 1 ? s * 255 : s;
216
+ return {
217
+ color: [this.targetColor[0], this.targetColor[1], this.targetColor[2], 1],
218
+ tolerance: t,
219
+ highlightColor: e.highlightColor,
220
+ opacity: this.enabled && this.visible ? e.opacity : 0
221
+ };
222
+ }
223
+ static createSharedMesh(e, s, t) {
224
+ const r = Math.max(1, Math.ceil(Math.sqrt(0))), l = 1, n = new Float32Array(r * l * 4), a = new g.DataTexture(n, r, l, g.RGBAFormat, g.FloatType);
225
+ a.needsUpdate = !0;
226
+ const d = new g.ShaderMaterial({
227
+ vertexShader: z,
228
+ fragmentShader: G,
229
+ uniforms: {
230
+ map: { value: e },
231
+ mergedTexture: { value: a },
232
+ groupCount: { value: 0 },
233
+ textureWidth: { value: r },
234
+ pixelsPerGroup: { value: 3 }
235
+ },
236
+ depthWrite: !1,
237
+ depthTest: !1,
238
+ transparent: !0
239
+ }), u = new g.SphereGeometry(1, 60, 40);
240
+ u.rotateY(-Math.PI / 2), u.scale(-1, 1, 1);
241
+ const p = new g.Mesh(u, d);
242
+ return p.renderOrder = -1e3, p.__maskMesh = !0, {
243
+ mesh: p,
244
+ material: d,
245
+ maskTexture: e,
246
+ maskSource: s,
247
+ tagsByColorKey: /* @__PURE__ */ new Map(),
248
+ styleIndexByColorKey: /* @__PURE__ */ new Map()
249
+ };
250
+ }
251
+ /** 仅更新材质中某一 slot 的 style(用于 enable/disable/updateMaskStyle) */
252
+ updateStyleSlotInMaterial(e, s, t) {
253
+ const i = e.uniforms.mergedTexture.value, r = i.image.data, n = s * 3, a = n * 4;
254
+ r[a] = t.color[0] / 255, r[a + 1] = t.color[1] / 255, r[a + 2] = t.color[2] / 255, r[a + 3] = t.color[3];
255
+ const d = (n + 1) * 4;
256
+ r[d] = t.tolerance / 255, r[d + 1] = t.highlightColor[0] / 255, r[d + 2] = t.highlightColor[1] / 255, r[d + 3] = t.highlightColor[2] / 255;
257
+ const u = (n + 2) * 4;
258
+ r[u] = t.opacity, i.needsUpdate = !0, this.five.needsRender = !0;
259
+ }
260
+ setupSharedMeshRaycast(e) {
261
+ const s = e.mesh;
262
+ if (s.__maskRaycastSet)
263
+ return;
264
+ s.__maskRaycastSet = !0;
265
+ let t = null, o = null;
266
+ const i = () => {
267
+ const l = e.maskTexture;
268
+ if (!(l != null && l.image))
269
+ return null;
270
+ if (o === l && t)
271
+ return t;
272
+ o = l;
273
+ try {
274
+ const n = document.createElement("canvas"), a = n.getContext("2d");
275
+ if (!a)
276
+ return null;
277
+ const d = l.image;
278
+ return n.width = d.width, n.height = d.height, a.drawImage(d, 0, 0), t = a.getImageData(0, 0, d.width, d.height), t;
279
+ } catch (n) {
280
+ return null;
281
+ }
282
+ }, r = s.raycast.bind(s);
283
+ s.raycast = (l, n) => {
284
+ var k, I;
285
+ const a = [];
286
+ if (r(l, a), a.length === 0)
287
+ return;
288
+ const d = a[0];
289
+ if (!d.uv || !((k = e.maskTexture) != null && k.image))
290
+ return;
291
+ const u = i();
292
+ if (!u)
293
+ return;
294
+ const p = Math.floor(d.uv.x * u.width), y = (Math.floor((1 - d.uv.y) * u.height) * u.width + p) * 4, f = [u.data[y], u.data[y + 1], u.data[y + 2]], M = 0.5 / 255;
295
+ for (const [, T] of e.tagsByColorKey) {
296
+ if (!T.enabled || ((I = T.config) == null ? void 0 : I.clickable) === !1)
297
+ continue;
298
+ const [K, P, U] = T.targetColor;
299
+ if (Math.abs(f[0] / 255 - K / 255) + Math.abs(f[1] / 255 - P / 255) + Math.abs(f[2] / 255 - U / 255) <= M) {
300
+ s.userData.__lastHitTag = T, n.push(d);
301
+ return;
302
+ }
303
+ }
304
+ };
305
+ }
306
+ /**
307
+ * 计算法向量
308
+ * Mask 标签返回向上的法向量(因为是贴在 cube 面上)
309
+ */
310
+ computeNormal() {
311
+ return new g.Vector3(0, 1, 0);
312
+ }
313
+ /**
314
+ * 不把共享 mesh 作为 blink 目标,闪烁通过本 tag 的 style opacity 动画实现
315
+ */
316
+ getAdditionalBlinkTargets() {
317
+ return null;
318
+ }
319
+ /**
320
+ * 闪烁仅针对本 tag:通过改变本 tag 在 merged texture 中的 opacity 实现
321
+ */
322
+ blink(e) {
323
+ return S(this, null, function* () {
324
+ var a, d, u;
325
+ if (!this.maskMesh || this._sharedMeshKey === null || this.sharedStyleIndex < 0)
326
+ return;
327
+ const s = h.sharedMeshRegistry.get(this._sharedMeshKey);
328
+ if (!s)
329
+ return;
330
+ const i = { opacity: this.buildStyleForMaterial().opacity }, r = (a = e == null ? void 0 : e.duration) != null ? a : 300, l = (d = e == null ? void 0 : e.loop) != null ? d : 4, n = $({
331
+ targets: i,
332
+ opacity: [0, 1],
333
+ duration: r,
334
+ easing: (u = e == null ? void 0 : e.easing) != null ? u : "easeInOutQuad",
335
+ direction: "alternate",
336
+ loop: l,
337
+ update: () => {
338
+ const p = this.buildStyleForMaterial();
339
+ p.opacity = i.opacity, this.updateStyleSlotInMaterial(s.material, this.sharedStyleIndex, p);
340
+ }
341
+ });
342
+ try {
343
+ yield n.finished;
344
+ } catch (p) {
345
+ } finally {
346
+ this.updateMaskStyle();
347
+ }
348
+ });
349
+ }
350
+ /**
351
+ * 更新标签数据
352
+ */
353
+ set(e, s = !0) {
354
+ var o, i;
355
+ super.set(e, s), e.style && (this.tagStyle = v(v({}, this.tagStyle), e.style), (o = e.style) != null && o.mask && this.updateMaskStyle());
356
+ const t = (i = e.mask) != null ? i : e.maskUrl;
357
+ t && t !== this.maskUrl && (this.maskUrl = t, this.updateSharedMeshTexture()), e.color !== void 0 && (this.targetColor = w(e.color), this.updateMaskStyle()), this.maskMesh && this.updateMaskStyle();
358
+ }
359
+ /** 供 rebuildEntryMaterial 使用:返回当前 tag 的 style 对象 */
360
+ getStyleForMaterial() {
361
+ return this.buildStyleForMaterial();
362
+ }
363
+ /**
364
+ * 重写 getVisible 方法
365
+ * Mask 标签仅在当前点位可见
366
+ */
367
+ getVisible(e) {
368
+ var s;
369
+ try {
370
+ if (!this.enabled || !this.plugin.state.enabled || !this.fiveUtil.model || !this.maskUrl)
371
+ return !1;
372
+ const t = v(v({}, this.five.getCurrentState()), e), { panoIndex: o } = t;
373
+ return o !== ((s = this.fiveState) == null ? void 0 : s.panoIndex) ? !1 : super.getVisible(t);
374
+ } catch (t) {
375
+ return !1;
376
+ }
377
+ }
378
+ /**
379
+ * 重写 computeVisible 方法
380
+ * 增加 Mask 特有的可见性检查逻辑,用于 whyHide 功能
381
+ */
382
+ computeVisible(e) {
383
+ var o, i, r;
384
+ const s = v(v({}, this.five.getCurrentState()), e), { panoIndex: t } = s;
385
+ return t !== ((o = this.fiveState) == null ? void 0 : o.panoIndex) ? {
386
+ value: !1,
387
+ reason: {
388
+ type: "panoIndex mismatch",
389
+ detail: `Mask 标签仅在当前点位可见。当前点位: ${t}, 标签点位: ${(i = this.fiveState) == null ? void 0 : i.panoIndex}`,
390
+ currentPanoIndex: t,
391
+ tagPanoIndex: (r = this.fiveState) == null ? void 0 : r.panoIndex
392
+ }
393
+ } : super.computeVisible(e);
394
+ }
395
+ /**
396
+ * 点击事件处理
397
+ */
398
+ onClick(e) {
399
+ e.target === "TagMaskModel" && this.unfoldAndFoldOthers();
400
+ }
401
+ /**
402
+ * 展开自己,收起其他标签
403
+ */
404
+ unfoldAndFoldOthers() {
405
+ if (this.isPopoverConfigEnabled())
406
+ return;
407
+ const e = this.can("fold"), s = this.can("unfold");
408
+ e && s && (this.state.unfolded = !this.state.unfolded, this.manuallyOperated = !0, this.plugin.addRenderQueue({ type: "TagContainerSvelte", keys: ["tags"] }), this.state.unfolded && this.plugin.tags.forEach((t) => {
409
+ t.id !== this.id && t.fold();
410
+ }));
411
+ }
412
+ /**
413
+ * 展开标签详情
414
+ */
415
+ unfold() {
416
+ this.isPopoverConfigEnabled() || this.setUnfold(!0);
417
+ }
418
+ /**
419
+ * 折叠标签详情
420
+ */
421
+ fold() {
422
+ this.isPopoverConfigEnabled() || this.setUnfold(!1);
423
+ }
424
+ /**
425
+ * 设置展开/折叠状态
426
+ */
427
+ setUnfold(e) {
428
+ if (this.isPopoverConfigEnabled())
429
+ return;
430
+ const s = this.can("fold"), t = this.can("unfold");
431
+ s && t && (this.state.unfolded = e, this.hooks.emit(e ? "unfolded" : "folded"), this.plugin.addRenderQueue({ type: "TagContainerSvelte", keys: ["tags"] }));
432
+ }
433
+ /**
434
+ * 更新屏幕位置
435
+ */
436
+ updateScreenPosition() {
437
+ if (!this.currentVisible || !this.position || !Array.isArray(this.position)) {
438
+ this.screenPosition = null, this.plugin.addRenderQueue({ type: "TagContainerSvelte", keys: ["tags"] });
439
+ return;
440
+ }
441
+ const s = new g.Vector3(...this.position).clone().project(this.five.camera);
442
+ if (this.five.renderer) {
443
+ const t = this.five.renderer.getSize(new g.Vector2());
444
+ this.screenPosition = {
445
+ leftPx: (s.x + 1) / 2 * t.x,
446
+ topPx: (-s.y + 1) / 2 * t.y,
447
+ scale: 1
448
+ };
449
+ }
450
+ this.plugin.addRenderQueue({ type: "TagContainerSvelte", keys: ["tags"] });
451
+ }
452
+ /**
453
+ * 应用可见性变化(通过 style opacity 控制展示,共享 mesh 保持 visible)
454
+ */
455
+ applyVisible() {
456
+ try {
457
+ if (!this.maskUrl)
458
+ return;
459
+ this.visible && !this.loadingMask && this.initializeMaskMesh(), this.maskMesh && (this.updateMaskStyle(), this.updateMeshTransform()), this.updateScreenPosition();
460
+ } catch (e) {
461
+ console.error(`[MaskTag] Error in applyVisible for tag ${this.id}:`, e);
462
+ }
463
+ }
464
+ /**
465
+ * 更新 mesh 的位置和旋转(跟随观察者)
466
+ * 参考 itemMask 实现
467
+ */
468
+ updateMeshTransform() {
469
+ var r;
470
+ if (!this.maskMesh)
471
+ return;
472
+ const e = (r = this.fiveState) == null ? void 0 : r.panoIndex;
473
+ if (e === void 0)
474
+ return;
475
+ const s = this.workUtil.getObserver(e);
476
+ if (!s)
477
+ return;
478
+ this.maskMesh.position.copy(L(s.position, this.workUtil.transform)), this.maskMesh.quaternion.copy(s.quaternion);
479
+ const t = new g.Vector3(), o = new g.Quaternion(), i = new g.Vector3();
480
+ this.workUtil.transform.decompose(t, o, i), this.maskMesh.quaternion.multiply(o), this.five.needsRender = !0;
481
+ }
482
+ /**
483
+ * 步骤1:从材质中解析出 styleList
484
+ * @param {THREE.ShaderMaterial} material - 目标材质
485
+ * @returns {Array} 解析后的 styleList
486
+ */
487
+ parseStyleListFromMaterial(e) {
488
+ const s = e.uniforms, t = s.groupCount.value, o = s.pixelsPerGroup.value, r = s.mergedTexture.value.image.data, l = [];
489
+ for (let n = 0; n < t; n++) {
490
+ const a = n * o, d = a * 4, u = r[d] * 255, p = r[d + 1] * 255, C = r[d + 2] * 255, y = r[d + 3], f = (a + 1) * 4, M = r[f] * 255, k = r[f + 1] * 255, I = r[f + 2] * 255, T = r[f + 3] * 255, K = (a + 2) * 4, P = r[K];
491
+ l.push({
492
+ color: [Math.round(u), Math.round(p), Math.round(C), y],
493
+ tolerance: Math.round(M),
494
+ highlightColor: [Math.round(k), Math.round(I), Math.round(T)],
495
+ opacity: P
496
+ });
497
+ }
498
+ return l;
499
+ }
500
+ /**
501
+ * 步骤2:更新材质的样式纹理(追加新元素后)
502
+ * @param {THREE.ShaderMaterial} material - 目标材质
503
+ * @param {Array} newStyle - 要追加的新样式对象
504
+ */
505
+ appendStyleToMaterial(e, s) {
506
+ const t = this.parseStyleListFromMaterial(e);
507
+ Array.isArray(s) ? t.push(...s) : t.push(s);
508
+ const o = t.length, i = 3, l = o * i, n = 1, a = new Float32Array(l * n * 4);
509
+ t.forEach((p, C) => {
510
+ const y = C * i, f = y * 4;
511
+ a[f] = p.color[0] / 255, a[f + 1] = p.color[1] / 255, a[f + 2] = p.color[2] / 255, a[f + 3] = p.color[3];
512
+ const M = (y + 1) * 4;
513
+ a[M] = p.tolerance / 255, a[M + 1] = p.highlightColor[0] / 255, a[M + 2] = p.highlightColor[1] / 255, a[M + 3] = p.highlightColor[2] / 255;
514
+ const k = (y + 2) * 4;
515
+ a[k] = p.opacity, a[k + 1] = 0, a[k + 2] = 0, a[k + 3] = 0;
516
+ });
517
+ const d = e.uniforms.mergedTexture.value, u = d.image;
518
+ u.data = a, u.width = l, u.height = n, d.needsUpdate = !0, e.uniforms.groupCount.value = o, e.uniforms.textureWidth.value = l, console.log(`成功追加样式,当前总组数:${o}`);
519
+ }
520
+ /**
521
+ * 获取 Mask 样式配置(合并用户配置和默认值)
522
+ */
523
+ getMaskStyle() {
524
+ var t, o, i;
525
+ const e = ((t = this.tagStyle) == null ? void 0 : t.mask) || {};
526
+ let s = [255, 255, 255];
527
+ return e.color !== void 0 ? s = w(e.color) : e.highlightColor !== void 0 && (s = w(e.highlightColor)), {
528
+ tolerance: (o = e.tolerance) != null ? o : 1e-3,
529
+ // 参考 itemMask 默认 0.001(归一化后的值)
530
+ highlightColor: s,
531
+ opacity: (i = e.opacity) != null ? i : 0.6
532
+ // 默认 0.6(用于填充区域)
533
+ };
534
+ }
535
+ /**
536
+ * 设置点击事件(仅当 raycast 命中本 tag 的 color 时触发)
537
+ */
538
+ setupClickEvents() {
539
+ var s;
540
+ if (!this.maskMesh || ((s = this.config) == null ? void 0 : s.clickable) === !1)
541
+ return;
542
+ this.cleanupClickEvents();
543
+ const e = (t) => {
544
+ var i, r;
545
+ ((r = (i = this.maskMesh) == null ? void 0 : i.userData) == null ? void 0 : r.__lastHitTag) === this && this.plugin.hooks.emit("click", { event: t, target: "TagMaskModel", tag: this });
546
+ };
547
+ requestAnimationFrame(() => {
548
+ !this.maskMesh || !this.plugin.domEvents || (this.clickEventDispose = this.addObjectClickHandler(this, this.maskMesh, e));
549
+ });
550
+ }
551
+ /**
552
+ * 清理点击事件
553
+ */
554
+ cleanupClickEvents() {
555
+ this.clickEventDispose && (this.clickEventDispose(), this.clickEventDispose = void 0);
556
+ }
557
+ /**
558
+ * 重新加载 mask 图:从旧点位 mesh 注销,再按新 maskUrl 初始化
559
+ */
560
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- 保留参数与 set() 调用一致
561
+ reloadMask(e) {
562
+ var i;
563
+ const s = (i = this.fiveState) == null ? void 0 : i.panoIndex, t = this.getColorKey(), o = typeof s == "number" ? h.getMeshKey(s) : this._sharedMeshKey;
564
+ if (o) {
565
+ const r = h.sharedMeshRegistry.get(o);
566
+ r && (r.tagsByColorKey.delete(t), r.styleIndexByColorKey.delete(t), r.tagsByColorKey.size === 0 && (r.mesh.parent && r.mesh.parent.remove(r.mesh), r.mesh.geometry.dispose(), r.mesh.material.dispose(), r.material.uniforms.mergedTexture.value.dispose(), h.releaseMaskTexture(r.maskSource), h.sharedMeshRegistry.delete(o)));
567
+ }
568
+ this.maskMesh = void 0, this._sharedMeshKey = null, this.sharedStyleIndex = -1, this.maskTexture = void 0, this.visible && !this.loadingMask && this.initializeMaskMesh();
569
+ }
570
+ /**
571
+ * changeTagById 改 mask 时:只更新共享 mesh 的 texture,不 unregister
572
+ * 有 entry 则换图;无 entry 则走完整初始化
573
+ */
574
+ updateSharedMeshTexture() {
575
+ return S(this, null, function* () {
576
+ var i;
577
+ if (this._disposed || !this.maskUrl)
578
+ return;
579
+ const e = (i = this.fiveState) == null ? void 0 : i.panoIndex;
580
+ if (typeof e != "number")
581
+ return;
582
+ const s = h.getMeshKey(e), t = h.sharedMeshRegistry.get(s);
583
+ if (!t) {
584
+ yield this.initializeMaskMesh();
585
+ return;
586
+ }
587
+ if (t.maskSource === this.maskUrl)
588
+ return;
589
+ const o = yield h.loadMaskTexture(this.maskUrl);
590
+ this.maskTexture = o, h.releaseMaskTexture(t.maskSource), t.maskTexture = o, t.maskSource = this.maskUrl, t.material.uniforms.map.value = o, this.five.needsRender = !0;
591
+ });
592
+ }
593
+ /**
594
+ * 更新当前 tag 在共享材质中的 style slot(color/style 控制展示)
595
+ */
596
+ updateMaskStyle() {
597
+ if (!this.maskMesh || this._sharedMeshKey === null || this.sharedStyleIndex < 0)
598
+ return;
599
+ const e = h.sharedMeshRegistry.get(this._sharedMeshKey);
600
+ e && this.updateStyleSlotInMaterial(e.material, this.sharedStyleIndex, this.buildStyleForMaterial());
601
+ }
602
+ /**
603
+ * 更新 Canvas 纹理(仅当 maskUrl 为 Canvas 时有效)
604
+ * 当 canvas 内容发生变化时,调用此方法更新渲染
605
+ */
606
+ updateCanvasTexture() {
607
+ if (!this.maskTexture || typeof this.maskUrl == "string") {
608
+ console.warn("[MaskTag] updateCanvasTexture only works for Canvas-based masks");
609
+ return;
610
+ }
611
+ this.maskTexture instanceof g.CanvasTexture && (this.maskTexture.needsUpdate = !0, this.five.needsRender = !0, console.log("[MaskTag] Canvas texture updated"));
612
+ }
613
+ /**
614
+ * 清理当前标签:从共享材质中删除本 tag 的样式槽,并更新材质;
615
+ * 若该点位已无其他 tag 则销毁 mesh 并释放纹理。
616
+ */
617
+ disposeMaskResources() {
618
+ if (this._disposed)
619
+ return;
620
+ this._disposed = !0, this.cleanupClickEvents();
621
+ const e = this._sharedMeshKey, s = this.getColorKey();
622
+ if (e) {
623
+ const t = h.sharedMeshRegistry.get(e);
624
+ t && (t.tagsByColorKey.delete(s), t.styleIndexByColorKey.delete(s), t.tagsByColorKey.size === 0 ? (t.mesh.parent && t.mesh.parent.remove(t.mesh), t.mesh.geometry.dispose(), t.mesh.material.dispose(), t.material.uniforms.mergedTexture.value.dispose(), h.releaseMaskTexture(t.maskSource), h.sharedMeshRegistry.delete(e)) : h.rebuildEntryMaterial(t));
625
+ }
626
+ this.maskMesh = void 0, this._sharedMeshKey = null, this.sharedStyleIndex = -1, this.maskTexture = void 0;
627
+ }
628
+ /**
629
+ * 清理 MaskTag 特有的资源(公开方法)
630
+ */
631
+ dispose() {
632
+ this.disposeMaskResources();
633
+ }
634
+ /**
635
+ * 禁用标签(通过 style opacity=0 隐藏,不拆 mesh)
636
+ */
637
+ disable() {
638
+ super.disable(), this.updateMaskStyle();
639
+ }
640
+ /**
641
+ * 启用标签(恢复 style 展示)
642
+ */
643
+ enable() {
644
+ super.enable(), this.updateMaskStyle();
645
+ }
646
+ /**
647
+ * 销毁标签(重写父类方法)
648
+ */
649
+ destroy() {
650
+ this.disposeMaskResources(), super.destroy();
651
+ }
652
+ /**
653
+ * 清除所有点位共享 mesh(重新 load 数据前调用)
654
+ */
655
+ static clearSharedMeshRegistry() {
656
+ h.sharedMeshRegistry.forEach((e) => {
657
+ e.tagsByColorKey.forEach((s) => {
658
+ s.maskMesh = void 0, s._sharedMeshKey = null, s.sharedStyleIndex = -1;
659
+ }), e.mesh.parent && e.mesh.parent.remove(e.mesh), e.mesh.geometry.dispose(), e.mesh.material.dispose(), e.material.uniforms.mergedTexture.value.dispose(), h.releaseMaskTexture(e.maskSource);
660
+ }), h.sharedMeshRegistry.clear();
661
+ }
662
+ /**
663
+ * 将 style 列表写入材质(用于重建材质)
664
+ */
665
+ static writeStyleListToMaterial(e, s) {
666
+ const t = s.length, o = 3, r = t * o, l = 1, n = new Float32Array(r * l * 4);
667
+ s.forEach((u, p) => {
668
+ const C = p * o, y = C * 4;
669
+ n[y] = u.color[0] / 255, n[y + 1] = u.color[1] / 255, n[y + 2] = u.color[2] / 255, n[y + 3] = u.color[3];
670
+ const f = (C + 1) * 4;
671
+ n[f] = u.tolerance / 255, n[f + 1] = u.highlightColor[0] / 255, n[f + 2] = u.highlightColor[1] / 255, n[f + 3] = u.highlightColor[2] / 255;
672
+ const M = (C + 2) * 4;
673
+ n[M] = u.opacity;
674
+ });
675
+ const a = e.uniforms.mergedTexture.value, d = a.image;
676
+ d.data = n, d.width = r, d.height = l, a.needsUpdate = !0, e.uniforms.groupCount.value = t, e.uniforms.textureWidth.value = r;
677
+ }
678
+ /**
679
+ * destroy 后重建该点位材质,更新剩余 tag 的 styleIndex
680
+ */
681
+ static rebuildEntryMaterial(e) {
682
+ const s = Array.from(e.tagsByColorKey.values()).sort((o, i) => o.sharedStyleIndex - i.sharedStyleIndex);
683
+ if (s.length === 0)
684
+ return;
685
+ const t = s.map((o) => o.getStyleForMaterial());
686
+ h.writeStyleListToMaterial(e.material, t), s.forEach((o, i) => {
687
+ o.sharedStyleIndex = i, e.styleIndexByColorKey.set(`${o.targetColor[0]},${o.targetColor[1]},${o.targetColor[2]}`, i);
688
+ });
689
+ }
690
+ /**
691
+ * 获取 mask 的缓存 key
692
+ * @param maskSource mask URL 或 Canvas
693
+ * @returns 缓存 key
694
+ */
695
+ static getMaskCacheKey(e) {
696
+ if (typeof e == "string")
697
+ return e;
698
+ {
699
+ let s = h.canvasSymbolMap.get(e);
700
+ return s || (s = Symbol("canvas-mask"), h.canvasSymbolMap.set(e, s)), s;
701
+ }
702
+ }
703
+ /**
704
+ * 加载 Mask 纹理(静态方法,支持缓存和引用计数)
705
+ * @param maskSource mask 图片 URL 或 Canvas 元素
706
+ * @returns Promise<THREE.Texture>
707
+ */
708
+ static loadMaskTexture(e) {
709
+ return S(this, null, function* () {
710
+ const s = h.getMaskCacheKey(e), t = h.maskTextureCache.get(s);
711
+ if (t)
712
+ return t.refCount++, t.texture;
713
+ const o = performance.now(), i = new AbortController();
714
+ try {
715
+ let r;
716
+ if (typeof e == "string") {
717
+ const a = new g.TextureLoader();
718
+ r = yield new Promise((d, u) => {
719
+ if (i.signal.aborted) {
720
+ u(new Error("Load aborted"));
721
+ return;
722
+ }
723
+ a.load(
724
+ e,
725
+ (p) => {
726
+ i.signal.aborted ? (p.dispose(), u(new Error("Load aborted"))) : d(p);
727
+ },
728
+ void 0,
729
+ (p) => {
730
+ u(p);
731
+ }
732
+ ), i.signal.addEventListener("abort", () => {
733
+ u(new Error("Load aborted"));
734
+ });
735
+ });
736
+ } else
737
+ r = new g.CanvasTexture(e), r.needsUpdate = !0, console.log("[MaskTag] Created texture from canvas, size:", e.width, "x", e.height);
738
+ r.wrapS = g.ClampToEdgeWrapping, r.wrapT = g.ClampToEdgeWrapping, r.minFilter = g.LinearFilter, r.magFilter = g.LinearFilter, r.anisotropy = 4, r instanceof g.CanvasTexture && (r.needsUpdate = !0), h.maskTextureCache.set(s, {
739
+ texture: r,
740
+ refCount: 1,
741
+ abortController: i
742
+ });
743
+ const l = performance.now() - o, n = typeof e == "string" ? e.substring(0, 50) : "Canvas";
744
+ if (console.log(`[MaskTag Performance] Texture loaded in ${l.toFixed(2)}ms, source: ${n}`), r.image) {
745
+ const a = (r.image.width * r.image.height * 4 / 1048576).toFixed(2);
746
+ console.log(`[MaskTag Memory] Texture size: ${r.image.width}x${r.image.height}, estimated memory: ${a}MB`);
747
+ }
748
+ return r;
749
+ } catch (r) {
750
+ throw console.error("[MaskTag] Failed to load mask texture:", typeof e == "string" ? e : "Canvas", r), r;
751
+ }
752
+ });
753
+ }
754
+ /**
755
+ * 释放 Mask 纹理(静态方法)
756
+ * @param maskSource mask 图片 URL 或 Canvas 元素
757
+ */
758
+ static releaseMaskTexture(e) {
759
+ var o;
760
+ const s = h.getMaskCacheKey(e), t = h.maskTextureCache.get(s);
761
+ if (t && (t.refCount--, t.refCount <= 0)) {
762
+ const i = typeof e == "string" ? e.substring(0, 50) : "Canvas";
763
+ console.log(`[MaskTag Memory] Releasing texture (refCount=0): ${i}`), (o = t.abortController) == null || o.abort(), t.texture.dispose(), h.maskTextureCache.delete(s);
764
+ }
765
+ }
766
+ /**
767
+ * 获取当前缓存的纹理统计信息(用于性能监控和调试)
768
+ * @returns 缓存统计信息
769
+ */
770
+ static getCacheStats() {
771
+ let e = 0, s = 0;
772
+ const t = [];
773
+ return h.maskTextureCache.forEach((o, i) => {
774
+ e += o.refCount;
775
+ let r = 0;
776
+ if (o.texture.image) {
777
+ const n = o.texture.image.width || 0, a = o.texture.image.height || 0;
778
+ r = n * a * 4 / (1024 * 1024), s += r;
779
+ }
780
+ const l = typeof i == "string" ? i.substring(0, 80) : "[Canvas]";
781
+ t.push({
782
+ source: l,
783
+ refCount: o.refCount,
784
+ sizeMB: parseFloat(r.toFixed(2))
785
+ });
786
+ }), {
787
+ totalCached: h.maskTextureCache.size,
788
+ totalRefCount: e,
789
+ estimatedMemoryMB: parseFloat(s.toFixed(2)),
790
+ cacheEntries: t
791
+ };
792
+ }
793
+ /**
794
+ * 强制清理所有缓存的纹理(用于内存管理,谨慎使用)
795
+ * 注意:这会释放所有纹理,即使它们仍在使用中
796
+ */
797
+ static clearAllCache() {
798
+ console.warn("[MaskTag] Clearing all texture cache"), h.maskTextureCache.forEach((e) => {
799
+ var s;
800
+ (s = e.abortController) == null || s.abort(), e.texture.dispose();
801
+ }), h.maskTextureCache.clear();
802
+ }
803
+ };
804
+ let b = h;
805
+ /**
806
+ * Mask 纹理缓存(静态,所有 MaskTag 实例共享)
807
+ * key: mask URL 或 canvas 的 symbol, value: { texture: THREE.Texture, refCount: number, abortController?: AbortController }
808
+ */
809
+ x(b, "maskTextureCache", /* @__PURE__ */ new Map()), /**
810
+ * Canvas 到 Symbol 的映射(用于缓存 canvas 纹理)
811
+ */
812
+ x(b, "canvasSymbolMap", /* @__PURE__ */ new WeakMap()), /** 同点位共用 mesh:key = meshKey(panoIndex + maskKey), value = 共享数据 */
813
+ x(b, "sharedMeshRegistry", /* @__PURE__ */ new Map());
814
+ export {
815
+ b as MaskTag
816
+ };