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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/CSS3DRenderPlugin/index.js +17 -14
  2. package/dist/CameraMovementPlugin/index.js +40 -15
  3. package/dist/ModelChassisCompassPlugin/index.js +32 -6
  4. package/dist/ModelEntryDoorGuidePlugin/index.js +48 -18
  5. package/dist/ModelItemLabelPlugin/events.type.d.ts +9 -0
  6. package/dist/ModelItemLabelPlugin/index.d.ts +4 -0
  7. package/dist/ModelItemLabelPlugin/index.js +679 -0
  8. package/dist/ModelItemLabelPlugin/typings.d.ts +55 -0
  9. package/dist/ModelItemLabelPlugin/utils/parseData.d.ts +3 -0
  10. package/dist/ModelRoomLabelPlugin/index.js +71 -28
  11. package/dist/PanoCompassPlugin/index.js +311 -164
  12. package/dist/PanoCursorRaycasterPlugin/index.js +5 -3
  13. package/dist/PanoMeasurePlugin/index.js +1337 -583
  14. package/dist/PanoRulerPlugin/index.js +32 -5
  15. package/dist/PanoSpatialTagPlugin/index.js +73 -38
  16. package/dist/floorplan/ModelFloorplanPlugin/Controller.d.ts +1 -0
  17. package/dist/floorplan/ModelFloorplanPlugin/index.js +678 -439
  18. package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +164 -72
  19. package/dist/floorplan/TopviewFloorplanPlugin/Controller.d.ts +1 -0
  20. package/dist/floorplan/TopviewFloorplanPlugin/index.js +403 -230
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.es.js +3596 -1612
  23. package/dist/index.js +3602 -1616
  24. package/dist/index.umd.js +3605 -1620
  25. package/docs/assets/main.js +1 -1
  26. package/docs/assets/search.js +1 -1
  27. package/docs/classes/ModelRoomLabelController.html +6 -6
  28. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  29. package/docs/enums/ModelFloorplanErrorType.html +1 -1
  30. package/docs/index.html +1 -1
  31. package/docs/interfaces/LineJson.html +1 -1
  32. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  33. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  34. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  35. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  36. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  37. package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
  38. package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
  39. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  40. package/docs/interfaces/PanoCompassPluginData.html +1 -1
  41. package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
  42. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  43. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  44. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  45. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  46. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  47. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  48. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  49. package/docs/interfaces/PointJson.html +1 -1
  50. package/docs/interfaces/RoomLabel.html +7 -7
  51. package/docs/interfaces/TopviewFloorplanPluginParameterType.html +1 -1
  52. package/docs/modules.html +12 -12
  53. package/libs/CSS3DRenderPlugin/index.js +16 -13
  54. package/libs/CameraMovementPlugin/index.js +24 -15
  55. package/libs/ModelChassisCompassPlugin/index.js +14 -5
  56. package/libs/ModelEntryDoorGuidePlugin/index.js +24 -12
  57. package/libs/ModelItemLabelPlugin/ItemLabelComponent.js +422 -0
  58. package/libs/ModelItemLabelPlugin/ItemLabelItem.js +133 -0
  59. package/libs/ModelItemLabelPlugin/events.type.d.ts +9 -0
  60. package/libs/ModelItemLabelPlugin/events.type.js +1 -0
  61. package/libs/ModelItemLabelPlugin/index.d.ts +4 -0
  62. package/libs/ModelItemLabelPlugin/index.js +172 -0
  63. package/libs/ModelItemLabelPlugin/typings.d.ts +55 -0
  64. package/libs/ModelItemLabelPlugin/typings.js +6 -0
  65. package/libs/ModelItemLabelPlugin/utils/parseData.d.ts +3 -0
  66. package/libs/ModelItemLabelPlugin/utils/parseData.js +4 -0
  67. package/libs/ModelRoomLabelPlugin/Controller.js +64 -23
  68. package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +7 -5
  69. package/libs/PanoCompassPlugin/index.js +225 -128
  70. package/libs/PanoCursorRaycasterPlugin/index.js +5 -3
  71. package/libs/PanoMeasurePlugin/Controller/BaseController.js +68 -13
  72. package/libs/PanoMeasurePlugin/Controller/EditController.js +267 -154
  73. package/libs/PanoMeasurePlugin/Controller/ShortcutKeyController.js +40 -20
  74. package/libs/PanoMeasurePlugin/Controller/WatchController.js +234 -152
  75. package/libs/PanoMeasurePlugin/Controller/index.js +131 -47
  76. package/libs/PanoMeasurePlugin/Model/index.js +30 -5
  77. package/libs/PanoMeasurePlugin/Model/line.js +60 -10
  78. package/libs/PanoMeasurePlugin/Model/point.js +24 -4
  79. package/libs/PanoMeasurePlugin/Model/polyline.js +20 -3
  80. package/libs/PanoMeasurePlugin/Modules/DeleteDom/index.js +59 -14
  81. package/libs/PanoMeasurePlugin/Modules/FiveHelper.js +23 -8
  82. package/libs/PanoMeasurePlugin/Modules/GuideController.js +61 -26
  83. package/libs/PanoMeasurePlugin/Modules/Magnifier.js +60 -10
  84. package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +83 -37
  85. package/libs/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +52 -17
  86. package/libs/PanoMeasurePlugin/Modules/UIController/index.js +61 -30
  87. package/libs/PanoMeasurePlugin/utils/distanceDom.js +3 -2
  88. package/libs/PanoMeasurePlugin/utils/line.js +8 -7
  89. package/libs/PanoRulerPlugin/index.js +16 -5
  90. package/libs/PanoSpatialTagPlugin/Components/tag.js +9 -9
  91. package/libs/PanoSpatialTagPlugin/index.js +11 -9
  92. package/libs/floorplan/Components/BaseImage.js +10 -5
  93. package/libs/floorplan/Components/RoomHighlight/RoomHighlight.js +3 -1
  94. package/libs/floorplan/Components/RoomMaterials/RoomMaterial.js +5 -6
  95. package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.js +24 -11
  96. package/libs/floorplan/ModelFloorplanPlugin/Components/Main.js +77 -69
  97. package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.js +3 -1
  98. package/libs/floorplan/ModelFloorplanPlugin/Controller.d.ts +1 -0
  99. package/libs/floorplan/ModelFloorplanPlugin/Controller.js +457 -273
  100. package/libs/floorplan/ModelFloorplanPlugin/utils/correctFiveState.js +33 -22
  101. package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/CurrentFloor.js +3 -1
  102. package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +97 -36
  103. package/libs/floorplan/TopviewFloorplanPlugin/Controller.d.ts +1 -0
  104. package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +232 -108
  105. package/libs/floorplan/utils/formatData.js +43 -28
  106. package/libs/floorplan/utils/formatPosition.js +1 -1
  107. package/libs/index.d.ts +1 -0
  108. package/libs/index.js +2 -0
  109. package/libs/shared-utils/Subscribe.js +8 -1
  110. package/libs/shared-utils/animationFrame/BetterTween.js +47 -18
  111. package/libs/shared-utils/createCanvasTextTexture.js +6 -5
  112. package/libs/shared-utils/five/changeMode.js +23 -12
  113. package/libs/shared-utils/getPxmm.js +1 -1
  114. package/libs/shared-utils/math/evenNumber.js +1 -1
  115. package/libs/shared-utils/three/loadFbxObj.js +20 -9
  116. package/libs/shared-utils/three/loadTexture.js +17 -6
  117. package/libs/shared-utils/three/transfromToMeshBasicMaterial.js +2 -1
  118. package/libs/shared-utils/tinyEJSrender.js +36 -6
  119. package/libs/shared-utils/to.js +21 -10
  120. package/libs/shared-utils/useDebounce.js +1 -1
  121. package/libs/shared-utils/useThrottle.js +2 -1
  122. package/package.json +2 -2
  123. package/CHANGELOG.md +0 -34
