@realsee/dnalogel 2.0.0-alpha.12 → 2.0.0-alpha.13

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 (101) hide show
  1. package/dist/CSS3DRenderPlugin/index.js +17 -14
  2. package/dist/CameraMovementPlugin/index.js +40 -15
  3. package/dist/ModelChassisCompassPlugin/index.js +32 -6
  4. package/dist/ModelEntryDoorGuidePlugin/index.js +48 -18
  5. package/dist/ModelItemLabelPlugin/index.js +18 -17
  6. package/dist/ModelRoomLabelPlugin/index.js +67 -26
  7. package/dist/PanoCompassPlugin/index.js +311 -164
  8. package/dist/PanoCursorRaycasterPlugin/index.js +5 -3
  9. package/dist/PanoMeasurePlugin/index.js +1337 -583
  10. package/dist/PanoRulerPlugin/index.js +32 -5
  11. package/dist/PanoSpatialTagPlugin/index.js +64 -29
  12. package/dist/floorplan/ModelFloorplanPlugin/index.js +586 -362
  13. package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +164 -72
  14. package/dist/floorplan/TopviewFloorplanPlugin/index.js +311 -153
  15. package/dist/index.es.js +2663 -1341
  16. package/dist/index.js +2667 -1345
  17. package/dist/index.umd.js +2667 -1345
  18. package/docs/assets/main.js +1 -1
  19. package/docs/classes/ModelRoomLabelController.html +6 -6
  20. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  21. package/docs/enums/ModelFloorplanErrorType.html +1 -1
  22. package/docs/interfaces/LineJson.html +1 -1
  23. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  24. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  25. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  26. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  27. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  28. package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
  29. package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
  30. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  31. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  32. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  33. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  34. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  35. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  36. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  37. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  38. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  39. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  40. package/docs/interfaces/PointJson.html +1 -1
  41. package/docs/interfaces/RoomLabel.html +7 -7
  42. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +1 -1
  43. package/docs/modules.html +12 -12
  44. package/libs/CSS3DRenderPlugin/index.js +16 -13
  45. package/libs/CameraMovementPlugin/index.js +24 -15
  46. package/libs/ModelChassisCompassPlugin/index.js +14 -5
  47. package/libs/ModelEntryDoorGuidePlugin/index.js +24 -12
  48. package/libs/ModelItemLabelPlugin/ItemLabelComponent.js +12 -10
  49. package/libs/ModelItemLabelPlugin/index.js +5 -3
  50. package/libs/ModelItemLabelPlugin/utils/parseData.js +1 -4
  51. package/libs/ModelRoomLabelPlugin/Controller.js +64 -23
  52. package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +3 -3
  53. package/libs/PanoCompassPlugin/index.js +225 -128
  54. package/libs/PanoCursorRaycasterPlugin/index.js +5 -3
  55. package/libs/PanoMeasurePlugin/Controller/BaseController.js +68 -13
  56. package/libs/PanoMeasurePlugin/Controller/EditController.js +267 -154
  57. package/libs/PanoMeasurePlugin/Controller/ShortcutKeyController.js +40 -20
  58. package/libs/PanoMeasurePlugin/Controller/WatchController.js +234 -152
  59. package/libs/PanoMeasurePlugin/Controller/index.js +131 -47
  60. package/libs/PanoMeasurePlugin/Model/index.js +30 -5
  61. package/libs/PanoMeasurePlugin/Model/line.js +60 -10
  62. package/libs/PanoMeasurePlugin/Model/point.js +24 -4
  63. package/libs/PanoMeasurePlugin/Model/polyline.js +20 -3
  64. package/libs/PanoMeasurePlugin/Modules/DeleteDom/index.js +59 -14
  65. package/libs/PanoMeasurePlugin/Modules/FiveHelper.js +23 -8
  66. package/libs/PanoMeasurePlugin/Modules/GuideController.js +61 -26
  67. package/libs/PanoMeasurePlugin/Modules/Magnifier.js +60 -10
  68. package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +83 -37
  69. package/libs/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +52 -17
  70. package/libs/PanoMeasurePlugin/Modules/UIController/index.js +61 -30
  71. package/libs/PanoMeasurePlugin/utils/distanceDom.js +3 -2
  72. package/libs/PanoMeasurePlugin/utils/line.js +8 -7
  73. package/libs/PanoRulerPlugin/index.js +16 -5
  74. package/libs/PanoSpatialTagPlugin/index.js +11 -9
  75. package/libs/floorplan/Components/BaseImage.js +10 -5
  76. package/libs/floorplan/Components/RoomHighlight/RoomHighlight.js +3 -1
  77. package/libs/floorplan/Components/RoomMaterials/RoomMaterial.js +5 -6
  78. package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.js +7 -2
  79. package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.js +3 -1
  80. package/libs/floorplan/ModelFloorplanPlugin/Controller.js +456 -273
  81. package/libs/floorplan/ModelFloorplanPlugin/utils/correctFiveState.js +33 -22
  82. package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/CurrentFloor.js +3 -1
  83. package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +97 -36
  84. package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +231 -108
  85. package/libs/floorplan/utils/formatData.js +43 -28
  86. package/libs/floorplan/utils/formatPosition.js +1 -1
  87. package/libs/shared-utils/Subscribe.js +8 -1
  88. package/libs/shared-utils/animationFrame/BetterTween.js +47 -18
  89. package/libs/shared-utils/createCanvasTextTexture.js +6 -5
  90. package/libs/shared-utils/five/changeMode.js +23 -12
  91. package/libs/shared-utils/getPxmm.js +1 -1
  92. package/libs/shared-utils/math/evenNumber.js +1 -1
  93. package/libs/shared-utils/three/loadFbxObj.js +20 -9
  94. package/libs/shared-utils/three/loadTexture.js +17 -6
  95. package/libs/shared-utils/three/transfromToMeshBasicMaterial.js +2 -1
  96. package/libs/shared-utils/tinyEJSrender.js +36 -6
  97. package/libs/shared-utils/to.js +21 -10
  98. package/libs/shared-utils/useDebounce.js +1 -1
  99. package/libs/shared-utils/useThrottle.js +2 -1
  100. package/package.json +1 -1
  101. package/CHANGELOG.md +0 -41
