Skip to content

Commit

Permalink
Merge pull request #122 from RuneLabsxyz/logging-stuff
Browse files Browse the repository at this point in the history
feat: add some logging
  • Loading branch information
0xMugen authored Oct 9, 2024
2 parents 618a12e + f22caf2 commit 145e516
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 10 additions & 3 deletions client/src/lib/3d/Scene.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@
const animationLoop = () => {
try {
if ($birdView) {
if (birdViewCamera) {
if (birdViewCamera && birdViewCamera.isCamera) {
resetCamera(birdViewCamera, renderer)
renderer.render(scene, birdViewCamera)
if (scene && scene.isScene) {
renderer.render(scene, birdViewCamera)
}
}
} else {
renderCameras(cameras, numCameras, renderer, scene)
if (cameras.length > 0 && cameras.every(cam => cam && cam.isCamera)) {
renderCameras(cameras, numCameras, renderer, scene)
}
}
if ($recordingMode) {
Expand All @@ -94,6 +98,9 @@
animationFrameId = requestAnimationFrame(animationLoop)
} catch (error) {
console.error('Error in animation loop:', error)
if (error instanceof TypeError && error.message.includes('byteLength')) {
console.warn('Possible issue with buffer or geometry.')
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions client/src/lib/3d/utils/shootUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ function applyBulletToStore(newBullet: BulletCoords) {
}

export function shoot(camera: PerspectiveCamera) {
if (!camera || !camera.isCamera) {
console.error('Invalid camera object')
return
}

let move_index = Math.floor(get(frameCounter) / 3)

let direction = getYawAngle(camera)
Expand All @@ -47,6 +52,10 @@ export function shoot(camera: PerspectiveCamera) {
)

recordedMove.update((rm) => {
if (!rm || !Array.isArray(rm.shots)) {
console.error('Invalid recordedMove structure')
return rm
}
rm.shots.push({ angle: direction, step: move_index })
console.log(rm.shots)
return rm
Expand Down

0 comments on commit 145e516

Please sign in to comment.