@@ -6,32 +6,271 @@ import throttle from '../../shared-utils/throttle';
6
6
  import BaseController from './BaseController';
7
7
  import { getIntersectionFromEvent } from '../utils/getIntersectionFromEvent';
8
8
  export default class EditController extends BaseController {
9
- type = 'edit';
10
- model = new Model({ userDistanceItemCreator: this.userDistanceItemCreator });
11
- pressPoint;
12
- hasAppendDashed = false;
13
- hasAppendMouseGroup = false;
14
- fiveElement;
15
- /** 上一个端点位置 */
16
- lastPoint = null;
17
- /** 鼠标点到上一个端点连接的虚线 */
18
- dashed;
19
- hammer;
20
- /** 根据 intersection 更新放大镜和吸附点 */
21
- onIntersectionUpdate = throttle((intersection, mesh) => {
22
- if (this.hasAppendMouseGroup === false) {
23
- this.group.add(this.mouseGroup);
24
- this.magnifier.appendTo(this.container);
25
- this.hasAppendMouseGroup = true;
26
- }
27
- const position = this.updateMouseGroup(intersection, mesh).position;
28
- this.pressPoint?.position.copy(position);
29
- this.updateDashed();
30
- requestAnimationFrame(() => this.magnifier.updateWithPoint(this.mouseGroup.position));
31
- this.five.needsRender = true;
32
- }, 20);
33
9
  constructor(params) {
10
+ var _a;
34
11
  super(params);
12
+ Object.defineProperty(this, "type", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: 'edit'
17
+ });
18
+ Object.defineProperty(this, "model", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: new Model({ userDistanceItemCreator: this.userDistanceItemCreator })
23
+ });
24
+ Object.defineProperty(this, "pressPoint", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: void 0
29
+ });
30
+ Object.defineProperty(this, "hasAppendDashed", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: false
35
+ });
36
+ Object.defineProperty(this, "hasAppendMouseGroup", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: false
41
+ });
42
+ Object.defineProperty(this, "fiveElement", {
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true,
46
+ value: void 0
47
+ });
48
+ /** 上一个端点位置 */
49
+ Object.defineProperty(this, "lastPoint", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: null
54
+ });
55
+ /** 鼠标点到上一个端点连接的虚线 */
56
+ Object.defineProperty(this, "dashed", {
57
+ enumerable: true,
58
+ configurable: true,
59
+ writable: true,
60
+ value: void 0
61
+ });
62
+ Object.defineProperty(this, "hammer", {
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true,
66
+ value: void 0
67
+ });
68
+ /** 根据 intersection 更新放大镜和吸附点 */
69
+ Object.defineProperty(this, "onIntersectionUpdate", {
70
+ enumerable: true,
71
+ configurable: true,
72
+ writable: true,
73
+ value: throttle((intersection, mesh) => {
74
+ var _a;
75
+ if (this.hasAppendMouseGroup === false) {
76
+ this.group.add(this.mouseGroup);
77
+ this.magnifier.appendTo(this.container);
78
+ this.hasAppendMouseGroup = true;
79
+ }
80
+ const position = this.updateMouseGroup(intersection, mesh).position;
81
+ (_a = this.pressPoint) === null || _a === void 0 ? void 0 : _a.position.copy(position);
82
+ this.updateDashed();
83
+ requestAnimationFrame(() => this.magnifier.updateWithPoint(this.mouseGroup.position));
84
+ this.five.needsRender = true;
85
+ }, 20)
86
+ });
87
+ /** 撤销编辑 */
88
+ Object.defineProperty(this, "revoke", {
89
+ enumerable: true,
90
+ configurable: true,
91
+ writable: true,
92
+ value: () => {
93
+ // ============ revoke points ============
94
+ // 如果当前没有虚线,只有起始点,需要删除起始点,重置起始状态。并删除虚线实例
95
+ if (this.model.lines.length === 0 && this.lastPoint) {
96
+ this.lastPoint = null;
97
+ this.hasAppendDashed = false;
98
+ this.dashed.distanceItem.remove();
99
+ this.group.remove(this.dashed.mesh);
100
+ this.hook.emit('anchorChange', null);
101
+ this.five.needsRender = true;
102
+ return;
103
+ }
104
+ if (this.model.lines.length === 0 && !this.lastPoint)
105
+ return;
106
+ if (!this.lastPoint)
107
+ return;
108
+ const revokedLine = this.model.lines[this.model.lines.length - 1];
109
+ const lastPoint = revokedLine.findAnotherPoint(this.lastPoint);
110
+ if (!lastPoint)
111
+ return;
112
+ this.lastPoint = lastPoint;
113
+ this.hook.emit('anchorChange', lastPoint.position);
114
+ // ============ revoke lines ============
115
+ this.group.remove(revokedLine.mesh);
116
+ this.model.removeLine(revokedLine);
117
+ // ============ revoke mouse group ============
118
+ this.hasAppendMouseGroup = false;
119
+ this.mouseGroup.position.copy(this.lastPoint.position);
120
+ this.group.remove(this.mouseGroup);
121
+ // ============ revoke lineDistance ============
122
+ revokedLine.distanceItem.remove();
123
+ // ============ revoke dashed ============
124
+ this.updateDashed();
125
+ // ============ revoke magnifier ============
126
+ this.magnifier.dispose();
127
+ this.five.needsRender = true;
128
+ }
129
+ });
130
+ Object.defineProperty(this, "onMouseLeave", {
131
+ enumerable: true,
132
+ configurable: true,
133
+ writable: true,
134
+ value: () => {
135
+ this.magnifier.dispose();
136
+ this.group.remove(this.mouseGroup);
137
+ this.hasAppendMouseGroup = false;
138
+ if (this.lastPoint) {
139
+ this.mouseGroup.position.copy(this.lastPoint.position);
140
+ this.updateDashed();
141
+ }
142
+ }
143
+ });
144
+ /** 编辑线条发生改变时通知外部 */
145
+ Object.defineProperty(this, "onLineChanged", {
146
+ enumerable: true,
147
+ configurable: true,
148
+ writable: true,
149
+ value: () => {
150
+ this.hook.emit('editedLineChange', this.model.lines.map((line) => line.toCompletelyJson()));
151
+ }
152
+ });
153
+ Object.defineProperty(this, "onPress", {
154
+ enumerable: true,
155
+ configurable: true,
156
+ writable: true,
157
+ value: (e) => {
158
+ const [intersection] = getIntersectionFromEvent(this.five, e);
159
+ if (!intersection || !intersection.face)
160
+ return;
161
+ const nowPoint = new Point(intersection.point);
162
+ this.pressPoint = nowPoint;
163
+ this.onIntersectionUpdate(intersection);
164
+ }
165
+ });
166
+ /**
167
+ * 1. 如果之前没有长按行为「即没有长按点时」-> 滑动全景
168
+ * 2. 如果有长按点,把长按点位置更新为当前位置
169
+ */
170
+ Object.defineProperty(this, "onPan", {
171
+ enumerable: true,
172
+ configurable: true,
173
+ writable: true,
174
+ value: (e) => {
175
+ if (!this.pressPoint)
176
+ return;
177
+ const [intersection] = getIntersectionFromEvent(this.five, e);
178
+ if (!intersection || !intersection.face)
179
+ return;
180
+ this.onIntersectionUpdate(intersection);
181
+ }
182
+ });
183
+ Object.defineProperty(this, "onPanEnd", {
184
+ enumerable: true,
185
+ configurable: true,
186
+ writable: true,
187
+ value: (e) => {
188
+ if (!this.pressPoint)
189
+ return;
190
+ this.onTap(e);
191
+ }
192
+ });
193
+ /**
194
+ * 1. 如果存在上一个点,需要绘制当前点到上一个点的连线
195
+ * 2. 把上一个点的位置更新为当前点的位置
196
+ * 3. 清除 mouseGroup 和 magnifier
197
+ */
198
+ Object.defineProperty(this, "onTap", {
199
+ enumerable: true,
200
+ configurable: true,
201
+ writable: true,
202
+ value: (e) => {
203
+ if (!this.hasAppendDashed) {
204
+ this.dashed.distanceItem.appendTo(this.container);
205
+ this.group.add(this.dashed.mesh);
206
+ }
207
+ this.hasAppendDashed = true;
208
+ const [intersection] = getIntersectionFromEvent(this.five, e);
209
+ this.updateMouseGroup(intersection);
210
+ const nowPoint = new Point(this.mouseGroup.position);
211
+ const lastPoint = this.lastPoint;
212
+ if (nowPoint)
213
+ this.lastPoint = nowPoint;
214
+ if (nowPoint && lastPoint) {
215
+ const line = new Line(lastPoint, nowPoint, this.model);
216
+ line.distanceItem.appendTo(this.container);
217
+ this.model.addLine(line);
218
+ this.group.add(line.mesh);
219
+ line.distanceItem.update(this.five);
220
+ }
221
+ this.pressPoint = undefined;
222
+ this.hasAppendMouseGroup = false;
223
+ this.magnifier.dispose();
224
+ this.group.remove(this.mouseGroup);
225
+ this.updateDashed();
226
+ this.five.needsRender = true;
227
+ this.hook.emit('anchorChange', nowPoint.position);
228
+ }
229
+ });
230
+ Object.defineProperty(this, "onWantsTapGesture", {
231
+ enumerable: true,
232
+ configurable: true,
233
+ writable: true,
234
+ value: () => false
235
+ });
236
+ /** 编辑时取消走点 */
237
+ Object.defineProperty(this, "onWantsToMoveToPano", {
238
+ enumerable: true,
239
+ configurable: true,
240
+ writable: true,
241
+ value: () => false
242
+ });
243
+ /** 存在长按点时不能移动全景 */
244
+ Object.defineProperty(this, "onWantsPanGesture", {
245
+ enumerable: true,
246
+ configurable: true,
247
+ writable: true,
248
+ value: () => (this.pressPoint ? false : undefined)
249
+ });
250
+ /** 移动全景时更新 distanceItem 在屏幕上的位置 */
251
+ Object.defineProperty(this, "onCameraUpdate", {
252
+ enumerable: true,
253
+ configurable: true,
254
+ writable: true,
255
+ value: () => {
256
+ this.updateDistanceUI();
257
+ this.dashed.distanceItem.update(this.five);
258
+ }
259
+ });
260
+ /** 更新虚线 */
261
+ Object.defineProperty(this, "updateDashed", {
262
+ enumerable: true,
263
+ configurable: true,
264
+ writable: true,
265
+ value: () => {
266
+ if (!this.lastPoint)
267
+ return;
268
+ this.dashed.points[0].position.copy(this.lastPoint.position);
269
+ this.dashed.points[1].position.copy(this.mouseGroup.position);
270
+ this.dashed.mesh.setPoints(this.lastPoint.position, this.mouseGroup.position);
271
+ this.dashed.distanceItem.update(this.five);
272
+ }
273
+ });
35
274
  // ==================== 虚线 ====================
