Skip to content

Commit

Permalink
add lint-fix script
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jan 27, 2025
1 parent ccc1d76 commit 6d91ad3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"prod-start": "node server.js --prod",
"test-mc-server": "tsx cypress/minecraft-server.mjs",
"lint": "eslint \"{src,cypress,prismarine-viewer}/**/*.{ts,js,jsx,tsx}\"",
"lint-fix": "pnpm lint --fix",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build && node scripts/build.js moveStorybookFiles",
"start-experiments": "vite --config experiments/vite.config.ts --host",
Expand Down
19 changes: 9 additions & 10 deletions src/mineflayer/cameraShake.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { downloadSoundsIfNeeded } from '../soundSystem'
import * as THREE from 'three'

class CameraShake {
private rollAngle = 0
private damageRollAmount = 5
private damageAnimDuration = 200
private get damageRollAmount () { return 5 }
private get damageAnimDuration () { return 200 }
private rollAnimation?: { startTime: number, startRoll: number, targetRoll: number, duration: number, returnToZero?: boolean }

constructor() {
constructor () {
this.rollAngle = 0
}

shakeFromDamage() {
shakeFromDamage () {
// Add roll animation
const startRoll = this.rollAngle
const targetRoll = startRoll + (Math.random() < 0.5 ? -1 : 1) * this.damageRollAmount
Expand All @@ -24,7 +23,7 @@ class CameraShake {
}
}

update() {
update () {
// Update roll animation
if (this.rollAnimation) {
const now = performance.now()
Expand Down Expand Up @@ -54,7 +53,7 @@ class CameraShake {
}

// Apply roll in camera's local space to maintain consistent left/right roll
const camera = viewer.camera
const { camera } = viewer
const rollQuat = new THREE.Quaternion()
rollQuat.setFromAxisAngle(new THREE.Vector3(0, 0, 1), THREE.MathUtils.degToRad(this.rollAngle))

Expand All @@ -67,12 +66,12 @@ class CameraShake {
camera.setRotationFromQuaternion(finalQuat)
}

private easeOut(t: number): number {
private easeOut (t: number): number {
return 1 - (1 - t) * (1 - t)
}

private easeInOut(t: number): number {
return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2
private easeInOut (t: number): number {
return t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/react/Singleplayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export default ({
{...rest}
size={size}
name={name}
elemRef={el => worldRefs.current[name] = el}
elemRef={el => { worldRefs.current[name] = el }}
onFocus={row => onRowSelectHandler(row, index)}
isFocused={focusedWorld === name}
key={name}
Expand Down

0 comments on commit 6d91ad3

Please sign in to comment.