diff options
author | Ananya Sen | 2012-07-09 16:52:49 -0700 |
---|---|---|
committer | Ananya Sen | 2012-07-09 16:52:49 -0700 |
commit | 2eb84584f44b8c774479d1af2ee1d810597474cf (patch) | |
tree | 64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/helper-classes/RDGE/src/core/script/init_state.js | |
parent | bf9dba001ec84243e2f12cd13b0c0ae020fba4a2 (diff) | |
parent | cee0deca695359ab468bd06d0e05ed3b2010b338 (diff) | |
download | ninja-2eb84584f44b8c774479d1af2ee1d810597474cf.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into codemirror-custom-theme-removal
Conflicts:
js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/init_state.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/init_state.js | 593 |
1 files changed, 297 insertions, 296 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/init_state.js b/js/helper-classes/RDGE/src/core/script/init_state.js index d8d6d4c5..7a324b2d 100755 --- a/js/helper-classes/RDGE/src/core/script/init_state.js +++ b/js/helper-classes/RDGE/src/core/script/init_state.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | 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 | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -26,289 +27,289 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | 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 | 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | POSSIBILITY OF SUCH DAMAGE. | 29 | POSSIBILITY OF SUCH DAMAGE. |
29 | </copyright> */ | 30 | </copyright> */ |
30 | 31 | ||
31 | var RDGE = RDGE || {}; | 32 | var RDGE = RDGE || {}; |
32 | 33 | ||
33 | // init the view | 34 | // init the view |
34 | RDGE.LoadState = function(userRunState, context) { | 35 | RDGE.LoadState = function(userRunState, context) { |
35 | this.name = "LoadState"; | 36 | this.name = "LoadState"; |
36 | this.userRunState = userRunState !== undefined ? userRunState : new RDGE.core.RDGEState; | 37 | this.userRunState = userRunState !== undefined ? userRunState : new RDGE.core.RDGEState; |
37 | this.hasUserState = userRunState !== undefined ? true : false; | 38 | this.hasUserState = userRunState !== undefined ? true : false; |
38 | this.renderer = context.renderer; | 39 | this.renderer = context.renderer; |
39 | this.loadingDone = false; | 40 | this.loadingDone = false; |
40 | this.stateManager = context.ctxStateManager; | 41 | this.stateManager = context.ctxStateManager; |
41 | this.sceneLoadQueue = []; | 42 | this.sceneLoadQueue = []; |
42 | this.textureLoadQueue = []; | 43 | this.textureLoadQueue = []; |
43 | }; | 44 | }; |
44 | 45 | ||
45 | RDGE.LoadState.prototype.loadScene = function (addr, sceneName) { | 46 | RDGE.LoadState.prototype.loadScene = function (addr, sceneName) { |
46 | var request = new RDGE.sceneRequestDef(addr, sceneName); | 47 | var request = new RDGE.sceneRequestDef(addr, sceneName); |
47 | request.doSceneRequest = true; | 48 | request.doSceneRequest = true; |
48 | this.sceneLoadQueue.push( request ); | 49 | this.sceneLoadQueue.push( request ); |
49 | }; | 50 | }; |
50 | 51 | ||
51 | RDGE.LoadState.prototype.loadTexture = function (textureObject) { | 52 | RDGE.LoadState.prototype.loadTexture = function (textureObject) { |
52 | if (this.stateManager.currentState().name != "LoadState") { | 53 | if (this.stateManager.currentState().name != "LoadState") { |
53 | this.stateManager.PushState( this.stateManager.RDGEInitState, "noInit" ); | 54 | this.stateManager.PushState( this.stateManager.RDGEInitState, "noInit" ); |
54 | } | 55 | } |
55 | 56 | ||
56 | this.textureLoadQueue.push(textureObject); | 57 | this.textureLoadQueue.push(textureObject); |
57 | }; | 58 | }; |
58 | 59 | ||
59 | RDGE.LoadState.prototype.Init = function () { | 60 | RDGE.LoadState.prototype.Init = function () { |
60 | if (this.sceneName) { | 61 | if (this.sceneName) { |
61 | this.loadScene("assets_web/mesh/" + this.sceneName + ".json", this.sceneName); | 62 | this.loadScene("assets_web/mesh/" + this.sceneName + ".json", this.sceneName); |
62 | } | 63 | } |
63 | 64 | ||
64 | if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) | 65 | if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) |
65 | this.userRunState.onLoadState(); | 66 | this.userRunState.onLoadState(); |
66 | }; | 67 | }; |
67 | 68 | ||
68 | RDGE.LoadState.prototype.ReInit = function () { | 69 | RDGE.LoadState.prototype.ReInit = function () { |
69 | if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) | 70 | if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) |
70 | this.userRunState.onLoadState(); | 71 | this.userRunState.onLoadState(); |
71 | }; | 72 | }; |
72 | 73 | ||
73 | RDGE.LoadState.prototype.Resize = function () { | 74 | RDGE.LoadState.prototype.Resize = function () { |
74 | if (RDGE.globals.engine.lastWindowWidth == window.innerWidth && RDGE.globals.engine.lastWindowHeight == window.innerHeight) { | 75 | if (RDGE.globals.engine.lastWindowWidth == window.innerWidth && RDGE.globals.engine.lastWindowHeight == window.innerHeight) { |
75 | this.userRunState.resize(); | 76 | this.userRunState.resize(); |
76 | RDGE.globals.engine.lastWindowWidth = window.innerWidth; | 77 | RDGE.globals.engine.lastWindowWidth = window.innerWidth; |
77 | RDGE.globals.engine.lastWindowHeight = window.innerHeight; | 78 | RDGE.globals.engine.lastWindowHeight = window.innerHeight; |
78 | } | 79 | } |
79 | }; | 80 | }; |
80 | 81 | ||
81 | RDGE.LoadState.prototype.Update = function (dt) { | 82 | RDGE.LoadState.prototype.Update = function (dt) { |
82 | // for the current scene go through processing steps | 83 | // for the current scene go through processing steps |
83 | var sceneLoadTop = this.sceneLoadQueue.length - 1; | 84 | var sceneLoadTop = this.sceneLoadQueue.length - 1; |
84 | var texLoadTop = this.textureLoadQueue.length - 1; | 85 | var texLoadTop = this.textureLoadQueue.length - 1; |
85 | 86 | ||
86 | if (sceneLoadTop > -1) { | 87 | if (sceneLoadTop > -1) { |
87 | var curSceneReq = this.sceneLoadQueue[sceneLoadTop]; | 88 | var curSceneReq = this.sceneLoadQueue[sceneLoadTop]; |
88 | 89 | ||
89 | // check for completed mesh requests and load the data | 90 | // check for completed mesh requests and load the data |
90 | RDGE.globals.meshMan.processMeshData(); | 91 | RDGE.globals.meshMan.processMeshData(); |
91 | 92 | ||
92 | if (curSceneReq.doSceneRequest) { | 93 | if (curSceneReq.doSceneRequest) { |
93 | curSceneReq.requestScene(); | 94 | curSceneReq.requestScene(); |
94 | } | 95 | } |
95 | else if (curSceneReq.requestComplete) { | 96 | else if (curSceneReq.requestComplete) { |
96 | if (curSceneReq.sceneBeginProcessing) { | 97 | if (curSceneReq.sceneBeginProcessing) { |
97 | // Load meshes attached to the scene | 98 | // Load meshes attached to the scene |
98 | curSceneReq.scene = new RDGE.SceneGraph(curSceneReq.rawData); | 99 | curSceneReq.scene = new RDGE.SceneGraph(curSceneReq.rawData); |
99 | curSceneReq.scene.enableShadows( true ); | 100 | curSceneReq.scene.enableShadows( true ); |
100 | RDGE.globals.engine.AddScene(curSceneReq.name, curSceneReq.scene); | 101 | RDGE.globals.engine.AddScene(curSceneReq.name, curSceneReq.scene); |
101 | 102 | ||
102 | // setup the scene and save a map of mesh names | 103 | // setup the scene and save a map of mesh names |
103 | // that will be check off as the meshes load | 104 | // that will be check off as the meshes load |
104 | curSceneReq.scene.Traverse(curSceneReq.sceneProcessor, false); | 105 | curSceneReq.scene.Traverse(curSceneReq.sceneProcessor, false); |
105 | 106 | ||
106 | // processing is complete | 107 | // processing is complete |
107 | curSceneReq.sceneBeginProcessing = false; | 108 | curSceneReq.sceneBeginProcessing = false; |
108 | } | 109 | } |
109 | // if we are here than the scene is processed but meshes are still loading/processing asynchronously | 110 | // if we are here than the scene is processed but meshes are still loading/processing asynchronously |
110 | else if (curSceneReq.processingComplete()) { | 111 | else if (curSceneReq.processingComplete()) { |
111 | // pop the head node | 112 | // pop the head node |
112 | var sceneReq = this.sceneLoadQueue.shift(); | 113 | var sceneReq = this.sceneLoadQueue.shift(); |
113 | this.userRunState.onComplete(sceneReq.name, sceneReq.scene); | 114 | this.userRunState.onComplete(sceneReq.name, sceneReq.scene); |
114 | } | 115 | } |
115 | } | 116 | } |
116 | 117 | ||
117 | } | 118 | } |
118 |