@realsee/dnalogel 2.0.0-alpha.30 → 2.0.0-alpha.31-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 (91) hide show
  1. package/dist/ItemLabelPlugin/index.js +61 -42
  2. package/dist/index.es.js +58 -39
  3. package/dist/index.js +61 -42
  4. package/dist/index.umd.js +61 -42
  5. package/docs/classes/Magnifier.html +4 -4
  6. package/docs/classes/ModelRoomLabelController.html +4 -4
  7. package/docs/classes/PanoFloorplanRadarPluginController.html +2 -2
  8. package/docs/enums/CameraMovementEffect.html +2 -2
  9. package/docs/enums/DIRECTION.html +1 -1
  10. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
  11. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  12. package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
  13. package/docs/enums/ModelFloorplanErrorType.html +1 -1
  14. package/docs/enums/Rotation.html +2 -2
  15. package/docs/index.html +1 -1
  16. package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
  17. package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
  18. package/docs/interfaces/FloorplanBounding.html +4 -4
  19. package/docs/interfaces/FloorplanData.html +2 -2
  20. package/docs/interfaces/FloorplanEntrance.html +7 -7
  21. package/docs/interfaces/FloorplanExtraObject.html +3 -3
  22. package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
  23. package/docs/interfaces/FloorplanFloorData.html +2 -2
  24. package/docs/interfaces/FloorplanImagePosition.html +2 -2
  25. package/docs/interfaces/FloorplanObserver.html +2 -2
  26. package/docs/interfaces/FloorplanOutlineItem.html +2 -2
  27. package/docs/interfaces/FloorplanPosition.html +2 -2
  28. package/docs/interfaces/FloorplanRoomItem.html +6 -6
  29. package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
  30. package/docs/interfaces/FloorplanServerBounding.html +4 -4
  31. package/docs/interfaces/FloorplanServerComputedData.html +1 -1
  32. package/docs/interfaces/FloorplanServerData.html +2 -2
  33. package/docs/interfaces/FloorplanServerEntrance.html +7 -7
  34. package/docs/interfaces/FloorplanServerFloorData.html +2 -2
  35. package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
  36. package/docs/interfaces/FloorplanServerObserver.html +2 -2
  37. package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
  38. package/docs/interfaces/FloorplanServerPosition.html +2 -2
  39. package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
  40. package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
  41. package/docs/interfaces/ItemLabelPluginData.html +1 -1
  42. package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
  43. package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
  44. package/docs/interfaces/LineJson.html +1 -1
  45. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  46. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  47. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  48. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  49. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  50. package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
  51. package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
  52. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  53. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  54. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  55. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  56. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  57. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  58. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  59. package/docs/interfaces/ModelViewPluginExportType.html +1 -1
  60. package/docs/interfaces/OpenParameter.html +2 -2
  61. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  62. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  63. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  64. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
  65. package/docs/interfaces/PanoFloorplanRadarPluginControllerParameter.html +1 -1
  66. package/docs/interfaces/PanoMeasureParameterType.html +1 -1
  67. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  68. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  69. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  70. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
  71. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
  72. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  73. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
  74. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  75. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
  76. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  77. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
  78. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
  79. package/docs/interfaces/Point.html +1 -1
  80. package/docs/interfaces/PointJson.html +1 -1
  81. package/docs/interfaces/Room.html +1 -1
  82. package/docs/interfaces/RoomInfo.html +1 -1
  83. package/docs/interfaces/RoomLabel.html +7 -7
  84. package/docs/interfaces/RoomRules.html +1 -1
  85. package/docs/interfaces/Rooms.html +1 -1
  86. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +9 -9
  87. package/docs/modules.html +20 -20
  88. package/libs/ItemLabelPlugin/ItemLabelComponent.js +51 -32
  89. package/libs/ItemLabelPlugin/ItemLabelItem.js +5 -6
  90. package/libs/ItemLabelPlugin/utils/isImpacted.js +2 -1
  91. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -13793,7 +13793,7 @@ function create_if_block$1(ctx) {
13793
13793
  div1 = internal.element("div");
13794
13794
  div0 = internal.element("div");
13795
13795
  internal.attr(div0, "class", "icon svelte-4rvov0");
13796
- internal.attr(div0, "style", div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`);
13796
+ internal.attr(div0, "style", div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon})`);
13797
13797
  internal.attr(div1, "class", "icon-wrap svelte-4rvov0");
13798
13798
  },
