-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.ts
More file actions
40 lines (31 loc) · 1.04 KB
/
Copy pathscript.ts
File metadata and controls
40 lines (31 loc) · 1.04 KB
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
34
35
36
37
38
39
40
///<reference path="SoftEngine.ts"/>
let canvas: HTMLCanvasElement;
let device: SoftEngine.Device;
let mesh: SoftEngine.Mesh;
let meshes: SoftEngine.Mesh[] = [];
let camera: SoftEngine.Camera;
document.addEventListener("DOMContentLoaded", main, false);
function main() {
canvas = <HTMLCanvasElement>document.getElementById("canvas");
camera = new SoftEngine.Camera();
device = new SoftEngine.Device(canvas);
camera.Position = new BABYLON.Vector3(0, 0, 10);
camera.Target = new BABYLON.Vector3(0, 0, 0);
// console.log(camera)
device.LoadJSONFileAsync("monkey.babylon", loadJSONCompleted);
requestAnimationFrame(drawingLoop);
}
function loadJSONCompleted(meshesLoaded: SoftEngine.Mesh[]) {
meshes = meshesLoaded;
requestAnimationFrame(drawingLoop);
}
function drawingLoop() {
device.clear();
// mesh.Rotation.y = 0.05;
for (let i = 0; i < meshes.length; i++) {
meshes[i].Rotation.y += 0.002;
}
device.render(camera, meshes);
device.present();
requestAnimationFrame(drawingLoop);
}