From b89a7ee8b956c96a1dcee995ea840feddc5d4b27 Mon Sep 17 00:00:00 2001 From: Pierre Frisch Date: Thu, 22 Dec 2011 07:25:50 -0800 Subject: First commit of Ninja to ninja-internal Signed-off-by: Valerio Virgillito --- js/helper-classes/RDGE/MaterialsLibrary.js | 197 +++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 js/helper-classes/RDGE/MaterialsLibrary.js (limited to 'js/helper-classes/RDGE/MaterialsLibrary.js') diff --git a/js/helper-classes/RDGE/MaterialsLibrary.js b/js/helper-classes/RDGE/MaterialsLibrary.js new file mode 100644 index 00000000..edc4f7da --- /dev/null +++ b/js/helper-classes/RDGE/MaterialsLibrary.js @@ -0,0 +1,197 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +/////////////////////////////////////////////////////////////////////// +// Class MaterialsLibrary +// Contains an array of GLMaterials. +/////////////////////////////////////////////////////////////////////// +var MaterialsLibrary = Object.create(Object.prototype, { + + _materials : { value: [], writable: true, enumerable: true, configurable: true }, + + materials : { + get: function() { + return this._materials; + } + }, + + addMaterial: { + value: function (material) + { + this._materials.push(material); + } + }, + + addMaterialAt: { + value: function (material, index) + { + this._materials.splice(index, 0, material); + } + }, + + removeMaterialAt: { + value: function (index) + { + return this._materials.splice(index, 1); + } + }, + + removeMaterial: { + value: function (materialName) + { + var index = this.getIndexOfMaterial(materialName); + if(index !== -1) + { + return this.removeMaterialAt(index); + } + } + }, + + getMaterialAt: { + value: function (index) + { + return this._materials[index]; + } + }, + + getMaterial: { + value: function (materialName) + { + var index = this.getIndexOfMaterial(materialName); + if(index !== -1) + { + return this._materials[index]; + } + } + }, + + getIndexOfMaterial: { + value: function (materialName) + { + var len = this._materials.length; + for(var i=0; i