13799
13799
  m(target, anchor) {
@@ -13806,7 +13806,7 @@ function create_if_block$1(ctx) {
13806
13806
  }
13807
13807
  },
13808
13808
  p(ctx, dirty) {
13809
- if (dirty & /*itemLabel*/ 1 && div0_style_value !== (div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`)) {
13809
+ if (dirty & /*itemLabel*/ 1 && div0_style_value !== (div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon})`)) {
13810
13810
  internal.attr(div0, "style", div0_style_value);
13811
13811
  }
13812
13812
  },
@@ -13824,7 +13824,7 @@ function create_fragment$1(ctx) {
13824
13824
  let t0;
13825
13825
  let div0;
13826
13826
  let span0;
13827
- let t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "";
13827
+ let t1_value = (/*itemLabel*/ ctx[0].code || /*itemLabel*/ ctx[0].id) + "";
13828
13828
  let t1;
13829
13829
  let t2;
13830
13830
  let span1;
@@ -13896,7 +13896,7 @@ function create_fragment$1(ctx) {
13896
13896
  if_block = null;
13897
13897
  }
13898
13898
 
13899
- if (dirty & /*itemLabel*/ 1 && t1_value !== (t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "")) internal.set_data(t1, t1_value);
13899
+ if (dirty & /*itemLabel*/ 1 && t1_value !== (t1_value = (/*itemLabel*/ ctx[0].code || /*itemLabel*/ ctx[0].id) + "")) internal.set_data(t1, t1_value);
13900
13900
  if (dirty & /*itemLabel*/ 1 && t3_value !== (t3_value = /*itemLabel*/ ctx[0].name + "")) internal.set_data(t3, t3_value);
13901
13901
 
13902
13902
  if (dirty & /*itemLabel*/ 1) {
@@ -13934,14 +13934,13 @@ function create_fragment$1(ctx) {
13934
13934
  };
13935
13935
  }
13936
13936
 
13937
- const defaultIcon = '//vrlab-public.ljcdn.com/common/file/web/c8591aaa-e62b-4e31-8fed-671483ace37f.svg\n';
13938
-
13939
13937
  function instance$1($$self, $$props, $$invalidate) {
13940
13938
  let { itemLabel } = $$props;
13941
13939
  let { hooks } = $$props;
13942
13940
  let { anchorEnabled } = $$props;
13943
13941
  let { onIconClick } = $$props;
13944
13942
 
13943
+ // const defaultIcon = '//vrlab-public.ljcdn.com/common/file/web/c8591aaa-e62b-4e31-8fed-671483ace37f.svg\n'
13945
13944
  function onClick() {
13946
13945
  hooks.emit('onLabelClick', itemLabel);
13947
13946
  }
@@ -13988,7 +13987,8 @@ const isImpacted = (five, sourceVector, targetVector, distance) => {
13988
13987
  const raycaster = new Raycaster();
13989
13988
  raycaster.set(targetVector, direction);
13990
13989
  const [intersection] = five.model.intersectRaycaster(raycaster);
13991
- return intersection && distance <= intersection.distance + 0.1;
13990
+ return intersection && intersection.distance + 0.01 < distance;
13991
+ // return intersection && distance <= intersection.distance + 0.1
13992
13992
  };
13993
13993
 
13994
13994
  /**
@@ -14024,18 +14024,18 @@ function add_css(target) {
14024
14024
 
14025
14025
  function get_each_context(ctx, list, i) {
14026
14026
  const child_ctx = ctx.slice();
14027
- child_ctx[31] = list[i];
14027
+ child_ctx[32] = list[i];
14028
14028
  return child_ctx;
14029
14029
  }
14030
14030
 
14031
- // (229:2) {#if itemLabelItem.visible}
14031
+ // (248:2) {#if itemLabelItem.visible}
14032
14032
  function create_if_block(ctx) {
14033
14033
  let itemlabelitem;
14034
14034
  let current;
14035
14035
 
14036
14036
  itemlabelitem = new ItemLabelItem({
14037
14037
  props: {
14038
- itemLabel: /*itemLabelItem*/ ctx[31],
14038
+ itemLabel: /*itemLabelItem*/ ctx[32],
14039
14039
  hooks: /*hooks*/ ctx[0],
14040
14040
  anchorEnabled: /*anchorEnabled*/ ctx[2],
14041
14041
  onIconClick: /*onIconClick*/ ctx[6]
@@ -14052,7 +14052,7 @@ function create_if_block(ctx) {
14052
14052
  },
14053
14053
  p(ctx, dirty) {
14054
14054
  const itemlabelitem_changes = {};
14055
- if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[31];
14055
+ if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[32];
14056
14056
  if (dirty[0] & /*hooks*/ 1) itemlabelitem_changes.hooks = /*hooks*/ ctx[0];
14057
14057
  if (dirty[0] & /*anchorEnabled*/ 4) itemlabelitem_changes.anchorEnabled = /*anchorEnabled*/ ctx[2];
14058
14058
  itemlabelitem.$set(itemlabelitem_changes);
@@ -14072,12 +14072,12 @@ function create_if_block(ctx) {
14072
14072
  };
14073
14073
  }
14074
14074
 
14075
- // (228:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
14075
+ // (247:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
14076
14076
  function create_each_block(key_1, ctx) {
14077
14077
  let first;
14078
14078
  let if_block_anchor;
14079
14079
  let current;
14080
- let if_block = /*itemLabelItem*/ ctx[31].visible && create_if_block(ctx);
14080
+ let if_block = /*itemLabelItem*/ ctx[32].visible && create_if_block(ctx);
14081
14081
 
14082
14082
  return {
14083
14083
  key: key_1,
@@ -14097,7 +14097,7 @@ function create_each_block(key_1, ctx) {
14097
14097
  p(new_ctx, dirty) {
14098
14098
  ctx = new_ctx;
14099
14099
 
14100
- if (/*itemLabelItem*/ ctx[31].visible) {
14100
+ if (/*itemLabelItem*/ ctx[32].visible) {
14101
14101
  if (if_block) {
14102
14102
  if_block.p(ctx, dirty);
14103
14103
 
@@ -14144,7 +14144,7 @@ function create_fragment(ctx) {
14144
14144
  let div_resize_listener;
14145
14145
  let current;
14146
14146
  let each_value = /*renderItemLabels*/ ctx[1];
14147
- const get_key = ctx => /*itemLabelItem*/ ctx[31].id;
14147
+ const get_key = ctx => /*itemLabelItem*/ ctx[32].id;
14148
14148
 
14149
14149
  for (let i = 0; i < each_value.length; i += 1) {
14150
14150
  let child_ctx = get_each_context(ctx, each_value, i);
@@ -14246,7 +14246,7 @@ function instance($$self, $$props, $$invalidate) {
14246
14246
  * 1、当前楼层(假设先不考虑多楼层)
14247
14247
  * 2、模型未被遮挡(一个 box 有没有被遮挡的计算? TODO)
14248
14248
  * */
14249
- const getLabelVisible = (five$1, itemLabel) => {
14249
+ const judgeImpacted = (five$1, itemLabel) => {
14250
14250
  // 虚拟 VR 仅有一层,不考虑楼层信息
14251
14251
  const cameraPosition = five$1.camera.position.clone();
14252
14252
 
@@ -14267,6 +14267,17 @@ function instance($$self, $$props, $$invalidate) {
14267
14267
  // const [intersection] = five.model.intersectRaycaster(raycaster)
14268
14268
  // return !(intersection && intersection.distance + 1 < vectorDistance);
14269
14269
 
14270
+ const judgeInViewport = modelPoint => {
14271
+ const { camera, model } = five$1;
14272
+ const { x: offsetXFromCenter, y: offsetYFromCenter, z: offsetZFromCenter } = modelPoint.clone().project(camera);
14273
+ const ratioFromLeft = (offsetXFromCenter + 1) / 2;
14274
+ const ratioFromTop = (2 - (offsetYFromCenter + 1)) / 2;
14275
+ const isFront = Math.abs(offsetZFromCenter) < 1;
14276
+ const cssOffset = [ratioFromLeft, ratioFromTop];
14277
+ const isInViewport = isFront && cssOffset.every(ratio => ratio < 1 && ratio >= 0);
14278
+ return Boolean(isInViewport);
14279
+ };
14280
+
14270
14281
  // cssOffset 获取
14271
14282
  const getLabelCssOffset = (five, itemLabel) => {
14272
14283
  const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
@@ -14283,19 +14294,26 @@ function instance($$self, $$props, $$invalidate) {
14283
14294
  return [xOffset, yOffset];
14284
14295
  };
14285
14296
 
14286
- const getFormatedItemLabels = (five, labels) => {
14297
+ const getFormatedItemLabels = (five$1, labels) => {
14287
14298
  // 计算位置 & 可见性
14288
14299
  const newLabels = labels.map(label => {
14289
- const cssOffset = getLabelCssOffset(five, label);
14300
+ const cssOffset = getLabelCssOffset(five$1, label);
14290
14301
  label.name.length * basicWidth;
14291
14302
  const strokeLength = getStrokeLength(label.modelPosition[1], displayStrategyType);
14292
14303
 
14293
14304
  // 是否加入碰撞检测
14294
- const naturalVisible = modelOcclusionEnable
14295
- ? getLabelVisible(five, label)
14296
- : label.visible;
14305
+ // 配置加入碰撞检测,则判断碰撞检测
14306
+ // 在可见范围内, 仅在 Panorama 模态计算
14307
+ const isInViewport = five$1.currentMode === five.Five.Mode.Panorama
14308
+ ? judgeInViewport(new Vector3(label.position[0], label.position[1], label.position[2]))
14309
+ : true;
14310
+
14311
+ // 碰撞
14312
+ const isBlocked = modelOcclusionEnable
14313
+ ? judgeImpacted(five$1, label)
14314
+ : false;
14297
14315
 
14298
- const visible = naturalVisible;
14316
+ const visible = isInViewport && !isBlocked;
14299
14317
 
14300
14318
  // 关掉重叠计算
14301
14319
  // const visible = naturalVisible && !isOverlap([cssOffset[0], cssOffset[1] + strokeLength], curLabelWidth)
@@ -14311,7 +14329,7 @@ function instance($$self, $$props, $$invalidate) {
14311
14329
 
14312
14330
  const sortedItemLabelItems = newLabels.filter(({ visible }) => visible).map(label => ({
14313
14331
  itemLabelItem: label,
14314
- distance: new Vector3(label.modelPosition[0], label.modelPosition[1], label.modelPosition[2]).clone().distanceTo(five.camera.position)
14332
+ distance: new Vector3(label.modelPosition[0], label.modelPosition[1], label.modelPosition[2]).clone().distanceTo(five$1.camera.position)
14315
14333
  })).sort((a, b) => a.distance - b.distance);
14316
14334
 
14317
14335
  return newLabels.map(label => {
@@ -14326,24 +14344,11 @@ function instance($$self, $$props, $$invalidate) {
14326
14344
  $$invalidate(1, renderItemLabels = getFormatedItemLabels(five$1, renderItemLabels));
14327
14345
  };
14328
14346
 
14329
- svelte.beforeUpdate(() => {
14330
- addDataUpdateListener();
14331
- });
14332
-
14333
14347
  const handleCameraUpdateCallback = () => {
14334
14348
  $$invalidate(5, itemsVisible = false);
14335
14349
  handleCameraUpdate();
14336
14350
  };
14337
14351
 
14338
- svelte.onMount(() => {
14339
- $$invalidate(1, renderItemLabels = transform2RenderData(itemLabels));
14340
- curItemLabels = itemLabels;
14341
- onItemLabelUpdate();
14342
- addResizeListener();
14343
- five$1.on('cameraUpdate', handleCameraUpdateCallback);
14344
- five$1.on('modeChange', onFiveModeChange);
14345
- });
14346
-
14347
14352
  const onFiveModeChange = mode => {
14348
14353
  $$invalidate(5, itemsVisible = false);
14349
14354
 
@@ -14391,12 +14396,6 @@ function instance($$self, $$props, $$invalidate) {
14391
14396
  }
14392
14397
  });
14393
14398
 
14394
- svelte.onDestroy(() => {
14395
- five$1.off('cameraUpdate', handleCameraUpdateCallback);
14396
- five$1.off('modeChange', onFiveModeChange);
14397
- resizeObserver.unobserve(wrapper);
14398
- });
14399
-
14400
14399
  const getNearObserverPano = (fromPositionVector, observers) => {
14401
14400
  let candidates = [];
14402
14401
 
@@ -14434,6 +14433,7 @@ function instance($$self, $$props, $$invalidate) {
14434
14433
  const observer = getNearObserverPano(fromPositionVector, observers);
14435
14434
 
14436
14435
  if (observer) {
14436
+ console.log('--has observer--');
14437
14437
  itemLabel.observerIndex = observer.panoIndex;
14438
14438
  }
14439
14439
 
@@ -14466,6 +14466,25 @@ function instance($$self, $$props, $$invalidate) {
14466
14466
  }
14467
14467
  };
14468
14468
 
14469
+ svelte.beforeUpdate(() => {
14470
+ addDataUpdateListener();
14471
+ });
14472
+
14473
+ svelte.onMount(() => {
14474
+ $$invalidate(1, renderItemLabels = transform2RenderData(itemLabels));
14475
+ curItemLabels = itemLabels;
14476
+ onItemLabelUpdate();
14477
+ addResizeListener();
14478
+ five$1.on('cameraUpdate', handleCameraUpdateCallback);
14479
+ five$1.on('modeChange', onFiveModeChange);
14480
+ });
14481
+
14482
+ svelte.onDestroy(() => {
14483
+ five$1.off('cameraUpdate', handleCameraUpdateCallback);
14484
+ five$1.off('modeChange', onFiveModeChange);
14485
+ resizeObserver.unobserve(wrapper);
14486
+ });
14487
+
14469
14488
  function div_elementresize_handler() {
14470
14489
  containerWidth = this.clientWidth;
14471
14490
  containerHeight = this.clientHeight;
package/dist/index.umd.js CHANGED
@@ -13781,7 +13781,7 @@
13781
13781
  div1 = internal.element("div");
13782
13782
  div0 = internal.element("div");
13783
13783
  internal.attr(div0, "class", "icon svelte-4rvov0");
13784
- internal.attr(div0, "style", div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`);
13784
+ internal.attr(div0, "style", div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon})`);
13785
13785
  internal.attr(div1, "class", "icon-wrap svelte-4rvov0");
13786
13786
  },
13787
13787
  m(target, anchor) {
@@ -13794,7 +13794,7 @@
13794
13794
  }
13795
13795
  },
13796
13796
  p(ctx, dirty) {
13797
- if (dirty & /*itemLabel*/ 1 && div0_style_value !== (div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`)) {
13797
+ if (dirty & /*itemLabel*/ 1 && div0_style_value !== (div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon})`)) {
13798
13798
  internal.attr(div0, "style", div0_style_value);
13799
13799
  }
13800
13800
  },
@@ -13812,7 +13812,7 @@
13812
13812
  let t0;
13813
13813
  let div0;
13814
13814
  let span0;
13815
- let t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "";
13815
+ let t1_value = (/*itemLabel*/ ctx[0].code || /*itemLabel*/ ctx[0].id) + "";
13816
13816
  let t1;
13817
13817
  let t2;
13818
13818
  let span1;
@@ -13884,7 +13884,7 @@
13884
13884
  if_block = null;
13885
13885
  }
13886
13886
 
13887
- if (dirty & /*itemLabel*/ 1 && t1_value !== (t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "")) internal.set_data(t1, t1_value);
13887
+ if (dirty & /*itemLabel*/ 1 && t1_value !== (t1_value = (/*itemLabel*/ ctx[0].code || /*itemLabel*/ ctx[0].id) + "")) internal.set_data(t1, t1_value);
13888
13888
  if (dirty & /*itemLabel*/ 1 && t3_value !== (t3_value = /*itemLabel*/ ctx[0].name + "")) internal.set_data(t3, t3_value);
13889
13889
 
13890
13890
  if (dirty & /*itemLabel*/ 1) {
@@ -13922,14 +13922,13 @@
13922
13922
  };
13923
13923
  }
13924
13924
 
13925
- const defaultIcon = '//vrlab-public.ljcdn.com/common/file/web/c8591aaa-e62b-4e31-8fed-671483ace37f.svg\n';
13926
-
13927
13925
  function instance$1($$self, $$props, $$invalidate) {
13928
13926
  let { itemLabel } = $$props;
13929
13927
  let { hooks } = $$props;
13930
13928
  let { anchorEnabled } = $$props;
13931
13929
  let { onIconClick } = $$props;
13932
13930
 
13931
+ // const defaultIcon = '//vrlab-public.ljcdn.com/common/file/web/c8591aaa-e62b-4e31-8fed-671483ace37f.svg\n'
13933
13932
  function onClick() {
13934
13933
  hooks.emit('onLabelClick', itemLabel);
13935
13934
  }
@@ -13976,7 +13975,8 @@
13976
13975
  const raycaster = new Raycaster();
13977
13976
  raycaster.set(targetVector, direction);
13978
13977
  const [intersection] = five.model.intersectRaycaster(raycaster);
13979
- return intersection && distance <= intersection.distance + 0.1;
13978
+ return intersection && intersection.distance + 0.01 < distance;
13979
+ // return intersection && distance <= intersection.distance + 0.1
13980
13980
  };
13981
13981
 
13982
13982
  /**
@@ -14012,18 +14012,18 @@
14012
14012
 
14013
14013
  function get_each_context(ctx, list, i) {
14014
14014
  const child_ctx = ctx.slice();
14015
- child_ctx[31] = list[i];
14015
+ child_ctx[32] = list[i];
14016
14016
  return child_ctx;
14017
14017
  }
14018
14018
 
14019
- // (229:2) {#if itemLabelItem.visible}
14019
+ // (248:2) {#if itemLabelItem.visible}
14020
14020
  function create_if_block(ctx) {
14021
14021
  let itemlabelitem;
14022
14022
  let current;
14023
14023
 
14024
14024
  itemlabelitem = new ItemLabelItem({
14025
14025
  props: {
14026
- itemLabel: /*itemLabelItem*/ ctx[31],
14026
+ itemLabel: /*itemLabelItem*/ ctx[32],
14027
14027
  hooks: /*hooks*/ ctx[0],
14028
14028
  anchorEnabled: /*anchorEnabled*/ ctx[2],
14029
14029
  onIconClick: /*onIconClick*/ ctx[6]
@@ -14040,7 +14040,7 @@
14040
14040
  },
14041
14041
  p(ctx, dirty) {
14042
14042
  const itemlabelitem_changes = {};
14043
- if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[31];
14043
+ if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[32];
14044
14044
  if (dirty[0] & /*hooks*/ 1) itemlabelitem_changes.hooks = /*hooks*/ ctx[0];
14045
14045
  if (dirty[0] & /*anchorEnabled*/ 4) itemlabelitem_changes.anchorEnabled = /*anchorEnabled*/ ctx[2];
14046
14046
  itemlabelitem.$set(itemlabelitem_changes);
@@ -14060,12 +14060,12 @@
14060
14060
  };
14061
14061
  }
14062
14062
 
14063
- // (228:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
14063
+ // (247:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
14064
14064
  function create_each_block(key_1, ctx) {
14065
14065
  let first;
14066
14066
  let if_block_anchor;
14067
14067
  let current;
14068
- let if_block = /*itemLabelItem*/ ctx[31].visible && create_if_block(ctx);
14068
+ let if_block = /*itemLabelItem*/ ctx[32].visible && create_if_block(ctx);
14069
14069
 
14070
14070
  return {
14071
14071
  key: key_1,
@@ -14085,7 +14085,7 @@
14085
14085
  p(new_ctx, dirty) {
14086
14086
  ctx = new_ctx;
14087
14087
 
14088
- if (/*itemLabelItem*/ ctx[31].visible) {
14088
+ if (/*itemLabelItem*/ ctx[32].visible) {
14089
14089
  if (if_block) {
14090
14090
  if_block.p(ctx, dirty);
14091
14091
 
@@ -14132,7 +14132,7 @@
14132
14132
  let div_resize_listener;
14133
14133
  let current;
14134
14134
  let each_value = /*renderItemLabels*/ ctx[1];
14135
- const get_key = ctx => /*itemLabelItem*/ ctx[31].id;
14135
+ const get_key = ctx => /*itemLabelItem*/ ctx[32].id;
14136
14136
 
14137
14137
  for (let i = 0; i < each_value.length; i += 1) {
14138
14138
  let child_ctx = get_each_context(ctx, each_value, i);
@@ -14234,7 +14234,7 @@
14234
14234
  * 1、当前楼层(假设先不考虑多楼层)
14235
14235
  * 2、模型未被遮挡(一个 box 有没有被遮挡的计算? TODO)
14236
14236
  * */
14237
- const getLabelVisible = (five$1, itemLabel) => {
14237
+ const judgeImpacted = (five$1, itemLabel) => {
14238
14238
  // 虚拟 VR 仅有一层,不考虑楼层信息
14239
14239
  const cameraPosition = five$1.camera.position.clone();
14240
14240
 
@@ -14255,6 +14255,17 @@
14255
14255
  // const [intersection] = five.model.intersectRaycaster(raycaster)
14256
14256
  // return !(intersection && intersection.distance + 1 < vectorDistance);
14257
14257
 
14258
+ const judgeInViewport = modelPoint => {
14259
+ const { camera, model } = five$1;
14260
+ const { x: offsetXFromCenter, y: offsetYFromCenter, z: offsetZFromCenter } = modelPoint.clone().project(camera);
14261
+ const ratioFromLeft = (offsetXFromCenter + 1) / 2;
14262
+ const ratioFromTop = (2 - (offsetYFromCenter + 1)) / 2;
14263
+ const isFront = Math.abs(offsetZFromCenter) < 1;
14264
+ const cssOffset = [ratioFromLeft, ratioFromTop];
14265
+ const isInViewport = isFront && cssOffset.every(ratio => ratio < 1 && ratio >= 0);
14266
+ return Boolean(isInViewport);
14267
+ };
14268
+
14258
14269
  // cssOffset 获取
14259
14270
  const getLabelCssOffset = (five, itemLabel) => {
14260
14271
  const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
@@ -14271,19 +14282,26 @@
14271
14282
  return [xOffset, yOffset];
14272
14283
  };
14273
14284
 
14274
- const getFormatedItemLabels = (five, labels) => {
14285
+ const getFormatedItemLabels = (five$1, labels) => {
14275
14286
  // 计算位置 & 可见性
14276
14287
  const newLabels = labels.map(label => {
14277
- const cssOffset = getLabelCssOffset(five, label);
14288
+ const cssOffset = getLabelCssOffset(five$1, label);
14278
14289
  label.name.length * basicWidth;
14279
14290
  const strokeLength = getStrokeLength(label.modelPosition[1], displayStrategyType);
14280
14291
 
14281
14292
  // 是否加入碰撞检测
14282
- const naturalVisible = modelOcclusionEnable
14283
- ? getLabelVisible(five, label)
14284
- : label.visible;
14293
+ // 配置加入碰撞检测,则判断碰撞检测
14294
+ // 在可见范围内, 仅在 Panorama 模态计算
14295
+ const isInViewport = five$1.currentMode === five.Five.Mode.Panorama
14296
+ ? judgeInViewport(new Vector3(label.position[0], label.position[1], label.position[2]))
14297
+ : true;
14298
+
14299
+ // 碰撞
14300
+ const isBlocked = modelOcclusionEnable
14301
+ ? judgeImpacted(five$1, label)
14302
+ : false;
14285
14303
 
14286
- const visible = naturalVisible;
14304
+ const visible = isInViewport && !isBlocked;
14287
14305
 
14288
14306
  // 关掉重叠计算
14289
14307
  // const visible = naturalVisible && !isOverlap([cssOffset[0], cssOffset[1] + strokeLength], curLabelWidth)
@@ -14299,7 +14317,7 @@
14299
14317
 
14300
14318
  const sortedItemLabelItems = newLabels.filter(({ visible }) => visible).map(label => ({
14301
14319
  itemLabelItem: label,
14302
- distance: new Vector3(label.modelPosition[0], label.modelPosition[1], label.modelPosition[2]).clone().distanceTo(five.camera.position)
14320
+ distance: new Vector3(label.modelPosition[0], label.modelPosition[1], label.modelPosition[2]).clone().distanceTo(five$1.camera.position)
14303
14321
  })).sort((a, b) => a.distance - b.distance);
14304
14322
 
14305
14323
  return newLabels.map(label => {
@@ -14314,24 +14332,11 @@
14314
14332
  $$invalidate(1, renderItemLabels = getFormatedItemLabels(five$1, renderItemLabels));
14315
14333
  };
14316
14334
 
14317
- svelte.beforeUpdate(() => {
14318
- addDataUpdateListener();
14319
- });
14320
-
14321
14335
  const handleCameraUpdateCallback = () => {
14322
14336
  $$invalidate(5, itemsVisible = false);
14323
14337
  handleCameraUpdate();
14324
14338
  };
14325
14339
 
14326
- svelte.onMount(() => {
14327
- $$invalidate(1, renderItemLabels = transform2RenderData(itemLabels));
14328
- curItemLabels = itemLabels;
14329
- onItemLabelUpdate();
14330
- addResizeListener();
14331
- five$1.on('cameraUpdate', handleCameraUpdateCallback);
14332
- five$1.on('modeChange', onFiveModeChange);
14333
- });
14334
-
14335
14340
  const onFiveModeChange = mode => {
14336
14341
  $$invalidate(5, itemsVisible = false);
14337
14342
 
@@ -14379,12 +14384,6 @@
14379
14384
  }
14380
14385
  });
14381
14386
 
14382
- svelte.onDestroy(() => {
14383
- five$1.off('cameraUpdate', handleCameraUpdateCallback);
14384
- five$1.off('modeChange', onFiveModeChange);
14385
- resizeObserver.unobserve(wrapper);
14386
- });
14387
-
14388
14387
  const getNearObserverPano = (fromPositionVector, observers) => {
14389
14388
  let candidates = [];
14390
14389
 
@@ -14422,6 +14421,7 @@
14422
14421
  const observer = getNearObserverPano(fromPositionVector, observers);
14423
14422
 
14424
14423
  if (observer) {
14424
+ console.log('--has observer--');
14425
14425
  itemLabel.observerIndex = observer.panoIndex;
14426
14426
  }
14427
14427
 
@@ -14454,6 +14454,25 @@
14454
14454
  }
14455
14455
  };
14456
14456
 
14457
+ svelte.beforeUpdate(() => {
14458
+ addDataUpdateListener();
14459
+ });
14460
+
14461
+ svelte.onMount(() => {
14462
+ $$invalidate(1, renderItemLabels = transform2RenderData(itemLabels));
14463
+ curItemLabels = itemLabels;
14464
+ onItemLabelUpdate();
14465
+ addResizeListener();
14466
+ five$1.on('cameraUpdate', handleCameraUpdateCallback);
14467
+ five$1.on('modeChange', onFiveModeChange);
14468
+ });
14469
+
14470
+ svelte.onDestroy(() => {
14471
+ five$1.off('cameraUpdate', handleCameraUpdateCallback);
14472
+ five$1.off('modeChange', onFiveModeChange);
14473
+ resizeObserver.unobserve(wrapper);
14474
+ });
14475
+
14457
14476
  function div_elementresize_handler() {
14458
14477
  containerWidth = this.clientWidth;
14459
14478
  containerHeight = this.clientHeight;