@@ -67,6 +67,8 @@ function vtkLineGlyphRepresentation(publicAPI, model) {
67
67
source : publicAPI ,
68
68
glyph : vtkCylinderSource . newInstance ( {
69
69
direction : [ 1 , 0 , 0 ] ,
70
+ center : [ 0.5 , 0 , 0 ] ,
71
+ capping : false ,
70
72
} ) ,
71
73
mapper : vtkGlyph3DMapper . newInstance ( {
72
74
orientationArray : 'directions' ,
@@ -111,13 +113,21 @@ function vtkLineGlyphRepresentation(publicAPI, model) {
111
113
3
112
114
) . getData ( ) ;
113
115
114
- const pos = [ ] ; // scratch
116
+ const tempVector = [ ] ; // scratch
115
117
for ( let point = 1 ; point < lines . length - 1 ; point ++ ) {
118
+ const glyph = ( point - 1 ) * 3 ; // start of glyph's 3 components in the arrays
119
+
120
+ // With cylinder glyph's offset center, position at state origins.
121
+ const origin = points [ lines [ point ] ] ;
122
+ [
123
+ glyphPositions [ glyph ] ,
124
+ glyphPositions [ glyph + 1 ] ,
125
+ glyphPositions [ glyph + 2 ] ,
126
+ ] = origin ;
127
+
116
128
// Orient glyphs to next point.
117
- const eye = points [ lines [ point ] ] ;
118
129
const target = points [ lines [ point + 1 ] ] ;
119
- const direction = vtkMath . subtract ( target , eye , pos ) ;
120
- const glyph = ( point - 1 ) * 3 ;
130
+ const direction = vtkMath . subtract ( target , origin , tempVector ) ;
121
131
[ directions [ glyph ] , directions [ glyph + 1 ] , directions [ glyph + 2 ] ] =
122
132
direction ;
123
133
@@ -126,16 +136,6 @@ function vtkLineGlyphRepresentation(publicAPI, model) {
126
136
lengths [ glyph ] = distance ;
127
137
lengths [ glyph + 1 ] = 1 ;
128
138
lengths [ glyph + 2 ] = 1 ;
129
-
130
- // Position glyph at center of line segment.
131
- vec3 . normalize ( pos , direction ) ;
132
- vec3 . scale ( pos , pos , distance / 2 ) ;
133
- vec3 . add ( pos , eye , direction ) ;
134
- [
135
- glyphPositions [ glyph ] ,
136
- glyphPositions [ glyph + 1 ] ,
137
- glyphPositions [ glyph + 2 ] ,
138
- ] = pos ;
139
139
}
140
140
141
141
internalPolyData . getPoints ( ) . modified ( ) ;
0 commit comments