@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
@@ -41,18 +41,18 @@ function add_css(target) {
41
41
 
42
42
  function get_each_context(ctx, list, i) {
43
43
  const child_ctx = ctx.slice();
44
- child_ctx[31] = list[i];
44
+ child_ctx[32] = list[i];
45
45
  return child_ctx;
46
46
  }
47
47
 
48
- // (229:2) {#if itemLabelItem.visible}
48
+ // (248:2) {#if itemLabelItem.visible}
49
49
  function create_if_block(ctx) {
50
50
  let itemlabelitem;
51
51
  let current;
52
52
 
53
53
  itemlabelitem = new ItemLabelItem({
54
54
  props: {
55
- itemLabel: /*itemLabelItem*/ ctx[31],
55
+ itemLabel: /*itemLabelItem*/ ctx[32],
56
56
  hooks: /*hooks*/ ctx[0],
57
57
  anchorEnabled: /*anchorEnabled*/ ctx[2],
58
58
  onIconClick: /*onIconClick*/ ctx[6]
@@ -69,7 +69,7 @@ function create_if_block(ctx) {
69
69
  },
70
70
  p(ctx, dirty) {
71
71
  const itemlabelitem_changes = {};
72
- if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[31];
72
+ if (dirty[0] & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[32];
73
73
  if (dirty[0] & /*hooks*/ 1) itemlabelitem_changes.hooks = /*hooks*/ ctx[0];
74
74
  if (dirty[0] & /*anchorEnabled*/ 4) itemlabelitem_changes.anchorEnabled = /*anchorEnabled*/ ctx[2];
75
75
  itemlabelitem.$set(itemlabelitem_changes);
@@ -89,12 +89,12 @@ function create_if_block(ctx) {
89
89
  };
90
90
  }
91
91
 
92
- // (228:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
92
+ // (247:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
93
93
  function create_each_block(key_1, ctx) {
94
94
  let first;
95
95
  let if_block_anchor;
96
96
  let current;
97
- let if_block = /*itemLabelItem*/ ctx[31].visible && create_if_block(ctx);
97
+ let if_block = /*itemLabelItem*/ ctx[32].visible && create_if_block(ctx);
98
98
 
99
99
  return {
100
100
  key: key_1,
@@ -114,7 +114,7 @@ function create_each_block(key_1, ctx) {
114
114
  p(new_ctx, dirty) {
115
115
  ctx = new_ctx;
116
116
 
117
- if (/*itemLabelItem*/ ctx[31].visible) {
117
+ if (/*itemLabelItem*/ ctx[32].visible) {
118
118
  if (if_block) {
119
119
  if_block.p(ctx, dirty);
120
120
 
@@ -161,7 +161,7 @@ function create_fragment(ctx) {
161
161
  let div_resize_listener;
162
162
  let current;
163
163
  let each_value = /*renderItemLabels*/ ctx[1];
164
- const get_key = ctx => /*itemLabelItem*/ ctx[31].id;
164
+ const get_key = ctx => /*itemLabelItem*/ ctx[32].id;
165
165
 
166
166
  for (let i = 0; i < each_value.length; i += 1) {
167
167
  let child_ctx = get_each_context(ctx, each_value, i);
@@ -265,7 +265,7 @@ function instance($$self, $$props, $$invalidate) {
265
265
  * 1、当前楼层(假设先不考虑多楼层)
266
266
  * 2、模型未被遮挡(一个 box 有没有被遮挡的计算? TODO)
267
267
  * */
268
- const getLabelVisible = (five, itemLabel) => {
268
+ const judgeImpacted = (five, itemLabel) => {
269
269
  // 虚拟 VR 仅有一层,不考虑楼层信息
270
270
  const cameraPosition = five.camera.position.clone();
271
271
 
@@ -286,6 +286,17 @@ function instance($$self, $$props, $$invalidate) {
286
286
  // const [intersection] = five.model.intersectRaycaster(raycaster)
287
287
  // return !(intersection && intersection.distance + 1 < vectorDistance);
288
288
 
289
+ const judgeInViewport = modelPoint => {
290
+ const { camera, model } = five;
291
+ const { x: offsetXFromCenter, y: offsetYFromCenter, z: offsetZFromCenter } = modelPoint.clone().project(camera);
292
+ const ratioFromLeft = (offsetXFromCenter + 1) / 2;
293
+ const ratioFromTop = (2 - (offsetYFromCenter + 1)) / 2;
294
+ const isFront = Math.abs(offsetZFromCenter) < 1;
295
+ const cssOffset = [ratioFromLeft, ratioFromTop];
296
+ const isInViewport = isFront && cssOffset.every(ratio => ratio < 1 && ratio >= 0);
297
+ return Boolean(isInViewport);
298
+ };
299
+
289
300
  // cssOffset 获取
290
301
  const getLabelCssOffset = (five, itemLabel) => {
291
302
  const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
@@ -320,11 +331,18 @@ function instance($$self, $$props, $$invalidate) {
320
331
  const strokeLength = getStrokeLength(label.modelPosition[1], displayStrategyType);
321
332
 
322
333
  // 是否加入碰撞检测
323
- const naturalVisible = modelOcclusionEnable
324
- ? getLabelVisible(five, label)
325
- : label.visible;
334
+ // 配置加入碰撞检测,则判断碰撞检测
335
+ // 在可见范围内, 仅在 Panorama 模态计算
336
+ const isInViewport = five.currentMode === Five.Mode.Panorama
337
+ ? judgeInViewport(new Vector3(label.position[0], label.position[1], label.position[2]))
338
+ : true;
339
+
340
+ // 碰撞
341
+ const isBlocked = modelOcclusionEnable
342
+ ? judgeImpacted(five, label)
343
+ : false;
326
344
 
327
- const visible = naturalVisible;
345
+ const visible = isInViewport && !isBlocked;
328
346
 
329
347
  // 关掉重叠计算
330
348
  // const visible = naturalVisible && !isOverlap([cssOffset[0], cssOffset[1] + strokeLength], curLabelWidth)
@@ -355,24 +373,11 @@ function instance($$self, $$props, $$invalidate) {
355
373
  $$invalidate(1, renderItemLabels = getFormatedItemLabels(five, renderItemLabels));
356
374
  };
357
375
 
358
- beforeUpdate(() => {
359
- addDataUpdateListener();
360
- });
361
-
362
376
  const handleCameraUpdateCallback = () => {
363
377
  $$invalidate(5, itemsVisible = false);
364
378
  handleCameraUpdate();
365
379
  };
366
380
 
367
- onMount(() => {
368
- $$invalidate(1, renderItemLabels = transform2RenderData(itemLabels));
369
- curItemLabels = itemLabels;
370
- onItemLabelUpdate();
371
- addResizeListener();
372
- five.on('cameraUpdate', handleCameraUpdateCallback);
373
- five.on('modeChange', onFiveModeChange);
374
- });
375
-
376
381
  const onFiveModeChange = mode => {
377
382
  $$invalidate(5, itemsVisible = false);
378
383
 
@@ -420,12 +425,6 @@ function instance($$self, $$props, $$invalidate) {
420
425
  }
421
426
  });
422
427
 
423
- onDestroy(() => {
424
- five.off('cameraUpdate', handleCameraUpdateCallback);
425
- five.off('modeChange', onFiveModeChange);
426
- resizeObserver.unobserve(wrapper);
427
- });
428
-
429
428
  const getNearObserverPano = (fromPositionVector, observers) => {
430
429
  let candidates = [];
431
430
 
@@ -463,6 +462,7 @@ function instance($$self, $$props, $$invalidate) {
463
462
  const observer = getNearObserverPano(fromPositionVector, observers);
464
463
 
465
464
  if (observer) {
465
+ console.log('--has observer--');
466
466
  itemLabel.observerIndex = observer.panoIndex;
467
467
  }
468
468
 
@@ -495,6 +495,25 @@ function instance($$self, $$props, $$invalidate) {
495
495
  }
496
496
  };
497
497
 
498
+ beforeUpdate(() => {
499
+ addDataUpdateListener();
500
+ });
501
+
502
+ onMount(() => {
503
+ $$invalidate(1, renderItemLabels = transform2RenderData(itemLabels));
504
+ curItemLabels = itemLabels;
505
+ onItemLabelUpdate();
506
+ addResizeListener();
507
+ five.on('cameraUpdate', handleCameraUpdateCallback);
508
+ five.on('modeChange', onFiveModeChange);
509
+ });
510
+
511
+ onDestroy(() => {
512
+ five.off('cameraUpdate', handleCameraUpdateCallback);
513
+ five.off('modeChange', onFiveModeChange);
514
+ resizeObserver.unobserve(wrapper);
515
+ });
516
+
498
517
  function div_elementresize_handler() {
499
518
  containerWidth = this.clientWidth;
500
519
  containerHeight = this.clientHeight;
@@ -38,7 +38,7 @@ function create_if_block(ctx) {
38
38
  div1 = element("div");
39
39
  div0 = element("div");
40
40
  attr(div0, "class", "icon svelte-1gam1w3");
41
- attr(div0, "style", div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`);
41
+ attr(div0, "style", div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon})`);
42
42
  attr(div1, "class", "icon-wrap svelte-1gam1w3");
43
43
  },
44
44
  m(target, anchor) {
@@ -51,7 +51,7 @@ function create_if_block(ctx) {
51
51
  }
52
52
  },
53
53
  p(ctx, dirty) {
54
- if (dirty & /*itemLabel*/ 1 && div0_style_value !== (div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon ?? defaultIcon})`)) {
54
+ if (dirty & /*itemLabel*/ 1 && div0_style_value !== (div0_style_value = `background-image: url(${/*itemLabel*/ ctx[0].icon})`)) {
55
55
  attr(div0, "style", div0_style_value);
56
56
  }
57
57
  },
@@ -69,7 +69,7 @@ function create_fragment(ctx) {
69
69
  let t0;
70
70
  let div0;
71
71
  let span0;
72
- let t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "";
72
+ let t1_value = (/*itemLabel*/ ctx[0].code || /*itemLabel*/ ctx[0].id) + "";
73
73
  let t1;
74
74
  let t2;
75
75
  let span1;
@@ -142,7 +142,7 @@ function create_fragment(ctx) {
142
142
  if_block = null;
143
143
  }
144
144
 
145
- if (dirty & /*itemLabel*/ 1 && t1_value !== (t1_value = (/*itemLabel*/ ctx[0].code ?? /*itemLabel*/ ctx[0].id) + "")) set_data(t1, t1_value);
145
+ if (dirty & /*itemLabel*/ 1 && t1_value !== (t1_value = (/*itemLabel*/ ctx[0].code || /*itemLabel*/ ctx[0].id) + "")) set_data(t1, t1_value);
146
146
  if (dirty & /*itemLabel*/ 1 && t3_value !== (t3_value = /*itemLabel*/ ctx[0].name + "")) set_data(t3, t3_value);
147
147
 
148
148
  if (dirty & /*itemLabel*/ 1) {
@@ -180,14 +180,13 @@ function create_fragment(ctx) {
180
180
  };
181
181
  }
182
182
 
183
- const defaultIcon = '//vrlab-public.ljcdn.com/common/file/web/c8591aaa-e62b-4e31-8fed-671483ace37f.svg\n';
184
-
185
183
  function instance($$self, $$props, $$invalidate) {
186
184
  let { itemLabel } = $$props;
187
185
  let { hooks } = $$props;
188
186
  let { anchorEnabled } = $$props;
189
187
  let { onIconClick } = $$props;
190
188
 
189
+ // const defaultIcon = '//vrlab-public.ljcdn.com/common/file/web/c8591aaa-e62b-4e31-8fed-671483ace37f.svg\n'
191
190
  function onClick() {
192
191
  hooks.emit('onLabelClick', itemLabel);
193
192
  }
@@ -8,5 +8,6 @@ export const isImpacted = (five, sourceVector, targetVector, distance) => {
8
8
  const raycaster = new Raycaster();
9
9
  raycaster.set(targetVector, direction);
10
10
  const [intersection] = five.model.intersectRaycaster(raycaster);
11
- return intersection && distance <= intersection.distance + 0.1;
11
+ return intersection && intersection.distance + 0.01 < distance;
12
+ // return intersection && distance <= intersection.distance + 0.1
12
13
  };
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "repository": "https://github.com/realsee-developer/dnalogel.git",
9
9
  "description": "如视 VR 看房插件合集",
10
10
  "private": false,
11
- "version": "2.0.0-alpha.30",
11
+ "version": "2.0.0-alpha.31-beta",
12
12
  "license": "SEE LICENSE IN TERMS.txt",
13
13
  "scripts": {
14
14
  "build": "yarn run tsb && yarn run build:rollup && yarn build:docs",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.17.5",
31
- "@realsee/five": "^5.0.0-alpha.127",
31
+ "@realsee/five": "5.0.0-alpha.127",
32
32
  "@rollup/plugin-alias": "^3.1.9",
33
33
  "@rollup/plugin-commonjs": "^21.1.0",
34
34
  "@rollup/plugin-typescript": "^8.3.2",