Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/swizec/something-3d

An experiment in compositional three.js
https://github.com/swizec/something-3d

react reactjs three three-js threejs

Last synced: 3 days ago
JSON representation

An experiment in compositional three.js

Awesome Lists containing this project

README

        

This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).

# An experiment in compositional Three.js

2 spinning cubes

![2 spinning cubes](https://raw.githubusercontent.com/Swizec/something-3d/master/compositional-threejs.gif)

Made from a normal React component tree.

```javascript
class App extends Component {
state = {
rotation1: { x: 0, y: 0, z: 0 },
rotation2: { x: 0, y: 0, z: 0 }
}

componentDidMount() {
this.gameLoop();
}

gameLoop = () => {
requestAnimationFrame(this.gameLoop);

const { rotation1, rotation2 } = this.state;

this.setState({
rotation1: { x: rotation1.x + 0.03,
y: rotation1.y + 0.03, },
rotation2: { x: rotation2.x - 0.06,
y: rotation2.y - 0.06 }
});
}

render() {
const { rotation1, rotation2 } = this.state;

return (



logo

Welcome to React










);
}
}

```

Excellent.