File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -27,16 +27,38 @@ for (var i = 0; i < 100; i++) {
2727 scene . add ( obstacle ) ;
2828}
2929
30- camera . position . z = 5 ;
31-
3230var jumping = false ;
3331var jump_distance = 0.1 ;
3432var acceleration = 0.0025 ;
3533var acceleration_step = 0.0025 ;
3634
35+ var radius = 7 ;
36+ var thetaX = 0 ;
37+ var thetaY = 0 ;
38+ var thetaZ = 0 ;
39+
40+ function degrees_to_radians ( degrees )
41+ {
42+ var pi = Math . PI ;
43+ return degrees * ( pi / 180 ) ;
44+ }
45+
46+ function oscillateCamera ( ) {
47+ thetaX += 0.1 ;
48+ thetaY += 0.05 ;
49+ thetaZ += 0.05 ;
50+
51+ camera . position . x = radius * Math . sin ( degrees_to_radians ( thetaX ) ) ;
52+ camera . position . y = radius * Math . sin ( degrees_to_radians ( thetaY ) ) ;
53+ camera . position . z = 3 + radius * Math . cos ( degrees_to_radians ( thetaZ ) ) ;
54+ camera . lookAt ( scene . position ) ;
55+ }
56+
3757var animate = function ( ) {
3858 requestAnimationFrame ( animate ) ;
3959
60+ oscillateCamera ( ) ;
61+
4062 for ( var i = 0 ; i < obstacles . length ; i ++ ) {
4163 obstacles [ i ] . position . x -= 0.05 ;
4264
You can’t perform that action at this time.
0 commit comments