A React Three.js application for viewing molecular structures with transmission materials and interactive controls.
npm install
npm run devTo add new molecular models, convert OBJ files to GLB format for optimal performance:
npm install -g obj2gltfobj2gltf -i your-molecule.obj -o public/your-molecule.glb --binaryThe GLB format provides:
- Smaller file sizes (typically 60-70% compression)
- Faster loading times
- Single binary file containing geometry, materials, and textures
public/
├── surface.glb # Surface representation
├── cartoon.glb # Cartoon representation
└── your-new-molecule.glb
For transmission materials (glass-like effect):
function TransmissionMolecule() {
const gltf = useLoader(GLTFLoader, './your-molecule.glb')
// ... rest of component
}For standard materials (solid appearance):
function StandardMolecule() {
const gltf = useLoader(GLTFLoader, './your-molecule.glb')
// ... rest of component
}- Adjust
transmission,roughness,thicknessin Leva controls - Modify colors in the
colorandbgproperties - Change material properties like
metalnessandclearcoat
MoleculeViewer.jsx- Main viewer component with dual rendering modespublic/- Static assets including GLB molecular models- Interactive controls powered by Leva for real-time shader adjustments