aboutsummaryrefslogtreecommitdiff
path: root/js/models
diff options
context:
space:
mode:
authorJonathan Duran2012-03-06 11:38:39 -0800
committerJonathan Duran2012-03-06 11:38:39 -0800
commit342fb451bd251358068a0dcb10e9dc218b79a176 (patch)
treeaa0195d581c3934fb6dc09981506b3c070002806 /js/models
parent2815adfd7c19b3dff89dc3e1bda9af8d30dca8d6 (diff)
downloadninja-342fb451bd251358068a0dcb10e9dc218b79a176.tar.gz
Squashed commit of the following:
commit 1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Tue Mar 6 11:24:25 2012 -0800 Fixing WebGL not available bug commit 84332ab81c1b445195f1d9be8bbeae0725c8e758 Author: Valerio Virgillito <valerio@motorola.com> Date: Tue Mar 6 10:58:25 2012 -0800 Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito <valerio@motorola.com> commit 13f52cf0c74f53a919fa864f86669e8155f82961 Merge: dced508 abc04f3 Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:46:11 2012 -0800 Merge pull request #93 from imix23ways/Timeline Timeline: Critical bug fixes commit dced508bb19a7bcd467ff1b86b5df5bbec4be794 Merge: 0aeb400 cc772ef Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:45:35 2012 -0800 Merge pull request #92 from mqg734/WebGLFixes Selection Tool Fixes for elements flying off into space when they overlap commit 0aeb400070762cf01d83cf9f9ee25a5595098b7f Merge: ff0a956 aabb48a Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 14:05:21 2012 -0800 Merge pull request #94 from ericguzman/PresetsPanel Presets Panel - Fix single-click activation, and transition cut-off bug. commit cc772ef3333ed419d269a2bda7aea5b0150a7bd9 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:34:58 2012 -0800 Fixing flying off into space bug for translate tool too. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit abc04f3d50311ed1c21067344bc7e448686f8c5c Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:26:25 2012 -0800 Timeline Fix timing function Signed-off-by: Jonathan Duran <jduran@motorola.com> commit aabb48a1c8d34bc968f4c6b0ffee4e31c1d5d286 Author: Eric Guzman <ericg@motorola.com> Date: Fri Mar 2 11:22:44 2012 -0800 Presets Panel - Fix single-click activation, and transition cut-off bug. Use double-click as the activation event for transition presets. Also fixed the bug when applying a style preset before the transition preset, which disabled transitions after the first one. commit f3207f39ea9d8c1c34246217a23d3a689671903d Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:21:29 2012 -0800 Don't draw transform handles if the stage is the target element. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 5425be91e7125c22955b4459a62412ff574e49a8 Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:11:48 2012 -0800 Timeline: Fix for animation iteration count Add default webkit css properties to allow animations with integer iteration counts. Signed-off-by: Jonathan Duran <jduran@motorola.com> commit 1760bac1da9218315ad1bacdcf3a157495a049e8 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 10:48:41 2012 -0800 Fix for jumping issue when moving items that have any 3d on them. We can't translate 3d moves into 2d space due to perspective, so we must update the matrix3d values instead of the top-left values if items have 3d. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 2c04935f0ccb1cb7c98371fc10b43155f2d956c4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 22:20:06 2012 -0800 Fix for elements flying off into space when moving elements that overlap. This was happening because our hit record's element and the browser's element from point did not match. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 50058746779f714ed9b0287f49e56c9f0d35593e Merge: 500426d ff0a956 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 21:49:44 2012 -0800 Merge branch 'refs/heads/ninja-internal' into WebGLFixes commit 500426dea0ca95a6b45be8ea8d132cfdb4d2c940 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:11:39 2012 -0800 Fixed logic error when resizing with the top-left transform handles. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 7980d9bde2b43aa5a494ddf6f1db5c4959a57b91 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:04:15 2012 -0800 Re-fixing IKNinja-940 - Can't select objects when in side/top view. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit f04cc0146d8f7573628678613a99c270116768e4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Feb 29 16:45:40 2012 -0800 Last-used material (instead of FlatMaterial) is applied to shape when turning on use WebGL checkbox in the PI. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/models')
-rwxr-xr-xjs/models/materials-model.js225
-rwxr-xr-xjs/models/properties-3d.js24
2 files changed, 237 insertions, 12 deletions
diff --git a/js/models/materials-model.js b/js/models/materials-model.js
new file mode 100755
index 00000000..d8fb4016
--- /dev/null
+++ b/js/models/materials-model.js
@@ -0,0 +1,225 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6///////////////////////////////////////////////////////////////////////
7// MaterialsLibrary module -- Contains an array of GLMaterials.
8///////////////////////////////////////////////////////////////////////
9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component,
11 AppModel = require("js/models/app-model").AppModel;
12
13var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
14var FlatMaterial = require("js/lib/rdge/materials/flat-material").FlatMaterial;
15var LinearGradientMaterial = require("js/lib/rdge/materials/linear-gradient-material").LinearGradientMaterial;
16var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial;
17var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial;
18var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial;
19var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial;
20var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial;
21var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
22var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial;
23var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial;
24var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial;
25var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial;
26var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial;
27var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial;
28var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial;
29var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial;
30var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial;
31var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial;
32var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial;
33var MandelMaterial = require("js/lib/rdge/materials/mandel-material").MandelMaterial;
34
35
36exports.MaterialsModel = Montage.create(Component, {
37
38 hasTemplate: {
39 value: false
40 },
41
42 deserializedFromTemplate: {
43 value: function() {
44 // Load all the materials
45 this.addMaterial(new FlatMaterial());
46 this.addMaterial(new LinearGradientMaterial());
47 this.addMaterial(new RadialGradientMaterial());
48 this.addMaterial(new BumpMetalMaterial());
49 this.addMaterial(new UberMaterial());
50 this.addMaterial(new RadialBlurMaterial());
51 this.addMaterial(new PlasmaMaterial());
52 this.addMaterial(new PulseMaterial());
53 this.addMaterial(new TunnelMaterial());
54 this.addMaterial(new ReliefTunnelMaterial());
55 this.addMaterial(new SquareTunnelMaterial());
56 this.addMaterial(new FlyMaterial());
57 this.addMaterial(new WaterMaterial());
58 this.addMaterial(new ZInvertMaterial());
59 this.addMaterial(new DeformMaterial());
60 this.addMaterial(new StarMaterial());
61 this.addMaterial(new TwistMaterial());
62 this.addMaterial(new JuliaMaterial());
63 this.addMaterial(new KeleidoscopeMaterial());
64 this.addMaterial(new MandelMaterial());
65 }
66 },
67
68 _materials : {
69 value: AppModel.materials
70 },
71
72 materials : {
73 get: function() {
74 return this._materials;
75 }
76 },
77
78 addMaterial: {
79 value: function (material) {
80 this._materials.push(material);
81 }
82 },
83
84 addMaterialAt: {
85 value: function (material, index) {
86 this._materials.splice(index, 0, material);
87 }
88 },
89
90 removeMaterialAt: {
91 value: function (index) {
92 return this._materials.splice(index, 1);
93 }
94 },
95
96 removeMaterial: {
97 value: function (materialName) {
98 var index = this.getIndexOfMaterial(materialName);
99 if(index !== -1) {
100 return this.removeMaterialAt(index);
101 }
102 }
103 },
104
105 getMaterialAt: {
106 value: function (index) {
107 return this._materials[index];
108 }
109 },
110
111 getMaterial: {
112 value: function (materialName) {
113 var index = this.getIndexOfMaterial(materialName);
114 if(index !== -1) {
115 return this._materials[index];
116 }
117 }
118 },
119
120 getIndexOfMaterial: {
121 value: function (materialName) {
122 var len = this._materials.length;
123 for(var i=0; i<len; i++) {
124 var material = this._materials[i];
125 if(material.getName() === materialName) {
126 return i;
127 }
128 }
129
130 return -1;
131 }
132 },
133
134 clearAllMaterials: {
135 value: function() {
136 this._materials = [];
137 }
138 },
139
140 exportFlatMaterial: {
141 value: function() {
142 return new FlatMaterial();
143 }
144 },
145
146 exportMaterials: {
147 value: function() {
148
149 var exportStr = "MaterialLibrary: \n";
150
151 var nMats = this._materials.length;
152
153 for (var i=0; i<nMats; i++) {
154 var material = this._materials[i];
155 exportStr += material.export();
156 }
157
158 exportStr += "endMatLib\n";
159 return exportStr;
160 }
161 },
162
163 importMaterials: {
164 value: function( importStr ) {
165 // we replace allmaterials, so remove anything
166 // that is currently there.
167 this.clearAllMaterials();
168
169 var pu = new MaterialParser( importStr );
170
171 var type = pu.nextValue( "material: ", "\n", false );
172
173 while (type) {
174
175 var mat = null;
176
177 switch (type)
178 {
179 case "flat": mat = new FlatMaterial(); break;
180 case "linearGradient": mat = new LinearGradientMaterial(); break;
181 case "radialGradient": mat = new RadialGradientMaterial(); break;
182 case "bumpMetal": mat = new BumpMetalMaterial(); break;
183 case "uber": mat = new UberMaterial(); break;
184
185 case "taper": mat = new TaperMaterial(); break;
186 case "twistVert": mat = new TwistVertMaterial(); break;
187 case "radialBlur": mat = new RadialBlurMaterial(); break;
188 case "plasma": mat = new PlasmaMaterial(); break;
189 case "pulse": mat = new PulseMaterial(); break;
190 case "tunnel": mat = new TunnelMaterial(); break;
191 case "reliefTunnel": mat = new ReliefTunnelMaterial(); break;
192 case "squareTunnel": mat = new SquareTunnelMaterial(); break;
193 case "fly": mat = new FlyMaterial(); break;
194 case "water": mat = new WaterMaterial(); break;
195 case "zinvert": mat = new ZInvertMaterial(); break;
196 case "deform": mat = new DeformMaterial(); break;
197 case "star": mat = new StarMaterial(); break;
198 case "twist": mat = new TwistMaterial(); break;
199 case "julia": mat = new JuliaMaterial(); break;
200 case "keleidoscope": mat = new KeleidoscopeMaterial(); break;
201 case "mandel": mat = new MandelMaterial(); break;
202
203
204 default:
205 throw new Error( "Unrecognized material type: " + type );
206 pu.advancePastToken( "endMaterial\n" );