Spaces:
Running
Running
Download src/camera-config.js from lordhet/fruit-fly-simulation: direct link, hf CLI and curl.
- Browser
- Download file 808 Bytes
-
https://huggingface.co/spaces/lordhet/fruit-fly-simulation/resolve/main/src/camera-config.js
- Command line
-
hf download hf://spaces/lordhet/fruit-fly-simulation/src/camera-config.js
-
curl -L -o camera-config.js https://huggingface.co/spaces/lordhet/fruit-fly-simulation/resolve/main/src/camera-config.js
808 Bytes
| export const CAMERA_FOV = 30; | |
| export const CAMERA_OFFSETS = { | |
| side: [3.2, -5.7, 1.9], | |
| top: [0.001, 0, 9], | |
| follow: [-5.5, -4.8, 2.8], | |
| }; | |
| export function cameraFit(view, aspect) { | |
| return Math.max(1, (view === 'top' ? 1.4 : 1.55) / aspect); | |
| } | |
| export function cameraPullback(pose) { | |
| return 1 + 0.5 * Math.max(0, Math.min(1, pose.wingOpen || 0)); | |
| } | |
| /** Track a point inside the specimen, including its bank, pitch and heading. */ | |
| export function cameraTarget(p) { | |
| const cy = Math.cos(p.yaw), | |
| sy = Math.sin(p.yaw), | |
| cp = Math.cos(p.pitch), | |
| sp = Math.sin(p.pitch), | |
| cr = Math.cos(p.bank), | |
| sr = Math.sin(p.bank); | |
| return [ | |
| p.z - 0.4 * cy * cp + 0.68 * (cy * sp * cr + sy * sr), | |
| p.x - 0.4 * sy * cp + 0.68 * (sy * sp * cr - cy * sr), | |
| p.y + 0.4 * sp + 0.68 * cp * cr, | |
| ]; | |
| } | |