@realsee/dnalogel 0.1.5 → 0.1.7-alpha.4

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 (151) hide show
  1. package/components/GLTFView/index.d.ts +104 -0
  2. package/components/GLTFView/index.js +181 -0
  3. package/data/81zxMaeVKLQU93OZMG.d.ts +49 -0
  4. package/data/81zxMaeVKLQU93OZMG.js +633 -0
  5. package/data/PrXel3aqGbp34JQn.js +139 -1
  6. package/data/vLykj3NWrllMrG06.js +335 -71
  7. package/libs/gltf-viewer/Subscribe.d.ts +76 -0
  8. package/libs/gltf-viewer/Subscribe.js +231 -0
  9. package/libs/gltf-viewer/coordsMoveByOffset.d.ts +13 -0
  10. package/libs/gltf-viewer/coordsMoveByOffset.js +22 -0
  11. package/libs/gltf-viewer/coordsToDirection.d.ts +5 -0
  12. package/{components/PBRView/index.js → libs/gltf-viewer/coordsToDirection.js} +14 -18
  13. package/libs/gltf-viewer/formatRad.d.ts +1 -0
  14. package/libs/gltf-viewer/formatRad.js +13 -0
  15. package/libs/gltf-viewer/getFrameTime.d.ts +1 -0
  16. package/libs/gltf-viewer/getFrameTime.js +28 -0
  17. package/libs/gltf-viewer/index.d.ts +69 -0
  18. package/libs/gltf-viewer/index.js +744 -0
  19. package/libs/gltf-viewer/mouseWheel.d.ts +2 -0
  20. package/libs/gltf-viewer/mouseWheel.js +59 -0
  21. package/libs/gltf-viewer/requestAnimationFrame.d.ts +1 -0
  22. package/libs/gltf-viewer/requestAnimationFrame.js +18 -0
  23. package/libs/gltf-viewer/requestAnimationFrameInterval.d.ts +1 -0
  24. package/libs/gltf-viewer/requestAnimationFrameInterval.js +31 -0
  25. package/libs/gltf-viewer/uuid.d.ts +4 -0
  26. package/libs/gltf-viewer/uuid.js +28 -0
  27. package/package.json +5 -4
  28. package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +6 -2
  29. package/plugins/ModelEntryDoorGuidePlugin/index.js +22 -14
  30. package/plugins/ModelRoomLabelPlugin/Controller.js +1 -0
  31. package/plugins/ModelRoomLabelPlugin/RoomLabelItem.js +5 -5
  32. package/plugins/ModelRoomLabelPlugin/index.d.ts +4 -0
  33. package/plugins/ModelRoomLabelPlugin/index.js +7 -2
  34. package/plugins/PanoMaskSelectorPlugin/createBox.js +3 -0
  35. package/plugins/PanoMaskSelectorPlugin/index.js +3 -1
  36. package/plugins/PanoMeasurePlugin/Controller/BaseController.d.ts +36 -0
  37. package/plugins/PanoMeasurePlugin/Controller/BaseController.js +103 -0
  38. package/plugins/PanoMeasurePlugin/Controller/EditController.d.ts +52 -0
  39. package/plugins/PanoMeasurePlugin/Controller/EditController.js +341 -0
  40. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.d.ts +12 -0
  41. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.js +69 -0
  42. package/plugins/PanoMeasurePlugin/Controller/WatchController.d.ts +25 -0
  43. package/plugins/PanoMeasurePlugin/Controller/WatchController.js +371 -0
  44. package/plugins/PanoMeasurePlugin/Controller/index.d.ts +61 -0
  45. package/plugins/PanoMeasurePlugin/Controller/index.js +230 -0
  46. package/plugins/PanoMeasurePlugin/Model/index.d.ts +38 -0
  47. package/plugins/PanoMeasurePlugin/Model/index.js +235 -0
  48. package/plugins/PanoMeasurePlugin/Model/line.d.ts +30 -0
  49. package/plugins/PanoMeasurePlugin/Model/line.js +121 -0
  50. package/plugins/PanoMeasurePlugin/Model/point.d.ts +16 -0
  51. package/plugins/PanoMeasurePlugin/Model/point.js +68 -0
  52. package/plugins/PanoMeasurePlugin/Model/polyline.d.ts +16 -0
  53. package/plugins/PanoMeasurePlugin/Model/polyline.js +109 -0
  54. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.d.ts +2 -0
  55. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.js +11 -0
  56. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.d.ts +2 -0
  57. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.js +11 -0
  58. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.d.ts +2 -0
  59. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.js +11 -0
  60. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.d.ts +22 -0
  61. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.js +182 -0
  62. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.d.ts +11 -0
  63. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.js +66 -0
  64. package/plugins/PanoMeasurePlugin/Modules/GuideController.d.ts +18 -0
  65. package/plugins/PanoMeasurePlugin/Modules/GuideController.js +107 -0
  66. package/plugins/PanoMeasurePlugin/Modules/Magnifier.d.ts +24 -0
  67. package/plugins/PanoMeasurePlugin/Modules/Magnifier.js +139 -0
  68. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.d.ts +6 -0
  69. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.js +26 -0
  70. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +18 -0
  71. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +169 -0
  72. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.d.ts +12 -0
  73. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +59 -0
  74. package/plugins/PanoMeasurePlugin/Modules/UIController/index.d.ts +16 -0
  75. package/plugins/PanoMeasurePlugin/Modules/UIController/index.js +123 -0
  76. package/plugins/PanoMeasurePlugin/Modules/UIController/style.d.ts +17 -0
  77. package/plugins/PanoMeasurePlugin/Modules/UIController/style.js +103 -0
  78. package/plugins/PanoMeasurePlugin/index.d.ts +7 -0
  79. package/plugins/PanoMeasurePlugin/index.js +20 -0
  80. package/plugins/PanoMeasurePlugin/typings/data.d.ts +28 -0
  81. package/plugins/PanoMeasurePlugin/typings/data.js +7 -0
  82. package/plugins/PanoMeasurePlugin/typings/event.type.d.ts +28 -0
  83. package/plugins/PanoMeasurePlugin/typings/event.type.js +7 -0
  84. package/plugins/PanoMeasurePlugin/typings/utils.type.d.ts +1 -0
  85. package/plugins/PanoMeasurePlugin/typings/utils.type.js +7 -0
  86. package/plugins/PanoMeasurePlugin/utils/clearGroup.d.ts +2 -0
  87. package/plugins/PanoMeasurePlugin/utils/clearGroup.js +16 -0
  88. package/plugins/PanoMeasurePlugin/utils/constants.d.ts +4 -0
  89. package/plugins/PanoMeasurePlugin/utils/constants.js +47 -0
  90. package/plugins/PanoMeasurePlugin/utils/distanceDom.d.ts +28 -0
  91. package/plugins/PanoMeasurePlugin/utils/distanceDom.js +147 -0
  92. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.d.ts +2 -0
  93. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.js +37 -0
  94. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.d.ts +10 -0
  95. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.js +49 -0
  96. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.d.ts +4 -0
  97. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.js +20 -0
  98. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.d.ts +10 -0
  99. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.js +33 -0
  100. package/plugins/PanoMeasurePlugin/utils/ironbox.d.ts +1 -0
  101. package/plugins/PanoMeasurePlugin/utils/ironbox.js +14 -0
  102. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.d.ts +2 -0
  103. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.js +16 -0
  104. package/plugins/PanoMeasurePlugin/utils/line.d.ts +17 -0
  105. package/plugins/PanoMeasurePlugin/utils/line.js +61 -0
  106. package/plugins/PanoMeasurePlugin/utils/math.d.ts +17 -0
  107. package/plugins/PanoMeasurePlugin/utils/math.js +57 -0
  108. package/plugins/PanoMeasurePlugin/utils/mouseGroup.d.ts +2 -0
  109. package/plugins/PanoMeasurePlugin/utils/mouseGroup.js +42 -0
  110. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.d.ts +5 -0
  111. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.js +16 -0
  112. package/plugins/PanoRulerPlugin/index.d.ts +4 -0
  113. package/plugins/PanoRulerPlugin/index.js +6 -1
  114. package/plugins/PanoTVVideoPlugin/index.d.ts +2 -0
  115. package/plugins/PanoTVVideoPlugin/index.js +20 -14
  116. package/plugins/floorplan/ModelFloorplanPlugin/Controller.d.ts +5 -2
  117. package/plugins/floorplan/ModelFloorplanPlugin/Controller.js +22 -11
  118. package/plugins/floorplan/ModelFloorplanPlugin/components/Camera.js +4 -4
  119. package/plugins/floorplan/ModelFloorplanPlugin/components/Compass.js +5 -5
  120. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomLabels.js +2 -2
  121. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.d.ts +11 -0
  122. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.js +174 -0
  123. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.d.ts +8 -0
  124. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.js +179 -0
  125. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.d.ts +2 -0
  126. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.js +14 -2
  127. package/plugins/floorplan/ModelFloorplanPlugin/components/index.d.ts +3 -0
  128. package/plugins/floorplan/ModelFloorplanPlugin/components/index.js +1 -1
  129. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.d.ts +2 -0
  130. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.js +7 -0
  131. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.d.ts +1 -1
  132. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.js +1 -1
  133. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.js +1 -0
  134. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.style.js +4 -4
  135. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/ExtraObjects.js +2 -2
  136. package/plugins/floorplan/TopviewFloorplanPlugin/Controller.js +3 -3
  137. package/plugins/floorplan/index.d.ts +4 -0
  138. package/plugins/floorplan/index.js +13 -0
  139. package/plugins/floorplan/typings/floorplanData.d.ts +2 -0
  140. package/plugins/floorplan/typings/floorplanServerData.d.ts +2 -0
  141. package/plugins/floorplan/utils/formatData.js +2 -1
  142. package/shared-utils/changeModelCanvasOpacity.d.ts +2 -0
  143. package/shared-utils/{changeModelCanvansOpacity.js → changeModelCanvasOpacity.js} +2 -2
  144. package/shared-utils/removeArrayItem.d.ts +7 -0
  145. package/shared-utils/removeArrayItem.js +22 -0
  146. package/shared-utils/three/loadTexture.d.ts +2 -2
  147. package/shared-utils/three/loadTexture.js +21 -2
  148. package/typedoc/libs.d.ts +1 -0
  149. package/typedoc/libs.js +7 -0
  150. package/components/PBRView/index.d.ts +0 -14
  151. package/shared-utils/changeModelCanvansOpacity.d.ts +0 -2
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.reflect.construct.js");
4
+
5
+ require("core-js/modules/es.object.define-property.js");
6
+
7
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
8
+
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+ exports["default"] = void 0;
13
+
14
+ require("core-js/modules/es.array.map.js");
15
+
16
+ require("core-js/modules/es.array.for-each.js");
17
+
18
+ require("core-js/modules/web.dom-collections.for-each.js");
19
+
20
+ require("core-js/modules/es.array.filter.js");
21
+
22
+ require("core-js/modules/es.array.sort.js");
23
+
24
+ require("core-js/modules/es.array.find.js");
25
+
26
+ require("core-js/modules/es.array.reverse.js");
27
+
28
+ require("core-js/modules/es.array.slice.js");
29
+
30
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
31
+
32
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
33
+
34
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
35
+
36
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
37
+
38
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
39
+
40
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
41
+
42
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
43
+
44
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
45
+
46
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
47
+
48
+ var _hammerjs = _interopRequireDefault(require("hammerjs"));
49
+
50
+ var _DeleteDom = _interopRequireDefault(require("../Modules/DeleteDom"));
51
+
52
+ var _isNDCPointInScreen = _interopRequireDefault(require("../utils/isNDCPointInScreen"));
53
+
54
+ var _BaseController2 = _interopRequireDefault(require("./BaseController"));
55
+
56
+ var _three = require("three");
57
+
58
+ var _math = require("../utils/math");
59
+
60
+ var _findClosestPoint2 = require("../utils/findClosestPoint");
61
+
62
+ var _findAssociatedLines = require("../utils/findAssociatedLines");
63
+
64
+ var _getPointFromHammerEvent = require("../utils/getPointFromHammerEvent");
65
+
66
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
67
+
68
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
69
+
70
+ var WatchController = /*#__PURE__*/function (_BaseController) {
71
+ (0, _inherits2["default"])(WatchController, _BaseController);
72
+
73
+ var _super = _createSuper(WatchController);
74
+
75
+ function WatchController(params) {
76
+ var _this;
77
+
78
+ (0, _classCallCheck2["default"])(this, WatchController);
79
+ _this = _super.call(this, params);
80
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "type", 'watch');
81
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "highlightedLines", []);
82
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPanStart", function (e) {
83
+ var _findClosestPoint;
84
+
85
+ if (_this.model.points.length === 0 || !_this.fiveElement) return;
86
+ var mouse = (0, _getPointFromHammerEvent.getPointFromHammerEvent)(e).point;
87
+ var closestPoint = (_findClosestPoint = (0, _findClosestPoint2.findClosestPoint)(_this.five, _this.model.points, mouse, 20)) === null || _findClosestPoint === void 0 ? void 0 : _findClosestPoint.point;
88
+
89
+ if (!closestPoint) {
90
+ _this.editPointState = undefined;
91
+ return;
92
+ }
93
+
94
+ var editPointState = {
95
+ point: closestPoint,
96
+ associatedLines: (0, _findAssociatedLines.findAssociatedLines)(closestPoint.lines[0])
97
+ };
98
+
99
+ var cancelDragLine = _this.hook.emit('wantsDragLine', {
100
+ point: closestPoint.id,
101
+ lines: editPointState.associatedLines.map(function (_ref) {
102
+ var id = _ref.id;
103
+ return id;
104
+ })
105
+ });
106
+
107
+ if (cancelDragLine) return;
108
+ _this.editPointState = editPointState;
109
+
110
+ _this.magnifier.appendTo(_this.container);
111
+
112
+ _this.group.add(_this.mouseGroup);
113
+ });
114
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPanEnd", function () {
115
+ if (!_this.editPointState) return; // 把拖动的线从虚线转换为实线
116
+
117
+ _this.editPointState.point.lines.forEach(function (line) {
118
+ return line.mesh.setMaterial({
119
+ dashed: false
120
+ });
121
+ }); // 还原选中态
122
+
123
+
124
+ _this.highlightLines(_this.editPointState.associatedLines);
125
+
126
+ _this.editPointState = undefined;
127
+
128
+ _this.magnifier.dispose();
129
+
130
+ _this.group.remove(_this.mouseGroup);
131
+ });
132
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPan", function (e) {
133
+ if (!_this.editPointState || !_this.fiveElement) return;
134
+ var mouse = (0, _getPointFromHammerEvent.getPointFromHammerEvent)(e).ndcPoint;
135
+ var raycaster = new _three.Raycaster();
136
+ raycaster.setFromCamera(mouse, _this.five.camera);
137
+
138
+ var _this$five$model$inte = _this.five.model.intersectRaycaster(raycaster),
139
+ _this$five$model$inte2 = (0, _slicedToArray2["default"])(_this$five$model$inte, 1),
140
+ intersection = _this$five$model$inte2[0];
141
+
142
+ if (!intersection) return;
143
+
144
+ _this.onIntersectionUpdate(intersection);
145
+ });
146
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onIntersectionUpdate", function (intersection, mesh) {
147
+ if (!_this.editPointState) return; // 拖动过程中清除选中态
148
+
149
+ _this.clearHighlightLines(); // 把拖动点相关的线变成虚线 & 改变相关线的位置
150
+
151
+
152
+ _this.editPointState.point.position.copy(intersection.point);
153
+
154
+ _this.editPointState.point.lines.forEach(function (line) {
155
+ line.mesh.setPoints(line.points[0].position.clone(), line.points[1].position.clone());
156
+ line.lightMesh.setPoints(line.points[0].position.clone(), line.points[1].position.clone());
157
+ line.mesh.setMaterial({
158
+ dashed: true
159
+ });
160
+ });
161
+
162
+ _this.updateDistanceUI();
163
+
164
+ _this.magnifier.updateWithPoint(intersection.point);
165
+
166
+ _this.mouseGroup.position.copy(intersection.point);
167
+
168
+ if (mesh) {
169
+ _this.mouseGroup.quaternion.copy(mesh.quaternion);
170
+ } else if (intersection.face) {
171
+ var face = intersection.face.normal;
172
+ var positionVector = face.clone().multiplyScalar(0.05);
173
+ var position = intersection.point.clone().add(positionVector);
174
+ var lookAtVector = position.clone().add(positionVector);
175
+
176
+ _this.mouseGroup.lookAt(lookAtVector);
177
+ }
178
+
179
+ _this.five.needsRender = true;
180
+
181
+ _this.hook.emit('selectedChange', _this.editPointState.associatedLines.map(function (line) {
182
+ return line.toCompletelyJson();
183
+ }));
184
+ });
185
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "wantsPanGesture", function () {
186
+ if (_this.editPointState) return false;
187
+ });
188
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "wantsTapGesture", function (raycaster) {
189
+ var _this$five$model$inte3 = _this.five.model.intersectRaycaster(raycaster),
190
+ _this$five$model$inte4 = (0, _slicedToArray2["default"])(_this$five$model$inte3, 1),
191
+ target = _this$five$model$inte4[0];
192
+
193
+ if (!target) return;
194
+ var camera = _this.five.camera;
195
+ var ndcTarget = target.point.clone().project(camera);
196
+ var screenWidth = _this.container.clientWidth;
197
+ var screenHeight = _this.container.clientHeight;
198
+ var targetScreenPosition = new _three.Vector2(ndcTarget.x * screenWidth, ndcTarget.y * screenHeight); // 把线的端点全部映射到屏幕上,过滤掉不在视野内的线,同时乘以屏幕宽 & 高
199
+
200
+ var screenLines = _this.model.lines.map(function (line) {
201
+ var _line$points = (0, _slicedToArray2["default"])(line.points, 2),
202
+ startPoint = _line$points[0],
203
+ endPoint = _line$points[1];
204
+
205
+ var ndcStartPoint = startPoint.position.clone().project(camera);
206
+ var ndcEndPoint = endPoint.position.clone().project(camera);
207
+ if (!(0, _isNDCPointInScreen["default"])(ndcStartPoint) && !(0, _isNDCPointInScreen["default"])(ndcEndPoint)) return null;
208
+ var startScreenPosition = new _three.Vector2(ndcStartPoint.x * screenWidth, ndcStartPoint.y * screenHeight);
209
+ var endScreenPosition = new _three.Vector2(ndcEndPoint.x * screenWidth, ndcEndPoint.y * screenHeight);
210
+ return {
211
+ id: line.id,
212
+ points: [startScreenPosition, endScreenPosition]
213
+ };
214
+ }).filter(function (line) {
215
+ return !!line;
216
+ });
217
+
218
+ if (screenLines.length === 0) return; // 找这些线距离鼠标点击位置最近的线
219
+
220
+ var distanceLines = screenLines.map(function (line) {
221
+ var closestPoint = (0, _math.closestPointOnLine)(targetScreenPosition, line.points);
222
+ return {
223
+ id: line.id,
224
+ distance: closestPoint.distanceTo(targetScreenPosition)
225
+ };
226
+ }).sort(function (a, b) {
227
+ return a.distance - b.distance;
228
+ });
229
+ var closestScreenLine = distanceLines[0];
230
+ if (closestScreenLine.distance > 20) return;
231
+
232
+ var closestLine = _this.model.lines.find(function (_ref2) {
233
+ var id = _ref2.id;
234
+ return id === closestScreenLine.id;
235
+ });
236
+
237
+ if (!closestLine) return;
238
+
239
+ _this.chooseLine(closestLine);
240
+
241
+ return false;
242
+ });
243
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "chooseLine", function (line) {
244
+ var highlightLines = (0, _findAssociatedLines.findAssociatedLines)(line);
245
+
246
+ _this.highlightLines(highlightLines);
247
+
248
+ _this.five.needsRender = true;
249
+
250
+ _this.hook.emit('selectedChange', highlightLines.map(function (line) {
251
+ return line.toCompletelyJson();
252
+ }));
253
+ });
254
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "lineRemoved", function (line) {
255
+ _this.removeLine(line); // TODO: 这个逻辑不太好,改进一下
256
+
257
+
258
+ _this.hook.emit('selectedChange', _this.model.lines.filter(function (line) {
259
+ return line.selected;
260
+ }).map(function (line) {
261
+ return line.toCompletelyJson();
262
+ }));
263
+ });
264
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCameraUpdate", function () {
265
+ _this.updateDistanceUI();
266
+
267
+ _this.highlightedLines.length > 0 && _this.deleteDom.updatePosition();
268
+ });
269
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteDomClickCallback", function () {
270
+ var firstLine = _this.highlightedLines[0]; // TODO: 优化折线的删除逻辑
271
+
272
+ firstLine.getPolyline().lines.slice().reverse().forEach(function (line) {
273
+ return _this.model.removeLine(line);
274
+ });
275
+ _this.highlightedLines = []; // this.clearHighlightLines()
276
+ // this.highlightedLines.forEach((line) => this.model.removeLine(line))
277
+
278
+ _this.deleteDom.setLines([]).hide();
279
+ });
280
+ _this.deleteDom = new _DeleteDom["default"](_this.five, {
281
+ onClick: _this.deleteDomClickCallback
282
+ }).appendTo(_this.container);
283
+
284
+ _this.model.lines.forEach(function (line) {
285
+ line.distanceItem.appendTo(_this.container);
286
+ line.distanceItem.update(_this.five);
287
+ line.hook.on('selected', _this.chooseLine);
288
+
289
+ _this.group.add(line.mesh);
290
+ });
291
+
292
+ var fiveElement = _this.five.getElement();
293
+
294
+ if (fiveElement) {
295
+ _this.fiveElement = fiveElement;
296
+ var hammer = new _hammerjs["default"](fiveElement);
297
+ _this.hammer = hammer;
298
+ hammer.on('pan', _this.onPan);
299
+ hammer.on('panstart', _this.onPanStart);
300
+ hammer.on('panend', _this.onPanEnd);
301
+ }
302
+
303
+ _this.model.hook.on('lineRemoved', _this.lineRemoved);
304
+
305
+ _this.five.on('cameraUpdate', _this.onCameraUpdate);
306
+
307
+ _this.five.on('wantsTapGesture', _this.wantsTapGesture);
308
+
309
+ _this.five.on('wantsPanGesture', _this.wantsPanGesture);
310
+
311
+ _this.five.needsRender = true;
312
+ return _this;
313
+ }
314
+
315
+ (0, _createClass2["default"])(WatchController, [{
316
+ key: "dispose",
317
+ value: function dispose() {
318
+ var _this$hammer;
319
+
320
+ (0, _get2["default"])((0, _getPrototypeOf2["default"])(WatchController.prototype), "dispose", this).call(this);
321
+ this.deleteDom.dispose();
322
+ this.model.hook.off('lineRemoved', this.lineRemoved);
323
+ this.five.off('cameraUpdate', this.onCameraUpdate);
324
+ this.five.off('wantsPanGesture', this.wantsPanGesture);
325
+ this.five.off('wantsTapGesture', this.wantsTapGesture);
326
+ this.five.needsRender = true;
327
+ this.hook.emit('selectedChange', []);
328
+ (_this$hammer = this.hammer) === null || _this$hammer === void 0 ? void 0 : _this$hammer.destroy();
329
+ }
330
+ }, {
331
+ key: "highlightLine",
332
+ value: function highlightLine(line) {
333
+ if (line.selected) return;
334
+ line.selected = true;
335
+ this.group.add(line.lightMesh);
336
+ line.distanceItem.highlight();
337
+ this.five.needsRender = true;
338
+ }
339
+ }, {
340
+ key: "clearHighlightLines",
341
+ value: function clearHighlightLines() {
342
+ var _this2 = this;
343
+
344
+ if (this.group.children.length === 0) return;
345
+ this.deleteDom.setLines([]).hide();
346
+ this.model.lines.forEach(function (line) {
347
+ line.selected = false;
348
+ line.distanceItem.unHighlight();
349
+
350
+ _this2.group.remove(line.lightMesh);
351
+ });
352
+ this.highlightedLines = [];
353
+ this.five.needsRender = true;
354
+ }
355
+ }, {
356
+ key: "highlightLines",
357
+ value: function highlightLines(lines) {
358
+ var _this3 = this;
359
+
360
+ this.clearHighlightLines();
361
+ this.highlightedLines = lines;
362
+ this.deleteDom.setLines(lines).updatePosition().show();
363
+ lines.forEach(function (line) {
364
+ return _this3.highlightLine(line);
365
+ });
366
+ }
367
+ }]);
368
+ return WatchController;
369
+ }(_BaseController2["default"]);
370
+
371
+ exports["default"] = WatchController;
@@ -0,0 +1,61 @@
1
+ import { PluginData } from '../typings/data';
2
+ import { Five, Subscribe } from '@realsee/five';
3
+ import { PluginEvent } from '../typings/event.type';
4
+ import { UserDistanceItem } from '../utils/distanceDom';
5
+ export declare type Mode = 'Watch' | 'Edit';
6
+ export interface MeasurePluginParameter {
7
+ useUIController?: boolean;
8
+ useGuideController?: boolean;
9
+ userDistanceItemCreator?: () => UserDistanceItem;
10
+ }
11
+ export default class MeasureController {
12
+ hasOpen: boolean;
13
+ hook: Subscribe<PluginEvent>;
14
+ private five;
15
+ private model;
16
+ private group;
17
+ private magnifier;
18
+ private fiveHelper;
19
+ private useUIController?;
20
+ private params;
21
+ private useGuideController?;
22
+ private container;
23
+ private shortcutKeyController?;
24
+ private controller;
25
+ private controllerParams;
26
+ constructor(five: Five, params: MeasurePluginParameter);
27
+ appendTo(parent: HTMLElement): void;
28
+ dispose(): void;
29
+ /** 加载数据
30
+ * @description 数据加载时会覆盖当前已保存的数据
31
+ * @description 如果当前正在编辑中,会自动退出并保存编辑
32
+ */
33
+ load(data: PluginData): void;
34
+ /** 插件功能入口
35
+ * @description 会隐藏鼠标的默认聚焦环
36
+ * @description 会隐藏当前 VR 内的点位展示
37
+ */
38
+ open(): void;
39
+ /** 关闭插件功能
40
+ * @description 清除标尺线条
41
+ * @description 还原点位展示和默认鼠标 UI
42
+ */
43
+ close(): void;
44
+ getCurrentMode: () => Mode | null;
45
+ /** 变更场景
46
+ * @description 如果从编辑场景改变到观看场景,不会自动保存,默认丢弃所有改动
47
+ */
48
+ changeMode: (mode: Mode) => void;
49
+ /** 撤销编辑 */
50
+ revoke(): void;
51
+ removeLineByID(lineID: string): void;
52
+ /**
53
+ * 高亮当前线段
54
+ */
55
+ highlightLine(lineID: string): boolean;
56
+ clearHighlightLines(): boolean;
57
+ /** 保存编辑 */
58
+ save(): this;
59
+ /** 把当前以保存的数据转换成 JSON 对象 */
60
+ toJson(): PluginData;
61
+ }
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ require("core-js/modules/es.function.name.js");
13
+
14
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
+
16
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
+
18
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
+
20
+ var _Magnifier = _interopRequireDefault(require("../Modules/Magnifier"));
21
+
22
+ var _FiveHelper = _interopRequireDefault(require("../Modules/FiveHelper"));
23
+
24
+ var _EditController = _interopRequireDefault(require("./EditController"));
25
+
26
+ var _WatchController = _interopRequireDefault(require("./WatchController"));
27
+
28
+ var _three = require("three");
29
+
30
+ var _Model = require("../Model");
31
+
32
+ var _five = require("@realsee/five");
33
+
34
+ var _mouseGroup = require("../utils/mouseGroup");
35
+
36
+ var _UIController = require("../Modules/UIController");
37
+
38
+ var _GuideController = require("../Modules/GuideController");
39
+
40
+ var _ShortcutKeyController = require("./ShortcutKeyController");
41
+
42
+ var MeasureController = /*#__PURE__*/function () {
43
+ function MeasureController(five, params) {
44
+ var _this = this;
45
+
46
+ (0, _classCallCheck2["default"])(this, MeasureController);
47
+ (0, _defineProperty2["default"])(this, "hasOpen", false);
48
+ (0, _defineProperty2["default"])(this, "hook", new _five.Subscribe());
49
+ (0, _defineProperty2["default"])(this, "container", document.createElement('div'));
50
+ (0, _defineProperty2["default"])(this, "controller", null);
51
+ (0, _defineProperty2["default"])(this, "getCurrentMode", function () {
52
+ if (_this.controller instanceof _EditController["default"]) return 'Edit';
53
+ if (_this.controller instanceof _WatchController["default"]) return 'Watch';
54
+ return null;
55
+ });
56
+ (0, _defineProperty2["default"])(this, "changeMode", function (mode) {
57
+ var _this$controller;
58
+
59
+ if (!_this.hasOpen) return;
60
+ if (_this.getCurrentMode() === mode) return;
61
+ (_this$controller = _this.controller) === null || _this$controller === void 0 ? void 0 : _this$controller.dispose();
62
+ var controllerMap = {
63
+ Watch: _WatchController["default"],
64
+ Edit: _EditController["default"]
65
+ };
66
+ if (!controllerMap[mode]) throw new Error('不存在的 Mode');
67
+ _this.controller = new controllerMap[mode](_this.controllerParams);
68
+
69
+ _this.hook.emit('modeChange', mode);
70
+ });
71
+ this.five = five;
72
+ this.params = params;
73
+ this.model = new _Model.Model({
74
+ userDistanceItemCreator: this.params.userDistanceItemCreator
75
+ });
76
+ this.fiveHelper = new _FiveHelper["default"](five); // magnifier
77
+
78
+ var magnifierSize = 190;
79
+ var magnifierScale = 2;
80
+ this.magnifier = new _Magnifier["default"](five, {
81
+ scale: magnifierScale,
82
+ width: magnifierSize,
83
+ height: magnifierSize
84
+ }); // ==================== Group ====================
85
+
86
+ this.group = new _three.Group();
87
+ this.group.name = 'plugin-measure-group';
88
+ this.container.classList.add('five-plugin-measure-container');
89
+ this.container.style.position = 'relative';
90
+ this.container.style.pointerEvents = 'none';
91
+ this.container.style.width = '100%';
92
+ this.container.style.height = '100%';
93
+ this.container.style.background = 'rgba(0, 0, 0, 0.15)';
94
+ this.controllerParams = {
95
+ five: this.five,
96
+ hook: this.hook,
97
+ group: this.group,
98
+ model: this.model,
99
+ magnifier: this.magnifier,
100
+ container: this.container,
101
+ fiveHelper: this.fiveHelper,
102
+ mouseGroup: (0, _mouseGroup.getMouseGroup)(),
103
+ userDistanceItemCreator: this.params.userDistanceItemCreator
104
+ };
105
+ if (this.params.useUIController !== false) this.useUIController = new _UIController.UIController(this, this.controllerParams);
106
+ if (this.params.useUIController !== false) this.useGuideController = new _GuideController.GuideController(this, this.controllerParams);
107
+ }
108
+
109
+ (0, _createClass2["default"])(MeasureController, [{
110
+ key: "appendTo",
111
+ value: function appendTo(parent) {
112
+ parent.append(this.container);
113
+ }
114
+ }, {
115
+ key: "dispose",
116
+ value: function dispose() {
117
+ var _this$useUIController, _this$magnifier;
118
+
119
+ this.close();
120
+ (_this$useUIController = this.useUIController) === null || _this$useUIController === void 0 ? void 0 : _this$useUIController.dispose();
121
+ (_this$magnifier = this.magnifier) === null || _this$magnifier === void 0 ? void 0 : _this$magnifier.dispose();
122
+ this.five.needsRender = true;
123
+ }
124
+ /** 加载数据
125
+ * @description 数据加载时会覆盖当前已保存的数据
126
+ * @description 如果当前正在编辑中,会自动退出并保存编辑
127
+ */
128
+
129
+ }, {
130
+ key: "load",
131
+ value: function load(data) {
132
+ this.model.parse(data);
133
+ this.save();
134
+ }
135
+ /** 插件功能入口
136
+ * @description 会隐藏鼠标的默认聚焦环
137
+ * @description 会隐藏当前 VR 内的点位展示
138
+ */
139
+
140
+ }, {
141
+ key: "open",
142
+ value: function open() {
143
+ var _this$useUIController2, _this$useGuideControl;
144
+
145
+ if (this.hasOpen) return;
146
+ this.hasOpen = true;
147
+ this.five.scene.add(this.group); // 隐藏点位和鼠标聚焦环
148
+
149
+ this.five.helperVisible = false;
150
+ this.controller = new _WatchController["default"](this.controllerParams);
151
+ (_this$useUIController2 = this.useUIController) === null || _this$useUIController2 === void 0 ? void 0 : _this$useUIController2.show();
152
+ (_this$useGuideControl = this.useGuideController) === null || _this$useGuideControl === void 0 ? void 0 : _this$useGuideControl.show();
153
+ this.shortcutKeyController = new _ShortcutKeyController.ShortcutKeyController(this, this.five);
154
+ }
155
+ /** 关闭插件功能
156
+ * @description 清除标尺线条
157
+ * @description 还原点位展示和默认鼠标 UI
158
+ */
159
+
160
+ }, {
161
+ key: "close",
162
+ value: function close() {
163
+ var _this$controller2, _this$useUIController3, _this$useGuideControl2, _this$shortcutKeyCont;
164
+
165
+ this.hasOpen = false; // 展示点位和鼠标聚焦环
166
+
167
+ (_this$controller2 = this.controller) === null || _this$controller2 === void 0 ? void 0 : _this$controller2.dispose();
168
+ (_this$useUIController3 = this.useUIController) === null || _this$useUIController3 === void 0 ? void 0 : _this$useUIController3.hide();
169
+ (_this$useGuideControl2 = this.useGuideController) === null || _this$useGuideControl2 === void 0 ? void 0 : _this$useGuideControl2.hide();
170
+ (_this$shortcutKeyCont = this.shortcutKeyController) === null || _this$shortcutKeyCont === void 0 ? void 0 : _this$shortcutKeyCont.dispose();
171
+ this.controller = null;
172
+ this.five.helperVisible = true;
173
+ this.five.scene.remove(this.group);
174
+ this.five.needsRender = true;
175
+ }
176
+ }, {
177
+ key: "revoke",
178
+ value:
179
+ /** 撤销编辑 */
180
+ function revoke() {
181
+ if (!(this.controller instanceof _EditController["default"])) return;
182
+ this.controller.revoke();
183
+ return;
184
+ }
185
+ }, {
186
+ key: "removeLineByID",
187
+ value: function removeLineByID(lineID) {
188
+ this.model.removeLineByID(lineID);
189
+ }
190
+ /**
191
+ * 高亮当前线段
192
+ */
193
+
194
+ }, {
195
+ key: "highlightLine",
196
+ value: function highlightLine(lineID) {
197
+ if (this.getCurrentMode() !== 'Watch') return false;
198
+ var line = this.model.getLineByID(lineID);
199
+ if (!line) return false;
200
+ this.controller.highlightLine(line);
201
+ return true;
202
+ }
203
+ }, {
204
+ key: "clearHighlightLines",
205
+ value: function clearHighlightLines() {
206
+ if (this.getCurrentMode() !== 'Watch') return false;
207
+ this.controller.clearHighlightLines();
208
+ return true;
209
+ }
210
+ /** 保存编辑 */
211
+
212
+ }, {
213
+ key: "save",
214
+ value: function save() {
215
+ if (!(this.controller instanceof _EditController["default"])) return this;
216
+ this.model.mergeModel(this.controller.model);
217
+ return this;
218
+ }
219
+ /** 把当前以保存的数据转换成 JSON 对象 */
220
+
221
+ }, {
222
+ key: "toJson",
223
+ value: function toJson() {
224
+ return this.model.toJson();
225
+ }
226
+ }]);
227
+ return MeasureController;
228
+ }();
229
+
230
+ exports["default"] = MeasureController;