Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

arena: fix orbit to not affect physics

Track appliedOrbitOffset and undo it at the start of sim() so the orbit
rotation only affects the render camera position, not the physics simulation.

This prevents the orbit from causing player movement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+14 -2
+14 -2
system/public/aesthetic.computer/disks/arena.mjs
··· 78 78 // without changing player body rotation. Orbits by modifying XZ offset. 79 79 let orbitAngle = 0; // extra Y rotation for camera only (degrees) 80 80 let orbiting = false; // currently dragging with right button 81 + let appliedOrbitOffset = [0, 0]; // track X,Z offset we applied so we can undo it 81 82 82 83 function applyZoom(doll) { 83 84 if (!doll) return; ··· 482 483 const cam = doll?.cam; 483 484 if (!cam) return; 484 485 486 + // Undo any orbit offset we applied last frame so it doesn't affect physics 487 + cam.x -= appliedOrbitOffset[0]; 488 + cam.z -= appliedOrbitOffset[1]; 489 + appliedOrbitOffset[0] = 0; 490 + appliedOrbitOffset[1] = 0; 491 + 485 492 // Always use the *logical* player position (not the render camera) for 486 493 // gameplay state. In 3P mode cam.x/z is offset behind the player. 487 494 const phys = doll?.physics; ··· 689 696 const baseAngle = Math.atan2(dx, dz); 690 697 const orbitRad = orbitAngle * Math.PI / 180; 691 698 const newAngle = baseAngle + orbitRad; 692 - cam.x = pCamX + dist * Math.sin(newAngle); 693 - cam.z = pCamZ + dist * Math.cos(newAngle); 699 + const newX = pCamX + dist * Math.sin(newAngle); 700 + const newZ = pCamZ + dist * Math.cos(newAngle); 701 + // Track what we're adding so we can undo it next frame 702 + appliedOrbitOffset[0] = newX - pCamX - dx; 703 + appliedOrbitOffset[1] = newZ - pCamZ - dz; 704 + cam.x = newX; 705 + cam.z = newZ; 694 706 } 695 707 } 696 708 }