@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
package/dist/index.umd.js CHANGED
@@ -1011,31 +1011,6 @@
1011
1011
  FLOOR_PLAN_ATTACHED_TO[FLOOR_PLAN_ATTACHED_TO["BOUNDING_CENTER"] = 3] = "BOUNDING_CENTER";
1012
1012
  })(exports.FLOOR_PLAN_ATTACHED_TO || (exports.FLOOR_PLAN_ATTACHED_TO = {}));
1013
1013
 
1014
- /******************************************************************************
1015
- Copyright (c) Microsoft Corporation.
1016
-
1017
- Permission to use, copy, modify, and/or distribute this software for any
1018
- purpose with or without fee is hereby granted.
1019
-
1020
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1021
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1022
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1023
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1024
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1025
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1026
- PERFORMANCE OF THIS SOFTWARE.
1027
- ***************************************************************************** */
1028
-
1029
- function __awaiter(thisArg, _arguments, P, generator) {
1030
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1031
- return new (P || (P = Promise))(function (resolve, reject) {
1032
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1033
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1034
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1035
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1036
- });
1037
- }
1038
-
1039
1014
  /**
1040
1015
  * 检查一个值是否是狭义上的对象
1041
1016
  * @param {any} value 要检查的值
@@ -4539,26 +4514,22 @@
4539
4514
 
4540
4515
  const FLOORPLAN_EXTRA_OBJECT_IMAGE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAwCAYAAACFUvPfAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAALaADAAQAAAABAAAAMAAAAADe2FZjAAAEF0lEQVRoBe2WzWskRRiHf13V092TxI2oEzYeVDwITtyDuCiihwiCePGgxIM3vYgHL4J4UIhBRA8i/gPqyUvWg7AiIuIeloDiYUHJLOK6BPwIk9nNODM9Xf1RVe1b3elJRjCZmQ6euqGmuqer33rq4e23GqiOykBloDJQGagMVAYqA5WBykBlYFYD1qwP/tdzaZqOx9zYOLxeX0+L5yzLGp0X/03a25MOnGRcBtx+6Rlo9SL08G4EooFnxa8Yiivox5/h5Ys/4cl7NVorNDRnngX+0MIkVMeMSf23zyKML8J7/Dy8hwF2Buh9CnS+AEQIdLspBuGb+M7/qLW4qJrNpsLapjYhpwVnx3BMfCtNNx3Etc9xywvnMf80wG8HmQainw0RxSGrnmeBp+8k5/j9S0HbvXb5io0Lz880/0wPHV1NlhLd316He+4xOCv5ragF7L9PrH1qBJyB0626x/lC+qrSvH5r/W+n1WpxUM5nMY4GPeH8lHJaPgfeAFQHCL+ntkXT+vnUc3W6pvTIwC0wy3rA4dwLmK2avZ7Eo9uKBuYJfgJscbs8dLCxDMt+EOEPBEZNEWyBYHqTz6bPXrzUnNrSShxHIsYiOL69zrCGLLcLqJP68tB+9w5wj+YhWDafQ2s61wNqxjZhmrQ2pvMFCEvXuCUZ7wqH794ZWs28LJqlTXSUyuksF2M/yOwqgkx2c1ADa4wLAQRk2sAGQQakhN6yFC2hltfz5kSY44NKQeeh+vtI/SSzWhg2CzCgmWISmKUGmaYFBDfCSymnfxJ6/+ospVcWOLLp5DGP/y0P/Rp66O99DQNq7Po3Ds0a0wY+My2QSv2N2mO/OyxR2o6UQk+Lv7yJ06JYSnnolZVU9cUn2O9SmaMWGFBqYXRwbqAJWIi94TX5biotpcGl1DXZ6LnqIbNDTnmUgi52Mv5l5ysMxIcZcGjy2DTK4ZHlcBC14zeSge4qphICjj3bS0A7o9nSp2TOkm7aZ8bGZy/jxhO87V91G0+dfY/Z7BWIIK9KYUi5qy/Hf8YfBG3sqJTHiQWhmTVkbip+wX3x6volVSx+LPAxF+VLXhZ8VQ+iP2Rta/iWe5v42Fngj0BbdnRTXh12ZIcKhTaGbcYjybRwXBU1lu9KlndXp04NM52poKWO0RZsviNaP9a6grkO972+st05pXhE5c1hTEluJy7XUejGUQNLMbAmTdWY1rKBLW3aTJqBZ7nZkb36DhYCreeYHbMUXHvaYi5XDK70EcgulmRjm77wNtenzuXCbmnTRaAx493rbGf3Jr/njMzj920CnKdUaFCjlDioy7NYNvOdGrQJNgI32/L2tkXfFPlxgToqjWVhD6KdLnQRdARf/HHQz2r2X2Gqy8pAZaAyUBmoDFQGKgP/q4F/AJYg9/s0ZoABAAAAAElFTkSuQmCC';
4541
4516
 
4542
- function formatOutlines(outlines) {
4543
- return __awaiter(this, void 0, void 0, function* () {
4544
- const headers = new Headers({ 'Content-Type': 'text/plain' });
4545
- const getOutlineItem = function (item) {
4546
- return __awaiter(this, void 0, void 0, function* () {
4547
- const outlineItem = {
4548
- index: item.index,
4549
- url: item.url,
4550
- svgUrl: item.svg_url,
4551
- };
4552
- if (item.svg_url) {
4553
- const svgContent = yield fetch(item.svg_url, { headers }).then((res) => res.text());
4554
- outlineItem.svgContent = svgContent;
4555
- }
4556
- return outlineItem;
4557
- });
4517
+ async function formatOutlines(outlines) {
4518
+ const headers = new Headers({ 'Content-Type': 'text/plain' });
4519
+ const getOutlineItem = async function (item) {
4520
+ const outlineItem = {
4521
+ index: item.index,
4522
+ url: item.url,
4523
+ svgUrl: item.svg_url,
4558
4524
  };
4559
- const svgOutlineItems = yield Promise.all(outlines.map(getOutlineItem));
4560
- return svgOutlineItems;
4561
- });
4525
+ if (item.svg_url) {
4526
+ const svgContent = await fetch(item.svg_url, { headers }).then((res) => res.text());
4527
+ outlineItem.svgContent = svgContent;
4528
+ }
4529
+ return outlineItem;
4530
+ };
4531
+ const svgOutlineItems = await Promise.all(outlines.map(getOutlineItem));
4532
+ return svgOutlineItems;
4562
4533
  }
4563
4534
  function formatRoom(data) {
4564
4535
  const floorplanRoomItem = {
@@ -4604,21 +4575,19 @@
4604
4575
  };
4605
4576
  return floorplanEntrance;
4606
4577
  }
4607
- function formatData(data) {
4608
- return __awaiter(this, void 0, void 0, function* () {
4609
- const outlines = yield formatOutlines(data.outlines);
4610
- const bounding = data.computed_data.bounding;
4611
- const floorDatas = data.computed_data.floor_datas.map(formatFloorData);
4612
- const entrance = data.computed_data.entrance ? formatFloorplanEntrance(data.computed_data.entrance) : null;
4613
- const floorplanData = {
4614
- outlines,
4615
- entrance,
4616
- bounding,
4617
- floorDatas,
4618
- observers: data.computed_data.observers.map(formateFloorplanObserver),
4619
- };
4620
- return floorplanData;
4621
- });
4578
+ async function formatData(data) {
4579
+ const outlines = await formatOutlines(data.outlines);
4580
+ const bounding = data.computed_data.bounding;
4581
+ const floorDatas = data.computed_data.floor_datas.map(formatFloorData);
4582
+ const entrance = data.computed_data.entrance ? formatFloorplanEntrance(data.computed_data.entrance) : null;
4583
+ const floorplanData = {
4584
+ outlines,
4585
+ entrance,
4586
+ bounding,
4587
+ floorDatas,
4588
+ observers: data.computed_data.observers.map(formateFloorplanObserver),
4589
+ };
4590
+ return floorplanData;
4622
4591
  }
4623
4592
  function formatExtraObjects(data, five, floorplanData) {
4624
4593
  const extraObjects = data.map((object) => {
@@ -4713,37 +4682,35 @@
4713
4682
  /** 等待 five changeMode 结束
4714
4683
  * @description Promise 的状态只代表 mode 与预期是否一致,不保证参数的一致性
4715
4684
  */
