@labelbee/lb-annotation 1.14.0-alpha.2 → 1.14.0-alpha.3
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/_virtual/MathUtilsWorker.js +8 -1
- package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +35 -2
- package/dist/_virtual/filterBoxWorker.js +8 -1
- package/dist/_virtual/highlightWorker.js +8 -1
- package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +5 -7
- package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +5 -12
- package/dist/assets/attributeIcon/icon_editFEN.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editHUANG.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editLAN.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editLV.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editQING.svg.js +5 -1
- package/dist/constant/annotation.js +127 -1
- package/dist/constant/annotationTask.js +30 -1
- package/dist/constant/defaultConfig.js +266 -1
- package/dist/constant/keyCode.js +38 -1
- package/dist/constant/style.js +98 -1
- package/dist/constant/tool.js +236 -1
- package/dist/core/index.js +150 -1
- package/dist/core/pointCloud/OrbitControls.js +665 -1
- package/dist/core/pointCloud/PCDLoader.js +260 -2
- package/dist/core/pointCloud/annotation.js +215 -1
- package/dist/core/pointCloud/cache.js +53 -1
- package/dist/core/pointCloud/index.js +991 -5
- package/dist/core/pointCloud/matrix.js +138 -1
- package/dist/core/pointCloud/segmentation.js +144 -0
- package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +26 -0
- package/dist/core/pointCloud/selector/Sse3dSelector.js +16 -0
- package/dist/core/scheduler.js +233 -1
- package/dist/core/toolOperation/LineToolOperation.js +1434 -1
- package/dist/core/toolOperation/ScribbleTool.js +292 -1
- package/dist/core/toolOperation/TextToolOperation.js +131 -1
- package/dist/core/toolOperation/ViewOperation.js +556 -1
- package/dist/core/toolOperation/basicToolOperation.js +881 -1
- package/dist/core/toolOperation/checkOperation.js +208 -1
- package/dist/core/toolOperation/cuboidOperation.js +754 -1
- package/dist/core/toolOperation/cuboidToggleButtonClass.js +152 -7
- package/dist/core/toolOperation/eventListener.js +37 -1
- package/dist/core/toolOperation/measureOperation.js +41 -1
- package/dist/core/toolOperation/pointCloud2dOperation.js +365 -1
- package/dist/core/toolOperation/pointOperation.js +696 -1
- package/dist/core/toolOperation/polygonOperation.js +1251 -1
- package/dist/core/toolOperation/rectOperation.js +1233 -1
- package/dist/core/toolOperation/segmentByRect.js +174 -1
- package/dist/core/toolOperation/tagOperation.js +201 -3
- package/dist/core/toolOperation/textAttributeClass.js +182 -16
- package/dist/index.js +185 -1
- package/dist/locales/constants.js +24 -1
- package/dist/locales/en_US/message.js +25 -1
- package/dist/locales/index.js +19 -1
- package/dist/locales/zh_CN/message.js +25 -1
- package/dist/newCore/CanvasScheduler.js +35 -1
- package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
- package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
- package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
- package/dist/utils/ActionsHistory.js +84 -1
- package/dist/utils/ImgUtils.js +23 -1
- package/dist/utils/MathUtils.js +385 -2
- package/dist/utils/VectorUtils.js +25 -1
- package/dist/utils/tool/AttributeUtils.js +218 -1
- package/dist/utils/tool/AxisUtils.js +340 -1
- package/dist/utils/tool/CanvasUtils.js +62 -1
- package/dist/utils/tool/CommonToolUtils.js +174 -1
- package/dist/utils/tool/CuboidUtils.js +704 -1
- package/dist/utils/tool/DblClickEventListener.js +102 -1
- package/dist/utils/tool/DrawUtils.js +492 -3
- package/dist/utils/tool/EnhanceCommonToolUtils.js +53 -1
- package/dist/utils/tool/ImgPosUtils.js +58 -1
- package/dist/utils/tool/LineToolUtils.js +261 -1
- package/dist/utils/tool/MarkerUtils.js +56 -1
- package/dist/utils/tool/PolygonUtils.js +460 -1
- package/dist/utils/tool/RectUtils.js +155 -1
- package/dist/utils/tool/RenderDomClass.js +57 -7
- package/dist/utils/tool/RenderDomUtils.js +21 -4
- package/dist/utils/tool/StyleUtils.js +31 -1
- package/dist/utils/tool/TagUtils.js +129 -1
- package/dist/utils/tool/UnitUtils.js +12 -1
- package/dist/utils/tool/ZoomUtils.js +72 -1
- package/dist/utils/tool/polygonTool.js +133 -1
- package/dist/utils/uuid.js +26 -1
- package/es/_virtual/MathUtilsWorker.js +6 -1
- 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__browser__createBase64WorkerFactory.js +31 -2
- 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/_virtual/filterBoxWorker.js +6 -1
- package/es/_virtual/highlightWorker.js +6 -1
- package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -1
- package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +3 -5
- package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +3 -7
- package/es/assets/attributeIcon/icon_cuboidMore.svg.js +3 -5
- package/es/assets/attributeIcon/icon_cuboidRight.svg.js +3 -5
- package/es/assets/attributeIcon/icon_cuboidTop.svg.js +3 -12
- package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editLV.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editQING.svg.js +3 -1
- package/es/constant/annotation.js +113 -1
- package/es/constant/annotationTask.js +25 -1
- package/es/constant/defaultConfig.js +260 -1
- package/es/constant/keyCode.js +36 -1
- package/es/constant/style.js +74 -1
- package/es/constant/tool.js +220 -1
- package/es/core/index.js +148 -1
- package/es/core/pointCloud/OrbitControls.js +661 -1
- package/es/core/pointCloud/PCDLoader.js +256 -2
- package/es/core/pointCloud/annotation.js +211 -1
- package/es/core/pointCloud/cache.js +49 -1
- package/es/core/pointCloud/index.js +962 -5
- package/es/core/pointCloud/matrix.js +109 -1
- package/es/core/pointCloud/segmentation.js +120 -0
- package/es/core/pointCloud/selector/Sse3dLassoSelector.js +24 -0
- package/es/core/pointCloud/selector/Sse3dSelector.js +14 -0
- package/es/core/scheduler.js +228 -1
- package/es/core/toolOperation/LineToolOperation.js +1421 -1
- package/es/core/toolOperation/ScribbleTool.js +290 -1
- package/es/core/toolOperation/TextToolOperation.js +129 -1
- package/es/core/toolOperation/ViewOperation.js +549 -1
- package/es/core/toolOperation/basicToolOperation.js +877 -1
- package/es/core/toolOperation/checkOperation.js +206 -1
- package/es/core/toolOperation/cuboidOperation.js +752 -1
- package/es/core/toolOperation/cuboidToggleButtonClass.js +150 -7
- package/es/core/toolOperation/eventListener.js +35 -1
- package/es/core/toolOperation/measureOperation.js +39 -1
- package/es/core/toolOperation/pointCloud2dOperation.js +359 -1
- package/es/core/toolOperation/pointOperation.js +690 -1
- package/es/core/toolOperation/polygonOperation.js +1245 -1
- package/es/core/toolOperation/rectOperation.js +1228 -1
- package/es/core/toolOperation/scribbleTool2.js +249 -0
- package/es/core/toolOperation/segmentByRect.js +172 -1
- package/es/core/toolOperation/tagOperation.js +199 -3
- package/es/core/toolOperation/textAttributeClass.js +180 -16
- package/es/index.js +46 -1
- package/es/locales/constants.js +22 -1
- package/es/locales/en_US/message.js +23 -1
- package/es/locales/index.js +17 -1
- package/es/locales/zh_CN/message.js +23 -1
- package/es/newCore/CanvasScheduler.js +31 -1
- package/es/utils/ActionsHistory.js +78 -1
- package/es/utils/ImgUtils.js +21 -1
- package/es/utils/MathUtils.js +380 -2
- package/es/utils/VectorUtils.js +23 -1
- package/es/utils/tool/AttributeUtils.js +212 -1
- package/es/utils/tool/AxisUtils.js +335 -1
- package/es/utils/tool/CanvasUtils.js +60 -1
- package/es/utils/tool/CommonToolUtils.js +172 -1
- package/es/utils/tool/CuboidUtils.js +680 -1
- package/es/utils/tool/DblClickEventListener.js +100 -1
- package/es/utils/tool/DrawUtils.js +490 -3
- package/es/utils/tool/EnhanceCommonToolUtils.js +48 -1
- package/es/utils/tool/ImgPosUtils.js +56 -1
- package/es/utils/tool/LineToolUtils.js +255 -1
- package/es/utils/tool/MarkerUtils.js +54 -1
- package/es/utils/tool/PolygonUtils.js +458 -1
- package/es/utils/tool/RectUtils.js +153 -1
- package/es/utils/tool/RenderDomClass.js +55 -7
- package/es/utils/tool/RenderDomUtils.js +19 -4
- package/es/utils/tool/StyleUtils.js +29 -1
- package/es/utils/tool/TagUtils.js +127 -1
- package/es/utils/tool/UnitUtils.js +10 -1
- package/es/utils/tool/ZoomUtils.js +70 -1
- package/es/utils/tool/polygonTool.js +126 -1
- package/es/utils/uuid.js +24 -1
- package/package.json +7 -5
|
@@ -1 +1,138 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var THREE = require('three');
|
|
6
|
+
var lbUtils = require('@labelbee/lb-utils');
|
|
7
|
+
var uuid = require('../../utils/uuid.js');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n["default"] = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
28
|
+
|
|
29
|
+
var __defProp = Object.defineProperty;
|
|
30
|
+
var __defProps = Object.defineProperties;
|
|
31
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
32
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
33
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
34
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
35
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
36
|
+
var __spreadValues = (a, b) => {
|
|
37
|
+
for (var prop in b || (b = {}))
|
|
38
|
+
if (__hasOwnProp.call(b, prop))
|
|
39
|
+
__defNormalProp(a, prop, b[prop]);
|
|
40
|
+
if (__getOwnPropSymbols)
|
|
41
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
42
|
+
if (__propIsEnum.call(b, prop))
|
|
43
|
+
__defNormalProp(a, prop, b[prop]);
|
|
44
|
+
}
|
|
45
|
+
return a;
|
|
46
|
+
};
|
|
47
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
48
|
+
function createThreeMatrix4(matrix4) {
|
|
49
|
+
return new THREE__namespace.Matrix4().set(...matrix4);
|
|
50
|
+
}
|
|
51
|
+
function transferKitti2Matrix(P, R, T) {
|
|
52
|
+
const PMA = lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(P);
|
|
53
|
+
const RMA = lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(R);
|
|
54
|
+
const TMA = lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(T);
|
|
55
|
+
const PM = createThreeMatrix4(PMA);
|
|
56
|
+
const RM = createThreeMatrix4(RMA);
|
|
57
|
+
const TM = createThreeMatrix4(TMA);
|
|
58
|
+
return {
|
|
59
|
+
composeMatrix4: TM.clone().premultiply(RM).premultiply(PM),
|
|
60
|
+
PM,
|
|
61
|
+
RM,
|
|
62
|
+
TM
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function rotatePoint(points, centerPoint, rotationZ) {
|
|
66
|
+
var _a;
|
|
67
|
+
const pointVector = new THREE__namespace.Vector3(points.x, points.y, (_a = points == null ? void 0 : points.z) != null ? _a : 1);
|
|
68
|
+
const Rz = new THREE__namespace.Matrix4().makeRotationZ(rotationZ);
|
|
69
|
+
const TFrom = new THREE__namespace.Matrix4().makeTranslation(centerPoint.x, centerPoint.y, centerPoint.z);
|
|
70
|
+
const TBack = new THREE__namespace.Matrix4().makeTranslation(-centerPoint.x, -centerPoint.y, -centerPoint.z);
|
|
71
|
+
return pointVector.clone().applyMatrix4(TBack).applyMatrix4(Rz).applyMatrix4(TFrom);
|
|
72
|
+
}
|
|
73
|
+
function lidar2image(point, composeMatrix4) {
|
|
74
|
+
const vector = new THREE__namespace.Vector4(point.x, point.y, point.z);
|
|
75
|
+
const newV = vector.applyMatrix4(composeMatrix4);
|
|
76
|
+
if (newV.z < 0) {
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
const z = 1 / newV.z;
|
|
80
|
+
const fixMatrix4 = new THREE__namespace.Matrix4().set(z, 0, 0, 0, 0, z, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
|
|
81
|
+
return newV.applyMatrix4(fixMatrix4);
|
|
82
|
+
}
|
|
83
|
+
function getCuboidFromPointCloudBox(boxParams) {
|
|
84
|
+
const {center, width, height, depth, rotation} = boxParams;
|
|
85
|
+
const polygonPointList = [
|
|
86
|
+
{
|
|
87
|
+
x: center.x + width / 2,
|
|
88
|
+
y: center.y - height / 2
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
x: center.x + width / 2,
|
|
92
|
+
y: center.y + height / 2
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
x: center.x - width / 2,
|
|
96
|
+
y: center.y + height / 2
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
x: center.x - width / 2,
|
|
100
|
+
y: center.y - height / 2
|
|
101
|
+
}
|
|
102
|
+
].map((v) => {
|
|
103
|
+
const vector = rotatePoint(v, center, rotation);
|
|
104
|
+
return {
|
|
105
|
+
x: vector.x,
|
|
106
|
+
y: vector.y
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
const zMax = center.z + depth / 2;
|
|
110
|
+
const zMin = center.z - depth / 2;
|
|
111
|
+
return __spreadProps(__spreadValues({}, boxParams), {
|
|
112
|
+
polygonPointList,
|
|
113
|
+
zMax,
|
|
114
|
+
zMin
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function pointCloudLidar2image(boxParams, cameraMatrix) {
|
|
118
|
+
const allViewData = lbUtils.PointCloudUtils.getAllViewData(boxParams);
|
|
119
|
+
const {P, R, T} = cameraMatrix;
|
|
120
|
+
const {composeMatrix4} = transferKitti2Matrix(P, R, T);
|
|
121
|
+
const transferViewData = allViewData.map((viewData) => ({
|
|
122
|
+
type: viewData.type,
|
|
123
|
+
pointList: viewData.pointList.map((point) => rotatePoint(point, boxParams.center, boxParams.rotation)).map((point) => lidar2image(point, composeMatrix4)).map((point) => {
|
|
124
|
+
if (!point) {
|
|
125
|
+
return void 0;
|
|
126
|
+
}
|
|
127
|
+
return {id: uuid(), x: point == null ? void 0 : point.x, y: point == null ? void 0 : point.y};
|
|
128
|
+
}).filter((v) => v !== void 0)
|
|
129
|
+
})).filter((v) => v.pointList.length !== 0);
|
|
130
|
+
return transferViewData;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
exports.createThreeMatrix4 = createThreeMatrix4;
|
|
134
|
+
exports.getCuboidFromPointCloudBox = getCuboidFromPointCloudBox;
|
|
135
|
+
exports.lidar2image = lidar2image;
|
|
136
|
+
exports.pointCloudLidar2image = pointCloudLidar2image;
|
|
137
|
+
exports.rotatePoint = rotatePoint;
|
|
138
|
+
exports.transferKitti2Matrix = transferKitti2Matrix;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var DrawUtils = require('../../utils/tool/DrawUtils.js');
|
|
6
|
+
var THREE = require('three');
|
|
7
|
+
var Sse3dLassoSelector = require('./selector/Sse3dLassoSelector.js');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n["default"] = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
28
|
+
|
|
29
|
+
class PointCloudSegmentOperation {
|
|
30
|
+
constructor(props) {
|
|
31
|
+
this.pointer = new THREE__namespace.Vector2();
|
|
32
|
+
this._forbidRender = false;
|
|
33
|
+
this.polygon = [];
|
|
34
|
+
this.startX = NaN;
|
|
35
|
+
this.startY = NaN;
|
|
36
|
+
this.onMouseMove = (iev) => {
|
|
37
|
+
const coord = this.getCoordinate(iev);
|
|
38
|
+
this.pointer.x = coord.x / this.dom.clientWidth * 2 - 1;
|
|
39
|
+
this.pointer.y = -(coord.y / this.dom.clientHeight) * 2 + 1;
|
|
40
|
+
const ev = {
|
|
41
|
+
offsetX: iev.offsetX,
|
|
42
|
+
offsetY: iev.offsetY,
|
|
43
|
+
pageX: iev.pageX,
|
|
44
|
+
pageY: iev.pageY,
|
|
45
|
+
which: iev.buttons === 2 ? 3 : 0
|
|
46
|
+
};
|
|
47
|
+
this.selector.mouseDrag(ev);
|
|
48
|
+
};
|
|
49
|
+
this.onMouseDown = (iev) => {
|
|
50
|
+
this._forbidRender = true;
|
|
51
|
+
const ev = {
|
|
52
|
+
offsetX: iev.offsetX,
|
|
53
|
+
offsetY: iev.offsetY,
|
|
54
|
+
pageX: iev.pageX,
|
|
55
|
+
pageY: iev.pageY,
|
|
56
|
+
which: iev.buttons === 2 ? 3 : 0
|
|
57
|
+
};
|
|
58
|
+
this.selector.mouseDown(ev);
|
|
59
|
+
};
|
|
60
|
+
this.onMouseUp = (iev) => {
|
|
61
|
+
const ev = {
|
|
62
|
+
offsetX: iev.offsetX,
|
|
63
|
+
offsetY: iev.offsetY,
|
|
64
|
+
pageX: iev.pageX,
|
|
65
|
+
pageY: iev.pageY,
|
|
66
|
+
which: iev.buttons === 2 ? 3 : 0
|
|
67
|
+
};
|
|
68
|
+
this.selector.mouseUp(ev);
|
|
69
|
+
};
|
|
70
|
+
this.render = ({camera, scene}) => {
|
|
71
|
+
const originPolygon = this.selector.polygon;
|
|
72
|
+
const polygon = [];
|
|
73
|
+
if (originPolygon.length > 0 && this.mouseCanvas) {
|
|
74
|
+
for (let i = 0; i < originPolygon.length; i += 2) {
|
|
75
|
+
polygon.push({
|
|
76
|
+
x: originPolygon[i * 2],
|
|
77
|
+
y: originPolygon[i * 2 + 1]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
console.log("polygon", polygon);
|
|
81
|
+
DrawUtils.drawPolygon(this.mouseCanvas, polygon, {isClose: false, color: "red"});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
this.dom = props.dom;
|
|
85
|
+
this.selector = new Sse3dLassoSelector(this);
|
|
86
|
+
const canvas = document.createElement("canvas");
|
|
87
|
+
canvas.id = "canvasMouse";
|
|
88
|
+
this.updateCanvasBasicStyle(canvas, {width: this.dom.clientWidth, height: this.dom.clientHeight}, 10);
|
|
89
|
+
this.dom.appendChild(canvas);
|
|
90
|
+
canvas.addEventListener("pointermove", this.onMouseMove);
|
|
91
|
+
canvas.addEventListener("pointerdown", this.onMouseDown);
|
|
92
|
+
canvas.addEventListener("pointerup", this.onMouseUp);
|
|
93
|
+
canvas.oncontextmenu = (e) => {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
};
|
|
96
|
+
canvas.getContext("2d");
|
|
97
|
+
this.mouseCanvas = canvas;
|
|
98
|
+
this.getPointsInPolygon = props.getPointsInPolygon;
|
|
99
|
+
this.setupRaycaster();
|
|
100
|
+
const geometry = new THREE__namespace.BufferGeometry();
|
|
101
|
+
const pointsMaterial = new THREE__namespace.PointsMaterial({size: 10, color: "red"});
|
|
102
|
+
geometry.setAttribute("position", new THREE__namespace.BufferAttribute(new Float32Array([0, 0, 0]), 3));
|
|
103
|
+
this._highlight_Point = new THREE__namespace.Points(geometry, pointsMaterial);
|
|
104
|
+
this.emitRender = props.render;
|
|
105
|
+
const geometry2 = new THREE__namespace.BufferGeometry();
|
|
106
|
+
const pointsMaterial2 = new THREE__namespace.PointsMaterial({size: 5, color: "white"});
|
|
107
|
+
geometry2.setAttribute("position", new THREE__namespace.BufferAttribute(new Float32Array([0, 0, 0]), 3));
|
|
108
|
+
this._temp = new THREE__namespace.Points(geometry2, pointsMaterial2);
|
|
109
|
+
}
|
|
110
|
+
updateCanvasBasicStyle(canvas, size, zIndex) {
|
|
111
|
+
const pixel = 2;
|
|
112
|
+
canvas.style.position = "absolute";
|
|
113
|
+
canvas.width = size.width * pixel;
|
|
114
|
+
canvas.height = size.height * pixel;
|
|
115
|
+
canvas.style.width = `${size.width}px`;
|
|
116
|
+
canvas.style.height = `${size.height}px`;
|
|
117
|
+
canvas.style.left = "0";
|
|
118
|
+
canvas.style.top = "0";
|
|
119
|
+
canvas.style.zIndex = `${zIndex} `;
|
|
120
|
+
}
|
|
121
|
+
addMorePoint(scene) {
|
|
122
|
+
scene.add(this._highlight_Point);
|
|
123
|
+
scene.add(this._temp);
|
|
124
|
+
}
|
|
125
|
+
getCoordinate(e) {
|
|
126
|
+
const bounding = this.dom.getBoundingClientRect();
|
|
127
|
+
return {
|
|
128
|
+
x: e.clientX - bounding.left,
|
|
129
|
+
y: e.clientY - bounding.top
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
setupRaycaster() {
|
|
133
|
+
const boundingBox = {x: 10, y: 10, z: 10};
|
|
134
|
+
const numberOfPoints = 10;
|
|
135
|
+
this.raycaster = new THREE__namespace.Raycaster();
|
|
136
|
+
const threshold = Math.cbrt(boundingBox.x * boundingBox.y * boundingBox.z / numberOfPoints) / 3;
|
|
137
|
+
if (this.raycaster) {
|
|
138
|
+
this.raycaster.params.Points.threshold = threshold;
|
|
139
|
+
this.raycaster.linePrecision = 0.1;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
exports.PointCloudSegmentOperation = PointCloudSegmentOperation;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Sse3dSelector = require('./Sse3dSelector.js');
|
|
4
|
+
|
|
5
|
+
class Sse3dLassoSelector extends Sse3dSelector {
|
|
6
|
+
mouseDown(ev) {
|
|
7
|
+
if (ev.which === 3) {
|
|
8
|
+
this.pushPoint(ev.offsetX, ev.offsetY);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
mouseUp(ev) {
|
|
12
|
+
if (ev.which === 3) {
|
|
13
|
+
this.scene.getPointsInPolygon(this.polygon);
|
|
14
|
+
this.polygon.length = 0;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
mouseDrag(ev) {
|
|
18
|
+
console.log("ev", ev.which);
|
|
19
|
+
if (ev.which === 3) {
|
|
20
|
+
this.pushPoint(ev.offsetX, ev.offsetY);
|
|
21
|
+
this.scene.emitRender(true);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = Sse3dLassoSelector;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class Sse3dSelector {
|
|
4
|
+
constructor(scene) {
|
|
5
|
+
this.scene = scene;
|
|
6
|
+
this.polygon = [];
|
|
7
|
+
}
|
|
8
|
+
pushPoint(x, y) {
|
|
9
|
+
this.polygon.push([x, y]);
|
|
10
|
+
}
|
|
11
|
+
deactivate() {
|
|
12
|
+
this.polygon.length = 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = Sse3dSelector;
|
package/dist/core/scheduler.js
CHANGED
|
@@ -1 +1,233 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var defaultConfig = require('../constant/defaultConfig.js');
|
|
6
|
+
var EnhanceCommonToolUtils = require('../utils/tool/EnhanceCommonToolUtils.js');
|
|
7
|
+
var basicToolOperation = require('./toolOperation/basicToolOperation.js');
|
|
8
|
+
|
|
9
|
+
const createEmptyImage = (size) => {
|
|
10
|
+
const canvas = document.createElement("canvas");
|
|
11
|
+
canvas.width = size.width;
|
|
12
|
+
canvas.height = size.height;
|
|
13
|
+
const ctx = canvas.getContext("2d");
|
|
14
|
+
if (ctx) {
|
|
15
|
+
ctx.fillStyle = "transparent";
|
|
16
|
+
ctx.fillRect(0, 0, size.width, size.height);
|
|
17
|
+
return canvas.toDataURL();
|
|
18
|
+
}
|
|
19
|
+
return "";
|
|
20
|
+
};
|
|
21
|
+
const arraySwap = (array, index1, index2) => {
|
|
22
|
+
const a = array[index1];
|
|
23
|
+
array[index1] = array[index2];
|
|
24
|
+
array[index2] = a;
|
|
25
|
+
return array;
|
|
26
|
+
};
|
|
27
|
+
const _HybridToolUtils = class {
|
|
28
|
+
static isSingleTool(toolName) {
|
|
29
|
+
return !this.isHybridTool(toolName);
|
|
30
|
+
}
|
|
31
|
+
static isHybridTool(toolName) {
|
|
32
|
+
return Array.isArray(toolName);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
let HybridToolUtils = _HybridToolUtils;
|
|
36
|
+
HybridToolUtils.getTopToolName = (toolName) => {
|
|
37
|
+
return _HybridToolUtils.isHybridTool(toolName) ? toolName[toolName.length - 1] : toolName;
|
|
38
|
+
};
|
|
39
|
+
class ToolScheduler {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
this.toolOperationList = [];
|
|
42
|
+
this.toolOperationDom = [];
|
|
43
|
+
this.toolOperationNameList = [];
|
|
44
|
+
var _a, _b;
|
|
45
|
+
this.init();
|
|
46
|
+
this.container = props.container;
|
|
47
|
+
this.size = props.size;
|
|
48
|
+
this.imgNode = props.imgNode;
|
|
49
|
+
this.config = (_a = props.config) != null ? _a : JSON.stringify(defaultConfig.getConfig(HybridToolUtils.getTopToolName(props.toolName)));
|
|
50
|
+
this.style = (_b = props.style) != null ? _b : defaultConfig.styleDefaultConfig;
|
|
51
|
+
}
|
|
52
|
+
setImgNode(imgNode, basicImgInfo) {
|
|
53
|
+
this.toolOperationList.forEach((toolInstance) => {
|
|
54
|
+
toolInstance.setImgNode(imgNode, basicImgInfo);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
setImgAttribute(imgAttribute) {
|
|
58
|
+
this.toolOperationList.forEach((toolInstance) => {
|
|
59
|
+
toolInstance.setImgAttribute(imgAttribute);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
setSize(size) {
|
|
63
|
+
this.toolOperationList.forEach((toolInstance) => {
|
|
64
|
+
toolInstance.setSize(size);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
syncPosition(currentPos, zoom, imgInfo, currentToolInstance) {
|
|
68
|
+
this.toolOperationList.forEach((toolInstance) => {
|
|
69
|
+
if (currentToolInstance === toolInstance) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
toolInstance.setCurrentPos(currentPos);
|
|
73
|
+
toolInstance.setZoom(zoom);
|
|
74
|
+
toolInstance.setImgInfo(imgInfo);
|
|
75
|
+
toolInstance.renderBasicCanvas();
|
|
76
|
+
toolInstance.render();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
get defaultSize() {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
return {
|
|
82
|
+
width: ((_a = this.imgNode) == null ? void 0 : _a.width) || this.size.width,
|
|
83
|
+
height: ((_b = this.imgNode) == null ? void 0 : _b.height) || this.size.height
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
createDom() {
|
|
87
|
+
const {width, height} = this.defaultSize;
|
|
88
|
+
const dom = window.document.createElement("div");
|
|
89
|
+
dom.style.position = "absolute";
|
|
90
|
+
dom.style.left = "0";
|
|
91
|
+
dom.style.top = "0";
|
|
92
|
+
dom.style.width = `${width}px`;
|
|
93
|
+
dom.style.height = `${height}px`;
|
|
94
|
+
const zIndex = this.toolOperationList.length + 1;
|
|
95
|
+
dom.style.zIndex = `${zIndex}`;
|
|
96
|
+
return dom;
|
|
97
|
+
}
|
|
98
|
+
getEmptyImage(width, height) {
|
|
99
|
+
const imgSrc = createEmptyImage({width, height});
|
|
100
|
+
const emptyImgNode = new Image();
|
|
101
|
+
emptyImgNode.src = imgSrc;
|
|
102
|
+
return emptyImgNode;
|
|
103
|
+
}
|
|
104
|
+
createOperation(tool, imgNode, config) {
|
|
105
|
+
var _a;
|
|
106
|
+
const {width, height} = this.defaultSize;
|
|
107
|
+
const dom = this.createDom();
|
|
108
|
+
const emptyImgNode = this.getEmptyImage(width, height);
|
|
109
|
+
const defaultData = {
|
|
110
|
+
container: dom,
|
|
111
|
+
size: this.size,
|
|
112
|
+
config: (_a = this == null ? void 0 : this.config) != null ? _a : "{}",
|
|
113
|
+
drawOutSideTarget: false,
|
|
114
|
+
style: this.style,
|
|
115
|
+
imgNode: imgNode || emptyImgNode,
|
|
116
|
+
hiddenImg: !!tool
|
|
117
|
+
};
|
|
118
|
+
if (config) {
|
|
119
|
+
Object.assign(defaultData, config);
|
|
120
|
+
}
|
|
121
|
+
let toolInstance;
|
|
122
|
+
if (!tool) {
|
|
123
|
+
toolInstance = new basicToolOperation.BasicToolOperation(defaultData);
|
|
124
|
+
dom.style.zIndex = "0";
|
|
125
|
+
toolInstance.init();
|
|
126
|
+
} else {
|
|
127
|
+
const ToolOperation = EnhanceCommonToolUtils.getCurrentOperation(tool);
|
|
128
|
+
if (!ToolOperation) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
toolInstance = new ToolOperation(defaultData);
|
|
132
|
+
}
|
|
133
|
+
toolInstance == null ? void 0 : toolInstance.init();
|
|
134
|
+
toolInstance.canvas.id = tool != null ? tool : "basicCanvas";
|
|
135
|
+
toolInstance.on("dragMove", ({currentPos, zoom, imgInfo}) => {
|
|
136
|
+
this.syncPosition(currentPos, zoom, imgInfo, toolInstance);
|
|
137
|
+
});
|
|
138
|
+
toolInstance.on("renderZoom", (zoom, currentPos, imgInfo) => {
|
|
139
|
+
if (zoom && currentPos) {
|
|
140
|
+
this.syncPosition(currentPos, zoom, imgInfo, toolInstance);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
if (!tool) {
|
|
144
|
+
this.container.insertBefore(dom, this.container.childNodes[0]);
|
|
145
|
+
this.toolOperationList.unshift(toolInstance);
|
|
146
|
+
this.toolOperationDom.unshift(dom);
|
|
147
|
+
return toolInstance;
|
|
148
|
+
}
|
|
149
|
+
this.container.appendChild(dom);
|
|
150
|
+
this.toolOperationList.push(toolInstance);
|
|
151
|
+
this.toolOperationNameList.push(tool);
|
|
152
|
+
this.toolOperationDom.push(dom);
|
|
153
|
+
return toolInstance;
|
|
154
|
+
}
|
|
155
|
+
switchLastTwoCanvas() {
|
|
156
|
+
if (this.toolOperationDom.length < 3) {
|
|
157
|
+
console.error("switchLastTwoCanvas is just used the layer which has 3 canvas");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const len = this.toolOperationDom.length;
|
|
161
|
+
const lastOneIndex = len - 1;
|
|
162
|
+
const last2SecondIndex = len - 2;
|
|
163
|
+
const lastOneDom = this.toolOperationDom[lastOneIndex];
|
|
164
|
+
const last2SecondDom = this.toolOperationDom[last2SecondIndex];
|
|
165
|
+
if (!last2SecondDom || !lastOneDom) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
lastOneDom.style.zIndex = `${lastOneIndex - 1}`;
|
|
169
|
+
last2SecondDom.style.zIndex = `${lastOneIndex}`;
|
|
170
|
+
this.toolOperationList[lastOneIndex].clearActiveStatus();
|
|
171
|
+
this.toolOperationList[lastOneIndex].clearCursorLine();
|
|
172
|
+
this.toolOperationList[lastOneIndex].render();
|
|
173
|
+
this.toolOperationList = arraySwap(this.toolOperationList, lastOneIndex, last2SecondIndex);
|
|
174
|
+
this.toolOperationDom = arraySwap(this.toolOperationDom, lastOneIndex, last2SecondIndex);
|
|
175
|
+
return this.toolOperationList[lastOneIndex];
|
|
176
|
+
}
|
|
177
|
+
getFirstToolOperation() {
|
|
178
|
+
if (this.toolOperationList.length > 1) {
|
|
179
|
+
return this.toolOperationList[1];
|
|
180
|
+
}
|
|
181
|
+
return this.toolOperationList[0];
|
|
182
|
+
}
|
|
183
|
+
switchToCanvas(toolName) {
|
|
184
|
+
var _a, _b, _c, _d;
|
|
185
|
+
const chosenIndex = this.toolOperationNameList.indexOf(toolName);
|
|
186
|
+
if (chosenIndex < 0 || this.toolOperationList.length < 1 || chosenIndex > this.toolOperationDom.length - 1) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const lastOneIndex = this.toolOperationDom.length - 1;
|
|
190
|
+
const chosenDom = this.toolOperationDom[chosenIndex];
|
|
191
|
+
const lastOneDom = this.toolOperationDom[lastOneIndex];
|
|
192
|
+
if (!chosenDom || !lastOneDom) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const temp = lastOneDom.style.zIndex;
|
|
196
|
+
lastOneDom.style.zIndex = `${chosenDom.style.zIndex}`;
|
|
197
|
+
chosenDom.style.zIndex = `${temp}`;
|
|
198
|
+
(_b = (_a = this.toolOperationList[lastOneIndex]).clearActiveStatus) == null ? void 0 : _b.call(_a);
|
|
199
|
+
(_d = (_c = this.toolOperationList[lastOneIndex]).clearCursorLine) == null ? void 0 : _d.call(_c);
|
|
200
|
+
this.toolOperationList[lastOneIndex].render();
|
|
201
|
+
this.toolOperationList = arraySwap(this.toolOperationList, lastOneIndex, chosenIndex);
|
|
202
|
+
this.toolOperationDom = arraySwap(this.toolOperationDom, lastOneIndex, chosenIndex);
|
|
203
|
+
this.toolOperationNameList = arraySwap(this.toolOperationNameList, lastOneIndex, chosenIndex);
|
|
204
|
+
return this.toolOperationList[lastOneIndex];
|
|
205
|
+
}
|
|
206
|
+
updateDataByToolName(toolName, result) {
|
|
207
|
+
const operationIndex = this.toolOperationNameList.indexOf(toolName);
|
|
208
|
+
if (operationIndex >= 0) {
|
|
209
|
+
const operationInstance = this.toolOperationList[operationIndex];
|
|
210
|
+
operationInstance.setResult(result);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
clearStatusAndResult() {
|
|
214
|
+
this.toolOperationList.forEach((toolInstance) => {
|
|
215
|
+
var _a;
|
|
216
|
+
(_a = toolInstance.clearActiveStatus) == null ? void 0 : _a.call(toolInstance);
|
|
217
|
+
toolInstance.clearResult();
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
destroyAllLayer() {
|
|
221
|
+
this.toolOperationList.forEach((toolInstance) => {
|
|
222
|
+
toolInstance.destroyCanvas();
|
|
223
|
+
this.init();
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
init() {
|
|
227
|
+
this.toolOperationList = [];
|
|
228
|
+
this.toolOperationDom = [];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
exports.HybridToolUtils = HybridToolUtils;
|
|
233
|
+
exports.ToolScheduler = ToolScheduler;
|