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/rdge/materials/flat-material.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'js/lib/rdge/materials/flat-material.js') diff --git a/js/lib/rdge/materials/flat-material.js b/js/lib/rdge/materials/flat-material.js index 40da9305..e5498b65 100755 --- a/js/lib/rdge/materials/flat-material.js +++ b/js/lib/rdge/materials/flat-material.js @@ -34,7 +34,22 @@ var FlatMaterial = function FlatMaterial() { // Methods /////////////////////////////////////////////////////////////////////// // duplcate method requirde - this.dup = function () { return new FlatMaterial(); }; + this.dup = function( world ) + { + // get the current values; + var propNames = [], propValues = [], propTypes = [], propLabels = []; + this.getAllProperties(propNames, propValues, propTypes, propLabels); + + // allocate a new material + var newMat = new FlatMaterial(); + + // copy over the current values; + var n = propNames.length; + for (var i = 0; i < n; i++) + newMat.setProperty(propNames[i], propValues[i]); + + return newMat; + }; this.init = function (world) { // save the world @@ -72,6 +87,7 @@ var FlatMaterial = function FlatMaterial() { // make sure we have legitimate input if (this.validateProperty(prop, value)) { this._propValues[prop] = value; + if (prop === 'color') this._color = value.slice(); if (this._shader && this._shader.colorMe) { this._shader.colorMe[prop].set(value); } -- cgit v1.2.3