| | |
| | | import { Scene,GridHelper } from 'three'; |
| | | |
| | | 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 CSSRenderer from './cssRenderer'; |
| | | |
| | | // 工具类 |
| | | import Sizes from "./utils/sizes"; |
| | |
| | | export default class Experience { |
| | | constructor(canvas) { |
| | | this.canvas = canvas; |
| | | this.sizes = new Sizes(); |
| | | this.container = canvas.parentElement; |
| | | this.sizes = new Sizes(this.canvas); |
| | | this.time = new Time(); |
| | | this.scene = new Scene(); |
| | | this.camera = new Camera(this); |
| | | this.renderer = new Renderer(this); |
| | | this.cssRenderer = new CSSRenderer(this); |
| | | this.world = new World(this); |
| | | |
| | | const size = 10; |
| | | const divisions = 10; |
| | | // const size = 100; |
| | | // const divisions = 100; |
| | | |
| | | const gridHelper = new GridHelper(size, divisions); |
| | | this.scene.add(gridHelper); |
| | | // 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.camera.update(); |
| | | this.world.update(); |
| | | this.renderer.update(); |
| | | this.cssRenderer.update(); |
| | | this.stats.update(); |
| | | } |
| | | } |