@realsee/dnalogel 3.48.0 → 3.48.2
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/CHANGELOG.md +6 -0
- package/dist/Sculpt/Objects/Base/index.d.ts +16 -0
- package/dist/Sculpt/Objects/Line/index.d.ts +12 -1
- package/dist/Sculpt/Objects/Polygon/index.d.ts +12 -1
- package/dist/Sculpt/Objects/Polyline/index.d.ts +12 -1
- package/dist/Sculpt/index.d.ts +10 -3
- package/dist/index.cjs.js +57 -57
- package/dist/index.js +5011 -4885
- package/dist/index.umd.js +50 -50
- package/dist/shared-utils/promise/withResolvers.d.ts +10 -0
- package/dist/shared-utils/three/Magnifier.d.ts +1 -1
- package/dist/shared-utils/three/PointSelector/utils/PointSelectorHelper.d.ts +4 -1
- package/libs/Sculpt/Meshes/Line.js +15 -15
- package/libs/Sculpt/Meshes/Polygon.js +20 -20
- package/libs/Sculpt/Objects/Base/index.d.ts +16 -0
- package/libs/Sculpt/Objects/Base/index.js +58 -32
- package/libs/Sculpt/Objects/Box/index.js +31 -34
- package/libs/Sculpt/Objects/Circle/index.js +36 -39
- package/libs/Sculpt/Objects/Line/index.d.ts +12 -1
- package/libs/Sculpt/Objects/Line/index.js +104 -75
- package/libs/Sculpt/Objects/Point/index.js +13 -16
- package/libs/Sculpt/Objects/Polygon/index.d.ts +12 -1
- package/libs/Sculpt/Objects/Polygon/index.js +112 -84
- package/libs/Sculpt/Objects/Polyline/index.d.ts +12 -1
- package/libs/Sculpt/Objects/Polyline/index.js +97 -68
- package/libs/Sculpt/Objects/Prism/index.js +20 -23
- package/libs/Sculpt/Objects/Rectangle/index.js +36 -39
- package/libs/Sculpt/index.d.ts +10 -3
- package/libs/Sculpt/index.js +80 -65
- package/libs/base/BasePlugin.js +1 -1
- package/libs/index.js +127 -126
- package/libs/shared-utils/logger.js +1 -1
- package/libs/shared-utils/promise/withResolvers.d.ts +10 -0
- package/libs/shared-utils/promise/withResolvers.js +13 -0
- package/libs/shared-utils/tag.js +9 -9
- package/libs/shared-utils/three/Magnifier.d.ts +1 -1
- package/libs/shared-utils/three/Magnifier.js +12 -12
- package/libs/shared-utils/three/PointSelector/utils/PointSelectorHelper.d.ts +4 -1
- package/libs/shared-utils/three/PointSelector/utils/PointSelectorHelper.js +9 -9
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ export interface LineImportData extends BaseImportData, LineData {
|
|
|
11
11
|
export declare class Line extends BaseObject<LineImportData> {
|
|
12
12
|
readonly type = "Line";
|
|
13
13
|
lineMesh: LineWithDotsMesh;
|
|
14
|
+
private creatingObject?;
|
|
14
15
|
get data(): {
|
|
15
16
|
points: [number, number, number][];
|
|
16
17
|
style: {
|
|
@@ -24,10 +25,20 @@ export declare class Line extends BaseObject<LineImportData> {
|
|
|
24
25
|
constructor(data?: LineImportData, config?: Partial<BaseObjectConfig>);
|
|
25
26
|
highlight(): void;
|
|
26
27
|
unhighlight(): void;
|
|
28
|
+
canUndo(): void;
|
|
29
|
+
canRedo(): void;
|
|
30
|
+
undo(): void;
|
|
31
|
+
redo(): void;
|
|
27
32
|
create(params?: Partial<LineMeshStyle & CreateLimitConfig>): Promise<void>;
|
|
28
33
|
}
|
|
29
34
|
/**
|
|
30
35
|
* @description 绘制线段
|
|
31
36
|
* @param config.limit 限制折线绘制的平面; `xoz` 限制在水平面; `y` 限制垂直面; `none` 不限制;默认 `none`
|
|
32
37
|
*/
|
|
33
|
-
export declare function createLine(lineMesh: LineMesh, pointSelector: PointSelector, config?: Partial<CreateLimitConfig>):
|
|
38
|
+
export declare function createLine(lineMesh: LineMesh, pointSelector: PointSelector, config?: Partial<CreateLimitConfig>): {
|
|
39
|
+
finished: Promise<void>;
|
|
40
|
+
canUndo: () => boolean;
|
|
41
|
+
canRedo: () => boolean;
|
|
42
|
+
undo: () => void;
|
|
43
|
+
redo: () => void;
|
|
44
|
+
};
|
|
@@ -1,55 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var k = Object.defineProperty, z = Object.defineProperties;
|
|
2
|
+
var B = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var U = Object.getOwnPropertySymbols;
|
|
4
|
+
var F = Object.prototype.hasOwnProperty, I = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var L = (n, t, e) => t in n ? k(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, f = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
7
|
+
F.call(t, e) && L(n, e, t[e]);
|
|
8
|
+
if (U)
|
|
9
|
+
for (var e of U(t))
|
|
10
|
+
I.call(t, e) && L(n, e, t[e]);
|
|
11
|
+
return n;
|
|
12
|
+
}, j = (n, t) => z(n, B(t));
|
|
13
|
+
var w = (n, t, e) => (L(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
14
|
+
var V = (n, t, e) => new Promise((s, p) => {
|
|
15
|
+
var P = (o) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
|
|
17
|
+
c(e.next(o));
|
|
18
|
+
} catch (l) {
|
|
19
|
+
p(l);
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, b = (o) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
|
|
23
|
+
c(e.throw(o));
|
|
24
|
+
} catch (l) {
|
|
25
|
+
p(l);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, c = (o) => o.done ? s(o.value) : Promise.resolve(o.value).then(P, b);
|
|
28
|
+
c((e = e.apply(n, t)).next());
|
|
29
29
|
});
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
const
|
|
39
|
-
class
|
|
40
|
-
constructor(e,
|
|
41
|
-
super(e,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
30
|
+
import { LineMesh as H } from "../../Meshes/Line.js";
|
|
31
|
+
import { BaseObject as N } from "../Base/index.js";
|
|
32
|
+
import * as a from "three";
|
|
33
|
+
import { LineEditor as _ } from "./Editor.js";
|
|
34
|
+
import { vector3ToArray as q } from "../../../shared-utils/three/vector3ToArray.js";
|
|
35
|
+
import { LineWithDotsMesh as T } from "../../Meshes/LineWithDots.js";
|
|
36
|
+
import { rayOnLine as G } from "../../utils/three/rayOnLine.js";
|
|
37
|
+
import { withResolvers as J } from "../../../shared-utils/promise/withResolvers.js";
|
|
38
|
+
const W = new a.Vector3();
|
|
39
|
+
class ie extends N {
|
|
40
|
+
constructor(e, s) {
|
|
41
|
+
super(e, s);
|
|
42
|
+
w(this, "type", "Line");
|
|
43
|
+
w(this, "lineMesh");
|
|
44
|
+
w(this, "creatingObject");
|
|
45
|
+
e && (this.lineMesh = new T(f(f({}, e.style), e)), this.add(this.lineMesh)), this.editor = new _(this);
|
|
47
46
|
}
|
|
48
47
|
get data() {
|
|
49
|
-
return
|
|
50
|
-
points:
|
|
48
|
+
return j(f({}, this.baseData), {
|
|
49
|
+
points: q(this.applyObjectMatrixWorld(this.lineMesh.points)),
|
|
51
50
|
style: {
|
|
52
|
-
lineColor: new
|
|
51
|
+
lineColor: new a.Color(this.lineMesh.color).getHex(),
|
|
53
52
|
lineWidth: this.lineMesh.lineWidth,
|
|
54
53
|
dashed: this.lineMesh.dashed
|
|
55
54
|
}
|
|
@@ -63,45 +62,75 @@ class X extends k {
|
|
|
63
62
|
var e;
|
|
64
63
|
(e = this.lineMesh) == null || e.unhighlight();
|
|
65
64
|
}
|
|
65
|
+
canUndo() {
|
|
66
|
+
var e;
|
|
67
|
+
(e = this.creatingObject) == null || e.canUndo();
|
|
68
|
+
}
|
|
69
|
+
canRedo() {
|
|
70
|
+
var e;
|
|
71
|
+
(e = this.creatingObject) == null || e.canRedo();
|
|
72
|
+
}
|
|
73
|
+
undo() {
|
|
74
|
+
var e;
|
|
75
|
+
(e = this.creatingObject) == null || e.undo();
|
|
76
|
+
}
|
|
77
|
+
redo() {
|
|
78
|
+
var e;
|
|
79
|
+
(e = this.creatingObject) == null || e.redo();
|
|
80
|
+
}
|
|
66
81
|
create(e) {
|
|
67
|
-
return
|
|
82
|
+
return V(this, null, function* () {
|
|
68
83
|
this.removeChildren();
|
|
69
|
-
const
|
|
70
|
-
this.lineMesh =
|
|
84
|
+
const s = new T(e);
|
|
85
|
+
this.lineMesh = s, this.add(this.lineMesh), this.creatingObject = K(s, this.pointSelector, e), yield this.creatingObject.finished, this.editor.enable();
|
|
71
86
|
});
|
|
72
87
|
}
|
|
73
88
|
}
|
|
74
|
-
function
|
|
75
|
-
var
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
89
|
+
function K(n, t, e) {
|
|
90
|
+
var R;
|
|
91
|
+
const s = n.parent;
|
|
92
|
+
if (!s)
|
|
78
93
|
return;
|
|
79
|
-
const c = (
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}), d.setPoints([])) : (o = new r.Line3(n[0].clone(), new r.Vector3(0, 1, 0).add(n[0])).closestPointToPoint(l.point, !1, T), d.setPoints([o, l.point])), a.setPoints([w, o]));
|
|
97
|
-
}, b = () => {
|
|
98
|
-
t.off("select", L), t.off("intersectionUpdate", M), t.off("disable", v), t.plane = null, t.disable(), i == null || i.remove(a, d);
|
|
99
|
-
}, v = () => {
|
|
100
|
-
b(), n.length !== 2 && (i == null || i.remove(s)), p(new Error("Cancelled"));
|
|
94
|
+
const { promise: p, resolve: P, reject: b } = J(), c = (R = e == null ? void 0 : e.limit) != null ? R : "none", o = new H(n.style);
|
|
95
|
+
s.add(o);
|
|
96
|
+
const l = new H(j(f({}, n.style), { dashed: !0, lengthEnable: !1 }));
|
|
97
|
+
s.add(l), t.enable();
|
|
98
|
+
const i = [];
|
|
99
|
+
let h, d, v;
|
|
100
|
+
const m = [], O = () => i.length > 0, M = () => m.length > 0, A = () => {
|
|
101
|
+
O() && (m.push(i.pop()), n.setPoints(i), g(v), t.pointSelectorHelper.magnifier.render());
|
|
102
|
+
}, D = () => {
|
|
103
|
+
M() && (i.push(m.pop()), n.setPoints(i), g(v), t.pointSelectorHelper.magnifier.render());
|
|
104
|
+
}, E = (r) => {
|
|
105
|
+
m.length = 0;
|
|
106
|
+
const u = i.length === 0 ? r.point : h.clone();
|
|
107
|
+
i.push(u), n.setPoints(i), i.length === 2 && (x(), P());
|
|
108
|
+
}, g = (r) => {
|
|
109
|
+
const u = () => {
|
|
110
|
+
o.setPoints([]), l.setPoints([]), t.pointSelectorHelper.magnifier.render();
|
|
101
111
|
};
|
|
102
|
-
|
|
103
|
-
|
|
112
|
+
if (!(i != null && i.length) || !r)
|
|
113
|
+
return u();
|
|
114
|
+
v = r;
|
|
115
|
+
const y = i.at(-1).clone();
|
|
116
|
+
c === "none" ? (h = r.point, o.setPoints([y, h])) : c === "xoz" ? (t.plane = d, d = d != null ? d : new a.Plane().setFromNormalAndCoplanarPoint(new a.Vector3(0, 1, 0), i[0]), h = d.projectPoint(r.point, W), o.setPoints([y, h]), l.setPoints([h, r.point])) : c === "y" && (r.isVirtual ? (h = G({
|
|
117
|
+
raycaster: r.raycaster,
|
|
118
|
+
line: new a.Line3(i[0].clone(), new a.Vector3(0, 1, 0).add(i[0])),
|
|
119
|
+
clampToLine: !1
|
|
120
|
+
}), l.setPoints([])) : (h = new a.Line3(i[0].clone(), new a.Vector3(0, 1, 0).add(i[0])).closestPointToPoint(r.point, !1, W), l.setPoints([h, r.point])), o.setPoints([y, h]));
|
|
121
|
+
}, x = () => {
|
|
122
|
+
t.off("select", E), t.off("intersectionUpdate", g), t.off("disable", C), t.plane = null, t.disable(), s == null || s.remove(o, l);
|
|
123
|
+
}, C = () => {
|
|
124
|
+
x(), i.length !== 2 && (s == null || s.remove(n)), b(new Error("Cancelled"));
|
|
125
|
+
};
|
|
126
|
+
return t.on("select", E), t.on("intersectionUpdate", g), t.on("disable", C), {
|
|
127
|
+
finished: p,
|
|
128
|
+
canUndo: O,
|
|
129
|
+
canRedo: M,
|
|
130
|
+
undo: A,
|
|
131
|
+
redo: D
|
|
132
|
+
};
|
|
104
133
|
}
|
|
105
134
|
export {
|
|
106
|
-
|
|
135
|
+
ie as Line
|
|
107
136
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var y = Object.defineProperty, b = Object.defineProperties;
|
|
2
2
|
var u = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
3
|
+
var d = Object.getOwnPropertySymbols;
|
|
4
4
|
var w = Object.prototype.hasOwnProperty, P = Object.prototype.propertyIsEnumerable;
|
|
5
5
|
var a = (e, i, t) => i in e ? y(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, n = (e, i) => {
|
|
6
6
|
for (var t in i || (i = {}))
|
|
7
7
|
w.call(i, t) && a(e, t, i[t]);
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
8
|
+
if (d)
|
|
9
|
+
for (var t of d(i))
|
|
10
10
|
P.call(i, t) && a(e, t, i[t]);
|
|
11
11
|
return e;
|
|
12
12
|
}, g = (e, i) => b(e, u(i));
|
|
13
13
|
var M = (e, i, t) => (a(e, typeof i != "symbol" ? i + "" : i, t), t);
|
|
14
|
-
var
|
|
14
|
+
var m = (e, i, t) => new Promise((o, h) => {
|
|
15
15
|
var r = (s) => {
|
|
16
16
|
try {
|
|
17
17
|
l(t.next(s));
|
|
@@ -29,21 +29,18 @@ var d = (e, i, t) => new Promise((o, h) => {
|
|
|
29
29
|
});
|
|
30
30
|
import { PointMesh as f } from "../../Meshes/Point.js";
|
|
31
31
|
import { BaseObject as x } from "../Base/index.js";
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
class H extends x {
|
|
32
|
+
import { PointEditor as j } from "./Editor.js";
|
|
33
|
+
import { vector3ToArray as v } from "../../../shared-utils/three/vector3ToArray.js";
|
|
34
|
+
class D extends x {
|
|
36
35
|
constructor(t, o) {
|
|
37
36
|
super(t, o);
|
|
38
37
|
M(this, "type", "Point");
|
|
39
38
|
M(this, "pointMesh");
|
|
40
|
-
this.editor = new
|
|
41
|
-
this.stopCreating();
|
|
42
|
-
});
|
|
39
|
+
this.editor = new j(this), t && (this.pointMesh = new f(n(n({}, t.style), t)), this.add(this.pointMesh));
|
|
43
40
|
}
|
|
44
41
|
get data() {
|
|
45
42
|
return g(n({}, this.baseData), {
|
|
46
|
-
point:
|
|
43
|
+
point: v(this.applyObjectMatrixWorld(this.pointMesh.position)),
|
|
47
44
|
style: {
|
|
48
45
|
color: this.pointMesh.color.getHex(),
|
|
49
46
|
size: this.pointMesh.size
|
|
@@ -70,12 +67,12 @@ class H extends x {
|
|
|
70
67
|
* @description: 创建点
|
|
71
68
|
*/
|
|
72
69
|
create(t) {
|
|
73
|
-
return
|
|
74
|
-
this.pointMesh && this.remove(this.pointMesh), this.add(this.pointMesh = new f(t)), yield
|
|
70
|
+
return m(this, null, function* () {
|
|
71
|
+
this.pointMesh && this.remove(this.pointMesh), this.add(this.pointMesh = new f(t)), yield z(this.pointMesh, this.pointSelector), this.editor.enable();
|
|
75
72
|
});
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
function
|
|
75
|
+
function z(e, i) {
|
|
79
76
|
return new Promise((t, o) => {
|
|
80
77
|
i.enable();
|
|
81
78
|
const h = (r) => {
|
|
@@ -88,5 +85,5 @@ function C(e, i) {
|
|
|
88
85
|
});
|
|
89
86
|
}
|
|
90
87
|
export {
|
|
91
|
-
|
|
88
|
+
D as Point
|
|
92
89
|
};
|
|
@@ -11,6 +11,7 @@ export interface PolygonImportData extends BaseImportData, PolygonData {
|
|
|
11
11
|
export declare class Polygon extends BaseObject<PolygonImportData> {
|
|
12
12
|
readonly type = "Polygon";
|
|
13
13
|
areaMesh: AreaMesh;
|
|
14
|
+
private creatingObject?;
|
|
14
15
|
get data(): {
|
|
15
16
|
points: [number, number, number][];
|
|
16
17
|
style: {
|
|
@@ -24,6 +25,16 @@ export declare class Polygon extends BaseObject<PolygonImportData> {
|
|
|
24
25
|
constructor(data?: PolygonImportData, config?: Partial<BaseObjectConfig>);
|
|
25
26
|
highlight(): void;
|
|
26
27
|
unhighlight(): void;
|
|
28
|
+
canUndo(): void;
|
|
29
|
+
canRedo(): void;
|
|
30
|
+
undo(): void;
|
|
31
|
+
redo(): void;
|
|
27
32
|
create(params?: Partial<PolygonStyle & CreateLimitConfig>): Promise<void>;
|
|
28
33
|
}
|
|
29
|
-
export declare function createPolygon(areaMesh: AreaMesh, pointSelector: PointSelector, config?: Partial<CreateLimitConfig>):
|
|
34
|
+
export declare function createPolygon(areaMesh: AreaMesh, pointSelector: PointSelector, config?: Partial<CreateLimitConfig>): {
|
|
35
|
+
finished: Promise<void>;
|
|
36
|
+
canUndo: () => boolean;
|
|
37
|
+
canRedo: () => boolean;
|
|
38
|
+
undo: () => void;
|
|
39
|
+
redo: () => void;
|
|
40
|
+
};
|
|
@@ -1,52 +1,51 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
|
|
1
|
+
var k = Object.defineProperty, z = Object.defineProperties;
|
|
2
|
+
var B = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var A = Object.getOwnPropertySymbols;
|
|
4
|
+
var _ = Object.prototype.hasOwnProperty, q = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var M = (s, t, e) => t in s ? k(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, g = (s, t) => {
|
|
6
|
+
for (var e in t || (t = {}))
|
|
7
|
+
_.call(t, e) && M(s, e, t[e]);
|
|
8
|
+
if (A)
|
|
9
|
+
for (var e of A(t))
|
|
10
|
+
q.call(t, e) && M(s, e, t[e]);
|
|
11
11
|
return s;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
12
|
+
}, O = (s, t) => z(s, B(t));
|
|
13
|
+
var j = (s, t, e) => (M(s, typeof t != "symbol" ? t + "" : t, e), e);
|
|
14
|
+
var V = (s, t, e) => new Promise((c, d) => {
|
|
15
|
+
var m = (o) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
d(
|
|
17
|
+
f(e.next(o));
|
|
18
|
+
} catch (a) {
|
|
19
|
+
d(a);
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, r = (o) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
d(
|
|
23
|
+
f(e.throw(o));
|
|
24
|
+
} catch (a) {
|
|
25
|
+
d(a);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, f = (o) => o.done ? c(o.value) : Promise.resolve(o.value).then(m, r);
|
|
28
|
+
f((e = e.apply(s, t)).next());
|
|
29
29
|
});
|
|
30
|
-
import {
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
const
|
|
38
|
-
class
|
|
39
|
-
constructor(
|
|
40
|
-
super(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
30
|
+
import { BaseObject as G } from "../Base/index.js";
|
|
31
|
+
import * as P from "three";
|
|
32
|
+
import { PolylineMesh as D } from "../../Meshes/Polyline.js";
|
|
33
|
+
import { AreaMesh as F } from "../../Meshes/Area.js";
|
|
34
|
+
import { PolygonEditor as J } from "./Editor.js";
|
|
35
|
+
import { vector3ToArray as K } from "../../../shared-utils/three/vector3ToArray.js";
|
|
36
|
+
import { withResolvers as Q } from "../../../shared-utils/promise/withResolvers.js";
|
|
37
|
+
const I = new P.Vector3();
|
|
38
|
+
class ne extends G {
|
|
39
|
+
constructor(e, c) {
|
|
40
|
+
super(e, c);
|
|
41
|
+
j(this, "type", "Polygon");
|
|
42
|
+
j(this, "areaMesh");
|
|
43
|
+
j(this, "creatingObject");
|
|
44
|
+
this.editor = new J(this), e && (this.areaMesh = new F(g(g({}, e.style), e)), this.add(this.areaMesh));
|
|
46
45
|
}
|
|
47
46
|
get data() {
|
|
48
|
-
return this.updateMatrixWorld(),
|
|
49
|
-
points:
|
|
47
|
+
return this.updateMatrixWorld(), O(g({}, this.baseData), {
|
|
48
|
+
points: K(this.applyObjectMatrixWorld(this.areaMesh.points)),
|
|
50
49
|
style: {
|
|
51
50
|
color: this.areaMesh.color.getHex(),
|
|
52
51
|
lineColor: this.areaMesh.lineColor.getHex(),
|
|
@@ -55,59 +54,88 @@ class X extends z {
|
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
56
|
highlight() {
|
|
58
|
-
var
|
|
59
|
-
(
|
|
57
|
+
var e;
|
|
58
|
+
(e = this.areaMesh) == null || e.highlight();
|
|
60
59
|
}
|
|
61
60
|
unhighlight() {
|
|
62
|
-
var
|
|
63
|
-
(
|
|
61
|
+
var e;
|
|
62
|
+
(e = this.areaMesh) == null || e.unhighlight();
|
|
63
|
+
}
|
|
64
|
+
canUndo() {
|
|
65
|
+
var e;
|
|
66
|
+
(e = this.creatingObject) == null || e.canUndo();
|
|
67
|
+
}
|
|
68
|
+
canRedo() {
|
|
69
|
+
var e;
|
|
70
|
+
(e = this.creatingObject) == null || e.canRedo();
|
|
71
|
+
}
|
|
72
|
+
undo() {
|
|
73
|
+
var e;
|
|
74
|
+
(e = this.creatingObject) == null || e.undo();
|
|
75
|
+
}
|
|
76
|
+
redo() {
|
|
77
|
+
var e;
|
|
78
|
+
(e = this.creatingObject) == null || e.redo();
|
|
64
79
|
}
|
|
65
|
-
create(
|
|
66
|
-
return
|
|
80
|
+
create(e) {
|
|
81
|
+
return V(this, null, function* () {
|
|
67
82
|
this.children.forEach((d) => {
|
|
68
83
|
d.parent === this && this.remove(d);
|
|
69
84
|
}), this.children.length = 0;
|
|
70
|
-
const
|
|
71
|
-
this.areaMesh =
|
|
85
|
+
const c = new F(e);
|
|
86
|
+
this.areaMesh = c, this.add(this.areaMesh), this.creatingObject = X(this.areaMesh, this.pointSelector, e), yield this.creatingObject.finished, this.editor.enable();
|
|
72
87
|
});
|
|
73
88
|
}
|
|
74
89
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
g.distanceTo(i) < W || g.distanceTo(h.point) < W ? (i = g, h.point.copy(g), e.pointSelectorHelper.updateWithIntersect(h, { emitEvent: !1 }), u = !0) : u = !1, a.setPoints([p, i]), l.setPoints([i, h.point]);
|
|
100
|
-
}
|
|
101
|
-
o.length >= 2 && s.setPoints([...o, i], { closed: !1 });
|
|
102
|
-
}, E = () => {
|
|
103
|
-
e.off("select", v), e.off("intersectionUpdate", b), e.off("disable", x), e.plane = null, e.disable(), n == null || n.remove(a, l);
|
|
104
|
-
}, x = () => {
|
|
105
|
-
E(), n == null || n.remove(s, l, a), d(new Error("Cancelled"));
|
|
90
|
+
function X(s, t, e) {
|
|
91
|
+
var H;
|
|
92
|
+
const { promise: c, resolve: d, reject: m } = Q(), r = s.parent;
|
|
93
|
+
if (!r) {
|
|
94
|
+
m(new Error("No container"));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const f = (H = e == null ? void 0 : e.limit) != null ? H : "none", o = new D(s.style);
|
|
98
|
+
r == null || r.add(o);
|
|
99
|
+
const a = new D(O(g({}, s.style), { dashed: !0, lengthEnable: !1 }));
|
|
100
|
+
r == null || r.add(a), t.enable();
|
|
101
|
+
const n = [];
|
|
102
|
+
let i, h, v = !1, E;
|
|
103
|
+
const u = [], x = () => n.length > 0, C = () => u.length > 0, L = () => {
|
|
104
|
+
x() && (u.push(n.pop()), w(E), t.pointSelectorHelper.magnifier.render());
|
|
105
|
+
}, N = () => {
|
|
106
|
+
C() && (n.push(u.pop()), w(E), t.pointSelectorHelper.magnifier.render());
|
|
107
|
+
}, R = (l) => {
|
|
108
|
+
u.length = 0;
|
|
109
|
+
const b = n.length === 0 ? l.point : i.clone();
|
|
110
|
+
n.push(b), s.setPoints(n, { closed: !1 }), v && (U(), d());
|
|
111
|
+
}, w = (l) => {
|
|
112
|
+
const b = () => {
|
|
113
|
+
o.setPoints([]), a.setPoints([]), s.setPoints([]), t.pointSelectorHelper.magnifier.render();
|
|
106
114
|
};
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
if (!(n != null && n.length) || !l)
|
|
116
|
+
return b();
|
|
117
|
+
E = l;
|
|
118
|
+
const p = n.at(-1).clone();
|
|
119
|
+
if (n.length < 3 && (f === "none" ? (i = l.point, o.setPoints([p, i]), a.setPoints([])) : f === "xoz" ? (h = h != null ? h : new P.Plane().setFromNormalAndCoplanarPoint(new P.Vector3(0, 1, 0), n[0]), t.plane = h, i = h.projectPoint(l.point, I), o.setPoints([p, i]), a.setPoints([i, l.point])) : f === "y" && (n.length === 1 ? (i = l.point, o.setPoints([p, i]), a.setPoints([])) : (h = h != null ? h : new P.Plane().setFromCoplanarPoints(n[0], n[1], new P.Vector3(0, 1, 0).add(n[0])), t.plane = h, i = h.projectPoint(l.point, I), o.setPoints([p, i]), a.setPoints([i, l.point])))), n.length >= 3) {
|
|
120
|
+
i = s.projectPoint(l.point);
|
|
121
|
+
const y = n[0], T = 0.2;
|
|
122
|
+
y.distanceTo(i) < T || y.distanceTo(l.point) < T ? (i = y, l.point.copy(y), t.pointSelectorHelper.updateWithIntersect(l, { emitEvent: !1 }), v = !0) : v = !1, o.setPoints([p, i]), a.setPoints([i, l.point]);
|
|
123
|
+
}
|
|
124
|
+
n.length >= 2 ? s.setPoints([...n, i], { closed: !1 }) : s.setPoints([]);
|
|
125
|
+
}, U = () => {
|
|
126
|
+
t.off("select", R), t.off("intersectionUpdate", w), t.off("disable", W), t.plane = null, t.disable(), r == null || r.remove(o, a);
|
|
127
|
+
}, W = () => {
|
|
128
|
+
U(), r == null || r.remove(s, a, o), m(new Error("Cancelled"));
|
|
129
|
+
};
|
|
130
|
+
return t.on("select", R), t.on("intersectionUpdate", w), t.on("disable", W), {
|
|
131
|
+
finished: c,
|
|
132
|
+
canUndo: x,
|
|
133
|
+
canRedo: C,
|
|
134
|
+
undo: L,
|
|
135
|
+
redo: N
|
|
136
|
+
};
|
|
109
137
|
}
|
|
110
138
|
export {
|
|
111
|
-
|
|
112
|
-
|
|
139
|
+
ne as Polygon,
|
|
140
|
+
X as createPolygon
|
|
113
141
|
};
|
|
@@ -10,6 +10,7 @@ export interface PolylineImportData extends BaseImportData, PolylineData {
|
|
|
10
10
|
export declare class Polyline extends BaseObject<PolylineImportData> {
|
|
11
11
|
readonly type = "Polyline";
|
|
12
12
|
polyLineMesh: PolylineWithDotsMesh;
|
|
13
|
+
private creatingObject?;
|
|
13
14
|
get data(): {
|
|
14
15
|
points: [number, number, number][];
|
|
15
16
|
style: {
|
|
@@ -23,10 +24,20 @@ export declare class Polyline extends BaseObject<PolylineImportData> {
|
|
|
23
24
|
constructor(data?: PolylineImportData, config?: Partial<BaseObjectConfig>);
|
|
24
25
|
highlight(): void;
|
|
25
26
|
unhighlight(): void;
|
|
27
|
+
canUndo(): void;
|
|
28
|
+
canRedo(): void;
|
|
29
|
+
undo(): void;
|
|
30
|
+
redo(): void;
|
|
26
31
|
create(params?: Partial<PolylineStyle & CreateLimitConfig>): Promise<void>;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
34
|
* @description 绘制折线
|
|
30
35
|
* @param config.limit 限制折线绘制的平面; `xoz` 限制在水平面; `y` 限制垂直面; `none` 不限制;默认 `none`
|
|
31
36
|
*/
|
|
32
|
-
export declare function createPolyline(polyLineMesh: PolylineMesh, pointSelector: PointSelector, config?: Partial<CreateLimitConfig>):
|
|
37
|
+
export declare function createPolyline(polyLineMesh: PolylineMesh, pointSelector: PointSelector, config?: Partial<CreateLimitConfig>): {
|
|
38
|
+
finished: Promise<void>;
|
|
39
|
+
canUndo: () => boolean;
|
|
40
|
+
canRedo: () => boolean;
|
|
41
|
+
undo: () => void;
|
|
42
|
+
redo: () => void;
|
|
43
|
+
};
|