Inspiration

Most people don't struggle with physics because they're bad at algebra,they struggle because static diagrams in textbooks don't move. When a book draws an arrow on a block or a frozen sine wave, you can't feel what happens when you double the mass, pull the spring down twice as far, or tilt a ramp steeper.

We wanted to build something that feels like standing at a real lab bench with a tutor: you ask a question, a 3D experiment appears, and you can actually grab the objects, pull them out of equilibrium, and watch the equations and graphs respond right beside the apparatus.

What it does

Labit turns physics questions into interactive 3D experiments paired with a step-by-step tutor and live math:

  • Ask any question or launch a core lab: Covers spring oscillations (Hooke's law), elastic cart collisions, transverse waves, inclined planes, projectile motion, simple pendulums, and orbital mechanics plus custom 3D scene generation for open-ended questions.
  • Direct 3D manipulation (not just sliders): Click any object in the 3D viewport to move (G) or rotate (R) it directly with a 3D gizmo. Pull the 100g mass on the spring to set its amplitude, tilt the inclined plane to change downhill acceleration, or drag a satellite inward to speed up its orbit.
  • Multi-object editing (Shift + click): Hold Shift to select multiple objects at once, transform the whole group around a shared pivot, or adjust group mass and height together.
  • Non-overlapping equations & live data: The explanation, governing equations, numeric readouts, and real-time energy/momentum charts stay docked beside the 3D stage so nothing blocks your view of the physics.

How we built it

  • 3D Rendering & Procedural Apparatus (Three.js): Built with OrbitControls, TransformControls, RoomEnvironment image-based lighting, and multi-part procedural apparatus (wooden plinth, dynamically coiled chrome helical spring, live-textured mass blocks, dynamics track and carts, tilted ramp, pendulum mount, and textured planet/satellite).
  • Zero-eval Math Expression Compiler: Every position, rotation, force vector, readout, and chart curve is compiled from math expression strings using a custom recursive-descent parser rather than eval().
  • Inverse Physics Coupling: Dragging an object in 3D updates the underlying physical parameters in real time—using analytical inverse solvers for springs, pendulums, orbits, carts, waves, and ramps, and a numerical Jacobian solver for custom AI-generated scenes:

$$F = -k \Delta y, \qquad T = 2\pi\sqrt{\frac{m}{k}}$$

$$a = g(\sin\theta - \mu\cos\theta), \qquad \frac{mv^2}{r} = \frac{GMm}{r^2}$$

  • Serverless AI Proxy & Fallback (Vercel + Node.js + Express): Custom questions call /api/generate (backed by @google/genai with gemini-2.5-flash), with in-memory response caching, per-IP rate limiting, and seamless fallback to the 7 built-in simulations via weighted keyword matching.

Challenges we ran into

  • Coupling 3D gizmo drags back into equations: Normally an animation loop sets object positions from \( x(t) \). Allowing a user to grab a bob, satellite, or spring mass mid-motion meant pausing and inverting the math cleanly—and supporting Shift+click group transforms around a dynamic centroid pivot without breaking single-object physics constraints.
  • Smooth 3D helical spring deformation: Drawing a spring as a 1px line looked flat, so we built a procedural tube-mesh coil that recalculates its helix frames every frame using pre-allocated scratch vectors to avoid garbage-collection stutter.
  • Accurate question routing: Early keyword matching accidentally sent "Why does a spring oscillate?" to the pendulum lab because both topics share words like "oscillate". Switching to weighted primary/secondary topic scoring fixed the routing across all built-in labs.
  • Keeping the 3D viewport unobstructed: Moving captions, equations, charts, and sliders out of canvas overlays into a clean split workspace made both the math and the 3D motion much easier to follow together.

What we learned

  • Interactive physics only clicks when cause and effect are instant—letting someone drag an object directly teaches way faster than hiding behavior behind abstract sliders alone.
  • Building a small, safe expression compiler gives AI-generated 3D scenes deterministic, frame-accurate motion without running untrusted code in the browser.

What's next

  • Expanding built-in interactive rigs to electromagnetism, optics/lenses, and thermodynamics.
  • Adding adaptive diagnostic hints that spot which step or variable a student is stuck on and highlight the relevant force vector in 3D.
Share this project:

Updates

Submission history