@@ -77,7 +77,6 @@ function vtkCamera(publicAPI, model) {
77
77
78
78
// Internal Functions that don't need to be public
79
79
function computeViewPlaneNormal ( ) {
80
- if ( ! model . viewPlaneNormal ) model . viewPlaneNormal = [ 0 , 0 , 0 ] ;
81
80
// VPN is -DOP
82
81
model . viewPlaneNormal [ 0 ] = - model . directionOfProjection [ 0 ] ;
83
82
model . viewPlaneNormal [ 1 ] = - model . directionOfProjection [ 1 ] ;
@@ -102,7 +101,8 @@ function vtkCamera(publicAPI, model) {
102
101
) {
103
102
return ;
104
103
}
105
- if ( ! model . position ) {
104
+ // Instanciation time
105
+ if ( model . position === undefined ) {
106
106
model . position = defaultValues ( ) . position ;
107
107
}
108
108
@@ -124,7 +124,10 @@ function vtkCamera(publicAPI, model) {
124
124
) {
125
125
return ;
126
126
}
127
-
127
+ // Instanciation time
128
+ if ( model . focalPoint === undefined ) {
129
+ model . focalPoint = defaultValues ( ) . focalPoint ;
130
+ }
128
131
model . focalPoint [ 0 ] = x ;
129
132
model . focalPoint [ 1 ] = y ;
130
133
model . focalPoint [ 2 ] = z ;
@@ -159,10 +162,12 @@ function vtkCamera(publicAPI, model) {
159
162
//----------------------------------------------------------------------------
160
163
// This method must be called when the focal point or camera position changes
161
164
publicAPI . computeDistance = ( ) => {
162
- if ( ! model . position ) {
165
+ // Instanciation time : computeDistance can be called either when model.position
166
+ // or model.focalPoint are undefined
167
+ if ( model . position === undefined ) {
163
168
model . position = defaultValues ( ) . position ;
164
169
}
165
- if ( ! model . focalPoint ) {
170
+ if ( model . focalPoint === undefined ) {
166
171
model . focalPoint = defaultValues ( ) . focalPoint ;
167
172
}
168
173
const dx = model . focalPoint [ 0 ] - model . position [ 0 ] ;
@@ -171,7 +176,7 @@ function vtkCamera(publicAPI, model) {
171
176
172
177
model . distance = Math . sqrt ( dx * dx + dy * dy + dz * dz ) ;
173
178
174
- if ( ! model . directionOfProjection ) {
179
+ if ( model . directionOfProjection === undefined ) {
175
180
model . directionOfProjection = defaultValues ( ) . directionOfProjection ;
176
181
}
177
182
@@ -233,7 +238,6 @@ function vtkCamera(publicAPI, model) {
233
238
) ;
234
239
vec4 . transformMat4 ( viewUpVec4 , viewUpVec4 , rotateMatrix ) ;
235
240
236
- if ( ! model . viewUp ) model . viewUp = defaultValues ( ) . viewUp ;
237
241
model . viewUp [ 0 ] = viewUpVec4 [ 0 ] ;
238
242
model . viewUp [ 1 ] = viewUpVec4 [ 1 ] ;
239
243
model . viewUp [ 2 ] = viewUpVec4 [ 2 ] ;
@@ -242,21 +246,19 @@ function vtkCamera(publicAPI, model) {
242
246
} ;
243
247
244
248
publicAPI . azimuth = ( angle ) => {
245
- const fp = model . focalPoint ? model . focalPoint : defaultValues ( ) . focalPoint ;
249
+ const fp = model . focalPoint ;
246
250
247
251
mat4 . identity ( trans ) ;
248
252
249
253
// translate the focal point to the origin,
250
254
// rotate about view up,
251
255
// translate back again
252
256
mat4 . translate ( trans , trans , fp ) ;
253
- const viewUp = model . viewUp ? model . viewUp : defaultValues ( ) . viewUp ;
254
- mat4 . rotate ( trans , trans , vtkMath . radiansFromDegrees ( angle ) , viewUp ) ;
257
+ mat4 . rotate ( trans , trans , vtkMath . radiansFromDegrees ( angle ) , model . viewUp ) ;
255
258
mat4 . translate ( trans , trans , [ - fp [ 0 ] , - fp [ 1 ] , - fp [ 2 ] ] ) ;
256
259
257
260
// apply the transform to the position
258
- const pos = model . position ? model . position : defaultValues ( ) . position ;
259
- vec3 . transformMat4 ( newPosition , pos , trans ) ;
261
+ vec3 . transformMat4 ( newPosition , model . position , trans ) ;
260
262
publicAPI . setPosition ( newPosition [ 0 ] , newPosition [ 1 ] , newPosition [ 2 ] ) ;
261
263
} ;
262
264
@@ -736,9 +738,7 @@ function vtkCamera(publicAPI, model) {
736
738
let vn = null ;
737
739
let position = null ;
738
740
739
- vn = model . viewPlaneNormal
740
- ? model . viewPlaneNormal
741
- : defaultValues ( ) . viewPlaneNormal ;
741
+ vn = model . viewPlaneNormal ;
742
742
position = model . position ;
743
743
744
744
const a = - vn [ 0 ] ;
0 commit comments