-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
55 lines (44 loc) · 2.17 KB
/
main.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//From https://github.com/EvanHahn/ScriptInclude
include=function(){function f(){var a=this.readyState;(!a||/ded|te/.test(a))&&(c--,!c&&e&&d())}var a=arguments,b=document,c=a.length,d=a[c-1],e=d.call;e&&c--;for(var g,h=0;c>h;h++)g=b.createElement("script"),g.src=arguments[h],g.async=!0,g.onload=g.onerror=g.onreadystatechange=f,(b.head||b.getElementsByTagName("head")[0]).appendChild(g)};
serialInclude=function(a){var b=console,c=serialInclude.l;if(a.length>0)c.splice(0,0,a);else b.log("Done!");if(c.length>0){if(c[0].length>1){var d=c[0].splice(0,1);b.log("Loading "+d+"...");include(d,function(){serialInclude([]);});}else{var e=c[0][0];c.splice(0,1);e.call();};}else b.log("Finished.");};serialInclude.l=new Array();
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
function(m,key,value) {
vars[decodeURIComponent(key)] = decodeURIComponent(value);
});
return vars;
}
//Include additional files here
serialInclude(['../lib/CGF.js',
'XMLscene.js',
'MySceneGraph.js',
'MyInterface.js',
'MyLeaf.js',
'MyNode.js',
'./primitives/MyRectangle.js',
'./primitives/MyCylinder.js',
'./primitives/MyTriangle.js',
'./primitives/MySphere.js',
'./primitives/MyTorus.js',
'./primitives/MyHalfTorus.js',
main=function()
{
// Standard application, scene and interface setup
var app = new CGFapplication(document.body);
var myInterface = new MyInterface();
var myScene = new XMLscene(myInterface);
app.init();
app.setScene(myScene);
app.setInterface(myInterface);
myInterface.setActiveCamera(myScene.camera);
// get file name provided in URL, e.g. http://localhost/myproj/?file=myfile.xml
// or use "demo.xml" as default (assumes files in subfolder "scenes", check MySceneGraph constructor)
var filename=getUrlVars()['file'] || "demo.xml";
// create and load graph, and associate it to scene.
// Check console for loading errors
var myGraph = new MySceneGraph(filename, myScene);
// start
app.run();
}
]);