@@ -187,59 +187,42 @@ THREE.FirstPersonControls = function ( object, domElement ) {
187
187
} ;
188
188
189
189
this . update = function ( delta ) {
190
- var actualMoveSpeed = 0 ;
191
190
192
191
if ( this . freeze ) {
193
192
194
193
return ;
195
194
196
- } else {
197
-
198
- if ( this . heightSpeed ) {
199
-
200
- var y = THREE . Math . clamp ( this . object . position . y , this . heightMin , this . heightMax ) ;
201
- var heightDelta = y - this . heightMin ;
202
-
203
- this . autoSpeedFactor = delta * ( heightDelta * this . heightCoef ) ;
204
-
205
- } else {
206
-
207
- this . autoSpeedFactor = 0.0 ;
195
+ }
208
196
209
- }
197
+ if ( this . heightSpeed ) {
210
198
211
- actualMoveSpeed = delta * this . movementSpeed ;
199
+ var y = THREE . Math . clamp ( this . object . position . y , this . heightMin , this . heightMax ) ;
200
+ var heightDelta = y - this . heightMin ;
212
201
213
- if ( this . moveForward || ( this . autoForward && ! this . moveBackward ) ) this . object . translateZ ( - ( actualMoveSpeed + this . autoSpeedFactor ) ) ;
214
- if ( this . moveBackward ) this . object . translateZ ( actualMoveSpeed ) ;
202
+ this . autoSpeedFactor = delta * ( heightDelta * this . heightCoef ) ;
215
203
216
- if ( this . moveLeft ) this . object . translateX ( - actualMoveSpeed ) ;
217
- if ( this . moveRight ) this . object . translateX ( actualMoveSpeed ) ;
204
+ } else {
218
205
219
- if ( this . moveUp ) this . object . translateY ( actualMoveSpeed ) ;
220
- if ( this . moveDown ) this . object . translateY ( - actualMoveSpeed ) ;
206
+ this . autoSpeedFactor = 0.0 ;
221
207
222
- var actualLookSpeed = delta * this . lookSpeed ;
208
+ }
223
209
224
- if ( ! this . activeLook ) {
210
+ var actualMoveSpeed = delta * this . movementSpeed ;
225
211
226
- actualLookSpeed = 0 ;
212
+ if ( this . moveForward || ( this . autoForward && ! this . moveBackward ) ) this . object . translateZ ( - ( actualMoveSpeed + this . autoSpeedFactor ) ) ;
213
+ if ( this . moveBackward ) this . object . translateZ ( actualMoveSpeed ) ;
227
214
228
- }
215
+ if ( this . moveLeft ) this . object . translateX ( - actualMoveSpeed ) ;
216
+ if ( this . moveRight ) this . object . translateX ( actualMoveSpeed ) ;
229
217
230
- this . lon += this . mouseX * actualLookSpeed ;
231
- if ( this . lookVertical ) this . lat -= this . mouseY * actualLookSpeed ; // * this.invertVertical?-1:1 ;
218
+ if ( this . moveUp ) this . object . translateY ( actualMoveSpeed ) ;
219
+ if ( this . moveDown ) this . object . translateY ( - actualMoveSpeed ) ;
232
220
233
- this . lat = Math . max ( - 85 , Math . min ( 85 , this . lat ) ) ;
234
- this . phi = THREE . Math . degToRad ( 90 - this . lat ) ;
235
- this . theta = THREE . Math . degToRad ( this . lon ) ;
221
+ var actualLookSpeed = delta * this . lookSpeed ;
236
222
237
- var targetPosition = this . target ,
238
- position = this . object . position ;
223
+ if ( ! this . activeLook ) {
239
224
240
- targetPosition . x = position . x + 100 * Math . sin ( this . phi ) * Math . cos ( this . theta ) ;
241
- targetPosition . y = position . y + 100 * Math . cos ( this . phi ) ;
242
- targetPosition . z = position . z + 100 * Math . sin ( this . phi ) * Math . sin ( this . theta ) ;
225
+ actualLookSpeed = 0 ;
243
226
244
227
}
245
228
0 commit comments