Skip to content

Commit fb1e579

Browse files
authored
Add bounds to pitch (#12)
* Add bounds to pitch * run linter
1 parent b6b6579 commit fb1e579

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const { WorldView, Viewer } = require('prismarine-viewer/viewer')
88
global.THREE = require('three')
99
const chat = require('./lib/chat')
1010

11+
const maxPitch = 0.5 * Math.PI
12+
const minPitch = -0.5 * Math.PI
13+
1114
async function main () {
1215
const viewDistance = 6
1316
const host = prompt('Host', '95.111.249.143')
@@ -65,7 +68,9 @@ async function main () {
6568

6669
function moveCallback (e) {
6770
bot.entity.pitch -= e.movementY * 0.01
71+
bot.entity.pitch = Math.max(minPitch, Math.min(maxPitch, bot.entity.pitch))
6872
bot.entity.yaw -= e.movementX * 0.01
73+
6974
viewer.setFirstPersonCamera(bot.entity.position, bot.entity.yaw, bot.entity.pitch)
7075
}
7176
function changeCallback () {

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@
2222
"client"
2323
],
2424
"author": "Romain Beaumont",
25-
"contributors" : [
26-
{"name":"AwesomestCode"},
27-
{"name":"circuit10"}
25+
"contributors": [
26+
{
27+
"name": "AwesomestCode"
28+
},
29+
{
30+
"name": "circuit10"
31+
}
2832
],
2933
"license": "MIT",
3034
"bin": {

0 commit comments

Comments
 (0)