@@ -78,9 +78,7 @@ function threeRender()
7878 if ( threeCanvas . style . cssText != LJS . mainCanvas . style . cssText )
7979 threeCanvas . style . cssText = LJS . mainCanvas . style . cssText ;
8080
81- // fixed offset chase camera, smoothly following the player
82- const eye = new THREE . Vector3 ( player . pos . x , player . pos . y , player . zPos ) . add ( cameraOffset ) ;
83- camera . position . lerp ( eye , cameraLerp ) ;
81+ // aim at the player and render
8482 camera . lookAt ( player . pos . x , player . pos . y , player . zPos + 1 ) ;
8583 renderer . render ( scene , camera ) ;
8684}
@@ -272,11 +270,15 @@ function gameInit()
272270 }
273271
274272 // start with the camera behind the player
275- camera . position . set ( player . pos . x , player . pos . y - 9 , 6 ) ;
273+ camera . position . set ( player . pos . x , player . pos . y , player . zPos ) . add ( cameraOffset ) ;
276274}
277275
278276function gameUpdate ( )
279277{
278+ // fixed offset chase camera, smoothly following the player
279+ // updated at the fixed 60 fps rate so the feel is refresh rate independent
280+ const eye = new THREE . Vector3 ( player . pos . x , player . pos . y , player . zPos ) . add ( cameraOffset ) ;
281+ camera . position . lerp ( eye , cameraLerp ) ;
280282}
281283
282284function gameUpdatePost ( )
0 commit comments