File tree 2 files changed +31
-0
lines changed 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,12 @@ <h3>[method:this setPositions]( [param:Array array] )</h3>
75
75
The length must be a multiple of three.
76
76
</ p >
77
77
78
+ < h3 > [method:this setFromPoints]( [param:Array points] )</ h3 >
79
+ < p >
80
+ Replace the vertex positions with an array of points.
81
+ Can be either a `Vector3` or `Vector2` array.
82
+ </ p >
83
+
78
84
< h2 > Source</ h2 >
79
85
80
86
< p >
Original file line number Diff line number Diff line change @@ -62,6 +62,31 @@ class LineGeometry extends LineSegmentsGeometry {
62
62
63
63
}
64
64
65
+ setFromPoints ( points ) {
66
+
67
+ // converts a vector3 or vector2 array to pairs format
68
+
69
+ const length = points . length - 1 ;
70
+ const positions = new Float32Array ( 6 * length ) ;
71
+
72
+ for ( let i = 0 ; i < length ; i ++ ) {
73
+
74
+ positions [ 6 * i ] = points [ i ] . x ;
75
+ positions [ 6 * i + 1 ] = points [ i ] . y ;
76
+ positions [ 6 * i + 2 ] = points [ i ] . z || 0 ;
77
+
78
+ positions [ 6 * i + 3 ] = points [ i + 1 ] . x ;
79
+ positions [ 6 * i + 4 ] = points [ i + 1 ] . y ;
80
+ positions [ 6 * i + 5 ] = points [ i + 1 ] . z || 0 ;
81
+
82
+ }
83
+
84
+ super . setPositions ( positions ) ;
85
+
86
+ return this ;
87
+
88
+ }
89
+
65
90
fromLine ( line ) {
66
91
67
92
const geometry = line . geometry ;
You can’t perform that action at this time.
0 commit comments