36
275
  this.dashed = new Line(new Point([0, 0, 0]), new Point([0, 0, 0]), this.model);
37
276
  this.dashed.mesh.setMaterial({ dashed: true, dashScale: 100 });
@@ -57,12 +296,13 @@ export default class EditController extends BaseController {
57
296
  hammer.on('panend', this.onPanEnd);
58
297
  }
59
298
  // fiveElement
60
- this.fiveElement?.addEventListener('mouseleave', this.onMouseLeave);
299
+ (_a = this.fiveElement) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseleave', this.onMouseLeave);
61
300
  // ==================== 其他 ====================
62
301
  this.hook.emit('anchorChange', null);
63
302
  this.five.refresh();
64
303
  }
65
304
  dispose() {
305
+ var _a, _b;
66
306
  super.dispose();
67
307
  this.group.remove(this.mouseGroup, this.dashed.mesh);
68
308
  // ==================== 解除事件监听 ====================
@@ -76,9 +316,9 @@ export default class EditController extends BaseController {
76
316
  this.model.hook.off('lineAdded', this.onLineChanged);
77
317
  this.model.hook.off('lineRemoved', this.onLineChanged);
78
318
  // hammer
79
- this.hammer?.destroy();
319
+ (_a = this.hammer) === null || _a === void 0 ? void 0 : _a.destroy();
80
320
  // fiveElement
81
- this.fiveElement?.removeEventListener('mouseleave', this.onMouseLeave);
321
+ (_b = this.fiveElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', this.onMouseLeave);
82
322
  this.magnifier.dispose();
83
323
  this.dashed.distanceItem.remove();
84
324
  this.five.needsRender = true;
@@ -86,131 +326,4 @@ export default class EditController extends BaseController {
86
326
  getEditingLines() {
87
327
  return this.model.lines;
88
328
  }
89
- /** 撤销编辑 */
90
- revoke = () => {
91
- // ============ revoke points ============
92
- // 如果当前没有虚线,只有起始点,需要删除起始点,重置起始状态。并删除虚线实例
93
- if (this.model.lines.length === 0 && this.lastPoint) {
94
- this.lastPoint = null;
95
- this.hasAppendDashed = false;
96
- this.dashed.distanceItem.remove();
97
- this.group.remove(this.dashed.mesh);
98
- this.hook.emit('anchorChange', null);
99
- this.five.needsRender = true;
100
- return;
101
- }
102
- if (this.model.lines.length === 0 && !this.lastPoint)
103
- return;
104
- if (!this.lastPoint)
105
- return;
106
- const revokedLine = this.model.lines[this.model.lines.length - 1];
107
- const lastPoint = revokedLine.findAnotherPoint(this.lastPoint);
108
- if (!lastPoint)
109
- return;
110
- this.lastPoint = lastPoint;
111
- this.hook.emit('anchorChange', lastPoint.position);
112
- // ============ revoke lines ============
113
- this.group.remove(revokedLine.mesh);
114
- this.model.removeLine(revokedLine);
115
- // ============ revoke mouse group ============
116
- this.hasAppendMouseGroup = false;
117
- this.mouseGroup.position.copy(this.lastPoint.position);
118
- this.group.remove(this.mouseGroup);
119
- // ============ revoke lineDistance ============
120
- revokedLine.distanceItem.remove();
121
- // ============ revoke dashed ============
122
- this.updateDashed();
123
- // ============ revoke magnifier ============
124
- this.magnifier.dispose();
125
- this.five.needsRender = true;
126
- };
127
- onMouseLeave = () => {
128
- this.magnifier.dispose();
129
- this.group.remove(this.mouseGroup);
130
- this.hasAppendMouseGroup = false;
131
- if (this.lastPoint) {
132
- this.mouseGroup.position.copy(this.lastPoint.position);
133
- this.updateDashed();
134
- }
135
- };
136
- /** 编辑线条发生改变时通知外部 */
137
- onLineChanged = () => {
138
- this.hook.emit('editedLineChange', this.model.lines.map((line) => line.toCompletelyJson()));
139
- };
140
- onPress = (e) => {
141
- const [intersection] = getIntersectionFromEvent(this.five, e);
142
- if (!intersection || !intersection.face)
143
- return;
144
- const nowPoint = new Point(intersection.point);
145
- this.pressPoint = nowPoint;
146
- this.onIntersectionUpdate(intersection);
147
- };
148
- /**
149
- * 1. 如果之前没有长按行为「即没有长按点时」-> 滑动全景
150
- * 2. 如果有长按点,把长按点位置更新为当前位置
151
- */
152
- onPan = (e) => {
153
- if (!this.pressPoint)
154
- return;
155
- const [intersection] = getIntersectionFromEvent(this.five, e);
156
- if (!intersection || !intersection.face)
157
- return;
158
- this.onIntersectionUpdate(intersection);
159
- };
160
- onPanEnd = (e) => {
161
- if (!this.pressPoint)
162
- return;
163
- this.onTap(e);
164
- };
165
- /**
166
- * 1. 如果存在上一个点,需要绘制当前点到上一个点的连线
167
- * 2. 把上一个点的位置更新为当前点的位置
168
- * 3. 清除 mouseGroup 和 magnifier
169
- */
170
- onTap = (e) => {
171
- if (!this.hasAppendDashed) {
172
- this.dashed.distanceItem.appendTo(this.container);
173
- this.group.add(this.dashed.mesh);
174
- }
175
- this.hasAppendDashed = true;
176
- const [intersection] = getIntersectionFromEvent(this.five, e);
177
- this.updateMouseGroup(intersection);
178
- const nowPoint = new Point(this.mouseGroup.position);
179
- const lastPoint = this.lastPoint;
180
- if (nowPoint)
181
- this.lastPoint = nowPoint;
182
- if (nowPoint && lastPoint) {
183
- const line = new Line(lastPoint, nowPoint, this.model);
184
- line.distanceItem.appendTo(this.container);
185
- this.model.addLine(line);
186
- this.group.add(line.mesh);
187
- line.distanceItem.update(this.five);
188
- }
189
- this.pressPoint = undefined;
190
- this.hasAppendMouseGroup = false;
191
- this.magnifier.dispose();
192
- this.group.remove(this.mouseGroup);
193
- this.updateDashed();
194
- this.five.needsRender = true;
195
- this.hook.emit('anchorChange', nowPoint.position);
196
- };
197
- onWantsTapGesture = () => false;
198
- /** 编辑时取消走点 */
199
- onWantsToMoveToPano = () => false;
200
- /** 存在长按点时不能移动全景 */
201
- onWantsPanGesture = () => (this.pressPoint ? false : undefined);
202
- /** 移动全景时更新 distanceItem 在屏幕上的位置 */
203
- onCameraUpdate = () => {
204
- this.updateDistanceUI();
205
- this.dashed.distanceItem.update(this.five);
206
- };
207
- /** 更新虚线 */
208
- updateDashed = () => {
209
- if (!this.lastPoint)
210
- return;
211
- this.dashed.points[0].position.copy(this.lastPoint.position);
212
- this.dashed.points[1].position.copy(this.mouseGroup.position);
213
- this.dashed.mesh.setPoints(this.lastPoint.position, this.mouseGroup.position);
214
- this.dashed.distanceItem.update(this.five);
215
- };
216
329
  }
@@ -1,8 +1,46 @@
1
1
  /** 快捷键控制器 */
2
2
  export class ShortcutKeyController {
3
- five;
4
- measureController;
5
3
  constructor(measureController, five) {
4
+ Object.defineProperty(this, "five", {
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true,
8
+ value: void 0
9
+ });
10
+ Object.defineProperty(this, "measureController", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: void 0
15
+ });
16
+ Object.defineProperty(this, "onKeyDown", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: (e) => {
21
+ // Command + S -> 保存 & 更改场景
22
+ if (e.metaKey && e.code === 'KeyS') {
23
+ this.measureController.save().changeMode('Watch');
24
+ e.preventDefault();
25
+ return;
26
+ }
27
+ // Escape -> 切换到观察模式 / 如果已经在观察模式,退出功能
28
+ if (e.code === 'Escape')
29
+ return this.escape();
30
+ }
31
+ });
32
+ Object.defineProperty(this, "onMouseDown", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: (e) => {
37
+ // 鼠标右键取消
38
+ if (e.button !== 2)
39
+ return;
40
+ e.preventDefault();
41
+ this.escape();
42
+ }
43
+ });
6
44
  this.five = five;
7
45
  this.measureController = measureController;
8
46
  const fiveElement = this.five.getElement();
@@ -23,22 +61,4 @@ export class ShortcutKeyController {
23
61
  return this.measureController.disable();
24
62
  return this.measureController.changeMode('Watch');
25
63
  }
26
- onKeyDown = (e) => {
27
- // Command + S -> 保存 & 更改场景
28
- if (e.metaKey && e.code === 'KeyS') {
29
- this.measureController.save().changeMode('Watch');
30
- e.preventDefault();
31
- return;
32
- }
33
- // Escape -> 切换到观察模式 / 如果已经在观察模式,退出功能
34
- if (e.code === 'Escape')
35
- return this.escape();
36
- };
37
- onMouseDown = (e) => {
38
- // 鼠标右键取消
39
- if (e.button !== 2)
40
- return;
41
- e.preventDefault();
42
- this.escape();
43
- };
44
64
  }