You've already forked vtt-mapper
Physics tests
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
import * as Three from 'three';
|
||||
import Asset from '../assets/asset.class';
|
||||
import { FRUSTUMSIZE } from '../consts';
|
||||
|
||||
export default class Renderer
|
||||
{
|
||||
static #scene: Three.Scene;
|
||||
static #camera: Three.OrthographicCamera;
|
||||
static scene: Three.Scene;
|
||||
static aspect: number;
|
||||
|
||||
static renderer: Three.WebGLRenderer;
|
||||
static camera: Three.OrthographicCamera;
|
||||
static init(): Boolean
|
||||
{
|
||||
try {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.addEventListener("webglcontextcreationerror", console.error);
|
||||
const context = canvas.getContext("webgl2");
|
||||
|
||||
this.#renderer.setPixelRatio( window.devicePixelRatio );
|
||||
document.body.appendChild(this.#renderer.domElement);
|
||||
this.renderer = new Three.WebGLRenderer({ antialias: true });
|
||||
this.renderer.setPixelRatio( window.devicePixelRatio );
|
||||
document.body.appendChild(this.renderer.domElement);
|
||||
|
||||
this.#scene = new Three.Scene();
|
||||
this.#camera = new Three.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, 1, 1000 );
|
||||
this.scene = new Three.Scene();
|
||||
this.camera = new Three.OrthographicCamera();
|
||||
this.camera.position.z = 500;
|
||||
|
||||
this.#resize();
|
||||
window.addEventListener("resize", this.#resize.bind(this));
|
||||
@@ -31,17 +32,28 @@ export default class Renderer
|
||||
}
|
||||
static #resize(): void
|
||||
{
|
||||
this.#renderer.setSize( window.innerWidth, window.innerHeight );
|
||||
this.#camera.left = window.innerWidth / - 2;
|
||||
this.#camera.right = window.innerWidth / 2;
|
||||
this.#camera.top = window.innerHeight / 2;
|
||||
this.#camera.bottom = window.innerHeight / - 2;
|
||||
const aspect = this.aspect = window.innerWidth / window.innerHeight;
|
||||
this.renderer.setSize( window.innerWidth, window.innerHeight );
|
||||
|
||||
this.camera.left = FRUSTUMSIZE * aspect / - 2;
|
||||
this.camera.right = FRUSTUMSIZE * aspect / 2;
|
||||
this.camera.top = FRUSTUMSIZE / 2;
|
||||
this.camera.bottom = FRUSTUMSIZE / - 2;
|
||||
|
||||
this.camera.updateProjectionMatrix();
|
||||
|
||||
this.render();
|
||||
}
|
||||
static render(): void
|
||||
static render(delta?: number): void
|
||||
{
|
||||
console.log(new Three.PlaneGeometry());
|
||||
this.#renderer.render(this.#scene, this.#camera);
|
||||
this.renderer.render(this.scene, this.camera);
|
||||
}
|
||||
static startRendering(): void
|
||||
{
|
||||
this.renderer.setAnimationLoop(Renderer.render.bind(Renderer));
|
||||
}
|
||||
static stopRendering(): void
|
||||
{
|
||||
this.renderer.setAnimationLoop(null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user