Skip to content

Commit 914099b

Browse files
committed
dynamic FOV
1 parent 492127c commit 914099b

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

coffee/client/module/FirstPersonControls.coffee

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class FirstPersonControls
1515
@canvas=options.canvas
1616
@camera=options.camera
1717
@socket=options.socket
18+
@TWEEN=options.TWEEN
1819
@setState "menu"
1920
@listen()
2021
updatePosition: (e)->
@@ -67,6 +68,14 @@ class FirstPersonControls
6768
#Wysyłanie state'u do serwera
6869
if _this.kc[z.keyCode] isnt undefined and _this.gameState is "gameLock"
6970
_this.socket.emit "move",_this.kc[z.keyCode],true
71+
if _this.kc[z.keyCode] is "sprint"
72+
to={fov:105}
73+
new _this.TWEEN.Tween _this.camera
74+
.to to, 200
75+
.easing _this.TWEEN.Easing.Quadratic.Out
76+
.onUpdate ()->
77+
_this.camera.updateProjectionMatrix()
78+
.start()
7079
return
7180
$(document).keyup (z) ->
7281
#Odkliknięcie
@@ -75,6 +84,14 @@ class FirstPersonControls
7584
#Wysyłanie state'u do serwera
7685
if _this.kc[z.keyCode] isnt undefined
7786
_this.socket.emit "move",_this.kc[z.keyCode],false
87+
if _this.kc[z.keyCode] is "sprint"
88+
to={fov:95}
89+
new _this.TWEEN.Tween _this.camera
90+
.to to, 200
91+
.easing _this.TWEEN.Easing.Quadratic.Out
92+
.onUpdate ()->
93+
_this.camera.updateProjectionMatrix()
94+
.start()
7895

7996
return
8097
$(".gameOn").click ->

coffee/client/module/index.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ init = ()->
2020
PixelRatio:window.devicePixelRatio
2121
}
2222
scene=new THREE.Scene
23-
camera = new THREE.PerspectiveCamera 100, 2, 0.1, 1000
23+
camera = new THREE.PerspectiveCamera 95, 2, 0.1, 1000
2424
camera.rotation.order = "YXZ"
2525
camera.position.set 26, 26, 26
2626

@@ -60,6 +60,7 @@ init = ()->
6060
camera
6161
micromove: 0.3
6262
socket
63+
TWEEN
6364
}
6465

6566
#Czat

src/client/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ <h1 class="loadingText">Ładowanie zasobów...</h1>
102102
<div class="inv_bar"></div>
103103

104104
</div>
105-
105+
106106
<!-- INVENTORY WINDOW -->
107107
<div class="inv_window"></div>
108108

@@ -142,6 +142,9 @@ <h3>Gra zatrzymana</h3>
142142
<li>
143143
<button>R</button> sprint
144144
</li>
145+
<li>
146+
<button>E</button> ekwipunek
147+
</li>
145148
<li>
146149
<button>Spacja</button> skakanie
147150
</li>

src/client/module/FirstPersonControls.js

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/module/index.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)