/*
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.
*/
///////////////////////////////////////////////////////////////////////
// MaterialsLibrary module -- Contains an array of GLMaterials.
///////////////////////////////////////////////////////////////////////
var Montage = require("montage/core/core").Montage,
Component = require("montage/ui/component").Component,
AppModel = require("js/models/app-model").AppModel;
var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
var FlatMaterial = require("js/lib/rdge/materials/flat-material").FlatMaterial;
var LinearGradientMaterial = require("js/lib/rdge/materials/linear-gradient-material").LinearGradientMaterial;
var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial;
var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial;
var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial;
var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial;
var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial;
var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial;
var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial;
var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial;
var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial;
var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial;
var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial;
var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial;
var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial;
var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial;
var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial;
var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial;
var MandelMaterial = require("js/lib/rdge/materials/mandel-material").MandelMaterial;
exports.MaterialsModel = Montage.create(Component, {
hasTemplate: {
value: false
},
deserializedFromTemplate: {
value: function() {
// Load all the materials
this.addMaterial(new FlatMaterial());
this.addMaterial(new LinearGradientMaterial());
this.addMaterial(new RadialGradientMaterial());
this.addMaterial(new BumpMetalMaterial());
this.addMaterial(new UberMaterial());
this.addMaterial(new RadialBlurMaterial());
this.addMaterial(new PlasmaMaterial());
this.addMaterial(new PulseMaterial());
this.addMaterial(new TunnelMaterial());
this.addMaterial(new ReliefTunnelMaterial());
this.addMaterial(new SquareTunnelMaterial());
this.addMaterial(new FlyMaterial());
this.addMaterial(new WaterMaterial());
this.addMaterial(new ZInvertMaterial());
this.addMaterial(new DeformMaterial());
this.addMaterial(new StarMaterial());
this.addMaterial(new TwistMaterial());
this.addMaterial(new JuliaMaterial());
this.addMaterial(new KeleidoscopeMaterial());
this.addMaterial(new MandelMaterial());
}
},
_materials : {
value: AppModel.materials
},
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