aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/selection-controller.js9
-rwxr-xr-xjs/document/html-document.js108
-rwxr-xr-xjs/helper-classes/RDGE/rdge-compiled.js6
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/engine.js7
-rw-r--r--js/io/system/ninjalibrary.json2
-rwxr-xr-xjs/lib/drawing/world.js147
-rwxr-xr-xjs/lib/geom/circle.js54
-rwxr-xr-xjs/lib/geom/geom-obj.js154
-rwxr-xr-xjs/lib/geom/line.js44
-rwxr-xr-xjs/lib/geom/rectangle.js63
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js40
-rw-r--r--js/lib/rdge/materials/cloud-material.js300
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js21
-rw-r--r--js/lib/rdge/materials/julia-material.js6
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js53
-rw-r--r--js/lib/rdge/materials/mandel-material.js6
-rw-r--r--js/lib/rdge/materials/plasma-material.js18
-rw-r--r--js/lib/rdge/materials/pulse-material.js44
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js57
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js54
-rw-r--r--js/lib/rdge/materials/taper-material.js27
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js28
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js180
-rw-r--r--js/lib/rdge/materials/water-material.js103
-rwxr-xr-xjs/models/materials-model.js90
25 files changed, 1471 insertions, 150 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 154fb7f8..f29b39e2 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -111,6 +111,15 @@ exports.SelectionController = Montage.create(Component, {
111 if(!this._isDocument) { 111 if(!this._isDocument) {
112 if(this.findSelectedElement(event.detail) !== -1) { 112 if(this.findSelectedElement(event.detail) !== -1) {
113 this.executeSelectElement(); 113 this.executeSelectElement();
114 var element = event.detail;
115 if (element) {
116 if (element.elementModel) {
117 if (element.elementModel.shapeModel) {
118 if (element.elementModel.shapeModel.GLWorld)
119 element.elementModel.shapeModel.GLWorld.clearTree();
120 }
121 }
122 }
114 } 123 }
115 } 124 }
116 } 125 }
diff --git a/js/document/html-document.js b/js/document/html-document.js
index d4db6e2f..3d109fdb 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -9,7 +9,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 TextDocument = require("js/document/text-document").TextDocument, 10 TextDocument = require("js/document/text-document").TextDocument,
11 NJUtils = require("js/lib/NJUtils").NJUtils, 11 NJUtils = require("js/lib/NJUtils").NJUtils,
12 GLWorld = require("js/lib/drawing/world").World; 12 GLWorld = require("js/lib/drawing/world").World,
13 MaterialsModel = require("js/models/materials-model").MaterialsModel;
13//////////////////////////////////////////////////////////////////////// 14////////////////////////////////////////////////////////////////////////
14// 15//
15exports.HTMLDocument = Montage.create(TextDocument, { 16exports.HTMLDocument = Montage.create(TextDocument, {
@@ -193,12 +194,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
193 var elt = this.iframe.contentWindow.document.getElementById("UserContent"); 194 var elt = this.iframe.contentWindow.document.getElementById("UserContent");
194 // 195 //
195 if (elt) { 196 if (elt) {
196 this._glData = []; 197 var matLib = MaterialsModel.exportMaterials();
197 //if (path) { 198 this._glData = [matLib];
198 //this.collectGLData(elt, this._glData, path); 199 this.collectGLData(elt, this._glData );
199 //} else {
200 this.collectGLData(elt, this._glData );
201 //}
202 } else { 200 } else {
203 this._glData = null 201 this._glData = null
204 } 202 }
@@ -219,29 +217,74 @@ exports.HTMLDocument = Montage.create(TextDocument, {
219 */ 217 */
220 218
221 // /* 219 // /*
220 // get the data for the next canvas
222 var importStr = value[i]; 221 var importStr = value[i];
223 var startIndex = importStr.indexOf( "id: " ); 222
224 if (startIndex >= 0) { 223 // determine if it is the new (JSON) or old style format
225 var endIndex = importStr.indexOf( "\n", startIndex ); 224 var id = null;
226 if (endIndex > 0) { 225 var jObj = null;
227 var id = importStr.substring( startIndex+4, endIndex ); 226 var index = importStr.indexOf( ';' );
228 if (id) { 227 if ((importStr[0] === 'v') && (index < 24))
229 var canvas = this.findCanvasWithID( id, elt ); 228 {
230 if (canvas) { 229 // JSON format. pull off the
231 if (!canvas.elementModel) { 230 importStr = importStr.substr( index+1 );
232 NJUtils.makeElementModel(canvas, "Canvas", "shape", true); 231 jObj = jObj = JSON.parse( importStr );
233 } 232 id = jObj.id;
234 if (canvas.elementModel) { 233 }
235 if (canvas.elementModel.shapeModel.GLWorld) { 234 else
236 canvas.elementModel.shapeModel.GLWorld.clearTree(); 235 {
237 } 236 // at this point the data could be either the materials library or
238 var index = importStr.indexOf( "webGL: " ); 237 // an old style world. We can determine which by converting the string
239 var useWebGL = (index >= 0) 238 // to an object via JSON.parse. That operation will fail if the string
240 var world = new GLWorld( canvas, useWebGL ); 239 // is an old style world.
241 world.import( importStr ); 240 var matLibStr = 'materialLibrary;';
242 this.buildShapeModel( canvas.elementModel, world ); 241 index = importStr.indexOf( matLibStr );
243 } 242 if (index == 0)
243 {
244 importStr = importStr.substr( matLibStr.length );
245 var matLibObj = JSON.parse( importStr );
246 MaterialsModel.importMaterials( matLibObj );
247 }
248 else
249 {
250 var startIndex = importStr.indexOf( "id: " );
251 if (startIndex >= 0) {
252 var endIndex = importStr.indexOf( "\n", startIndex );
253 if (endIndex > 0)
254 id = importStr.substring( startIndex+4, endIndex );
255 }
256 }
257 }
258
259 if (id != null)
260 {
261 var canvas = this.findCanvasWithID( id, elt );
262 if (canvas)
263 {
264 if (!canvas.elementModel)
265 {
266 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
267 }
268 if (canvas.elementModel)
269 {
270 if (canvas.elementModel.shapeModel.GLWorld)
271 canvas.elementModel.shapeModel.GLWorld.clearTree();
272
273 if (jObj)
274 {
275 var useWebGL = jObj.webGL;
276 var world = new GLWorld( canvas, useWebGL );
277 world.importJSON( jObj );
278 }
279 else
280 {
281 var index = importStr.indexOf( "webGL: " );
282 var useWebGL = (index >= 0);
283 var world = new GLWorld( canvas, useWebGL );
284 world.import( importStr );
244 } 285 }
286
287 this.buildShapeModel( canvas.elementModel, world );
245 } 288 }
246 } 289 }
247 } 290 }
@@ -265,7 +308,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
265 shapeModel.GLGeomObj = root; 308 shapeModel.GLGeomObj = root;
266 shapeModel.strokeSize = root._strokeWidth; 309 shapeModel.strokeSize = root._strokeWidth;
267 shapeModel.stroke = root._strokeColor.slice(); 310 shapeModel.stroke = root._strokeColor.slice();
268 shapeModel.strokeMaterial = root._strokeMaterial.dup(); 311 shapeModel.strokeMaterial = root._strikeMaterial ? root._strokeMaterial.dup() : null;
269 shapeModel.strokeStyle = "solid"; 312 shapeModel.strokeStyle = "solid";
270 //shapeModel.strokeStyleIndex 313 //shapeModel.strokeStyleIndex
271 //shapeModel.border 314 //shapeModel.border
@@ -276,7 +319,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
276 elementModel.selection = "Rectangle"; 319 elementModel.selection = "Rectangle";
277 elementModel.pi = "RectanglePi"; 320 elementModel.pi = "RectanglePi";
278 shapeModel.fill = root._fillColor.slice(); 321 shapeModel.fill = root._fillColor.slice();
279 shapeModel.fillMaterial = root._fillMaterial.dup(); 322 shapeModel.fillMaterial = root._fillMaterial ? root._fillMaterial.dup() : null;
280 shapeModel.tlRadius = root._tlRadius; 323 shapeModel.tlRadius = root._tlRadius;
281 shapeModel.trRadius = root._trRadius; 324 shapeModel.trRadius = root._trRadius;
282 shapeModel.blRadius = root._blRadius; 325 shapeModel.blRadius = root._blRadius;
@@ -287,7 +330,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
287 elementModel.selection = "Oval"; 330 elementModel.selection = "Oval";
288 elementModel.pi = "OvalPi"; 331 elementModel.pi = "OvalPi";
289 shapeModel.fill = root._fillColor.slice(); 332 shapeModel.fill = root._fillColor.slice();
290 shapeModel.fillMaterial = root._fillMaterial.dup(); 333 shapeModel.fillMaterial = root._fillMaterial ? root<