@realsee/dnalogel 2.0.0-alpha.38 → 2.0.0-alpha.39

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 (95) hide show
  1. package/dist/ItemLabelPlugin/index.js +60 -36
  2. package/dist/ItemLabelPlugin/typings.d.ts +4 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.es.js +63 -37
  5. package/dist/index.js +63 -36
  6. package/dist/index.umd.js +63 -36
  7. package/docs/assets/search.js +1 -1
  8. package/docs/classes/Magnifier.html +4 -4
  9. package/docs/classes/ModelRoomLabelController.html +4 -4
  10. package/docs/enums/CameraMovementEffect.html +2 -2
  11. package/docs/enums/DIRECTION.html +1 -1
  12. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
  13. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  14. package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
  15. package/docs/enums/Rotation.html +2 -2
  16. package/docs/index.html +2 -2
  17. package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
  18. package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
  19. package/docs/interfaces/FloorplanBounding.html +4 -4
  20. package/docs/interfaces/FloorplanData.html +2 -2
  21. package/docs/interfaces/FloorplanEntrance.html +7 -7
  22. package/docs/interfaces/FloorplanExtraObject.html +3 -3
  23. package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
  24. package/docs/interfaces/FloorplanFloorData.html +2 -2
  25. package/docs/interfaces/FloorplanImagePosition.html +2 -2
  26. package/docs/interfaces/FloorplanObserver.html +2 -2
  27. package/docs/interfaces/FloorplanOutlineItem.html +2 -2
  28. package/docs/interfaces/FloorplanPosition.html +2 -2
  29. package/docs/interfaces/FloorplanRoomItem.html +6 -6
  30. package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
  31. package/docs/interfaces/FloorplanServerBounding.html +4 -4
  32. package/docs/interfaces/FloorplanServerComputedData.html +1 -1
  33. package/docs/interfaces/FloorplanServerData.html +2 -2
  34. package/docs/interfaces/FloorplanServerEntrance.html +7 -7
  35. package/docs/interfaces/FloorplanServerFloorData.html +2 -2
  36. package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
  37. package/docs/interfaces/FloorplanServerObserver.html +2 -2
  38. package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
  39. package/docs/interfaces/FloorplanServerPosition.html +2 -2
  40. package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
  41. package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
  42. package/docs/interfaces/ItemLabelPluginData.html +1 -1
  43. package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
  44. package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
  45. package/docs/interfaces/LineJson.html +1 -1
  46. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  47. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  48. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  49. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  50. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  51. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  52. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  53. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  54. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  55. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  56. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  57. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  58. package/docs/interfaces/ModelViewPluginExportType.html +1 -1
  59. package/docs/interfaces/OpenParameter.html +2 -2
  60. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  61. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  62. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  63. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
  64. package/docs/interfaces/PanoMeasureParameterType.html +1 -1
  65. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  66. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  67. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  68. package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
  69. package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
  70. package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
  71. package/docs/interfaces/PanoRulerProPluginState.html +1 -1
  72. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
  73. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
  74. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  75. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
  76. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  77. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
  78. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  79. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
  80. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
  81. package/docs/interfaces/Point.html +1 -1
  82. package/docs/interfaces/PointJson.html +1 -1
  83. package/docs/interfaces/Room.html +1 -1
  84. package/docs/interfaces/RoomInfo.html +1 -1
  85. package/docs/interfaces/RoomLabel.html +7 -7
  86. package/docs/interfaces/RoomRules.html +1 -1
  87. package/docs/interfaces/Rooms.html +1 -1
  88. package/docs/modules.html +18 -18
  89. package/libs/ItemLabelPlugin/ItemLabelComponent.js +34 -21
  90. package/libs/ItemLabelPlugin/Plugin.js +16 -10
  91. package/libs/ItemLabelPlugin/typings.d.ts +4 -0
  92. package/libs/ItemLabelPlugin/utils/parseData.js +1 -1
  93. package/libs/index.d.ts +1 -0
  94. package/libs/index.js +1 -0
  95. package/package.json +1 -1
