import { Scene,GridHelper } from 'three';
|
|
|
import World from "./world/world";
|
import Camera from "./camera";
|
import Renderer from "./renderer";
|
|
// 工具类
|
import Sizes from "./utils/sizes";
|
import Time from "./utils/time";
|
|
export default class Experience {
|
constructor(canvas) {
|
this.canvas = canvas;
|
this.sizes = new Sizes();
|
this.time = new Time();
|
this.scene = new Scene();
|
this.camera = new Camera(this);
|
this.renderer = new Renderer(this);
|
this.world = new World(this);
|
|
const size = 10;
|
const divisions = 10;
|
|
const gridHelper = new GridHelper(size, divisions);
|
this.scene.add(gridHelper);
|
|
// 帧
|
this.time.on('tick', () => {
|
this.update();
|
});
|
}
|
|
update() {
|
this.camera.update();
|
this.world.update();
|
this.renderer.update();
|
}
|
}
|