3D Physics Engine & PSX Shaders

PSX Retro 3D Beyblade Arena

A high-fidelity client-side 3D retro arcade combat simulator running on WebGL with analytical paraboloid bowl physics, custom PSX shaders (Bayer 8x8 dithering, RGB555 quantization), and procedural tops.

Three.jsWebGLGLSL ShadersWeb Audio APIViteTypeScript

Code Specs

Bundle Size 165 KB gzip
Est. LOC 7,421 lines
Deps 1 npm pkg (three)
Languages
TypeScript 88%
GLSL / Shaders 7%
CSS 5%

Experiment Objective

To engineer a deterministic client-side 3D combat physics engine ($y(r)=1.8(r/10)^2$) with 120Hz substepping, dynamic impulse collisions, and authentic 32-bit PSX post-processing shaders with zero backend dependencies.

Telemetry & Metrics

Gemini 3.8 Flash High AI Model
teamwork-preview Orchestrator Mode
54m 59s Autonomous Dev Time
14 Agents Subagent Fleet
293/293 Pass (66ms) E2E Test Suite
120 Hz Fixed Physics Loop Rate

Live Simulator / Console

psx-beyblade-arena_preview.sh
$ agy swarm --model gemini-3.8-flash-high --mode teamwork-preview
✓ 14 subagents dispatched across 6 milestones (M1–M6)
$ node tests/runner.js
✔ 293 / 293 tests passed (66.35ms) · 0 stubs
ℹ 120Hz paraboloid physics & PSX Bayer 8x8 shaders loaded
Gemini 3.8 Flash High
teamwork-preview
54m 59s
14 Agents
293 Pass (66ms)

Autonomous multi-agent lifecycle telemetry: Gemini 3.8 Flash High executing under Antigravity SDK teamwork-preview mode with 293 verified test suites.

Environment & Runtime

Host Platform Firebase Hosting (Static CDN Edge)
Orchestrator Google Antigravity SDK (teamwork-preview swarm)
Engine / Language Gemini 3.8 Flash High (14 Autonomous Agents)
Context / Isolation Sandboxed Iframe & Fixed-Step 120Hz Loop

Key Features

  • ⚡ Autonomous 14-Agent Fleet: Dispatched via Google Antigravity SDK in teamwork-preview mode; completed in 54m 59s with 0 human code intervention.
  • ⚡ Analytical Paraboloid Dish Physics: Gravitational slide F_inward = mg*sinθ*cosθ on curved dish y(r)=1.8(r/10)^2 with 3 knockout perimeter chutes at 0°, 120°, and 240°.
  • ⚡ Impulse Clash Momentum Resolution: Elastic/inelastic impulse exchange with guard dampening (-65% spin loss) and Overdrive 1.5x surge.
  • ⚡ Custom PSX Retro Post-Processing: UV downsampling to 480x270, Bayer 8x8 threshold matrix dithering, 15-bit RGB555 color quantization, CRT barrel distortion, and scanlines.
  • ⚡ Procedural 4-Layer 3D Tops: Ember Wyrm (Attack, 雷) and Rook (Defense, 鬼) built procedurally with Bit Chip, Attack Ring, Weight Disk, and Blade Base with dynamic clash spark particles.
  • ⚡ Timed Launch Sequence & Gold Perfect Zone: Hold-and-release power meter with strict [84%, 94%] Gold Zone granting +25% RPM bonus (5000 RPM) and 12 m/s forward surge.
  • ⚡ Dual-Layer Audio Architecture: 13 bundled 16-bit PCM WAV audio samples with dynamic pitch-modulated RPM spinning drone and polyphonic limiter.

Core Hypothesis & Outcomes

Demonstrates that analytical paraboloid dish physics ($y(r)=1.8(r/10)^2$) with 120Hz substepping and impulse momentum collision resolution ($J_n = \frac{(1+e)v_{rel}}{m_1^{-1} + m_2^{-1}}$) can achieve locked 60 FPS in WebGL with authentic PSX Bayer 8x8 dithering and RGB555 quantization, passing 293/293 automated E2E tests in 66ms with zero runtime backend.

Autonomous Multi-Agent Synthesis · Technical Report
Gemini 3.8 Flash High Google Antigravity SDK teamwork-preview swarm 54m 59s autonomous

Autonomous Provenance: Zero-Human Combat Engine

Technical provenance and architecture analysis of the end-to-end development of PSX Retro 3D Beyblade Arena. Powered by Gemini 3.8 Flash High and orchestrated via the Google Antigravity SDK in teamwork-preview multi-agent swarm mode, the engine was built from an empty folder to a locked 60 FPS 3D combat simulator with 293/293 verified tests in 54 minutes and 59 seconds without external physics libraries.

