From 2ab7fbef0df37f0c2bb6a4447f03993b9d50b5d0 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 29 Mar 2012 07:27:49 -0700 Subject: linked textures --- js/lib/drawing/world.js | 72 +++++++------------------------------------------ js/lib/rdge/texture.js | 8 +++++- 2 files changed, 16 insertions(+), 64 deletions(-) (limited to 'js') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index f077a5e2..a489110f 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -364,6 +364,15 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { return str; }; + this.addListener = function( obj, callbackFunc, calleeData ) + { + this._notifier.addListener( obj, callbackFunc, calleeData ); + } + + this.removeListener = function( obj ) + { + this._notifier.removeListener( obj ); + } // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state // in the case of a procedurally built scene an init state is not needed for loading data @@ -818,70 +827,7 @@ World.prototype.exportObjectsJSON = function( obj, parentObj ) this.exportObjectsJSON( obj.getNext(), parentObj ); } -/* -World.prototype.export = function() -{ - var exportStr = "GLWorld 1.0\n"; - var id = this.getCanvas().getAttribute( "data-RDGE-id" ); - exportStr += "id: " + id + "\n"; - //exportStr += "id: " + this._canvas.rdgeid + "\n"; - exportStr += "fov: " + this._fov + "\n"; - exportStr += "zNear: " + this._zNear + "\n"; - exportStr += "zFar: " + this._zFar + "\n"; - exportStr += "viewDist: " + this._viewDist + "\n"; - if (this._useWebGL) - exportStr += "webGL: true\n"; - - // we need 2 export modes: One for save/restore, one for publish. - // hardcoding for now - //var exportForPublish = false; - //if (!exportForPublish) exportForPublish = false; - var exportForPublish = true; - exportStr += "publish: " + exportForPublish + "\n"; - - if (exportForPublish && this._useWebGL) - { - exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; - - // write out all of the objects - exportStr += "tree\n"; - exportStr += this.exportObjects( this._geomRoot ); - exportStr += "endtree\n"; - } - else - { - // output the material library - //exportStr += MaterialsLibrary.export(); // THIS NEEDS TO BE DONE AT THE DOC LEVEL - - // write out all of the objects - exportStr += "tree\n"; - exportStr += this.exportObjects( this._geomRoot ); - exportStr += "endtree\n"; - } - - return exportStr; -}; - -World.prototype.exportObjects = function( obj ) { - if (!obj) return; - - var rtnStr = "OBJECT\n"; - rtnStr += obj.export(); - if (obj.getChild()) { - rtnStr += this.exportObjects( obj.getChild () ); - } - - // the end object goes outside the children - rtnStr += "ENDOBJECT\n"; - - if (obj.getNext()) { - rtnStr += this.exportObjects( obj.getNext() ); - } - - return rtnStr; -}; -*/ World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) { //if (trNode == null) trNode = this._ctrNode; diff --git a/js/lib/rdge/texture.js b/js/lib/rdge/texture.js index 41c9a54a..d67c65d2 100644 --- a/js/lib/rdge/texture.js +++ b/js/lib/rdge/texture.js @@ -68,6 +68,9 @@ function Texture( dstWorld, texMapName, wrap, mips ) { this._srcWorld = srcCanvas.elementModel.shapeModel.GLWorld; + // add a notifier to the world + this._srcWorld.addListener( this, this.worldCallback, { myObj: 'anything' } ); + // check if the source is animated if (srcCanvas.elementModel && srcCanvas.elementModel.shapeModel && srcCanvas.elementModel.shapeModel.GLWorld) this._isAnimated = this._srcWorld._hasAnimatedMaterials; @@ -79,8 +82,11 @@ function Texture( dstWorld, texMapName, wrap, mips ) { this.loadFromFile(); } + } - + this.worldCallback = function( type, callbackObj, calleeData, callerData ) + { + console.log( "texture callback, type: " + type ); } this.loadFromFile = function() -- cgit v1.2.3