forked from turbulenz/turbulenz_engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
69 lines (60 loc) · 1.71 KB
/
app.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
// Generated by the Turbulenz Engine: https://github.com/turbulenz/turbulenz_engine
// Turbulenz Engine distributed under the MIT license: https://github.com/turbulenz/turbulenz_engine/blob/master/LICENSE
/* global Protolib: false*/
/* global Config: false*/
function Application() {}
Application.prototype =
{
// Use the properties from Config by default, otherwise use these defaults
protolibConfig: Protolib.extend(true, {
fps: 60,
useShadows: true
},
Config),
init: function initFn()
{
// Locally referenced variables to use for this function
var protolib = this.protolib;
var mathDevice = protolib.getMathDevice();
// Set the background color to clear during protolib.beginFrame
protolib.setClearColor(mathDevice.v3Build(0, 0, 0));
// Initialization code goes here
},
update: function updateFn()
{
var protolib = this.protolib;
if (protolib.beginFrame())
{
// Update code goes here
// Render code goes here
protolib.endFrame();
}
},
destroy: function destroyFn()
{
var protolib = this.protolib;
if (protolib)
{
// Destruction code goes here
protolib.destroy();
this.protolib = null;
}
}
};
// Application constructor function
Application.create = function applicationCreateFn(params)
{
var app = new Application();
app.protolib = params.protolib;
if (!app.protolib)
{
var console = window.console;
if (console)
{
console.error("Protolib could not be found");
}
return null;
}
app.init();
return app;
};