aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js69
-rwxr-xr-xjs/helper-classes/3D/math-utils.js5
-rwxr-xr-xjs/helper-classes/RDGE/GLCircle.js3
-rwxr-xr-xjs/helper-classes/RDGE/GLGeomObj.js46
-rwxr-xr-xjs/helper-classes/RDGE/GLRectangle.js2
-rwxr-xr-xjs/helper-classes/RDGE/GLWorld.js46
-rwxr-xr-xjs/helper-classes/RDGE/Materials/BumpMetalMaterial.js39
-rw-r--r--js/helper-classes/RDGE/Materials/DeformMaterial.js2
-rwxr-xr-xjs/helper-classes/RDGE/Materials/FlatMaterial.js34
-rw-r--r--js/helper-classes/RDGE/Materials/FlyMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/JuliaMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js2
-rwxr-xr-xjs/helper-classes/RDGE/Materials/LinearGradientMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/MandelMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/PlasmaMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/PulseMaterial.js5
-rw-r--r--js/helper-classes/RDGE/Materials/RadialBlurMaterial.js2
-rwxr-xr-xjs/helper-classes/RDGE/Materials/RadialGradientMaterial.js6
-rw-r--r--js/helper-classes/RDGE/Materials/ReliefTunnelMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/SquareTunnelMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/StarMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/TaperMaterial.js4
-rw-r--r--js/helper-classes/RDGE/Materials/TunnelMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/TwistMaterial.js2
-rw-r--r--js/helper-classes/RDGE/Materials/TwistVertMaterial.js2
-rwxr-xr-xjs/helper-classes/RDGE/Materials/UberMaterial.js38
-rw-r--r--js/helper-classes/RDGE/Materials/WaterMaterial.js4
-rw-r--r--js/helper-classes/RDGE/Materials/ZInvertMaterial.js2
-rw-r--r--js/helper-classes/RDGE/runtime/CanvasDataManager.js33
-rw-r--r--js/helper-classes/RDGE/runtime/GLRuntime.js303
-rw-r--r--js/helper-classes/RDGE/runtime/RuntimeGeomObj.js611
-rw-r--r--js/helper-classes/RDGE/runtime/RuntimeMaterial.js282
-rwxr-xr-xjs/lib/NJUtils.js34
-rwxr-xr-xjs/preloader/Preloader.js2
34 files changed, 1436 insertions, 160 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 5d507476..2d7192b7 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -185,9 +185,51 @@ exports.HTMLDocument = Montage.create(TextDocument, {
185 var elt = this.documentRoot; 185 var elt = this.documentRoot;
186 if (elt) 186 if (elt)
187 { 187 {
188 console.log( "load canvas data: " , value ); 188 var loadForRuntime = false;
189 var cdm = new CanvasDataManager(); 189 if (loadForRuntime)
190 cdm.loadGLData(elt, value); 190 {
191 //console.log( "load canvas data: " , value );
192 var cdm = new CanvasDataManager();
193 cdm.loadGLData(elt, value, NJUtils);
194 }
195 else
196 {
197 var nWorlds= value.length;
198 for (var i=0; i<nWorlds; i++)
199 {
200 var importStr = value[i];
201 var startIndex = importStr.indexOf( "id: " );
202 if (startIndex >= 0)
203 {
204 var endIndex = importStr.indexOf( "\n", startIndex );
205 if (endIndex > 0)
206 {
207 var id = importStr.substring( startIndex+4, endIndex );
208 if (id)
209 {
210 var canvas = this.findCanvasWithID( id, elt );
211 if (canvas)
212 {
213 if (!canvas.elementModel)
214 {
215 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
216 }
217
218 if (canvas.elementModel)
219 {
220 if (canvas.elementModel.shapeModel.GLWorld)
221 canvas.elementModel.shapeModel.GLWorld.clearTree();
222
223 var world = new GLWorld( canvas );
224 canvas.elementModel.shapeModel.GLWorld = world;
225 world.import( importStr );
226 }
227 }
228 }
229 }
230 }
231 }
232 }
191 } 233 }
192 } 234 }
193 }, 235 },
@@ -219,6 +261,27 @@ exports.HTMLDocument = Montage.create(TextDocument, {
219 } 261 }
220 } 262 }
221 }, 263 },
264
265 /**
266 * search the DOM tree to find a canvas with the given id
267 */
268 findCanvasWithID: {
269 value: function( id, elt ) {
270 var cid = elt.getAttribute( "data-RDGE-id" );
271 if (cid == id) return elt;
272
273 if (elt.children)
274 {
275 var nKids = elt.children.length;
276 for (var i=0; i<nKids; i++)
277 {
278 var child = elt.children[i];
279 var foundElt = this.findCanvasWithID( id, child );
280 if (foundElt) return foundElt;
281 }
282 }
283 }
284 },
222 285
223 286
224 287
diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js
index 37044763..f084cf9f 100755
--- a/js/helper-classes/3D/math-utils.js
+++ b/js/helper-classes/3D/math-utils.js
@@ -709,7 +709,10 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
709 // the area of the polygon is the length of the normal 709 // the area of the polygon is the length of the normal
710 var area = VecUtils.vecMag(3, normal ); 710 var area = VecUtils.vecMag(3, normal );
711 if (this.fpSign(area) != 0) 711 if (this.fpSign(area) != 0)
712 vec3.scale(normal, 1.0/area); 712 {
713 //vec3.scale(normal, 1.0/area);
714 normal = VecUtils.vecNormalize(3, normal, 1.0);
715 }
713 716
714 return normal; 717 return normal;
715 } 718 }
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js
index 15ed6b6d..59d0bdaf 100755
--- a/js/helper-classes/RDGE/GLCircle.js
+++ b/js/helper-classes/RDGE/GLCircle.js
@@ -381,7 +381,6 @@ function GLCircle()
381 // translate 381 // translate
382 var xCtr = 0.5*world.getViewportWidth() + this._xOffset, 382 var xCtr = 0.5*world.getViewportWidth() + this._xOffset,
383 yCtr = 0.5*world.getViewportHeight() + this._yOffset; 383 yCtr = 0.5*world.getViewportHeight() + this._yOffset;
384 //ctx.setTransform( xScale, 0.0, 0.0, yScale, xCtr, yCtr );
385 var mat = Matrix.create( [ 384 var mat = Matrix.create( [
386 [ xScale, 0.0, 0.0, xCtr], 385 [ xScale, 0.0, 0.0, xCtr],
387 [ 0.0, yScale, 0.0, yCtr], 386 [ 0.0, yScale, 0.0, yCtr],
@@ -538,6 +537,8 @@ function GLCircle()
538 rtnStr += "flatMaterial"; 537 rtnStr += "flatMaterial";
539 rtnStr += "\n"; 538 rtnStr += "\n";
540 539
540 rtnStr += this.exportMaterials();
541
541 return rtnStr; 542 return rtnStr;
542 } 543 }
543 544
diff --git a/js/helper-classes/RDGE/GLGeomObj.js b/js/helper-classes/RDGE/GLGeomObj.js
index c1ee01ba..955f0f39 100755
--- a/js/helper-classes/RDGE/GLGeomObj.js
+++ b/js/helper-classes/RDGE/GLGeomObj.js
@@ -158,6 +158,52 @@ function GLGeomObj()
158 return fillMaterial; 158 return fillMaterial;
159 } 159 }
160 160
161 this.exportMaterials = function()
162 {
163 var rtnStr = "";
164 if (this._materialArray && this._materialNodeArray)
165 {
166 var nMats = this._materialArray.length;
167 rtnStr += "nMaterials: " + nMats + "\n";
168 for (var i=0; i<nMats; i++)
169 {
170 var matNode = this._materialNodeArray[i];
171 rtnStr += "materialNodeName: " + matNode.name + "\n";
172
173 var material = this._materialArray[i];
174 rtnStr += material.export();
175 }
176 }
177 else
178 rtnStr += "nMaterials: 0\n" ;
179
180 return rtnStr;
181 }
182
183 this.importMaterials = function(importStr)
184 {
185 var nMaterials = Number( this.getPropertyFromString( "nMaterials: ", importStr ) );