-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
39 lines (37 loc) · 1.58 KB
/
app.js
File metadata and controls
39 lines (37 loc) · 1.58 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
/**
* Execute every method necessary to run the application.
*
* We are using the external library, for matrices computation and model loading, contained in utils.js.
* Other JavaScript files needed for the execution of the application are, in order of loading:
* webgl.js
* shaders.js
* model.js
* textures.js
* nodes.js
* animation.js
* camera.js
* draw.js
*
* This application requires the execution of alocal server in its root directory at the port 8889. A simple Phyton server called server.py is provided.
*
* The application was written by Paolo Fumagalli and Marco Gullo, Politecnico di Milano.
*/
initWebGl(); // webgl.js: initialize canvas and webGL context.
if (!gl) {
// Check if context was initialized correctly.
document.write("GL context not opened");
}
else {
loadShaders(); // Load shader files and set variable handlers in JS.
//loadModel(); // Load model from json and load buffers for positions, UVs and normals.
OBJ.downloadMeshes({"planet": this.modelDir + "OnePlanet.obj"}, keepGoing);
//loadTextures(); // Load textures from image files.
//buildSceneGraph(); // Build node structure defining planets and orbits.
//startDrawing(); // Set camera and trigger recursive method to draw elements on the screen.
}
function keepGoing(meshes){
loadModel(meshes); // Load model from json and load buffers for positions, UVs and normals.
loadTextures(); // Load textures from image files.
buildSceneGraph(); // Build node structure defining planets and orbits.
startDrawing(); // Set camera and trigger recursive method to draw elements on the screen.
}