Add bounds to pitch (#12)

* Add bounds to pitch

* run linter
This commit is contained in:
AwesomestCode 2021-02-28 14:02:22 -05:00 committed by GitHub
commit fb1e579ee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -8,6 +8,9 @@ const { WorldView, Viewer } = require('prismarine-viewer/viewer')
global.THREE = require('three')
const chat = require('./lib/chat')
const maxPitch = 0.5 * Math.PI
const minPitch = -0.5 * Math.PI
async function main () {
const viewDistance = 6
const host = prompt('Host', '95.111.249.143')
@ -65,7 +68,9 @@ async function main () {
function moveCallback (e) {
bot.entity.pitch -= e.movementY * 0.01
bot.entity.pitch = Math.max(minPitch, Math.min(maxPitch, bot.entity.pitch))
bot.entity.yaw -= e.movementX * 0.01
viewer.setFirstPersonCamera(bot.entity.position, bot.entity.yaw, bot.entity.pitch)
}
function changeCallback () {

View file

@ -22,9 +22,13 @@
"client"
],
"author": "Romain Beaumont",
"contributors" : [
{"name":"AwesomestCode"},
{"name":"circuit10"}
"contributors": [
{
"name": "AwesomestCode"
},
{
"name": "circuit10"
}
],
"license": "MIT",
"bin": {