@realsee/dnalogel 2.0.0-alpha.18 → 2.0.0-alpha.20

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 (177) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/CSS3DRenderPlugin/index.d.ts +2 -2
  3. package/dist/CameraMovementPlugin/index.js +15 -40
  4. package/dist/CameraMovementPlugin/typing.d.ts +1 -1
  5. package/dist/ModelChassisCompassPlugin/index.js +3 -28
  6. package/dist/ModelEntryDoorGuidePlugin/index.d.ts +1 -1
  7. package/dist/ModelEntryDoorGuidePlugin/index.js +8 -33
  8. package/dist/ModelItemLabelPlugin/events.type.d.ts +2 -2
  9. package/dist/ModelItemLabelPlugin/typings.d.ts +2 -2
  10. package/dist/ModelItemLabelPlugin/utils/parseData.d.ts +1 -1
  11. package/dist/ModelRoomLabelPlugin/utils/parseData.d.ts +1 -1
  12. package/dist/ModelTVVideoPlugin/index.d.ts +1 -1
  13. package/dist/ModelTVVideoPlugin/index.js +3 -28
  14. package/dist/PanoCompassPlugin/index.js +53 -86
  15. package/dist/PanoCursorRaycasterPlugin/index.d.ts +1 -1
  16. package/dist/PanoMeasurePlugin/Controller/BaseController.d.ts +8 -8
  17. package/dist/PanoMeasurePlugin/Controller/EditController.d.ts +1 -1
  18. package/dist/PanoMeasurePlugin/Controller/ShortcutKeyController.d.ts +2 -2
  19. package/dist/PanoMeasurePlugin/Controller/WatchController.d.ts +1 -1
  20. package/dist/PanoMeasurePlugin/Controller/index.d.ts +3 -3
  21. package/dist/PanoMeasurePlugin/Model/index.d.ts +2 -2
  22. package/dist/PanoMeasurePlugin/Model/line.d.ts +5 -5
  23. package/dist/PanoMeasurePlugin/Model/point.d.ts +2 -2
  24. package/dist/PanoMeasurePlugin/Model/polyline.d.ts +3 -3
  25. package/dist/PanoMeasurePlugin/Modules/DeleteDom/index.d.ts +2 -2
  26. package/dist/PanoMeasurePlugin/Modules/FiveHelper.d.ts +1 -1
  27. package/dist/PanoMeasurePlugin/Modules/GuideController.d.ts +1 -1
  28. package/dist/PanoMeasurePlugin/Modules/Magnifier.d.ts +1 -1
  29. package/dist/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +1 -1
  30. package/dist/PanoMeasurePlugin/Modules/UIController/Revoke/index.d.ts +2 -1
  31. package/dist/PanoMeasurePlugin/Modules/UIController/index.d.ts +1 -1
  32. package/dist/PanoMeasurePlugin/index.d.ts +1 -1
  33. package/dist/PanoMeasurePlugin/index.js +2 -0
  34. package/dist/PanoMeasurePlugin/typings/event.type.d.ts +4 -4
  35. package/dist/PanoMeasurePlugin/utils/clearGroup.d.ts +1 -1
  36. package/dist/PanoMeasurePlugin/utils/constants.d.ts +1 -1
  37. package/dist/PanoMeasurePlugin/utils/distanceDom.d.ts +3 -3
  38. package/dist/PanoMeasurePlugin/utils/findAssociatedLines.d.ts +1 -1
  39. package/dist/PanoMeasurePlugin/utils/findClosestPoint.d.ts +3 -3
  40. package/dist/PanoMeasurePlugin/utils/getIntersectionFromEvent.d.ts +2 -2
  41. package/dist/PanoMeasurePlugin/utils/getPointFromHammerEvent.d.ts +1 -1
  42. package/dist/PanoMeasurePlugin/utils/isNDCPointInScreen.d.ts +1 -1
  43. package/dist/PanoMeasurePlugin/utils/line.d.ts +1 -1
  44. package/dist/PanoRulerPlugin/index.d.ts +1 -1
  45. package/dist/PanoRulerPlugin/index.js +3 -28
  46. package/dist/PanoSpatialTagPlugin/typings.d.ts +1 -1
  47. package/dist/floorplan/{ModelFloorplanPlugin/Assets → Assets}/compass.d.ts +0 -0
  48. package/dist/floorplan/ModelFloorplanPlugin/Controller.d.ts +2 -2
  49. package/dist/floorplan/ModelFloorplanPlugin/index.js +1253 -1284
  50. package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +61 -183
  51. package/dist/floorplan/TopviewFloorplanPlugin/Controller.d.ts +28 -15
  52. package/dist/floorplan/TopviewFloorplanPlugin/index.d.ts +1 -1
  53. package/dist/floorplan/TopviewFloorplanPlugin/index.js +1243 -1235
  54. package/dist/floorplan/utils/formatPosition.d.ts +1 -1
  55. package/dist/index.es.js +1431 -1435
  56. package/dist/index.js +1430 -1434
  57. package/dist/index.umd.js +1430 -1434
  58. package/dist/shared-utils/three/getExtraModelLoader.d.ts +1 -1
  59. package/dist/shared-utils/three/getNormal.d.ts +1 -1
  60. package/dist/shared-utils/three/getTextureLoader.d.ts +1 -1
  61. package/dist/shared-utils/three/loadFbxObj.d.ts +1 -1
  62. package/dist/shared-utils/vectorTocoordinates.d.ts +1 -1
  63. package/docs/assets/search.js +1 -1
  64. package/docs/classes/ModelRoomLabelController.html +6 -6
  65. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  66. package/docs/enums/ModelFloorplanErrorType.html +1 -1
  67. package/docs/interfaces/LineJson.html +1 -1
  68. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  69. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  70. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  71. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  72. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  73. package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
  74. package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
  75. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  76. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  77. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  78. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  79. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  80. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  81. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  82. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  83. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  84. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  85. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  86. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  87. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  88. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  89. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  90. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  91. package/docs/interfaces/PointJson.html +1 -1
  92. package/docs/interfaces/RoomLabel.html +7 -7
  93. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +19 -1
  94. package/docs/modules.html +12 -12
  95. package/libs/CSS3DRenderPlugin/index.d.ts +2 -2
  96. package/libs/CameraMovementPlugin/index.js +15 -24
  97. package/libs/CameraMovementPlugin/typing.d.ts +1 -1
  98. package/libs/ModelChassisCompassPlugin/index.js +3 -12
  99. package/libs/ModelEntryDoorGuidePlugin/index.d.ts +1 -1
  100. package/libs/ModelEntryDoorGuidePlugin/index.js +8 -17
  101. package/libs/ModelItemLabelPlugin/events.type.d.ts +2 -2
  102. package/libs/ModelItemLabelPlugin/typings.d.ts +2 -2
  103. package/libs/ModelItemLabelPlugin/utils/parseData.d.ts +1 -1
  104. package/libs/ModelRoomLabelPlugin/utils/parseData.d.ts +1 -1
  105. package/libs/ModelTVVideoPlugin/index.d.ts +1 -1
  106. package/libs/ModelTVVideoPlugin/index.js +3 -12
  107. package/libs/ModelTVVideoPlugin/typings.js +1 -0
  108. package/libs/PanoCompassPlugin/index.js +49 -64
  109. package/libs/PanoCursorRaycasterPlugin/index.d.ts +1 -1
  110. package/libs/PanoMeasurePlugin/Controller/BaseController.d.ts +8 -8
  111. package/libs/PanoMeasurePlugin/Controller/EditController.d.ts +1 -1
  112. package/libs/PanoMeasurePlugin/Controller/ShortcutKeyController.d.ts +2 -2
  113. package/libs/PanoMeasurePlugin/Controller/WatchController.d.ts +1 -1
  114. package/libs/PanoMeasurePlugin/Controller/index.d.ts +3 -3
  115. package/libs/PanoMeasurePlugin/Model/index.d.ts +2 -2
  116. package/libs/PanoMeasurePlugin/Model/line.d.ts +5 -5
  117. package/libs/PanoMeasurePlugin/Model/line.js +1 -1
  118. package/libs/PanoMeasurePlugin/Model/point.d.ts +2 -2
  119. package/libs/PanoMeasurePlugin/Model/polyline.d.ts +3 -3
  120. package/libs/PanoMeasurePlugin/Modules/DeleteDom/index.d.ts +2 -2
  121. package/libs/PanoMeasurePlugin/Modules/FiveHelper.d.ts +1 -1
  122. package/libs/PanoMeasurePlugin/Modules/GuideController.d.ts +1 -1
  123. package/libs/PanoMeasurePlugin/Modules/Magnifier.d.ts +1 -1
  124. package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +1 -1
  125. package/libs/PanoMeasurePlugin/Modules/UIController/Revoke/index.d.ts +2 -1
  126. package/libs/PanoMeasurePlugin/Modules/UIController/index.d.ts +1 -1
  127. package/libs/PanoMeasurePlugin/Modules/UIController/index.js +2 -0
  128. package/libs/PanoMeasurePlugin/index.d.ts +1 -1
  129. package/libs/PanoMeasurePlugin/typings/event.type.d.ts +4 -4
  130. package/libs/PanoMeasurePlugin/utils/clearGroup.d.ts +1 -1
  131. package/libs/PanoMeasurePlugin/utils/constants.d.ts +1 -1
  132. package/libs/PanoMeasurePlugin/utils/distanceDom.d.ts +3 -3
  133. package/libs/PanoMeasurePlugin/utils/findAssociatedLines.d.ts +1 -1
  134. package/libs/PanoMeasurePlugin/utils/findClosestPoint.d.ts +3 -3
  135. package/libs/PanoMeasurePlugin/utils/getIntersectionFromEvent.d.ts +2 -2
  136. package/libs/PanoMeasurePlugin/utils/getPointFromHammerEvent.d.ts +1 -1
  137. package/libs/PanoMeasurePlugin/utils/isNDCPointInScreen.d.ts +1 -1
  138. package/libs/PanoMeasurePlugin/utils/line.d.ts +1 -1
  139. package/libs/PanoMeasurePlugin/utils/mouseGroup.js +1 -0
  140. package/libs/PanoRulerPlugin/index.d.ts +1 -1
  141. package/libs/PanoRulerPlugin/index.js +3 -12
  142. package/libs/PanoSpatialTagPlugin/typings.d.ts +1 -1
  143. package/libs/floorplan/{ModelFloorplanPlugin/Assets → Assets}/compass.d.ts +0 -0
  144. package/libs/floorplan/{ModelFloorplanPlugin/Assets → Assets}/compass.js +0 -0
  145. package/libs/floorplan/{ModelFloorplanPlugin/Components → Components}/Camera.js +2 -2
  146. package/libs/floorplan/{ModelFloorplanPlugin/Components → Components}/Compass.js +0 -0
  147. package/libs/floorplan/{ModelFloorplanPlugin/Components/CurrentFloor → Components}/CurrentFloor.js +73 -80
  148. package/libs/floorplan/{ModelFloorplanPlugin/Components → Components}/Main.js +186 -105
  149. package/libs/floorplan/Components/RoomHighlight/Room.js +5 -7
  150. package/libs/floorplan/Components/RoomHighlight/RoomHighlight.js +24 -116
  151. package/libs/floorplan/{ModelFloorplanPlugin/Components → Components}/RoomLabels/RoomLabel.js +0 -0
  152. package/libs/floorplan/{ModelFloorplanPlugin/Components → Components}/RoomLabels/RoomLabels.js +2 -2
  153. package/libs/floorplan/Components/RoomMaterials/RoomMaterial.js +26 -22
  154. package/libs/floorplan/Components/RuleLabels/RuleItem.js +284 -0
  155. package/libs/floorplan/{ModelFloorplanPlugin/Components → Components}/RuleLabels/RuleLabels.js +82 -32
  156. package/libs/floorplan/ModelFloorplanPlugin/Controller.d.ts +2 -2
  157. package/libs/floorplan/ModelFloorplanPlugin/Controller.js +34 -43
  158. package/libs/floorplan/ModelFloorplanPlugin/utils/correctFiveState.js +22 -33
  159. package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +3 -12
  160. package/libs/floorplan/TopviewFloorplanPlugin/Controller.d.ts +28 -15
  161. package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +80 -54
  162. package/libs/floorplan/TopviewFloorplanPlugin/index.d.ts +1 -1
  163. package/libs/floorplan/TopviewFloorplanPlugin/style.js +0 -1
  164. package/libs/floorplan/utils/formatData.js +28 -43
  165. package/libs/floorplan/utils/formatPosition.d.ts +1 -1
  166. package/libs/floorplan/utils/formatPosition.js +2 -2
  167. package/libs/shared-utils/five/changeMode.js +12 -23
  168. package/libs/shared-utils/three/getExtraModelLoader.d.ts +1 -1
  169. package/libs/shared-utils/three/getNormal.d.ts +1 -1
  170. package/libs/shared-utils/three/getTextureLoader.d.ts +1 -1
  171. package/libs/shared-utils/three/loadFbxObj.d.ts +1 -1
  172. package/libs/shared-utils/three/loadFbxObj.js +9 -20
  173. package/libs/shared-utils/three/loadTexture.js +6 -17
  174. package/libs/shared-utils/to.js +10 -21
  175. package/libs/shared-utils/vectorTocoordinates.d.ts +1 -1
  176. package/package.json +2 -2
  177. package/libs/floorplan/ModelFloorplanPlugin/Components/RuleLabels/RuleItem.js +0 -301
