@realsee/dnalogel 2.0.0-alpha.42 → 2.0.0-alpha.43

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 (130) hide show
  1. package/dist/CSS3DRenderPlugin/PanoCompassPlugin/index.d.ts +1 -1
  2. package/dist/CameraMovementPlugin/PanoCompassPlugin/index.d.ts +1 -1
  3. package/dist/CameraMovementPlugin/index.js +15 -40
  4. package/dist/ItemLabelPlugin/PanoCompassPlugin/index.d.ts +1 -1
  5. package/dist/ModelChassisCompassPlugin/PanoCompassPlugin/index.d.ts +1 -1
  6. package/dist/ModelChassisCompassPlugin/index.js +5 -30
  7. package/dist/ModelEntryDoorGuidePlugin/PanoCompassPlugin/index.d.ts +1 -1
  8. package/dist/ModelEntryDoorGuidePlugin/index.js +8 -33
  9. package/dist/ModelItemLabelPlugin/PanoCompassPlugin/index.d.ts +1 -1
  10. package/dist/ModelRoomLabelPlugin/PanoCompassPlugin/index.d.ts +1 -1
  11. package/dist/ModelTVVideoPlugin/PanoCompassPlugin/index.d.ts +1 -1
  12. package/dist/ModelTVVideoPlugin/index.js +3 -28
  13. package/dist/ModelViewPlugin/PanoCompassPlugin/index.d.ts +1 -1
  14. package/dist/PanoCompassPlugin/PanoCompassPlugin/index.d.ts +1 -1
  15. package/dist/PanoCompassPlugin/index.d.ts +1 -1
  16. package/dist/PanoCompassPlugin/index.js +64 -99
  17. package/dist/PanoCursorRaycasterPlugin/PanoCompassPlugin/index.d.ts +1 -1
  18. package/dist/PanoMeasurePlugin/PanoCompassPlugin/index.d.ts +1 -1
  19. package/dist/PanoRulerPlugin/PanoCompassPlugin/index.d.ts +1 -1
  20. package/dist/PanoRulerPlugin/index.js +3 -28
  21. package/dist/PanoRulerProPlugin/PanoCompassPlugin/index.d.ts +1 -1
  22. package/dist/PanoRulerProPlugin/index.js +29 -58
  23. package/dist/PanoSpatialTagPlugin/PanoCompassPlugin/index.d.ts +1 -1
  24. package/dist/floorplan/ModelFloorplanPlugin/PanoCompassPlugin/index.d.ts +1 -1
  25. package/dist/floorplan/ModelFloorplanPlugin/index.js +115 -156
  26. package/dist/floorplan/PanoFloorplanRadarPlugin/PanoCompassPlugin/index.d.ts +1 -1
  27. package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +71 -110
  28. package/dist/floorplan/TopviewFloorplanPlugin/PanoCompassPlugin/index.d.ts +1 -1
  29. package/dist/floorplan/TopviewFloorplanPlugin/index.js +114 -159
  30. package/dist/index.es.js +341 -416
  31. package/dist/index.js +341 -416
  32. package/dist/index.umd.js +341 -416
  33. package/docs/assets/search.js +1 -1
  34. package/docs/classes/Magnifier.html +4 -4
  35. package/docs/classes/ModelRoomLabelController.html +4 -4
  36. package/docs/enums/CameraMovementEffect.html +2 -2
  37. package/docs/enums/DIRECTION.html +1 -1
  38. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
  39. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  40. package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
  41. package/docs/enums/Rotation.html +2 -2
  42. package/docs/index.html +2 -2
  43. package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
  44. package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
  45. package/docs/interfaces/FloorplanBounding.html +4 -4
  46. package/docs/interfaces/FloorplanData.html +2 -2
  47. package/docs/interfaces/FloorplanEntrance.html +7 -7
  48. package/docs/interfaces/FloorplanExtraObject.html +3 -3
  49. package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
  50. package/docs/interfaces/FloorplanFloorData.html +2 -2
  51. package/docs/interfaces/FloorplanImagePosition.html +2 -2
  52. package/docs/interfaces/FloorplanObserver.html +2 -2
  53. package/docs/interfaces/FloorplanOutlineItem.html +2 -2
  54. package/docs/interfaces/FloorplanPosition.html +2 -2
  55. package/docs/interfaces/FloorplanRoomItem.html +6 -6
  56. package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
  57. package/docs/interfaces/FloorplanServerBounding.html +4 -4
  58. package/docs/interfaces/FloorplanServerComputedData.html +1 -1
  59. package/docs/interfaces/FloorplanServerData.html +2 -2
  60. package/docs/interfaces/FloorplanServerEntrance.html +7 -7
  61. package/docs/interfaces/FloorplanServerFloorData.html +2 -2
  62. package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
  63. package/docs/interfaces/FloorplanServerObserver.html +2 -2
  64. package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
  65. package/docs/interfaces/FloorplanServerPosition.html +2 -2
  66. package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
  67. package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
  68. package/docs/interfaces/ItemLabelPluginData.html +1 -1
  69. package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
  70. package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
  71. package/docs/interfaces/LineJson.html +1 -1
  72. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  73. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  74. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  75. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  76. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  77. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  78. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  79. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  80. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  81. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  82. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  83. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  84. package/docs/interfaces/ModelViewPluginExportType.html +1 -1
  85. package/docs/interfaces/OpenParameter.html +2 -2
  86. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  87. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
  88. package/docs/interfaces/PanoMeasureParameterType.html +1 -1
  89. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  90. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  91. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  92. package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
  93. package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
  94. package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
  95. package/docs/interfaces/PanoRulerProPluginState.html +1 -1
  96. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
  97. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
  98. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  99. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
  100. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  101. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
  102. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  103. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
  104. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
  105. package/docs/interfaces/Point.html +1 -1
  106. package/docs/interfaces/PointJson.html +1 -1
  107. package/docs/interfaces/Room.html +1 -1
  108. package/docs/interfaces/RoomInfo.html +1 -1
  109. package/docs/interfaces/RoomLabel.html +7 -7
  110. package/docs/interfaces/RoomRules.html +1 -1
  111. package/docs/interfaces/Rooms.html +1 -1
  112. package/docs/modules.html +18 -18
  113. package/libs/CameraMovementPlugin/CameraMovementPlugin.js +15 -24
  114. package/libs/ModelChassisCompassPlugin/Plugin.js +5 -14
  115. package/libs/ModelEntryDoorGuidePlugin/Plugin.js +8 -17
  116. package/libs/ModelTVVideoPlugin/Plugin.js +3 -12
  117. package/libs/PanoCompassPlugin/controller.js +56 -73
  118. package/libs/PanoCompassPlugin/index.d.ts +1 -1
  119. package/libs/PanoRulerPlugin/Plugin.js +3 -12
  120. package/libs/PanoRulerProPlugin/Controller.js +29 -42
  121. package/libs/floorplan/ModelFloorplanPlugin/Controller.js +29 -42
  122. package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +43 -60
  123. package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +58 -79
  124. package/libs/floorplan/utils/correctFiveState.js +20 -31
  125. package/libs/floorplan/utils/formatData.js +28 -43
  126. package/libs/shared-utils/five/changeMode.js +28 -39
  127. package/libs/shared-utils/three/loadFbxObj.js +9 -20
  128. package/libs/shared-utils/three/loadTexture.js +6 -17
  129. package/libs/shared-utils/to.js +10 -21
  130. package/package.json +14 -14
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import to from '../../shared-utils/to';
11
2
  import equal from '../../shared-utils/equal';