@@ -28,6 +28,31 @@ function _interopNamespace(e) {
28
28
 
29
29
  var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
30
30
 
31
+ /*! *****************************************************************************
32
+ Copyright (c) Microsoft Corporation.
33
+
34
+ Permission to use, copy, modify, and/or distribute this software for any
35
+ purpose with or without fee is hereby granted.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
38
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
39
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
40
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
41
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
42
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
43
+ PERFORMANCE OF THIS SOFTWARE.
44
+ ***************************************************************************** */
45
+
46
+ function __awaiter(thisArg, _arguments, P, generator) {
47
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
48
+ return new (P || (P = Promise))(function (resolve, reject) {
49
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
50
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
51
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
52
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
53
+ });
54
+ }
55
+
31
56
  const CAMERA_IMAGE = 'data:image/png;base64,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';
32
57
 
33
58
  function rad2Deg$1(rad) {
@@ -145,7 +170,7 @@ function add_css$b(target) {
145
170
  internal.append_styles(target, "svelte-5l80pv", ".floorplan-plugin__compass.svelte-5l80pv{position:absolute;left:50%;top:-46px;width:231px;height:41px;will-change:opacity;transform-origin:center 184px}.floorplan-plugin__compass-image.svelte-5l80pv{width:100%;height:100%;position:absolute;left:0;top:0;opacity:0.1;background-repeat:no-repeat;background-size:100% 100%}.floorplan-plugin__compass-text.svelte-5l80pv{position:absolute;left:50%;top:15px;transform:translateX(-50%);opacity:0.2;font-weight:bold;font-size:10px;color:#fff}");
146
171
  }
147
172
 
148
- // (12:0) {#if northRad}
173
+ // (13:0) {#if northRad}
149
174
  function create_if_block$6(ctx) {
150
175
  let div1;
151
176
  let div0;
@@ -212,9 +237,14 @@ function rad2Deg(rad) {
212
237
  }
213
238
 
214
239
  function instance$f($$self, $$props, $$invalidate) {
240
+ var _a;
215
241
  let { floorplanData } = $$props;
216
242
  let { northDesc } = $$props;
217
- const northRad = floorplanData.entrance?.northRad;
243
+
244
+ const northRad = (_a = floorplanData.entrance) === null || _a === void 0
245
+ ? void 0
246
+ : _a.northRad;
247
+
218
248
  const rotate = !northRad ? 0 : rad2Deg(northRad);
219
249
  const compassTransformStyle = `translateX(-50%) translateZ(10px) rotate(${-rotate + 90}deg)`;
220
250
 
@@ -371,7 +401,9 @@ function instance$e($$self, $$props, $$invalidate) {
371
401
 
372
402
  $$self.$$.update = () => {
373
403
  if ($$self.$$.dirty & /*getLabelElement, room*/ 3) {
374
- $$invalidate(2, userConfigElement = getLabelElement?.(room));
404
+ $$invalidate(2, userConfigElement = getLabelElement === null || getLabelElement === void 0
405
+ ? void 0
406
+ : getLabelElement(room));
375
407
  }
376
408
  };
377
409
 
@@ -1236,7 +1268,7 @@ function add_css$5(target) {
1236
1268
  internal.append_styles(target, "svelte-126ja8e", ".floorplan-plugin__base-image.svelte-126ja8e{position:absolute;z-index:10;width:100%;height:100%;pointer-events:none}");
1237
1269
  }
1238
1270
 
1239
- // (12:22)
1271
+ // (13:22)
1240
1272
  function create_if_block_1$3(ctx) {
1241
1273
  let normalimage;
1242
1274
  let current;
@@ -1270,7 +1302,7 @@ function create_if_block_1$3(ctx) {
1270
1302
  };
1271
1303
  }
1272
1304
 
1273
- // (10:2) {#if svgContent}
1305
+ // (11:2) {#if svgContent}
1274
1306
  function create_if_block$3(ctx) {
1275
1307
  let svgimage;
1276
1308
  let current;
@@ -1398,6 +1430,7 @@ function create_fragment$8(ctx) {
1398
1430
  function instance$8($$self, $$props, $$invalidate) {
1399
1431
  let imageData;
1400
1432
  let svgContent;
1433
+ var _a, _b;
1401
1434
  let { floorIndex } = $$props;
1402
1435
  let { floorplanData } = $$props;
1403
1436
 
@@ -1411,12 +1444,16 @@ function instance$8($$self, $$props, $$invalidate) {
1411
1444
  $$invalidate(1, imageData = floorplanData.outlines[floorIndex]);
1412
1445
  }
1413
1446
 
1414
- if ($$self.$$.dirty & /*floorplanData, floorIndex*/ 12) {
1415
- $$invalidate(0, svgContent = floorplanData.outlines?.[floorIndex]?.svgContent);
1447
+ if ($$self.$$.dirty & /*floorplanData, _a, floorIndex, _b*/ 60) {
1448
+ $$invalidate(0, svgContent = $$invalidate(5, _b = $$invalidate(4, _a = floorplanData.outlines) === null || _a === void 0
1449
+ ? void 0
1450
+ : _a[floorIndex]) === null || _b === void 0
1451
+ ? void 0
1452
+ : _b.svgContent);
1416
1453
  }
1417
1454
  };
1418
1455
 
1419
- return [svgContent, imageData, floorIndex, floorplanData];
1456
+ return [svgContent, imageData, floorIndex, floorplanData, _a, _b];
1420
1457
  }
1421
1458
 
1422
1459
  class BaseImage extends internal.SvelteComponent {
@@ -1437,7 +1474,7 @@ function pathD(points, options = {}) {
1437
1474
  d += 'M' + point;
1438
1475
  return d;
1439
1476
  }
1440
- if (needA?.[index]) {
1477
+ if (needA === null || needA === void 0 ? void 0 : needA[index]) {
1441
1478
  d += 'A' + needA[index] + ',' + point;
1442
1479
  return d;
1443
1480
  }
@@ -1728,7 +1765,7 @@ function get_each_context$1(ctx, list, i) {
1728
1765
  return child_ctx;
1729
1766
  }
1730
1767
 
1731
- // (21:6) {:else}
1768
+ // (18:6) {:else}
1732
1769
  function create_else_block(ctx) {
1733
1770
  let roommaterial_1;
1734
1771
  let current;
@@ -1762,7 +1799,7 @@ function create_else_block(ctx) {
1762
1799
  };
1763
1800
  }
1764
1801
 
1765
- // (19:37)
1802
+ // (16:37)
1766
1803
  function create_if_block_1$2(ctx) {
1767
1804
  let roommaterial_2;
1768
1805
  let current;
@@ -1796,7 +1833,7 @@ function create_if_block_1$2(ctx) {
1796
1833
  };
1797
1834
  }
1798
1835
 
1799
- // (17:6) {#if room.floorType === 1}
1836
+ // (14:6) {#if room.floorType === 1}
1800
1837
  function create_if_block$2(ctx) {
1801
1838
  let roommaterial_0;
1802
1839
  let current;
@@ -1830,7 +1867,7 @@ function create_if_block$2(ctx) {
1830
1867
  };
1831
1868
  }
1832
1869
 
1833
- // (15:2) {#each rooms as room}
1870
+ // (12:2) {#each rooms as room}
1834
1871
  function create_each_block$1(ctx) {
1835
1872
  let svg;
1836
1873
  let current_block_type_index;
@@ -2002,8 +2039,7 @@ function instance$4($$self, $$props, $$invalidate) {
2002
2039
 
2003
2040
  $$self.$$.update = () => {
2004
2041
  if ($$self.$$.dirty & /*floorplanData, floorIndex, pxmm*/ 14) {
2005
- $$invalidate(0, rooms = floorplanData.floorDatas[floorIndex].rooms.map(room => ({
2006
- ...room,
2042
+ $$invalidate(0, rooms = floorplanData.floorDatas[floorIndex].rooms.map(room => Object.assign(Object.assign({}, room), {
2007
2043
  path: room.path.map(p => formatFloorplanPoint(p, pxmm, floorplanData.bounding))
2008
2044
  })));
2009
2045
  }
@@ -2251,7 +2287,9 @@ function instance$2($$self, $$props, $$invalidate) {
2251
2287
  const { observers: floorplan_observers } = floorplanData;
2252
2288
 
2253
2289
  const handleClick = function (e) {
2254
- if (onRoomHeightClick?.(e) === false) return;
2290
+ if ((onRoomHeightClick === null || onRoomHeightClick === void 0
2291
+ ? void 0
2292
+ : onRoomHeightClick(e)) === false) return;
2255
2293
 
2256
2294
  // 因为 mouse.offsetX 的兼容性问题,手动计算 mouse offsetX offsetY
2257
2295
  const boundingClientRect = highlightContainerDom.getBoundingClientRect();
@@ -3124,34 +3162,40 @@ class Main extends internal.SvelteComponent {
3124
3162
  * 有异常,则返回 [Error, undefined]
3125
3163
  * 用于替代 try&catch 处理 await 异常的方案
3126
3164
  */
3127
- async function to(promise) {
3128
- try {
3129
- const data = await promise;
3130
- return [null, data];
3131
- }
3132
- catch (error) {
3133
- if (error instanceof Error)
3134
- return [error, null];
3135
- return [new Error(''), null];
3136
- }
3165
+ function to(promise) {
3166
+ return __awaiter(this, void 0, void 0, function* () {
3167
+ try {
3168
+ const data = yield promise;
3169
+ return [null, data];
3170
+ }
3171
+ catch (error) {
3172
+ if (error instanceof Error)
3173
+ return [error, null];
3174
+ return [new Error(''), null];
3175
+ }
3176
+ });
3137
3177
  }
3138
3178
 
3139
- async function formatOutlines(outlines) {
3140
- const headers = new Headers({ 'Content-Type': 'text/plain' });
3141
- const getOutlineItem = async function (item) {
3142
- const outlineItem = {
3143
- index: item.index,
3144
- url: item.url,
3145
- svgUrl: item.svg_url,
3179
+ function formatOutlines(outlines) {
3180
+ return __awaiter(this, void 0, void 0, function* () {
3181
+ const headers = new Headers({ 'Content-Type': 'text/plain' });
3182
+ const getOutlineItem = function (item) {
3183
+ return __awaiter(this, void 0, void 0, function* () {
3184
+ const outlineItem = {
3185
+ index: item.index,
3186
+ url: item.url,
3187
+ svgUrl: item.svg_url,
3188
+ };
3189
+ if (item.svg_url) {
3190
+ const svgContent = yield fetch(item.svg_url, { headers }).then((res) => res.text());
3191
+ outlineItem.svgContent = svgContent;
3192
+ }
3193
+ return outlineItem;
3194
+ });
3146
3195
  };
3147
- if (item.svg_url) {
3148
- const svgContent = await fetch(item.svg_url, { headers }).then((res) => res.text());
3149
- outlineItem.svgContent = svgContent;
3150
- }
3151
- return outlineItem;
3152
- };
3153
- const svgOutlineItems = await Promise.all(outlines.map(getOutlineItem));
3154
- return svgOutlineItems;
3196
+ const svgOutlineItems = yield Promise.all(outlines.map(getOutlineItem));
3197
+ return svgOutlineItems;
3198
+ });
3155
3199
  }
3156
3200
  function formatRoom(data) {
3157
3201
  const floorplanRoomItem = {
@@ -3197,19 +3241,21 @@ function formatFloorplanEntrance(data) {
3197
3241
  };
3198
3242
  return floorplanEntrance;
3199
3243
  }
3200
- async function formatData(data) {
3201
- const outlines = await formatOutlines(data.outlines);
3202
- const bounding = data.computed_data.bounding;
3203
- const floorDatas = data.computed_data.floor_datas.map(formatFloorData);
3204
- const entrance = data.computed_data.entrance ? formatFloorplanEntrance(data.computed_data.entrance) : null;
3205
- const floorplanData = {
3206
- outlines,
3207
- entrance,
3208
- bounding,
3209
- floorDatas,
3210
- observers: data.computed_data.observers.map(formateFloorplanObserver),
3211
- };
3212
- return floorplanData;
3244
+ function formatData(data) {
3245
+ return __awaiter(this, void 0, void 0, function* () {
3246
+ const outlines = yield formatOutlines(data.outlines);
3247
+ const bounding = data.computed_data.bounding;
3248
+ const floorDatas = data.computed_data.floor_datas.map(formatFloorData);
3249
+ const entrance = data.computed_data.entrance ? formatFloorplanEntrance(data.computed_data.entrance) : null;
3250
+ const floorplanData = {
3251
+ outlines,
3252
+ entrance,
3253
+ bounding,
3254
+ floorDatas,
3255
+ observers: data.computed_data.observers.map(formateFloorplanObserver),
3256
+ };
3257
+ return floorplanData;
3258
+ });
3213
3259
  }
3214
3260
 
3215
3261
  /**
@@ -3340,7 +3386,7 @@ function getPxmm(five, container, floorIndex, options) {
3340
3386
  function getY() {
3341
3387
  const currentFloorY = getFloorY(floorIndex);
3342
3388
  const nextFloorY = getFloorY(floorIndex + 1);
3343
- const attachedTo = options?.attachedTo || FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER;
3389
+ const attachedTo = (options === null || options === void 0 ? void 0 : options.attachedTo) || FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER;
3344
3390
  if (attachedTo === FLOOR_PLAN_ATTACHED_TO.BOUNDING_CENTER)
3345
3391
  return (five.model.bounding.max.y + five.model.bounding.min.y) / 2;
3346
3392
  else if (attachedTo === FLOOR_PLAN_ATTACHED_TO.CEILING)
@@ -3357,18 +3403,20 @@ function getPxmm(five, container, floorIndex, options) {
3357
3403
  return pxmm;
3358
3404
  }
3359
3405
 
3360
- async function changeMode(five, ...changeModeParams) {
3361
- const [changeModeError] = await to(five.changeMode(...changeModeParams));
3362
- if (changeModeError)
3363
- throw changeModeError;
3364
- await new Promise((reslove, reject) => {
3365
- five.once('initAnimationEnded', reslove);
3366
- const handleModeChange = (mode) => {
3367
- if (mode !== changeModeParams[0])
3368
- reject('changeMode 被中断');
3369
- five.off('modeChange', handleModeChange);
3370
- };
3371
- five.on('modeChange', handleModeChange);
3406
+ function changeMode(five, ...changeModeParams) {
3407
+ return __awaiter(this, void 0, void 0, function* () {
3408
+ const [changeModeError] = yield to(five.changeMode(...changeModeParams));
3409
+ if (changeModeError)
3410
+ throw changeModeError;
3411
+ yield new Promise((reslove, reject) => {
3412
+ five.once('initAnimationEnded', reslove);
3413
+ const handleModeChange = (mode) => {
3414
+ if (mode !== changeModeParams[0])
3415
+ reject('changeMode 被中断');
3416
+ five.off('modeChange', handleModeChange);
3417
+ };
3418
+ five.on('modeChange', handleModeChange);
3419
+ });
3372
3420
  });
3373
3421
  }
3374
3422
 
@@ -3413,30 +3461,32 @@ function checkShowState(five$1, showState) {
3413
3461
  * 2. 内置了相应的动画时间计算
3414
3462
  * 3. 纠正成功会返回 true,失败「可能会被用户行为中断」会返回 false
3415
3463
  */
3416
- async function correctFiveState(five$1, showState, userAction = true) {
3417
- // 当前已满足状态,不需要变更
3418
- const result = checkShowState(five$1, showState);
3419
- if (result === true)
3420
- return;
3421
- // 纠正 mode
3422
- if (five$1.currentMode !== five.Five.Mode.Floorplan) {
3423
- const [changeModeError] = await to(changeMode(five$1, five.Five.Mode.Floorplan, showState, undefined, userAction));
3424
- if (changeModeError)
3425
- throw changeModeError;
3426
- // changeMode 是异步行为,可能会被打断,需要在结束后加一次判断
3464
+ function correctFiveState(five$1, showState, userAction = true) {
3465
+ return __awaiter(this, void 0, void 0, function* () {
3466
+ // 当前已满足状态,不需要变更
3427
3467
  const result = checkShowState(five$1, showState);
3428
- if (result === false)
3429
- throw new Error(FloorplanErrorType.ChangeModeError);
3468
+ if (result === true)
3469
+ return;
3470
+ // 纠正 mode
3471
+ if (five$1.currentMode !== five.Five.Mode.Floorplan) {
3472
+ const [changeModeError] = yield to(changeMode(five$1, five.Five.Mode.Floorplan, showState, undefined, userAction));
3473
+ if (changeModeError)
3474
+ throw changeModeError;
3475
+ // changeMode 是异步行为,可能会被打断,需要在结束后加一次判断
3476
+ const result = checkShowState(five$1, showState);
3477
+ if (result === false)
3478
+ throw new Error(FloorplanErrorType.ChangeModeError);
3479
+ return;
3480
+ }
3481
+ // 纠正相机状态
3482
+ // 根据 latitude、longitude、fov 计算动画时间,最多 1s
3483
+ const { latitude, longitude, fov } = five$1.getCurrentState();
3484
+ const time = Math.min(1000, Math.max(200, Math.abs(latitude - Math.PI / 2) * 1000, (longitude > Math.PI ? 2 * Math.PI - longitude : longitude) * 500, Math.abs(fov - showState.fov) * 10));
3485
+ const [updateCameraError] = yield to(five$1.updateCamera(showState, time, userAction));
3486
+ if (updateCameraError)
3487
+ throw new Error(FloorplanErrorType.UpdateCameraError);
3430
3488
  return;
3431
- }
3432
- // 纠正相机状态
3433
- // 根据 latitude、longitude、fov 计算动画时间,最多 1s
3434
- const { latitude, longitude, fov } = five$1.getCurrentState();
3435
- const time = Math.min(1000, Math.max(200, Math.abs(latitude - Math.PI / 2) * 1000, (longitude > Math.PI ? 2 * Math.PI - longitude : longitude) * 500, Math.abs(fov - showState.fov) * 10));
3436
- const [updateCameraError] = await to(five$1.updateCamera(showState, time, userAction));
3437
- if (updateCameraError)
3438
- throw new Error(FloorplanErrorType.UpdateCameraError);
3439
- return;
3489
+ });
3440
3490
  }
3441
3491
 
3442
3492
  function changeModelCanvasOpacity(five, opacity, duration = 300) {
@@ -3486,35 +3536,446 @@ function omit(object, props) {
3486
3536
 
3487
3537
  const MODEL_FLOORPLAN_PLUGIN_NAME = 'modelFloorplanPlugin';
3488
3538
  class ModelFloorplanPluginController {
3489
- name = MODEL_FLOORPLAN_PLUGIN_NAME;
3490
- /** 用于绑定事件钩子 */
3491
- hooks;
3492
- /** 展示状态 */
3493
- visible = false;
3494
- /** 户型图大小 */
3495
- size = { width: 0, height: 0 };
3496
- app = undefined;
3497
- pxmm = 0;
3498
- five;
3499
- panoIndex = 0;
3500
- floorIndex = 0;
3501
- configs = {};
3502
- lastPanoramaLongitude = 0;
3503
- selector;
3504
- floorplanData;
3505
- wrapper;
3506
- container = document.createElement('div');
3507
- showState;
3508
- /** 记录上次 show 的参数,如果不一致,需要 reject 掉正在进行的 showPromise */
3509
- ModelFloorplanPluginsShowOpts;
3510
- showPromise;
3511
- showRejection;
3512
3539
  constructor(five$1, params) {
3540
+ var _a;
3541
+ Object.defineProperty(this, "name", {
3542
+ enumerable: true,
3543
+ configurable: true,
3544
+ writable: true,
3545
+ value: MODEL_FLOORPLAN_PLUGIN_NAME
3546
+ });
3547
+ /** 用于绑定事件钩子 */
3548
+ Object.defineProperty(this, "hooks", {
3549
+ enumerable: true,
3550
+ configurable: true,
3551
+ writable: true,
3552
+ value: void 0
3553
+ });
3554
+ /** 展示状态 */
3555
+ Object.defineProperty(this, "visible", {
3556
+ enumerable: true,
3557
+ configurable: true,
3558
+ writable: true,
3559
+ value: false
3560
+ });
3561
+ /** 户型图大小 */
3562
+ Object.defineProperty(this, "size", {
3563
+ enumerable: true,
3564
+ configurable: true,
3565
+ writable: true,
3566
+ value: { width: 0, height: 0 }
3567
+ });
3568
+ Object.defineProperty(this, "app", {
3569
+ enumerable: true,
3570
+ configurable: true,
3571
+ writable: true,
3572
+ value: undefined
3573
+ });
3574
+ Object.defineProperty(this, "pxmm", {
3575
+ enumerable: true,
3576
+ configurable: true,
3577
+ writable: true,
3578
+ value: 0
3579
+ });
3580
+ Object.defineProperty(this, "five", {
3581
+ enumerable: true,
3582
+ configurable: true,
3583
+ writable: true,
3584
+ value: void 0
3585
+ });
3586
+ Object.defineProperty(this, "panoIndex", {
3587
+ enumerable: true,
3588
+ configurable: true,
3589
+ writable: true,
3590
+ value: 0
3591
+ });
3592
+ Object.defineProperty(this, "floorIndex", {
3593
+ enumerable: true,
3594
+ configurable: true,
3595
+ writable: true,
3596
+ value: 0
3597
+ });
3598
+ Object.defineProperty(this, "configs", {
3599
+ enumerable: true,
3600
+ configurable: true,
3601
+ writable: true,
3602
+ value: {}
3603
+ });
3604
+ Object.defineProperty(this, "lastPanoramaLongitude", {
3605
+ enumerable: true,
3606
+ configurable: true,
3607
+ writable: true,
3608
+ value: 0
3609
+ });
3610
+ Object.defineProperty(this, "selector", {
3611
+ enumerable: true,
3612
+ configurable: true,
3613
+ writable: true,
3614
+ value: void 0
3615
+ });
3616
+ Object.defineProperty(this, "floorplanData", {
3617
+ enumerable: true,
3618
+ configurable: true,
3619
+ writable: true,
3620
+ value: void 0
3621
+ });
3622
+ Object.defineProperty(this, "wrapper", {
3623
+ enumerable: true,
3624
+ configurable: true,
3625
+ writable: true,
3626
+ value: void 0
3627
+ });
3628
+ Object.defineProperty(this, "container", {
3629
+ enumerable: true,
3630
+ configurable: true,
3631
+ writable: true,
3632
+ value: document.createElement('div')
3633
+ });
3634
+ Object.defineProperty(this, "showState", {
3635
+ enumerable: true,
3636
+ configurable: true,
3637
+ writable: true,
3638
+ value: void 0
3639
+ });
3640
+ /** 记录上次 show 的参数,如果不一致,需要 reject 掉正在进行的 showPromise */
3641
+ Object.defineProperty(this, "ModelFloorplanPluginsShowOpts", {
3642
+ enumerable: true,
3643
+ configurable: true,
3644
+ writable: true,
3645
+ value: void 0
3646
+ });
3647
+ Object.defineProperty(this, "showPromise", {
3648
+ enumerable: true,
3649
+ configurable: true,
3650
+ writable: true,
3651
+ value: void 0
3652
+ });
3653
+ Object.defineProperty(this, "showRejection", {
3654
+ enumerable: true,
3655
+ configurable: true,
3656
+ writable: true,
3657
+ value: void 0
3658
+ });
3659
+ Object.defineProperty(this, "dispose", {
3660
+ enumerable: true,
3661
+ configurable: true,
3662
+ writable: true,
3663
+ value: () => {
3664
+ var _a, _b;
3665
+ const five = this.five;
3666
+ this.hide();
3667
+ (_a = this.app) === null || _a === void 0 ? void 0 : _a.$destroy();
3668
+ (_b = this.container) === null || _b === void 0 ? void 0 : _b.remove();
3669
+ five.off('modelLoaded', this.handleModelLoaded);
3670
+ five.off('modeChange', this.handleModeChange);
3671
+ five.off('panGesture', this.handlePanGesture);
3672
+ five.off('panoArrived', this.handlePanoArrived);
3673
+ five.off('wantsChangeMode', this.handleWantsChangeMode);
3674
+ five.off('wantsInteriaPan', this.handleWantsInteriaPan);
3675
+ five.off('wantsTapGesture', this.handleWantsTapGesture);
3676
+ five.off('modelShownFloorChange', this.onModelShownFloorChange);
3677
+ }
3678
+ });
3679
+ /** 更新户型图大小 */
3680
+ Object.defineProperty(this, "updateSize", {
3681
+ enumerable: true,
3682
+ configurable: true,
3683
+ writable: true,
3684
+ value: () => {
3685
+ if (!this.floorplanData)
3686
+ return;
3687
+ if (!checkShowState(this.five, this.showState))
3688
+ return;
3689
+ if (!this.container || !this.wrapper)
3690
+ return;
3691
+ // 计算户型图展示大小
3692
+ const { min, max } = this.floorplanData.bounding;
3693
+ const width = max.x - min.x;
3694
+ const height = max.y - min.y;
3695
+ // 每毫米对应的 px 值
3696
+ const options = this.configs.attachedTo ? { attachedTo: this.configs.attachedTo } : undefined;
3697
+ const pxmm = getPxmm(this.five, this.wrapper, this.floorIndex, options);
3698
+ const _width = Math.ceil(width * pxmm);
3699
+ const _height = Math.ceil(height * pxmm);
3700
+ if (this.size.width === _width && this.size.height === _height)
3701
+ return;
3702
+ this.pxmm = pxmm;
3703
+ this.size = { width: _width, height: _height };
3704
+ this.container.style.width = _width + 'px';
3705
+ this.container.style.height = _height + 'px';
3706
+ }
3707
+ });
3708
+ /** 展示户型图
3709
+ * 1. show 函数大部分情况下需要耗时
3710
+ * 2. 如果当前已经在展示中,将不会触发任何事件
3711
+ * 3. 如果展示过程被中断,将抛出错误
3712
+ * 4. 多次调用 show 方法,只会触发一次 showAnimationEnded 事件,但是展示结果会取决于最后一次调用参数
3713
+ * 5. 如果多次调用 show 方法,参数与上次参数不一致时,上次 show Promise 会被 reject
3714
+ * @param opts.floorIndex 楼层
3715
+ * @param opts.modelOpacity 模型透明度
3716
+ * @param opts.immediately 是否立即展示
3717
+ * @param opts.isAutoShow 是否是自动展示
3718
+ */
3719
+ Object.defineProperty(this, "show", {
3720
+ enumerable: true,
3721
+ configurable: true,
3722
+ writable: true,
3723
+ value: (opts) => __awaiter(this, void 0, void 0, function* () {
3724
+ var _b, _c;
3725
+ // 已经在展示中了
3726
+ if (!this.showPromise && this.visible)
3727
+ return true;
3728
+ if (!((_b = this.five.model) === null || _b === void 0 ? void 0 : _b.loaded))
3729
+ throw new Error(FloorplanErrorType.ModelNotLoaded);
3730
+ if (!this.floorplanData)
3731
+ throw new Error(FloorplanErrorType.DataNotLoaded);
3732
+ this.visible = true;
3733
+ if (this.showPromise) {
3734
+ const sameWithLastOpts = equal(opts, this.ModelFloorplanPluginsShowOpts, { deep: false });
3735
+ if (!!this.showPromise && sameWithLastOpts)
3736
+ return this.showPromise;
3737
+ if (!!this.showPromise && !sameWithLastOpts)
3738
+ (_c = this.showRejection) === null || _c === void 0 ? void 0 : _c.call(this, FloorplanErrorType.DifferentShowParams);
3739
+ }
3740
+ this.ModelFloorplanPluginsShowOpts = opts;
3741
+ const getShowPromise = () => __awaiter(this, void 0, void 0, function* () {
3742
+ var _d, _e;
3743
+ let hasRejected = false;
3744
+ let externalErrorMsg;
3745
+ this.showRejection = (errorMsg) => {
3746
+ hasRejected = true;
3747
+ externalErrorMsg = errorMsg;
3748
+ };
3749
+ const [correctError] = yield to(correctFiveState(this.five, this.showState, opts === null || opts === void 0 ? void 0 : opts.userAction));
3750
+ if (correctError)
3751
+ throw correctError;
3752
+ // 异步结束要判断当前是不是被中断了,是不是调用了隐藏
3753
+ if (hasRejected)
3754
+ throw externalErrorMsg ? new Error(externalErrorMsg) : new Error(FloorplanErrorType.UnknownError);
3755
+ if (!this.visible)
3756
+ throw new Error(FloorplanErrorType.UnknownError);
3757
+ // 更新户型图状态
3758
+ this.visible = true;
3759
+ // 更新户型图大小
3760
+ this.updateSize();
3761
+ // 高亮当前楼层,有两个目的
3762
+ // 1. 点击模型时,可以跳转到当前楼层的点位上
3763
+ // 2. 当前楼层比较小时,户型图也比较小,如果展示全部楼层,会展示户型图外有一圈模型
3764
+ if (opts === null || opts === void 0 ? void 0 : opts.floorIndex)
3765
+ this.floorIndex = opts.floorIndex;
3766
+ this.five.model.show(this.floorIndex);
3767
+ // 模型消失, 渲染户型图
3768
+ const modelOpacity = (_e = (_d = opts === null || opts === void 0 ? void 0 : opts.modelOpacity) !== null && _d !== void 0 ? _d : this.configs.modelOpacity) !== null && _e !== void 0 ? _e : 1;
3769
+ const renderDuration = (opts === null || opts === void 0 ? void 0 : opts.immediately) ? 0 : SHOW_ANIME_DURATION;
3770
+ changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
3771
+ this.render(renderDuration);
3772
+ // 展示之后的事件监听
3773
+ this.five.on('wantsGesture', this.handleWantsGesture);
3774
+ this.five.on('wantsTapGesture', this.handleWantsTapGesture);
3775
+ return true;
3776
+ });
3777
+ const showPromise = getShowPromise()
3778
+ .then(() => {
3779
+ var _a;
3780
+ this.hooks.emit('showAnimationEnded', { auto: !!(opts === null || opts === void 0 ? void 0 : opts.isAutoShow), userAction: (_a = opts === null || opts === void 0 ? void 0 : opts.userAction) !== null && _a !== void 0 ? _a : true });
3781
+ return true;
3782
+ })
3783
+ .catch((error) => {
3784
+ // 自动展示的报错内部处理
3785
+ if (opts === null || opts === void 0 ? void 0 : opts.isAutoShow)
3786
+ return false;
3787
+ if (!(error instanceof Error))
3788
+ return false;
3789
+ // 非自动展示的报错继续向外抛出
3790
+ throw error;
3791
+ })
3792
+ .finally(() => {
3793
+ this.showPromise = undefined;
3794
+ this.showRejection = undefined;
3795
+ });
3796
+ this.showPromise = showPromise;
3797
+ return showPromise;
3798
+ })
3799
+ });
3800
+ /** 隐藏户型图 */
3801
+ Object.defineProperty(this, "hide", {
3802
+ enumerable: true,
3803
+ configurable: true,
3804
+ writable: true,
3805
+ value: (options) => {
3806
+ var _a, _b;
3807
+ if (this.size.width === 0)
3808
+ return true;
3809
+ if (this.visible === false)
3810
+ return true;
3811
+ const isAutoHide = !!(options === null || options === void 0 ? void 0 : options.isAutoHide);
3812
+ this.five.off('wantsGesture', this.handleWantsGesture);
3813
+ this.five.off('wantsTapGesture', this.handleWantsTapGesture);
3814
+ this.visible = false;
3815
+ (_a = this.showRejection) === null || _a === void 0 ? void 0 : _a.call(this, FloorplanErrorType.BreakOffByHide);
3816
+ changeModelCanvasOpacity(this.five, 1, 0);
3817
+ this.render();
3818
+ this.hooks.emit('hide', { auto: isAutoHide, userAction: (_b = options === null || options === void 0 ? void 0 : options.userAction) !== null && _b !== void 0 ? _b : true });
3819
+ return true;
3820
+ }
3821
+ });
3822
+ /** 模型楼层高亮改变时,自动进行楼层切换 */
3823
+ Object.defineProperty(this, "onModelShownFloorChange", {
3824
+ enumerable: true,
3825
+ configurable: true,
3826
+ writable: true,
3827
+ value: (shownFloor) => {
3828
+ if (shownFloor === null)
3829
+ return;
3830
+ this.floorIndex = shownFloor;
3831
+ this.updateSize();
3832
+ this.render();
3833
+ }
3834
+ });
3835
+ Object.defineProperty(this, "handleModelLoaded", {
3836
+ enumerable: true,
3837
+ configurable: true,
3838
+ writable: true,
3839
+ value: () => {
3840
+ if (this.wrapper)
3841
+ return;
3842
+ if (!this.selector)
3843
+ return;
3844
+ const wrapper = this.selector instanceof Element ? this.selector : document.querySelector(this.selector);
3845
+ if (!wrapper)
3846
+ throw new Error('不正确的父容器选择器');
3847
+ this.wrapper = wrapper;
3848
+ wrapper.append(this.container);
3849
+ }
3850
+ });
3851
+ Object.defineProperty(this, "handleClick", {
3852
+ enumerable: true,
3853
+ configurable: true,
3854
+ writable: true,
3855
+ value: () => {
3856
+ if (!this.visible)
3857
+ return;
3858
+ const prevented = this.hooks.emit('click');
3859
+ if (prevented)
3860
+ return false;
3861
+ }
3862
+ });
3863
+ Object.defineProperty(this, "handleWantsTapGesture", {
3864
+ enumerable: true,
3865
+ configurable: true,
3866
+ writable: true,
3867
+ value: () => this.handleClick()
3868
+ });
3869
+ /** 从 Panorama 切换到其他模态时,记录当前的相机水平视角 */
3870
+ Object.defineProperty(this, "handleWantsChangeMode", {
3871
+ enumerable: true,
3872
+ configurable: true,
3873
+ writable: true,
3874
+ value: (mode) => {
3875
+ if (mode !== 'Panorama') {
3876
+ this.lastPanoramaLongitude = this.five.getCurrentState().longitude;
3877
+ }
3878
+ if (mode !== 'Floorplan')
3879
+ this.hide();
3880
+ }
3881
+ });
3882
+ /** 监听模型态变化,只有在模型态才进行手势动作监听 */
3883
+ Object.defineProperty(this, "handleModeChange", {
3884
+ enumerable: true,
3885
+ configurable: true,
3886
+ writable: true,
3887
+ value: (mode) => {
3888
+ if (mode === 'Floorplan') {
3889
+ this.five.on('panGesture', this.handlePanGesture);
3890
+ }
3891
+ else {
3892
+ this.hide();
3893
+ this.five.off('panGesture', this.handlePanGesture);
3894
+ }
3895
+ }
3896
+ });
3897
+ /** panoIndex 改变时,更新 floorIndex */
3898
+ Object.defineProperty(this, "handlePanoArrived", {
3899
+ enumerable: true,
3900
+ configurable: true,
3901
+ writable: true,
3902
+ value: (index) => {
3903
+ var _a;
3904
+ if (!((_a = this.five) === null || _a === void 0 ? void 0 : _a.work))
3905
+ return;
3906
+ this.panoIndex = index;
3907
+ this.floorIndex = this.five.work.observers[index].floorIndex;
3908
+ }
3909
+ });
3910
+ /** 当户型图正在展示中的时候禁用惯性 */
3911
+ Object.defineProperty(this, "handleWantsInteriaPan", {
3912
+ enumerable: true,
3913
+ configurable: true,
3914
+ writable: true,
3915
+ value: () => {
3916
+ if (this.visible)
3917
+ return false;
3918
+ }
3919
+ });
3920
+ /** 在户型图展示时阻止多指操作, 阻止鼠标放大 */
3921
+ Object.defineProperty(this, "handleWantsGesture", {
3922
+ enumerable: true,
3923
+ configurable: true,
3924
+ writable: true,
3925
+ value: (type, pointers) => {
3926
+ if (!this.visible)
3927
+ return;
3928
+ if (pointers.length > 1)
3929
+ return false;
3930
+ if (type === 'mouseWheel')
3931
+ return false;
3932
+ }
3933
+ });
3934
+ /** 监听三维模型滑动
3935
+ * 1. 在三维模型转动结束时,如果达到设置的阈值,会自动切换到户型图
3936
+ * 2. 如何户型图已经展示,滑动时关闭户型图
3937
+ */
3938
+ Object.defineProperty(this, "handlePanGesture", {
3939
+ enumerable: true,
3940
+ configurable: true,
3941
+ writable: true,
3942
+ value: ({ latitude, longitude }, isFinal) => __awaiter(this, void 0, void 0, function* () {
3943
+ if (this.configs.autoShowEnable === false)
3944
+ return;
3945
+ // 如果操作结束后,户型图还在展示中,初始化模型状态
3946
+ if (isFinal && this.visible)
3947
+ return this.five.setState(this.showState, true);
3948
+ // 满足消失的条件:
3949
+ // 水平旋转角大于正负 5 度 || 俯仰角度大于 5 度
3950
+ const latitudeHide = Math.abs(latitude - Math.PI / 2) > (5 * Math.PI) / 180;
3951
+ const longitudeHide = longitude > 5 * (Math.PI / 180) && longitude < 355 * (Math.PI / 180);
3952
+ const canHide = latitudeHide || longitudeHide;
3953
+ if (this.visible && canHide)
3954
+ return this.hide({ isAutoHide: true });
3955
+ if (this.five.camera.fov / FIVE_CAMERA_DEFAULT_FOV < 0.8)
3956
+ return;
3957
+ // 户型图展示条件:
3958
+ // 水平旋转角正负 30 度 && 俯仰角度小于 10 度
3959
+ const latitudeVisible = Math.abs(latitude - Math.PI / 2) < (10 * Math.PI) / 180;
3960
+ const longitudeVisible = longitude < 30 * (Math.PI / 180) || longitude > 330 * (Math.PI / 180);
3961
+ if (isFinal && !this.visible && latitudeVisible && longitudeVisible) {
3962
+ // 当手指离开时需要等惯性结束之后在进行判断
3963
+ const handleInteriaPan = (any, isFinal) => __awaiter(this, void 0, void 0, function* () {
3964
+ if (!isFinal)
3965
+ return;
3966
+ this.five.off('interiaPan', handleInteriaPan);
3967
+ yield this.show({ isAutoShow: true });
3968
+ });
3969
+ this.five.on('interiaPan', handleInteriaPan);
3970
+ return;
3971
+ }
3972
+ })
3973
+ });
3513
3974
  this.five = five$1;
3514
3975
  this.hooks = new five.Subscribe();
3515
3976
  this.selector = params.selector;
3516
3977
  this.configs = omit(params, ['selector']);
3517
- this.showState = { longitude: 0, latitude: Math.PI / 2, fov: FIVE_CAMERA_DEFAULT_FOV / (params?.scale ?? 1) };
3978
+ this.showState = { longitude: 0, latitude: Math.PI / 2, fov: FIVE_CAMERA_DEFAULT_FOV / ((_a = params === null || params === void 0 ? void 0 : params.scale) !== null && _a !== void 0 ? _a : 1) };
3518
3979
  // 设置 container 样式
3519
3980
  this.container.classList.add('floorplan-plugin');
3520
3981
  Object.assign(this.container.style, {
@@ -3534,25 +3995,13 @@ class ModelFloorplanPluginController {
3534
3995
  five$1.on('wantsInteriaPan', this.handleWantsInteriaPan);
3535
3996
  five$1.on('modelShownFloorChange', this.onModelShownFloorChange);
3536
3997
  }
3537
- dispose = () => {
3538
- const five = this.five;
3539
- this.hide();
3540
- this.app?.$destroy();
3541
- this.container?.remove();
3542
- five.off('modelLoaded', this.handleModelLoaded);
3543
- five.off('modeChange', this.handleModeChange);
3544
- five.off('panGesture', this.handlePanGesture);
3545
- five.off('panoArrived', this.handlePanoArrived);
3546
- five.off('wantsChangeMode', this.handleWantsChangeMode);
3547
- five.off('wantsInteriaPan', this.handleWantsInteriaPan);
3548
- five.off('wantsTapGesture', this.handleWantsTapGesture);
3549
- five.off('modelShownFloorChange', this.onModelShownFloorChange);
3550
- };
3551
3998
  /** 加载户型图数据 */
3552
- async load(data) {
3553
- const copyData = JSON.parse(JSON.stringify(data));
3554
- this.floorplanData = await formatData(copyData);
3555
- this.render();
3999
+ load(data) {
4000
+ return __awaiter(this, void 0, void 0, function* () {
4001
+ const copyData = JSON.parse(JSON.stringify(data));
4002
+ this.floorplanData = yield formatData(copyData);
4003
+ this.render();
4004
+ });
3556
4005
  }
3557
4006
  /** 把插件的渲染DOM插入到对应的容器中去 */
3558
4007
  appendTo(wrapper) {
@@ -3560,130 +4009,6 @@ class ModelFloorplanPluginController {
3560
4009
  wrapper.appendChild(this.container);
3561
4010
  return this;
3562
4011
  }
3563
- /** 更新户型图大小 */
3564
- updateSize = () => {
3565
- if (!this.floorplanData)
3566
- return;
3567
- if (!checkShowState(this.five, this.showState))
3568
- return;
3569
- if (!this.container || !this.wrapper)
3570
- return;
3571
- // 计算户型图展示大小
3572
- const { min, max } = this.floorplanData.bounding;
3573
- const width = max.x - min.x;
3574
- const height = max.y - min.y;
3575
- // 每毫米对应的 px 值
3576
- const options = this.configs.attachedTo ? { attachedTo: this.configs.attachedTo } : undefined;
3577
- const pxmm = getPxmm(this.five, this.wrapper, this.floorIndex, options);
3578
- const _width = Math.ceil(width * pxmm);
3579
- const _height = Math.ceil(height * pxmm);
3580
- if (this.size.width === _width && this.size.height === _height)
3581
- return;
3582
- this.pxmm = pxmm;
3583
- this.size = { width: _width, height: _height };
3584
- this.container.style.width = _width + 'px';
3585
- this.container.style.height = _height + 'px';
3586
- };
3587
- /** 展示户型图
3588
- * 1. show 函数大部分情况下需要耗时
3589
- * 2. 如果当前已经在展示中,将不会触发任何事件
3590
- * 3. 如果展示过程被中断,将抛出错误
3591
- * 4. 多次调用 show 方法,只会触发一次 showAnimationEnded 事件,但是展示结果会取决于最后一次调用参数
3592
- * 5. 如果多次调用 show 方法,参数与上次参数不一致时,上次 show Promise 会被 reject
3593
- * @param opts.floorIndex 楼层
3594
- * @param opts.modelOpacity 模型透明度
3595
- * @param opts.immediately 是否立即展示
3596
- * @param opts.isAutoShow 是否是自动展示
3597
- */
3598
- show = async (opts) => {
3599
- // 已经在展示中了
3600
- if (!this.showPromise && this.visible)
3601
- return true;
3602
- if (!this.five.model?.loaded)
3603
- throw new Error(FloorplanErrorType.ModelNotLoaded);
3604
- if (!this.floorplanData)
3605
- throw new Error(FloorplanErrorType.DataNotLoaded);
3606
- this.visible = true;
3607
- if (this.showPromise) {
3608
- const sameWithLastOpts = equal(opts, this.ModelFloorplanPluginsShowOpts, { deep: false });
3609
- if (!!this.showPromise && sameWithLastOpts)
3610
- return this.showPromise;
3611
- if (!!this.showPromise && !sameWithLastOpts)
3612
- this.showRejection?.(FloorplanErrorType.DifferentShowParams);
3613
- }
3614
- this.ModelFloorplanPluginsShowOpts = opts;
3615
- const getShowPromise = async () => {
3616
- let hasRejected = false;
3617
- let externalErrorMsg;
3618
- this.showRejection = (errorMsg) => {
3619
- hasRejected = true;
3620
- externalErrorMsg = errorMsg;
3621
- };
3622
- const [correctError] = await to(correctFiveState(this.five, this.showState, opts?.userAction));
3623
- if (correctError)
3624
- throw correctError;
3625
- // 异步结束要判断当前是不是被中断了,是不是调用了隐藏
3626
- if (hasRejected)
3627
- throw externalErrorMsg ? new Error(externalErrorMsg) : new Error(FloorplanErrorType.UnknownError);
3628
- if (!this.visible)
3629
- throw new Error(FloorplanErrorType.UnknownError);
3630
- // 更新户型图状态
3631
- this.visible = true;
3632
- // 更新户型图大小
3633
- this.updateSize();
3634
- // 高亮当前楼层,有两个目的
3635
- // 1. 点击模型时,可以跳转到当前楼层的点位上
3636
- // 2. 当前楼层比较小时,户型图也比较小,如果展示全部楼层,会展示户型图外有一圈模型
3637
- if (opts?.floorIndex)
3638
- this.floorIndex = opts.floorIndex;
3639
- this.five.model.show(this.floorIndex);
3640
- // 模型消失, 渲染户型图
3641
- const modelOpacity = opts?.modelOpacity ?? this.configs.modelOpacity ?? 1;
3642
- const renderDuration = opts?.immediately ? 0 : SHOW_ANIME_DURATION;
3643
- changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
3644
- this.render(renderDuration);
3645
- // 展示之后的事件监听
3646
- this.five.on('wantsGesture', this.handleWantsGesture);
3647
- this.five.on('wantsTapGesture', this.handleWantsTapGesture);
3648
- return true;
3649
- };
3650
- const showPromise = getShowPromise()
3651
- .then(() => {
3652
- this.hooks.emit('showAnimationEnded', { auto: !!opts?.isAutoShow, userAction: opts?.userAction ?? true });
3653
- return true;
3654
- })
3655
- .catch((error) => {
3656
- // 自动展示的报错内部处理
3657
- if (opts?.isAutoShow)
3658
- return false;
3659
- if (!(error instanceof Error))
3660
- return false;
3661
- // 非自动展示的报错继续向外抛出
3662
- throw error;
3663
- })
3664
- .finally(() => {
3665
- this.showPromise = undefined;
3666
- this.showRejection = undefined;
3667
- });
3668
- this.showPromise = showPromise;
3669
- return showPromise;
3670
- };
3671
- /** 隐藏户型图 */
3672
- hide = (options) => {
3673
- if (this.size.width === 0)
3674
- return true;
3675
- if (this.visible === false)
3676
- return true;
3677
- const isAutoHide = !!options?.isAutoHide;
3678
- this.five.off('wantsGesture', this.handleWantsGesture);
3679
- this.five.off('wantsTapGesture', this.handleWantsTapGesture);
3680
- this.visible = false;
3681
- this.showRejection?.(FloorplanErrorType.BreakOffByHide);
3682
- changeModelCanvasOpacity(this.five, 1, 0);
3683
- this.render();
3684
- this.hooks.emit('hide', { auto: isAutoHide, userAction: options?.userAction ?? true });
3685
- return true;
3686
- };
3687
4012
  /** 更改户型图楼层 */
3688
4013
  changeFloor(floorIndex) {
3689
4014
  this.five.model.show(floorIndex);
@@ -3696,107 +4021,6 @@ class ModelFloorplanPluginController {
3696
4021
  return;
3697
4022
  this.render();
3698
4023
  }
3699
- /** 模型楼层高亮改变时,自动进行楼层切换 */
3700
- onModelShownFloorChange = (shownFloor) => {
3701
- if (shownFloor === null)
3702
- return;
3703
- this.floorIndex = shownFloor;
3704
- this.updateSize();
3705
- this.render();
3706
- };
3707
- handleModelLoaded = () => {
3708
- if (this.wrapper)
3709
- return;
3710
- if (!this.selector)
3711
- return;
3712
- const wrapper = this.selector instanceof Element ? this.selector : document.querySelector(this.selector);
3713
- if (!wrapper)
3714
- throw new Error('不正确的父容器选择器');
3715
- this.wrapper = wrapper;
3716
- wrapper.append(this.container);
3717
- };
3718
- handleClick = () => {
3719
- if (!this.visible)
3720
- return;
3721
- const prevented = this.hooks.emit('click');
3722
- if (prevented)
3723
- return false;
3724
- };
3725
- handleWantsTapGesture = () => this.handleClick();
3726
- /** 从 Panorama 切换到其他模态时,记录当前的相机水平视角 */
3727
- handleWantsChangeMode = (mode) => {
3728
- if (mode !== 'Panorama') {
3729
- this.lastPanoramaLongitude = this.five.getCurrentState().longitude;
3730
- }
3731
- if (mode !== 'Floorplan')
3732
- this.hide();
3733
- };
3734
- /** 监听模型态变化,只有在模型态才进行手势动作监听 */
3735
- handleModeChange = (mode) => {
3736
- if (mode === 'Floorplan') {
3737
- this.five.on('panGesture', this.handlePanGesture);
3738
- }
3739
- else {
3740
- this.hide();
3741
- this.five.off('panGesture', this.handlePanGesture);
3742
- }
3743
- };
3744
- /** panoIndex 改变时,更新 floorIndex */
3745
- handlePanoArrived = (index) => {
3746
- if (!this.five?.work)
3747
- return;
3748
- this.panoIndex = index;
3749
- this.floorIndex = this.five.work.observers[index].floorIndex;
3750
- };
3751
- /** 当户型图正在展示中的时候禁用惯性 */
3752
- handleWantsInteriaPan = () => {
3753
- if (this.visible)
3754
- return false;
3755
- };
3756
- /** 在户型图展示时阻止多指操作, 阻止鼠标放大 */
3757
- handleWantsGesture = (type, pointers) => {
3758
- if (!this.visible)
3759
- return;
3760
- if (pointers.length > 1)
3761
- return false;
3762
- if (type === 'mouseWheel')
3763
- return false;
3764
- };
3765
- /** 监听三维模型滑动
3766
- * 1. 在三维模型转动结束时,如果达到设置的阈值,会自动切换到户型图
3767
- * 2. 如何户型图已经展示,滑动时关闭户型图
3768
- */
3769
- handlePanGesture = async ({ latitude, longitude }, isFinal) => {
3770
- if (this.configs.autoShowEnable === false)
3771
- return;
3772
- // 如果操作结束后,户型图还在展示中,初始化模型状态
3773
- if (isFinal && this.visible)
3774
- return this.five.setState(this.showState, true);
3775
- // 满足消失的条件:
3776
- // 水平旋转角大于正负 5 度 || 俯仰角度大于 5 度
3777
- const latitudeHide = Math.abs(latitude - Math.PI / 2) > (5 * Math.PI) / 180;
3778
- const longitudeHide = longitude > 5 * (Math.PI / 180) && longitude < 355 * (Math.PI / 180);
3779
- const canHide = latitudeHide || longitudeHide;
3780
- if (this.visible && canHide)
3781
- return this.hide({ isAutoHide: true });
3782
- if (this.five.camera.fov / FIVE_CAMERA_DEFAULT_FOV < 0.8)
3783
- return;
3784
- // 户型图展示条件:
3785
- // 水平旋转角正负 30 度 && 俯仰角度小于 10 度
3786
- const latitudeVisible = Math.abs(latitude - Math.PI / 2) < (10 * Math.PI) / 180;
3787
- const longitudeVisible = longitude < 30 * (Math.PI / 180) || longitude > 330 * (Math.PI / 180);
3788
- if (isFinal && !this.visible && latitudeVisible && longitudeVisible) {
3789
- // 当手指离开时需要等惯性结束之后在进行判断
3790
- const handleInteriaPan = async (any, isFinal) => {
3791
- if (!isFinal)
3792
- return;
3793
- this.five.off('interiaPan', handleInteriaPan);
3794
- await this.show({ isAutoShow: true });
3795
- };
3796
- this.five.on('interiaPan', handleInteriaPan);
3797
- return;
3798
- }
3799
- };
3800
4024
  render(duration) {
3801
4025
  if (!this.container || !this.floorplanData)
3802
4026
  return;
@@ -3804,19 +4028,19 @@ class ModelFloorplanPluginController {
3804
4028
  return;
3805
4029
  const { northDesc, hoverEnable, cameraImageUrl, getLabelElement, roomLabelsEnable, compassEnable, ruleLabelsEnable } = this.configs;
3806
4030
  const props = {
3807
- northDesc: northDesc ?? '北',
4031
+ northDesc: northDesc !== null && northDesc !== void 0 ? northDesc : '北',
3808
4032
  five: this.five,
3809
4033
  pxmm: this.pxmm,
3810
4034
  cameraImageUrl,
3811
4035
  visible: this.visible,
3812
- duration: duration ?? 0,
4036
+ duration: duration !== null && duration !== void 0 ? duration : 0,
3813
4037
  panoIndex: this.panoIndex,
3814
4038
  floorIndex: this.floorIndex,
3815
4039
  floorplanData: this.floorplanData,
3816
- hoverEnable: hoverEnable ?? false,
3817
- compassEnable: compassEnable ?? true,
3818
- ruleLabelsEnable: ruleLabelsEnable ?? true,
3819
- roomLabelsEnable: roomLabelsEnable ?? true,
4040
+ hoverEnable: hoverEnable !== null && hoverEnable !== void 0 ? hoverEnable : false,
4041
+ compassEnable: compassEnable !== null && compassEnable !== void 0 ? compassEnable : true,
4042
+ ruleLabelsEnable: ruleLabelsEnable !== null && ruleLabelsEnable !== void 0 ? ruleLabelsEnable : true,
4043
+ roomLabelsEnable: roomLabelsEnable !== null && roomLabelsEnable !== void 0 ? roomLabelsEnable : true,
3820
4044
  lastPanoramaLongitude: this.lastPanoramaLongitude,
3821
4045
  getLabelElement,
3822
4046
  onRoomHeightClick: this.handleClick,