aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/engine.js174
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/jshader.js6
2 files changed, 90 insertions, 90 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/engine.js b/js/helper-classes/RDGE/src/core/script/engine.js
index cf576702..d437d5f8 100755
--- a/js/helper-classes/RDGE/src/core/script/engine.js
+++ b/js/helper-classes/RDGE/src/core/script/engine.js
@@ -76,151 +76,151 @@ RDGE.stateManager = function () {
76 }; 76 };
77}; 77};
78 78
79RDGE.Engine = function() { 79RDGE.Engine = function () {
80 this._assetPath = "assets/"; 80 this._assetPath = "assets/";
81 81
82 // map of scene graphs to names 82 // map of scene graphs to names
83 this.sceneMap = []; 83 this.sceneMap = [];
84 84
85 // number of states on the stack 85 // number of states on the stack
86 this.stateTop = undefined; 86 this.stateTop = undefined;
87 87
88 // size of the browser window 88 // size of the browser window
89 this.lastWindowWidth = window.innerWidth; 89 this.lastWindowWidth = window.innerWidth;
90 this.lastWindowHeight = window.innerHeight; 90 this.lastWindowHeight = window.innerHeight;
91 91
92 this.defaultContext = null; 92 this.defaultContext = null;
93 93
94 this.lightManager = null; 94 this.lightManager = null;
95 95
96 clearColor = [0.0, 0.0, 0.0, 0.0]; 96 clearColor = [0.0, 0.0, 0.0, 0.0];
97 97
98 this.initializeComplete = false; 98 this.initializeComplete = false;
99 99
100 this.RDGECanvas = null; 100 this.RDGECanvas = null;
101 101
102 /* 102 /*
103 * a map of canvas names to renderer 103 * a map of canvas names to renderer
104 */ 104 */
105 this.canvasToRendererMap = {}; 105 this.canvasToRendererMap = {};
106 106
107 /* 107 /*
108 * states to canvas map - maps a state stack to the canvas context it belongs to 108 * states to canvas map - maps a state stack to the canvas context it belongs to
109 */ 109 */
110 this.canvasNameToStateStack = {}; 110 this.canvasNameToStateStack = {};
111 111
112 /* 112 /*
113 * the list of context's that are active 113 * the list of context's that are active
114 */ 114 */
115 this.canvasCtxList = []; 115 this.canvasCtxList = [];
116 116
117 /* 117 /*
118 * regex object to verify runtime object is not some sort of exploit 118 * regex object to verify runtime object is not some sort of exploit
119 */ 119 */
120 invalidObj = new RegExp("([()]|function)"); 120 invalidObj = new RegExp("([()]|function)");
121 121
122 isValidObj = function (name) { 122 isValidObj = function (name) {
123 // do a quick test make sure user isn't trying to execute a function 123 // do a quick test make sure user isn't trying to execute a function
124 if (invalidObj.test(name)) { 124 if (invalidObj.test(name)) {
125 window.console.error("invalid object name passed to RDGE, " + name + " - looks like a function"); 125 window.console.error("invalid object name passed to RDGE, " + name + " - looks like a function");
126 return false; 126 return false;
127 } 127 }
128 128
129 return true; 129 return true;
130 }; 130 };
131 131
132 /* 132 /*
133 * The context definition - every context shares these parameters 133 * The context definition - every context shares these parameters
134 */ 134 */
135 contextDef = function () { 135 contextDef = function () {
136 this.id = null; 136 this.id = null;
137 this.renderer = null; 137 this.renderer = null;
138 this.ctxStateManager = null; 138 this.ctxStateManager = null;
139 this.startUpState = null; 139 this.startUpState = null;
140 this.sceneGraphMap = []; 140 this.sceneGraphMap = [];
141 this.currentScene = null; 141 this.currentScene = null;
142 this.getScene = function () { 142 this.getScene = function () {
143 return this.sceneGraphMap[this.currentScene]; 143 return this.sceneGraphMap[this.currentScene];
144 } 144 }
145 this.debug = 145 this.debug =
146 { 146 {
147 'frameCounter' : 0, 147 'frameCounter': 0,
148 'mat4CallCount': 0 148 'mat4CallCount': 0
149 } 149 }
150 }; 150 };
151 151
152 // maintains the contexts 152 // maintains the contexts
153 contextManager = new RDGE.objectManager(); 153 contextManager = new RDGE.objectManager();
154 this.ctxMan = contextManager; 154 this.ctxMan = contextManager;
155 155
156 // the context currently being updated 156 // the context currently being updated
157 contextManager.currentCtx = null; 157 contextManager.currentCtx = null;
158 158
159 contextManager._addObject = contextManager.addObject; 159 contextManager._addObject = contextManager.addObject;
160 contextManager.contextMap = {}; 160 contextManager.contextMap = {};
161 161
162 contextManager.addObject = function (context) { 162 contextManager.addObject = function (context) {
163 this.contextMap[context.id] = context; 163 this.contextMap[context.id] = context;
164 return this._addObject(context); 164 return this._addObject(context);
165 }; 165 };
166 166
167 contextManager.start = function () { 167 contextManager.start = function () {
168 var len = this.objects.length; 168 var len = this.objects.length;
169 for (var i = 0; i < len; ++i) { 169 for (var i = 0; i < len; ++i) {
170 // set the current context 170 // set the current context
171 contextManager.currentCtx = this.objects[i]; 171 contextManager.currentCtx = this.objects[i];
172 this.objects[i].ctxStateManager.PushState(this.objects[i].startUpState); 172 this.objects[i].ctxStateManager.PushState(this.objects[i].startUpState);
173 } 173 }
174 }; 174 };
175 175
176 contextManager.forEach = function (cb) { 176 contextManager.forEach = function (cb) {
177 var len = this.objects.length; 177 var len = this.objects.length;
178 for (var i = 0; i < len; ++i) { 178 for (var i = 0; i < len; ++i) {
179 cb(this.objects[i]); 179 cb(this.objects[i]);
180 } 180 }
181 }; 181 };
182 182
183 this.getContext = function (optCanvasID) { 183 this.getContext = function (optCanvasID) {
184 if (!optCanvasID) { 184 if (!optCanvasID) {
185 return contextManager.currentCtx; 185 return contextManager.currentCtx;
186 } 186 }
187 else { 187 else {
188 return contextManager.contextMap[optCanvasID]; 188 return contextManager.contextMap[optCanvasID];
189 } 189 }
190 }; 190 };
191 191
192 this.clearContext = function( canvasID ) 192 this.clearContext = function (canvasID) {
193 { 193 contextManager.contextMap[canvasID] = undefined;
194 contextManager.contextMap[canvasID] = undefined; 194 };
195 } 195
196
197 /* 196 /*
198 * give the contextID (canvas id) of the context to set 197 * give the contextID (canvas id) of the context to set
199 */ 198 */
200 this.setContext = function (contextID) { 199 this.setContext = function (contextID) {
201 contextManager.currentCtx = contextManager.contextMap[contextID]; 200 contextManager.currentCtx = contextManager.contextMap[contextID];
202 }; 201 };
203
204 this.tickContext = function(contextID) {
205 var savedCtx = contextManager.currentCtx;
206 contextManager.currentCtx = contextManager.contextMap[contextID];
207 this.objects[i].ctxStateManager.tick(dt);
208 contextManager.currentCtx = savedCtx;
209 202
210 } 203 this.tickContext = function (contextID) {
204 var savedCtx = contextManager.currentCtx;
205 contextManager.currentCtx = contextManager.contextMap[contextID];
206 this.objects[i].ctxStateManager.tick(dt);
207 contextManager.currentCtx = savedCtx;
208 };
211 209
212 this.remapAssetFolder = function( url ) 210 this.setAssetPath = function (path) {