12
3
  import Main from '../Components/Main';
@@ -185,7 +176,7 @@ export class Controller extends BasePlugin.Controller {
185
176
  enumerable: true,
186
177
  configurable: true,
187
178
  writable: true,
188
- value: (options = {}) => __awaiter(this, void 0, void 0, function* () {
179
+ value: async (options = {}) => {
189
180
  if (!this.state.enabled)
190
181
  return;
191
182
  // 已经展示完成了,不做任何操作
@@ -194,14 +185,14 @@ export class Controller extends BasePlugin.Controller {
194
185
  const userAction = options.userAction !== undefined ? options.userAction : true;
195
186
  this.updateState({ visible: true }, userAction);
196
187
  this._show(options);
197
- })
188
+ }
198
189
  });
199
190
  /** 隐藏户型图 */
200
191
  Object.defineProperty(this, "hide", {
201
192
  enumerable: true,
202
193
  configurable: true,
203
194
  writable: true,
204
- value: (options = {}) => __awaiter(this, void 0, void 0, function* () {
195
+ value: async (options = {}) => {
205
196
  if (!this.state.enabled)
206
197
  return;
207
198
  this.isHiddenByHideFunc = true;
@@ -209,7 +200,7 @@ export class Controller extends BasePlugin.Controller {
209
200
  return;
210
201
  this.updateState({ visible: false }, options.userAction || true);
211
202
  this._hide(options);
212
- })
203
+ }
213
204
  });
214
205
  /** 更新户型图大小 */
215
206
  Object.defineProperty(this, "updateSize", {
@@ -275,11 +266,11 @@ export class Controller extends BasePlugin.Controller {
275
266
  enumerable: true,
276
267
  configurable: true,
277
268
  writable: true,
278
- value: (options) => __awaiter(this, void 0, void 0, function* () {
279
- var _b;
269
+ value: async (options) => {
270
+ var _a;
280
271
  if (!this.state.enabled)
281
272
  return;
282
- if (!((_b = this.five.model) === null || _b === void 0 ? void 0 : _b.loaded))
273
+ if (!((_a = this.five.model) === null || _a === void 0 ? void 0 : _a.loaded))
283
274
  throw new Error(FloorplanErrorType.ModelNotLoaded);
284
275
  if (!this.data)
285
276
  throw new Error(FloorplanErrorType.DataNotLoaded);
@@ -293,7 +284,7 @@ export class Controller extends BasePlugin.Controller {
293
284
  userAction: true,
294
285
  };
295
286
  const mergedOptions = Object.assign(Object.assign({}, baseShowOpts), options);
296
- const getShowPromise = () => __awaiter(this, void 0, void 0, function* () {
287
+ const getShowPromise = async () => {
297
288
  this.hooks.emit('show', { userAction: mergedOptions.userAction, auto: mergedOptions.isAutoShow });
298
289
  let hasRejected = false;
299
290
  let externalErrorMsg;
@@ -301,7 +292,7 @@ export class Controller extends BasePlugin.Controller {
301
292
  hasRejected = true;
302
293
  externalErrorMsg = errorMsg;
303
294
  };
304
- const [correctError] = yield to(correctFiveState(this.five, this.showState, mergedOptions.userAction));
295
+ const [correctError] = await to(correctFiveState(this.five, this.showState, mergedOptions.userAction));
305
296
  if (correctError)
306
297
  throw correctError;
307
298
  // 异步结束要判断当前是不是被中断了
@@ -319,7 +310,7 @@ export class Controller extends BasePlugin.Controller {
319
310
  const renderDuration = mergedOptions.immediately ? 0 : SHOW_ANIME_DURATION;
320
311
  changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
321
312
  this.render(renderDuration);
322
- });
313
+ };
323
314
  this.showPromise = getShowPromise()
324
315
  .then(() => {
325
316
  this.hooks.emit('showAnimationEnded', {
@@ -341,7 +332,7 @@ export class Controller extends BasePlugin.Controller {
341
332
  this.showRejection = undefined;
342
333
  });
343
334
  return this.showPromise;
344
- })
335
+ }
345
336
  });
346
337
  Object.defineProperty(this, "_hide", {
347
338
  enumerable: true,
@@ -575,24 +566,22 @@ export class Controller extends BasePlugin.Controller {
575
566
  five.once('dispose', this.dispose);
576
567
  this.addEventListener();
577
568
  }
578
- load(serverData, state, userAction = true) {
579
- return __awaiter(this, void 0, void 0, function* () {
580
- function isPluginServerData(serverData) {
581
- return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
582
- }
583
- const _data = serverData;
584
- if (_data && !_data.version)
585
- console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
586
- const copyData = JSON.parse(JSON.stringify(serverData));
587
- const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
588
- const prevData = this.data;
589
- this.data = yield formatData(_serverData);
590
- this.hooks.emit('dataLoaded', this.data);
591
- this.hooks.emit('dataChange', this.data, prevData);
592
- if (state)
593
- this.updateState(state, userAction);
594
- this.render();
595
- });
569
+ async load(serverData, state, userAction = true) {
570
+ function isPluginServerData(serverData) {
571
+ return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
572
+ }
573
+ const _data = serverData;
574
+ if (_data && !_data.version)
575
+ console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
576
+ const copyData = JSON.parse(JSON.stringify(serverData));
577
+ const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
578
+ const prevData = this.data;
579
+ this.data = await formatData(_serverData);
580
+ this.hooks.emit('dataLoaded', this.data);
581
+ this.hooks.emit('dataChange', this.data, prevData);
582
+ if (state)
583
+ this.updateState(state, userAction);
584
+ this.render();
596
585
  }
597
586
  /** 把插件的渲染DOM插入到对应的容器中去 */
598
587
  appendTo(wrapper) {
@@ -640,10 +629,8 @@ export class Controller extends BasePlugin.Controller {
640
629
  return;
641
630
  this.render();
642
631
  }
643
- formatData(serverData) {
644
- return __awaiter(this, void 0, void 0, function* () {
645
- return yield formatData(serverData.data);
646
- });
632
+ async formatData(serverData) {
633
+ return await formatData(serverData.data);
647
634
  }
648
635
  updateState(state, userAction) {
649
636
  const prevState = this.state;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import Main from './Components/Main';
11
2
  import equal from '../../shared-utils/equal';
12
3
  import { CAMERA_IMAGE } from '../Assets/camera';
@@ -110,55 +101,49 @@ export class Controller extends BasePlugin.Controller {
110
101
  // =============== init Listener ===============
111
102
  five.once('dispose', this.dispose);
112
103
  }
113
- load(serverData, state, userAction = true) {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- // const loadImage = async () => {
116
- // const floorIndex = this.five.work.observers[this.five.getCurrentState().panoIndex].floorIndex
117
- // // 当有 svgString 时,没有加载过程
118
- // if (floorplanData.outlines[floorIndex]?.svgContent) return
119
- // // 如果当前楼层图片不存在,不存在加载过程
120
- // const nowFloorImageSrc = floorplanData.outlines[floorIndex]?.url
121
- // if (!nowFloorImageSrc) return
122
- // // 图片加载完成时再 render
123
- // await new Promise<void>((resolve) => {
124
- // const nowFloorImage = new Image()
125
- // nowFloorImage.src = nowFloorImageSrc
126
- // nowFloorImage.onload = () => resolve()
127
- // })
128
- // }
129
- // await loadImage()
130
- function isPluginServerData(serverData) {
131
- return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
132
- }
133
- const copyData = JSON.parse(JSON.stringify(serverData));
134
- const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
135
- const prevData = this.data;
136
- this.data = yield formatData(_serverData);
137
- this.hooks.emit('dataLoaded', this.data);
138
- this.hooks.emit('dataChange', this.data, prevData);
139
- if (state)
140
- this.updateState(state, userAction);
141
- this.render();
142
- });
104
+ async load(serverData, state, userAction = true) {
105
+ // const loadImage = async () => {
106
+ // const floorIndex = this.five.work.observers[this.five.getCurrentState().panoIndex].floorIndex
107
+ // // 当有 svgString 时,没有加载过程
108
+ // if (floorplanData.outlines[floorIndex]?.svgContent) return
109
+ // // 如果当前楼层图片不存在,不存在加载过程
110
+ // const nowFloorImageSrc = floorplanData.outlines[floorIndex]?.url
111
+ // if (!nowFloorImageSrc) return
112
+ // // 图片加载完成时再 render
113
+ // await new Promise<void>((resolve) => {
114
+ // const nowFloorImage = new Image()
115
+ // nowFloorImage.src = nowFloorImageSrc
116
+ // nowFloorImage.onload = () => resolve()
117
+ // })
118
+ // }
119
+ // await loadImage()
120
+ function isPluginServerData(serverData) {
121
+ return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
122
+ }
123
+ const copyData = JSON.parse(JSON.stringify(serverData));
124
+ const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
125
+ const prevData = this.data;
126
+ this.data = await formatData(_serverData);
127
+ this.hooks.emit('dataLoaded', this.data);
128
+ this.hooks.emit('dataChange', this.data, prevData);
129
+ if (state)
130
+ this.updateState(state, userAction);
131
+ this.render();
143
132
  }
144
- show(options = {}) {
145
- return __awaiter(this, void 0, void 0, function* () {
146
- // 已经展示完成了,不做任何操作
147
- if (this.state.visible)
148
- return;
149
- const userAction = options.userAction !== undefined ? options.userAction : true;
150
- this.updateState({ visible: true }, userAction);
151
- this._show({ userAction });
152
- });
133
+ async show(options = {}) {
134
+ // 已经展示完成了,不做任何操作
135
+ if (this.state.visible)
136
+ return;
137
+ const userAction = options.userAction !== undefined ? options.userAction : true;
138
+ this.updateState({ visible: true }, userAction);
139
+ this._show({ userAction });
153
140
  }
154
- hide(options = {}) {
155
- return __awaiter(this, void 0, void 0, function* () {
156
- if (!this.state.visible)
157
- return;
158
- const userAction = options.userAction !== undefined ? options.userAction : true;
159
- this.updateState({ visible: false }, userAction);
160
- this._hide({ userAction });
161
- });
141
+ async hide(options = {}) {
142
+ if (!this.state.visible)
143
+ return;
144
+ const userAction = options.userAction !== undefined ? options.userAction : true;
145
+ this.updateState({ visible: false }, userAction);
146
+ this._hide({ userAction });
162
147
  }
163
148
  enable(options = {}) {
164
149
  if (this.state.enabled)
@@ -203,10 +188,8 @@ export class Controller extends BasePlugin.Controller {
203
188
  this.extraObjects = formatExtraObjects(data, this.five, this.data);
204
189
  this.render();
205
190
  }
206
- formatData(serverData) {
207
- return __awaiter(this, void 0, void 0, function* () {
208
- return yield formatData(serverData.data);
209
- });
191
+ async formatData(serverData) {
192
+ return await formatData(serverData.data);
210
193
  }
211
194
  _enable(options) {
212
195
  const { userAction } = options;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import * as THREE from 'three';
11
2
  import equal from '../../shared-utils/equal';
12
3
  import Main from '../Components/Main';
@@ -306,24 +297,22 @@ export class Controller extends BasePlugin.Controller {
306
297
  five.once('dispose', this.dispose);
307
298
  this.addEventListener();
308
299
  }
309
- load(serverData, state, userAction = true) {
310
- return __awaiter(this, void 0, void 0, function* () {
311
- function isPluginServerData(serverData) {
312
- return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
313
- }
314
- const _data = serverData;
315
- if (_data && !_data.version)
316
- console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
317
- const copyData = JSON.parse(JSON.stringify(serverData));
318
- const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
319
- const prevData = this.data;
320
- this.data = yield formatData(_serverData);
321
- this.hooks.emit('dataLoaded', this.data);
322
- this.hooks.emit('dataChange', this.data, prevData);
323
- if (state)
324
- this.updateState(state, userAction);
325
- this.render();
326
- });
300
+ async load(serverData, state, userAction = true) {
301
+ function isPluginServerData(serverData) {
302
+ return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
303
+ }
304
+ const _data = serverData;
305
+ if (_data && !_data.version)
306
+ console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
307
+ const copyData = JSON.parse(JSON.stringify(serverData));
308
+ const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
309
+ const prevData = this.data;
310
+ this.data = await formatData(_serverData);
311
+ this.hooks.emit('dataLoaded', this.data);
312
+ this.hooks.emit('dataChange', this.data, prevData);
313
+ if (state)
314
+ this.updateState(state, userAction);
315
+ this.render();
327
316
  }
328
317
  /** 更新户型图位置 */
329
318
  updatePosition() {
@@ -348,25 +337,21 @@ export class Controller extends BasePlugin.Controller {
348
337
  this.render();
349
338
  return this;
350
339
  }
351
- show(options = {}) {
352
- return __awaiter(this, void 0, void 0, function* () {
353
- // 已经展示完成了,不做任何操作
354
- if (this.state.visible)
355
- return;
356
- const userAction = options.userAction !== undefined ? options.userAction : true;
357
- this.updateState({ visible: true }, userAction);
358
- this._show({ userAction });
359
- });
340
+ async show(options = {}) {
341
+ // 已经展示完成了,不做任何操作
342
+ if (this.state.visible)
343
+ return;
344
+ const userAction = options.userAction !== undefined ? options.userAction : true;
345
+ this.updateState({ visible: true }, userAction);
346
+ this._show({ userAction });
360
347
  }
361
- hide(options = {}) {
362
- return __awaiter(this, void 0, void 0, function* () {
363
- this.isHiddenByHideFunc = true;
364
- if (!this.state.visible)
365
- return;
366
- const userAction = options.userAction !== undefined ? options.userAction : true;
367
- this.updateState({ visible: false }, userAction);
368
- this._hide({ userAction });
369
- });
348
+ async hide(options = {}) {
349
+ this.isHiddenByHideFunc = true;
350
+ if (!this.state.visible)
351
+ return;
352
+ const userAction = options.userAction !== undefined ? options.userAction : true;
353
+ this.updateState({ visible: false }, userAction);
354
+ this._hide({ userAction });
370
355
  }
371
356
  enable(options = {}) {
372
357
  if (this.state.enabled)
@@ -396,42 +381,36 @@ export class Controller extends BasePlugin.Controller {
396
381
  state.visible ? this._show(options) : this._hide(options);
397
382
  }
398
383
  }
399
- formatData(serverData) {
400
- return __awaiter(this, void 0, void 0, function* () {
401
- return yield formatData(serverData.data);
402
- });
384
+ async formatData(serverData) {
385
+ return await formatData(serverData.data);
403
386
  }
404
- _show(options) {
405
- return __awaiter(this, void 0, void 0, function* () {
406
- if (!this.state.enabled)
407
- return;
408
- this.isHiddenByHideFunc = false;
409
- const { userAction } = options;
410
- this.hooks.emit('show', { userAction });
411
- if (this.five.getCurrentState().mode !== 'Topview') {
412
- yield changeMode(this.five, ['Topview', undefined, undefined, userAction]);
413
- }
414
- this.five.model.show(this.floorIndex);
415
- this.updatePosition();
416
- this.updateSize();
417
- const renderDuration = 500;
418
- const modelOpacity = this.state.config.modelOpacity;
419
- changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
420
- this.hooks.emit('showAnimationEnded', { userAction });
421
- this.render();
422
- });
387
+ async _show(options) {
388
+ if (!this.state.enabled)
389
+ return;
390
+ this.isHiddenByHideFunc = false;
391
+ const { userAction } = options;
392
+ this.hooks.emit('show', { userAction });
393
+ if (this.five.getCurrentState().mode !== 'Topview') {
394
+ await changeMode(this.five, ['Topview', undefined, undefined, userAction]);
395
+ }
396
+ this.five.model.show(this.floorIndex);
397
+ this.updatePosition();
398
+ this.updateSize();
399
+ const renderDuration = 500;
400
+ const modelOpacity = this.state.config.modelOpacity;
401
+ changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
402
+ this.hooks.emit('showAnimationEnded', { userAction });
403
+ this.render();
423
404
  }
424
- _hide(options) {
425
- return __awaiter(this, void 0, void 0, function* () {
426
- if (!this.state.enabled)
427
- return;
428
- const { userAction } = options;
429
- this.hooks.emit('hide', { userAction });
430
- const modelOpacity = 1;
431
- const renderDuration = 0;
432
- changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
433
- this.render();
434
- });
405
+ async _hide(options) {
406
+ if (!this.state.enabled)
407
+ return;
408
+ const { userAction } = options;
409
+ this.hooks.emit('hide', { userAction });
410
+ const modelOpacity = 1;
411
+ const renderDuration = 0;
412
+ changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
413
+ this.render();
435
414
  }
436
415
  _enable(options) {
437
416
  const { userAction } = options;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import to from '../../shared-utils/to';
11
2
  import { FloorplanErrorType } from '../utils/constant';
12
3
  import nearlyEqual from '../../shared-utils/nearlyEqual';
@@ -31,27 +22,25 @@ export function checkShowState(five, showState) {
31
22
  * 2. 内置了相应的动画时间计算
32
23
  * 3. 纠正成功会返回 true,失败「可能会被用户行为中断」会返回 false
33
24
  */
34
- export default function correctFiveState(five, showState, userAction = true) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- // 当前已满足状态,不需要变更
37
- const result = checkShowState(five, showState);
38
- if (result === true)
39
- return;
40
- const currentFiveState = five.getCurrentState();
41
- // 纠正 mode
42
- if (currentFiveState.mode !== showState.mode) {
43
- const [changeModeError] = yield to(changeMode(five, [showState.mode, showState, undefined, userAction]));
44
- if (changeModeError)
45
- throw new Error(FloorplanErrorType.ChangeModeError);
46
- return;
47
- }
48
- // 纠正相机状态
49
- // 根据 latitude、longitude、fov 计算动画时间,最多 1s
50
- const { latitude, longitude, fov } = currentFiveState;
51
- 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));
52
- const [updateCameraError] = yield to(five.updateCamera(showState, time, userAction));
53
- if (updateCameraError)
54
- throw new Error(FloorplanErrorType.UpdateCameraError);
25
+ export default async function correctFiveState(five, showState, userAction = true) {
26
+ // 当前已满足状态,不需要变更
27
+ const result = checkShowState(five, showState);
28
+ if (result === true)
55
29
  return;
56
- });
30
+ const currentFiveState = five.getCurrentState();
31
+ // 纠正 mode
32
+ if (currentFiveState.mode !== showState.mode) {
33
+ const [changeModeError] = await to(changeMode(five, [showState.mode, showState, undefined, userAction]));
34
+ if (changeModeError)
35
+ throw new Error(FloorplanErrorType.ChangeModeError);
36
+ return;
37
+ }
38
+ // 纠正相机状态
39
+ // 根据 latitude、longitude、fov 计算动画时间,最多 1s
40
+ const { latitude, longitude, fov } = currentFiveState;
41
+ 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));
42
+ const [updateCameraError] = await to(five.updateCamera(showState, time, userAction));
43
+ if (updateCameraError)
44
+ throw new Error(FloorplanErrorType.UpdateCameraError);
45
+ return;
57
46
  }
@@ -1,34 +1,21 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { FLOORPLAN_EXTRA_OBJECT_IMAGE } from '../Assets/floorplanExtraObject';
11
2
  import { floorplanPosition2ImagePosition, getFloorIndexFromModelPosition, modelPosition2FloorplanPosition, } from './formatPosition';
12
- function formatOutlines(outlines) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- const headers = new Headers({ 'Content-Type': 'text/plain' });
15
- const getOutlineItem = function (item) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const outlineItem = {
18
- index: item.index,
19
- url: item.url,
20
- svgUrl: item.svg_url,
21
- };
22
- if (item.svg_url) {
23
- const svgContent = yield fetch(item.svg_url, { headers }).then((res) => res.text());
24
- outlineItem.svgContent = svgContent;
25
- }
26
- return outlineItem;
27
- });
3
+ async function formatOutlines(outlines) {
4
+ const headers = new Headers({ 'Content-Type': 'text/plain' });
5
+ const getOutlineItem = async function (item) {
6
+ const outlineItem = {
7
+ index: item.index,
8
+ url: item.url,
9
+ svgUrl: item.svg_url,
28
10
  };
29
- const svgOutlineItems = yield Promise.all(outlines.map(getOutlineItem));
30
- return svgOutlineItems;
31
- });
11
+ if (item.svg_url) {
12
+ const svgContent = await fetch(item.svg_url, { headers }).then((res) => res.text());
13
+ outlineItem.svgContent = svgContent;
14
+ }
15
+ return outlineItem;
16
+ };
17
+ const svgOutlineItems = await Promise.all(outlines.map(getOutlineItem));
18
+ return svgOutlineItems;
32
19
  }
33
20
  function formatRoom(data) {
34
21
  const floorplanRoomItem = {
@@ -74,21 +61,19 @@ function formatFloorplanEntrance(data) {
74
61
  };
75
62
  return floorplanEntrance;
76
63
  }
77
- export default function formatData(data) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- const outlines = yield formatOutlines(data.outlines);
80
- const bounding = data.computed_data.bounding;
81
- const floorDatas = data.computed_data.floor_datas.map(formatFloorData);
82
- const entrance = data.computed_data.entrance ? formatFloorplanEntrance(data.computed_data.entrance) : null;
83
- const floorplanData = {
84
- outlines,
85
- entrance,
86
- bounding,
87
- floorDatas,
88
- observers: data.computed_data.observers.map(formateFloorplanObserver),
89
- };
90
- return floorplanData;
91
- });
64
+ export default async function formatData(data) {
65
+ const outlines = await formatOutlines(data.outlines);
66
+ const bounding = data.computed_data.bounding;
67
+ const floorDatas = data.computed_data.floor_datas.map(formatFloorData);
68
+ const entrance = data.computed_data.entrance ? formatFloorplanEntrance(data.computed_data.entrance) : null;
69
+ const floorplanData = {
70
+ outlines,
71
+ entrance,
72
+ bounding,
73
+ floorDatas,
74
+ observers: data.computed_data.observers.map(formateFloorplanObserver),
75
+ };
76
+ return floorplanData;
92
77
  }
93
78
  export function formatExtraObjects(data, five, floorplanData) {
94
79
  const extraObjects = data.map((object) => {