aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorhwc4872012-04-02 10:17:48 -0700
committerhwc4872012-04-02 10:17:48 -0700
commit679a0746bedab9c5871a83a5fea6a06ac6a4f41c (patch)
tree9fabe83b2c48ebe1d1ae2b8ed6bb870ceec2fda7 /js
parent947bad893335e1023bcbe177ff8db454c27c4bf8 (diff)
downloadninja-679a0746bedab9c5871a83a5fea6a06ac6a4f41c.tar.gz
texture abstraction
Diffstat (limited to 'js')
-rwxr-xr-xjs/lib/drawing/world.js6
-rwxr-xr-xjs/lib/geom/geom-obj.js4
-rw-r--r--js/lib/rdge/texture.js29
3 files changed, 35 insertions, 4 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index a489110f..402563e9 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -1051,9 +1051,9 @@ World.prototype.importSubObject = function( objStr, parentNode ) {
1051function Notifier() 1051function Notifier()
1052{ 1052{
1053 // notification types supported 1053 // notification types supported
1054 this.OBJECT_DELETE = 1; 1054 this.OBJECT_DELETE = 1;
1055 this.OBJECT_REANIMATE = 2; // the object has come back after a deletion - as in undo 1055 this.OBJECT_REINSTANTIATE = 2; // the object has come back after a deletion - as in undo
1056 this.OBJECT_CHANGE = 3; 1056 this.OBJECT_CHANGE = 3;
1057 1057
1058 1058
1059 // the array of listener objects 1059 // the array of listener objects
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index a87bdbf5..11b9303a 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -220,6 +220,8 @@ var GeomObj = function GLGeomObj() {
220 this.setStrokeColor(this._strokeColor); 220 this.setStrokeColor(this._strokeColor);
221 } 221 }
222 222
223 this._strokeMaterial = strokeMaterial;
224
223 return strokeMaterial; 225 return strokeMaterial;
224 }; 226 };
225 227
@@ -242,6 +244,8 @@ var GeomObj = function GLGeomObj() {
242 this.setFillColor(this._fillColor); 244 this.setFillColor(this._fillColor);
243 } 245 }
244 246
247 this._fillMaterial = fillMaterial;
248
245 return fillMaterial; 249 return fillMaterial;
246 }; 250 };
247 251
diff --git a/js/lib/rdge/texture.js b/js/lib/rdge/texture.js
index d67c65d2..83509f80 100644
--- a/js/lib/rdge/texture.js
+++ b/js/lib/rdge/texture.js
@@ -69,7 +69,7 @@ function Texture( dstWorld, texMapName, wrap, mips )
69 this._srcWorld = srcCanvas.elementModel.shapeModel.GLWorld; 69 this._srcWorld = srcCanvas.elementModel.shapeModel.GLWorld;
70 70
71 // add a notifier to the world 71 // add a notifier to the world
72 this._srcWorld.addListener( this, this.worldCallback, { myObj: 'anything' } ); 72 this._srcWorld.addListener( this, this.worldCallback, { srcWorld: this._srcWorld } );
73 73
74 // check if the source is animated 74 // check if the source is animated
75 if (srcCanvas.elementModel && srcCanvas.elementModel.shapeModel && srcCanvas.elementModel.shapeModel.GLWorld) 75 if (srcCanvas.elementModel && srcCanvas.elementModel.shapeModel && srcCanvas.elementModel.shapeModel.GLWorld)
@@ -87,6 +87,33 @@ function Texture( dstWorld, texMapName, wrap, mips )
87 this.worldCallback = function( type, callbackObj, calleeData, callerData ) 87 this.worldCallback = function( type, callbackObj, calleeData, callerData )
88 { 88 {
89 console.log( "texture callback, type: " + type ); 89 console.log( "texture callback, type: " + type );
90 if (calleeData.srcWorld)
91 {
92 var srcWorld = calleeData.srcWorld;
93 var notifier = srcWorld._notifier;
94 var texture = this.callbackObj;
95 if (texture)
96 {
97 switch (type)
98 {
99 case notifier.OBJECT_DELETE:
100 break;
101
102 case notifier.OBJECT_REINSTANTIATE:
103 break;
104
105 case notifier.OBJECT_CHANGE:
106 if (!texture.isAnimated())
107 texture.rerender();
108 texture.getDstWorld().restartRenderLoop();
109 break;
110
111 default:
112 throw new Exception( "unrecognized texture callback type: " + type );
113 break;
114 }
115 }
116 }
90 } 117 }
91 118
92 this.loadFromFile = function() 119 this.loadFromFile = function()