-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (32 loc) · 826 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import addBackground from './src/add-background';
import addLights from './src/add-lights';
import addMeshes from './src/add-meshes';
import viewer from './src/viewer';
const render = (app) => {
for (const animate of app.animation) {
animate();
}
app.renderer.render(app.scene, app.camera);
requestAnimationFrame(() => {
render(app);
});
};
export default function (options) {
const app = viewer({
canvas: options.canvas,
width: options.width,
height: options.height,
});
addBackground(app);
addLights(app);
addMeshes(app);
render(app);
return {
updateView: (width, height) => {
app.camera.aspect = width / height;
app.camera.updateProjectionMatrix();
app.renderer.setSize(width, height);
app.renderer.render(app.scene, app.camera);
},
};
}