@@ -8,12 +8,13 @@ import {
8
8
GeometryNode ,
9
9
I18n ,
10
10
LineType ,
11
+ Precision ,
11
12
ShapeMeshData ,
12
13
VisualConfig ,
13
14
XYZ ,
14
15
command ,
15
16
} from "chili-core" ;
16
- import { Dimension , PointSnapData } from "../../snap" ;
17
+ import { Dimension , PointSnapData , SnapResult } from "../../snap" ;
17
18
import { IStep , PointStep } from "../../step" ;
18
19
import { CreateCommand } from "../createCommand" ;
19
20
@@ -39,9 +40,20 @@ export class BezierCommand extends CreateCommand {
39
40
return this . controller . result ?. status === "success" ;
40
41
}
41
42
this . stepDatas . push ( data ) ;
43
+ if ( this . isClose ( data ) ) {
44
+ return true ;
45
+ }
42
46
}
43
47
}
44
48
49
+ private isClose ( data : SnapResult ) {
50
+ console . log ( this . stepDatas [ 0 ] . point ! . distanceTo ( data . point ! ) ) ;
51
+ return (
52
+ this . stepDatas . length > 1 &&
53
+ this . stepDatas [ 0 ] . point ! . distanceTo ( data . point ! ) <= Precision . Distance
54
+ ) ;
55
+ }
56
+
45
57
protected override getSteps ( ) : IStep [ ] {
46
58
let firstStep = new PointStep ( "operate.pickFistPoint" ) ;
47
59
let secondStep = new PointStep ( "operate.pickNextPoint" , this . getNextData ) ;
@@ -54,6 +66,13 @@ export class BezierCommand extends CreateCommand {
54
66
dimension : Dimension . D1D2D3 ,
55
67
validator : this . validator ,
56
68
preview : this . preview ,
69
+ featurePoints : [
70
+ {
71
+ point : this . stepDatas . at ( 0 ) ! . point ! ,
72
+ prompt : I18n . translate ( "prompt.polygon.close" ) ,
73
+ when : ( ) => this . stepDatas . length > 2 ,
74
+ } ,
75
+ ] ,
57
76
} ;
58
77
} ;
59
78
0 commit comments