@realsee/dnalogel 0.1.7-alpha.2 → 0.1.7-alpha.6

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 (157) hide show
  1. package/components/ARVideoFigure/ImgBgTransparentMesh.js +2 -2
  2. package/components/GLTFView/index.d.ts +7 -1
  3. package/components/GLTFView/index.js +7 -1
  4. package/components/GlassFilters/index.js +2 -2
  5. package/components/ModelView/ModelViewController.js +6 -5
  6. package/data/81zxMaeVKLQU93OZMG.d.ts +49 -0
  7. package/data/81zxMaeVKLQU93OZMG.js +633 -0
  8. package/data/PrXel3aqGbp34JQn.js +139 -1
  9. package/data/_vLykj3NWrllMrG06.d.ts +95 -0
  10. package/data/_vLykj3NWrllMrG06.js +1 -0
  11. package/data/vLykj3NWrllMrG06.js +335 -71
  12. package/libs/gltf-viewer/Subscribe.js +2 -0
  13. package/libs/gltf-viewer/coordsToDirection.d.ts +1 -1
  14. package/libs/gltf-viewer/index.d.ts +18 -0
  15. package/libs/gltf-viewer/index.js +133 -45
  16. package/package.json +3 -3
  17. package/plugins/CSS3DRenderPlugin/components/Marker/index.js +2 -0
  18. package/plugins/CSS3DRenderPlugin/index.js +2 -2
  19. package/plugins/ModelChassisCompassPlugin/index.d.ts +1 -1
  20. package/plugins/ModelChassisCompassPlugin/index.js +2 -1
  21. package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +4 -0
  22. package/plugins/ModelEntryDoorGuidePlugin/index.js +6 -1
  23. package/plugins/ModelExtrudeWallsPlugin/index.js +2 -2
  24. package/plugins/ModelRoomLabelPlugin/Controller.js +1 -0
  25. package/plugins/ModelRoomLabelPlugin/RoomLabelItem.js +5 -5
  26. package/plugins/ModelRoomLabelPlugin/RoomLabelItems.js +2 -2
  27. package/plugins/ModelRoomLabelPlugin/index.d.ts +4 -0
  28. package/plugins/ModelRoomLabelPlugin/index.js +7 -2
  29. package/plugins/ModelTVVideoPlugin/index.js +4 -2
  30. package/plugins/ModelViewPlugin/index.js +2 -2
  31. package/plugins/PanoCursorRaycasterPlugin/index.js +2 -0
  32. package/plugins/PanoMeasurePlugin/Controller/BaseController.d.ts +36 -0
  33. package/plugins/PanoMeasurePlugin/Controller/BaseController.js +105 -0
  34. package/plugins/PanoMeasurePlugin/Controller/EditController.d.ts +52 -0
  35. package/plugins/PanoMeasurePlugin/Controller/EditController.js +343 -0
  36. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.d.ts +12 -0
  37. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.js +69 -0
  38. package/plugins/PanoMeasurePlugin/Controller/WatchController.d.ts +25 -0
  39. package/plugins/PanoMeasurePlugin/Controller/WatchController.js +373 -0
  40. package/plugins/PanoMeasurePlugin/Controller/index.d.ts +61 -0
  41. package/plugins/PanoMeasurePlugin/Controller/index.js +230 -0
  42. package/plugins/PanoMeasurePlugin/Model/index.d.ts +38 -0
  43. package/plugins/PanoMeasurePlugin/Model/index.js +237 -0
  44. package/plugins/PanoMeasurePlugin/Model/line.d.ts +30 -0
  45. package/plugins/PanoMeasurePlugin/Model/line.js +123 -0
  46. package/plugins/PanoMeasurePlugin/Model/point.d.ts +16 -0
  47. package/plugins/PanoMeasurePlugin/Model/point.js +72 -0
  48. package/plugins/PanoMeasurePlugin/Model/polyline.d.ts +16 -0
  49. package/plugins/PanoMeasurePlugin/Model/polyline.js +111 -0
  50. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.d.ts +2 -0
  51. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.js +11 -0
  52. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.d.ts +2 -0
  53. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.js +11 -0
  54. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.d.ts +2 -0
  55. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.js +11 -0
  56. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.d.ts +22 -0
  57. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.js +184 -0
  58. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.d.ts +11 -0
  59. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.js +68 -0
  60. package/plugins/PanoMeasurePlugin/Modules/GuideController.d.ts +18 -0
  61. package/plugins/PanoMeasurePlugin/Modules/GuideController.js +107 -0
  62. package/plugins/PanoMeasurePlugin/Modules/Magnifier.d.ts +24 -0
  63. package/plugins/PanoMeasurePlugin/Modules/Magnifier.js +139 -0
  64. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.d.ts +6 -0
  65. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.js +26 -0
  66. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +18 -0
  67. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +169 -0
  68. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.d.ts +12 -0
  69. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +59 -0
  70. package/plugins/PanoMeasurePlugin/Modules/UIController/index.d.ts +16 -0
  71. package/plugins/PanoMeasurePlugin/Modules/UIController/index.js +125 -0
  72. package/plugins/PanoMeasurePlugin/Modules/UIController/style.d.ts +17 -0
  73. package/plugins/PanoMeasurePlugin/Modules/UIController/style.js +103 -0
  74. package/plugins/PanoMeasurePlugin/index.d.ts +7 -0
  75. package/plugins/PanoMeasurePlugin/index.js +20 -0
  76. package/plugins/PanoMeasurePlugin/typings/data.d.ts +28 -0
  77. package/plugins/PanoMeasurePlugin/typings/data.js +7 -0
  78. package/plugins/PanoMeasurePlugin/typings/event.type.d.ts +28 -0
  79. package/plugins/PanoMeasurePlugin/typings/event.type.js +7 -0
  80. package/plugins/PanoMeasurePlugin/typings/utils.type.d.ts +1 -0
  81. package/plugins/PanoMeasurePlugin/typings/utils.type.js +7 -0
  82. package/plugins/PanoMeasurePlugin/utils/clearGroup.d.ts +2 -0
  83. package/plugins/PanoMeasurePlugin/utils/clearGroup.js +16 -0
  84. package/plugins/PanoMeasurePlugin/utils/constants.d.ts +4 -0
  85. package/plugins/PanoMeasurePlugin/utils/constants.js +47 -0
  86. package/plugins/PanoMeasurePlugin/utils/distanceDom.d.ts +28 -0
  87. package/plugins/PanoMeasurePlugin/utils/distanceDom.js +147 -0
  88. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.d.ts +2 -0
  89. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.js +39 -0
  90. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.d.ts +10 -0
  91. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.js +49 -0
  92. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.d.ts +4 -0
  93. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.js +20 -0
  94. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.d.ts +10 -0
  95. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.js +33 -0
  96. package/plugins/PanoMeasurePlugin/utils/ironbox.d.ts +1 -0
  97. package/plugins/PanoMeasurePlugin/utils/ironbox.js +14 -0
  98. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.d.ts +2 -0
  99. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.js +16 -0
  100. package/plugins/PanoMeasurePlugin/utils/line.d.ts +17 -0
  101. package/plugins/PanoMeasurePlugin/utils/line.js +61 -0
  102. package/plugins/PanoMeasurePlugin/utils/math.d.ts +17 -0
  103. package/plugins/PanoMeasurePlugin/utils/math.js +57 -0
  104. package/plugins/PanoMeasurePlugin/utils/mouseGroup.d.ts +2 -0
  105. package/plugins/PanoMeasurePlugin/utils/mouseGroup.js +42 -0
  106. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.d.ts +5 -0
  107. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.js +16 -0
  108. package/plugins/PanoRulerPlugin/index.d.ts +4 -0
  109. package/plugins/PanoRulerPlugin/index.js +8 -3
  110. package/plugins/TreasurePlugin/Controller.js +2 -2
  111. package/plugins/TreasurePlugin/TreasureOpenAnime.js +2 -2
  112. package/plugins/floorplan/Assets/floorplanExtraObject.d.ts +1 -1
  113. package/plugins/floorplan/Assets/floorplanExtraObject.js +3 -3
  114. package/plugins/floorplan/ModelFloorplanPlugin/Controller.d.ts +5 -2
  115. package/plugins/floorplan/ModelFloorplanPlugin/Controller.js +22 -11
  116. package/plugins/floorplan/ModelFloorplanPlugin/components/Camera.js +4 -4
  117. package/plugins/floorplan/ModelFloorplanPlugin/components/Compass.js +5 -5
  118. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomHighlight.js +2 -2
  119. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomLabels.js +2 -2
  120. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.d.ts +11 -0
  121. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.js +174 -0
  122. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.d.ts +8 -0
  123. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.js +182 -0
  124. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.d.ts +2 -0
  125. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.js +14 -2
  126. package/plugins/floorplan/ModelFloorplanPlugin/components/index.d.ts +3 -0
  127. package/plugins/floorplan/ModelFloorplanPlugin/components/index.js +1 -1
  128. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.d.ts +2 -0
  129. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.js +7 -0
  130. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.d.ts +1 -1
  131. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.js +1 -1
  132. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.js +3 -2
  133. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.style.js +4 -4
  134. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/ExtraObjects.js +2 -2
  135. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/RoomHighlight.js +2 -2
  136. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/index.js +2 -2
  137. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/index.js +2 -2
  138. package/plugins/floorplan/TopviewFloorplanPlugin/Controller.d.ts +3 -0
  139. package/plugins/floorplan/TopviewFloorplanPlugin/Controller.js +16 -6
  140. package/plugins/floorplan/index.d.ts +4 -0
  141. package/plugins/floorplan/index.js +13 -0
  142. package/plugins/floorplan/typings/floorplanData.d.ts +2 -0
  143. package/plugins/floorplan/typings/floorplanServerData.d.ts +3 -1
  144. package/plugins/floorplan/typings/floorplanServerData.js +3 -3
  145. package/plugins/floorplan/utils/formatData.js +3 -2
  146. package/plugins/floorplan/utils/formatPosition.js +2 -0
  147. package/shared-utils/Subscribe.js +4 -2
  148. package/shared-utils/animationFrame/BetterTween.js +5 -1
  149. package/shared-utils/changeModelCanvasOpacity.d.ts +2 -0
  150. package/shared-utils/{changeModelCanvansOpacity.js → changeModelCanvasOpacity.js} +2 -2
  151. package/shared-utils/filter.js +4 -2
  152. package/shared-utils/math/planimetry.js +2 -0
  153. package/shared-utils/removeArrayItem.d.ts +7 -0
  154. package/shared-utils/removeArrayItem.js +22 -0
  155. package/shared-utils/three/loadTexture.d.ts +2 -2
  156. package/shared-utils/three/loadTexture.js +21 -2
  157. package/shared-utils/changeModelCanvansOpacity.d.ts +0 -2
