@realsee/dnalogel 0.1.7-alpha.1 → 0.1.7-alpha.10

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 (144) hide show
  1. package/components/GLTFView/index.d.ts +30 -1
  2. package/components/GLTFView/index.js +35 -3
  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.d.ts +95 -0
  7. package/data/_vLykj3NWrllMrG06.js +1 -0
  8. package/data/vLykj3NWrllMrG06.js +335 -71
  9. package/libs/gltf-viewer/coordsToDirection.d.ts +1 -1
  10. package/libs/gltf-viewer/index.d.ts +25 -3
  11. package/libs/gltf-viewer/index.js +169 -52
  12. package/package.json +3 -3
  13. package/plugins/CSS3DRenderPlugin/index.js +15 -10
  14. package/plugins/CSS3DRenderPlugin/utils/createResizeObserver.d.ts +7 -0
  15. package/plugins/CSS3DRenderPlugin/utils/createResizeObserver.js +34 -0
  16. package/plugins/ModelChassisCompassPlugin/index.d.ts +1 -1
  17. package/plugins/ModelChassisCompassPlugin/index.js +2 -1
  18. package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +4 -0
  19. package/plugins/ModelEntryDoorGuidePlugin/index.js +13 -7
  20. package/plugins/ModelRoomLabelPlugin/Controller.js +1 -0
  21. package/plugins/ModelRoomLabelPlugin/RoomLabelItem.js +5 -5
  22. package/plugins/ModelRoomLabelPlugin/index.d.ts +4 -0
  23. package/plugins/ModelRoomLabelPlugin/index.js +7 -2
  24. package/plugins/PanoMaskSelectorPlugin/fragmentShader.d.ts +1 -1
  25. package/plugins/PanoMaskSelectorPlugin/fragmentShader.js +1 -1
  26. package/plugins/PanoMeasurePlugin/Controller/BaseController.d.ts +36 -0
  27. package/plugins/PanoMeasurePlugin/Controller/BaseController.js +103 -0
  28. package/plugins/PanoMeasurePlugin/Controller/EditController.d.ts +52 -0
  29. package/plugins/PanoMeasurePlugin/Controller/EditController.js +341 -0
  30. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.d.ts +12 -0
  31. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.js +69 -0
  32. package/plugins/PanoMeasurePlugin/Controller/WatchController.d.ts +25 -0
  33. package/plugins/PanoMeasurePlugin/Controller/WatchController.js +371 -0
  34. package/plugins/PanoMeasurePlugin/Controller/index.d.ts +61 -0
  35. package/plugins/PanoMeasurePlugin/Controller/index.js +230 -0
  36. package/plugins/PanoMeasurePlugin/Model/index.d.ts +38 -0
  37. package/plugins/PanoMeasurePlugin/Model/index.js +235 -0
  38. package/plugins/PanoMeasurePlugin/Model/line.d.ts +30 -0
  39. package/plugins/PanoMeasurePlugin/Model/line.js +121 -0
  40. package/plugins/PanoMeasurePlugin/Model/point.d.ts +16 -0
  41. package/plugins/PanoMeasurePlugin/Model/point.js +68 -0
  42. package/plugins/PanoMeasurePlugin/Model/polyline.d.ts +16 -0
  43. package/plugins/PanoMeasurePlugin/Model/polyline.js +109 -0
  44. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.d.ts +2 -0
  45. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.js +11 -0
  46. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.d.ts +2 -0
  47. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.js +11 -0
  48. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.d.ts +2 -0
  49. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.js +11 -0
  50. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.d.ts +22 -0
  51. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.js +182 -0
  52. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.d.ts +11 -0
  53. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.js +66 -0
  54. package/plugins/PanoMeasurePlugin/Modules/GuideController.d.ts +18 -0
  55. package/plugins/PanoMeasurePlugin/Modules/GuideController.js +107 -0
  56. package/plugins/PanoMeasurePlugin/Modules/Magnifier.d.ts +24 -0
  57. package/plugins/PanoMeasurePlugin/Modules/Magnifier.js +139 -0
  58. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.d.ts +6 -0
  59. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.js +26 -0
  60. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +18 -0
  61. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +169 -0
  62. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.d.ts +12 -0
  63. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +59 -0
  64. package/plugins/PanoMeasurePlugin/Modules/UIController/index.d.ts +16 -0
  65. package/plugins/PanoMeasurePlugin/Modules/UIController/index.js +123 -0
  66. package/plugins/PanoMeasurePlugin/Modules/UIController/style.d.ts +17 -0
  67. package/plugins/PanoMeasurePlugin/Modules/UIController/style.js +103 -0
  68. package/plugins/PanoMeasurePlugin/index.d.ts +7 -0
  69. package/plugins/PanoMeasurePlugin/index.js +20 -0
  70. package/plugins/PanoMeasurePlugin/typings/data.d.ts +28 -0
  71. package/plugins/PanoMeasurePlugin/typings/data.js +7 -0
  72. package/plugins/PanoMeasurePlugin/typings/event.type.d.ts +28 -0
  73. package/plugins/PanoMeasurePlugin/typings/event.type.js +7 -0
  74. package/plugins/PanoMeasurePlugin/typings/utils.type.d.ts +1 -0
  75. package/plugins/PanoMeasurePlugin/typings/utils.type.js +7 -0
  76. package/plugins/PanoMeasurePlugin/utils/clearGroup.d.ts +2 -0
  77. package/plugins/PanoMeasurePlugin/utils/clearGroup.js +16 -0
  78. package/plugins/PanoMeasurePlugin/utils/constants.d.ts +4 -0
  79. package/plugins/PanoMeasurePlugin/utils/constants.js +47 -0
  80. package/plugins/PanoMeasurePlugin/utils/distanceDom.d.ts +28 -0
  81. package/plugins/PanoMeasurePlugin/utils/distanceDom.js +147 -0
  82. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.d.ts +2 -0
  83. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.js +37 -0
  84. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.d.ts +10 -0
  85. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.js +49 -0
  86. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.d.ts +4 -0
  87. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.js +20 -0
  88. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.d.ts +10 -0
  89. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.js +33 -0
  90. package/plugins/PanoMeasurePlugin/utils/ironbox.d.ts +1 -0
  91. package/plugins/PanoMeasurePlugin/utils/ironbox.js +14 -0
  92. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.d.ts +2 -0
  93. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.js +16 -0
  94. package/plugins/PanoMeasurePlugin/utils/line.d.ts +17 -0
  95. package/plugins/PanoMeasurePlugin/utils/line.js +61 -0
  96. package/plugins/PanoMeasurePlugin/utils/math.d.ts +17 -0
  97. package/plugins/PanoMeasurePlugin/utils/math.js +57 -0
  98. package/plugins/PanoMeasurePlugin/utils/mouseGroup.d.ts +2 -0
  99. package/plugins/PanoMeasurePlugin/utils/mouseGroup.js +42 -0
  100. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.d.ts +5 -0
  101. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.js +16 -0
  102. package/plugins/PanoRulerPlugin/index.d.ts +4 -0
  103. package/plugins/PanoRulerPlugin/index.js +6 -1
  104. package/plugins/floorplan/Assets/floorplanExtraObject.d.ts +1 -1
  105. package/plugins/floorplan/Assets/floorplanExtraObject.js +3 -3
  106. package/plugins/floorplan/ModelFloorplanPlugin/Controller.d.ts +5 -2
  107. package/plugins/floorplan/ModelFloorplanPlugin/Controller.js +22 -11
  108. package/plugins/floorplan/ModelFloorplanPlugin/components/Camera.js +4 -4
  109. package/plugins/floorplan/ModelFloorplanPlugin/components/Compass.js +5 -5
  110. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomLabels.js +2 -2
  111. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.d.ts +11 -0
  112. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.js +174 -0
  113. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.d.ts +8 -0
  114. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.js +178 -0
  115. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.d.ts +2 -0
  116. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.js +14 -2
  117. package/plugins/floorplan/ModelFloorplanPlugin/components/index.d.ts +3 -0
  118. package/plugins/floorplan/ModelFloorplanPlugin/components/index.js +1 -1
  119. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.d.ts +2 -0
  120. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.js +7 -0
  121. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.d.ts +1 -1
  122. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.js +1 -1
  123. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.js +1 -0
  124. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.style.js +4 -4
  125. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/ExtraObjects.js +2 -2
  126. package/plugins/floorplan/PanoFloorplanRadarPlugin/Controller.d.ts +1 -1
  127. package/plugins/floorplan/PanoFloorplanRadarPlugin/Controller.js +3 -3
  128. package/plugins/floorplan/TopviewFloorplanPlugin/Controller.d.ts +3 -0
  129. package/plugins/floorplan/TopviewFloorplanPlugin/Controller.js +16 -6
  130. package/plugins/floorplan/index.d.ts +4 -0
  131. package/plugins/floorplan/index.js +13 -0
  132. package/plugins/floorplan/typings/floorplanData.d.ts +2 -0
  133. package/plugins/floorplan/typings/floorplanServerData.d.ts +3 -1
  134. package/plugins/floorplan/typings/floorplanServerData.js +3 -3
  135. package/plugins/floorplan/utils/formatData.js +3 -2
  136. package/shared-utils/changeModelCanvasOpacity.d.ts +2 -0
  137. package/shared-utils/{changeModelCanvansOpacity.js → changeModelCanvasOpacity.js} +2 -2
  138. package/shared-utils/math/evenNumber.d.ts +3 -1
  139. package/shared-utils/math/evenNumber.js +4 -2
  140. package/shared-utils/removeArrayItem.d.ts +7 -0
  141. package/shared-utils/removeArrayItem.js +22 -0
  142. package/shared-utils/three/loadTexture.d.ts +2 -2
  143. package/shared-utils/three/loadTexture.js +21 -2
  144. package/shared-utils/changeModelCanvansOpacity.d.ts +0 -2
