diff options
Diffstat (limited to 'js')
29 files changed, 625 insertions, 257 deletions
diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js index 21de9879..b5df3911 100644 --- a/js/controllers/elements/canvas-controller.js +++ b/js/controllers/elements/canvas-controller.js | |||
@@ -34,12 +34,12 @@ exports.CanvasController = Montage.create(ElementController, { | |||
34 | } | 34 | } |
35 | } | 35 | } |
36 | }, | 36 | }, |
37 | 37 | ||
38 | setProperties: { | 38 | setProperties: { |
39 | value: function(el, props, index) { | 39 | value: function(el, props, index) { |
40 | for(var p in props) { | 40 | for(var p in props) { |
41 | el.elementModel.controller.setProperty(el, p, props[p][index]); | 41 | el.elementModel.controller.setProperty(el, p, props[p][index]); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | } | 44 | } |
45 | }); \ No newline at end of file | 45 | }); \ No newline at end of file |
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js index fc2e6460..8f7a5d30 100644 --- a/js/helper-classes/RDGE/GLCircle.js +++ b/js/helper-classes/RDGE/GLCircle.js | |||
@@ -63,14 +63,16 @@ function GLCircle() | |||
63 | 63 | ||
64 | this.m_world = world; | 64 | this.m_world = world; |
65 | 65 | ||
66 | |||
66 | if(strokeMaterial) | 67 | if(strokeMaterial) |
67 | { | ||
68 | this._strokeMaterial = strokeMaterial; | 68 | this._strokeMaterial = strokeMaterial; |
69 | } | 69 | else |
70 | this._strokeMaterial = new FlatMaterial(); | ||
71 | |||
70 | if(fillMaterial) | 72 | if(fillMaterial) |
71 | { | ||
72 | this._fillMaterial = fillMaterial; | 73 | this._fillMaterial = fillMaterial; |
73 | } | 74 | else |
75 | this._fillMaterial = new FlatMaterial(); | ||
74 | } | 76 | } |
75 | 77 | ||
76 | /////////////////////////////////////////////////////////////////////// | 78 | /////////////////////////////////////////////////////////////////////// |
diff --git a/js/helper-classes/RDGE/GLGeomObj.js b/js/helper-classes/RDGE/GLGeomObj.js index 72019703..e04b3283 100644 --- a/js/helper-classes/RDGE/GLGeomObj.js +++ b/js/helper-classes/RDGE/GLGeomObj.js | |||
@@ -99,6 +99,9 @@ function GLGeomObj() | |||
99 | } | 99 | } |
100 | } | 100 | } |
101 | } | 101 | } |
102 | |||
103 | var world = this.getWorld(); | ||
104 | if (world) world.restartRenderLoop(); | ||
102 | } | 105 | } |
103 | 106 | ||
104 | this.setFillColor = function(c) { this.setMaterialColor(c, "fill"); } | 107 | this.setFillColor = function(c) { this.setMaterialColor(c, "fill"); } |
diff --git a/js/helper-classes/RDGE/GLMaterial.js b/js/helper-classes/RDGE/GLMaterial.js index 51c27ace..c633f679 100644 --- a/js/helper-classes/RDGE/GLMaterial.js +++ b/js/helper-classes/RDGE/GLMaterial.js | |||
@@ -62,6 +62,10 @@ function GLMaterial( world ) | |||
62 | this.getShader = function() { return this._shader; } | 62 | this.getShader = function() { return this._shader; } |
63 | this.getMaterialNode = function() { return this._materialNode; } | 63 | this.getMaterialNode = function() { return this._materialNode; } |
64 | 64 | ||
65 | // a material can be animated or not. default is not. | ||
66 | // Any material needing continuous rendering should override this method | ||
67 | this.isAnimated = function() { return false; } | ||
68 | |||
65 | 69 | ||
66 | /////////////////////////////////////////////////////////////////////// | 70 | /////////////////////////////////////////////////////////////////////// |
67 | // Common Material Methods | 71 | // Common Material Methods |
@@ -174,6 +178,31 @@ function GLMaterial( world ) | |||
174 | // animated materials should implement the update method | 178 | // animated materials should implement the update method |
175 | } | 179 | } |
176 | 180 | ||
181 | this.registerTexture = function( texture ) | ||
182 | { | ||
183 | // the world needs to know about the texture map | ||
184 | var world = this.getWorld(); | ||
185 | if (!world) | ||
186 | console.log( "**** world not defined for registering texture map: " + texture.lookUpName ); | ||
187 | else | ||
188 | world.textureToLoad( texture ); | ||
189 | } | ||
190 | |||
191 | this.loadTexture = function( texMapName, wrap, mips ) | ||
192 | { | ||
193 | var tex; | ||
194 | var world = this.getWorld(); | ||
195 | if (!world) | ||
196 | console.log( "world not defined for material with texture map" ); | ||
197 | else | ||
198 | { | ||
199 | var renderer = world.getRenderer(); | ||
200 | tex = renderer.getTextureByName(texMapName, wrap, mips ); | ||
201 | this.registerTexture( tex ); | ||
202 | } | ||
203 | return tex; | ||
204 | } | ||
205 | |||
177 | this.export = function() | 206 | this.export = function() |
178 | { | 207 | { |
179 | // this function should be overridden by subclasses | 208 | // this function should be overridden by subclasses |
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 1334d7e6..bc3b1478 100644 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js | |||
@@ -80,13 +80,14 @@ function GLRectangle() | |||
80 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; | 80 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; |
81 | 81 | ||
82 | if(strokeMaterial) | 82 | if(strokeMaterial) |
83 | { | ||
84 | this._strokeMaterial = strokeMaterial; | 83 | this._strokeMaterial = strokeMaterial; |
85 | } | 84 | else |
85 | this._strokeMaterial = new FlatMaterial(); | ||
86 | |||
86 | if(fillMaterial) | 87 | if(fillMaterial) |
87 | { | ||
88 | this._fillMaterial = fillMaterial; | 88 | this._fillMaterial = fillMaterial; |
89 | } | 89 | else |
90 | this._fillMaterial = new FlatMaterial(); | ||
90 | } | 91 | } |
91 | 92 | ||
92 | /////////////////////////////////////////////////////////////////////// | 93 | /////////////////////////////////////////////////////////////////////// |
@@ -278,10 +279,10 @@ function GLRectangle() | |||
278 | brRadius = -z*(r-l)/(2.0*zn)*brRadiusNDC; | 279 | brRadius = -z*(r-l)/(2.0*zn)*brRadiusNDC; |
279 | 280 | ||
280 | // stroke | 281 | // stroke |
281 | var strokeMaterial = this.makeStrokeMaterial(); | 282 | // var strokeMaterial = this.makeStrokeMaterial(); |
282 | prim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial) | 283 | // prim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial) |
283 | this._primArray.push( prim ); | 284 | // this._primArray.push( prim ); |
284 | this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); | 285 | // this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); |
285 | 286 | ||
286 | // fill | 287 | // fill |
287 | tlRadius -= strokeSize; if (tlRadius < 0) tlRadius = 0.0; | 288 | tlRadius -= strokeSize; if (tlRadius < 0) tlRadius = 0.0; |
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index cc44da50..b84bb585 100644 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -65,6 +65,11 @@ function GLWorld( canvas, use3D ) | |||
65 | 65 | ||
66 | this._camera; | 66 | this._camera; |
67 | 67 | ||
68 | // keep a flag indicating whether a render has been completed. | ||
69 | // this allows us to turn off automatic updating if there are | ||
70 | // no animated materials | ||
71 | this._firstRender = true; | ||
72 | |||
68 | /////////////////////////////////////////////////////////////////////// | 73 | /////////////////////////////////////////////////////////////////////// |
69 | // Property accessors | 74 | // Property accessors |
70 | /////////////////////////////////////////////////////////////////////// | 75 | /////////////////////////////////////////////////////////////////////// |
@@ -103,6 +108,8 @@ function GLWorld( canvas, use3D ) | |||
103 | 108 | ||
104 | this.isWebGL = function() { return this._useWebGL; } | 109 | this.isWebGL = function() { return this._useWebGL; } |