diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/engine.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/engine.js | 922 |
1 files changed, 461 insertions, 461 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/engine.js b/js/helper-classes/RDGE/src/core/script/engine.js index 36a34689..919a1e9c 100755 --- a/js/helper-classes/RDGE/src/core/script/engine.js +++ b/js/helper-classes/RDGE/src/core/script/engine.js | |||
@@ -1,461 +1,461 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility, Inc |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | BSD License. |
5 | 5 | ||
6 | Redistribution and use in source and binary forms, with or without | 6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 7 | modification, are permitted provided that the following conditions are met: |
8 | 8 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 9 | - Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 10 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 11 | - Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the | 12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. | 13 | documentation and/or other materials provided with the distribution. |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 14 | - Neither the name of Motorola Mobility nor the names of its contributors |
15 | may be used to endorse or promote products derived from this software | 15 | may be used to endorse or promote products derived from this software |
16 | without specific prior written permission. | 16 | without specific prior written permission. |
17 | 17 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | POSSIBILITY OF SUCH DAMAGE. |
29 | </copyright> */ | 29 | </copyright> */ |
30 | 30 | ||
31 | var RDGE = RDGE || {}; | 31 | var RDGE = RDGE || {}; |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * Manage state instances | 34 | * Manage state instances |
35 | */ | 35 | */ |
36 | RDGE.stateManager = function () { | 36 | RDGE.stateManager = function () { |
37 | // a stack of states | 37 | // a stack of states |
38 | this.stateStack = []; | 38 | this.stateStack = []; |
39 | 39 | ||
40 | // number of states on the stack | 40 | // number of states on the stack |
41 | this.stateTop = undefined; | 41 | this.stateTop = undefined; |
42 | 42 | ||
43 | // the states of the context | 43 | // the states of the context |
44 | this.RDGEInitState = null; | 44 | this.RDGEInitState = null; |
45 | this.RDGERunState = null; | 45 | this.RDGERunState = null; |
46 | 46 | ||
47 | this.currentState = function () { | 47 | this.currentState = function () { |
48 | if(this.stateTop != undefined) | 48 | if(this.stateTop != undefined) |
49 | return this.stateStack[this.stateTop]; | 49 | return this.stateStack[this.stateTop]; |
50 | 50 | ||
51 | return null; | 51 | return null; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | /* | 54 | /* |
55 | * Push new IRuntime state - engine executes the new state | 55 | * Push new IRuntime state - engine executes the new state |
56 | */ | 56 | */ |
57 | this.PushState = function (state, flags) { | 57 | this.PushState = function (state, flags) { |
58 | if (state != null && typeof state.Init == 'function') { | 58 | if (state != null && typeof state.Init == 'function') { |
59 | if(this.stateTop != undefined) | 59 | if(this.stateTop != undefined) |
60 | this.stateStack[this.stateTop].LeaveState(); | 60 | this.stateStack[this.stateTop].LeaveState(); |
61 | 61 | ||
62 | if(flags == undefined || flags != "noInit") | 62 | if(flags == undefined || flags != "noInit") |
63 | state.Init(); | 63 | state.Init(); |
64 | 64 | ||
65 | this.stateTop = this.stateStack.push(state) - 1; | 65 | this.stateTop = this.stateStack.push(state) - 1; |
66 | } | 66 | } |
67 | }; | 67 | }; |
68 | 68 | ||
69 | /* | 69 | /* |
70 | * Remove IRuntime state from stack, engine executes previous state | 70 | * Remove IRuntime state from stack, engine executes previous state |
71 | */ | 71 | */ |
72 | this.PopState = function () { | 72 | this.PopState = function () { |
73 | state = this.stateStack.pop(); | 73 | state = this.stateStack.pop(); |
74 | if (state != null) { | 74 | if (state != null) { |
75 | state.Shutdown(); | 75 | state.Shutdown(); |
76 | } | 76 | } |
77 | 77 | ||
78 | this.stateTop = this.stateTop > 0 ? this.stateTop - 1 : 0; | 78 | this.stateTop = this.stateTop > 0 ? this.stateTop - 1 : 0; |
79 | 79 | ||
80 | if (this.stateStack[this.stateTop]) { | 80 | if (this.stateStack[this.stateTop]) { |
81 | this.stateStack[this.stateTop].ReInit(); | 81 | this.stateStack[this.stateTop].ReInit(); |
82 | } | 82 | } |
83 | }; | 83 | }; |
84 | 84 | ||
85 | /* | 85 | /* |
86 | * Remove all states from the stack | 86 | * Remove all states from the stack |
87 | */ | 87 | */ |
88 | this.PopAll = function () { | 88 | this.PopAll = function () { |
89 | while (this.stateStack[this.stateTop] != null) { | 89 | while (this.stateStack[this.stateTop] != null) { |
90 | this.PopState(); | 90 | this.PopState(); |
91 | } | 91 | } |
92 | }; | 92 | }; |
93 | 93 | ||
94 | this.tick = function (dt) { | 94 | this.tick = function (dt) { |
95 | if (this.stateStack[this.stateTop] != null) { | 95 | if (this.stateStack[this.stateTop] != null) { |
96 | this.stateStack[this.stateTop].Update(dt); | 96 | this.stateStack[this.stateTop].Update(dt); |
97 | this.stateStack[this.stateTop].Resize(); | 97 | this.stateStack[this.stateTop].Resize(); |
98 | this.stateStack[this.stateTop].Draw(); | 98 | this.stateStack[this.stateTop].Draw(); |
99 | } | 99 | } |
100 | }; | 100 | }; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | RDGE.Engine = function () { | 103 | RDGE.Engine = function () { |
104 | this._assetPath = "assets/"; | 104 | this._assetPath = "assets/"; |
105 | 105 | ||
106 | // map of scene graphs to names | 106 | // map of scene graphs to names |
107 | this.sceneMap = []; | 107 | this.sceneMap = []; |
108 | 108 | ||
109 | // number of states on the stack | 109 | // number of states on the stack |
110 | this.stateTop = undefined; | 110 | this.stateTop = undefined; |
111 | 111 | ||
112 | // size of the browser window | 112 | // size of the browser window |
113 | this.lastWindowWidth = window.innerWidth; | 113 | this.lastWindowWidth = window.innerWidth; |
114 | this.lastWindowHeight = window.innerHeight; | 114 | this.lastWindowHeight = window.innerHeight; |
115 | 115 | ||
116 | this.defaultContext = null; | 116 | this.defaultContext = null; |
117 | 117 | ||
118 | this.lightManager = null; | 118 | this.lightManager = null; |
119 | 119 | ||
120 | clearColor = [0.0, 0.0, 0.0, 0.0]; | 120 | clearColor = [0.0, 0.0, 0.0, 0.0]; |
121 | 121 | ||
122 | this.initializeComplete = false; | 122 | this.initializeComplete = false; |
123 | 123 | ||
124 | this.RDGECanvas = null; | 124 | this.RDGECanvas = null; |
125 | 125 | ||
126 | /* | 126 | /* |
127 | * a map of canvas names to renderer | 127 | * a map of canvas names to renderer |
128 | */ | 128 | */ |
129 | this.canvasToRendererMap = {}; | 129 | this.canvasToRendererMap = {}; |
130 | 130 | ||
131 |