@realsee/dnalogel 2.0.0-alpha.29-beta → 2.0.0-alpha.30-beta

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 (107) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/dist/ItemLabelPlugin/Plugin.d.ts +4 -0
  3. package/dist/ItemLabelPlugin/events.type.d.ts +9 -0
  4. package/dist/ItemLabelPlugin/index.d.ts +9 -0
  5. package/dist/ItemLabelPlugin/index.js +703 -0
  6. package/dist/ItemLabelPlugin/typings.d.ts +54 -0
  7. package/dist/ItemLabelPlugin/utils/parseData.d.ts +3 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.es.js +829 -177
  10. package/dist/index.js +830 -176
  11. package/dist/index.umd.js +830 -176
  12. package/docs/assets/search.js +1 -1
  13. package/docs/classes/ModelRoomLabelController.html +4 -4
  14. package/docs/classes/PanoFloorplanRadarPluginController.html +2 -2
  15. package/docs/enums/CameraMovementEffect.html +2 -2
  16. package/docs/enums/DIRECTION.html +1 -1
  17. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
  18. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  19. package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -0
  20. package/docs/enums/ModelFloorplanErrorType.html +1 -1
  21. package/docs/enums/Rotation.html +2 -2
  22. package/docs/index.html +2 -2
  23. package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
  24. package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
  25. package/docs/interfaces/FloorplanBounding.html +4 -4
  26. package/docs/interfaces/FloorplanData.html +2 -2
  27. package/docs/interfaces/FloorplanEntrance.html +7 -7
  28. package/docs/interfaces/FloorplanExtraObject.html +3 -3
  29. package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
  30. package/docs/interfaces/FloorplanFloorData.html +2 -2
  31. package/docs/interfaces/FloorplanImagePosition.html +2 -2
  32. package/docs/interfaces/FloorplanObserver.html +2 -2
  33. package/docs/interfaces/FloorplanOutlineItem.html +2 -2
  34. package/docs/interfaces/FloorplanPosition.html +2 -2
  35. package/docs/interfaces/FloorplanRoomItem.html +6 -6
  36. package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
  37. package/docs/interfaces/FloorplanServerBounding.html +4 -4
  38. package/docs/interfaces/FloorplanServerComputedData.html +1 -1
  39. package/docs/interfaces/FloorplanServerData.html +2 -2
  40. package/docs/interfaces/FloorplanServerEntrance.html +7 -7
  41. package/docs/interfaces/FloorplanServerFloorData.html +2 -2
  42. package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
  43. package/docs/interfaces/FloorplanServerObserver.html +2 -2
  44. package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
  45. package/docs/interfaces/FloorplanServerPosition.html +2 -2
  46. package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
  47. package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
  48. package/docs/interfaces/ItemLabelPluginData.html +1 -0
  49. package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -0
  50. package/docs/interfaces/ItemLabelPluginParametersType.html +1 -0
  51. package/docs/interfaces/LineJson.html +1 -1
  52. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  53. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  54. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  55. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  56. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  57. package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
  58. package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
  59. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  60. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  61. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  62. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  63. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  64. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  65. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  66. package/docs/interfaces/ModelViewPluginExportType.html +1 -1
  67. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  68. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  69. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  70. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
  71. package/docs/interfaces/PanoFloorplanRadarPluginControllerParameter.html +1 -1
  72. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  73. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  74. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  75. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
  76. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
  77. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  78. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
  79. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  80. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
  81. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  82. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
  83. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
  84. package/docs/interfaces/Point.html +1 -1
  85. package/docs/interfaces/PointJson.html +1 -1
  86. package/docs/interfaces/Room.html +1 -1
  87. package/docs/interfaces/RoomInfo.html +1 -1
  88. package/docs/interfaces/RoomLabel.html +7 -7
  89. package/docs/interfaces/RoomRules.html +1 -1
  90. package/docs/interfaces/Rooms.html +1 -1
  91. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +9 -9
  92. package/docs/modules.html +20 -20
  93. package/libs/ItemLabelPlugin/ItemLabelComponent.js +414 -0
  94. package/libs/ItemLabelPlugin/ItemLabelItem.js +173 -0
  95. package/libs/ItemLabelPlugin/Plugin.d.ts +4 -0
  96. package/libs/ItemLabelPlugin/Plugin.js +117 -0
  97. package/libs/ItemLabelPlugin/events.type.d.ts +9 -0
  98. package/libs/ItemLabelPlugin/events.type.js +1 -0
  99. package/libs/ItemLabelPlugin/index.d.ts +9 -0
  100. package/libs/ItemLabelPlugin/index.js +8 -0
  101. package/libs/ItemLabelPlugin/typings.d.ts +54 -0
  102. package/libs/ItemLabelPlugin/typings.js +7 -0
  103. package/libs/ItemLabelPlugin/utils/parseData.d.ts +3 -0
  104. package/libs/ItemLabelPlugin/utils/parseData.js +4 -0
  105. package/libs/index.d.ts +1 -0
  106. package/libs/index.js +2 -1
  107. package/package.json +2 -1
