aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/engine.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-09 14:35:44 -0700
committerValerio Virgillito2012-07-09 14:35:44 -0700
commit84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch)
tree3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/helper-classes/RDGE/src/core/script/engine.js
parentc0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff)
parent40c6eb2c06b34f65a74d59ef9687251952858bab (diff)
downloadninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts: js/components/gradientpicker.reel/gradientpicker.js js/components/tools-properties/text-properties.reel/text-properties.js js/document/views/base.js js/document/views/design.js js/helper-classes/3D/StageLine.js js/helper-classes/3D/draw-utils.js js/lib/drawing/world.js js/lib/geom/circle.js js/lib/geom/line.js js/lib/geom/rectangle.js js/lib/geom/shape-primitive.js js/lib/rdge/materials/bump-metal-material.js js/lib/rdge/materials/flag-material.js js/lib/rdge/materials/fly-material.js js/lib/rdge/materials/julia-material.js js/lib/rdge/materials/keleidoscope-material.js js/lib/rdge/materials/mandel-material.js js/lib/rdge/materials/material.js js/lib/rdge/materials/plasma-material.js js/lib/rdge/materials/pulse-material.js js/lib/rdge/materials/radial-gradient-material.js js/lib/rdge/materials/taper-material.js js/lib/rdge/materials/twist-vert-material.js js/lib/rdge/materials/water-material.js js/panels/Materials/materials-library-panel.reel/materials-library-panel.html js/panels/Materials/materials-library-panel.reel/materials-library-panel.js js/panels/Materials/materials-popup.reel/materials-popup.html js/panels/Materials/materials-popup.reel/materials-popup.js js/tools/LineTool.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/engine.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/engine.js922
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>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility, Inc
3All Rights Reserved. 3All Rights Reserved.
4BSD License. 4BSD License.
5 5
6Redistribution and use in source and binary forms, with or without 6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 7modification, 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
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE. 28POSSIBILITY OF SUCH DAMAGE.
29</copyright> */ 29</copyright> */
30 30
31var RDGE = RDGE || {}; 31var RDGE = RDGE || {};
32 32
33/* 33/*
34 * Manage state instances 34 * Manage state instances
35 */ 35 */
36RDGE.stateManager = function () { 36RDGE.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
103RDGE.Engine = function () { 103RDGE.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;