BondLab is an interactive 3D molecule builder built with React, TypeScript, and React Three Fiber.
It is designed for chemistry learning: build molecules, inspect bond behavior, and get instant feedback on identity, stability, and polarity.
- 3D molecule sandbox with draggable atoms.
- Core elements: Hydrogen (
H), Carbon (C), Nitrogen (N), Oxygen (O). - Bond building with chemistry constraints (single/double/triple bond order and valency limits).
- Bond rotation interaction for rotatable single bonds (
Shift + drag). - Molecule identification from known structure templates plus fallback formula display.
- Stability scoring with bond energy and valency/geometry checks.
- Polarity classification (
polar,nonpolar, orunknown) from geometry and electronegativity. - Timed Challenge Mode with randomized target molecules.
- Theme toggle (light/dark), multilingual UI (
en,es,zh,fr,ja), and persisted preferences.
- Node.js
- npm
npm install
npm run devThe dev server runs on http://localhost:3000.
An .env.example file exists with:
GEMINI_API_KEYAPP_URL
Current frontend code does not read these values directly at runtime, but they may be required by your hosting/runtime integration workflow.
npm run dev: Start Vite dev server on port3000.npm run build: Build production assets intodist/.npm run preview: Preview the production build.npm run lint: Type-check withtsc --noEmit.npm run test: Run unit tests insrc/*.test.ts.npm run clean: Removedist/.
- Add atoms from the element panel.
- Build mode: click one atom, then another atom to create or upgrade a bond.
- Build mode: drag an atom to reposition it.
- Build mode: release a dragged atom near another atom to auto-create a bond.
- Build mode:
Shift + dragon a single bond to rotate connected geometry. - Delete mode: click atoms or bonds to remove them.
- Delete mode: right-click on an atom or bond to remove it.
- Camera: drag background to orbit.
- Camera: scroll or pinch to zoom.
The identifier currently includes:
- Water (
H2O) - Methane (
CH4) - Carbon Dioxide (
CO2) - Ammonia (
NH3) - Ethane (
C2H6) - Ethene (
C2H4) - Ethyne (
C2H2) - Oxygen (
O2) - Nitrogen (
N2) - Hydrogen (
H2) - Methanol (
CH3OH) - Ethanol (
C2H5OH) - Formaldehyde (
CH2O) - Hydrogen Cyanide (
HCN)
src/components/: UI and 3D scene components (Scene,UI,AtomNode,BondNode,ChallengeMode).src/store.ts: Zustand state and actions for atoms, bonds, and game/challenge state.src/physics.ts: Position simulation and transform synchronization.src/identifier.ts: Molecule template matching and formula fallback.src/stability.ts: Stability score and issue reporting.src/polarity.ts: Polarity calculation.src/i18n.ts: Localization strings and molecule name localization.
Before submitting changes, run:
npm run test
npm run lint
npm run buildThen manually verify:
- Add/remove atoms
- Create/upgrade/remove bonds
- Bond rotation
- Challenge mode flow