AI Model & Reasoning Gemini 3.8 Flash High High-speed inference + multi-agent parallel execution
Autonomous Tool & Mode Antigravity SDK teamwork-preview swarm mode (DAG orchestrated)
Total Dev Duration 54m 59s 19:10:01Z dispatch → 20:05:00Z victory audit
Subagent Swarm Fleet 14 Agents Orchestrator, Explorers, TDD, Reviewers, Challengers
Test Verification Suite 293 / 293 Pass 100% assertions green in 66.35 ms (0 stubs)
Engine Scale & Deps 7,421 LOC 1 npm pkg (Three.js WebGL) · 0 physics engines

1. The AI Model & Swarm Orchestration Engine

Building a deterministic 3D combat physics engine with custom GLSL post-processing typically demands days of manual mathematics, shader tuning, and audio engineering. In this lab, the entire system was synthesized autonomously by Gemini 3.8 Flash High operating inside the Google Antigravity SDK under the teamwork-preview swarm paradigm.

Unlike traditional monolithic single-agent systems that accumulate context bloat and hallucinate when refactoring large codebases, teamwork-preview partitions the mission into an explicit Directed Acyclic Graph (DAG) of specialized subagents. Gemini 3.8 Flash High was selected for its ultra-rapid inference speed and exceptional mathematical reasoning, allowing subagents to draft, peer-review, and challenge milestone deliverables with sub-second turnaround.

⚡ Why teamwork-preview over Monolithic Coding Agents?

Single agents often introduce regressions or erase working physics when addressing subsequent features. In teamwork-preview swarm mode, Antigravity isolates subagents into sandboxed roles. Milestone workers cannot merge code until an adversarial Challenger attempts to break collision boundaries with extreme inputs (10,000 RPM, 50 m/s), and an independent Reviewer validates zero dummy stubs and strict TypeScript type integrity.

2. Zero-Dependency Analytical Physics Engine

The swarm operated under a strict zero-dependency physics requirement (0 Ammo.js, 0 Cannon.js, 0 Rapier). The mathematical core was derived and implemented directly in pure TypeScript with a 120Hz fixed-step physics integration loop:

Paraboloid Dish Geometry y(r) = 1.8 · (r / 10)²   ∀ r ∈ [0, 10]
Curvature Normal & Inward Force tan(θ) = dy/dr = 0.036 r  ⇒  F_inward = m · g · sin(θ) cos(θ)
Impulse Clash Momentum Resolution J_n = - [ (1 + e) · (Δv · n̂) ] / [ 1/m_1 + 1/m_2 ]  ⇒  Δv_1 = (J_n n̂) / m_1,   Δv_2 = -(J_n n̂) / m_2
PSX RGB555 Color Quantization C_quant = floor(C_in · 31.0 + 0.5) / 31.0   (15-bit RGB color depth)
Bayer 8×8 Matrix Dithering D(x, y) = [ M_8x8(x mod 8, y mod 8) / 64.0 ] - 0.5  ⇒  C_final = C_quant + D(x, y)

This analytical formulation delivers absolute determinism, completely eliminates numerical tunneling through bowl boundaries, and executes with sub-millisecond overhead per frame.

3. The 14-Agent Autonomous Fleet Hierarchy

During the 54m 59s run, the Antigravity SDK instantiated and coordinated 14 specialized subagent instances across distinct lifecycle stages:

Agent Instance Lifecycle Role Subagent Specialization & Deliverables Exit Gate Criteria
orchestrator_1 Swarm Director Structured the project into 6 milestones (M1–M6); coordinated DAG execution, branch merging, and gate validation. All M1–M6 gates verified
explorer_survey_1..3 Hardware & API Researchers Researched PSX GPU hardware limitations (RGB555 15-bit color, Bayer 8×8 dithering), Web Audio synthesis nodes. Approved architectural spec
test_writer_1 TDD Protocol Architect Authored the comprehensive 293-test assertion suite across 5 verification tiers prior to writing engine code. 293 red-state test suite
worker_m1 M1: Dish Geometry & Gravity Implemented paraboloid arena mesh generator, slope gradient vectors, and analytical gravity sliding force equations. Tier 1 tests pass (120/120)
worker_m2 M2: Impulse Clash & Chutes Built 120Hz substepping loop, dynamic collision restitution, angular friction decay, and 3 knockout chutes. Tier 2 tests pass (105/105)
worker_m3 M3: Procedural 3D Tops Constructed 4-layer procedural 3D tops (Ember Wyrm & Rook) with Bit Chip, Attack Ring, and GPU spark particles. Tier 3 tests pass (15/15)
worker_m4 M4: Retro PSX Shaders Authored custom GLSL post-processing pipeline: Bayer 8×8 dithering, 15-bit RGB555 quantization, CRT scanlines. Tier 4 tests pass (5/5)
worker_m5 M5: Web Audio Sound Engine Synthesized 13 procedural 16-bit PCM WAV audio samples with dynamic pitch-modulated RPM drone and limiter. Tier 5 tests pass (30/30)
worker_m6 M6: Launch Power & HUD Implemented hold-to-launch power meter with Gold Perfect Zone ([84%, 94%]), rounds HUD, and victory state loop. Full battle loop green
reviewer_m1_1..2 Adversarial Static Review Enforced strict TypeScript types, 0 any casts, 0 dummy stubs, and proper Three.js geometry/material deallocation. 100% clean linter report
challenger_m1_1..2 Adversarial Boundary Fuzzer Subjected collision solver to extreme velocity spikes (10,000 RPM, 50 m/s) to ensure zero mesh penetration/tunneling. Zero boundary clipping
victory_auditor_1 Final E2E Victory Auditor Executed clean build, verified bundle size (165 KB gzip), and ran complete test suite (293/293 passing in 66.35ms). Final release sign-off

