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.
- Expanded element set including
H,C,N,O,F,Cl,S,P,Na,K,Mg,Ca,Al,Fe, andCu. - 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.
No environment variables are required for local frontend development.
The .env.example file only contains optional placeholders for deployment integrations.
npm run dev: Start Vite dev server on port3000.npm run build: Build production assets intodist/.npm run bundle:report: Print built JS/CSS asset sizes fromdist/assets.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 test:e2e: Run Playwright browser-level tests ine2e/.npm run verify: Runtest,lint, andbuildin sequence.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: click a bond to select it, then use explicit
Upgrade/Deleteactions. - Build mode:
Shift + dragon a single bond to rotate connected geometry. - Delete mode (shortcut): click atoms or bonds to remove them quickly.
- Delete mode: press
Escto return to Build mode. - Camera: drag background to orbit.
- Camera: scroll or pinch to zoom.
- Add 2 atoms from the element panel.
- Click atom A, then atom B, to create the first bond.
- Click the bond once to select it.
- Use the floating
Upgradebutton to change bond order. - Use
Deletein the same action bar to remove only that selected bond. - Use Delete mode only when you want fast cleanup of multiple atoms/bonds.
The identifier includes a broad built-in template library spanning:
- introductory molecules (for example
H2O,CO2,NH3,CH4); - small organics and functional isomers (for example alcohols, acids, ethers, nitriles);
- selected inorganic and ionic compounds;
- larger biochemistry-themed structures and examples.
For the canonical list used by the app, see src/identifier.ts.
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 verify
npm run test:e2eThen manually verify:
- Add/remove atoms
- Create/upgrade/remove bonds
- Bond rotation
- Challenge mode flow