three-demo
Version:
A demo framework for three.js.
53 lines (30 loc) • 1.59 kB
Markdown
[](https://github.com/vanruesc/three-demo/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/three-demo)
A compact demo framework for [three.js](https://threejs.org/).
*[Demo](https://vanruesc.github.io/three-demo/demo) · [Documentation](https://vanruesc.github.io/three-demo/docs)*
This library requires the peer dependencies [three](https://github.com/mrdoob/three.js/) and [dat.gui](https://github.com/dataarts/dat.gui).
```sh
npm install dat.gui three three-demo
```
```js
import { DemoManager } from "three-demo";
import { MyDemo } from "./MyDemo";
const manager = new DemoManager(document.getElementById("viewport"), {
aside: document.getElementById("aside"),
renderer
});
manager.addEventListener("change", (event) => console.log(event));
manager.addEventListener("load", (event) => console.log(event));
manager.addDemo(new MyDemo());
requestAnimationFrame(function render(timestamp) {
requestAnimationFrame(render);
manager.render(timestamp);
});
```
You can create custom demos by extending the `Demo` class. For details, take a look at the [ExampleDemo](https://github.com/vanruesc/three-demo/blob/main/demo/src/demos/ExampleDemo.ts).
Please refer to the [contribution guidelines](https://github.com/vanruesc/three-demo/blob/main/.github/CONTRIBUTING.md) for details.