ZhangXianQiang
2024-04-17 7d8fabb5feddf7d2daffd2452781c515d2eb13cd
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
40
41
42
43
44
45
import { Scene, GridHelper,AxesHelper } from 'three';
import Stats from "three/examples/jsm/libs/stats.module";
 
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 = 200;
    // const divisions = 200;
 
    // const gridHelper = new GridHelper(size, divisions);
    // this.scene.add(gridHelper);
 
    this.stats = new Stats();
    document.querySelector('.map-container').appendChild(this.stats.dom);
 
    
 
    // 帧
    this.time.on('tick', () => {
      this.update();
    });
  }
 
  update() {
    this.camera.update();
    this.world.update();
    this.renderer.update();
    this.stats.update();
  }
}