@labelbee/lb-annotation 1.13.0 → 1.13.1
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.
- package/dist/core/pointCloud/index.js +2 -2
- package/dist/types/core/pointCloud/index.d.ts +8 -3
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
- package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +3 -0
- package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +3 -0
- package/es/assets/attributeIcon/icon_cuboidMore.svg.js +3 -0
- package/es/assets/attributeIcon/icon_cuboidRight.svg.js +3 -0
- package/es/assets/attributeIcon/icon_cuboidTop.svg.js +3 -0
- package/es/core/pointCloud/index.js +2 -2
- package/es/core/pointCloud/render/index.js +131 -0
- package/es/core/pointCloud/segmentation.js +95 -0
- package/es/core/pointCloud/selector/Sse3dLassoSelector.js +23 -0
- package/es/core/pointCloud/selector/Sse3dSelector.js +15 -0
- package/es/core/pointCloud/selector/circleSelector.js +39 -0
- package/es/core/pointCloud/selector/lassoSelector.js +22 -0
- package/es/core/pointCloud/selector/selector.js +16 -0
- package/es/core/pointCloud/store/fsm.js +41 -0
- package/es/core/pointCloud/store/index.js +376 -0
- package/es/core/toolOperation/Selection.js +101 -0
- package/es/core/toolOperation/cuboidOperation.js +752 -0
- package/es/core/toolOperation/cuboidToggleButtonClass.js +174 -0
- package/es/core/toolOperation/scribbleTool2.js +249 -0
- package/es/utils/tool/CuboidUtils.js +680 -0
- package/package.json +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import DefaultSelector from './selector.js';
|
|
2
|
+
|
|
3
|
+
class LassoSelector extends DefaultSelector {
|
|
4
|
+
mouseDown(ev) {
|
|
5
|
+
if (ev.button === 2) {
|
|
6
|
+
this.pushPoint(ev.offsetX, ev.offsetY);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
mouseUp(ev) {
|
|
10
|
+
if (ev.button === 2) {
|
|
11
|
+
this.store.getPointsInPolygon(this.polygon2d);
|
|
12
|
+
this.updatePolygon2d([]);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
mouseMove(ev) {
|
|
16
|
+
if (ev.button === 2) {
|
|
17
|
+
this.pushPoint(ev.offsetX, ev.offsetY);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { LassoSelector as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class DefaultSelector {
|
|
2
|
+
constructor(store) {
|
|
3
|
+
this.store = store;
|
|
4
|
+
this.polygon2d = [];
|
|
5
|
+
}
|
|
6
|
+
pushPoint(x, y) {
|
|
7
|
+
this.polygon2d.push({x, y});
|
|
8
|
+
this.store.syncPolygon2d(this.polygon2d);
|
|
9
|
+
}
|
|
10
|
+
updatePolygon2d(polygon2d) {
|
|
11
|
+
this.polygon2d = polygon2d;
|
|
12
|
+
this.store.syncPolygon2d(this.polygon2d);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { DefaultSelector as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EPointCloudSegmentStatus } from '@labelbee/lb-utils';
|
|
2
|
+
|
|
3
|
+
class PointCloudFSM {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.segmentStatus = EPointCloudSegmentStatus.Ready;
|
|
6
|
+
}
|
|
7
|
+
statusToggle() {
|
|
8
|
+
switch (this.segmentStatus) {
|
|
9
|
+
case EPointCloudSegmentStatus.Ready:
|
|
10
|
+
this.segmentStatus = EPointCloudSegmentStatus.Check;
|
|
11
|
+
break;
|
|
12
|
+
case EPointCloudSegmentStatus.Check:
|
|
13
|
+
this.segmentStatus = EPointCloudSegmentStatus.Edit;
|
|
14
|
+
break;
|
|
15
|
+
case EPointCloudSegmentStatus.Edit:
|
|
16
|
+
this.segmentStatus = EPointCloudSegmentStatus.Ready;
|
|
17
|
+
break;
|
|
18
|
+
default: {
|
|
19
|
+
console.error("Error Status in PointCloudSegmentFSM");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
updateStatus2Edit() {
|
|
24
|
+
this.segmentStatus = EPointCloudSegmentStatus.Edit;
|
|
25
|
+
}
|
|
26
|
+
updateStatus2Check() {
|
|
27
|
+
this.segmentStatus = EPointCloudSegmentStatus.Check;
|
|
28
|
+
}
|
|
29
|
+
get isReadyStatus() {
|
|
30
|
+
return this.segmentStatus === EPointCloudSegmentStatus.Ready;
|
|
31
|
+
}
|
|
32
|
+
get isCheckStatus() {
|
|
33
|
+
return this.segmentStatus === EPointCloudSegmentStatus.Check;
|
|
34
|
+
}
|
|
35
|
+
get isEditStatus() {
|
|
36
|
+
return this.segmentStatus === EPointCloudSegmentStatus.Edit;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const instance = new PointCloudFSM();
|
|
40
|
+
|
|
41
|
+
export { instance as default };
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { EPointCloudSegmentMode, EPointCloudSegmentCoverMode, PointCloudUtils } from '@labelbee/lb-utils';
|
|
3
|
+
import { isInPolygon } from '../../../utils/tool/polygonTool.js';
|
|
4
|
+
import uuid from '../../../utils/uuid.js';
|
|
5
|
+
import instance from './fsm.js';
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defProps = Object.defineProperties;
|
|
9
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
14
|
+
var __spreadValues = (a, b) => {
|
|
15
|
+
for (var prop in b || (b = {}))
|
|
16
|
+
if (__hasOwnProp.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
if (__getOwnPropSymbols)
|
|
19
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
+
if (__propIsEnum.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
+
const DEFAULT_PREFIX = "LABELBEE_CANVAS_";
|
|
27
|
+
class PointCloudStore {
|
|
28
|
+
constructor({container, scene, camera, renderer, emit, on, unbind}) {
|
|
29
|
+
this.canvas2d = null;
|
|
30
|
+
this.polygon2d = [];
|
|
31
|
+
this.forbidOperation = false;
|
|
32
|
+
this.raycaster = new THREE.Raycaster();
|
|
33
|
+
this.mouse = new THREE.Vector2();
|
|
34
|
+
this.cloudData = new Map();
|
|
35
|
+
this.segmentData = new Map();
|
|
36
|
+
this.hoverPointsID = "";
|
|
37
|
+
this.segmentMode = EPointCloudSegmentMode.Add;
|
|
38
|
+
this.segmentCoverMode = EPointCloudSegmentCoverMode.Cover;
|
|
39
|
+
this.updatePointCloud = false;
|
|
40
|
+
this.addPointCloud = false;
|
|
41
|
+
this.orbiting = false;
|
|
42
|
+
this.currentAttribute = "";
|
|
43
|
+
this.pointCloudObjectName = "pointCloud";
|
|
44
|
+
this.updateCoverPoints = (coverPoints = new Float32Array([])) => {
|
|
45
|
+
this.segmentData.forEach((seg, id) => {
|
|
46
|
+
var _a;
|
|
47
|
+
if (id !== ((_a = this.cacheSegData) == null ? void 0 : _a.id)) {
|
|
48
|
+
const newPoints = this.splitPointsFromPoints(seg.points, coverPoints);
|
|
49
|
+
seg.points = newPoints;
|
|
50
|
+
const originPoints = this.scene.getObjectByName(id);
|
|
51
|
+
if (originPoints) {
|
|
52
|
+
originPoints.geometry.setAttribute("position", new THREE.Float32BufferAttribute(newPoints, 3));
|
|
53
|
+
originPoints.geometry.attributes.position.needsUpdate = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
this.emit("reRender3d");
|
|
58
|
+
};
|
|
59
|
+
this.container = container;
|
|
60
|
+
this.scene = scene;
|
|
61
|
+
this.camera = camera;
|
|
62
|
+
this.renderer = renderer;
|
|
63
|
+
this.emit = emit;
|
|
64
|
+
this.on = on;
|
|
65
|
+
this.unbind = unbind;
|
|
66
|
+
this.createCanvas2d();
|
|
67
|
+
this.clearStash = this.clearStash.bind(this);
|
|
68
|
+
this.addStash2Store = this.addStash2Store.bind(this);
|
|
69
|
+
this.updateCheck2Edit = this.updateCheck2Edit.bind(this);
|
|
70
|
+
this.setAttribute = this.setAttribute.bind(this);
|
|
71
|
+
this.setSegmentMode = this.setSegmentMode.bind(this);
|
|
72
|
+
this.setSegmentCoverMode = this.setSegmentCoverMode.bind(this);
|
|
73
|
+
this.initMsg();
|
|
74
|
+
this.setupRaycaster();
|
|
75
|
+
}
|
|
76
|
+
initMsg() {
|
|
77
|
+
this.on("clearStash", this.clearStash);
|
|
78
|
+
this.on("addStash2Store", this.addStash2Store);
|
|
79
|
+
this.on("updateCheck2Edit", this.updateCheck2Edit);
|
|
80
|
+
this.on("setSegmentMode", this.setSegmentMode);
|
|
81
|
+
this.on("setSegmentCoverMode", this.setSegmentCoverMode);
|
|
82
|
+
}
|
|
83
|
+
unbindMsg() {
|
|
84
|
+
this.unbind("clearStash", this.clearStash);
|
|
85
|
+
this.unbind("addStash2Store", this.addStash2Store);
|
|
86
|
+
this.unbind("updateCheck2Edit", this.updateCheck2Edit);
|
|
87
|
+
this.unbind("setSegmentMode", this.setSegmentMode);
|
|
88
|
+
this.unbind("setSegmentCoverMode", this.setSegmentCoverMode);
|
|
89
|
+
}
|
|
90
|
+
get containerWidth() {
|
|
91
|
+
return this.container.clientWidth;
|
|
92
|
+
}
|
|
93
|
+
get containerHeight() {
|
|
94
|
+
return this.container.clientHeight;
|
|
95
|
+
}
|
|
96
|
+
get allSegmentPoints() {
|
|
97
|
+
return this.scene.children.filter((v) => v.type === "Points" && v.name !== this.pointCloudObjectName);
|
|
98
|
+
}
|
|
99
|
+
get segmentStatus() {
|
|
100
|
+
return instance.segmentStatus;
|
|
101
|
+
}
|
|
102
|
+
get isReadyStatus() {
|
|
103
|
+
return instance.isReadyStatus;
|
|
104
|
+
}
|
|
105
|
+
get isCheckStatus() {
|
|
106
|
+
return instance.isCheckStatus;
|
|
107
|
+
}
|
|
108
|
+
get isEditStatus() {
|
|
109
|
+
return instance.isEditStatus;
|
|
110
|
+
}
|
|
111
|
+
statusToggle() {
|
|
112
|
+
instance.statusToggle();
|
|
113
|
+
}
|
|
114
|
+
updateStatus2Edit() {
|
|
115
|
+
instance.updateStatus2Edit();
|
|
116
|
+
}
|
|
117
|
+
createCanvas(id) {
|
|
118
|
+
const canvas = document.createElement("canvas");
|
|
119
|
+
canvas.id = id;
|
|
120
|
+
this.updateCanvasBasicStyle(canvas, {width: this.containerWidth, height: this.containerHeight}, 10);
|
|
121
|
+
return canvas;
|
|
122
|
+
}
|
|
123
|
+
createCanvas2d() {
|
|
124
|
+
this.canvas2d = this.createCanvas(`${DEFAULT_PREFIX}2d`);
|
|
125
|
+
this.container.appendChild(this.canvas2d);
|
|
126
|
+
}
|
|
127
|
+
setupRaycaster() {
|
|
128
|
+
this.raycaster.params = {
|
|
129
|
+
Mesh: {},
|
|
130
|
+
Line: {threshold: 1},
|
|
131
|
+
LOD: {},
|
|
132
|
+
Points: {threshold: 0.2},
|
|
133
|
+
Sprite: {}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
setHoverPointsID(id) {
|
|
137
|
+
this.hoverPointsID = id;
|
|
138
|
+
}
|
|
139
|
+
setSegmentMode(mode) {
|
|
140
|
+
this.segmentMode = mode;
|
|
141
|
+
}
|
|
142
|
+
setSegmentCoverMode(coverMode) {
|
|
143
|
+
this.segmentCoverMode = coverMode;
|
|
144
|
+
}
|
|
145
|
+
updateCanvasBasicStyle(canvas, size, zIndex) {
|
|
146
|
+
const pixel = 1;
|
|
147
|
+
canvas.style.position = "absolute";
|
|
148
|
+
canvas.width = size.width * pixel;
|
|
149
|
+
canvas.height = size.height * pixel;
|
|
150
|
+
canvas.style.width = `${size.width}px`;
|
|
151
|
+
canvas.style.height = `${size.height}px`;
|
|
152
|
+
canvas.style.left = "0";
|
|
153
|
+
canvas.style.top = "0";
|
|
154
|
+
canvas.style.zIndex = `${zIndex} `;
|
|
155
|
+
}
|
|
156
|
+
syncPolygon2d(polygon2d) {
|
|
157
|
+
this.polygon2d = polygon2d;
|
|
158
|
+
}
|
|
159
|
+
getPointsInPolygon(originPolygon) {
|
|
160
|
+
var _a, _b, _c;
|
|
161
|
+
const polygon = originPolygon;
|
|
162
|
+
const originPoints = this.scene.getObjectByName(this.pointCloudObjectName);
|
|
163
|
+
const cloudDataArrayLike = (_c = (_b = (_a = originPoints == null ? void 0 : originPoints.geometry) == null ? void 0 : _a.attributes) == null ? void 0 : _b.position) == null ? void 0 : _c.array;
|
|
164
|
+
if (cloudDataArrayLike) {
|
|
165
|
+
const len = cloudDataArrayLike.length;
|
|
166
|
+
const vertices = [];
|
|
167
|
+
const covers = [];
|
|
168
|
+
for (let i = 0; i < len; i += 3) {
|
|
169
|
+
const vector3d = new THREE.Vector3(cloudDataArrayLike[i], cloudDataArrayLike[i + 1], cloudDataArrayLike[i + 2]);
|
|
170
|
+
vector3d.project(this.camera);
|
|
171
|
+
const projection = {x: 0, y: 0};
|
|
172
|
+
projection.x = Math.round(vector3d.x * this.container.clientWidth / 2 + this.container.clientWidth / 2);
|
|
173
|
+
projection.y = Math.round(-vector3d.y * this.container.clientHeight / 2 + this.container.clientHeight / 2);
|
|
174
|
+
const isIn = isInPolygon(projection, polygon);
|
|
175
|
+
if (isIn) {
|
|
176
|
+
const x = cloudDataArrayLike[i];
|
|
177
|
+
const y = cloudDataArrayLike[i + 1];
|
|
178
|
+
const z = cloudDataArrayLike[i + 2];
|
|
179
|
+
const key = PointCloudUtils.getCloudKeys(x, y, z);
|
|
180
|
+
if (this.segmentMode === EPointCloudSegmentMode.Remove) {
|
|
181
|
+
this.cloudData.get(key).visible = false;
|
|
182
|
+
vertices.push(cloudDataArrayLike[i], cloudDataArrayLike[i + 1], cloudDataArrayLike[i + 2]);
|
|
183
|
+
}
|
|
184
|
+
if (this.segmentMode === EPointCloudSegmentMode.Add) {
|
|
185
|
+
if (this.segmentCoverMode === EPointCloudSegmentCoverMode.Cover) {
|
|
186
|
+
vertices.push(cloudDataArrayLike[i], cloudDataArrayLike[i + 1], cloudDataArrayLike[i + 2]);
|
|
187
|
+
if (this.cloudData.get(key).visible === true) {
|
|
188
|
+
covers.push(cloudDataArrayLike[i], cloudDataArrayLike[i + 1], cloudDataArrayLike[i + 2]);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (this.segmentCoverMode === EPointCloudSegmentCoverMode.Uncover) {
|
|
192
|
+
if (this.cloudData.get(key).visible === false) {
|
|
193
|
+
vertices.push(cloudDataArrayLike[i], cloudDataArrayLike[i + 1], cloudDataArrayLike[i + 2]);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (this.cloudData.get(key).visible === false) {
|
|
197
|
+
this.cloudData.get(key).visible = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const verticesArray = new Float32Array(vertices);
|
|
203
|
+
const coversArray = new Float32Array(covers);
|
|
204
|
+
this.updateStatusBySelector(verticesArray, coversArray);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
updateStatusBySelector(verticesArray, coversArray) {
|
|
208
|
+
switch (this.segmentMode) {
|
|
209
|
+
case EPointCloudSegmentMode.Add:
|
|
210
|
+
if (this.cacheSegData) {
|
|
211
|
+
const {points, coverPoints = new Float32Array([])} = this.cacheSegData;
|
|
212
|
+
const combinedLength = points.length + verticesArray.length;
|
|
213
|
+
const combined = new Float32Array(combinedLength);
|
|
214
|
+
combined.set(points, 0);
|
|
215
|
+
combined.set(verticesArray, points.length);
|
|
216
|
+
const coverCombinedLength = coverPoints.length + coversArray.length;
|
|
217
|
+
const coverCombined = new Float32Array(coverCombinedLength);
|
|
218
|
+
coverCombined.set(coverPoints, 0);
|
|
219
|
+
coverCombined.set(coversArray, coverPoints.length);
|
|
220
|
+
this.cacheSegData = __spreadProps(__spreadValues({}, this.cacheSegData), {
|
|
221
|
+
points: combined,
|
|
222
|
+
coverPoints: coverCombined
|
|
223
|
+
});
|
|
224
|
+
this.emit("updateNewPoints", this.cacheSegData);
|
|
225
|
+
} else {
|
|
226
|
+
this.cacheSegData = {
|
|
227
|
+
id: uuid(),
|
|
228
|
+
attribute: this.currentAttribute,
|
|
229
|
+
points: verticesArray,
|
|
230
|
+
coverPoints: coversArray
|
|
231
|
+
};
|
|
232
|
+
this.emit("addNewPointsCloud", this.cacheSegData);
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
case EPointCloudSegmentMode.Remove:
|
|
236
|
+
if (this.cacheSegData) {
|
|
237
|
+
const {points} = this.cacheSegData;
|
|
238
|
+
this.cacheSegData = __spreadProps(__spreadValues({}, this.cacheSegData), {
|
|
239
|
+
points: this.splitPointsFromPoints(points, verticesArray)
|
|
240
|
+
});
|
|
241
|
+
this.emit("updateNewPoints", this.cacheSegData);
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
this.updateStatus2Edit();
|
|
246
|
+
this.emit("syncPointCloudStatus", {
|
|
247
|
+
segmentStatus: this.segmentStatus,
|
|
248
|
+
cacheSegData: this.cacheSegData
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
splitPointsFromPoints(originPoints, splitPoints) {
|
|
252
|
+
const splitMap = new Map();
|
|
253
|
+
for (let i = 0; i < splitPoints.length; i += 3) {
|
|
254
|
+
splitMap.set(PointCloudUtils.getCloudKeys(splitPoints[i], splitPoints[i + 1], splitPoints[i + 2]), 1);
|
|
255
|
+
}
|
|
256
|
+
const result = [];
|
|
257
|
+
for (let i = 0; i < originPoints.length; i += 3) {
|
|
258
|
+
const key = PointCloudUtils.getCloudKeys(originPoints[i], originPoints[i + 1], originPoints[i + 2]);
|
|
259
|
+
if (!splitMap.has(key)) {
|
|
260
|
+
result.push(originPoints[i], originPoints[i + 1], originPoints[i + 2]);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return new Float32Array(result);
|
|
264
|
+
}
|
|
265
|
+
syncPointCloudStatus() {
|
|
266
|
+
this.statusToggle();
|
|
267
|
+
const {segmentStatus, cacheSegData} = this;
|
|
268
|
+
this.emit("syncPointCloudStatus", {segmentStatus, cacheSegData});
|
|
269
|
+
}
|
|
270
|
+
addStash2Store() {
|
|
271
|
+
if (this.isEditStatus && this.cacheSegData) {
|
|
272
|
+
if (this.cacheSegData.coverPoints && this.cacheSegData.coverPoints.length !== 0) {
|
|
273
|
+
this.updateCoverPoints(this.cacheSegData.coverPoints);
|
|
274
|
+
}
|
|
275
|
+
delete this.cacheSegData.coverPoints;
|
|
276
|
+
this.segmentData.set(this.cacheSegData.id, this.cacheSegData);
|
|
277
|
+
this.cacheSegData = void 0;
|
|
278
|
+
this.syncPointCloudStatus();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
updateCloudDataStatus(points, status) {
|
|
282
|
+
for (let i = 0; i < points.length; i += 3) {
|
|
283
|
+
const x = points[i];
|
|
284
|
+
const y = points[i + 1];
|
|
285
|
+
const z = points[i + 2];
|
|
286
|
+
const key = PointCloudUtils.getCloudKeys(x, y, z);
|
|
287
|
+
const data = this.cloudData.get(key);
|
|
288
|
+
Object.keys(status).forEach((k) => {
|
|
289
|
+
data[k] = status[k];
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
clearStash() {
|
|
294
|
+
if (this.isEditStatus && this.cacheSegData) {
|
|
295
|
+
this.updateCloudDataStatus(this.cacheSegData.points, {visible: false});
|
|
296
|
+
if (this.segmentData.has(this.cacheSegData.id)) {
|
|
297
|
+
const originSegmentData = this.segmentData.get(this.cacheSegData.id);
|
|
298
|
+
if (originSegmentData) {
|
|
299
|
+
this.emit("updateNewPoints", originSegmentData);
|
|
300
|
+
this.updateCloudDataStatus(originSegmentData == null ? void 0 : originSegmentData.points, {visible: true});
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
this.emit("clearStashRender");
|
|
304
|
+
}
|
|
305
|
+
this.cacheSegData = void 0;
|
|
306
|
+
this.syncPointCloudStatus();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
updateCheck2Edit() {
|
|
310
|
+
if (this.isCheckStatus) {
|
|
311
|
+
this.syncPointCloudStatus();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
checkPoints() {
|
|
315
|
+
const hoverPoints = this.segmentData.get(this.hoverPointsID);
|
|
316
|
+
if (hoverPoints) {
|
|
317
|
+
this.cacheSegData = __spreadProps(__spreadValues({}, hoverPoints), {
|
|
318
|
+
points: new Float32Array(hoverPoints.points)
|
|
319
|
+
});
|
|
320
|
+
instance.updateStatus2Check();
|
|
321
|
+
this.emit("syncPointCloudStatus", {
|
|
322
|
+
segmentStatus: this.segmentStatus,
|
|
323
|
+
cacheSegData: this.cacheSegData
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
editPoints() {
|
|
328
|
+
const hoverPoints = this.segmentData.get(this.hoverPointsID);
|
|
329
|
+
if (hoverPoints) {
|
|
330
|
+
this.cacheSegData = __spreadProps(__spreadValues({}, hoverPoints), {
|
|
331
|
+
points: new Float32Array(hoverPoints.points)
|
|
332
|
+
});
|
|
333
|
+
this.emit("updateNewPoints");
|
|
334
|
+
this.syncPointCloudStatus();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
setForbidOperation(forbidOperation) {
|
|
338
|
+
this.forbidOperation = forbidOperation;
|
|
339
|
+
}
|
|
340
|
+
updateMouse(offset) {
|
|
341
|
+
const x = offset.x / this.containerWidth * 2 - 1;
|
|
342
|
+
const y = -(offset.y / this.containerHeight) * 2 + 1;
|
|
343
|
+
this.mouse.setX(x);
|
|
344
|
+
this.mouse.setY(y);
|
|
345
|
+
}
|
|
346
|
+
resetAllSegDataSize() {
|
|
347
|
+
this.allSegmentPoints.forEach((points) => {
|
|
348
|
+
var _a;
|
|
349
|
+
if (((_a = this.cacheSegData) == null ? void 0 : _a.id) === points.name) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
points.material.size = 5;
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
resetHoverPointsID() {
|
|
356
|
+
this.hoverPointsID = "";
|
|
357
|
+
}
|
|
358
|
+
resetAllSegDataSizeAndRender() {
|
|
359
|
+
this.resetAllSegDataSize();
|
|
360
|
+
this.emit("reRender3d");
|
|
361
|
+
}
|
|
362
|
+
highlightPoints(newPoints) {
|
|
363
|
+
if (!(this.isCheckStatus || this.isReadyStatus)) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
this.resetAllSegDataSize();
|
|
367
|
+
newPoints.material.size = 10;
|
|
368
|
+
this.hoverPointsID = newPoints.name;
|
|
369
|
+
this.emit("reRender3d");
|
|
370
|
+
}
|
|
371
|
+
setAttribute(attribute) {
|
|
372
|
+
this.currentAttribute = attribute;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export { PointCloudStore as default };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import CommonToolUtils from '../../utils/tool/CommonToolUtils.js';
|
|
3
|
+
|
|
4
|
+
class Selection {
|
|
5
|
+
constructor(toolInstance) {
|
|
6
|
+
if (!toolInstance) {
|
|
7
|
+
console.error("MultipleSelect is require a tool instance");
|
|
8
|
+
}
|
|
9
|
+
this._selectedIDs = [];
|
|
10
|
+
this.toolInstance = toolInstance;
|
|
11
|
+
}
|
|
12
|
+
get selectedIDs() {
|
|
13
|
+
return this._selectedIDs;
|
|
14
|
+
}
|
|
15
|
+
get selectedID() {
|
|
16
|
+
return this._selectedIDs.length === 1 ? this._selectedIDs[0] : void 0;
|
|
17
|
+
}
|
|
18
|
+
get visibleDataList() {
|
|
19
|
+
const {dataList, attributeLockList, basicResult} = this.toolInstance;
|
|
20
|
+
const [showingDataList] = CommonToolUtils.getRenderResultList(dataList, CommonToolUtils.getSourceID(basicResult), attributeLockList);
|
|
21
|
+
return showingDataList;
|
|
22
|
+
}
|
|
23
|
+
get dataList() {
|
|
24
|
+
return this.toolInstance.dataList;
|
|
25
|
+
}
|
|
26
|
+
set selectedIDs(selectedIDs) {
|
|
27
|
+
var _a;
|
|
28
|
+
(_a = this.toolInstance._textAttributeInstance) == null ? void 0 : _a.selectedIDsChanged(this.selectedIDs, selectedIDs);
|
|
29
|
+
this._selectedIDs = selectedIDs;
|
|
30
|
+
this.toolInstance.render();
|
|
31
|
+
}
|
|
32
|
+
updateSelectedIDs(selectedID) {
|
|
33
|
+
if (!selectedID) {
|
|
34
|
+
this._selectedIDs = [];
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (this.selectedIDs.includes(selectedID)) {
|
|
38
|
+
this.selectedIDs = this.selectedIDs.filter((id) => id !== selectedID);
|
|
39
|
+
} else {
|
|
40
|
+
this.selectedIDs = [...this.selectedIDs, selectedID];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
setSelectedIDs(id, isAppend = false) {
|
|
44
|
+
if (isAppend) {
|
|
45
|
+
this.updateSelectedIDs(id);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.selectedIDs = id ? [id] : [];
|
|
49
|
+
}
|
|
50
|
+
hardSetSelectedIDs(ids) {
|
|
51
|
+
this.selectedIDs = ids;
|
|
52
|
+
}
|
|
53
|
+
selectAll() {
|
|
54
|
+
this.selectedIDs = this.visibleDataList.map((i) => i.id);
|
|
55
|
+
this.toolInstance.render();
|
|
56
|
+
}
|
|
57
|
+
toStashDataList() {
|
|
58
|
+
if (this.selectedIDs.length > 0) {
|
|
59
|
+
this.stashDataList = _.cloneDeep(this.dataList.filter((i) => this.selectedIDs.includes(i.id)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
toUnStashDataList() {
|
|
63
|
+
if (this.stashDataList) {
|
|
64
|
+
const _stashDataList = this.stashDataList;
|
|
65
|
+
this.stashDataList = void 0;
|
|
66
|
+
return _stashDataList;
|
|
67
|
+
}
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
mergeStashData(setDataList) {
|
|
71
|
+
const stashList = this.toUnStashDataList();
|
|
72
|
+
if (!stashList) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const mergedDataList = _(this.dataList).keyBy("id").merge(_.keyBy(stashList, "id")).values().value();
|
|
76
|
+
setDataList(mergedDataList);
|
|
77
|
+
this.toolInstance.render();
|
|
78
|
+
}
|
|
79
|
+
isIdSelected(id) {
|
|
80
|
+
return this.selectedIDs.includes(id);
|
|
81
|
+
}
|
|
82
|
+
triggerKeyboardEvent(e, setDataList) {
|
|
83
|
+
if (e.ctrlKey) {
|
|
84
|
+
if (e.key === "v") {
|
|
85
|
+
this.mergeStashData(setDataList);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
if (e.key === "a") {
|
|
89
|
+
this.selectAll();
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
if (e.key === "c") {
|
|
93
|
+
this.toStashDataList();
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { Selection as default };
|