-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
33 lines (27 loc) · 1.24 KB
/
main.ts
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
import "core-js/es";
import Camera from "./src/Camera";
import InputHandler from "./src/InputHandler";
import Scene from "./src/Scene";
import Canvas from "./src/Canvas";
import Renderer from "./src/Renderer";
import Vertex from "./src/Vertex";
import Cube from "./src/WorldObjects/Cube";
import {randomColor} from "./src/Services/Color";
import {randomSign} from "./src/Services/Math";
import {SceneRandomizerDecorator} from "./src/SceneRandomizerDecorator";
import {SceneInterface} from "./src/Scene.interface";
import Sphere from "./src/WorldObjects/Sphere";
const canvasElement = <HTMLCanvasElement> document.getElementById('projectionCanvas');
const canvas = new Canvas(canvasElement);
const camera = new Camera();
new InputHandler(camera);
let scene: SceneInterface = new Scene();
// Randomize elements;
scene = new SceneRandomizerDecorator(scene);
const objects = [Sphere, Cube];
for (let i = 0; i < 15; i++) {
const color = randomColor();
const center = new Vertex(randomSign() * Math.random() * 10 * i, 25 + randomSign() * Math.random() * 10 * i, 25 + randomSign() * Math.random() * 5 * (i));
scene.addElement(new objects[i % objects.length](center, Math.random() * 6, color));
}
const renderer = new Renderer(scene, camera, canvas, window);