1 /**
  2  * @author mikael emtinger / http://gomo.se/
  3  */
  4 
  5 /**@namespace*/
  6 THREE.AnimationHandler = (function() {
  7 
  8 	var playing = [];
  9 	var library = {};
 10 	var that    = {};
 11 
 12 
 13 	//--- update ---
 14 	/**@memberOf THREE.AnimationHandler
 15 @function
 16 @name update*/
 17 that.update = function( deltaTimeMS ) {
 18 
 19 		for( var i = 0; i < playing.length; i ++ )
 20 			playing[ i ].update( deltaTimeMS );
 21 
 22 	};
 23 
 24 
 25 	//--- add ---
 26 
 27 	/**@memberOf THREE.AnimationHandler
 28 @function
 29 @name addToUpdate*/
 30 that.addToUpdate = function( animation ) {
 31 
 32 		if ( playing.indexOf( animation ) === -1 )
 33 			playing.push( animation );
 34 
 35 	};
 36 
 37 
 38 	//--- remove ---
 39 
 40 	/**@memberOf THREE.AnimationHandler
 41 @function
 42 @name removeFromUpdate*/
 43 that.removeFromUpdate = function( animation ) {
 44 
 45 		var index = playing.indexOf( animation );
 46 
 47 		if( index !== -1 )
 48 			playing.splice( index, 1 );
 49 
 50 	};
 51 
 52 
 53 	//--- add ---
 54 
 55 	/**@memberOf THREE.AnimationHandler
 56 @function
 57 @name add*/
 58 that.add = function( data ) {
 59 
 60 		if ( library[ data.name ] !== undefined )
 61 			console.log( "THREE.AnimationHandler.add: Warning! " + data.name + " already exists in library. Overwriting." );
 62 
 63 		library[ data.name ] = data;
 64 		initData( data );
 65 
 66 	};
 67 
 68 
 69 	//--- get ---
 70 
 71 	/**@memberOf THREE.AnimationHandler
 72 @function
 73 @name get*/
 74 that.get = function( name ) {
 75 
 76 		if ( typeof name === "string" ) {
 77 
 78 			if ( library[ name ] ) {
 79 
 80 				return library[ name ];
 81 
 82 			} else {
 83 
 84 				console.log( "THREE.AnimationHandler.get: Couldn't find animation " + name );
 85 				return null;
 86 
 87 			}
 88 
 89 		} else {
 90 
 91 			// todo: add simple tween library
 92 
 93 		}
 94 
 95 	};
 96 
 97 	//--- parse ---
 98 
 99 	/**@memberOf THREE.AnimationHandler
100 @function
101 @name parse*/
102 that.parse = function( root ) {
103 
104 		// setup hierarchy
105 
106 		var hierarchy = [];
107 
108 		if ( root instanceof THREE.SkinnedMesh ) {
109 
110 			for( var b = 0; b < root.bones.length; b++ ) {
111 
112 				hierarchy.push( root.bones[ b ] );
113 
114 			}
115 
116 		} else {
117 
118 			parseRecurseHierarchy( root, hierarchy );
119 
120 		}
121 
122 		return hierarchy;
123 
124 	};
125 
126 	var parseRecurseHierarchy = function( root, hierarchy ) {
127 
128 		hierarchy.push( root );
129 
130 		for( var c = 0; c < root.children.length; c++ )
131 			parseRecurseHierarchy( root.children[ c ], hierarchy );
132 
133 	}
134 
135 
136 	//--- init data ---
137 
138 	var initData = function( data ) {
139 
140 		if( data.initialized === true )
141 			return;
142 
143 
144 		// loop through all keys
145 
146 		for( var h = 0; h < data.hierarchy.length; h ++ ) {
147 
148 			for( var k = 0; k < data.hierarchy[ h ].keys.length; k ++ ) {
149 
150 				// remove minus times
151 
152 				if( data.hierarchy[ h ].keys[ k ].time < 0 )
153 					data.hierarchy[ h ].keys[ k ].time = 0;
154 
155 
156 				// create quaternions
157 
158 				if( data.hierarchy[ h ].keys[ k ].rot !== undefined &&
159 				 !( data.hierarchy[ h ].keys[ k ].rot instanceof THREE.Quaternion ) ) {
160 
161 					var quat = data.hierarchy[ h ].keys[ k ].rot;
162 					data.hierarchy[ h ].keys[ k ].rot = new THREE.Quaternion( quat[0], quat[1], quat[2], quat[3] );
163 
164 				}
165 
166 			}
167 
168 
169 			// prepare morph target keys
170 
171 			if( data.hierarchy[ h ].keys.length && data.hierarchy[ h ].keys[ 0 ].morphTargets !== undefined ) {
172 
173 				// get all used
174 
175 				var usedMorphTargets = {};
176 
177 				for ( var k = 0; k < data.hierarchy[ h ].keys.length; k ++ ) {
178 
179 					for ( var m = 0; m < data.hierarchy[ h ].keys[ k ].morphTargets.length; m ++ ) {
180 
181 						var morphTargetName = data.hierarchy[ h ].keys[ k ].morphTargets[ m ];
182 						usedMorphTargets[ morphTargetName ] = -1;
183 
184 					}
185 
186 				}
187 
188 				data.hierarchy[ h ].usedMorphTargets = usedMorphTargets;
189 
190 
191 				// set all used on all frames
192 
193 				for ( var k = 0; k < data.hierarchy[ h ].keys.length; k ++ ) {
194 
195 					var influences = {};
196 
197 					for ( var morphTargetName in usedMorphTargets ) {
198 
199 						for ( var m = 0; m < data.hierarchy[ h ].keys[ k ].morphTargets.length; m ++ ) {
200 
201 							if ( data.hierarchy[ h ].keys[ k ].morphTargets[ m ] === morphTargetName ) {
202 
203 								influences[ morphTargetName ] = data.hierarchy[ h ].keys[ k ].morphTargetsInfluences[ m ];
204 								break;
205 
206 							}
207 
208 						}
209 
210 						if ( m === data.hierarchy[ h ].keys[ k ].morphTargets.length ) {
211 
212 							influences[ morphTargetName ] = 0;
213 
214 						}
215 
216 					}
217 
218 					data.hierarchy[ h ].keys[ k ].morphTargetsInfluences = influences;
219 
220 				}
221 
222 			}
223 
224 
225 			// remove all keys that are on the same time
226 
227 			for ( var k = 1; k < data.hierarchy[ h ].keys.length; k ++ ) {
228 
229 				if ( data.hierarchy[ h ].keys[ k ].time === data.hierarchy[ h ].keys[ k - 1 ].time ) {
230 
231 					data.hierarchy[ h ].keys.splice( k, 1 );
232 					k --;
233 
234 				}
235 
236 			}
237 
238 
239 			// set index
240 
241 			for ( var k = 0; k < data.hierarchy[ h ].keys.length; k ++ ) {
242 
243 				data.hierarchy[ h ].keys[ k ].index = k;
244 
245 			}
246 
247 		}
248 
249 
250 		// JIT
251 
252 		var lengthInFrames = parseInt( data.length * data.fps, 10 );
253 
254 		data.JIT = {};
255 		data.JIT.hierarchy = [];
256 
257 		for( var h = 0; h < data.hierarchy.length; h ++ )
258 			data.JIT.hierarchy.push( new Array( lengthInFrames ) );
259 
260 
261 		// done
262 
263 		data.initialized = true;
264 
265 	};
266 
267 
268 	// interpolation types
269 
270 	that.LINEAR = 0;
271 	that.CATMULLROM = 1;
272 	that.CATMULLROM_FORWARD = 2;
273 
274 	return that;
275 
276 }());
277 

nike free rn new balance hombre baratas cinturones gucci ugg rebajas cinturon gucci ray ban baratas nike cortez peuterey mujer christian louboutin madrid mbt zapatos gafas ray ban baratas mbt ofertas air max blancas mbt barcelona nike air max 90 woolrich barcelona nike mujer botas ugg gafas de sol carrera aratas air max 2016 baratas oakley baratas nike air max 2016

mbt skor nike sverige louboutin skor hollister sverige polo ralph lauren skjorta woolrich jacka dam canada goose jacka woolrich jacka ray ban rea canada goose rea michael kors rea new balance skor ralph lauren skjorta new balance rea uggs sverige lacoste rea christian louboutin skor moncler jacka nike shox barbour jacka uggs rea