Download src/dims.js from DJLougen/moonshot: direct link, hf CLI and curl.
- Browser
- Download file 3.74 kB
-
https://huggingface.co/spaces/DJLougen/moonshot/resolve/main/src/dims.js
- Command line
-
hf download hf://spaces/DJLougen/moonshot/src/dims.js
-
curl -L -o dims.js https://huggingface.co/spaces/DJLougen/moonshot/resolve/main/src/dims.js
3.74 kB
| // dims.js — MOONSHOT canonical field dimensions (REVISION 4). | |
| // PURE: no three.js, no DOM. Single source of truth so the world, the ball | |
| // physics, the pitcher, and the camera all agree on ONE real-scale ballpark. | |
| // Units: meters. 1 ft = 0.3048 m exactly. A real MLB park: 90-ft basepaths, | |
| // 60.5-ft mound, ~400-ft center-field wall. The old 48 m wall + 1.6x distance | |
| // fudge is GONE — feet now read true because the field IS real scale. | |
| export const FT_PER_M = 3.28084; | |
| export const M_PER_FT = 0.3048; | |
| // Outfield wall: 400 ft to center, a touch shorter down the lines (real parks). | |
| export const WALL_FT = 400; | |
| export const FENCE_R = WALL_FT * M_PER_FT; // 121.92 m, center field | |
| export const FENCE_HALF = 1.15; // rad; arc spans the ±45° foul lines | |
| export const WALL_H = 4; // m, wall height (top trim ~4.12) | |
| export const LINE_FT = 340; // foul-line distance | |
| // Infield: 90-ft basepaths → diamond half-diagonal 90/√2 ft = 19.38 m. | |
| export const BASEPATH_FT = 90; | |
| export const D = BASEPATH_FT * M_PER_FT / Math.SQRT2; // 19.38 m; bases (±D,-D), 2B (0,-2D) | |
| // Pitcher's mound: 60 ft 6 in from the plate. | |
| export const MOUND_FT = 60.5; | |
| export const MOUND_Z = -MOUND_FT * M_PER_FT; // -18.44 m | |
| export const MOUND_TOP = 0.25; // m, mound crown height | |
| // Release point: hand at the mound, ~1.85 m up. | |
| export const RELEASE = { x: 0, y: 1.85, z: MOUND_Z }; | |
| // The ringed planet — a real collision target, high over center field. | |
| // Center (10, 95, -210), radius 30 m. A perfectly-timed moonshot can reach it. | |
| export const PLANET = { x: 10, y: 95, z: -210, r: 30 }; | |
| // MOONSHOT billboard — a real collision target above the center-field wall. | |
| // Center (0, 14, -FENCE_R), face 30 m wide × 8 m tall, facing the plate (+z). | |
| export const SIGN = { x: 0, y: 14, z: -FENCE_R, w: 30, h: 8 }; | |
| // Sky dome must enclose the whole park + planet. | |
| export const SKY_R = 520; | |
| export const STAR_R_MIN = 430; | |
| export const STAR_R_MAX = 500; | |
| // --------------------------------------------------------------------------- | |
| // Grandstand deck (R27 crowd collision). The crowd sits on a stepped ring | |
| // sector behind the wall. These mirror buildCrowd()'s deck profile EXACTLY so | |
| // the ball slice and the world slice agree on ONE collision surface. PURE. | |
| // --------------------------------------------------------------------------- | |
| export const STANDS_R_IN = FENCE_R + 2; // 123.92 m, deck front face | |
| export const STANDS_ROWS = 6; // bench rows | |
| export const STANDS_TREAD = 1.7; // m, radial tread depth | |
| export const STANDS_RISER = 1.27; // m, rise per row | |
| export const STANDS_BASE = 4.3; // m, deck starts this high | |
| export const STANDS_R_OUT = STANDS_R_IN + STANDS_TREAD * STANDS_ROWS; // 134.12 m | |
| export const STANDS_CAP_R = STANDS_R_OUT + 0.5; // 134.62 m, back skirt | |
| export const STANDS_CAP_Y = STANDS_BASE + STANDS_RISER * STANDS_ROWS + 0.4; // 12.32 m | |
| export const CROWD_HEAD = 1.0; // m, fan head above the tread | |
| // Top surface of the grandstand deck (where fans' feet rest) at horizontal | |
| // radius rho. Stepped: each tread is STANDS_RISER higher than the last. On the | |
| // back cap returns STANDS_CAP_Y; in front of the deck returns STANDS_BASE (the | |
| // front-face top). Callers gate on the arc + rho >= STANDS_R_IN themselves. | |
| export function standsDeckY(rho) { | |
| if (rho >= STANDS_R_OUT) return STANDS_CAP_Y; | |
| if (rho < STANDS_R_IN) return STANDS_BASE; | |
| const row = Math.min(STANDS_ROWS - 1, Math.floor((rho - STANDS_R_IN) / STANDS_TREAD)); | |
| return STANDS_BASE + STANDS_RISER * (row + 1); | |
| } | |