From f031c950361251e45f4c2e6795bcb832985e9d25 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 7 May 2012 16:31:04 -0700 Subject: Moving webGL to own helper class Cleaning up webGL for better working files. --- js/document/models/html.js | 196 ++------------------------------------------- 1 file changed, 6 insertions(+), 190 deletions(-) (limited to 'js/document/models') diff --git a/js/document/models/html.js b/js/document/models/html.js index e0a18850..1639a8e2 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -6,11 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - BaseDocumentModel = require("js/document/models/base").BaseDocumentModel, - MaterialsModel = require("js/models/materials-model").MaterialsModel, - NJUtils = require("js/lib/NJUtils").NJUtils, - GLWorld = require("js/lib/drawing/world").World; +var Montage = require("montage/core/core").Montage, + BaseDocumentModel = require("js/document/models/base").BaseDocumentModel, + webGlDocumentHelper = require("js/document/helpers/webgl-helper").webGlDocumentHelper; //////////////////////////////////////////////////////////////////////// // exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { @@ -26,191 +24,9 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { }, //////////////////////////////////////////////////////////////////// // - _glData: { - value: null - }, - //////////////////////////////////////////////////////////////////// - // - glData: { - // - get: function() { - // - var elt = this.views.design.iframe.contentWindow.document.body; - // - if (elt) { - var matLib = MaterialsModel.exportMaterials(); - this._glData = [matLib]; - this.collectGLData(elt, this._glData ); - } else { - this._glData = null - } - // - return this._glData; - }, - // - set: function(value) { - // - var elt = this.views.design.iframe.contentWindow.document.body; - // - if (elt) { - /* - // Use this code to test the runtime version of WebGL - var cdm = new NinjaCvsRt.CanvasDataManager(); - cdm.loadGLData(elt, value, null ); - */ - - // - var i, nWorlds= value.length; - // - for (i = 0; i < nWorlds; i++) { - // get the data for the next canvas - var importStr = value[i], id, jObj, index = importStr.indexOf(';'), matLibStr, matLibObj, startIndex, endIndex, canvas, useWebGL, world; - // determine if it is the new (JSON) or old style format - if ((importStr[0] === 'v') && (index < 24)) { - // JSON format. pull off the - importStr = importStr.substr(index+1); - jObj = JSON.parse(importStr); - id = jObj.id; - } else { - // at this point the data could be either the materials library or - // an old style world. We can determine which by converting the string - // to an object via JSON.parse. That operation will fail if the string - // is an old style world. - matLibStr = 'materialLibrary;'; - index = importStr.indexOf(matLibStr); - if (index == 0) { - importStr = importStr.substr(matLibStr.length); - matLibObj = JSON.parse(importStr); - MaterialsModel.importMaterials(matLibObj); - } else { - startIndex = importStr.indexOf("id: "); - if (startIndex >= 0) { - endIndex = importStr.indexOf("\n", startIndex); - if (endIndex > 0) id = importStr.substring(startIndex+4, endIndex); - } - } - } - // - if (id != null) { - // - canvas = this.findCanvasWithID(id, elt); - // - if (canvas) { - // - if (!canvas.elementModel) { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - // - if (canvas.elementModel) { - if (canvas.elementModel.shapeModel.GLWorld) { - canvas.elementModel.shapeModel.GLWorld.clearTree(); - } - // - if (jObj) { - useWebGL = jObj.webGL; - world = new GLWorld(canvas, useWebGL); - world.importJSON(jObj); - } - // - this.buildShapeModel(canvas.elementModel, world); - } - } - } - } - } - } - }, - //////////////////////////////////////////////////////////////////// - // - findCanvasWithID: { - value: function(id, elt) { - // - var i, child, nKids, foundElt, cid = elt.getAttribute("data-RDGE-id"); - // - if (cid == id) return elt; - // - if (elt.children) { - nKids = elt.children.length; - for (i=0; i