How We Built a 60fps 3D Rigid-Body Pinball & Marble Arcade in WebGL (Playable in Browser & iOS/Android)
When you set out to build a 3D mechanical pinball and marble arcade game for mobile browsers, iOS, and Android, the conventional wisdom is to reach for a heavy native engine, ship a 400 MB binary, and hide behind pre-baked animations whenever dozens of spheres collide at once. But for SmartBall Hall V4.0.1—our tribute to 1978 Japanese wooden SmartBall cabinets—we wanted two seemingly contradictory things at the exact same time:
- Instant 3-second cold boot in any mobile or desktop WebGL browser with zero login friction; and
- Uncompromising 60fps rigid-body collision physics capable of handling 5-marble multi-ball volleys, moving butterfly wings, spinning 3-hole funnels, and a 600-marble jackpot waterfall without a single tunnelled pin or stuck ball.
Here is a technical look under the hood at how we engineered our physics loop, brass-pin geometry, procedural metallic ASMR, and cross-platform Web-to-App carryover architecture.
1. Solving the Tunneling Problem: 10-Substep Rigid-Body Integration
In a flipperless 1978 SmartBall cabinet, gameplay integrity lives or dies by micro-collisions. When a player pulls the spring-loaded brass plunger to 71% vs. 74%, the marble launches up a curved arch rail at high velocity and drops into a dense lattice of 3mm brass pins. At a naive 60Hz single-step update (dt = 16.67ms), a fast-moving 22px-equivalent sphere can easily step halfway through a thin brass pin or moving gate segment, causing unnatural velocity spikes or tunneling right through pocket rims.
Instead of importing a bloated general-purpose WASM physics engine, we wrote a specialized, cache-friendly solver running SUBSTEPS = 10 per render frame (an effective 600Hz physics tick rate) paired with seeded mulberry32 determinism where needed. During each substep, dynamic mechanical segments—such as Table NO.02's interpolating emerald butterfly wings (openProgress: 0.0 ➔ 1.0), Table NO.04's rotating wheel pockets, and Table NO.05's rising 24K Golden Stopper Bar—update their exact line-segment normals and impart true angular velocity and tangential friction to colliding marbles.
2. The "Symmetric Pin Engine": Mathematically Zero Ball Jams
Early playtests taught us a painful lesson real 1970s cabinet makers knew well: if two brass pins sit even slightly closer than a marble's diameter, or if an upper arch pin sits too close to the curved outer rail, a heavy marble will eventually wedge itself dead on the playfield. Worse, even a 1-pixel left-right asymmetry makes skilled players feel the board is "tilted."
To eliminate both issues permanently, we built a dedicated Symmetric Pin Engine with strict geometric invariants:
- 100% Mirror-Axis Symmetry: Every non-center pin is generated as an exact mirrored pair across the playfield centerline (zero orphan asymmetric pins).
- Guaranteed Clearance Invariant: For a
22.0pxmarble diameter, center-to-center spacing between any two pins is strictly enforced at>= 27.5px, and top-arch pins maintain a Euclidean clearance of>= 30.0pxfrom the arch rail segments. - Live Marble-as-Bumper Physics: On Table NO.02's Twin-Holdockets, when the first marble drops in, it flags
ball.isHeld = trueand converts into a live static rigid-body collider at the pocket center—physically deflecting subsequent marbles toward its sister pocket until both lock and burst out 15 bonus marbles!
3. Crystal Marble Shaders & Low-Latency Metallic ASMR
Visual and acoustic tactile feedback is half the magic of a physical arcade hall. In Version 4.0.1, we upgraded our Three.js rendering pipeline (`Spectacle3DRenderer` & `ballRenderer`) so Sapphire Glass, 3x Crimson Ruby, Magnetic Jade, and 18.1g 24K Gold marbles catch warm overhead showroom spotlights without tanking mobile GPU fill-rate—and when a player hits a table's goal, a 3D Mount Fuji eruption and celebratory Japanese fireworks accompany the 600-marble cascade.
On the audio side, playing 40 overlapping MP3 samples during a 600-marble waterfall quickly chokes mobile browser audio threads. By synthesizing pitch-varied brass-pin pings, hardwood rolling resonance, and solenoid clacks through WebAudio alongside coupled micro-screen-shake haptics (`55ms` damped canvas translation), every collision feels crisp, immediate, and deeply relaxing with headphones on.
4. Seamless WebGL-to-Native Carryover Without Forced Accounts
Because we wanted zero registration walls, players who start on our instant WebGL build (`smartball.jp/play/`) can transfer their exact earned marble and ticket balance into the native Capacitor-powered iOS (`v4.0.1 Build 43`) and Android (`v4.0.1 Code 40`) apps using a signed, 15-minute cryptographic carryover code (`FNV-1a` dual-hash signature)—and zero bottom banner ads ever get in the way of your thumb. Give the live WebGL build a spin below and tell us what you think of the physics!