34 lines
745 B
TypeScript
34 lines
745 B
TypeScript
import { PerspectiveCamera, Scene, WebGLRenderer } from 'three';
|
|
|
|
export class Renderer {
|
|
public width = window.innerWidth;
|
|
public height = window.innerHeight;
|
|
|
|
public renderer = new WebGLRenderer({ antialias: true });
|
|
public scene = new Scene();
|
|
public camera = new PerspectiveCamera(
|
|
90,
|
|
this.width / this.height,
|
|
0.1,
|
|
10000
|
|
);
|
|
|
|
constructor() {}
|
|
|
|
resize() {
|
|
this.width = window.innerWidth;
|
|
this.height = window.innerHeight;
|
|
this.renderer.setSize(this.width, this.height);
|
|
this.camera.aspect = this.width / this.height;
|
|
this.camera.updateProjectionMatrix();
|
|
}
|
|
|
|
render() {
|
|
this.renderer.render(this.scene, this.camera);
|
|
}
|
|
|
|
get canvas() {
|
|
return this.renderer.domElement;
|
|
}
|
|
}
|