š”A molecular chemistry based simulation library
npm install react-mol

npm i three @react-three/fiber react-mol
git clone https://github.com/tseijp/react-mol
cd react-mol
npm i
npm start
|
Atom |
Mol |
Flow |
Tile |
Spring |
š” is a molecular chemistry based simulation component
that covers most cases of organic molecule simulation. (More Recipes) View Code`` tsx
`
|
 |
|
š
(More Recipes) View Code` tsx
`
|
 |
|
šŖ
(live demo). |
|
tsx
import React from 'react'
import ReactDOM from 'react-dom'
import { Atom } from 'react-mol'
import { Canvas, useFrame } from ''
function Basic () {
// This reference will give us direct access to the last instance
const ref = React.useRef(null)
// Rotate instance every frame, this is outside of React without overhead
useFrame(() => {
ref.current.rotation.x =
ref.current.rotation.y =
ref.current.rotation.z += 0.025
})
return (
)
}
ReactDOM.render(
,
document.getElementById('root')
)
`
Show Recursion Example
`tsx
import React from 'react'
import ReactDOM from 'react-dom'
import { Atom } from 'react-mol'
import { Canvas, useFrame } from ''
function Basic () {
// This reference will give us direct access to the last instance
const ref = React.useRef(null)
// Rotate instance every frame, this is outside of React without overhead
useFrame(() => {
ref.current.rotation.x =
ref.current.rotation.y =
ref.current.rotation.z += 0.025
})
return (
{[...Array(5)].map((_, i) =>
)}
)
}
ReactDOM.render(
,
document.getElementById('root')
)
`
$3




###### Methyl alcohol


`tsx
`
`tsx
`

###### Acetil acid


`tsx
`
`tsx
`

###### Poly ethylene


`tsx
{next =>
{next|| }
}
`
`tsx
{Array(200)
.fill(0)
.map((_,i) =>
)}
`

$3



###### Points
`tsx
{[...Array(2500)].map((_,i) =>
args={(t,x,_,z) => [
sin((x+t)/3)+sin((z+t)/2)]}
position={r => [i%c,r,i/c%c]}
scale={r => [r/3,r/3,r/3]} />
)}
`

###### Boxes
`tsx
{[...Array(1000)].map((_,i) =>
args={(t,x,y,z) => [
sin(x/4+t)+sin(y/4+t)+sin(z/4+t) ]}
position={[i%10-5,i/10%10-5,i/100-5]}
rotation={r => [0,r2,r3]}
scale={r => [r/4,r/4,r/4]}/>
)}
`

###### Spheres
`tsx
{[...Array(1000)].map((_, i) =>
args={[...Array(4)].map(() => rand())}
position={(t,s,x,y,z) => [
x40-20 + cos(ts6) + sin(ts*2),
y40-20 + sin(ts4) + cos(ts*4),
z40-20 + cos(ts2) + sin(ts*6),]}
scale={(t,s) => Array(3).fill(
max(.3, cos((t+s10)s))*s)}/>
)}
`

###### Dodecas
`tsx
{[...Array(1000)].map((_,i) =>
args={[...Array(4)].map(() => rand())}
position={(t,s,x,y,z) => [
((x-.5)-cos(ts+x)-sin(ts/1))x100,
((y-.5)-sin(ts+y)-cos(ts/3))y100,
((z-.5)-cos(ts+z)-sin(ts/5))z100,]}
rotation={(t,s)=>Array(3).fill(cos(t*s))}
scale={(t,s)=>Array(3).fill(cos(t*s))}/>
)}
`

$3


###### Pieces

###### Bounds

###### Pipes

$3


$3
__TODO__
###### Koch Curve
`tsx
`
###### Meandering Snake
`tsx
LR={[90,90]}>
`
###### Urban Charting
`tsx
LR={[90,90]}>
``