From 8fa51b9d8c37896dfd13a5b238cf990fcbdb0c96 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 23 Mar 2012 13:46:40 -0700 Subject: textures --- js/lib/drawing/world.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/lib/drawing/world.js') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 07a2c3ae..4140208c 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -30,6 +30,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { this._canvas = canvas; if (this._useWebGL) { + preserveDrawingBuffer = true; if(preserveDrawingBuffer) { this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true}); } else { -- cgit v1.2.3 From 2f66a9ab38f761b7796800bb37f8146f140db40b Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 26 Mar 2012 11:31:23 -0700 Subject: WebGL & Canvas as data for texture maps. --- js/lib/drawing/world.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/lib/drawing/world.js') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index d314760b..e3818178 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -327,6 +327,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { var rtnVal = false; if (root) { rtnVal = this.hHasAnimatedMaterials( root ); + this._hasAnimatedMaterials = rtnVal; } return rtnVal; -- cgit v1.2.3 From 0a0aa4662ffa687dd049cc5a24e701cedf87253a Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 28 Mar 2012 05:44:38 -0700 Subject: added a notification procedure to worlds. --- js/lib/drawing/world.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) (limited to 'js/lib/drawing/world.js') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index ebeeeb20..f077a5e2 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -78,6 +78,9 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { // keep a counter for generating node names this._nodeCounter = 0; + // for sending notifications to listeners + this._notifier = new Notifier(); + /////////////////////////////////////////////////////////////////////// // Property accessors /////////////////////////////////////////////////////////////////////// @@ -435,6 +438,9 @@ World.prototype.updateObject = function (obj) { childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); childTrNode.attachMaterial(materialNodes[i]); } + + // send a notification that the tree has changed + this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); }; World.prototype.addObject = function( obj ) { @@ -463,6 +469,9 @@ World.prototype.addObject = function( obj ) { obj.buildBuffers(); this.restartRenderLoop(); } + + // send a notification that the tree has changed + this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); } catch(e) { @@ -520,13 +529,21 @@ World.prototype.addIfNewObject = function (obj) { obj.buildBuffers(); this.restartRenderLoop(); } + + // send a notification that the tree has changed + this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); + } catch (e) { alert("Exception in GLWorld.addIfNewObject " + e); } }; -World.prototype.clearTree = function() { - if (this._useWebGL) { +World.prototype.clearTree = function() +{ + this._notifier.sendNotification( this._notifier.OBJECT_DELETE ); + + if (this._useWebGL) + { var root = this._rootNode; root.children = new Array(); g_Engine.unregisterCanvas( this._canvas.rdgeid ) @@ -1085,6 +1102,56 @@ World.prototype.importSubObject = function( objStr, parentNode ) { return trNode; }; +function Notifier() +{ + // notification types supported + this.OBJECT_DELETE = 1; + this.OBJECT_REANIMATE = 2; // the object has come back after a deletion - as in undo + this.OBJECT_CHANGE = 3; + + + // the array of listener objects + this._listenerArray = []; + + this.sendNotification = function( type, callerData ) + { + var n = this._listenerArray.length; + for (var i=0; i 0) + if (prims.length != materialNodes.length) + throw new Error("inconsistent material and primitive counts"); + var nPrims = prims.length; + var ctrTrNode; + if (nPrims > 0) { - ctrTrNode = obj.getTransformNode(); + ctrTrNode = obj.getTransformNode(); if (ctrTrNode == null) { ctrTrNode = RDGE.createTransformNode("objRootNode_" + this._nodeCounter++); this._rootNode.insertAsChild( ctrTrNode ); @@ -459,42 +459,42 @@ World.prototype.updateObject = function (obj) { ); ctrTrNode.meshes = []; - ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); - ctrTrNode.attachMaterial(materialNodes[0]); - } + ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); + ctrTrNode.attachMaterial(materialNodes[0]); + } + // delete all of the child nodes + var i; + var childTrNode; var children = ctrTrNode.children; - for (var i = 1; i < nPrims; i++) + for (i=0; i= i) { - childTrNode = children[i-1].transformNode; - - childTrNode.meshes.forEach( - function(thisMesh) - { - RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name); - } - ); - childTrNode.meshes = []; - } - else - { - childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); - ctrTrNode.insertAsChild(childTrNode); - } + childTrNode = children[i].transformNode; + childTrNode.meshes.forEach( + function(thisMesh) + { + RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name); + } + ); + childTrNode.meshes = []; + children[i] = null; + } + ctrTrNode.children = []; - // attach the instanced box goe - childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); - childTrNode.attachMaterial(materialNodes[i]); - } + for (var i = 1; i < nPrims; i++) + { + // get the next primitive + var prim = prims[i]; + childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); + ctrTrNode.insertAsChild(childTrNode); + + // attach the instanced box goe + childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); + childTrNode.attachMaterial(materialNodes[i]); + } - // send a notification that the tree has changed - this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); + // send a notification that the tree has changed + this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); }; World.prototype.addObject = function( obj ) -- cgit v1.2.3 From 6c994c4b90023cecf4fd0caafb404b859fe28f54 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 6 Jun 2012 16:34:41 -0700 Subject: material cleanup and rearchitecture --- js/lib/drawing/world.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/lib/drawing/world.js') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 228c0d94..8068284e 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -484,11 +484,11 @@ World.prototype.updateObject = function (obj) { for (var i = 1; i < nPrims; i++) { // get the next primitive - var prim = prims[i]; childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); ctrTrNode.insertAsChild(childTrNode); // attach the instanced box goe + var prim = prims[i]; childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); childTrNode.attachMaterial(materialNodes[i]); } -- cgit v1.2.3