@@ -0,0 +1,36 @@
1
+ import Line from '../Model/line';
2
+ import Magnifier from '../Modules/Magnifier';
3
+ import FiveHelper from '../Modules/FiveHelper';
4
+ import { Group } from 'three';
5
+ import { Model } from '../Model';
6
+ import { PluginEvent } from '../typings/event.type';
7
+ import { Five, Intersection, IntersectMeshInterface, Subscribe } from '@realsee/five';
8
+ import { UserDistanceItem } from '../utils/distanceDom';
9
+ export interface IControllerParams {
10
+ five: Five;
11
+ group: Group;
12
+ model: Model;
13
+ mouseGroup: Group;
14
+ container: Element;
15
+ magnifier: Magnifier;
16
+ fiveHelper: FiveHelper;
17
+ hook: Subscribe<PluginEvent>;
18
+ userDistanceItemCreator?: () => UserDistanceItem;
19
+ }
20
+ export default abstract class BaseController {
21
+ protected five: Five;
22
+ protected group: Group;
23
+ protected model: Model;
24
+ protected disposed: boolean;
25
+ protected mouseGroup: Group;
26
+ protected container: Element;
27
+ protected fiveHelper: FiveHelper;
28
+ protected hook: IControllerParams['hook'];
29
+ protected magnifier: IControllerParams['magnifier'];
30
+ protected userDistanceItemCreator: IControllerParams['userDistanceItemCreator'];
31
+ constructor(params: IControllerParams);
32
+ protected removeLine(line: Line): void;
33
+ protected updateDistanceUI: () => void;
34
+ protected updateMouseGroup(intersection: Intersection, mesh?: IntersectMeshInterface): Group;
35
+ protected dispose(): void;
36
+ }
@@ -0,0 +1,105 @@
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.array.for-each.js");
13
+
14
+ require("core-js/modules/es.object.to-string.js");
15
+
16
+ require("core-js/modules/web.dom-collections.for-each.js");
17
+
18
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
+
20
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _ironbox = require("../utils/ironbox");
25
+
26
+ var BaseController = /*#__PURE__*/function () {
27
+ function BaseController(params) {
28
+ var _this = this;
29
+
30
+ (0, _classCallCheck2["default"])(this, BaseController);
31
+ (0, _defineProperty2["default"])(this, "disposed", false);
32
+ (0, _defineProperty2["default"])(this, "updateDistanceUI", function () {
33
+ _this.model.lines.forEach(function (line) {
34
+ return line.distanceItem.update(_this.five);
35
+ });
36
+ });
37
+ // ==================== Params ====================
38
+ this.five = params.five;
39
+ this.hook = params.hook;
40
+ this.model = params.model;
41
+ this.magnifier = params.magnifier;
42
+ this.container = params.container;
43
+ this.fiveHelper = params.fiveHelper;
44
+ this.userDistanceItemCreator = params.userDistanceItemCreator; // ==================== Groups ====================
45
+
46
+ this.group = params.group;
47
+ this.mouseGroup = params.mouseGroup;
48
+ var fiveElement = this.five.getElement();
49
+
50
+ if (fiveElement) {
51
+ fiveElement.addEventListener('touchstart', _ironbox.preventDefault);
52
+ fiveElement.addEventListener('contextmenu', _ironbox.preventDefault);
53
+ }
54
+ }
55
+
56
+ (0, _createClass2["default"])(BaseController, [{
57
+ key: "removeLine",
58
+ value: function removeLine(line) {
59
+ this.group.remove(line.mesh, line.lightMesh);
60
+ line.distanceItem.remove();
61
+ this.five.needsRender = true;
62
+ }
63
+ }, {
64
+ key: "updateMouseGroup",
65
+ value: function updateMouseGroup(intersection, mesh) {
66
+ if (!intersection) return this.mouseGroup; // ============ update mouseGroup position ============
67
+
68
+ var adsorbentPoint = this.fiveHelper.getAdsorbentPoint(intersection);
69
+ var viewPosition = adsorbentPoint ? adsorbentPoint : intersection.point;
70
+ this.mouseGroup.position.copy(viewPosition); // ============ update mouseGroup quaternion ============
71
+
72
+ if (mesh) {
73
+ this.mouseGroup.quaternion.copy(mesh.quaternion);
74
+ } else if (intersection.face) {
75
+ var normal = intersection.face.normal;
76
+ var positionVector = normal.clone().multiplyScalar(0.05);
77
+ var position = intersection.point.clone().add(positionVector);
78
+ var lookAtVector = position.clone().add(positionVector);
79
+ this.mouseGroup.lookAt(lookAtVector);
80
+ }
81
+
82
+ return this.mouseGroup;
83
+ }
84
+ }, {
85
+ key: "dispose",
86
+ value: function dispose() {
87
+ var _this2 = this;
88
+
89
+ this.disposed = true;
90
+ this.magnifier.dispose();
91
+ this.model.lines.forEach(function (line) {
92
+ return _this2.removeLine(line);
93
+ });
94
+ var fiveElement = this.five.getElement();
95
+
96
+ if (fiveElement) {
97
+ fiveElement.removeEventListener('touchstart', _ironbox.preventDefault);
98
+ fiveElement.removeEventListener('contextmenu', _ironbox.preventDefault);
99
+ }
100
+ }
101
+ }]);
102
+ return BaseController;
103
+ }();
104
+
105
+ exports["default"] = BaseController;
@@ -0,0 +1,52 @@
1
+ import { Model } from '../Model';
2
+ import Line from '../Model/line';
3
+ import { LineJson } from '../typings/data';
4
+ import BaseController, { IControllerParams } from './BaseController';
5
+ export interface EditEvent {
6
+ editedLineChange: (lines: LineJson[]) => void;
7
+ }
8
+ export default class EditController extends BaseController {
9
+ type: string;
10
+ model: Model;
11
+ private pressPoint?;
12
+ private hasAppendDashed;
13
+ private hasAppendMouseGroup;
14
+ private fiveElement?;
15
+ /** 上一个端点位置 */
16
+ private lastPoint;
17
+ /** 鼠标点到上一个端点连接的虚线 */
18
+ private dashed;
19
+ private hammer?;
20
+ /** 根据 intersection 更新放大镜和吸附点 */
21
+ private onIntersectionUpdate;
22
+ constructor(params: IControllerParams);
23
+ dispose(): void;
24
+ getEditingLines(): Line[];
25
+ /** 撤销编辑 */
26
+ revoke: () => void;
27
+ private onMouseLeave;
28
+ /** 编辑线条发生改变时通知外部 */
29
+ private onLineChanged;
30
+ private onPress;
31
+ /**
32
+ * 1. 如果之前没有长按行为「即没有长按点时」-> 滑动全景
33
+ * 2. 如果有长按点,把长按点位置更新为当前位置
34
+ */
35
+ private onPan;
36
+ private onPanEnd;
37
+ /**
38
+ * 1. 如果存在上一个点,需要绘制当前点到上一个点的连线
39
+ * 2. 把上一个点的位置更新为当前点的位置
40
+ * 3. 清除 mouseGroup 和 magnifier
41
+ */
42
+ private onTap;
43
+ private onWantsTapGesture;
44
+ /** 编辑时取消走点 */
45
+ private onWantsToMoveToPano;
46
+ /** 存在长按点时不能移动全景 */
47
+ private onWantsPanGesture;
48
+ /** 移动全景时更新 distanceItem 在屏幕上的位置 */
49
+ private onCameraUpdate;
50
+ /** 更新虚线 */
51
+ private updateDashed;
52
+ }
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.to-string.js");
4
+
5
+ require("core-js/modules/es.reflect.construct.js");
6
+
7
+ require("core-js/modules/es.object.define-property.js");
8
+
9
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
10
+
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ exports["default"] = void 0;
15
+
16
+ require("core-js/modules/es.array.map.js");
17
+
18
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
+
20
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
21
+
22
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
23
+
24
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
25
+
26
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
27
+
28
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
29
+
30
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
31
+
32
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
33
+
34
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
35
+
36
+ var _hammerjs = _interopRequireDefault(require("hammerjs"));
37
+
38
+ var _Model = require("../Model");
39
+
40
+ var _line = _interopRequireDefault(require("../Model/line"));
41
+
42
+ var _point = _interopRequireDefault(require("../Model/point"));
43
+
44
+ var _throttle = _interopRequireDefault(require("../../../shared-utils/throttle"));
45
+
46
+ var _BaseController2 = _interopRequireDefault(require("./BaseController"));
47
+
48
+ var _getIntersectionFromEvent = require("../utils/getIntersectionFromEvent");
49
+
50
+ 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); }; }
51
+
52
+ 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; } }
53
+
54
+ var EditController = /*#__PURE__*/function (_BaseController) {
55
+ (0, _inherits2["default"])(EditController, _BaseController);
56
+
57
+ var _super = _createSuper(EditController);
58
+
59
+ /** 上一个端点位置 */
60
+
61
+ /** 根据 intersection 更新放大镜和吸附点 */
62
+ function EditController(params) {
63
+ var _this$fiveElement;
64
+
65
+ var _this;
66
+
67
+ (0, _classCallCheck2["default"])(this, EditController);
68
+ _this = _super.call(this, params); // ==================== 虚线 ====================
69
+
70
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "type", 'edit');
71
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "model", new _Model.Model({
72
+ userDistanceItemCreator: _this.userDistanceItemCreator
73
+ }));
74
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hasAppendDashed", false);
75
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hasAppendMouseGroup", false);
76
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "lastPoint", null);
77
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onIntersectionUpdate", (0, _throttle["default"])(function (intersection, mesh) {
78
+ var _this$pressPoint;
79
+
80
+ if (_this.hasAppendMouseGroup === false) {
81
+ _this.group.add(_this.mouseGroup);
82
+
83
+ _this.magnifier.appendTo(_this.container);
84
+
85
+ _this.hasAppendMouseGroup = true;
86
+ }
87
+
88
+ var position = _this.updateMouseGroup(intersection, mesh).position;
89
+
90
+ (_this$pressPoint = _this.pressPoint) === null || _this$pressPoint === void 0 ? void 0 : _this$pressPoint.position.copy(position);
91
+
92
+ _this.updateDashed();
93
+
94
+ requestAnimationFrame(function () {
95
+ return _this.magnifier.updateWithPoint(_this.mouseGroup.position);
96
+ });
97
+ _this.five.needsRender = true;
98
+ }, 20));
99
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "revoke", function () {
100
+ // ============ revoke points ============
101
+ // 如果当前没有虚线,只有起始点,需要删除起始点,重置起始状态。并删除虚线实例
102
+ if (_this.model.lines.length === 0 && _this.lastPoint) {
103
+ _this.lastPoint = null;
104
+ _this.hasAppendDashed = false;
105
+
106
+ _this.dashed.distanceItem.remove();
107
+
108
+ _this.group.remove(_this.dashed.mesh);
109
+
110
+ _this.hook.emit('anchorChange', null);
111
+
112
+ _this.five.needsRender = true;
113
+ return;
114
+ }
115
+
116
+ if (_this.model.lines.length === 0 && !_this.lastPoint) return;
117
+ if (!_this.lastPoint) return;
118
+ var revokedLine = _this.model.lines[_this.model.lines.length - 1];
119
+ var lastPoint = revokedLine.findAnotherPoint(_this.lastPoint);
120
+ if (!lastPoint) return;
121
+ _this.lastPoint = lastPoint;
122
+
123
+ _this.hook.emit('anchorChange', lastPoint.position); // ============ revoke lines ============
124
+
125
+
126
+ _this.group.remove(revokedLine.mesh);
127
+
128
+ _this.model.removeLine(revokedLine); // ============ revoke mouse group ============
129
+
130
+
131
+ _this.hasAppendMouseGroup = false;
132
+
133
+ _this.mouseGroup.position.copy(_this.lastPoint.position);
134
+
135
+ _this.group.remove(_this.mouseGroup); // ============ revoke lineDistance ============
136
+
137
+
138
+ revokedLine.distanceItem.remove(); // ============ revoke dashed ============
139
+
140
+ _this.updateDashed(); // ============ revoke magnifier ============
141
+
142
+
143
+ _this.magnifier.dispose();
144
+
145
+ _this.five.needsRender = true;
146
+ });
147
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMouseLeave", function () {
148
+ _this.magnifier.dispose();
149
+
150
+ _this.group.remove(_this.mouseGroup);
151
+
152
+ _this.hasAppendMouseGroup = false;
153
+
154
+ if (_this.lastPoint) {
155
+ _this.mouseGroup.position.copy(_this.lastPoint.position);
156
+
157
+ _this.updateDashed();
158
+ }
159
+ });
160
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLineChanged", function () {
161
+ _this.hook.emit('editedLineChange', _this.model.lines.map(function (line) {
162
+ return line.toCompletelyJson();
163
+ }));
164
+ });
165
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPress", function (e) {
166
+ var _getIntersectionFromE = (0, _getIntersectionFromEvent.getIntersectionFromEvent)(_this.five, e),
167
+ _getIntersectionFromE2 = (0, _slicedToArray2["default"])(_getIntersectionFromE, 1),
168
+ intersection = _getIntersectionFromE2[0];
169
+
170
+ if (!intersection || !intersection.face) return;
171
+ var nowPoint = new _point["default"](intersection.point);
172
+ _this.pressPoint = nowPoint;
173
+
174
+ _this.onIntersectionUpdate(intersection);
175
+ });
176
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPan", function (e) {
177
+ if (!_this.pressPoint) return;
178
+
179
+ var _getIntersectionFromE3 = (0, _getIntersectionFromEvent.getIntersectionFromEvent)(_this.five, e),
180
+ _getIntersectionFromE4 = (0, _slicedToArray2["default"])(_getIntersectionFromE3, 1),
181
+ intersection = _getIntersectionFromE4[0];
182
+
183
+ if (!intersection || !intersection.face) return;
184
+
185
+ _this.onIntersectionUpdate(intersection);
186
+ });
187
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPanEnd", function (e) {
188
+ if (!_this.pressPoint) return;
189
+
190
+ _this.onTap(e);
191
+ });
192
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTap", function (e) {
193
+ if (!_this.hasAppendDashed) {
194
+ _this.dashed.distanceItem.appendTo(_this.container);
195
+
196
+ _this.group.add(_this.dashed.mesh);
197
+ }
198
+
199
+ _this.hasAppendDashed = true;
200
+
201
+ var _getIntersectionFromE5 = (0, _getIntersectionFromEvent.getIntersectionFromEvent)(_this.five, e),
202
+ _getIntersectionFromE6 = (0, _slicedToArray2["default"])(_getIntersectionFromE5, 1),
203
+ intersection = _getIntersectionFromE6[0];
204
+
205
+ _this.updateMouseGroup(intersection);
206
+
207
+ var nowPoint = new _point["default"](_this.mouseGroup.position);
208
+ var lastPoint = _this.lastPoint;
209
+ if (nowPoint) _this.lastPoint = nowPoint;
210
+
211
+ if (nowPoint && lastPoint) {
212
+ var line = new _line["default"](lastPoint, nowPoint, _this.model);
213
+ line.distanceItem.appendTo(_this.container);
214
+
215
+ _this.model.addLine(line);
216
+
217
+ _this.group.add(line.mesh);
218
+
219
+ line.distanceItem.update(_this.five);
220
+ }
221
+
222
+ _this.pressPoint = undefined;
223
+ _this.hasAppendMouseGroup = false;
224
+
225
+ _this.magnifier.dispose();
226
+
227
+ _this.group.remove(_this.mouseGroup);
228
+
229
+ _this.updateDashed();
230
+
231
+ _this.five.needsRender = true;
232
+
233
+ _this.hook.emit('anchorChange', nowPoint.position);
234
+ });
235
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onWantsTapGesture", function () {
236
+ return false;
237
+ });
238
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onWantsToMoveToPano", function () {
239
+ return false;
240
+ });
241
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onWantsPanGesture", function () {
242
+ return _this.pressPoint ? false : undefined;
243
+ });
244
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCameraUpdate", function () {
245
+ _this.updateDistanceUI();
246
+
247
+ _this.dashed.distanceItem.update(_this.five);
248
+ });
249
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateDashed", function () {
250
+ if (!_this.lastPoint) return;
251
+
252
+ _this.dashed.points[0].position.copy(_this.lastPoint.position);
253
+
254
+ _this.dashed.points[1].position.copy(_this.mouseGroup.position);
255
+
256
+ _this.dashed.mesh.setPoints(_this.lastPoint.position, _this.mouseGroup.position);
257
+
258
+ _this.dashed.distanceItem.update(_this.five);
259
+ });
260
+ _this.dashed = new _line["default"](new _point["default"]([0, 0, 0]), new _point["default"]([0, 0, 0]), _this.model);
261
+
262
+ _this.dashed.mesh.setMaterial({
263
+ dashed: true,
264
+ dashScale: 100
265
+ }); // ==================== 事件监听 ====================
266
+ // five
267
+
268
+
269
+ _this.five.on('cameraUpdate', _this.onCameraUpdate);
270
+
271
+ _this.five.on('wantsPanGesture', _this.onWantsPanGesture);
272
+
273
+ _this.five.on('wantsTapGesture', _this.onWantsTapGesture);
274
+
275
+ _this.five.on('wantsToMoveToPano', _this.onWantsToMoveToPano);
276
+
277
+ _this.five.on('intersectionOnModelUpdate', _this.onIntersectionUpdate); // model
278
+
279
+
280
+ _this.model.hook.on('lineAdded', _this.onLineChanged);
281
+
282
+ _this.model.hook.on('lineRemoved', _this.onLineChanged); // hammer
283
+
284
+
285
+ var fiveElement = _this.five.getElement();
286
+
287
+ if (fiveElement) {
288
+ _this.fiveElement = fiveElement;
289
+ var hammer = new _hammerjs["default"](fiveElement);
290
+ _this.hammer = hammer;
291
+ hammer.on('tap', _this.onTap);
292
+ hammer.on('pan', _this.onPan);
293
+ hammer.on('press', _this.onPress);
294
+ hammer.on('panend', _this.onPanEnd);
295
+ } // fiveElement
296
+
297
+
298
+ (_this$fiveElement = _this.fiveElement) === null || _this$fiveElement === void 0 ? void 0 : _this$fiveElement.addEventListener('mouseleave', _this.onMouseLeave); // ==================== 其他 ====================
299
+
300
+ _this.hook.emit('anchorChange', null);
301
+
302
+ _this.five.refresh();
303
+
304
+ return _this;
305
+ }
306
+
307
+ (0, _createClass2["default"])(EditController, [{
308
+ key: "dispose",
309
+ value: function dispose() {
310
+ var _this$hammer, _this$fiveElement2;
311
+
312
+ (0, _get2["default"])((0, _getPrototypeOf2["default"])(EditController.prototype), "dispose", this).call(this);
313
+ this.group.remove(this.mouseGroup, this.dashed.mesh); // ==================== 解除事件监听 ====================
314
+ // five
315
+
316
+ this.five.off('cameraUpdate', this.onCameraUpdate);
317
+ this.five.off('wantsPanGesture', this.onWantsPanGesture);
318
+ this.five.off('wantsTapGesture', this.onWantsTapGesture);
319
+ this.five.off('wantsToMoveToPano', this.onWantsToMoveToPano);
320
+ this.five.off('intersectionOnModelUpdate', this.onIntersectionUpdate); // model
321
+
322
+ this.model.hook.off('lineAdded', this.onLineChanged);
323
+ this.model.hook.off('lineRemoved', this.onLineChanged); // hammer
324
+
325
+ (_this$hammer = this.hammer) === null || _this$hammer === void 0 ? void 0 : _this$hammer.destroy(); // fiveElement
326
+
327
+ (_this$fiveElement2 = this.fiveElement) === null || _this$fiveElement2 === void 0 ? void 0 : _this$fiveElement2.removeEventListener('mouseleave', this.onMouseLeave);
328
+ this.magnifier.dispose();
329
+ this.dashed.distanceItem.remove();
330
+ this.five.needsRender = true;
331
+ }
332
+ }, {
333
+ key: "getEditingLines",
334
+ value: function getEditingLines() {
335
+ return this.model.lines;
336
+ }
337
+ /** 撤销编辑 */
338
+
339
+ }]);
340
+ return EditController;
341
+ }(_BaseController2["default"]);
342
+
343
+ exports["default"] = EditController;
@@ -0,0 +1,12 @@
1
+ import MeasureController from '.';
2
+ import { Five } from '@realsee/five';
3
+ /** 快捷键控制器 */
4
+ export declare class ShortcutKeyController {
5
+ five: Five;
6
+ measureController: MeasureController;
7
+ constructor(measureController: MeasureController, five: Five);
8
+ dispose(): void;
9
+ private escape;
10
+ private onKeyDown;
11
+ private onMouseDown;
12
+ }
@@ -0,0 +1,69 @@
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.ShortcutKeyController = void 0;
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+
18
+ /** 快捷键控制器 */
19
+ var ShortcutKeyController = /*#__PURE__*/function () {
20
+ function ShortcutKeyController(measureController, five) {
21
+ var _this = this;
22
+
23
+ (0, _classCallCheck2["default"])(this, ShortcutKeyController);
24
+ (0, _defineProperty2["default"])(this, "onKeyDown", function (e) {
25
+ // Command + S -> 保存 & 更改场景
26
+ if (e.metaKey && e.code === 'KeyS') {
27
+ _this.measureController.save().changeMode('Watch');
28
+
29
+ e.preventDefault();
30
+ return;
31
+ } // Escape -> 切换到观察模式 / 如果已经在观察模式,退出功能
32
+
33
+
34
+ if (e.code === 'Escape') return _this.escape();
35
+ });
36
+ (0, _defineProperty2["default"])(this, "onMouseDown", function (e) {
37
+ // 鼠标右键取消
38
+ if (e.button !== 2) return;
39
+ e.preventDefault();
40
+
41
+ _this.escape();
42
+ });
43
+ this.five = five;
44
+ this.measureController = measureController;
45
+ var fiveElement = this.five.getElement();
46
+ if (!fiveElement) return;
47
+ document.body.addEventListener('keydown', this.onKeyDown);
48
+ fiveElement.addEventListener('mousedown', this.onMouseDown);
49
+ }
50
+
51
+ (0, _createClass2["default"])(ShortcutKeyController, [{
52
+ key: "dispose",
53
+ value: function dispose() {
54
+ var fiveElement = this.five.getElement();
55
+ if (!fiveElement) return;
56
+ document.body.removeEventListener('keydown', this.onKeyDown);
57
+ fiveElement.removeEventListener('mousedown', this.onMouseDown);
58
+ }
59
+ }, {
60
+ key: "escape",
61
+ value: function escape() {
62
+ if (this.measureController.getCurrentMode() === 'Watch') return this.measureController.close();
63
+ return this.measureController.changeMode('Watch');
64
+ }
65
+ }]);
66
+ return ShortcutKeyController;
67
+ }();
68
+
69
+ exports.ShortcutKeyController = ShortcutKeyController;
@@ -0,0 +1,25 @@
1
+ import Line from '../Model/line';
2
+ import BaseController, { IControllerParams } from './BaseController';
3
+ export default class WatchController extends BaseController {
4
+ type: string;
5
+ private deleteDom;
6
+ private highlightedLines;
7
+ private fiveElement?;
8
+ private editPointState?;
9
+ private hammer?;
10
+ constructor(params: IControllerParams);
11
+ dispose(): void;
12
+ highlightLine(line: Line): void;
13
+ clearHighlightLines(): void;
14
+ private onPanStart;
15
+ private onPanEnd;
16
+ private onPan;
17
+ private onIntersectionUpdate;
18
+ private wantsPanGesture;
19
+ private wantsTapGesture;
20
+ private chooseLine;
21
+ private highlightLines;
22
+ private lineRemoved;
23
+ private onCameraUpdate;
24
+ private deleteDomClickCallback;
25
+ }