aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/html-document.js33
1 files changed, 25 insertions, 8 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 8b765501..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,7 +194,8 @@ 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();
198 this._glData = [matLib];
197 this.collectGLData(elt, this._glData ); 199 this.collectGLData(elt, this._glData );
198 } else { 200 } else {
199 this._glData = null 201 this._glData = null
@@ -231,12 +233,27 @@ exports.HTMLDocument = Montage.create(TextDocument, {
231 } 233 }
232 else 234 else
233 { 235 {
234 var startIndex = importStr.indexOf( "id: " ); 236 // at this point the data could be either the materials library or
235 if (startIndex >= 0) { 237 // an old style world. We can determine which by converting the string
236 var endIndex = importStr.indexOf( "\n", startIndex ); 238 // to an object via JSON.parse. That operation will fail if the string
237 if (endIndex > 0) 239 // is an old style world.
238 id = importStr.substring( startIndex+4, endIndex ); 240 var matLibStr = 'materialLibrary;';
239 } 241 index = importStr.indexOf( matLibStr );
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 }
240 } 257 }
241 258
242 if (id != null) 259 if (id != null)