backup-05-06-2024

This commit is contained in:
2024-06-05 17:57:07 +02:00
parent f8122076eb
commit 98e78ca33e
14 changed files with 179 additions and 4 deletions

View File

@@ -0,0 +1,47 @@
import * as Three from 'three';
import Asset from '../assets/asset.class';
export default class Renderer
{
static #scene: Three.Scene;
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.#scene = new Three.Scene();
this.#camera = new Three.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, 1, 1000 );
this.#resize();
window.addEventListener("resize", this.#resize.bind(this));
return true;
}
catch(e)
{
console.error(e);
return false;
}
}
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;
this.render();
}
static render(): void
{
console.log(new Three.PlaneGeometry());
this.#renderer.render(this.#scene, this.#camera);
}
}