@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,414 @@
1
+ /* generated by Svelte v3.47.0 */
2
+ import {
3
+ SvelteComponent,
4
+ add_render_callback,
5
+ add_resize_listener,
6
+ append_styles,
7
+ attr,
8
+ check_outros,
9
+ create_component,
10
+ destroy_component,
11
+ detach,
12
+ element,
13
+ empty,
14
+ group_outros,
15
+ init,
16
+ insert,
17
+ mount_component,
18
+ outro_and_destroy_block,
19
+ safe_not_equal,
20
+ set_style,
21
+ transition_in,
22
+ transition_out,
23
+ update_keyed_each
24
+ } from "svelte/internal";
25
+
26
+ import { Five } from '@realsee/five';
27
+ import { ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE } from "./typings";
28
+ import { beforeUpdate, onDestroy, onMount } from "svelte";
29
+ import * as THREE from 'three';
30
+ import ItemLabelItem from './ItemLabelItem';
31
+ import "./events.type";
32
+ import debounce from '../shared-utils/debounce';
33
+
34
+ function add_css(target) {
35
+ append_styles(target, "svelte-rmdeb", ".item-labels-container.svelte-rmdeb{width:100%;height:100%;position:relative}");
36
+ }
37
+
38
+ function get_each_context(ctx, list, i) {
39
+ const child_ctx = ctx.slice();
40
+ child_ctx[28] = list[i];
41
+ return child_ctx;
42
+ }
43
+
44
+ // (163:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
45
+ function create_each_block(key_1, ctx) {
46
+ let first;
47
+ let itemlabelitem;
48
+ let current;
49
+
50
+ itemlabelitem = new ItemLabelItem({
51
+ props: {
52
+ itemLabel: /*itemLabelItem*/ ctx[28],
53
+ hooks: /*hooks*/ ctx[1],
54
+ anchorEnabled: /*five*/ ctx[0].currentMode === Five.Mode.Panorama
55
+ }
56
+ });
57
+
58
+ return {
59
+ key: key_1,
60
+ first: null,
61
+ c() {
62
+ first = empty();
63
+ create_component(itemlabelitem.$$.fragment);
64
+ this.first = first;
65
+ },
66
+ m(target, anchor) {
67
+ insert(target, first, anchor);
68
+ mount_component(itemlabelitem, target, anchor);
69
+ current = true;
70
+ },
71
+ p(new_ctx, dirty) {
72
+ ctx = new_ctx;
73
+ const itemlabelitem_changes = {};
74
+ if (dirty & /*renderItemLabels*/ 4) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[28];
75
+ if (dirty & /*hooks*/ 2) itemlabelitem_changes.hooks = /*hooks*/ ctx[1];
76
+ if (dirty & /*five*/ 1) itemlabelitem_changes.anchorEnabled = /*five*/ ctx[0].currentMode === Five.Mode.Panorama;
77
+ itemlabelitem.$set(itemlabelitem_changes);
78
+ },
79
+ i(local) {
80
+ if (current) return;
81
+ transition_in(itemlabelitem.$$.fragment, local);
82
+ current = true;
83
+ },
84
+ o(local) {
85
+ transition_out(itemlabelitem.$$.fragment, local);
86
+ current = false;
87
+ },
88
+ d(detaching) {
89
+ if (detaching) detach(first);
90
+ destroy_component(itemlabelitem, detaching);
91
+ }
92
+ };
93
+ }
94
+
95
+ function create_fragment(ctx) {
96
+ let div;
97
+ let each_blocks = [];
98
+ let each_1_lookup = new Map();
99
+ let div_resize_listener;
100
+ let current;
101
+ let each_value = /*renderItemLabels*/ ctx[2];
102
+ const get_key = ctx => /*itemLabelItem*/ ctx[28].id;
103
+
104
+ for (let i = 0; i < each_value.length; i += 1) {
105
+ let child_ctx = get_each_context(ctx, each_value, i);
106
+ let key = get_key(child_ctx);
107
+ each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
108
+ }
109
+
110
+ return {
111
+ c() {
112
+ div = element("div");
113
+
114
+ for (let i = 0; i < each_blocks.length; i += 1) {
115
+ each_blocks[i].c();
116
+ }
117
+
118
+ attr(div, "class", "item-labels-container svelte-rmdeb");
119
+ add_render_callback(() => /*div_elementresize_handler*/ ctx[10].call(div));
120
+ set_style(div, "opacity", /*itemsVisible*/ ctx[5] ? 1 : 0, false);
121
+ },
122
+ m(target, anchor) {
123
+ insert(target, div, anchor);
124
+
125
+ for (let i = 0; i < each_blocks.length; i += 1) {
126
+ each_blocks[i].m(div, null);
127
+ }
128
+
129
+ div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[10].bind(div));
130
+ current = true;
131
+ },
132
+ p(ctx, [dirty]) {
133
+ if (dirty & /*renderItemLabels, hooks, five, Five*/ 7) {
134
+ each_value = /*renderItemLabels*/ ctx[2];
135
+ group_outros();
136
+ each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, div, outro_and_destroy_block, create_each_block, null, get_each_context);
137
+ check_outros();
138
+ }
139
+
140
+ if (dirty & /*itemsVisible*/ 32) {
141
+ set_style(div, "opacity", /*itemsVisible*/ ctx[5] ? 1 : 0, false);
142
+ }
143
+ },
144
+ i(local) {
145
+ if (current) return;
146
+
147
+ for (let i = 0; i < each_value.length; i += 1) {
148
+ transition_in(each_blocks[i]);
149
+ }
150
+
151
+ current = true;
152
+ },
153
+ o(local) {
154
+ for (let i = 0; i < each_blocks.length; i += 1) {
155
+ transition_out(each_blocks[i]);
156
+ }
157
+
158
+ current = false;
159
+ },
160
+ d(detaching) {
161
+ if (detaching) detach(div);
162
+
163
+ for (let i = 0; i < each_blocks.length; i += 1) {
164
+ each_blocks[i].d();
165
+ }
166
+
167
+ div_resize_listener();
168
+ }
169
+ };
170
+ }
171
+
172
+ let cssHeight = 26;
173
+ let basicWidth = 11;
174
+
175
+ function instance($$self, $$props, $$invalidate) {
176
+ const { Raycaster, Vector3 } = THREE;
177
+ let { five } = $$props;
178
+ let { modelOcclusionEnable } = $$props;
179
+ let { itemLabels } = $$props;
180
+ let { wrapper } = $$props;
181
+ let { hooks } = $$props;
182
+ let { displayStrategyType } = $$props;
183
+ let curItemLabels = null;
184
+ let renderItemLabels = null;
185
+ let wrapperSize = { width: 0, height: 0 };
186
+ let containerWidth;
187
+ let containerHeight;
188
+
189
+ // 计算重叠
190
+ let cssOffsetLists = [];
191
+
192
+ // 动画过程中 itemsVisible 为 false
193
+ let itemsVisible = true;
194
+
195
+ /**
196
+ * 可见性策略:
197
+ * 1、当前楼层(假设先不考虑多楼层)
198
+ * 2、模型未被遮挡(一个 box 有没有被遮挡的计算? TODO)
199
+ * */
200
+ const getLabelVisible = (five, itemLabel) => {
201
+ // 虚拟 VR 仅有一层,不考虑楼层信息
202
+ const raycaster = new Raycaster();
203
+
204
+ const cameraPosition = five.camera.position.clone();
205
+ const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
206
+
207
+ // 计算点到相机的位置
208
+ const vectorDistance = modelPosition.distanceTo(cameraPosition);
209
+
210
+ raycaster.set(cameraPosition.clone(), modelPosition.clone().sub(cameraPosition).normalize());
211
+ const [intersection] = five.model.intersectRaycaster(raycaster);
212
+ return !(intersection && intersection.distance + 1 < vectorDistance);
213
+ };
214
+
215
+ // cssOffset 获取
216
+ const getLabelCssOffset = (five, itemLabel) => {
217
+ const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
218
+ const cssPosition = five.project2d(modelPosition);
219
+
220
+ const xOffset = cssPosition === null || cssPosition === void 0
221
+ ? void 0
222
+ : cssPosition.x;
223
+
224
+ const yOffset = cssPosition === null || cssPosition === void 0
225
+ ? void 0
226
+ : cssPosition.y;
227
+
228
+ return [xOffset, yOffset];
229
+ };
230
+
231
+ const getLabelTransform = cssOffset => {
232
+ return `translate(${cssOffset[0]}px, ${cssOffset[1]}px)`;
233
+ };
234
+
235
+ // 重叠计算
236
+ const isOverlap = (cssOffset, widthOffset) => {
237
+ if (cssOffsetLists.length === 0) {
238
+ return false;
239
+ }
240
+
241
+ const hasOverlapPoint = cssOffsetLists.find(item => cssOffset[0] >= item[0] - widthOffset && cssOffset[0] <= item[0] + widthOffset || cssOffset[1] >= item[1] - cssHeight && cssOffset[1] <= item[1] + cssHeight);
242
+ return !!hasOverlapPoint;
243
+ };
244
+
245
+ function getStrokeLength(itemSpaceHeight, type) {
246
+ switch (type) {
247
+ case ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.SMALL:
248
+ return Math.ceil(-27.78 * itemSpaceHeight + 85);
249
+ case ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.MIDLLE:
250
+ return Math.ceil(-38.9 * itemSpaceHeight + 130);
251
+ case ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.LARGE:
252
+ return Math.ceil(-44.44 * itemSpaceHeight + 140);
253
+ case ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.EXTRA_LARGE:
254
+ return Math.ceil(-92.59 * itemSpaceHeight + 300);
255
+ }
256
+ }
257
+
258
+ const getFormatedItemLabels = (five, labels) => {
259
+ // 计算位置 & 可见性
260
+ const newLabels = labels.map(label => {
261
+ const cssOffset = getLabelCssOffset(five, label);
262
+ const curLabelWidth = label.name.length * basicWidth;
263
+ const strokeLength = getStrokeLength(label.modelPosition[1], displayStrategyType);
264
+
265
+ // 是否加入碰撞检测
266
+ const naturalVisible = modelOcclusionEnable
267
+ ? getLabelVisible(five, label)
268
+ : true;
269
+
270
+ const visible = naturalVisible;
271
+
272
+ // 关掉重叠计算
273
+ // const visible = naturalVisible && !isOverlap([cssOffset[0], cssOffset[1] + strokeLength], curLabelWidth)
274
+ if (!visible) return Object.assign(Object.assign({}, label), { visible });
275
+
276
+ cssOffsetLists.push(cssOffset);
277
+
278
+ // position
279
+ const transform = getLabelTransform(cssOffset);
280
+
281
+ return Object.assign(Object.assign({}, label), { visible, transform, strokeLength });
282
+ });
283
+
284
+ const sortedItemLabelItems = newLabels.filter(({ visible }) => visible).map(label => ({
285
+ itemLabelItem: label,
286
+ distance: new Vector3(label.modelPosition[0], label.modelPosition[1], label.modelPosition[2]).clone().distanceTo(five.camera.position)
287
+ })).sort((a, b) => a.distance - b.distance);
288
+
289
+ return newLabels.map(label => {
290
+ const sortIndex = sortedItemLabelItems.findIndex(item => item.itemLabelItem.id === label.id);
291
+ if (sortIndex !== undefined) return Object.assign(Object.assign({}, label), { zIndex: sortIndex * 10 });
292
+ return label;
293
+ });
294
+ };
295
+
296
+ const onItemLabelUpdate = () => {
297
+ cssOffsetLists = [];
298
+ $$invalidate(2, renderItemLabels = getFormatedItemLabels(five, renderItemLabels));
299
+ };
300
+
301
+ beforeUpdate(() => {
302
+ addDataUpdateListener();
303
+ });
304
+
305
+ const handleCameraUpdateCallback = () => {
306
+ $$invalidate(5, itemsVisible = false);
307
+ handleCameraUpdate();
308
+ };
309
+
310
+ onMount(() => {
311
+ $$invalidate(2, renderItemLabels = itemLabels);
312
+ curItemLabels = itemLabels;
313
+ onItemLabelUpdate();
314
+ addResizeListener();
315
+ five.on('cameraUpdate', handleCameraUpdateCallback);
316
+ });
317
+
318
+ const handleCameraUpdate = debounce(
319
+ () => {
320
+ $$invalidate(5, itemsVisible = true);
321
+ onItemLabelUpdate();
322
+ },
323
+ 300
324
+ );
325
+
326
+ const addResizeListener = () => {
327
+ wrapperSize = {
328
+ width: wrapper.clientWidth,
329
+ height: wrapper.clientHeight
330
+ };
331
+
332
+ resizeObserver.observe(wrapper);
333
+ };
334
+
335
+ const addDataUpdateListener = () => {
336
+ if (curItemLabels !== itemLabels) {
337
+ $$invalidate(2, renderItemLabels = itemLabels);
338
+ curItemLabels = itemLabels;
339
+ onItemLabelUpdate();
340
+ }
341
+ };
342
+
343
+ const resizeObserver = new ResizeObserver(entries => {
344
+ const entry = entries[0];
345
+ const target = entry.target;
346
+ const curWidth = target.clientWidth;
347
+ const curHeight = target.clientHeight;
348
+
349
+ if (wrapperSize.width !== curWidth || wrapperSize.height !== curHeight) {
350
+ wrapperSize = { width: curWidth, height: curHeight };
351
+ onItemLabelUpdate();
352
+ }
353
+ });
354
+
355
+ onDestroy(() => {
356
+ five.off('cameraUpdate', handleCameraUpdateCallback);
357
+ resizeObserver.unobserve(wrapper);
358
+ });
359
+
360
+ function div_elementresize_handler() {
361
+ containerWidth = this.clientWidth;
362
+ containerHeight = this.clientHeight;
363
+ $$invalidate(3, containerWidth);
364
+ $$invalidate(4, containerHeight);
365
+ }
366
+
367
+ $$self.$$set = $$props => {
368
+ if ('five' in $$props) $$invalidate(0, five = $$props.five);
369
+ if ('modelOcclusionEnable' in $$props) $$invalidate(6, modelOcclusionEnable = $$props.modelOcclusionEnable);
370
+ if ('itemLabels' in $$props) $$invalidate(7, itemLabels = $$props.itemLabels);
371
+ if ('wrapper' in $$props) $$invalidate(8, wrapper = $$props.wrapper);
372
+ if ('hooks' in $$props) $$invalidate(1, hooks = $$props.hooks);
373
+ if ('displayStrategyType' in $$props) $$invalidate(9, displayStrategyType = $$props.displayStrategyType);
374
+ };
375
+
376
+ return [
377
+ five,
378
+ hooks,
379
+ renderItemLabels,
380
+ containerWidth,
381
+ containerHeight,
382
+ itemsVisible,
383
+ modelOcclusionEnable,
384
+ itemLabels,
385
+ wrapper,
386
+ displayStrategyType,
387
+ div_elementresize_handler
388
+ ];
389
+ }
390
+
391
+ class Component extends SvelteComponent {
392
+ constructor(options) {
393
+ super();
394
+
395
+ init(
396
+ this,
397
+ options,
398
+ instance,
399
+ create_fragment,
400
+ safe_not_equal,
401
+ {
402
+ five: 0,
403
+ modelOcclusionEnable: 6,
404
+ itemLabels: 7,
405
+ wrapper: 8,
406
+ hooks: 1,
407
+ displayStrategyType: 9
408
+ },
409
+ add_css
410
+ );
411
+ }
412
+ }
413
+
414
+ export default Component;
@@ -0,0 +1,173 @@
1
+ /* generated by Svelte v3.47.0 */
2
+ import {
3
+ SvelteComponent,
4
+ append,
5
+ append_styles,
6
+ attr,
7
+ detach,
8
+ element,
9
+ init,
10
+ insert,
11
+ listen,
12
+ noop,
13
+ null_to_empty,
14
+ safe_not_equal,
15
+ set_data,
16
+ set_style,
17
+ space,
18
+ text
19
+ } from "svelte/internal";
20
+
21
+ import "./events.type";
22
+ import classNames from 'classnames';
23
+
24
+ function add_css(target) {
25
+ append_styles(target, "svelte-1u8wokx", ".item-label-item.svelte-1u8wokx{position:absolute;z-index:0;transform:none;cursor:pointer;pointer-events:none;user-select:none;opacity:0}.item-label-item.visible.svelte-1u8wokx{opacity:1;animation:svelte-1u8wokx-fadeIn .3s ease-in}.item-label-item__text-wrap.svelte-1u8wokx{height:fit-content;padding:12px 20px 12px 12px;position:absolute;width:max-content;max-width:473px;min-height:92px;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:3px;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-1u8wokx{pointer-events:all}.icon-wrap.svelte-1u8wokx{width:68px;height:100%;display:flex;justify-content:center;align-content:center}.icon.svelte-1u8wokx{width:68px;height:68px;background-repeat:no-repeat;background-size:contain;background-position:center}.item-label-text.svelte-1u8wokx{margin-left:12px;padding-left:12px;min-height:68px;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-1u8wokx{white-space:nowrap;font-size:22px;font-weight:bold;line-height:30px}.item-name.svelte-1u8wokx{height:auto;word-wrap:break-word;word-break:break-all;font-size:20px;line-height:28px}.item-label-item__bar.svelte-1u8wokx{position:absolute;bottom:0;width:3px;background-image:linear-gradient(to bottom, white, rgba(255, 255, 255, 0));box-shadow:0 2px 8px 0 rgba(0,0,0,0.20);pointer-events:none}.item-label-item__bar.anchor.svelte-1u8wokx:after{content:'';position:absolute;bottom:0;width:24px;height:24px;background-image:url(\"//vrlab-public.ljcdn.com/common/file/web/67e7a198-28c9-47dc-879b-507bd3ae600c.png \");background-position:center;background-size:contain;transform:translate(-10.5px, 50%)}@keyframes svelte-1u8wokx-fadeIn{from{opacity:0\n }to{opacity:1\n }}");
26
+ }
27
+
28
+ function create_fragment(ctx) {
29
+ let div5;
30
+ let div3;
31
+ let div1;
32
+ let div0;
33
+ let div0_style_value;
34
+ let t0;
35
+ let div2;
36
+ let span0;
37
+ let t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "";
38
+ let t1;
39
+ let t2;
40
+ let span1;
41
+ let t3_value = /*itemLabel*/ ctx[0].name + "";
42
+ let t3;
43
+ let div3_class_value;
44
+ let t4;
45
+ let div4;
46
+ let div4_class_value;
47
+ let div5_class_value;
48
+ let mounted;
49
+ let dispose;
50
+
51
+ return {
52
+ c() {
53
+ div5 = element("div");
54
+ div3 = element("div");
55
+ div1 = element("div");
56
+ div0 = element("div");
57
+ t0 = space();
58
+ div2 = element("div");
59
+ span0 = element("span");
60
+ t1 = text(t1_value);
61
+ t2 = space();
62
+ span1 = element("span");
63
+ t3 = text(t3_value);
64
+ t4 = space();
65
+ div4 = element("div");
66
+ attr(div0, "class", "icon svelte-1u8wokx");
67
+ attr(div0, "style", div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`);
68
+ attr(div1, "class", "icon-wrap svelte-1u8wokx");
69
+ attr(span0, "class", "item-model svelte-1u8wokx");
70
+ attr(span1, "class", "item-name svelte-1u8wokx");
71
+ attr(div2, "class", "item-label-text svelte-1u8wokx");
72
+ attr(div3, "class", div3_class_value = "" + (null_to_empty(classNames("item-label-item__text-wrap", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1u8wokx"));
73
+ set_style(div3, "bottom", `${/*itemLabel*/ ctx[0].strokeLength}px`);
74
+ attr(div4, "class", div4_class_value = "" + (null_to_empty(classNames("item-label-item__bar", { anchor: /*anchorEnabled*/ ctx[1] })) + " svelte-1u8wokx"));
75
+ set_style(div4, "height", `${/*itemLabel*/ ctx[0].strokeLength}px`);
76
+ attr(div5, "class", div5_class_value = "" + (null_to_empty(classNames("item-label-item", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1u8wokx"));
77
+ set_style(div5, "z-index", /*itemLabel*/ ctx[0].zIndex, false);
78
+ set_style(div5, "transform", /*itemLabel*/ ctx[0].transform, false);
79
+ },
80
+ m(target, anchor) {
81
+ insert(target, div5, anchor);
82
+ append(div5, div3);
83
+ append(div3, div1);
84
+ append(div1, div0);
85
+ append(div3, t0);
86
+ append(div3, div2);
87
+ append(div2, span0);
88
+ append(span0, t1);
89
+ append(div2, t2);
90
+ append(div2, span1);
91
+ append(span1, t3);
92
+ append(div5, t4);
93
+ append(div5, div4);
94
+
95
+ if (!mounted) {
96
+ dispose = listen(div3, "click", /*onClick*/ ctx[2]);
97
+ mounted = true;
98
+ }
99
+ },
100
+ p(ctx, [dirty]) {
101
+ if (dirty & /*itemLabel*/ 1 && div0_style_value !== (div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`)) {
102
+ attr(div0, "style", div0_style_value);
103
+ }
104
+
105
+ if (dirty & /*itemLabel*/ 1 && t1_value !== (t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "")) set_data(t1, t1_value);
106
+ if (dirty & /*itemLabel*/ 1 && t3_value !== (t3_value = /*itemLabel*/ ctx[0].name + "")) set_data(t3, t3_value);
107
+
108
+ if (dirty & /*itemLabel*/ 1 && div3_class_value !== (div3_class_value = "" + (null_to_empty(classNames("item-label-item__text-wrap", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1u8wokx"))) {
109
+ attr(div3, "class", div3_class_value);
110
+ }
111
+
112
+ if (dirty & /*itemLabel*/ 1) {
113
+ set_style(div3, "bottom", `${/*itemLabel*/ ctx[0].strokeLength}px`);
114
+ }
115
+
116
+ if (dirty & /*anchorEnabled*/ 2 && div4_class_value !== (div4_class_value = "" + (null_to_empty(classNames("item-label-item__bar", { anchor: /*anchorEnabled*/ ctx[1] })) + " svelte-1u8wokx"))) {
117
+ attr(div4, "class", div4_class_value);
118
+ }
119
+
120
+ if (dirty & /*itemLabel*/ 1) {
121
+ set_style(div4, "height", `${/*itemLabel*/ ctx[0].strokeLength}px`);
122
+ }
123
+
124
+ if (dirty & /*itemLabel*/ 1 && div5_class_value !== (div5_class_value = "" + (null_to_empty(classNames("item-label-item", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1u8wokx"))) {
125
+ attr(div5, "class", div5_class_value);
126
+ }
127
+
128
+ if (dirty & /*itemLabel*/ 1) {
129
+ set_style(div5, "z-index", /*itemLabel*/ ctx[0].zIndex, false);
130
+ }
131
+
132
+ if (dirty & /*itemLabel*/ 1) {
133
+ set_style(div5, "transform", /*itemLabel*/ ctx[0].transform, false);
134
+ }
135
+ },
136
+ i: noop,
137
+ o: noop,
138
+ d(detaching) {
139
+ if (detaching) detach(div5);
140
+ mounted = false;
141
+ dispose();
142
+ }
143
+ };
144
+ }
145
+
146
+ const defaultIcon = '//vrlab-public.ljcdn.com/common/file/web/c8591aaa-e62b-4e31-8fed-671483ace37f.svg\n';
147
+
148
+ function instance($$self, $$props, $$invalidate) {
149
+ let { itemLabel } = $$props;
150
+ let { hooks } = $$props;
151
+ let { anchorEnabled } = $$props;
152
+
153
+ function onClick() {
154
+ hooks.emit('onLabelClick', itemLabel);
155
+ }
156
+
157
+ $$self.$$set = $$props => {
158
+ if ('itemLabel' in $$props) $$invalidate(0, itemLabel = $$props.itemLabel);
159
+ if ('hooks' in $$props) $$invalidate(3, hooks = $$props.hooks);
160
+ if ('anchorEnabled' in $$props) $$invalidate(1, anchorEnabled = $$props.anchorEnabled);
161
+ };
162
+
163
+ return [itemLabel, anchorEnabled, onClick, hooks];
164
+ }
165
+
166
+ class Component extends SvelteComponent {
167
+ constructor(options) {
168
+ super();
169
+ init(this, options, instance, create_fragment, safe_not_equal, { itemLabel: 0, hooks: 3, anchorEnabled: 1 }, add_css);
170
+ }
171
+ }
172
+
173
+ export default Component;
@@ -0,0 +1,4 @@
1
+ import type { FivePlugin } from "@realsee/five";
2
+ import { ItemLabelPluginExportReturnsType, ItemLabelPluginParametersType } from "./typings";
3
+ export declare const Plugin: FivePlugin<ItemLabelPluginParametersType, ItemLabelPluginExportReturnsType>;
4
+ export default Plugin;
@@ -0,0 +1,117 @@
1
+ import { Subscribe } from "@realsee/five";
2
+ import ItemLabelComponent from './ItemLabelComponent';
3
+ import { ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE } from "./typings";
4
+ import { parseItemLabelPluginData } from "./utils/parseData";
5
+ export const Plugin = (five, params) => {
6
+ var _a, _b;
7
+ const pluginState = {
8
+ container: document.createElement('div'),
9
+ data: null,
10
+ enabled: true,
11
+ fiveModeEnabled: true,
12
+ itemLabels: [],
13
+ wrapper: null,
14
+ app: undefined,
15
+ hooks: new Subscribe(),
16
+ modelOcclusionEnable: (_a = params === null || params === void 0 ? void 0 : params.modelOcclusionEnable) !== null && _a !== void 0 ? _a : true,
17
+ displayStrategyType: (_b = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _b !== void 0 ? _b : ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.SMALL,
18
+ };
19
+ pluginState.container.setAttribute('class', 'item-label-plugin-container');
20
+ pluginState.container.style.cssText = `
21
+ position: absolute;
22
+ left: 0;
23
+ top: 0;
24
+ width: 100%;
25
+ height: 100%;
26
+ z-index: 5;
27
+ `;
28
+ pluginState.container.style.pointerEvents = 'none'; // 写到 cssText 里不生效
29
+ const appendTo = (wrapper) => {
30
+ pluginState.wrapper = wrapper;
31
+ wrapper.appendChild(pluginState.container);
32
+ render();
33
+ return true;
34
+ };
35
+ const load = (data) => {
36
+ pluginState.itemLabels = parseItemLabelPluginData(data);
37
+ render();
38
+ };
39
+ const enable = () => {
40
+ if (pluginState.enabled)
41
+ return true;
42
+ pluginState.enabled = true;
43
+ render();
44
+ return true;
45
+ };
46
+ const disable = () => {
47
+ if (!pluginState.enabled)
48
+ return true;
49
+ pluginState.enabled = false;
50
+ render();
51
+ return true;
52
+ };
53
+ const dispose = () => {
54
+ removeListener4Five();
55
+ pluginState.container.remove();
56
+ };
57
+ const render = () => {
58
+ var _a;
59
+ if (!pluginState.wrapper)
60
+ return;
61
+ // 只要不可展示,销毁容器
62
+ if (!pluginState.enabled || !pluginState.fiveModeEnabled) {
63
+ (_a = pluginState.app) === null || _a === void 0 ? void 0 : _a.$destroy();
64
+ pluginState.app = undefined;
65
+ return;
66
+ }
67
+ // 正常显示时,分为 app 存在和不存在两种情况,如果存在,传值,不存在则初始化并传值
68
+ if (!pluginState.app) {
69
+ pluginState.app = new ItemLabelComponent({
70
+ target: pluginState.container,
71
+ props: {
72
+ five: five,
73
+ modelOcclusionEnable: pluginState.modelOcclusionEnable,
74
+ itemLabels: pluginState.itemLabels,
75
+ wrapper: pluginState.wrapper,
76
+ hooks: pluginState.hooks,
77
+ displayStrategyType: pluginState.displayStrategyType
78
+ }
79
+ });
80
+ }
81
+ else {
82
+ pluginState.app.$set({
83
+ five: five,
84
+ itemLabels: pluginState.itemLabels
85
+ });
86
+ }
87
+ };
88
+ // 添加 five 监听
89
+ const addListener4Five = () => {
90
+ five.on('modeChange', onFiveModeChange);
91
+ five.once('dispose', dispose);
92
+ };
93
+ // 取消 five 监听
94
+ const removeListener4Five = () => {
95
+ five.off('modeChange', onFiveModeChange);
96
+ };
97
+ const onFiveModeChange = (mode) => {
98
+ if (!pluginState.enabled)
99
+ return;
100
+ pluginState.fiveModeEnabled = false;
101
+ render();
102
+ five.once('initAnimationEnded', () => {
103
+ pluginState.fiveModeEnabled = true;
104
+ render();
105
+ });
106
+ };
107
+ addListener4Five();
108
+ return {
109
+ appendTo,
110
+ load,
111
+ enable,
112
+ disable,
113
+ dispose,
114
+ hooks: pluginState.hooks
115
+ };
116
+ };
117
+ export default Plugin;