4716
- function changeMode(five, changeModeParams) {
4717
- return __awaiter(this, void 0, void 0, function* () {
4718
- yield new Promise((resolve, reject) => {
4719
- // 虽然 changeMode 是异步函数,但不代表异步流程结束代表切换 Mode 动画结束
4720
- five.changeMode(...changeModeParams).catch((error) => reject(error));
4721
- five.once('initAnimationEnded', () => {
4722
- const fiveCurrentState = five.getCurrentState();
4723
- const correctMode = changeModeParams[0];
4724
- if (fiveCurrentState.mode !== correctMode)
4725
- reject(new Error('mode 与预期不符'));
4726
- /** 检测当前的 current pose 和传入的 pose 是否一致 */
4727
- const checkPose = () => {
4728
- const correctPose = changeModeParams[1];
4729
- if (!correctPose)
4685
+ async function changeMode(five, changeModeParams) {
4686
+ await new Promise((resolve, reject) => {
4687
+ // 虽然 changeMode 是异步函数,但不代表异步流程结束代表切换 Mode 动画结束
4688
+ five.changeMode(...changeModeParams).catch((error) => reject(error));
4689
+ five.once('initAnimationEnded', () => {
4690
+ const fiveCurrentState = five.getCurrentState();
4691
+ const correctMode = changeModeParams[0];
4692
+ if (fiveCurrentState.mode !== correctMode)
4693
+ reject(new Error('mode 与预期不符'));
4694
+ /** 检测当前的 current pose 和传入的 pose 是否一致 */
4695
+ const checkPose = () => {
4696
+ const correctPose = changeModeParams[1];
4697
+ if (!correctPose)
4698
+ return true;
4699
+ return Object.keys(correctPose).every((key) => {
4700
+ const fivePoseItem = fiveCurrentState[key];
4701
+ if (fivePoseItem === undefined)
4730
4702
  return true;
4731
- return Object.keys(correctPose).every((key) => {
4732
- const fivePoseItem = fiveCurrentState[key];
4733
- if (fivePoseItem === undefined)
4734
- return true;
4735
- const correctPoseItem = correctPose[key];
4736
- if (typeof fivePoseItem === 'number' && typeof correctPoseItem === 'number') {
4737
- return nearlyEqual(fivePoseItem, correctPoseItem, 2);
4738
- }
4739
- return fivePoseItem === correctPoseItem;
4740
- });
4741
- };
4742
- const checkPoseResult = checkPose();
4743
- if (!checkPoseResult)
4744
- reject(new Error('five pose 与预期不符'));
4745
- resolve();
4746
- });
4703
+ const correctPoseItem = correctPose[key];
4704
+ if (typeof fivePoseItem === 'number' && typeof correctPoseItem === 'number') {
4705
+ return nearlyEqual(fivePoseItem, correctPoseItem, 2);
4706
+ }
4707
+ return fivePoseItem === correctPoseItem;
4708
+ });
4709
+ };
4710
+ const checkPoseResult = checkPose();
4711
+ if (!checkPoseResult)
4712
+ reject(new Error('five pose 与预期不符'));
4713
+ resolve();
4747
4714
  });
4748
4715
  });
4749
4716
  }
@@ -5090,24 +5057,22 @@
5090
5057
  five.once('dispose', this.dispose);
5091
5058
  this.addEventListener();
5092
5059
  }
5093
- load(serverData, state, userAction = true) {
5094
- return __awaiter(this, void 0, void 0, function* () {
5095
- function isPluginServerData(serverData) {
5096
- return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
5097
- }
5098
- const _data = serverData;
5099
- if (_data && !_data.version)
5100
- console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
5101
- const copyData = JSON.parse(JSON.stringify(serverData));
5102
- const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
5103
- const prevData = this.data;
5104
- this.data = yield formatData(_serverData);
5105
- this.hooks.emit('dataLoaded', this.data);
5106
- this.hooks.emit('dataChange', this.data, prevData);
5107
- if (state)
5108
- this.updateState(state, userAction);
5109
- this.render();
5110
- });
5060
+ async load(serverData, state, userAction = true) {
5061
+ function isPluginServerData(serverData) {
5062
+ return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
5063
+ }
5064
+ const _data = serverData;
5065
+ if (_data && !_data.version)
5066
+ console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
5067
+ const copyData = JSON.parse(JSON.stringify(serverData));
5068
+ const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
5069
+ const prevData = this.data;
5070
+ this.data = await formatData(_serverData);
5071
+ this.hooks.emit('dataLoaded', this.data);
5072
+ this.hooks.emit('dataChange', this.data, prevData);
5073
+ if (state)
5074
+ this.updateState(state, userAction);
5075
+ this.render();
5111
5076
  }
5112
5077
  /** 更新户型图位置 */
5113
5078
  updatePosition() {
@@ -5132,25 +5097,21 @@
5132
5097
  this.render();
5133
5098
  return this;
5134
5099
  }
5135
- show(options = {}) {
5136
- return __awaiter(this, void 0, void 0, function* () {
5137
- // 已经展示完成了,不做任何操作
5138
- if (this.state.visible)
5139
- return;
5140
- const userAction = options.userAction !== undefined ? options.userAction : true;
5141
- this.updateState({ visible: true }, userAction);
5142
- this._show({ userAction });
5143
- });
5100
+ async show(options = {}) {
5101
+ // 已经展示完成了,不做任何操作
5102
+ if (this.state.visible)
5103
+ return;
5104
+ const userAction = options.userAction !== undefined ? options.userAction : true;
5105
+ this.updateState({ visible: true }, userAction);
5106
+ this._show({ userAction });
5144
5107
  }
5145
- hide(options = {}) {
5146
- return __awaiter(this, void 0, void 0, function* () {
5147
- this.isHiddenByHideFunc = true;
5148
- if (!this.state.visible)
5149
- return;
5150
- const userAction = options.userAction !== undefined ? options.userAction : true;
5151
- this.updateState({ visible: false }, userAction);
5152
- this._hide({ userAction });
5153
- });
5108
+ async hide(options = {}) {
5109
+ this.isHiddenByHideFunc = true;
5110
+ if (!this.state.visible)
5111
+ return;
5112
+ const userAction = options.userAction !== undefined ? options.userAction : true;
5113
+ this.updateState({ visible: false }, userAction);
5114
+ this._hide({ userAction });
5154
5115
  }
5155
5116
  enable(options = {}) {
5156
5117
  if (this.state.enabled)
@@ -5180,42 +5141,36 @@
5180
5141
  state.visible ? this._show(options) : this._hide(options);
5181
5142
  }
5182
5143
  }
5183
- formatData(serverData) {
5184
- return __awaiter(this, void 0, void 0, function* () {
5185
- return yield formatData(serverData.data);
5186
- });
5144
+ async formatData(serverData) {
5145
+ return await formatData(serverData.data);
5187
5146
  }
5188
- _show(options) {
5189
- return __awaiter(this, void 0, void 0, function* () {
5190
- if (!this.state.enabled)
5191
- return;
5192
- this.isHiddenByHideFunc = false;
5193
- const { userAction } = options;
5194
- this.hooks.emit('show', { userAction });
5195
- if (this.five.getCurrentState().mode !== 'Topview') {
5196
- yield changeMode(this.five, ['Topview', undefined, undefined, userAction]);
5197
- }
5198
- this.five.model.show(this.floorIndex);
5199
- this.updatePosition();
5200
- this.updateSize();
5201
- const renderDuration = 500;
5202
- const modelOpacity = this.state.config.modelOpacity;
5203
- changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
5204
- this.hooks.emit('showAnimationEnded', { userAction });
5205
- this.render();
5206
- });
5147
+ async _show(options) {
5148
+ if (!this.state.enabled)
5149
+ return;
5150
+ this.isHiddenByHideFunc = false;
5151
+ const { userAction } = options;
5152
+ this.hooks.emit('show', { userAction });
5153
+ if (this.five.getCurrentState().mode !== 'Topview') {
5154
+ await changeMode(this.five, ['Topview', undefined, undefined, userAction]);
5155
+ }
5156
+ this.five.model.show(this.floorIndex);
5157
+ this.updatePosition();
5158
+ this.updateSize();
5159
+ const renderDuration = 500;
5160
+ const modelOpacity = this.state.config.modelOpacity;
5161
+ changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
5162
+ this.hooks.emit('showAnimationEnded', { userAction });
5163
+ this.render();
5207
5164
  }
5208
- _hide(options) {
5209
- return __awaiter(this, void 0, void 0, function* () {
5210
- if (!this.state.enabled)
5211
- return;
5212
- const { userAction } = options;
5213
- this.hooks.emit('hide', { userAction });
5214
- const modelOpacity = 1;
5215
- const renderDuration = 0;
5216
- changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
5217
- this.render();
5218
- });
5165
+ async _hide(options) {
5166
+ if (!this.state.enabled)
5167
+ return;
5168
+ const { userAction } = options;
5169
+ this.hooks.emit('hide', { userAction });
5170
+ const modelOpacity = 1;
5171
+ const renderDuration = 0;
5172
+ changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
5173
+ this.render();
5219
5174
  }
5220
5175
  _enable(options) {
5221
5176
  const { userAction } = options;
@@ -6268,55 +6223,49 @@
6268
6223
  // =============== init Listener ===============
6269
6224
  five.once('dispose', this.dispose);
6270
6225
  }
6271
- load(serverData, state, userAction = true) {
6272
- return __awaiter(this, void 0, void 0, function* () {
6273
- // const loadImage = async () => {
6274
- // const floorIndex = this.five.work.observers[this.five.getCurrentState().panoIndex].floorIndex
6275
- // // 当有 svgString 时,没有加载过程
6276
- // if (floorplanData.outlines[floorIndex]?.svgContent) return
6277
- // // 如果当前楼层图片不存在,不存在加载过程
6278
- // const nowFloorImageSrc = floorplanData.outlines[floorIndex]?.url
6279
- // if (!nowFloorImageSrc) return
6280
- // // 图片加载完成时再 render
6281
- // await new Promise<void>((resolve) => {
6282
- // const nowFloorImage = new Image()
6283
- // nowFloorImage.src = nowFloorImageSrc
6284
- // nowFloorImage.onload = () => resolve()
6285
- // })
6286
- // }
6287
- // await loadImage()
6288
- function isPluginServerData(serverData) {
6289
- return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
6290
- }
6291
- const copyData = JSON.parse(JSON.stringify(serverData));
6292
- const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
6293
- const prevData = this.data;
6294
- this.data = yield formatData(_serverData);
6295
- this.hooks.emit('dataLoaded', this.data);
6296
- this.hooks.emit('dataChange', this.data, prevData);
6297
- if (state)
6298
- this.updateState(state, userAction);
6299
- this.render();
6300
- });
6226
+ async load(serverData, state, userAction = true) {
6227
+ // const loadImage = async () => {
6228
+ // const floorIndex = this.five.work.observers[this.five.getCurrentState().panoIndex].floorIndex
6229
+ // // 当有 svgString 时,没有加载过程
6230
+ // if (floorplanData.outlines[floorIndex]?.svgContent) return
6231
+ // // 如果当前楼层图片不存在,不存在加载过程
6232
+ // const nowFloorImageSrc = floorplanData.outlines[floorIndex]?.url
6233
+ // if (!nowFloorImageSrc) return
6234
+ // // 图片加载完成时再 render
6235
+ // await new Promise<void>((resolve) => {
6236
+ // const nowFloorImage = new Image()
6237
+ // nowFloorImage.src = nowFloorImageSrc
6238
+ // nowFloorImage.onload = () => resolve()
6239
+ // })
6240
+ // }
6241
+ // await loadImage()
6242
+ function isPluginServerData(serverData) {
6243
+ return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
6244
+ }
6245
+ const copyData = JSON.parse(JSON.stringify(serverData));
6246
+ const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
6247
+ const prevData = this.data;
6248
+ this.data = await formatData(_serverData);
6249
+ this.hooks.emit('dataLoaded', this.data);
6250
+ this.hooks.emit('dataChange', this.data, prevData);
6251
+ if (state)
6252
+ this.updateState(state, userAction);
6253
+ this.render();
6301
6254
  }
6302
- show(options = {}) {
6303
- return __awaiter(this, void 0, void 0, function* () {
6304
- // 已经展示完成了,不做任何操作
6305
- if (this.state.visible)
6306
- return;
6307
- const userAction = options.userAction !== undefined ? options.userAction : true;
6308
- this.updateState({ visible: true }, userAction);
6309
- this._show({ userAction });
6310
- });
6255
+ async show(options = {}) {
6256
+ // 已经展示完成了,不做任何操作
6257
+ if (this.state.visible)
6258
+ return;
6259
+ const userAction = options.userAction !== undefined ? options.userAction : true;
6260
+ this.updateState({ visible: true }, userAction);
6261
+ this._show({ userAction });
6311
6262
  }
6312
- hide(options = {}) {
6313
- return __awaiter(this, void 0, void 0, function* () {
6314
- if (!this.state.visible)
6315
- return;
6316
- const userAction = options.userAction !== undefined ? options.userAction : true;
6317
- this.updateState({ visible: false }, userAction);
6318
- this._hide({ userAction });
6319
- });
6263
+ async hide(options = {}) {
6264
+ if (!this.state.visible)
6265
+ return;
6266
+ const userAction = options.userAction !== undefined ? options.userAction : true;
6267
+ this.updateState({ visible: false }, userAction);
6268
+ this._hide({ userAction });
6320
6269
  }
6321
6270
  enable(options = {}) {
6322
6271
  if (this.state.enabled)
@@ -6361,10 +6310,8 @@
6361
6310
  this.extraObjects = formatExtraObjects(data, this.five, this.data);
6362
6311
  this.render();
6363
6312
  }
6364
- formatData(serverData) {
6365
- return __awaiter(this, void 0, void 0, function* () {
6366
- return yield formatData(serverData.data);
6367
- });
6313
+ async formatData(serverData) {
6314
+ return await formatData(serverData.data);
6368
6315
  }
6369
6316
  _enable(options) {
6370
6317
  const { userAction } = options;
@@ -6424,18 +6371,16 @@
6424
6371
  * 有异常,则返回 [Error, undefined]
6425
6372
  * 用于替代 try&catch 处理 await 异常的方案
6426
6373
  */
6427
- function to(promise) {
6428
- return __awaiter(this, void 0, void 0, function* () {
6429
- try {
6430
- const data = yield promise;
6431
- return [null, data];
6432
- }
6433
- catch (error) {
6434
- if (error instanceof Error)
6435
- return [error, null];
6436
- return [new Error(''), null];
6437
- }
6438
- });
6374
+ async function to(promise) {
6375
+ try {
6376
+ const data = await promise;
6377
+ return [null, data];
6378
+ }
6379
+ catch (error) {
6380
+ if (error instanceof Error)
6381
+ return [error, null];
6382
+ return [new Error(''), null];
6383
+ }
6439
6384
  }
6440
6385
 
6441
6386
  var FloorplanErrorType;
@@ -6480,29 +6425,27 @@
6480
6425
  * 2. 内置了相应的动画时间计算
6481
6426
  * 3. 纠正成功会返回 true,失败「可能会被用户行为中断」会返回 false
6482
6427
  */
6483
- function correctFiveState(five, showState, userAction = true) {
6484
- return __awaiter(this, void 0, void 0, function* () {
6485
- // 当前已满足状态,不需要变更
6486
- const result = checkShowState(five, showState);
6487
- if (result === true)
6488
- return;
6489
- const currentFiveState = five.getCurrentState();
6490
- // 纠正 mode
6491
- if (currentFiveState.mode !== showState.mode) {
6492
- const [changeModeError] = yield to(changeMode(five, [showState.mode, showState, undefined, userAction]));
6493
- if (changeModeError)
6494
- throw new Error(FloorplanErrorType.ChangeModeError);
6495
- return;
6496
- }
6497
- // 纠正相机状态
6498
- // 根据 latitude、longitude、fov 计算动画时间,最多 1s
6499
- const { latitude, longitude, fov } = currentFiveState;
6500
- 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));
6501
- const [updateCameraError] = yield to(five.updateCamera(showState, time, userAction));
6502
- if (updateCameraError)
6503
- throw new Error(FloorplanErrorType.UpdateCameraError);
6428
+ async function correctFiveState(five, showState, userAction = true) {
6429
+ // 当前已满足状态,不需要变更
6430
+ const result = checkShowState(five, showState);
6431
+ if (result === true)
6504
6432
  return;
6505
- });
6433
+ const currentFiveState = five.getCurrentState();
6434
+ // 纠正 mode
6435
+ if (currentFiveState.mode !== showState.mode) {
6436
+ const [changeModeError] = await to(changeMode(five, [showState.mode, showState, undefined, userAction]));
6437
+ if (changeModeError)
6438
+ throw new Error(FloorplanErrorType.ChangeModeError);
6439
+ return;
6440
+ }
6441
+ // 纠正相机状态
6442
+ // 根据 latitude、longitude、fov 计算动画时间,最多 1s
6443
+ const { latitude, longitude, fov } = currentFiveState;
6444
+ 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));
6445
+ const [updateCameraError] = await to(five.updateCamera(showState, time, userAction));
6446
+ if (updateCameraError)
6447
+ throw new Error(FloorplanErrorType.UpdateCameraError);
6448
+ return;
6506
6449
  }
6507
6450
 
6508
6451
  /** 当前 five 的相机视角是否满足户型图自动隐藏条件
@@ -6671,7 +6614,7 @@
6671
6614
  enumerable: true,
6672
6615
  configurable: true,
6673
6616
  writable: true,
6674
- value: (options = {}) => __awaiter(this, void 0, void 0, function* () {
6617
+ value: async (options = {}) => {
6675
6618
  if (!this.state.enabled)
6676
6619
  return;
6677
6620
  // 已经展示完成了,不做任何操作
@@ -6680,14 +6623,14 @@
6680
6623
  const userAction = options.userAction !== undefined ? options.userAction : true;
6681
6624
  this.updateState({ visible: true }, userAction);
6682
6625
  this._show(options);
6683
- })
6626
+ }
6684
6627
  });
6685
6628
  /** 隐藏户型图 */
6686
6629
  Object.defineProperty(this, "hide", {
6687
6630
  enumerable: true,
6688
6631
  configurable: true,
6689
6632
  writable: true,
6690
- value: (options = {}) => __awaiter(this, void 0, void 0, function* () {
6633
+ value: async (options = {}) => {
6691
6634
  if (!this.state.enabled)
6692
6635
  return;
6693
6636
  this.isHiddenByHideFunc = true;
@@ -6695,7 +6638,7 @@
6695
6638
  return;
6696
6639
  this.updateState({ visible: false }, options.userAction || true);
6697
6640
  this._hide(options);
6698
- })
6641
+ }
6699
6642
  });
6700
6643
  /** 更新户型图大小 */
6701
6644
  Object.defineProperty(this, "updateSize", {
@@ -6761,11 +6704,11 @@
6761
6704
  enumerable: true,
6762
6705
  configurable: true,
6763
6706
  writable: true,
6764
- value: (options) => __awaiter(this, void 0, void 0, function* () {
6765
- var _b;
6707
+ value: async (options) => {
6708
+ var _a;
6766
6709
  if (!this.state.enabled)
6767
6710
  return;
6768
- if (!((_b = this.five.model) === null || _b === void 0 ? void 0 : _b.loaded))
6711
+ if (!((_a = this.five.model) === null || _a === void 0 ? void 0 : _a.loaded))
6769
6712
  throw new Error(FloorplanErrorType.ModelNotLoaded);
6770
6713
  if (!this.data)
6771
6714
  throw new Error(FloorplanErrorType.DataNotLoaded);
@@ -6779,7 +6722,7 @@
6779
6722
  userAction: true,
6780
6723
  };
6781
6724
  const mergedOptions = Object.assign(Object.assign({}, baseShowOpts), options);
6782
- const getShowPromise = () => __awaiter(this, void 0, void 0, function* () {
6725
+ const getShowPromise = async () => {
6783
6726
  this.hooks.emit('show', { userAction: mergedOptions.userAction, auto: mergedOptions.isAutoShow });
6784
6727
  let hasRejected = false;
6785
6728
  let externalErrorMsg;
@@ -6787,7 +6730,7 @@
6787
6730
  hasRejected = true;
6788
6731
  externalErrorMsg = errorMsg;
6789
6732
  };
6790
- const [correctError] = yield to(correctFiveState(this.five, this.showState, mergedOptions.userAction));
6733
+ const [correctError] = await to(correctFiveState(this.five, this.showState, mergedOptions.userAction));
6791
6734
  if (correctError)
6792
6735
  throw correctError;
6793
6736
  // 异步结束要判断当前是不是被中断了
@@ -6805,7 +6748,7 @@
6805
6748
  const renderDuration = mergedOptions.immediately ? 0 : SHOW_ANIME_DURATION;
6806
6749
  changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
6807
6750
  this.render(renderDuration);
6808
- });
6751
+ };
6809
6752
  this.showPromise = getShowPromise()
6810
6753
  .then(() => {
6811
6754
  this.hooks.emit('showAnimationEnded', {
@@ -6827,7 +6770,7 @@
6827
6770
  this.showRejection = undefined;
6828
6771
  });
6829
6772
  return this.showPromise;
6830
- })
6773
+ }
6831
6774
  });
6832
6775
  Object.defineProperty(this, "_hide", {
6833
6776
  enumerable: true,
@@ -7061,24 +7004,22 @@
7061
7004
  five.once('dispose', this.dispose);
7062
7005
  this.addEventListener();
7063
7006
  }
7064
- load(serverData, state, userAction = true) {
7065
- return __awaiter(this, void 0, void 0, function* () {
7066
- function isPluginServerData(serverData) {
7067
- return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
7068
- }
7069
- const _data = serverData;
7070
- if (_data && !_data.version)
7071
- console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
7072
- const copyData = JSON.parse(JSON.stringify(serverData));
7073
- const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
7074
- const prevData = this.data;
7075
- this.data = yield formatData(_serverData);
7076
- this.hooks.emit('dataLoaded', this.data);
7077
- this.hooks.emit('dataChange', this.data, prevData);
7078
- if (state)
7079
- this.updateState(state, userAction);
7080
- this.render();
7081
- });
7007
+ async load(serverData, state, userAction = true) {
7008
+ function isPluginServerData(serverData) {
7009
+ return Object.prototype.hasOwnProperty.apply(serverData, ['version']);
7010
+ }
7011
+ const _data = serverData;
7012
+ if (_data && !_data.version)
7013
+ console.warn('传入 serverData.data 的方式后续可能不再支持,请把 serverData 整体传入 load 函数');
7014
+ const copyData = JSON.parse(JSON.stringify(serverData));
7015
+ const _serverData = isPluginServerData(copyData) ? copyData.data : copyData;
7016
+ const prevData = this.data;
7017
+ this.data = await formatData(_serverData);
7018
+ this.hooks.emit('dataLoaded', this.data);
7019
+ this.hooks.emit('dataChange', this.data, prevData);
7020
+ if (state)
7021
+ this.updateState(state, userAction);
7022
+ this.render();
7082
7023
  }
7083
7024
  /** 把插件的渲染DOM插入到对应的容器中去 */
7084
7025
  appendTo(wrapper) {
@@ -7126,10 +7067,8 @@
7126
7067
  return;
7127
7068
  this.render();
7128
7069
  }
7129
- formatData(serverData) {
7130
- return __awaiter(this, void 0, void 0, function* () {
7131
- return yield formatData(serverData.data);
7132
- });
7070
+ async formatData(serverData) {
7071
+ return await formatData(serverData.data);
7133
7072
  }
7134
7073
  updateState(state, userAction) {
7135
7074
  const prevState = this.state;
@@ -7357,10 +7296,10 @@
7357
7296
  const defaultNorthRad = (_a = params.north_rad) !== null && _a !== void 0 ? _a : undefined;
7358
7297
  // 局部状态
7359
7298
  const state = {};
7360
- const load = (data) => __awaiter(void 0, void 0, void 0, function* () {
7361
- var _b;
7299
+ const load = async (data) => {
7300
+ var _a;
7362
7301
  const fbxUrl = (data === null || data === void 0 ? void 0 : data.fbx_url) || defaultFbxUrl;
7363
- const northRad = (_b = data === null || data === void 0 ? void 0 : data.north_rad) !== null && _b !== void 0 ? _b : defaultNorthRad;
7302
+ const northRad = (_a = data === null || data === void 0 ? void 0 : data.north_rad) !== null && _a !== void 0 ? _a : defaultNorthRad;
7364
7303
  if (typeof northRad !== 'number') {
7365
7304
  throw new Error('"northRad"配置参数缺失:未配置指南针指向!');
7366
7305
  }
@@ -7369,7 +7308,7 @@
7369
7308
  const zOffset = bounding.max.z - bounding.min.z;
7370
7309
  const maxOffset = Math.max(xOffset, zOffset);
7371
7310
  const fbxLoader = new FBXLoader.FBXLoader();
7372
- const object = yield fbxLoader.loadAsync(fbxUrl);
7311
+ const object = await fbxLoader.loadAsync(fbxUrl);
7373
7312
  transfromToMeshBasicMaterial(object, {
7374
7313
  transparent: true,
7375
7314
  side: THREE__namespace.DoubleSide,
@@ -7383,7 +7322,7 @@
7383
7322
  bject3d2LocalMatrix(object, { position, rotation, scale });
7384
7323
  state.object = object;
7385
7324
  return true;
7386
- });
7325
+ };
7387
7326
  const onCameraUpdate = ({ latitude }) => {
7388
7327
  if (!state.object)
7389
7328
  return;
@@ -7453,25 +7392,25 @@
7453
7392
  const defaultRad = (_c = params.rad) !== null && _c !== void 0 ? _c : undefined;
7454
7393
  const defaultFbxUrl = params.fbx_url || '//vrlab-image4.ljcdn.com/release/web/entryDoorMini/Anim_Door1.fbx';
7455
7394
  const mixers = [];
7456
- const load = (data) => __awaiter(void 0, void 0, void 0, function* () {
7457
- var _d, _e, _f, _g, _h, _j, _k;
7458
- const position = (_d = data === null || data === void 0 ? void 0 : data.position) !== null && _d !== void 0 ? _d : defaultModelPosition;
7395
+ const load = async (data) => {
7396
+ var _a, _b, _c, _d, _e, _f, _g;
7397
+ const position = (_a = data === null || data === void 0 ? void 0 : data.position) !== null && _a !== void 0 ? _a : defaultModelPosition;
7459
7398
  if (!position)
7460
7399
  return Promise.reject(`ModelEntryDoorGuidePlugin.load(): position is undefined`);
7461
7400
  const modelPosition = transformPositionToVector3(position);
7462
- const rad = (_e = data === null || data === void 0 ? void 0 : data.rad) !== null && _e !== void 0 ? _e : defaultRad;
7463
- const fbxUrl = (_f = data === null || data === void 0 ? void 0 : data.fbx_url) !== null && _f !== void 0 ? _f : defaultFbxUrl;
7401
+ const rad = (_b = data === null || data === void 0 ? void 0 : data.rad) !== null && _b !== void 0 ? _b : defaultRad;
7402
+ const fbxUrl = (_c = data === null || data === void 0 ? void 0 : data.fbx_url) !== null && _c !== void 0 ? _c : defaultFbxUrl;
7464
7403
  state.rad = rad;
7465
7404
  if (rad === undefined)
7466
7405
  return Promise.reject(`ModelEntryDoorGuidePlugin.load(): rad is ${rad}`);
7467
7406
  // 加载模型
7468
- const object = yield new FBXLoader.FBXLoader().loadAsync(fbxUrl);
7407
+ const object = await new FBXLoader.FBXLoader().loadAsync(fbxUrl);
7469
7408
  // 设置位置
7470
7409
  object.position.copy(modelPosition);
7471
7410
  object.rotation.z = rad;
7472
7411
  object.scale.set(0.8, 0.8, 0.8);
7473
7412
  transfromToMeshBasicMaterial(object, { transparent: true, side: THREE__namespace.DoubleSide });
7474
- const textMesh = (_k = (_j = (_h = (_g = object.children) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.children) === null || _j === void 0 ? void 0 : _j[3]) === null || _k === void 0 ? void 0 : _k.clone();
7413
+ const textMesh = (_g = (_f = (_e = (_d = object.children) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.children) === null || _f === void 0 ? void 0 : _f[3]) === null || _g === void 0 ? void 0 : _g.clone();
7475
7414
  if (!textMesh)
7476
7415
  return Promise.reject(`ModelEntryDoorGuidePlugin.load(): textMesh is ${textMesh}`);
7477
7416
  textMesh.material = new THREE.MeshBasicMaterial({ transparent: true, map: createCanvasTextTexture('入户门') });
@@ -7479,7 +7418,7 @@
7479
7418
  object.children[0].add(textMesh);
7480
7419
  state.object = object;
7481
7420
  return true;
7482
- });
7421
+ };
7483
7422
  const initAnimation = () => {
7484
7423
  if (state.animation)
7485
7424
  return;
@@ -7716,21 +7655,21 @@
7716
7655
  */
7717
7656
  const CameraMovementPlugin = (five$1) => {
7718
7657
  const state = {};
7719
- const move = (args, duration, opts = { preload: true }) => __awaiter(void 0, void 0, void 0, function* () {
7658
+ const move = async (args, duration, opts = { preload: true }) => {
7720
7659
  if (state.interruptCallback) {
7721
7660
  state.interruptCallback(false);
7722
7661
  }
7723
7662
  if (opts.asyncStartCallback) {
7724
- yield opts.asyncStartCallback();
7663
+ await opts.asyncStartCallback();
7725
7664
  }
7726
7665
  if (args.mode && args.mode !== five$1.currentMode) {
7727
- yield five$1.changeMode(args.mode);
7666
+ await five$1.changeMode(args.mode);
7728
7667
  }
7729
7668
  if (opts.preload && args.panoIndex !== undefined && args.panoIndex !== five$1.panoIndex) {
7730
- yield five$1.preloadPano(args.panoIndex);
7669
+ await five$1.preloadPano(args.panoIndex);
7731
7670
  }
7732
7671
  if (opts.asyncEndCallback) {
7733
- yield opts.asyncEndCallback();
7672
+ await opts.asyncEndCallback();
7734
7673
  }
7735
7674
  if (args.panoIndex === undefined &&
7736
7675
  args.fov === undefined &&
@@ -7738,7 +7677,7 @@
7738
7677
  args.longitude === undefined) {
7739
7678
  return true;
7740
7679
  }
7741
- return yield new Promise((resolve, reject) => {
7680
+ return await new Promise((resolve, reject) => {
7742
7681
  const panoIndex = args.panoIndex !== undefined ? args.panoIndex : five$1.panoIndex;
7743
7682
  if (panoIndex !== undefined) {
7744
7683
  five$1.moveToPano(panoIndex, Object.assign({
@@ -7751,7 +7690,7 @@
7751
7690
  reject(false);
7752
7691
  }
7753
7692
  });
7754
- });
7693
+ };
7755
7694
  const getAnimeParams = (args) => {
7756
7695
  const currentFiveState = five$1.state;
7757
7696
  // latitude
@@ -7767,20 +7706,20 @@
7767
7706
  to: { latitude: toLatitude, longitude: toLongitude, fov: toFov },
7768
7707
  };
7769
7708
  };
7770
- const rotate = (args, duration, opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
7709
+ const rotate = async (args, duration, opts = {}) => {
7771
7710
  if (state.interruptCallback) {
7772
7711
  state.interruptCallback(false);
7773
7712
  }
7774
7713
  if (opts.asyncStartCallback) {
7775
- yield opts.asyncStartCallback();
7714
+ await opts.asyncStartCallback();
7776
7715
  }
7777
7716
  if (five$1.currentMode !== five.Five.Mode.Panorama) {
7778
- yield five$1.changeMode(five.Five.Mode.Panorama);
7717
+ await five$1.changeMode(five.Five.Mode.Panorama);
7779
7718
  }
7780
7719
  if (args.panoIndex !== undefined && args.panoIndex !== five$1.panoIndex) {
7781
7720
  if (opts.preload)
7782
- yield five$1.preloadPano(args.panoIndex);
7783
- yield new Promise((resolve, reject) => {
7721
+ await five$1.preloadPano(args.panoIndex);
7722
+ await new Promise((resolve, reject) => {
7784
7723
  if (!args.panoIndex) {
7785
7724
  resolve(true);
7786
7725
  return;
@@ -7792,10 +7731,10 @@
7792
7731
  });
7793
7732
  }
7794
7733
  if (opts.asyncEndCallback) {
7795
- yield opts.asyncEndCallback();
7734
+ await opts.asyncEndCallback();
7796
7735
  }
7797
7736
  const { from, to } = getAnimeParams(args);
7798
- return yield new Promise((resolve) => {
7737
+ return await new Promise((resolve) => {
7799
7738
  const onUpdate = ({ progress }) => {
7800
7739
  const state = {};
7801
7740
  state.longitude = progressNumber(from.longitude, to.longitude, progress);
@@ -7837,7 +7776,7 @@
7837
7776
  state.interruptCallback(true);
7838
7777
  }, duration);
7839
7778
  });
7840
- });
7779
+ };
7841
7780
  return {
7842
7781
  move,
7843
7782
  rotate,
@@ -8197,7 +8136,7 @@
8197
8136
  freshRule();
8198
8137
  return true;
8199
8138
  };
8200
- const load = (_roomInfo, _roomRules, options) => __awaiter(void 0, void 0, void 0, function* () {
8139
+ const load = async (_roomInfo, _roomRules, options) => {
8201
8140
  const roomInfo = _roomInfo || params.roomInfo;
8202
8141
  const roomRules = _roomRules || params.roomRules;
8203
8142
  if (!roomInfo || !roomRules) {
@@ -8209,9 +8148,9 @@
8209
8148
  return _load(roomInfo, roomRules);
8210
8149
  }
8211
8150
  else {
8212
- return yield new Promise((resolve) => five$1.once('modelLoaded', () => resolve(_load(roomInfo, roomRules))));
8151
+ return await new Promise((resolve) => five$1.once('modelLoaded', () => resolve(_load(roomInfo, roomRules))));
8213
8152
  }
8214
- });
8153
+ };
8215
8154
  if (params.roomInfo && params.roomRules) {
8216
8155
  load(params.roomInfo, params.roomRules);
8217
8156
  }
@@ -9121,22 +9060,20 @@
9121
9060
  if ((_a = params.options) === null || _a === void 0 ? void 0 : _a.className)
9122
9061
  this.container.classList.add((_b = params.options) === null || _b === void 0 ? void 0 : _b.className);
9123
9062
  }
9124
- this.five.once('modelLoaded', () => __awaiter(this, void 0, void 0, function* () {
9125
- var _c, _d;
9126
- (_d = (_c = this.five.getElement()) === null || _c === void 0 ? void 0 : _c.parentNode) === null || _d === void 0 ? void 0 : _d.append(this.container);
9127
- }));
9063
+ this.five.once('modelLoaded', async () => {
9064
+ var _a, _b;
9065
+ (_b = (_a = this.five.getElement()) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.append(this.container);
9066
+ });
9128
9067
  this.five.once('dispose', () => this.dispose());
9129
9068
  }
9130
- load(serverData) {
9131
- return __awaiter(this, void 0, void 0, function* () {
9132
- if (!this.five.work)
9133
- return;
9134
- const data = serverData.data;
9135
- if (!data)
9136
- throw new Error('标尺数据依赖不齐全!');
9137
- this.panoRulerProData = data;
9138
- this.state.loaded = true;
9139
- });
9069
+ async load(serverData) {
9070
+ if (!this.five.work)
9071
+ return;
9072
+ const data = serverData.data;
9073
+ if (!data)
9074
+ throw new Error('标尺数据依赖不齐全!');
9075
+ this.panoRulerProData = data;
9076
+ this.state.loaded = true;
9140
9077
  }
9141
9078
  enable() {
9142
9079
  if (!this.state.loaded)
@@ -9154,26 +9091,24 @@
9154
9091
  this.render();
9155
9092
  return true;
9156
9093
  }
9157
- render() {
9094
+ async render() {
9158
9095
  var _a;
9159
- return __awaiter(this, void 0, void 0, function* () {
9160
- if (this.state.enabled) {
9161
- if (!this.panoRulerProData || !this.container)
9162
- return;
9163
- this.rulerItems = new RulerItems({
9164
- target: this.container,
9165
- props: {
9166
- five: this.five,
9167
- rulerDatas: this.panoRulerProData,
9168
- options: this.state.options,
9169
- },
9170
- });
9171
- }
9172
- else {
9173
- (_a = this.rulerItems) === null || _a === void 0 ? void 0 : _a.$destroy();
9174
- this.rulerItems = undefined;
9175
- }
9176
- });
9096
+ if (this.state.enabled) {
9097
+ if (!this.panoRulerProData || !this.container)
9098
+ return;
9099
+ this.rulerItems = new RulerItems({
9100
+ target: this.container,
9101
+ props: {
9102
+ five: this.five,
9103
+ rulerDatas: this.panoRulerProData,
9104
+ options: this.state.options,
9105
+ },
9106
+ });
9107
+ }
9108
+ else {
9109
+ (_a = this.rulerItems) === null || _a === void 0 ? void 0 : _a.$destroy();
9110
+ this.rulerItems = undefined;
9111
+ }
9177
9112
  }
9178
9113
  dispose() {
9179
9114
  if (this.container) {
@@ -9242,14 +9177,12 @@
9242
9177
  }
9243
9178
 
9244
9179
  const textureLoader = new THREE__namespace.TextureLoader();
9245
- function loadTexture(url) {
9246
- return __awaiter(this, void 0, void 0, function* () {
9247
- return new Promise((resolve, reject) => {
9248
- textureLoader.load(url, resolve, undefined, reject);
9249
- }).then((texture) => {
9250
- texture.encoding = THREE__namespace.sRGBEncoding;
9251
- return texture;
9252
- });
9180
+ async function loadTexture(url) {
9181
+ return new Promise((resolve, reject) => {
9182
+ textureLoader.load(url, resolve, undefined, reject);
9183
+ }).then((texture) => {
9184
+ texture.encoding = THREE__namespace.sRGBEncoding;
9185
+ return texture;
9253
9186
  });
9254
9187
  }
9255
9188
 
@@ -9676,19 +9609,17 @@
9676
9609
  this.init();
9677
9610
  }
9678
9611
  }
9679
- load(data, state, userAction = true) {
9680
- return __awaiter(this, void 0, void 0, function* () {
9681
- const nextData = yield this.formatData(data);
9682
- if (JSON.stringify(this.data) !== JSON.stringify(nextData)) {
9683
- this.hooks.emit('dataChange', nextData, this.data);
9684
- this.data = Object.assign({}, nextData);
9685
- this.init();
9686
- if (state) {
9687
- this.setState(state, { userAction });
9688
- }
9689
- this.hooks.emit('dataLoaded', this.data);
9612
+ async load(data, state, userAction = true) {
9613
+ const nextData = await this.formatData(data);
9614
+ if (JSON.stringify(this.data) !== JSON.stringify(nextData)) {
9615
+ this.hooks.emit('dataChange', nextData, this.data);
9616
+ this.data = Object.assign({}, nextData);
9617
+ this.init();
9618
+ if (state) {
9619
+ this.setState(state, { userAction });
9690
9620
  }
9691
- });
9621
+ this.hooks.emit('dataLoaded', this.data);
9622
+ }
9692
9623
  }
9693
9624
  formatData(serverData) {
9694
9625
  if (serverData.version && serverData.data) {
@@ -9702,64 +9633,58 @@
9702
9633
  * 初始化
9703
9634
  * @todo 逻辑需要细分
9704
9635
  */
9705
- init() {
9636
+ async init() {
9706
9637
  var _a, _b, _c, _d;
9707
- return __awaiter(this, void 0, void 0, function* () {
9708
- const northRad = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.north_rad) !== null && _b !== void 0 ? _b : null;
9709
- this._clearCompassIfNeed();
9710
- if (northRad !== null) {
9711
- this.compassMesh = yield this.loadCompassMesh();
9712
- this.compassMesh.rotateX(-Math.PI / 2);
9713
- this.compassMesh.rotateZ(northRad - Math.PI / 2);
9714
- this.group.add(this.compassMesh);
9715
- }
9716
- const entrance = (_d = (_c = this.data) === null || _c === void 0 ? void 0 : _c.entrance) !== null && _d !== void 0 ? _d : null;
9717
- this._clearEntryDoorIfNeed();
9718
- if (entrance !== null) {
9719
- this.entryDoorMesh = yield this.loadEntryDoorMesh();
9720
- this.roomInfoWrapperInstance = this.loadRoomInfo();
9721
- this.roomInfoInstance = getRoomInfoInstance();
9722
- this.entryDoorMesh.rotateX(-Math.PI / 2);
9723
- if (this.roomInfoWrapperInstance) {
9724
- this.roomInfoInstance.appendTo(this.roomInfoWrapperInstance.container);
9725
- }
9726
- this.group.add(this.entryDoorMesh);
9638
+ const northRad = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.north_rad) !== null && _b !== void 0 ? _b : null;
9639
+ this._clearCompassIfNeed();
9640
+ if (northRad !== null) {
9641
+ this.compassMesh = await this.loadCompassMesh();
9642
+ this.compassMesh.rotateX(-Math.PI / 2);
9643
+ this.compassMesh.rotateZ(northRad - Math.PI / 2);
9644
+ this.group.add(this.compassMesh);
9645
+ }
9646
+ const entrance = (_d = (_c = this.data) === null || _c === void 0 ? void 0 : _c.entrance) !== null && _d !== void 0 ? _d : null;
9647
+ this._clearEntryDoorIfNeed();
9648
+ if (entrance !== null) {
9649
+ this.entryDoorMesh = await this.loadEntryDoorMesh();
9650
+ this.roomInfoWrapperInstance = this.loadRoomInfo();
9651
+ this.roomInfoInstance = getRoomInfoInstance();
9652
+ this.entryDoorMesh.rotateX(-Math.PI / 2);
9653
+ if (this.roomInfoWrapperInstance) {
9654
+ this.roomInfoInstance.appendTo(this.roomInfoWrapperInstance.container);
9727
9655
  }
9728
- this.onFivePanoArrived(this.five.panoIndex || 0);
9729
- this.five.needsRender = true;
9730
- });
9656
+ this.group.add(this.entryDoorMesh);
9657
+ }
9658
+ this.onFivePanoArrived(this.five.panoIndex || 0);
9659
+ this.five.needsRender = true;
9731
9660
  }
9732
- loadCompassMesh() {
9733
- return __awaiter(this, void 0, void 0, function* () {
9734
- const compassImageUrl = this.state.config.compassImageUrl;
9735
- const compassTexture = yield loadTexture(compassImageUrl);
9736
- const compassGeometry = new THREE__namespace.CircleGeometry(0.7, 32);
9737
- const compassMaterial = new THREE__namespace.MeshBasicMaterial({
9738
- map: compassTexture,
9739
- transparent: true,
9740
- opacity: 0,
9741
- depthTest: false,
9742
- });
9743
- const compassMesh = new THREE__namespace.Mesh(compassGeometry, compassMaterial);
9744
- compassMesh.name = 'pano-compass-mesh';
9745
- return compassMesh;
9661
+ async loadCompassMesh() {
9662
+ const compassImageUrl = this.state.config.compassImageUrl;
9663
+ const compassTexture = await loadTexture(compassImageUrl);
9664
+ const compassGeometry = new THREE__namespace.CircleGeometry(0.7, 32);
9665
+ const compassMaterial = new THREE__namespace.MeshBasicMaterial({
9666
+ map: compassTexture,
9667
+ transparent: true,
9668
+ opacity: 0,
9669
+ depthTest: false,
9746
9670
  });
9671
+ const compassMesh = new THREE__namespace.Mesh(compassGeometry, compassMaterial);
9672
+ compassMesh.name = 'pano-compass-mesh';
9673
+ return compassMesh;
9747
9674
  }
9748
- loadEntryDoorMesh() {
9749
- return __awaiter(this, void 0, void 0, function* () {
9750
- const entryDoorImageUrl = this.state.config.entryDoorImageUrl;
9751
- const entryDoorTexture = yield loadTexture(entryDoorImageUrl);
9752
- const entryDoorGeometry = new THREE__namespace.PlaneGeometry(0.2, 0.16);
9753
- const entryDoorMaterial = new THREE__namespace.MeshBasicMaterial({
9754
- map: entryDoorTexture,
9755
- transparent: true,
9756
- opacity: 0.8,
9757
- depthTest: false,
9758
- });
9759
- const entryDoorMesh = new THREE__namespace.Mesh(entryDoorGeometry, entryDoorMaterial);
9760
- entryDoorMesh.name = 'pano-compass-entry-door';
9761
- return entryDoorMesh;
9675
+ async loadEntryDoorMesh() {
9676
+ const entryDoorImageUrl = this.state.config.entryDoorImageUrl;
9677
+ const entryDoorTexture = await loadTexture(entryDoorImageUrl);
9678
+ const entryDoorGeometry = new THREE__namespace.PlaneGeometry(0.2, 0.16);
9679
+ const entryDoorMaterial = new THREE__namespace.MeshBasicMaterial({
9680
+ map: entryDoorTexture,
9681
+ transparent: true,
9682
+ opacity: 0.8,
9683
+ depthTest: false,
9762
9684
  });
9685
+ const entryDoorMesh = new THREE__namespace.Mesh(entryDoorGeometry, entryDoorMaterial);
9686
+ entryDoorMesh.name = 'pano-compass-entry-door';
9687
+ return entryDoorMesh;
9763
9688
  }
9764
9689
  loadRoomInfo() {
9765
9690
  const points = [
@@ -15669,7 +15594,7 @@ void main() {
15669
15594
  xhr.send();
15670
15595
  });
15671
15596
  };
15672
- const load = (data, videoElement) => __awaiter(void 0, void 0, void 0, function* () {
15597
+ const load = async (data, videoElement) => {
15673
15598
  const { video_src, video_poster_src, points } = data;
15674
15599
  state.videoSource = video_src;
15675
15600
  // TODO 存疑,先处理多一次遍历 o(2n)
@@ -15679,11 +15604,11 @@ void main() {
15679
15604
  if (videoElement) {
15680
15605
  state.videoElement = videoElement;
15681
15606
  }
15682
- state.videoTexture = yield getVideoTexture(state.videoSource, state.videoElement);
15607
+ state.videoTexture = await getVideoTexture(state.videoSource, state.videoElement);
15683
15608
  state.enabled = !!data.enable;
15684
15609
  if (state.enabled)
15685
15610
  enable();
15686
- });
15611
+ };
15687
15612
  const dispose = () => {
15688
15613
  disable();
15689
15614
  state.videoTexture = undefined;