@@ -0,0 +1,703 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var five = require('@realsee/five');
6
+ var internal = require('svelte/internal');
7
+ var svelte = require('svelte');
8
+ var THREE = require('three');
9
+ var classNames = require('classnames');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n["default"] = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
32
+ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
33
+
34
+ exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE = void 0;
35
+ (function (ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE) {
36
+ ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE["SMALL"] = "small";
37
+ ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE["MIDLLE"] = "middle";
38
+ ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE["LARGE"] = "large";
39
+ ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE["EXTRA_LARGE"] = "x-large";
40
+ })(exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE || (exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE = {}));
41
+
42
+ /* src/ItemLabelPlugin/ItemLabelItem.svelte generated by Svelte v3.47.0 */
43
+
44
+ function add_css$1(target) {
45
+ internal.append_styles(target, "svelte-1s5p8g", ".item-label-item.svelte-1s5p8g{position:absolute;z-index:0;transform:none;cursor:pointer;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:0}.item-label-item.visible.svelte-1s5p8g{opacity:1;-webkit-animation:svelte-1s5p8g-fadeIn .3s ease-in;animation:svelte-1s5p8g-fadeIn .3s ease-in}.item-label-item__text-wrap.svelte-1s5p8g{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;padding:0.625rem 1.04167rem 0.625rem 0.625rem;position:absolute;width:-webkit-max-content;width:-moz-max-content;width:max-content;max-width:24.63542rem;min-height:4.79167rem;pointer-events:none;background-image:linear-gradient(269deg, rgba(0,0,0,0.50) 0%, rgba(0,0,0,0.60) 49%, rgba(31,38,46,0.70) 100%);border:1.5px solid rgba(255, 255, 255, .65);border-radius:0.15625rem;color:white;transform:translate(-50%, 0);display:flex;justify-content:flex-start;align-items:center;box-sizing:border-box;overflow:hidden}.item-label-item__text-wrap.visible.svelte-1s5p8g{pointer-events:all}.icon-wrap.svelte-1s5p8g{width:3.54167rem;height:100%;display:flex;justify-content:center;align-content:center}.icon.svelte-1s5p8g{width:3.54167rem;height:3.54167rem;background-repeat:no-repeat;background-size:contain;background-position:center}.item-label-text.svelte-1s5p8g{margin-left:0.625rem;padding-left:0.625rem;min-height:3.54167rem;height:auto;display:flex;flex-flow:column;justify-content:space-around;align-content:flex-start;border-left:solid rgba(255, 255, 255, .2) 1px;border-top:solid rgba(255, 255, 255, .2) 0;border-right:solid rgba(255, 255, 255, .2) 0;border-bottom:solid rgba(255, 255, 255, .2) 0;pointer-events:auto}.item-model.svelte-1s5p8g{white-space:nowrap;font-size:1.14583rem;font-weight:bold;line-height:1.5625rem}.item-name.svelte-1s5p8g{height:auto;word-wrap:break-word;word-break:break-all;font-size:1.04167rem;line-height:1.45833rem}.item-label-item__bar.svelte-1s5p8g{position:absolute;bottom:0;width:0.15625rem;background-image:linear-gradient(to bottom, white, rgba(255, 255, 255, 0));box-shadow:0 2px 0.41667rem 0 rgba(0,0,0,0.20);pointer-events:none}.item-label-item__bar.anchor.svelte-1s5p8g:after{content:'';position:absolute;bottom:0;width:1.25rem;height:1.25rem;background-image:url(\"//vrlab-public.ljcdn.com/common/file/web/67e7a198-28c9-47dc-879b-507bd3ae600c.png \");background-position:center;background-size:contain;transform:translate(-0.54688rem, 50%)}@-webkit-keyframes svelte-1s5p8g-fadeIn{from{opacity:0\n }to{opacity:1\n }}@keyframes svelte-1s5p8g-fadeIn{from{opacity:0\n }to{opacity:1\n }}");
46
+ }
47
+
48
+ function create_fragment$1(ctx) {
49
+ let div5;
50
+ let div3;
51
+ let div1;
52
+ let div0;
53
+ let div0_style_value;
54
+ let t0;
55
+ let div2;
56
+ let span0;
57
+ let t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "";
58
+ let t1;
59
+ let t2;
60
+ let span1;
61
+ let t3_value = /*itemLabel*/ ctx[0].name + "";
62
+ let t3;
63
+ let div3_class_value;
64
+ let t4;
65
+ let div4;
66
+ let div4_class_value;
67
+ let div5_class_value;
68
+ let mounted;
69
+ let dispose;
70
+
71
+ return {
72
+ c() {
73
+ div5 = internal.element("div");
74
+ div3 = internal.element("div");
75
+ div1 = internal.element("div");
76
+ div0 = internal.element("div");
77
+ t0 = internal.space();
78
+ div2 = internal.element("div");
79
+ span0 = internal.element("span");
80
+ t1 = internal.text(t1_value);
81
+ t2 = internal.space();
82
+ span1 = internal.element("span");
83
+ t3 = internal.text(t3_value);
84
+ t4 = internal.space();
85
+ div4 = internal.element("div");
86
+ internal.attr(div0, "class", "icon svelte-1s5p8g");
87
+ internal.attr(div0, "style", div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`);
88
+ internal.attr(div1, "class", "icon-wrap svelte-1s5p8g");
89
+ internal.attr(span0, "class", "item-model svelte-1s5p8g");
90
+ internal.attr(span1, "class", "item-name svelte-1s5p8g");
91
+ internal.attr(div2, "class", "item-label-text svelte-1s5p8g");
92
+ internal.attr(div3, "class", div3_class_value = "" + (internal.null_to_empty(classNames__default["default"]("item-label-item__text-wrap", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1s5p8g"));
93
+ internal.set_style(div3, "bottom", `${/*itemLabel*/ ctx[0].strokeLength}px`);
94
+ internal.attr(div4, "class", div4_class_value = "" + (internal.null_to_empty(classNames__default["default"]("item-label-item__bar", { anchor: /*anchorEnabled*/ ctx[1] })) + " svelte-1s5p8g"));
95
+ internal.set_style(div4, "height", `${/*itemLabel*/ ctx[0].strokeLength}px`);
96
+ internal.attr(div5, "class", div5_class_value = "" + (internal.null_to_empty(classNames__default["default"]("item-label-item", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1s5p8g"));
97
+ internal.set_style(div5, "z-index", /*itemLabel*/ ctx[0].zIndex, false);
98
+ internal.set_style(div5, "transform", /*itemLabel*/ ctx[0].transform, false);
99
+ },
100
+ m(target, anchor) {
101
+ internal.insert(target, div5, anchor);
102
+ internal.append(div5, div3);
103
+ internal.append(div3, div1);
104
+ internal.append(div1, div0);
105
+ internal.append(div3, t0);
106
+ internal.append(div3, div2);
107
+ internal.append(div2, span0);
108
+ internal.append(span0, t1);
109
+ internal.append(div2, t2);
110
+ internal.append(div2, span1);
111
+ internal.append(span1, t3);
112
+ internal.append(div5, t4);
113
+ internal.append(div5, div4);
114
+
115
+ if (!mounted) {
116
+ dispose = internal.listen(div3, "click", /*onClick*/ ctx[2]);
117
+ mounted = true;
118
+ }
119
+ },
120
+ p(ctx, [dirty]) {
121
+ if (dirty & /*itemLabel*/ 1 && div0_style_value !== (div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`)) {
122
+ internal.attr(div0, "style", div0_style_value);
123
+ }
124
+
125
+ if (dirty & /*itemLabel*/ 1 && t1_value !== (t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "")) internal.set_data(t1, t1_value);
126
+ if (dirty & /*itemLabel*/ 1 && t3_value !== (t3_value = /*itemLabel*/ ctx[0].name + "")) internal.set_data(t3, t3_value);
127
+
128
+ if (dirty & /*itemLabel*/ 1 && div3_class_value !== (div3_class_value = "" + (internal.null_to_empty(classNames__default["default"]("item-label-item__text-wrap", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1s5p8g"))) {
129
+ internal.attr(div3, "class", div3_class_value);
130
+ }
131
+
132
+ if (dirty & /*itemLabel*/ 1) {
133
+ internal.set_style(div3, "bottom", `${/*itemLabel*/ ctx[0].strokeLength}px`);
134
+ }
135
+
136
+ if (dirty & /*anchorEnabled*/ 2 && div4_class_value !== (div4_class_value = "" + (internal.null_to_empty(classNames__default["default"]("item-label-item__bar", { anchor: /*anchorEnabled*/ ctx[1] })) + " svelte-1s5p8g"))) {
137
+ internal.attr(div4, "class", div4_class_value);
138
+ }
139
+
140
+ if (dirty & /*itemLabel*/ 1) {
141
+ internal.set_style(div4, "height", `${/*itemLabel*/ ctx[0].strokeLength}px`);
142
+ }
143
+
144
+ if (dirty & /*itemLabel*/ 1 && div5_class_value !== (div5_class_value = "" + (internal.null_to_empty(classNames__default["default"]("item-label-item", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1s5p8g"))) {
145
+ internal.attr(div5, "class", div5_class_value);
146
+ }
147
+
148
+ if (dirty & /*itemLabel*/ 1) {
149
+ internal.set_style(div5, "z-index", /*itemLabel*/ ctx[0].zIndex, false);
150
+ }
151
+
152
+ if (dirty & /*itemLabel*/ 1) {
153
+ internal.set_style(div5, "transform", /*itemLabel*/ ctx[0].transform, false);
154
+ }
155
+ },
156
+ i: internal.noop,
157
+ o: internal.noop,
158
+ d(detaching) {
159
+ if (detaching) internal.detach(div5);
160
+ mounted = false;
161
+ dispose();
162
+ }
163
+ };
164
+ }
165
+
166
+ const defaultIcon = '//vrlab-public.ljcdn.com/common/file/web/c8591aaa-e62b-4e31-8fed-671483ace37f.svg\n';
167
+
168
+ function instance$1($$self, $$props, $$invalidate) {
169
+ let { itemLabel } = $$props;
170
+ let { hooks } = $$props;
171
+ let { anchorEnabled } = $$props;
172
+
173
+ function onClick() {
174
+ hooks.emit('onLabelClick', itemLabel);
175
+ }
176
+
177
+ $$self.$$set = $$props => {
178
+ if ('itemLabel' in $$props) $$invalidate(0, itemLabel = $$props.itemLabel);
179
+ if ('hooks' in $$props) $$invalidate(3, hooks = $$props.hooks);
180
+ if ('anchorEnabled' in $$props) $$invalidate(1, anchorEnabled = $$props.anchorEnabled);
181
+ };
182
+
183
+ return [itemLabel, anchorEnabled, onClick, hooks];
184
+ }
185
+
186
+ class ItemLabelItem extends internal.SvelteComponent {
187
+ constructor(options) {
188
+ super();
189
+ internal.init(this, options, instance$1, create_fragment$1, internal.safe_not_equal, { itemLabel: 0, hooks: 3, anchorEnabled: 1 }, add_css$1);
190
+ }
191
+ }
192
+
193
+ /**
194
+ * 创建一个防抖动函数,该函数会在 wait 毫秒后调用 func 方法
195
+ * @param func - 要防抖动的函数
196
+ * @param [wait=0] - 需要延迟的毫秒数
197
+ */
198
+ function debounce(func, wait = 200) {
199
+ let last;
200
+ return function (...args) {
201
+ clearTimeout(last);
202
+ last = setTimeout(() => {
203
+ func(...args);
204
+ }, wait);
205
+ };
206
+ }
207
+
208
+ /* src/ItemLabelPlugin/ItemLabelComponent.svelte generated by Svelte v3.47.0 */
209
+
210
+ function add_css(target) {
211
+ internal.append_styles(target, "svelte-gk8s47", ".item-labels-container.svelte-gk8s47{width:100%;height:100%;position:relative}");
212
+ }
213
+
214
+ function get_each_context(ctx, list, i) {
215
+ const child_ctx = ctx.slice();
216
+ child_ctx[28] = list[i];
217
+ return child_ctx;
218
+ }
219
+
220
+ // (163:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
221
+ function create_each_block(key_1, ctx) {
222
+ let first;
223
+ let itemlabelitem;
224
+ let current;
225
+
226
+ itemlabelitem = new ItemLabelItem({
227
+ props: {
228
+ itemLabel: /*itemLabelItem*/ ctx[28],
229
+ hooks: /*hooks*/ ctx[1],
230
+ anchorEnabled: /*five*/ ctx[0].currentMode === five.Five.Mode.Panorama
231
+ }
232
+ });
233
+
234
+ return {
235
+ key: key_1,
236
+ first: null,
237
+ c() {
238
+ first = internal.empty();
239
+ internal.create_component(itemlabelitem.$$.fragment);
240
+ this.first = first;
241
+ },
242
+ m(target, anchor) {
243
+ internal.insert(target, first, anchor);
244
+ internal.mount_component(itemlabelitem, target, anchor);
245
+ current = true;
246
+ },
247
+ p(new_ctx, dirty) {
248
+ ctx = new_ctx;
249
+ const itemlabelitem_changes = {};
250
+ if (dirty & /*renderItemLabels*/ 4) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[28];
251
+ if (dirty & /*hooks*/ 2) itemlabelitem_changes.hooks = /*hooks*/ ctx[1];
252
+ if (dirty & /*five*/ 1) itemlabelitem_changes.anchorEnabled = /*five*/ ctx[0].currentMode === five.Five.Mode.Panorama;
253
+ itemlabelitem.$set(itemlabelitem_changes);
254
+ },
255
+ i(local) {
256
+ if (current) return;
257
+ internal.transition_in(itemlabelitem.$$.fragment, local);
258
+ current = true;
259
+ },
260
+ o(local) {
261
+ internal.transition_out(itemlabelitem.$$.fragment, local);
262
+ current = false;
263
+ },
264
+ d(detaching) {
265
+ if (detaching) internal.detach(first);
266
+ internal.destroy_component(itemlabelitem, detaching);
267
+ }
268
+ };
269
+ }
270
+
271
+ function create_fragment(ctx) {
272
+ let div;
273
+ let each_blocks = [];
274
+ let each_1_lookup = new Map();
275
+ let div_resize_listener;
276
+ let current;
277
+ let each_value = /*renderItemLabels*/ ctx[2];
278
+ const get_key = ctx => /*itemLabelItem*/ ctx[28].id;
279
+
280
+ for (let i = 0; i < each_value.length; i += 1) {
281
+ let child_ctx = get_each_context(ctx, each_value, i);
282
+ let key = get_key(child_ctx);
283
+ each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
284
+ }
285
+
286
+ return {
287
+ c() {
288
+ div = internal.element("div");
289
+
290
+ for (let i = 0; i < each_blocks.length; i += 1) {
291
+ each_blocks[i].c();
292
+ }
293
+
294
+ internal.attr(div, "class", "item-labels-container svelte-gk8s47");
295
+ internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[10].call(div));
296
+ internal.set_style(div, "opacity", /*itemsVisible*/ ctx[5] ? 1 : 0, false);
297
+ },
298
+ m(target, anchor) {
299
+ internal.insert(target, div, anchor);
300
+
301
+ for (let i = 0; i < each_blocks.length; i += 1) {
302
+ each_blocks[i].m(div, null);
303
+ }
304
+
305
+ div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[10].bind(div));
306
+ current = true;
307
+ },
308
+ p(ctx, [dirty]) {
309
+ if (dirty & /*renderItemLabels, hooks, five, Five*/ 7) {
310
+ each_value = /*renderItemLabels*/ ctx[2];
311
+ internal.group_outros();
312
+ each_blocks = internal.update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, div, internal.outro_and_destroy_block, create_each_block, null, get_each_context);
313
+ internal.check_outros();
314
+ }
315
+
316
+ if (dirty & /*itemsVisible*/ 32) {
317
+ internal.set_style(div, "opacity", /*itemsVisible*/ ctx[5] ? 1 : 0, false);
318
+ }
319
+ },
320
+ i(local) {
321
+ if (current) return;
322
+
323
+ for (let i = 0; i < each_value.length; i += 1) {
324
+ internal.transition_in(each_blocks[i]);
325
+ }
326
+
327
+ current = true;
328
+ },
329
+ o(local) {
330
+ for (let i = 0; i < each_blocks.length; i += 1) {
331
+ internal.transition_out(each_blocks[i]);
332
+ }
333
+
334
+ current = false;
335
+ },
336
+ d(detaching) {
337
+ if (detaching) internal.detach(div);
338
+
339
+ for (let i = 0; i < each_blocks.length; i += 1) {
340
+ each_blocks[i].d();
341
+ }
342
+
343
+ div_resize_listener();
344
+ }
345
+ };
346
+ }
347
+ let basicWidth = 11;
348
+
349
+ function instance($$self, $$props, $$invalidate) {
350
+ const { Raycaster, Vector3 } = THREE__namespace;
351
+ let { five } = $$props;
352
+ let { modelOcclusionEnable } = $$props;
353
+ let { itemLabels } = $$props;
354
+ let { wrapper } = $$props;
355
+ let { hooks } = $$props;
356
+ let { displayStrategyType } = $$props;
357
+ let curItemLabels = null;
358
+ let renderItemLabels = null;
359
+ let wrapperSize = { width: 0, height: 0 };
360
+ let containerWidth;
361
+ let containerHeight;
362
+
363
+ // 计算重叠
364
+ let cssOffsetLists = [];
365
+
366
+ // 动画过程中 itemsVisible 为 false
367
+ let itemsVisible = true;
368
+
369
+ /**
370
+ * 可见性策略:
371
+ * 1、当前楼层(假设先不考虑多楼层)
372
+ * 2、模型未被遮挡(一个 box 有没有被遮挡的计算? TODO)
373
+ * */
374
+ const getLabelVisible = (five, itemLabel) => {
375
+ // 虚拟 VR 仅有一层,不考虑楼层信息
376
+ const raycaster = new Raycaster();
377
+
378
+ const cameraPosition = five.camera.position.clone();
379
+ const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
380
+
381
+ // 计算点到相机的位置
382
+ const vectorDistance = modelPosition.distanceTo(cameraPosition);
383
+
384
+ raycaster.set(cameraPosition.clone(), modelPosition.clone().sub(cameraPosition).normalize());
385
+ const [intersection] = five.model.intersectRaycaster(raycaster);
386
+ return !(intersection && intersection.distance + 1 < vectorDistance);
387
+ };
388
+
389
+ // cssOffset 获取
390
+ const getLabelCssOffset = (five, itemLabel) => {
391
+ const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
392
+ const cssPosition = five.project2d(modelPosition);
393
+
394
+ const xOffset = cssPosition === null || cssPosition === void 0
395
+ ? void 0
396
+ : cssPosition.x;
397
+
398
+ const yOffset = cssPosition === null || cssPosition === void 0
399
+ ? void 0
400
+ : cssPosition.y;
401
+
402
+ return [xOffset, yOffset];
403
+ };
404
+
405
+ const getLabelTransform = cssOffset => {
406
+ return `translate(${cssOffset[0]}px, ${cssOffset[1]}px)`;
407
+ };
408
+
409
+ function getStrokeLength(itemSpaceHeight, type) {
410
+ switch (type) {
411
+ case exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.SMALL:
412
+ return Math.ceil(-27.78 * itemSpaceHeight + 85);
413
+ case exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.MIDLLE:
414
+ return Math.ceil(-38.9 * itemSpaceHeight + 130);
415
+ case exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.LARGE:
416
+ return Math.ceil(-44.44 * itemSpaceHeight + 140);
417
+ case exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.EXTRA_LARGE:
418
+ return Math.ceil(-92.59 * itemSpaceHeight + 300);
419
+ }
420
+ }
421
+
422
+ const getFormatedItemLabels = (five, labels) => {
423
+ // 计算位置 & 可见性
424
+ const newLabels = labels.map(label => {
425
+ const cssOffset = getLabelCssOffset(five, label);
426
+ label.name.length * basicWidth;
427
+ const strokeLength = getStrokeLength(label.modelPosition[1], displayStrategyType);
428
+
429
+ // 是否加入碰撞检测
430
+ const naturalVisible = modelOcclusionEnable
431
+ ? getLabelVisible(five, label)
432
+ : true;
433
+
434
+ const visible = naturalVisible;
435
+
436
+ // 关掉重叠计算
437
+ // const visible = naturalVisible && !isOverlap([cssOffset[0], cssOffset[1] + strokeLength], curLabelWidth)
438
+ if (!visible) return Object.assign(Object.assign({}, label), { visible });
439
+
440
+ cssOffsetLists.push(cssOffset);
441
+
442
+ // position
443
+ const transform = getLabelTransform(cssOffset);
444
+
445
+ return Object.assign(Object.assign({}, label), { visible, transform, strokeLength });
446
+ });
447
+
448
+ const sortedItemLabelItems = newLabels.filter(({ visible }) => visible).map(label => ({
449
+ itemLabelItem: label,
450
+ distance: new Vector3(label.modelPosition[0], label.modelPosition[1], label.modelPosition[2]).clone().distanceTo(five.camera.position)
451
+ })).sort((a, b) => a.distance - b.distance);
452
+
453
+ return newLabels.map(label => {
454
+ const sortIndex = sortedItemLabelItems.findIndex(item => item.itemLabelItem.id === label.id);
455
+ if (sortIndex !== undefined) return Object.assign(Object.assign({}, label), { zIndex: sortIndex * 10 });
456
+ return label;
457
+ });
458
+ };
459
+
460
+ const onItemLabelUpdate = () => {
461
+ cssOffsetLists = [];
462
+ $$invalidate(2, renderItemLabels = getFormatedItemLabels(five, renderItemLabels));
463
+ };
464
+
465
+ svelte.beforeUpdate(() => {
466
+ addDataUpdateListener();
467
+ });
468
+
469
+ const handleCameraUpdateCallback = () => {
470
+ $$invalidate(5, itemsVisible = false);
471
+ handleCameraUpdate();
472
+ };
473
+
474
+ svelte.onMount(() => {
475
+ $$invalidate(2, renderItemLabels = itemLabels);
476
+ curItemLabels = itemLabels;
477
+ onItemLabelUpdate();
478
+ addResizeListener();
479
+ five.on('cameraUpdate', handleCameraUpdateCallback);
480
+ });
481
+
482
+ const handleCameraUpdate = debounce(
483
+ () => {
484
+ $$invalidate(5, itemsVisible = true);
485
+ onItemLabelUpdate();
486
+ },
487
+ 300
488
+ );
489
+
490
+ const addResizeListener = () => {
491
+ wrapperSize = {
492
+ width: wrapper.clientWidth,
493
+ height: wrapper.clientHeight
494
+ };
495
+
496
+ resizeObserver.observe(wrapper);
497
+ };
498
+
499
+ const addDataUpdateListener = () => {
500
+ if (curItemLabels !== itemLabels) {
501
+ $$invalidate(2, renderItemLabels = itemLabels);
502
+ curItemLabels = itemLabels;
503
+ onItemLabelUpdate();
504
+ }
505
+ };
506
+
507
+ const resizeObserver = new ResizeObserver(entries => {
508
+ const entry = entries[0];
509
+ const target = entry.target;
510
+ const curWidth = target.clientWidth;
511
+ const curHeight = target.clientHeight;
512
+
513
+ if (wrapperSize.width !== curWidth || wrapperSize.height !== curHeight) {
514
+ wrapperSize = { width: curWidth, height: curHeight };
515
+ onItemLabelUpdate();
516
+ }
517
+ });
518
+
519
+ svelte.onDestroy(() => {
520
+ five.off('cameraUpdate', handleCameraUpdateCallback);
521
+ resizeObserver.unobserve(wrapper);
522
+ });
523
+
524
+ function div_elementresize_handler() {
525
+ containerWidth = this.clientWidth;
526
+ containerHeight = this.clientHeight;
527
+ $$invalidate(3, containerWidth);
528
+ $$invalidate(4, containerHeight);
529
+ }
530
+
531
+ $$self.$$set = $$props => {
532
+ if ('five' in $$props) $$invalidate(0, five = $$props.five);
533
+ if ('modelOcclusionEnable' in $$props) $$invalidate(6, modelOcclusionEnable = $$props.modelOcclusionEnable);
534
+ if ('itemLabels' in $$props) $$invalidate(7, itemLabels = $$props.itemLabels);
535
+ if ('wrapper' in $$props) $$invalidate(8, wrapper = $$props.wrapper);
536
+ if ('hooks' in $$props) $$invalidate(1, hooks = $$props.hooks);
537
+ if ('displayStrategyType' in $$props) $$invalidate(9, displayStrategyType = $$props.displayStrategyType);
538
+ };
539
+
540
+ return [
541
+ five,
542
+ hooks,
543
+ renderItemLabels,
544
+ containerWidth,
545
+ containerHeight,
546
+ itemsVisible,
547
+ modelOcclusionEnable,
548
+ itemLabels,
549
+ wrapper,
550
+ displayStrategyType,
551
+ div_elementresize_handler
552
+ ];
553
+ }
554
+
555
+ class ItemLabelComponent extends internal.SvelteComponent {
556
+ constructor(options) {
557
+ super();
558
+
559
+ internal.init(
560
+ this,
561
+ options,
562
+ instance,
563
+ create_fragment,
564
+ internal.safe_not_equal,
565
+ {
566
+ five: 0,
567
+ modelOcclusionEnable: 6,
568
+ itemLabels: 7,
569
+ wrapper: 8,
570
+ hooks: 1,
571
+ displayStrategyType: 9
572
+ },
573
+ add_css
574
+ );
575
+ }
576
+ }
577
+
578
+ /** @description 转成内部所需数据 */
579
+ function parseItemLabelPluginData(data) {
580
+ return data.item_labels.map(label => (Object.assign({ modelPosition: [label.position[0], label.position[1], label.position[2]] }, label)));
581
+ }
582
+
583
+ const Plugin = (five$1, params) => {
584
+ var _a, _b;
585
+ const pluginState = {
586
+ container: document.createElement('div'),
587
+ data: null,
588
+ enabled: true,
589
+ fiveModeEnabled: true,
590
+ itemLabels: [],
591
+ wrapper: null,
592
+ app: undefined,
593
+ hooks: new five.Subscribe(),
594
+ modelOcclusionEnable: (_a = params === null || params === void 0 ? void 0 : params.modelOcclusionEnable) !== null && _a !== void 0 ? _a : true,
595
+ displayStrategyType: (_b = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _b !== void 0 ? _b : exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.SMALL,
596
+ };
597
+ pluginState.container.setAttribute('class', 'item-label-plugin-container');
598
+ pluginState.container.style.cssText = `
599
+ position: absolute;
600
+ left: 0;
601
+ top: 0;
602
+ width: 100%;
603
+ height: 100%;
604
+ z-index: 5;
605
+ `;
606
+ pluginState.container.style.pointerEvents = 'none'; // 写到 cssText 里不生效
607
+ const appendTo = (wrapper) => {
608
+ pluginState.wrapper = wrapper;
609
+ wrapper.appendChild(pluginState.container);
610
+ render();
611
+ return true;
612
+ };
613
+ const load = (data) => {
614
+ pluginState.itemLabels = parseItemLabelPluginData(data);
615
+ render();
616
+ };
617
+ const enable = () => {
618
+ if (pluginState.enabled)
619
+ return true;
620
+ pluginState.enabled = true;
621
+ render();
622
+ return true;
623
+ };
624
+ const disable = () => {
625
+ if (!pluginState.enabled)
626
+ return true;
627
+ pluginState.enabled = false;
628
+ render();
629
+ return true;
630
+ };
631
+ const dispose = () => {
632
+ removeListener4Five();
633
+ pluginState.container.remove();
634
+ };
635
+ const render = () => {
636
+ var _a;
637
+ if (!pluginState.wrapper)
638
+ return;
639
+ // 只要不可展示,销毁容器
640
+ if (!pluginState.enabled || !pluginState.fiveModeEnabled) {
641
+ (_a = pluginState.app) === null || _a === void 0 ? void 0 : _a.$destroy();
642
+ pluginState.app = undefined;
643
+ return;
644
+ }
645
+ // 正常显示时,分为 app 存在和不存在两种情况,如果存在,传值,不存在则初始化并传值
646
+ if (!pluginState.app) {
647
+ pluginState.app = new ItemLabelComponent({
648
+ target: pluginState.container,
649
+ props: {
650
+ five: five$1,
651
+ modelOcclusionEnable: pluginState.modelOcclusionEnable,
652
+ itemLabels: pluginState.itemLabels,
653
+ wrapper: pluginState.wrapper,
654
+ hooks: pluginState.hooks,
655
+ displayStrategyType: pluginState.displayStrategyType
656
+ }
657
+ });
658
+ }
659
+ else {
660
+ pluginState.app.$set({
661
+ five: five$1,
662
+ itemLabels: pluginState.itemLabels
663
+ });
664
+ }
665
+ };
666
+ // 添加 five 监听
667
+ const addListener4Five = () => {
668
+ five$1.on('modeChange', onFiveModeChange);
669
+ five$1.once('dispose', dispose);
670
+ };
671
+ // 取消 five 监听
672
+ const removeListener4Five = () => {
673
+ five$1.off('modeChange', onFiveModeChange);
674
+ };
675
+ const onFiveModeChange = (mode) => {
676
+ if (!pluginState.enabled)
677
+ return;
678
+ pluginState.fiveModeEnabled = false;
679
+ render();
680
+ five$1.once('initAnimationEnded', () => {
681
+ pluginState.fiveModeEnabled = true;
682
+ render();
683
+ });
684
+ };
685
+ addListener4Five();
686
+ return {
687
+ appendTo,
688
+ load,
689
+ enable,
690
+ disable,
691
+ dispose,
692
+ hooks: pluginState.hooks
693
+ };
694
+ };
695
+
696
+ const itemLabelPluginServerParams = {
697
+ name: 'ItemLabelPlugin',
698
+ version: 0,
699
+ };
700
+
701
+ exports.ItemLabelPlugin = Plugin;
702
+ exports["default"] = Plugin;
703
+ exports.itemLabelPluginServerParams = itemLabelPluginServerParams;