4. Real-Time Autonomous Timeline

Forensic log timestamps recorded during the autonomous swarm execution from initial dispatch to victory sign-off:

19:10:01Z
Swarm Dispatch & DAG Initialization

orchestrator_1 booted; parsed specification and assigned parallel research tasks to 3 explorer subagents.

19:18:22Z
M1 Paraboloid Dish & Gravity Physics Verified

worker_m1 authored 120-step physics equations; reviewer_m1_1 signed off on analytical slope math.

19:27:45Z
M2 Collision Restitution & Chute Ejection Passed

worker_m2 resolved dynamic impulse transfer; challenger_m1_1 tested extreme speed collisions with 0 tunneling.

19:35:10Z
M3 Procedural 4-Layer Mesh Tops Assembled

worker_m3 generated Ember Wyrm and Rook meshes with GPU spark particle emitters.

19:44:30Z
M4 PSX Retro Shaders & Dithering Matrix Applied

worker_m4 built GLSL pipeline with 15-bit RGB555 quantization and Bayer 8×8 threshold matrix.

19:53:15Z
M5 Web Audio Dual-Layer Sound & Limiter Active

worker_m5 authored 13 audio clips and continuous RPM pitch modulation.

20:00:40Z
M6 Gold Perfect Zone & Combat HUD Online

worker_m6 completed launch power gauge and round transition state machine.

20:05:00Z
Audit Victory: 293/293 Tests Passing (54m 59s Total)

victory_auditor_1 verified all 5 test tiers in 66.35ms; production build bundled into 165 KB gzip.

5. 5-Tier Test Verification Matrix

Under Test-Driven Development (TDD), test_writer_1 authored 293 unit, integration, and physics assertions before code implementation. The test suite executed in 66.35 ms:

Tier 1 Unit & Analytical Physics 120 / 120 Pass

Validates paraboloid dish curvature y(r)=1.8(r/10)², gravity gradient slope, radial deceleration, kinetic surface friction, and angular spin decay.

Tier 2 Impulse Clash & Boundary Dynamics 105 / 105 Pass

Verifies normal impulse momentum J_n, restitution coefficient e, guard dampening (-65% spin loss), Overdrive 1.5x surge, and chute knockout ejection.

Tier 3 Procedural 3D Geometry Hierarchy 15 / 15 Pass

Checks Bit Chip, Attack Ring, Weight Disk, and Blade Base mesh grouping, material assignment, and dynamic clash spark emitter pooling.

Tier 4 PSX GLSL Post-Processing Pipeline 5 / 5 Pass

Tests framebuffer resolution downscaling (480×270), Bayer 8×8 matrix texture bindings, 15-bit RGB555 truncation, and CRT barrel warp shader uniformity.

Tier 5 Web Audio & Round Lifecycle 30 / 30 Pass

Ensures 13 PCM WAV clip buffers, dynamic RPM audio pitch mapping, polyphonic limiter voice capping, Gold Perfect Zone [84%, 94%], and round reset logic.

6. Synthesis & Key Takeaways

Speed with Mathematical Determinism

By pairing Gemini 3.8 Flash High's ultra-low time-to-first-token with strict mathematical formulas rather than fuzzy approximations, the swarm produced a 120Hz physics engine that runs without glitches, clipping, or instability.

Adversarial Swarm Quality Gates

The inclusion of dedicated reviewer and challenger agents in the teamwork-preview mode eliminated the common failure mode of AI coding assistants: declaring victory with broken stubs or untested corner cases.

Zero Backend Footprint

The entire 7,421-line application runs natively in client-side WebGL, requiring 0 servers, 0 database writes, and only 165 KB of gzipped static assets delivered from Firebase CDN edge nodes.