aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/document/html-document.js41
-rwxr-xr-xjs/helper-classes/3D/view-utils.js8
-rwxr-xr-xjs/helper-classes/RDGE/GLCircle.js142
-rwxr-xr-xjs/helper-classes/RDGE/GLGeomObj.js4
-rwxr-xr-xjs/helper-classes/RDGE/GLLine.js69
-rwxr-xr-xjs/helper-classes/RDGE/GLRectangle.js83
-rwxr-xr-xjs/helper-classes/RDGE/GLWorld.js29
-rwxr-xr-xjs/helper-classes/RDGE/rdge-compiled.js28
-rw-r--r--js/helper-classes/RDGE/runtime/CanvasDataManager.js98
-rw-r--r--js/helper-classes/RDGE/runtime/GLRuntime.js159
-rw-r--r--js/helper-classes/RDGE/src/tools/rdge-compiled.js28
-rwxr-xr-xjs/preloader/Preloader.js3
-rwxr-xr-xjs/tools/LineTool.js5
13 files changed, 467 insertions, 230 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 9a7755e6..f5816f64 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -152,13 +152,13 @@ exports.HTMLDocument = Montage.create(TextDocument, {
152 glData: { 152 glData: {
153 get: function() 153 get: function()
154 { 154 {
155 var elt = this.iframe;
156 var elt = this.iframe.contentWindow.document.getElementById("UserContent"); 155 var elt = this.iframe.contentWindow.document.getElementById("UserContent");
157 this._glData = null; 156 this._glData = null;
158 if (elt) 157 if (elt)
159 { 158 {
160 this._glData = new Array(); 159 var cdm = new CanvasDataManager();
161 this.collectGLData( elt, this._glData ); 160 this._glData = [];
161 cdm.collectGLData( elt, this._glData );
162 } 162 }
163 163
164 return this._glData 164 return this._glData
@@ -166,37 +166,12 @@ exports.HTMLDocument = Montage.create(TextDocument, {
166 166
167 set: function(value) 167 set: function(value)
168 { 168 {
169 var nWorlds = value.length; 169 var elt = this.iframe.contentWindow.document.getElementById("UserContent");
170 for (var i=0; i<nWorlds; i++) 170 if (elt)
171 { 171 {
172 var importStr = value[i]; 172 console.log( "load canvas data: " + value );
173 var startIndex = importStr.indexOf( "id: " ); 173 var cdm = new CanvasDataManager();
174 if (startIndex >= 0) 174 cdm.loadGLData(elt, value);
175 {
176 var endIndex = importStr.indexOf( "\n", startIndex );
177 if (endIndex > 0)
178 {
179 var id = importStr.substring( startIndex+4, endIndex );
180 var canvas = this.iframe.contentWindow.document.getElementById( id );
181 if (canvas)
182 {
183 if (!canvas.elementModel)
184 {
185 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
186 }
187
188 if (canvas.elementModel)
189 {
190 if (canvas.elementModel.shapeModel.GLWorld)
191 canvas.elementModel.shapeModel.GLWorld.clearTree();
192
193 var world = new GLWorld( canvas );
194 canvas.elementModel.shapeModel.GLWorld = world;
195 world.import( importStr );
196 }
197 }
198 }
199 }
200 } 175 }
201 } 176 }
202 }, 177 },
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index a2fac34f..bedda8bf 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -1226,6 +1226,14 @@ exports.ViewUtils = Montage.create(Component, {
1226 } 1226 }
1227 }, 1227 },
1228 1228
1229 getCurrentDocument:
1230 {
1231 value: function()
1232 {
1233 return snapManagerModule.SnapManager.application.ninja.currentDocument;
1234 }
1235 },
1236
1229 setStageZoom: { 1237 setStageZoom: {
1230 value:function( globalPt, zoomFactor ) { 1238 value:function( globalPt, zoomFactor ) {
1231 var localPt; 1239 var localPt;
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js
index 5b32547e..15ed6b6d 100755
--- a/js/helper-classes/RDGE/GLCircle.js
+++ b/js/helper-classes/RDGE/GLCircle.js
@@ -47,8 +47,8 @@ function GLCircle()
47 47
48 this._strokeWidth = strokeSize; 48 this._strokeWidth = strokeSize;
49 this._innerRadius = innerRadius; 49 this._innerRadius = innerRadius;
50 this._strokeColor = strokeColor; 50 if (strokeColor) this._strokeColor = strokeColor;
51 this._fillColor = fillColor; 51 if (fillColor) this._fillColor = fillColor;
52 52
53 this._strokeStyle = strokeStyle; 53 this._strokeStyle = strokeStyle;
54 } 54 }
@@ -135,7 +135,7 @@ function GLCircle()
135 if (!world._useWebGL) return; 135 if (!world._useWebGL) return;
136 136
137 // make sure RDGE has the correct context 137 // make sure RDGE has the correct context
138 g_Engine.setContext( world.getCanvas().uuid ); 138 g_Engine.setContext( world.getCanvas().rdgeid );
139 139
140 // create the gl buffer 140 // create the gl buffer
141 var gl = world.getGLContext(); 141 var gl = world.getGLContext();
@@ -398,59 +398,58 @@ function GLCircle()
398 // set up the fill style 398 // set up the fill style
399 ctx.beginPath(); 399 ctx.beginPath();
400 ctx.lineWidth = 0; 400 ctx.lineWidth = 0;
401 ctx.fillStyle = "#990000";
402 if (this._fillColor) 401 if (this._fillColor)
403 { 402 {
404 var c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")"; 403 var c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")";
405 ctx.fillStyle = c; 404 ctx.fillStyle = c;
406 }
407 405
408 // draw the fill 406 // draw the fill
409 ctx.beginPath(); 407 ctx.beginPath();
410 var p = MathUtils.transformPoint( bezPts[0], mat ); 408 var p = MathUtils.transformPoint( bezPts[0], mat );
411 ctx.moveTo( p[0], p[1] ); 409 ctx.moveTo( p[0], p[1] );
412 var index = 1; 410 var index = 1;
413 while (index < n) 411 while (index < n)
414 { 412 {
415 p0 = MathUtils.transformPoint( bezPts[index], mat ); 413 p0 = MathUtils.transformPoint( bezPts[index], mat );
416 p1 = MathUtils.transformPoint( bezPts[index+1], mat ); 414 p1 = MathUtils.transformPoint( bezPts[index+1], mat );
417 415
418 x0 = p0[0]; y0 = p0[1]; 416 x0 = p0[0]; y0 = p0[1];
419 x1 = p1[0]; y1 = p1[1]; 417 x1 = p1[0]; y1 = p1[1];
420 ctx.quadraticCurveTo( x0, y0, x1, y1 ); 418 ctx.quadraticCurveTo( x0, y0, x1, y1 );
421 index += 2; 419 index += 2;
422 } 420 }
423 421
424 if ( MathUtils.fpSign(innerRad) > 0) 422 if ( MathUtils.fpSign(innerRad) > 0)
425 {
426 xScale = 0.5*innerRad*this._width;
427 yScale = 0.5*innerRad*this._height;
428 mat[0] = xScale;
429 mat[5] = yScale;
430
431 // get the bezier points
432 var bezPts = MathUtils.circularArcToBezier( Vector.create([0,0,0]), Vector.create([1,0,0]), -2.0*Math.PI );
433 if (bezPts)
434 { 423 {
435 var n = bezPts.length; 424 xScale = 0.5*innerRad*this._width;
436 p = MathUtils.transformPoint( bezPts[0], mat ); 425 yScale = 0.5*innerRad*this._height;
437 ctx.moveTo( p[0], p[1] ); 426 mat[0] = xScale;
438 index = 1; 427 mat[5] = yScale;
439 while (index < n) 428
429 // get the bezier points
430 var bezPts = MathUtils.circularArcToBezier( Vector.create([0,0,0]), Vector.create([1,0,0]), -2.0*Math.PI );
431 if (bezPts)
440 { 432 {
441 p0 = MathUtils.transformPoint( bezPts[index], mat ); 433 var n = bezPts.length;
442 p1 = MathUtils.transformPoint( bezPts[index+1], mat ); 434 p = MathUtils.transformPoint( bezPts[0], mat );
443 435 ctx.moveTo( p[0], p[1] );
444 var x0 = p0[0], y0 = p0[1], 436 index = 1;
445 x1 = p1[0], y1 = p1[1]; 437 while (index < n)
446 ctx.quadraticCurveTo( x0, y0, x1, y1 ); 438 {
447 index += 2; 439 p0 = MathUtils.transformPoint( bezPts[index], mat );
440 p1 = MathUtils.transformPoint( bezPts[index+1], mat );
441
442 var x0 = p0[0], y0 = p0[1],
443 x1 = p1[0], y1 = p1[1];
444 ctx.quadraticCurveTo( x0, y0, x1, y1 );
445 index += 2;
446 }
448 }