CoolFace
Apppublic

CyberSys/fruit-fly-simulation

sourceHugging Faceapache-2.0updated 16d agoView on Hugging Face
0likes
camera-config.js27 linesDownload Raw Back to src
1export const CAMERA_FOV = 30;2export const CAMERA_OFFSETS = {3  side: [3.2, -5.7, 1.9],4  top: [0.001, 0, 9],5  follow: [-5.5, -4.8, 2.8],6};7export function cameraFit(view, aspect) {8  return Math.max(1, (view === 'top' ? 1.4 : 1.55) / aspect);9}10export function cameraPullback(pose) {11  return 1 + 0.5 * Math.max(0, Math.min(1, pose.wingOpen || 0));12}13/** Track a point inside the specimen, including its bank, pitch and heading. */14export function cameraTarget(p) {15  const cy = Math.cos(p.yaw),16    sy = Math.sin(p.yaw),17    cp = Math.cos(p.pitch),18    sp = Math.sin(p.pitch),19    cr = Math.cos(p.bank),20    sr = Math.sin(p.bank);21  return [22    p.z - 0.4 * cy * cp + 0.68 * (cy * sp * cr + sy * sr),23    p.x - 0.4 * sy * cp + 0.68 * (sy * sp * cr - cy * sr),24    p.y + 0.4 * sp + 0.68 * cp * cr,25  ];26}27