@@ -1,17 +1,9 @@
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
- };
1
+ import * as THREE from 'three';
10
2
  import { pluginStyle } from './style';
11
3
  import formatData from '../utils/formatData';
12
- import { omit } from '../../shared-utils/filter';
13
4
  import getPxmm from '../../shared-utils/getPxmm';
14
- import Main from "../ModelFloorplanPlugin/Components/Main";
5
+ import { omit } from '../../shared-utils/filter';
6
+ import Main from '../Components/Main';
15
7
  import changeModelCanvasOpacity from '../../shared-utils/changeModelCanvasOpacity';
16
8
  export class TopviewFloorplanPluginController {
17
9
  constructor(five, params) {
@@ -100,32 +92,58 @@ export class TopviewFloorplanPluginController {
100
92
  value: () => {
101
93
  var _a, _b;
102
94
  this.hide();
103
- (_a = this.container) === null || _a === void 0 ? void 0 : _a.remove();
104
- (_b = this.app) === null || _b === void 0 ? void 0 : _b.$destroy();
105
- this.five.off('modeChange', this.handleModeChange);
106
- this.five.off('panoArrived', this.handlePanoArrived);
107
- this.five.off('modelLoaded', this.handleModelLoaded);
108
- this.five.off('wantsMoveToPano', this.handleWantsMoveToPano);
109
- this.five.off('wantsPanGesture', this.handleWantsPanGesture);
110
- this.five.off('initAnimationEnded', this.handleInitAnimationEnded);
95
+ (_a = this.app) === null || _a === void 0 ? void 0 : _a.$destroy();
96
+ (_b = this.container) === null || _b === void 0 ? void 0 : _b.remove();
97
+ this.five.off('modeChange', this.onFiveModeChange);
98
+ this.five.off('panGesture', this.onFivePanGesture);
99
+ this.five.off('panoArrived', this.onFivePanoArrived);
100
+ this.five.off('modelLoaded', this.onFiveModelLoaded);
101
+ this.five.off('pinchGesture', this.onFivePinchGesture);
102
+ this.five.off('wantsGesture', this.onFiveWantsGesture);
103
+ this.five.off('wantsMoveToPano', this.onFiveWantsMoveToPano);
104
+ this.five.off('initAnimationEnded', this.onFiveInitAnimationEnded);
111
105
  this.five.off('modelShownFloorChange', this.onModelShownFloorChange);
112
106
  }
113
107
  });
114
- /** 模型楼层高亮改变时,自动进行楼层切换 */
108
+ Object.defineProperty(this, "onFiveWantsMoveToPano", {
109
+ enumerable: true,
110
+ configurable: true,
111
+ writable: true,
112
+ value: () => {
113
+ if (this.visible && this.configs.preventRoomClick)
114
+ return false;
115
+ }
116
+ });
117
+ Object.defineProperty(this, "onFiveWantsGesture", {
118
+ enumerable: true,
119
+ configurable: true,
120
+ writable: true,
121
+ value: (type) => {
122
+ if (type !== 'pan' && type !== 'pinch' && type !== 'mouseWheel')
123
+ return;
124
+ if (this.visible && !this.configs.gestureEnable)
125
+ return false;
126
+ }
127
+ });
115
128
  Object.defineProperty(this, "onModelShownFloorChange", {
116
129
  enumerable: true,
117
130
  configurable: true,
118
131
  writable: true,
119
132
  value: (shownFloor) => {
120
- if (shownFloor === null)
133
+ if (this.floorIndex === shownFloor)
121
134
  return;
135
+ if (shownFloor === null) {
136
+ const panoIndex = this.five.getCurrentState().panoIndex;
137
+ this.floorIndex = this.five.work.observers[panoIndex].floorIndex;
138
+ return;
139
+ }
140
+ // 模型楼层高亮改变时,自动进行楼层切换
122
141
  this.floorIndex = shownFloor;
123
142
  this.updateSize();
124
143
  this.render();
125
144
  }
126
145
  });
127
- /** panoIndex 改变时,更新 floorIndex */
128
- Object.defineProperty(this, "handlePanoArrived", {
146
+ Object.defineProperty(this, "onFivePanoArrived", {
129
147
  enumerable: true,
130
148
  configurable: true,
131
149
  writable: true,
@@ -137,31 +155,28 @@ export class TopviewFloorplanPluginController {
137
155
  this.floorIndex = this.five.work.observers[index].floorIndex;
138
156
  }
139
157
  });
140
- /** 配置了 preventRoomClick 后,在户型图展示时阻止 Five 走点 */
141
- Object.defineProperty(this, "handleWantsMoveToPano", {
158
+ Object.defineProperty(this, "onFivePanGesture", {
142
159
  enumerable: true,
143
160
  configurable: true,
144
161
  writable: true,
145
162
  value: () => {
146
163
  if (!this.visible)
147
164
  return;
148
- if (this.configs.preventRoomClick)
149
- return false;
150
- return;
165
+ this.updatePosition();
151
166
  }
152
167
  });
153
- /** 在户型图展示时阻止 Five 滑动行为 */
154
- Object.defineProperty(this, "handleWantsPanGesture", {
168
+ Object.defineProperty(this, "onFivePinchGesture", {
155
169
  enumerable: true,
156
170
  configurable: true,
157
171
  writable: true,
158
172
  value: () => {
159
173
  if (!this.visible)
160
174
  return;
161
- return false;
175
+ this.updatePosition();
176
+ this.updateSize();
162
177
  }
163
178
  });
164
- Object.defineProperty(this, "handleModelLoaded", {
179
+ Object.defineProperty(this, "onFiveModelLoaded", {
165
180
  enumerable: true,
166
181
  configurable: true,
167
182
  writable: true,
@@ -178,7 +193,7 @@ export class TopviewFloorplanPluginController {
178
193
  }
179
194
  });
180
195
  /** 非 Topview 态隐藏户型图 */
181
- Object.defineProperty(this, "handleModeChange", {
196
+ Object.defineProperty(this, "onFiveModeChange", {
182
197
  enumerable: true,
183
198
  configurable: true,
184
199
  writable: true,
@@ -188,7 +203,7 @@ export class TopviewFloorplanPluginController {
188
203
  }
189
204
  });
190
205
  /** 动画结束后是 Topview 态就展示户型图 */
191
- Object.defineProperty(this, "handleInitAnimationEnded", {
206
+ Object.defineProperty(this, "onFiveInitAnimationEnded", {
192
207
  enumerable: true,
193
208
  configurable: true,
194
209
  writable: true,
@@ -228,24 +243,30 @@ export class TopviewFloorplanPluginController {
228
243
  this.five = five;
229
244
  this.selector = params.selector;
230
245
  this.configs = omit(params, ['selector']);
246
+ this.five.addExtraElement(this.container);
231
247
  // 设置 container 样式
232
248
  this.container.classList.add('floorplan-plugin');
233
249
  Object.assign(this.container.style, pluginStyle);
234
250
  // 如果初始化的时候模型已经加载完毕了,就不用再等 modelLoaded
235
- this.five.model.loaded ? this.handleModelLoaded() : five.once('modelLoaded', this.handleModelLoaded);
251
+ this.five.model.loaded
252
+ ? this.onFiveModelLoaded()
253
+ : five.once('modelLoaded', this.onFiveModelLoaded);
236
254
  this.five.once('dispose', this.dispose);
237
- this.five.on('modeChange', this.handleModeChange);
238
- this.five.on('panoArrived', this.handlePanoArrived);
239
- this.five.on('initAnimationEnded', this.handleInitAnimationEnded);
255
+ this.five.on('modeChange', this.onFiveModeChange);
256
+ this.five.on('panGesture', this.onFivePanGesture);
257
+ this.five.on('mouseWheel', this.onFivePinchGesture);
258
+ this.five.on('panoArrived', this.onFivePanoArrived);
259
+ this.five.on('pinchGesture', this.onFivePinchGesture);
260
+ this.five.on('wantsGesture', this.onFiveWantsGesture);
261
+ this.five.on('wantsMoveToPano', this.onFiveWantsMoveToPano);
262
+ this.five.on('initAnimationEnded', this.onFiveInitAnimationEnded);
240
263
  this.five.on('modelShownFloorChange', this.onModelShownFloorChange);
241
264
  }
242
265
  /** 加载户型图数据 */
243
- load(data) {
244
- return __awaiter(this, void 0, void 0, function* () {
245
- const copyData = JSON.parse(JSON.stringify(data));
246
- this.floorplanData = yield formatData(copyData);
247
- this.render();
248
- });
266
+ async load(data) {
267
+ const copyData = JSON.parse(JSON.stringify(data));
268
+ this.floorplanData = await formatData(copyData);
269
+ this.render();
249
270
  }
250
271
  /** 把插件的渲染DOM插入到对应的容器中去 */
251
272
  appendTo(wrapper) {
@@ -256,6 +277,7 @@ export class TopviewFloorplanPluginController {
256
277
  show() {
257
278
  this.visible = true;
258
279
  this.five.model.show(this.floorIndex);
280
+ this.updatePosition();
259
281
  this.updateSize();
260
282
  const renderDuration = 500;
261
283
  const modelOpacity = this.configs.modelOpacity;
@@ -263,8 +285,6 @@ export class TopviewFloorplanPluginController {
263
285
  changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
264
286
  }
265
287
  this.render(renderDuration);
266
- this.five.on('wantsMoveToPano', this.handleWantsMoveToPano);
267
- this.five.on('wantsPanGesture', this.handleWantsPanGesture);
268
288
  }
269
289
  hide() {
270
290
  const modelOpacity = 1;
@@ -272,20 +292,28 @@ export class TopviewFloorplanPluginController {
272
292
  this.visible = false;
273
293
  changeModelCanvasOpacity(this.five, modelOpacity, renderDuration);
274
294
  this.render();
275
- this.five.on('wantsMoveToPano', this.handleWantsMoveToPano);
276
- this.five.on('wantsPanGesture', this.handleWantsPanGesture);
295
+ }
296
+ /** 更新户型图位置 */
297
+ updatePosition() {
298
+ var _a;
299
+ const modelCenter = (_a = this.five.model) === null || _a === void 0 ? void 0 : _a.bounding.getCenter(new THREE.Vector3());
300
+ if (!modelCenter)
301
+ return;
302
+ const ndcModelCenter = modelCenter.clone().project(this.five.camera);
303
+ const left = (ndcModelCenter.x + 1) / 2;
304
+ const top = -(ndcModelCenter.y - 1) / 2;
305
+ this.container.style.left = left * 100 + '%';
306
+ this.container.style.top = top * 100 + '%';
277
307
  }
278
308
  render(duration) {
279
309
  if (!this.container || !this.floorplanData)
280
310
  return;
281
311
  if (this.size.width === 0)
282
312
  return;
283
- const { northDesc, getLabelElement, cameraImageUrl, preventRoomClick, hoverEnable, compassEnable, roomLabelsEnable, ruleLabelsEnable, } = this.configs;
284
- const handleClick = preventRoomClick ? () => false : undefined;
313
+ const { northDesc, getLabelElement, cameraImageUrl, hoverEnable, compassEnable, roomLabelsEnable, ruleLabelsEnable, } = this.configs;
285
314
  const props = {
315
+ getLabelElement,
286
316
  northDesc: northDesc !== null && northDesc !== void 0 ? northDesc : '北',
287
- five: this.five,
288
- pxmm: this.pxmm,
289
317
  cameraImageUrl,
290
318
  visible: this.visible,
291
319
  duration: duration !== null && duration !== void 0 ? duration : 0,
@@ -297,8 +325,6 @@ export class TopviewFloorplanPluginController {
297
325
  ruleLabelsEnable: ruleLabelsEnable !== null && ruleLabelsEnable !== void 0 ? ruleLabelsEnable : true,
298
326
  roomLabelsEnable: roomLabelsEnable !== null && roomLabelsEnable !== void 0 ? roomLabelsEnable : true,
299
327
  lastPanoramaLongitude: this.lastPanoramaLongitude,
300
- getLabelElement,
301
- onRoomHeightClick: handleClick,
302
328
  };
303
329
  if (!this.app) {
304
330
  this.app = new Main({
@@ -1,4 +1,4 @@
1
- import { FivePlugin } from '@realsee/five';
1
+ import type { FivePlugin } from '@realsee/five';
2
2
  import { TopviewFloorplanPluginParameterType, TopviewFloorplanPluginReturnType } from './Controller';
3
3
  export declare const TopviewFloorplanPlugin: FivePlugin<TopviewFloorplanPluginParameterType, TopviewFloorplanPluginReturnType>;
4
4
  export default TopviewFloorplanPlugin;
@@ -3,6 +3,5 @@ export const pluginStyle = {
3
3
  left: '50%',
4
4
  top: '50%',
5
5
  transform: 'translate(-50%, -50%)',
6
- pointerEvents: 'none',
7
6
  zIndex: '10',
8
7
  };
@@ -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) => {
@@ -7,7 +7,7 @@ export declare function pathD(points: Vector2Position[], options?: {
7
7
  format?: (vector: Vector2Position) => Vector2Position;
8
8
  }): string;
9
9
  /** 把户型图上点点位转换到 SVG 上的点位 */
10
- export default function formatFloorplanPoint({ x, y }: Vector2Position, pxmm: number, bounding: FloorplanBounding): {
10
+ export default function formatFloorplanPoint({ x, y }: Vector2Position, bounding: FloorplanBounding): {
11
11
  x: number;
12
12
  y: number;
13
13
  };
@@ -19,9 +19,9 @@ export function pathD(points, options = {}) {
19
19
  return d + (needZ ? 'Z' : '');
20
20
  }
21
21
  /** 把户型图上点点位转换到 SVG 上的点位 */
22
- export default function formatFloorplanPoint({ x, y }, pxmm, bounding) {
22
+ export default function formatFloorplanPoint({ x, y }, bounding) {
23
23
  const { max, min } = bounding;
24
- return { x: (x - min.x) * pxmm, y: (max.y - y) * pxmm };
24
+ return { x: x - min.x, y: max.y - y };
25
25
  }
26
26
  /** 模型坐标转户型图坐标 */
27
27
  export function modelPosition2FloorplanPosition(position, floorplanData) {
@@ -1,26 +1,15 @@
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 '../to';
11
- export default function changeMode(five, ...changeModeParams) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- const [changeModeError] = yield to(five.changeMode(...changeModeParams));
14
- if (changeModeError)
15
- throw changeModeError;
16
- yield new Promise((reslove, reject) => {
17
- five.once('initAnimationEnded', reslove);
18
- const handleModeChange = (mode) => {
19
- if (mode !== changeModeParams[0])
20
- reject('changeMode 被中断');
21
- five.off('modeChange', handleModeChange);
22
- };
23
- five.on('modeChange', handleModeChange);
24
- });
2
+ export default async function changeMode(five, ...changeModeParams) {
3
+ const [changeModeError] = await to(five.changeMode(...changeModeParams));
4
+ if (changeModeError)
5
+ throw changeModeError;
6
+ await new Promise((reslove, reject) => {
7
+ five.once('initAnimationEnded', reslove);
8
+ const handleModeChange = (mode) => {
9
+ if (mode !== changeModeParams[0])
10
+ reject('changeMode 被中断');
11
+ five.off('modeChange', handleModeChange);
12
+ };
13
+ five.on('modeChange', handleModeChange);
25
14
  });
26
15
  }
@@ -1,4 +1,4 @@
1
- import * as THREE from 'three';
1
+ import type * as THREE from 'three';
2
2
  /** 模型资源加载器,用于满足资源共用 */
3
3
  export declare function getExtraModelLoader(): {
4
4
  load: (url: string, type?: string) => Promise<THREE.Group>;
@@ -1,2 +1,2 @@
1
- import { Vector3 } from 'three';
1
+ import type { Vector3 } from 'three';
2
2
  export default function getNormal(a: Vector3, b: Vector3, c: Vector3): Vector3;
@@ -1,4 +1,4 @@
1
- import * as THREE from 'three';
1
+ import type * as THREE from 'three';
2
2
  /** 贴图加载器,用于满足资源共用 */
3
3
  export declare function getTextureLoader(): {
4
4
  load: (url: string) => Promise<THREE.Texture>;
@@ -1,2 +1,2 @@
1
- import { Group } from 'three';
1
+ import type { Group } from 'three';
2
2
  export declare function loadFbxObj(url: string): Promise<Group>;
@@ -1,24 +1,13 @@
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 { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';
11
2
  const loader = new FBXLoader();
12
- export function loadFbxObj(url) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- return new Promise((resolve, reject) => {
15
- function onLoad(object) {
16
- resolve(object);
17
- }
18
- function onError(error) {
19
- reject(error);
20
- }
21
- loader.load(url, onLoad, undefined, onError);
22
- });
3
+ export async function loadFbxObj(url) {
4
+ return new Promise((resolve, reject) => {
5
+ function onLoad(object) {
6
+ resolve(object);
7
+ }
8
+ function onError(error) {
9
+ reject(error);
10
+ }
11
+ loader.load(url, onLoad, undefined, onError);
23
12
  });
24
13
  }
@@ -1,21 +1,10 @@
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
  const textureLoader = new THREE.TextureLoader();
12
- export function loadTexture(url) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- return new Promise((resolve, reject) => {
15
- textureLoader.load(url, resolve, undefined, reject);
16
- }).then((texture) => {
17
- texture.encoding = THREE.sRGBEncoding;
18
- return texture;
19
- });
3
+ export async function loadTexture(url) {
4
+ return new Promise((resolve, reject) => {
5
+ textureLoader.load(url, resolve, undefined, reject);
6
+ }).then((texture) => {
7
+ texture.encoding = THREE.sRGBEncoding;
8
+ return texture;
20
9
  });
21
10
  }
@@ -1,29 +1,18 @@
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
  /**
11
2
  * 传入一个 Promise
12
3
  * 无异常,返回 [null, data]
13
4
  * 有异常,则返回 [Error, undefined]
14
5
  * 用于替代 try&catch 处理 await 异常的方案
15
6
  */
16
- export function to(promise) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- try {
19
- const data = yield promise;
20
- return [null, data];
21
- }
22
- catch (error) {
23
- if (error instanceof Error)
24
- return [error, null];
25
- return [new Error(''), null];
26
- }
27
- });
7
+ export async function to(promise) {
8
+ try {
9
+ const data = await promise;
10
+ return [null, data];
11
+ }
12
+ catch (error) {
13
+ if (error instanceof Error)
14
+ return [error, null];
15
+ return [new Error(''), null];
16
+ }
28
17
  }
29
18
  export default to;
@@ -1,4 +1,4 @@
1
- import * as THREE from 'three';
1
+ import type * as THREE from 'three';
2
2
  /** 单位向量转换成坐标 */
3
3
  declare function vectorTocoordinates(vector: THREE.Vector3): {
4
4
  longitude: number;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "repository": "https://github.com/realsee-developer/dnalogel.git",
8
8
  "description": "如视 VR 看房插件合集",
9
9
  "private": false,
10
- "version": "2.0.0-alpha.18",
10
+ "version": "2.0.0-alpha.20",
11
11
  "license": "SEE LICENSE IN TERMS.txt",
12
12
  "scripts": {
13
13
  "build": "yarn run tsb && yarn run build:rollup && yarn build:docs",
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "devDependencies": {
29
29
  "@babel/core": "^7.17.5",
30
- "@realsee/five": "^5.0.0-alpha.120",
30
+ "@realsee/five": "^5.0.0-alpha.123",
31
31
  "@rollup/plugin-alias": "^3.1.9",
32
32
  "@rollup/plugin-commonjs": "^21.1.0",
33
33
  "@rollup/plugin-typescript": "^8.3.2",