@@ -108,17 +108,23 @@ class EventHandler {
108108 _this . gameState === "gameLock"
109109 ) {
110110 _this . game . socket . emit ( "move" , _this . controls [ z . code ] , true ) ;
111- if ( _this . controls [ z . code ] === "sprint" ) {
112- var to = {
113- fov : _this . game . fov + 10 ,
114- } ;
115- new TWEEN . Tween ( _this . game . camera )
116- . to ( to , 200 )
117- . easing ( TWEEN . Easing . Quadratic . Out )
118- . onUpdate ( function ( ) {
119- return _this . game . camera . updateProjectionMatrix ( ) ;
120- } )
121- . start ( ) ;
111+ switch ( _this . controls [ z . code ] ) {
112+ case "sprint" :
113+ var to = {
114+ fov : _this . game . fov ,
115+ } ;
116+ new TWEEN . Tween ( _this . game . camera )
117+ . to ( to , 200 )
118+ . easing ( TWEEN . Easing . Quadratic . Out )
119+ . onUpdate ( function ( ) {
120+ return _this . game . camera . updateProjectionMatrix ( ) ;
121+ } )
122+ . start ( ) ;
123+ break ;
124+
125+ case "sneak" :
126+ _this . game . headHeight = 16.7 ;
127+ break ;
122128 }
123129 }
124130 } ) ;
@@ -127,17 +133,23 @@ class EventHandler {
127133 delete _this . keys [ z . code ] ;
128134 if ( _this . controls [ z . code ] !== undefined ) {
129135 _this . game . socket . emit ( "move" , _this . controls [ z . code ] , false ) ;
130- if ( _this . controls [ z . code ] === "sprint" ) {
131- var to = {
132- fov : _this . game . fov ,
133- } ;
134- new TWEEN . Tween ( _this . game . camera )
135- . to ( to , 200 )
136- . easing ( TWEEN . Easing . Quadratic . Out )
137- . onUpdate ( function ( ) {
138- return _this . game . camera . updateProjectionMatrix ( ) ;
139- } )
140- . start ( ) ;
136+ switch ( _this . controls [ z . code ] ) {
137+ case "sprint" :
138+ var to = {
139+ fov : _this . game . fov ,
140+ } ;
141+ new TWEEN . Tween ( _this . game . camera )
142+ . to ( to , 200 )
143+ . easing ( TWEEN . Easing . Quadratic . Out )
144+ . onUpdate ( function ( ) {
145+ return _this . game . camera . updateProjectionMatrix ( ) ;
146+ } )
147+ . start ( ) ;
148+ break ;
149+
150+ case "sneak" :
151+ _this . game . headHeight = 17 ;
152+ break ;
141153 }
142154 }
143155 } ) ;
0 commit comments