@@ -66,6 +66,8 @@ THREE.TrackballCamera = function ( parameters ) {
66
66
var _keyPressed = false ,
67
67
_state = this . STATE . NONE ,
68
68
69
+ _eye = new THREE . Vector3 ( ) ,
70
+
69
71
_rotateStart = new THREE . Vector3 ( ) ,
70
72
_rotateEnd = new THREE . Vector3 ( ) ,
71
73
@@ -117,9 +119,11 @@ THREE.TrackballCamera = function ( parameters ) {
117
119
118
120
}
119
121
122
+ _eye = this . position . clone ( ) . subSelf ( this . target . position ) ;
123
+
120
124
var projection = this . up . clone ( ) . setLength ( mouseOnBall . y ) ;
121
- projection . addSelf ( this . up . clone ( ) . crossSelf ( this . position ) . setLength ( mouseOnBall . x ) ) ;
122
- projection . addSelf ( this . position . clone ( ) . setLength ( mouseOnBall . z ) ) ;
125
+ projection . addSelf ( this . up . clone ( ) . crossSelf ( _eye ) . setLength ( mouseOnBall . x ) ) ;
126
+ projection . addSelf ( _eye . setLength ( mouseOnBall . z ) ) ;
123
127
124
128
return projection ;
125
129
@@ -138,7 +142,7 @@ THREE.TrackballCamera = function ( parameters ) {
138
142
139
143
quaternion . setFromAxisAngle ( axis , - angle ) ;
140
144
141
- quaternion . multiplyVector3 ( this . position ) ;
145
+ quaternion . multiplyVector3 ( _eye ) ;
142
146
quaternion . multiplyVector3 ( this . up ) ;
143
147
144
148
quaternion . multiplyVector3 ( _rotateEnd ) ;
@@ -164,8 +168,7 @@ THREE.TrackballCamera = function ( parameters ) {
164
168
165
169
if ( factor !== 1.0 && factor > 0.0 ) {
166
170
167
- var eye = this . position . clone ( ) . subSelf ( this . target . position ) ;
168
- this . position . add ( this . target . position , eye . multiplyScalar ( factor ) ) ;
171
+ _eye . multiplyScalar ( factor ) ;
169
172
170
173
if ( this . staticMoving ) {
171
174
@@ -187,11 +190,9 @@ THREE.TrackballCamera = function ( parameters ) {
187
190
188
191
if ( mouseChange . lengthSq ( ) ) {
189
192
190
- var factor = this . position . distanceTo ( this . target . position ) * this . panSpeed ;
191
-
192
- mouseChange . multiplyScalar ( factor ) ;
193
+ mouseChange . multiplyScalar ( _eye . length ( ) * this . panSpeed ) ;
193
194
194
- var pan = this . position . clone ( ) . crossSelf ( this . up ) . setLength ( mouseChange . x ) ;
195
+ var pan = _eye . clone ( ) . crossSelf ( this . up ) . setLength ( mouseChange . x ) ;
195
196
pan . addSelf ( this . up . clone ( ) . setLength ( mouseChange . y ) ) ;
196
197
197
198
this . position . addSelf ( pan ) ;
@@ -221,11 +222,9 @@ THREE.TrackballCamera = function ( parameters ) {
221
222
222
223
}
223
224
224
- var eye = this . position . clone ( ) . subSelf ( this . target . position ) ;
225
+ if ( _eye . lengthSq ( ) < this . minDistance * this . minDistance ) {
225
226
226
- if ( eye . lengthSq ( ) < this . minDistance * this . minDistance ) {
227
-
228
- this . position . add ( this . target . position , eye . setLength ( this . minDistance ) ) ;
227
+ this . position . add ( this . target . position , _eye . setLength ( this . minDistance ) ) ;
229
228
230
229
}
231
230
@@ -235,6 +234,8 @@ THREE.TrackballCamera = function ( parameters ) {
235
234
236
235
this . update = function ( parentMatrixWorld , forceUpdate , camera ) {
237
236
237
+ _eye = this . position . clone ( ) . subSelf ( this . target . position ) ,
238
+
238
239
this . rotateCamera ( ) ;
239
240
240
241
if ( ! this . noZoom ) {
@@ -249,6 +250,8 @@ THREE.TrackballCamera = function ( parameters ) {
249
250
250
251
}
251
252
253
+ this . position . add ( this . target . position , _eye ) ;
254
+
252
255
this . checkDistances ( ) ;
253
256
254
257
this . supr . update . call ( this , parentMatrixWorld , forceUpdate , camera ) ;
0 commit comments