-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
108 lines (100 loc) · 2.73 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//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",
"../lib/chess/chess.js/chess.js",
"GUI/XMLscene.js",
"GUI/MySceneGraph.js",
"GUI/MyInterface.js",
"GUI/MyRectangle.js",
"GUI/MyNode.js",
"GUI/MyCylinder.js",
"GUI/MySphere.js",
"GUI/MyTorus.js",
"GUI/MyTriangle.js",
"GUI/MyAnimation.js",
"GUI/MySpriteAnimation.js",
"GUI/MySpritesheet.js",
"GUI/MySpriteText.js",
"GUI/MyPlane.js",
"GUI/MyPatch.js",
"GUI/MyBarrel.js",
"GUI/MyTile.js",
"GUI/MyGameBoard.js",
"GUI/MyPiece.js",
"GUI/MyComputedAnimation.js",
"GUI/MyAuxiliarBoard.js",
"GUI/MyGameOrchestrator.js",
"GUI/MyEvaluationBoard.js",
"GUI/MyTable.js",
'GUI/CGFResourceReader.js',
'GUI/CGFOBJModel.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"] || "sala_default.xml";
myScene.default_scene=filename;
// create and load graph, and associate it to scene.
// Check console for loading errors
var myGraph = new MySceneGraph(filename, myScene);
// start
app.run();
}),
]);