@@ -304,18 +304,18 @@ function add_css(target) {
304
304
 
305
305
  function get_each_context(ctx, list, i) {
306
306
  const child_ctx = ctx.slice();
307
- child_ctx[30] = list[i];
307
+ child_ctx[31] = list[i];
308
308
  return child_ctx;
309
309
  }
310
310
 
311
- // (229:2) {#if itemLabelItem.visible}
311
+ // (235:2) {#if itemLabelItem.visible}
312
312
  function create_if_block(ctx) {
313
313
  let itemlabelitem;
314
314
  let current;
315
315
 
316
316
  itemlabelitem = new ItemLabelItem({
317
317
  props: {
318
- itemLabel: /*itemLabelItem*/ ctx[30],
318
+ itemLabel: /*itemLabelItem*/ ctx[31],
319
319
  hooks: /*hooks*/ ctx[0],
320
320
  anchorEnabled: /*anchorEnabled*/ ctx[2],
321
321
  onIconClick: /*onIconClick*/ ctx[6]
@@ -332,7 +332,7 @@ function create_if_block(ctx) {
332
332
  },
333
333
  p(ctx, dirty) {
334
334
  const itemlabelitem_changes = {};
335
- if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[30];
335
+ if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[31];
336
336
  if (dirty[0] & /*hooks*/ 1) itemlabelitem_changes.hooks = /*hooks*/ ctx[0];
337
337
  if (dirty[0] & /*anchorEnabled*/ 4) itemlabelitem_changes.anchorEnabled = /*anchorEnabled*/ ctx[2];
338
338
  itemlabelitem.$set(itemlabelitem_changes);
@@ -352,12 +352,12 @@ function create_if_block(ctx) {
352
352
  };
353
353
  }
354
354
 
355
- // (228:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
355
+ // (234:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
356
356
  function create_each_block(key_1, ctx) {
357
357
  let first;
358
358
  let if_block_anchor;
359
359
  let current;
360
- let if_block = /*itemLabelItem*/ ctx[30].visible && create_if_block(ctx);
360
+ let if_block = /*itemLabelItem*/ ctx[31].visible && create_if_block(ctx);
361
361
 
362
362
  return {
363
363
  key: key_1,
@@ -377,7 +377,7 @@ function create_each_block(key_1, ctx) {
377
377
  p(new_ctx, dirty) {
378
378
  ctx = new_ctx;
379
379
 
380
- if (/*itemLabelItem*/ ctx[30].visible) {
380
+ if (/*itemLabelItem*/ ctx[31].visible) {
381
381
  if (if_block) {
382
382
  if_block.p(ctx, dirty);
383
383
 
@@ -424,7 +424,7 @@ function create_fragment(ctx) {
424
424
  let div_resize_listener;
425
425
  let current;
426
426
  let each_value = /*renderItemLabels*/ ctx[1];
427
- const get_key = ctx => /*itemLabelItem*/ ctx[30].id;
427
+ const get_key = ctx => /*itemLabelItem*/ ctx[31].id;
428
428
 
429
429
  for (let i = 0; i < each_value.length; i += 1) {
430
430
  let child_ctx = get_each_context(ctx, each_value, i);
@@ -441,7 +441,7 @@ function create_fragment(ctx) {
441
441
  }
442
442
 
443
443
  internal.attr(div, "class", "item-labels-container svelte-gk8s47");
444
- internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[12].call(div));
444
+ internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[13].call(div));
445
445
  internal.set_style(div, "opacity", /*itemsVisible*/ ctx[5] ? 1 : 0, false);
446
446
  },
447
447
  m(target, anchor) {
@@ -451,7 +451,7 @@ function create_fragment(ctx) {
451
451
  each_blocks[i].m(div, null);
452
452
  }
453
453
 
454
- div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[12].bind(div));
454
+ div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[13].bind(div));
455
455
  current = true;
456
456
  },
457
457
  p(ctx, dirty) {
@@ -499,6 +499,7 @@ function instance($$self, $$props, $$invalidate) {
499
499
  const { Raycaster, Vector3 } = THREE__namespace;
500
500
  let { five: five$1 } = $$props;
501
501
  let { modelOcclusionEnable } = $$props;
502
+ let { onlyVisibleInPanorama } = $$props;
502
503
  let { itemLabels } = $$props;
503
504
  let { hooks } = $$props;
504
505
  let { displayStrategyType } = $$props;
@@ -550,7 +551,10 @@ function instance($$self, $$props, $$invalidate) {
550
551
  const ratioFromTop = (2 - (offsetYFromCenter + 1)) / 2;
551
552
  const isFront = Math.abs(offsetZFromCenter) < 1;
552
553
  const cssOffset = [ratioFromLeft, ratioFromTop];
554
+
555
+ // 只计算在前面就行
553
556
  const isInViewport = isFront && cssOffset.every(ratio => ratio < 1 && ratio >= 0);
557
+
554
558
  return Boolean(isInViewport);
555
559
  };
556
560
 
@@ -571,8 +575,15 @@ function instance($$self, $$props, $$invalidate) {
571
575
  };
572
576
 
573
577
  const getFormatedItemLabels = (five$1, labels) => {
578
+ console.log(labels);
579
+
574
580
  // 计算位置 & 可见性
575
581
  const newLabels = labels.map(label => {
582
+ // 不在绑定点位则直接不可见
583
+ if (five$1.state.panoIndex !== label.panoIndex) {
584
+ return Object.assign(Object.assign({}, label), { visible: false });
585
+ }
586
+
576
587
  const cssOffset = getLabelCssOffset(five$1, label);
577
588
  label.name.length * basicWidth;
578
589
  const strokeLength = getStrokeLength(label.modelPosition[1], displayStrategyType);
@@ -625,16 +636,6 @@ function instance($$self, $$props, $$invalidate) {
625
636
  handleCameraUpdate();
626
637
  };
627
638
 
628
- const onFiveModeChange = mode => {
629
- $$invalidate(5, itemsVisible = false);
630
-
631
- five$1.once('initAnimationEnded', (panoIndex, pose, userAction) => {
632
- $$invalidate(2, anchorEnabled = mode === five.Five.Mode.Panorama);
633
- $$invalidate(5, itemsVisible = true);
634
- if (!userAction) return; else onItemLabelUpdate();
635
- });
636
- };
637
-
638
639
  const handleCameraUpdate = debounce(
639
640
  () => {
640
641
  $$invalidate(5, itemsVisible = true);
@@ -692,11 +693,10 @@ function instance($$self, $$props, $$invalidate) {
692
693
  const onIconClick = itemLabel => {
693
694
  if (five$1.state.mode === five.Five.Mode.Panorama) return;
694
695
  const observers = five$1.work.observers;
695
- const fromPositionVector = new Vector3(itemLabel.position[0], itemLabel.position[1], itemLabel.position[2]);
696
+ const fromPositionVector = new Vector3().fromArray(itemLabel.position);
696
697
  const observer = getNearObserverPano(fromPositionVector, observers);
697
698
 
698
699
  if (observer) {
699
- console.log('--has observer--');
700
700
  itemLabel.observerIndex = observer.panoIndex;
701
701
  }
702
702
 
@@ -739,12 +739,12 @@ function instance($$self, $$props, $$invalidate) {
739
739
  onItemLabelUpdate();
740
740
  addResizeListener();
741
741
  five$1.on('cameraUpdate', handleCameraUpdateCallback);
742
- five$1.on('modeChange', onFiveModeChange);
743
- });
742
+ }); // five.on('modeChange', onFiveModeChange)
744
743
 
745
744
  svelte.onDestroy(() => {
746
745
  five$1.off('cameraUpdate', handleCameraUpdateCallback);
747
- five$1.off('modeChange', onFiveModeChange);
746
+
747
+ // five.off('modeChange', onFiveModeChange)
748
748
  window.removeEventListener('resize', onResize, false);
749
749
  });
750
750
 
@@ -758,10 +758,11 @@ function instance($$self, $$props, $$invalidate) {
758
758
  $$self.$$set = $$props => {
759
759
  if ('five' in $$props) $$invalidate(7, five$1 = $$props.five);
760
760
  if ('modelOcclusionEnable' in $$props) $$invalidate(8, modelOcclusionEnable = $$props.modelOcclusionEnable);
761
- if ('itemLabels' in $$props) $$invalidate(9, itemLabels = $$props.itemLabels);
761
+ if ('onlyVisibleInPanorama' in $$props) $$invalidate(9, onlyVisibleInPanorama = $$props.onlyVisibleInPanorama);
762
+ if ('itemLabels' in $$props) $$invalidate(10, itemLabels = $$props.itemLabels);
762
763
  if ('hooks' in $$props) $$invalidate(0, hooks = $$props.hooks);
763
- if ('displayStrategyType' in $$props) $$invalidate(10, displayStrategyType = $$props.displayStrategyType);
764
- if ('maxVisibleDistance' in $$props) $$invalidate(11, maxVisibleDistance = $$props.maxVisibleDistance);
764
+ if ('displayStrategyType' in $$props) $$invalidate(11, displayStrategyType = $$props.displayStrategyType);
765
+ if ('maxVisibleDistance' in $$props) $$invalidate(12, maxVisibleDistance = $$props.maxVisibleDistance);
765
766
  };
766
767
 
767
768
  return [
@@ -774,6 +775,7 @@ function instance($$self, $$props, $$invalidate) {
774
775
  onIconClick,
775
776
  five$1,
776
777
  modelOcclusionEnable,
778
+ onlyVisibleInPanorama,
777
779
  itemLabels,
778
780
  displayStrategyType,
779
781
  maxVisibleDistance,
@@ -794,10 +796,11 @@ class ItemLabelComponent extends internal.SvelteComponent {
794
796
  {
795
797
  five: 7,
796
798
  modelOcclusionEnable: 8,
797
- itemLabels: 9,
799
+ onlyVisibleInPanorama: 9,
800
+ itemLabels: 10,
798
801
  hooks: 0,
799
- displayStrategyType: 10,
800
- maxVisibleDistance: 11
802
+ displayStrategyType: 11,
803
+ maxVisibleDistance: 12
801
804
  },
802
805
  add_css,
803
806
  [-1, -1]
@@ -807,12 +810,12 @@ class ItemLabelComponent extends internal.SvelteComponent {
807
810
 
808
811
  /** @description 转成内部所需数据 */
809
812
  function parseItemLabelPluginData(data) {
810
- return data.item_labels.map(label => (Object.assign({ modelPosition: [label.position[0], label.position[1], label.position[2]], observerIndex: undefined }, label)));
813
+ return data.item_labels.map(label => (Object.assign(Object.assign({}, label), { modelPosition: [label.position[0], label.position[1], label.position[2]], observerIndex: undefined })));
811
814
  }
812
815
 
813
816
  const defaultMaxVisibleDistance = undefined;
814
817
  const Plugin = (five$1, params) => {
815
- var _a, _b, _c;
818
+ var _a, _b, _c, _d;
816
819
  const pluginState = {
817
820
  container: document.createElement('div'),
818
821
  data: null,
@@ -823,8 +826,9 @@ const Plugin = (five$1, params) => {
823
826
  app: undefined,
824
827
  hooks: new five.Subscribe(),
825
828
  modelOcclusionEnable: (_a = params === null || params === void 0 ? void 0 : params.modelOcclusionEnable) !== null && _a !== void 0 ? _a : true,
826
- displayStrategyType: (_b = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _b !== void 0 ? _b : exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.SMALL,
827
- maxVisibleDistance: (_c = params === null || params === void 0 ? void 0 : params.maxVisibleDistance) !== null && _c !== void 0 ? _c : defaultMaxVisibleDistance,
829
+ onlyVisibleInPanorama: (_b = params === null || params === void 0 ? void 0 : params.onlyVisibleInPanorama) !== null && _b !== void 0 ? _b : true,
830
+ displayStrategyType: (_c = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _c !== void 0 ? _c : exports.ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.SMALL,
831
+ maxVisibleDistance: (_d = params === null || params === void 0 ? void 0 : params.maxVisibleDistance) !== null && _d !== void 0 ? _d : defaultMaxVisibleDistance,
828
832
  };
829
833
  pluginState.container.setAttribute('class', 'item-label-plugin-container');
830
834
  pluginState.container.style.cssText = `
@@ -861,6 +865,7 @@ const Plugin = (five$1, params) => {
861
865
  return true;
862
866
  };
863
867
  const dispose = () => {
868
+ removeListener4Five();
864
869
  pluginState.container.remove();
865
870
  };
866
871
  const render = () => {
@@ -880,6 +885,7 @@ const Plugin = (five$1, params) => {
880
885
  props: {
881
886
  five: five$1,
882
887
  modelOcclusionEnable: pluginState.modelOcclusionEnable,
888
+ onlyVisibleInPanorama: pluginState.onlyVisibleInPanorama,
883
889
  itemLabels: pluginState.itemLabels,
884
890
  wrapper: pluginState.wrapper,
885
891
  hooks: pluginState.hooks,
@@ -897,9 +903,27 @@ const Plugin = (five$1, params) => {
897
903
  };
898
904
  // 添加 five 监听
899
905
  const addListener4Five = () => {
900
- // five.on('modeChange', onFiveModeChange)
906
+ five$1.on('modeChange', onFiveModeChange);
901
907
  five$1.once('dispose', dispose);
902
908
  };
909
+ // 取消 five 监听
910
+ const removeListener4Five = () => {
911
+ five$1.off('modeChange', onFiveModeChange);
912
+ };
913
+ const onFiveModeChange = (mode) => {
914
+ // if (!pluginState.enabled) return
915
+ if (mode !== five.Five.Mode.Panorama) {
916
+ pluginState.fiveModeEnabled = false;
917
+ disable();
918
+ return;
919
+ }
920
+ // pluginState.fiveModeEnabled = false
921
+ // render()
922
+ five$1.once('initAnimationEnded', () => {
923
+ pluginState.fiveModeEnabled = true;
924
+ enable();
925
+ });
926
+ };
903
927
  addListener4Five();
904
928
  return {
905
929
  appendTo,
@@ -10,10 +10,12 @@ export declare enum ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE {
10
10
  export interface ItemLabelPluginParametersType {
11
11
  maxVisibleDistance?: number;
12
12
  modelOcclusionEnable?: boolean;
13
+ onlyVisibleInPanorama?: boolean;
13
14
  displayStrategyType?: Partial<ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE>;
14
15
  }
15
16
  export interface ItemLabelPluginData {
16
17
  item_labels: Readonly<{
18
+ panoIndex: number;
17
19
  id: string;
18
20
  code: string;
19
21
  name: string;
@@ -24,6 +26,7 @@ export interface ItemLabelPluginData {
24
26
  }>[];
25
27
  }
26
28
  export interface ItemLabel {
29
+ panoIndex: number;
27
30
  id: string;
28
31
  code: string;
29
32
  name: string;
@@ -54,6 +57,7 @@ export interface ItemLabelPluginState {
54
57
  app?: ItemLabelComponent | undefined;
55
58
  hooks: Subscribe<PluginEvent>;
56
59
  modelOcclusionEnable: boolean;
60
+ onlyVisibleInPanorama: boolean;
57
61
  displayStrategyType: Partial<ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE>;
58
62
  maxVisibleDistance: number | undefined;
59
63
  }
package/dist/index.d.ts CHANGED
@@ -14,3 +14,4 @@ export * from './PanoSpatialTagPlugin';
14
14
  export * from './ModelItemLabelPlugin';
15
15
  export * from './ModelTVVideoPlugin';
16
16
  export * from './ItemLabelPlugin';
17
+ export declare const DnalogelVersion = "2.0.0-alpha.38";
package/dist/index.es.js CHANGED
@@ -15573,18 +15573,18 @@ function add_css(target) {
15573
15573
 
15574
15574
  function get_each_context(ctx, list, i) {
15575
15575
  const child_ctx = ctx.slice();
15576
- child_ctx[30] = list[i];
15576
+ child_ctx[31] = list[i];
15577
15577
  return child_ctx;
15578
15578
  }
15579
15579
 
15580
- // (229:2) {#if itemLabelItem.visible}
15580
+ // (235:2) {#if itemLabelItem.visible}
15581
15581
  function create_if_block(ctx) {
15582
15582
  let itemlabelitem;
15583
15583
  let current;
15584
15584
 
15585
15585
  itemlabelitem = new ItemLabelItem({
15586
15586
  props: {
15587
- itemLabel: /*itemLabelItem*/ ctx[30],
15587
+ itemLabel: /*itemLabelItem*/ ctx[31],
15588
15588
  hooks: /*hooks*/ ctx[0],
15589
15589
  anchorEnabled: /*anchorEnabled*/ ctx[2],
15590
15590
  onIconClick: /*onIconClick*/ ctx[6]
@@ -15601,7 +15601,7 @@ function create_if_block(ctx) {
15601
15601
  },
15602
15602
  p(ctx, dirty) {
15603
15603
  const itemlabelitem_changes = {};
15604
- if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[30];
15604
+ if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[31];
15605
15605
  if (dirty[0] & /*hooks*/ 1) itemlabelitem_changes.hooks = /*hooks*/ ctx[0];
15606
15606
  if (dirty[0] & /*anchorEnabled*/ 4) itemlabelitem_changes.anchorEnabled = /*anchorEnabled*/ ctx[2];
15607
15607
  itemlabelitem.$set(itemlabelitem_changes);
@@ -15621,12 +15621,12 @@ function create_if_block(ctx) {
15621
15621
  };
15622
15622
  }
15623
15623
 
15624
- // (228:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
15624
+ // (234:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
15625
15625
  function create_each_block(key_1, ctx) {
15626
15626
  let first;
15627
15627
  let if_block_anchor;
15628
15628
  let current;
15629
- let if_block = /*itemLabelItem*/ ctx[30].visible && create_if_block(ctx);
15629
+ let if_block = /*itemLabelItem*/ ctx[31].visible && create_if_block(ctx);
15630
15630
 
15631
15631
  return {
15632
15632
  key: key_1,
@@ -15646,7 +15646,7 @@ function create_each_block(key_1, ctx) {
15646
15646
  p(new_ctx, dirty) {
15647
15647
  ctx = new_ctx;
15648
15648
 
15649
- if (/*itemLabelItem*/ ctx[30].visible) {
15649
+ if (/*itemLabelItem*/ ctx[31].visible) {
15650
15650
  if (if_block) {
15651
15651
  if_block.p(ctx, dirty);
15652
15652
 
@@ -15693,7 +15693,7 @@ function create_fragment(ctx) {
15693
15693
  let div_resize_listener;
15694
15694
  let current;
15695
15695
  let each_value = /*renderItemLabels*/ ctx[1];
15696
- const get_key = ctx => /*itemLabelItem*/ ctx[30].id;
15696
+ const get_key = ctx => /*itemLabelItem*/ ctx[31].id;
15697
15697
 
15698
15698
  for (let i = 0; i < each_value.length; i += 1) {
15699
15699
  let child_ctx = get_each_context(ctx, each_value, i);
@@ -15710,7 +15710,7 @@ function create_fragment(ctx) {
15710
15710
  }
15711
15711
 
15712
15712
  attr(div, "class", "item-labels-container svelte-gk8s47");
15713
- add_render_callback(() => /*div_elementresize_handler*/ ctx[12].call(div));
15713
+ add_render_callback(() => /*div_elementresize_handler*/ ctx[13].call(div));
15714
15714
  set_style(div, "opacity", /*itemsVisible*/ ctx[5] ? 1 : 0, false);
15715
15715
  },
15716
15716
  m(target, anchor) {
@@ -15720,7 +15720,7 @@ function create_fragment(ctx) {
15720
15720
  each_blocks[i].m(div, null);
15721
15721
  }
15722
15722
 
15723
- div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[12].bind(div));
15723
+ div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[13].bind(div));
15724
15724
  current = true;
15725
15725
  },
15726
15726
  p(ctx, dirty) {
@@ -15768,6 +15768,7 @@ function instance($$self, $$props, $$invalidate) {
15768
15768
  const { Raycaster, Vector3 } = THREE;
15769
15769
  let { five } = $$props;
15770
15770
  let { modelOcclusionEnable } = $$props;
15771
+ let { onlyVisibleInPanorama } = $$props;
15771
15772
  let { itemLabels } = $$props;
15772
15773
  let { hooks } = $$props;
15773
15774
  let { displayStrategyType } = $$props;
@@ -15819,7 +15820,10 @@ function instance($$self, $$props, $$invalidate) {
15819
15820
  const ratioFromTop = (2 - (offsetYFromCenter + 1)) / 2;
15820
15821
  const isFront = Math.abs(offsetZFromCenter) < 1;
15821
15822
  const cssOffset = [ratioFromLeft, ratioFromTop];
15823
+
15824
+ // 只计算在前面就行
15822
15825
  const isInViewport = isFront && cssOffset.every(ratio => ratio < 1 && ratio >= 0);
15826
+
15823
15827
  return Boolean(isInViewport);
15824
15828
  };
15825
15829
 
@@ -15840,8 +15844,15 @@ function instance($$self, $$props, $$invalidate) {
15840
15844
  };
15841
15845
 
15842
15846
  const getFormatedItemLabels = (five, labels) => {
15847
+ console.log(labels);
15848
+
15843
15849
  // 计算位置 & 可见性
15844
15850
  const newLabels = labels.map(label => {
15851
+ // 不在绑定点位则直接不可见
15852
+ if (five.state.panoIndex !== label.panoIndex) {
15853
+ return Object.assign(Object.assign({}, label), { visible: false });
15854
+ }
15855
+
15845
15856
  const cssOffset = getLabelCssOffset(five, label);
15846
15857
  label.name.length * basicWidth;
15847
15858
  const strokeLength = getStrokeLength(label.modelPosition[1], displayStrategyType);
@@ -15894,16 +15905,6 @@ function instance($$self, $$props, $$invalidate) {
15894
15905
  handleCameraUpdate();
15895
15906
  };
15896
15907
 
15897
- const onFiveModeChange = mode => {
15898
- $$invalidate(5, itemsVisible = false);
15899
-
15900
- five.once('initAnimationEnded', (panoIndex, pose, userAction) => {
15901
- $$invalidate(2, anchorEnabled = mode === Five.Mode.Panorama);
15902
- $$invalidate(5, itemsVisible = true);
15903
- if (!userAction) return; else onItemLabelUpdate();
15904
- });
15905
- };
15906
-
15907
15908
  const handleCameraUpdate = debounce(
15908
15909
  () => {
15909
15910
  $$invalidate(5, itemsVisible = true);
@@ -15961,11 +15962,10 @@ function instance($$self, $$props, $$invalidate) {
15961
15962
  const onIconClick = itemLabel => {
15962
15963
  if (five.state.mode === Five.Mode.Panorama) return;
15963
15964
  const observers = five.work.observers;
15964
- const fromPositionVector = new Vector3(itemLabel.position[0], itemLabel.position[1], itemLabel.position[2]);
15965
+ const fromPositionVector = new Vector3().fromArray(itemLabel.position);
15965
15966
  const observer = getNearObserverPano(fromPositionVector, observers);
15966
15967
 
15967
15968
  if (observer) {
15968
- console.log('--has observer--');
15969
15969
  itemLabel.observerIndex = observer.panoIndex;
15970
15970
  }
15971
15971
 
@@ -16008,12 +16008,12 @@ function instance($$self, $$props, $$invalidate) {
16008
16008
  onItemLabelUpdate();
16009
16009
  addResizeListener();
16010
16010
  five.on('cameraUpdate', handleCameraUpdateCallback);
16011
- five.on('modeChange', onFiveModeChange);
16012
- });
16011
+ }); // five.on('modeChange', onFiveModeChange)
16013
16012
 
16014
16013
  onDestroy(() => {
16015
16014
  five.off('cameraUpdate', handleCameraUpdateCallback);
16016
- five.off('modeChange', onFiveModeChange);
16015
+
16016
+ // five.off('modeChange', onFiveModeChange)
16017
16017
  window.removeEventListener('resize', onResize, false);
16018
16018
  });
16019
16019
 
@@ -16027,10 +16027,11 @@ function instance($$self, $$props, $$invalidate) {
16027
16027
  $$self.$$set = $$props => {
16028
16028
  if ('five' in $$props) $$invalidate(7, five = $$props.five);
16029
16029
  if ('modelOcclusionEnable' in $$props) $$invalidate(8, modelOcclusionEnable = $$props.modelOcclusionEnable);
16030
- if ('itemLabels' in $$props) $$invalidate(9, itemLabels = $$props.itemLabels);
16030
+ if ('onlyVisibleInPanorama' in $$props) $$invalidate(9, onlyVisibleInPanorama = $$props.onlyVisibleInPanorama);
16031
+ if ('itemLabels' in $$props) $$invalidate(10, itemLabels = $$props.itemLabels);
16031
16032
  if ('hooks' in $$props) $$invalidate(0, hooks = $$props.hooks);
16032
- if ('displayStrategyType' in $$props) $$invalidate(10, displayStrategyType = $$props.displayStrategyType);
16033
- if ('maxVisibleDistance' in $$props) $$invalidate(11, maxVisibleDistance = $$props.maxVisibleDistance);
16033
+ if ('displayStrategyType' in $$props) $$invalidate(11, displayStrategyType = $$props.displayStrategyType);
16034
+ if ('maxVisibleDistance' in $$props) $$invalidate(12, maxVisibleDistance = $$props.maxVisibleDistance);
16034
16035
  };
16035
16036
 
16036
16037
  return [
@@ -16043,6 +16044,7 @@ function instance($$self, $$props, $$invalidate) {
16043
16044
  onIconClick,
16044
16045
  five,
16045
16046
  modelOcclusionEnable,
16047
+ onlyVisibleInPanorama,
16046
16048
  itemLabels,
16047
16049
  displayStrategyType,
16048
16050
  maxVisibleDistance,
@@ -16063,10 +16065,11 @@ class ItemLabelComponent extends SvelteComponent {
16063
16065
  {
16064
16066
  five: 7,
16065
16067
  modelOcclusionEnable: 8,
16066
- itemLabels: 9,
16068
+ onlyVisibleInPanorama: 9,
16069
+ itemLabels: 10,
16067
16070
  hooks: 0,
16068
- displayStrategyType: 10,
16069
- maxVisibleDistance: 11
16071
+ displayStrategyType: 11,
16072
+ maxVisibleDistance: 12
16070
16073
  },
16071
16074
  add_css,
16072
16075
  [-1, -1]
@@ -16076,12 +16079,12 @@ class ItemLabelComponent extends SvelteComponent {
16076
16079
 
16077
16080
  /** @description 转成内部所需数据 */
16078
16081
  function parseItemLabelPluginData(data) {
16079
- return data.item_labels.map(label => (Object.assign({ modelPosition: [label.position[0], label.position[1], label.position[2]], observerIndex: undefined }, label)));
16082
+ return data.item_labels.map(label => (Object.assign(Object.assign({}, label), { modelPosition: [label.position[0], label.position[1], label.position[2]], observerIndex: undefined })));
16080
16083
  }
16081
16084
 
16082
16085
  const defaultMaxVisibleDistance = undefined;
16083
16086
  const Plugin = (five, params) => {
16084
- var _a, _b, _c;
16087
+ var _a, _b, _c, _d;
16085
16088
  const pluginState = {
16086
16089
  container: document.createElement('div'),
16087
16090
  data: null,
@@ -16092,8 +16095,9 @@ const Plugin = (five, params) => {
16092
16095
  app: undefined,
16093
16096
  hooks: new Subscribe(),
16094
16097
  modelOcclusionEnable: (_a = params === null || params === void 0 ? void 0 : params.modelOcclusionEnable) !== null && _a !== void 0 ? _a : true,
16095
- displayStrategyType: (_b = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _b !== void 0 ? _b : ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.SMALL,
16096
- maxVisibleDistance: (_c = params === null || params === void 0 ? void 0 : params.maxVisibleDistance) !== null && _c !== void 0 ? _c : defaultMaxVisibleDistance,
16098
+ onlyVisibleInPanorama: (_b = params === null || params === void 0 ? void 0 : params.onlyVisibleInPanorama) !== null && _b !== void 0 ? _b : true,
16099
+ displayStrategyType: (_c = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _c !== void 0 ? _c : ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.SMALL,
16100
+ maxVisibleDistance: (_d = params === null || params === void 0 ? void 0 : params.maxVisibleDistance) !== null && _d !== void 0 ? _d : defaultMaxVisibleDistance,
16097
16101
  };
16098
16102
  pluginState.container.setAttribute('class', 'item-label-plugin-container');
16099
16103
  pluginState.container.style.cssText = `
@@ -16130,6 +16134,7 @@ const Plugin = (five, params) => {
16130
16134
  return true;
16131
16135
  };
16132
16136
  const dispose = () => {
16137
+ removeListener4Five();
16133
16138
  pluginState.container.remove();
16134
16139
  };
16135
16140
  const render = () => {
@@ -16149,6 +16154,7 @@ const Plugin = (five, params) => {
16149
16154
  props: {
16150
16155
  five: five,
16151
16156
  modelOcclusionEnable: pluginState.modelOcclusionEnable,
16157
+ onlyVisibleInPanorama: pluginState.onlyVisibleInPanorama,
16152
16158
  itemLabels: pluginState.itemLabels,
16153
16159
  wrapper: pluginState.wrapper,
16154
16160
  hooks: pluginState.hooks,
@@ -16166,9 +16172,27 @@ const Plugin = (five, params) => {
16166
16172
  };
16167
16173
  // 添加 five 监听
16168
16174
  const addListener4Five = () => {
16169
- // five.on('modeChange', onFiveModeChange)
16175
+ five.on('modeChange', onFiveModeChange);
16170
16176
  five.once('dispose', dispose);
16171
16177
  };
16178
+ // 取消 five 监听
16179
+ const removeListener4Five = () => {
16180
+ five.off('modeChange', onFiveModeChange);
16181
+ };
16182
+ const onFiveModeChange = (mode) => {
16183
+ // if (!pluginState.enabled) return
16184
+ if (mode !== Five.Mode.Panorama) {
16185
+ pluginState.fiveModeEnabled = false;
16186
+ disable();
16187
+ return;
16188
+ }
16189
+ // pluginState.fiveModeEnabled = false
16190
+ // render()
16191
+ five.once('initAnimationEnded', () => {
16192
+ pluginState.fiveModeEnabled = true;
16193
+ enable();
16194
+ });
16195
+ };
16172
16196
  addListener4Five();
16173
16197
  return {
16174
16198
  appendTo,
@@ -16185,4 +16209,6 @@ const itemLabelPluginServerParams = {
16185
16209
  version: 0,
16186
16210
  };
16187
16211
 
16188
- export { CSS3DRenderPlugin, CameraMovementEffect, CameraMovementPlugin, DIRECTION, DISPLAY_STRATEGY_TYPE, FLOOR_PLAN_ATTACHED_TO, FLOOR_TYPE_MAP, ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE, Plugin as ItemLabelPlugin, Magnifier, ModelChassisCompassPlugin, ModelEntryDoorGuidePlugin, ModelFloorplanPlugin, ModelItemLabelPlugin, ModelRoomLabelPlugin, ModelTVVideoPlugin, ModelViewPlugin, PanoCompassPlugin, PanoCursorRaycasterPlugin, PanoFloorplanRadarPlugin, PanoMeasurePlugin, PanoRulerPlugin, PanoRulerProPlugin, PanoSpatialTagPlugin, ROOM_FETILE_TYPE_MAP, ROOM_TYPE_MAP, Rotation, TopviewFloorplanPlugin, itemLabelPluginServerParams, modelItemLabelPluginServerParams, modelRoomLabelPluginServerParams, panoCompassPluginServerParams };
16212
+ const DnalogelVersion = '2.0.0-alpha.38';
16213
+
16214
+ export { CSS3DRenderPlugin, CameraMovementEffect, CameraMovementPlugin, DIRECTION, DISPLAY_STRATEGY_TYPE, DnalogelVersion, FLOOR_PLAN_ATTACHED_TO, FLOOR_TYPE_MAP, ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE, Plugin as ItemLabelPlugin, Magnifier, ModelChassisCompassPlugin, ModelEntryDoorGuidePlugin, ModelFloorplanPlugin, ModelItemLabelPlugin, ModelRoomLabelPlugin, ModelTVVideoPlugin, ModelViewPlugin, PanoCompassPlugin, PanoCursorRaycasterPlugin, PanoFloorplanRadarPlugin, PanoMeasurePlugin, PanoRulerPlugin, PanoRulerProPlugin, PanoSpatialTagPlugin, ROOM_FETILE_TYPE_MAP, ROOM_TYPE_MAP, Rotation, TopviewFloorplanPlugin, itemLabelPluginServerParams, modelItemLabelPluginServerParams, modelRoomLabelPluginServerParams, panoCompassPluginServerParams };