This repository was archived by the owner on Mar 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
87 lines (75 loc) · 2.61 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//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 = [];
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
function(m, key, value) {
vars[decodeURIComponent(key)] = decodeURIComponent(value);
});
return vars;
}
serialInclude(['../lib/CGF.js', 'XMLscene.js', 'MySceneGraph.js', 'Shiftago.js',
'MyGraphNode.js', 'MyGraphLeaf.js', 'MyInterface.js',
'primitives/cylinder.js', 'primitives/patch.js', 'primitives/rectangle.js',
'primitives/sphere.js', 'primitives/triangle.js', 'animations/animation.js',
'animations/bezieranimation.js', 'animations/circularanimation.js', 'animations/comboanimation.js',
'animations/linearanimation.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'] || "Shiftago.xml";
// create and load graph, and associate it to scene.
// Check console for loading errors
var myGraph = new MySceneGraph(filename, myScene);
// start
app.run();
}
]);