@@ -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;
@@ -0,0 +1,38 @@
1
+ import Line from './line';
2
+ import Point from './point';
3
+ import { Subscribe, SubscribeEventMap } from '@realsee/five';
4
+ import { PluginData } from '../typings/data';
5
+ import { Polyline } from './polyline';
6
+ import { UserDistanceItem } from '../utils/distanceDom';
7
+ interface IModelEvent extends SubscribeEventMap {
8
+ /** 新增线条
9
+ * @param line 被创建的线条
10
+ */
11
+ lineAdded: (line: Line) => void;
12
+ /** 删除线条
13
+ * @param lines 被删除的线条数组
14
+ */
15
+ lineRemoved: (lines: Line) => void;
16
+ }
17
+ export interface ModelParams {
18
+ userDistanceItemCreator?: () => UserDistanceItem;
19
+ }
20
+ export declare class Model {
21
+ readonly lines: Line[];
22
+ readonly points: Point[];
23
+ readonly params: ModelParams;
24
+ readonly polylines: Polyline[];
25
+ readonly hook: Subscribe<IModelEvent>;
26
+ constructor(params: ModelParams);
27
+ addLine(line: Line): this | undefined;
28
+ removeLineByID(lineID: string): void;
29
+ removeLine(line: Line): this;
30
+ mergeModel(model: Model): void;
31
+ includes(item: Point | Line): boolean | undefined;
32
+ getPointByID(id: string): Point | undefined;
33
+ getLineByID(id: string): Line | undefined;
34
+ getClosestPoint(): void;
35
+ parse(data: PluginData): this;
36
+ toJson(): PluginData;
37
+ }
38
+ export {};
@@ -0,0 +1,235 @@
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.Model = void 0;
11
+
12
+ require("core-js/modules/es.array.includes.js");
13
+
14
+ require("core-js/modules/es.string.includes.js");
15
+
16
+ require("core-js/modules/es.array.find.js");
17
+
18
+ require("core-js/modules/es.array.slice.js");
19
+
20
+ require("core-js/modules/es.array.for-each.js");
21
+
22
+ require("core-js/modules/web.dom-collections.for-each.js");
23
+
24
+ require("core-js/modules/es.array.map.js");
25
+
26
+ require("core-js/modules/es.array.splice.js");
27
+
28
+ require("core-js/modules/es.array.concat.js");
29
+
30
+ require("core-js/modules/es.array.filter.js");
31
+
32
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
33
+
34
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
35
+
36
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
37
+
38
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
39
+
40
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
41
+
42
+ var _line = _interopRequireDefault(require("./line"));
43
+
44
+ var _point = _interopRequireDefault(require("./point"));
45
+
46
+ var _five = require("@realsee/five");
47
+
48
+ var _removeArrayItem = _interopRequireDefault(require("../../../shared-utils/removeArrayItem"));
49
+
50
+ var _polyline = require("./polyline");
51
+
52
+ var Model = /*#__PURE__*/function () {
53
+ function Model(params) {
54
+ (0, _classCallCheck2["default"])(this, Model);
55
+ (0, _defineProperty2["default"])(this, "lines", []);
56
+ (0, _defineProperty2["default"])(this, "points", []);
57
+ (0, _defineProperty2["default"])(this, "polylines", []);
58
+ (0, _defineProperty2["default"])(this, "hook", new _five.Subscribe());
59
+ this.params = params;
60
+ }
61
+
62
+ (0, _createClass2["default"])(Model, [{
63
+ key: "addLine",
64
+ value: function addLine(line) {
65
+ var _line$points = (0, _slicedToArray2["default"])(line.points, 2),
66
+ startPoint = _line$points[0],
67
+ endPoint = _line$points[1];
68
+
69
+ if (!startPoint || !endPoint) return this;
70
+ if (!this.includes(startPoint)) this.points.push(startPoint);
71
+ if (!this.includes(endPoint)) this.points.push(endPoint);
72
+ this.lines.push(line);
73
+ var lastPolyline = this.polylines.find(function (polyline) {
74
+ return !!polyline.getNext(line);
75
+ });
76
+
77
+ if (lastPolyline) {
78
+ lastPolyline.push(line);
79
+ } else {
80
+ var polyline = new _polyline.Polyline();
81
+ polyline.push(line);
82
+ this.polylines.push(polyline);
83
+ }
84
+
85
+ this.hook.emit('lineAdded', line);
86
+ }
87
+ }, {
88
+ key: "removeLineByID",
89
+ value: function removeLineByID(lineID) {
90
+ var line = this.getLineByID(lineID);
91
+ if (line) this.removeLine(line);
92
+ }
93
+ }, {
94
+ key: "removeLine",
95
+ value: function removeLine(line) {
96
+ // handle polyline
97
+ var polyline = this.polylines.find(function (polyline) {
98
+ return polyline.lines.includes(line);
99
+ });
100
+
101
+ if (polyline) {
102
+ if (polyline.lines.slice(-1)[0] !== line) throw new Error('不能从中间删除线段');
103
+ polyline.pop();
104
+ if (polyline.lines.length === 0) (0, _removeArrayItem["default"])(polyline, this.polylines);
105
+ }
106
+
107
+ var _line$points2 = (0, _slicedToArray2["default"])(line.points, 2),
108
+ point = _line$points2[0],
109
+ anotherPoint = _line$points2[1];
110
+
111
+ if (point.lines.length === 0) (0, _removeArrayItem["default"])(point, this.points);
112
+ if (anotherPoint.lines.length === 0) (0, _removeArrayItem["default"])(anotherPoint, this.points);
113
+ (0, _removeArrayItem["default"])(line, this.lines);
114
+ line.clear();
115
+ this.hook.emit('lineRemoved', line);
116
+ return this;
117
+ }
118
+ }, {
119
+ key: "mergeModel",
120
+ value: function mergeModel(model) {
121
+ var _this = this;
122
+
123
+ model.lines.forEach(function (line) {
124
+ return _this.addLine(line);
125
+ });
126
+ }
127
+ }, {
128
+ key: "includes",
129
+ value: function includes(item) {
130
+ if (item.type === 'point') {
131
+ return this.points.find(function (_ref) {
132
+ var id = _ref.id;
133
+ return id === item.id;
134
+ }) !== undefined;
135
+ } else if (item.type === 'line') {
136
+ return this.lines.find(function (_ref2) {
137
+ var id = _ref2.id;
138
+ return id === item.id;
139
+ }) !== undefined;
140
+ }
141
+ }
142
+ }, {
143
+ key: "getPointByID",
144
+ value: function getPointByID(id) {
145
+ return this.points.find(function (_ref3) {
146
+ var _id = _ref3.id;
147
+ return _id === id;
148
+ });
149
+ }
150
+ }, {
151
+ key: "getLineByID",
152
+ value: function getLineByID(id) {
153
+ return this.lines.find(function (_ref4) {
154
+ var _id = _ref4.id;
155
+ return _id === id;
156
+ });
157
+ }
158
+ }, {
159
+ key: "getClosestPoint",
160
+ value: function getClosestPoint() {}
161
+ }, {
162
+ key: "parse",
163
+ value: function parse(data) {
164
+ var _this2 = this,
165
+ _this$points,
166
+ _this$lines,
167
+ _this$polylines;
168
+
169
+ var points = data.points.map(function (_ref5) {
170
+ var id = _ref5.id,
171
+ position = _ref5.position;
172
+ var point = new _point["default"](position);
173
+ point.id = id;
174
+ return point;
175
+ });
176
+ var lines = data.lines.map(function (data) {
177
+ var _data$points = (0, _slicedToArray2["default"])(data.points, 2),
178
+ pointID = _data$points[0],
179
+ anotherPointID = _data$points[1];
180
+
181
+ var point = _this2.getPointByID.call({
182
+ points: points
183
+ }, pointID);
184
+
185
+ var anotherPoint = _this2.getPointByID.call({
186
+ points: points
187
+ }, anotherPointID);
188
+
189
+ if (!point || !anotherPoint) throw new Error('线上的点不存在');
190
+ var line = new _line["default"](point, anotherPoint, _this2);
191
+ line.id = data.id;
192
+ return line;
193
+ });
194
+ var polylines = data.polylines.map(function (polylineJson) {
195
+ var polyline = new _polyline.Polyline();
196
+ polylineJson.lines.forEach(function (lineID) {
197
+ var line = lines.find(function (_ref6) {
198
+ var id = _ref6.id;
199
+ return id === lineID;
200
+ });
201
+ line && polyline.push(line);
202
+ });
203
+ return polyline;
204
+ });
205
+
206
+ (_this$points = this.points).splice.apply(_this$points, [0, this.points.length].concat((0, _toConsumableArray2["default"])(points)));
207
+
208
+ (_this$lines = this.lines).splice.apply(_this$lines, [0, this.lines.length].concat((0, _toConsumableArray2["default"])(lines)));
209
+
210
+ (_this$polylines = this.polylines).splice.apply(_this$polylines, [0, this.polylines.length].concat((0, _toConsumableArray2["default"])(polylines)));
211
+
212
+ return this;
213
+ }
214
+ }, {
215
+ key: "toJson",
216
+ value: function toJson() {
217
+ return {
218
+ points: this.points.map(function (point) {
219
+ return point.toJson();
220
+ }),
221
+ lines: this.lines.map(function (line) {
222
+ return line.toJson();
223
+ }),
224
+ polylines: this.polylines.map(function (polyline) {
225
+ return polyline.toJson();
226
+ }).filter(function (polylines) {
227
+ return polylines.lines.length > 0;
228
+ })
229
+ };
230
+ }
231
+ }]);
232
+ return Model;
233
+ }();
234
+
235
+ exports.Model = Model;
@@ -0,0 +1,30 @@
1
+ import { Model } from '.';
2
+ import Point from './point';
3
+ import { LineJson } from '..';
4
+ import { Polyline } from './polyline';
5
+ import { LineCompletelyJson } from '../typings/data';
6
+ import { Line as FiveLine } from '@realsee/five/line';
7
+ import { Subscribe, SubscribeEventMap } from '@realsee/five';
8
+ import { DistanceItem } from '../utils/distanceDom';
9
+ export interface ILineHook extends SubscribeEventMap {
10
+ selected: (line: Line) => void;
11
+ }
12
+ export default class Line {
13
+ id: string;
14
+ selected: boolean;
15
+ readonly type = "line";
16
+ readonly model: Model;
17
+ readonly mesh: FiveLine;
18
+ readonly points: Point[];
19
+ readonly lightMesh: FiveLine;
20
+ readonly hook: Subscribe<ILineHook>;
21
+ readonly distanceItem: DistanceItem;
22
+ private polyline?;
23
+ constructor(point: Point, anotherPoint: Point, model: Model);
24
+ clear(): void;
25
+ getPolyline(): Polyline;
26
+ findAnotherPoint(point: Point): Point | undefined;
27
+ toJson(): LineJson;
28
+ toCompletelyJson(): LineCompletelyJson;
29
+ clone(): Line;
30
+ }
@@ -0,0 +1,121 @@
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.find.js");
13
+
14
+ require("core-js/modules/es.array.includes.js");
15
+
16
+ require("core-js/modules/es.string.includes.js");
17
+
18
+ require("core-js/modules/es.array.map.js");
19
+
20
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
21
+
22
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
23
+
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
+
26
+ var _polyline = require("./polyline");
27
+
28
+ var _uuid = _interopRequireDefault(require("../../../shared-utils/uuid"));
29
+
30
+ var _line = require("../utils/line");
31
+
32
+ var _five = require("@realsee/five");
33
+
34
+ var _distanceDom = require("../utils/distanceDom");
35
+
36
+ var Line = /*#__PURE__*/function () {
37
+ function Line(point, anotherPoint, model) {
38
+ var _this = this;
39
+
40
+ (0, _classCallCheck2["default"])(this, Line);
41
+ (0, _defineProperty2["default"])(this, "selected", false);
42
+ (0, _defineProperty2["default"])(this, "type", 'line');
43
+ this.id = (0, _uuid["default"])();
44
+ this.model = model;
45
+ if (point.id === anotherPoint.id) throw new Error('无效的线段, 一个点无法构成线段');
46
+ this.hook = new _five.Subscribe();
47
+ this.points = [point, anotherPoint];
48
+ this.mesh = (0, _line.creatLineMesh)(this, 'normal');
49
+ this.lightMesh = (0, _line.creatLineMesh)(this, 'light');
50
+ this.distanceItem = (0, _distanceDom.creatDistanceItem)({
51
+ line: this,
52
+ clickCallback: function clickCallback() {
53
+ return _this.hook.emit('selected', _this);
54
+ },
55
+ userDistanceItem: this.model.params.userDistanceItemCreator ? this.model.params.userDistanceItemCreator() : undefined
56
+ });
57
+ point.lines.push(this);
58
+ anotherPoint.lines.push(this);
59
+ }
60
+
61
+ (0, _createClass2["default"])(Line, [{
62
+ key: "clear",
63
+ value: function clear() {
64
+ this.selected = false;
65
+ this.polyline = undefined;
66
+ }
67
+ }, {
68
+ key: "getPolyline",
69
+ value: function getPolyline() {
70
+ var _this2 = this;
71
+
72
+ if (this.polyline) return this.polyline;
73
+ var modelPolyline = this.model.polylines.find(function (polyline) {
74
+ return polyline.lines.includes(_this2);
75
+ });
76
+ this.polyline = modelPolyline;
77
+ if (modelPolyline) return modelPolyline;
78
+ var polyline = new _polyline.Polyline();
79
+ polyline.push(this);
80
+ return polyline;
81
+ }
82
+ }, {
83
+ key: "findAnotherPoint",
84
+ value: function findAnotherPoint(point) {
85
+ return this.points.find(function (_ref) {
86
+ var id = _ref.id;
87
+ return id !== point.id;
88
+ });
89
+ }
90
+ }, {
91
+ key: "toJson",
92
+ value: function toJson() {
93
+ return {
94
+ id: this.id,
95
+ points: this.points.map(function (_ref2) {
96
+ var id = _ref2.id;
97
+ return id;
98
+ })
99
+ };
100
+ }
101
+ }, {
102
+ key: "toCompletelyJson",
103
+ value: function toCompletelyJson() {
104
+ return {
105
+ id: this.id,
106
+ points: this.points.map(function (point) {
107
+ return point.toJson();
108
+ })
109
+ };
110
+ }
111
+ }, {
112
+ key: "clone",
113
+ value: function clone() {
114
+ var line = new Line(this.points[0].clone(), this.points[1].clone(), this.model);
115
+ return line;
116
+ }
117
+ }]);
118
+ return Line;
119
+ }();
120
+
121
+ exports["default"] = Line;
@@ -0,0 +1,16 @@
1
+ import Line from './line';
2
+ import { Vector3 } from 'three';
3
+ import { PluginData } from '../typings/data';
4
+ declare type IPointData = PluginData['points'][0];
5
+ export default class Point {
6
+ id: string;
7
+ lines: Line[];
8
+ position: Vector3;
9
+ readonly type = "point";
10
+ constructor(position: Vector3 | number[]);
11
+ toJson(): IPointData;
12
+ addLine(line: Line): void;
13
+ removeLine(line: Line): void;
14
+ clone(): Point;
15
+ }
16
+ export {};