diff options
Diffstat (limited to 'js/lib')
35 files changed, 3680 insertions, 3302 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 4f1082f9..67bb59c4 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js | |||
@@ -94,19 +94,53 @@ exports.NJUtils = Object.create(Object.prototype, { | |||
94 | ///// TODO: find a different place for this function | 94 | ///// TODO: find a different place for this function |
95 | makeElementModel: { | 95 | makeElementModel: { |
96 | value: function(el, selection, controller, isShape) { | 96 | value: function(el, selection, controller, isShape) { |
97 | var p3d = Montage.create(Properties3D).init(el); | 97 | var p3d = Montage.create(Properties3D); |
98 | if(selection === "Stage") { | ||
99 | p3d.init(el, true); | ||
100 | } | ||
98 | var shapeProps = null; | 101 | var shapeProps = null; |
102 | var pi = controller + "Pi"; | ||
103 | |||
99 | if(isShape) { | 104 | if(isShape) { |
100 | shapeProps = Montage.create(ShapeModel); | 105 | shapeProps = Montage.create(ShapeModel); |
101 | } | 106 | } |
102 | 107 | ||
108 | if(el.controller) { | ||
109 | |||
110 | var componentInfo = Montage.getInfoForObject(el.controller); | ||
111 | var componentName = componentInfo.objectName.toLowerCase(); | ||
112 | |||
113 | controller = "component"; | ||
114 | isShape = false; | ||
115 | |||
116 | switch(componentName) { | ||
117 | case "feedreader": | ||
118 | selection = "Feed Reader"; | ||
119 | pi = "FeedReaderPi"; | ||
120 | break; | ||
121 | case "map": | ||
122 | selection = "Map"; | ||
123 | pi = "MapPi"; | ||
124 | break; | ||
125 | case "youtubechannel": | ||
126 | selection = "Youtube Channel"; | ||
127 | pi = "YoutubeChannelPi"; | ||
128 | break; | ||
129 | case "picasacarousel": | ||
130 | selection = "Picasa Carousel"; | ||
131 | pi = "PicasaCarouselPi"; | ||
132 | break; | ||
133 | } | ||
134 | } | ||
135 | |||
103 | el.elementModel = Montage.create(ElementModel, { | 136 | el.elementModel = Montage.create(ElementModel, { |
104 | type: { value: el.nodeName}, | 137 | type: { value: el.nodeName}, |
105 | selection: { value: selection}, | 138 | selection: { value: selection}, |
106 | controller: { value: ControllerFactory.getController(controller)}, | 139 | controller: { value: ControllerFactory.getController(controller)}, |
107 | pi: { value: controller + "Pi"}, | 140 | pi: { value: pi}, |
108 | props3D: { value: p3d}, | 141 | props3D: { value: p3d}, |
109 | shapeModel: { value: shapeProps} | 142 | shapeModel: { value: shapeProps}, |
143 | isShape: { value: isShape} | ||
110 | }); | 144 | }); |
111 | 145 | ||
112 | } | 146 | } |
@@ -138,6 +172,7 @@ exports.NJUtils = Object.create(Object.prototype, { | |||
138 | // TODO - Need more info about the shape | 172 | // TODO - Need more info about the shape |
139 | selection = "canvas"; | 173 | selection = "canvas"; |
140 | controller = "shape"; | 174 | controller = "shape"; |
175 | isShape = true; | ||
141 | } | 176 | } |
142 | else | 177 | else |
143 | { | 178 | { |
@@ -149,6 +184,9 @@ exports.NJUtils = Object.create(Object.prototype, { | |||
149 | break; | 184 | break; |
150 | } | 185 | } |
151 | this.makeElementModel(el, selection, controller, isShape); | 186 | this.makeElementModel(el, selection, controller, isShape); |
187 | if(el.elementModel && el.elementModel.props3D) { | ||
188 | el.elementModel.props3D.init(el, (selection === "Stage")); | ||
189 | } | ||
152 | } | 190 | } |
153 | }, | 191 | }, |
154 | 192 | ||
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index df24f556..945c9883 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -117,6 +117,8 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
117 | 117 | ||
118 | this.getRenderer = function() { return this.renderer; }; | 118 | this.getRenderer = function() { return this.renderer; }; |
119 | 119 | ||
120 | // Flag to play/pause animation at authortime | ||
121 | this._previewAnimation = true; | ||
120 | //////////////////////////////////////////////////////////////////////////////////// | 122 | //////////////////////////////////////////////////////////////////////////////////// |
121 | // RDGE | 123 | // RDGE |
122 | // local variables | 124 | // local variables |
@@ -142,45 +144,45 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
142 | 144 | ||
143 | // post-load processing of the scene | 145 | // post-load processing of the scene |
144 | this.init = function() { | 146 | this.init = function() { |
145 | var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), | 147 | var ctx1 = RDGE.globals.engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), |
146 | ctx2 = g_Engine.getContext(); | 148 | ctx2 = RDGE.globals.engine.getContext(); |
147 | if (ctx1 != ctx2) console.log( "***** different contexts *****" ); | 149 | if (ctx1 != ctx2) console.log( "***** different contexts *****" ); |
148 | this.renderer = ctx1.renderer; | 150 | this.renderer = ctx1.renderer; |
149 | this.renderer._world = this; | 151 | this.renderer._world = this; |
150 | 152 | ||
151 | // create a camera, set its perspective, and then point it at the origin | 153 | // create a camera, set its perspective, and then point it at the origin |
152 | var cam = new camera(); | 154 | var cam = new RDGE.camera(); |
153 | this._camera = cam; | 155 | this._camera = cam; |
154 | cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar()); | 156 | cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar()); |
155 | cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], vec3.up()); | 157 | cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], RDGE.vec3.up()); |
156 | 158 | ||
157 | // make this camera the active camera | 159 | // make this camera the active camera |
158 | this.renderer.cameraManager().setActiveCamera(cam); | 160 | this.renderer.cameraManager().setActiveCamera(cam); |
159 | 161 | ||
160 | // change clear color | 162 | // change clear color |
161 | //this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT); | 163 | //this.renderer.setClearFlags(RDGE.globals.engine.getContext().DEPTH_BUFFER_BIT); |
162 | this.renderer.setClearColor([0.0, 0.0, 0.0, 0.0]); | 164 | this.renderer.setClearColor([0.0, 0.0, 0.0, 0.0]); |
163 | //this.renderer.NinjaWorld = this; | 165 | //this.renderer.NinjaWorld = this; |
164 | 166 | ||
165 | // create an empty scene graph | 167 | // create an empty scene graph |
166 | this.myScene = new SceneGraph(); | 168 | this.myScene = new RDGE.SceneGraph(); |
167 | 169 | ||
168 | // create some lights | 170 | // create some lights |
169 | // light 1 | 171 | // light 1 |
170 | this.light = createLightNode("myLight"); | 172 | this.light = RDGE.createLightNode("myLight"); |
171 | this.light.setPosition([0,0,1.2]); | 173 | this.light.setPosition([0,0,1.2]); |
172 | this.light.setDiffuseColor([0.75,0.9,1.0,1.0]); | 174 | this.light.setDiffuseColor([0.75,0.9,1.0,1.0]); |
173 | 175 | ||
174 | // light 2 | 176 | // light 2 |
175 | this.light2 = createLightNode("myLight2"); | 177 | this.light2 = RDGE.createLightNode("myLight2"); |
176 | this.light2.setPosition([-0.5,0,1.2]); | 178 | this.light2.setPosition([-0.5,0,1.2]); |
177 | this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]); | 179 | this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]); |
178 | 180 | ||
179 | // create a light transform | 181 | // create a light transform |
180 | var lightTr = createTransformNode("lightTr"); | 182 | var lightTr = RDGE.createTransformNode("lightTr"); |
181 | 183 | ||
182 | // create and attach a material - materials hold the light data | 184 | // create and attach a material - materials hold the light data |
183 | lightTr.attachMaterial(createMaterialNode("lights")); | 185 | lightTr.attachMaterial(RDGE.createMaterialNode("lights")); |
184 | 186 | ||
185 | // enable light channels 1, 2 - channel 0 is used by the default shader | 187 | // enable light channels 1, 2 - channel 0 is used by the default shader |
186 | lightTr.materialNode.enableLightChannel(1, this.light); | 188 | lightTr.materialNode.enableLightChannel(1, this.light); |
@@ -193,9 +195,9 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
193 | this.myScene.addNode(lightTr); | 195 | this.myScene.addNode(lightTr); |
194 | 196 | ||
195 | // Add the scene to the engine - necessary if you want the engine to draw for you | 197 | // Add the scene to the engine - necessary if you want the engine to draw for you |
196 | //g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); | 198 | //RDGE.globals.engine.AddScene("myScene" + this._canvas.id, this.myScene); |
197 | var name = this._canvas.getAttribute( "data-RDGE-id" ); |