1 /**
  2  * @author mikael emtinger / http://gomo.se/
  3  */
  4 
  5 /**@constructor*/
  6 THREE.AnimationMorphTarget = function( root, data ) {
  7 
  8 	this.root = root;
  9 	this.data = THREE.AnimationHandler.get( data );
 10 	this.hierarchy = THREE.AnimationHandler.parse( root );
 11 	this.currentTime = 0;
 12 	this.timeScale = 1;
 13 	this.isPlaying = false;
 14 	this.isPaused = true;
 15 	this.loop = true;
 16 	this.influence = 1;
 17 }
 18 
 19 /*
 20  * Play
 21  */
 22 
 23 THREE.AnimationMorphTarget.prototype.play = function( loop, startTimeMS ) {
 24 
 25 	if( !this.isPlaying ) {
 26 
 27 		this.isPlaying = true;
 28 		this.loop = loop !== undefined ? loop : true;
 29 		this.currentTime = startTimeMS !== undefined ? startTimeMS : 0;
 30 
 31 
 32 		// reset key cache
 33 
 34 		for ( var h = 0; h < this.hierarchy.length; h++ ) {
 35 
 36 			if ( this.hierarchy[ h ].animationCache === undefined ) {
 37 
 38 				this.hierarchy[ h ].animationCache = {};
 39 				this.hierarchy[ h ].animationCache.prevKey = 0;
 40 				this.hierarchy[ h ].animationCache.nextKey = 0;
 41 			}
 42 
 43 			this.hierarchy[ h ].animationCache.prevKey = this.data.hierarchy[ h ].keys[ 0 ];
 44 			this.hierarchy[ h ].animationCache.nextKey = this.data.hierarchy[ h ].keys[ 1 ];
 45 		}
 46 
 47 		this.update( 0 );
 48 	}
 49 
 50 	this.isPaused = false;
 51 	THREE.AnimationHandler.addToUpdate( this );
 52 }
 53 
 54 
 55 /*
 56  * Pause
 57  */
 58 
 59 THREE.AnimationMorphTarget.prototype.pause = function() {
 60 
 61 	if( this.isPaused ) {
 62 		
 63 		THREE.AnimationHandler.addToUpdate( this );
 64 		
 65 	} else {
 66 		
 67 		THREE.AnimationHandler.removeFromUpdate( this );
 68 		
 69 	}
 70 	
 71 	this.isPaused = !this.isPaused;
 72 }
 73 
 74 
 75 /*
 76  * Stop
 77  */
 78 
 79 THREE.AnimationMorphTarget.prototype.stop = function() {
 80 
 81 	this.isPlaying = false;
 82 	this.isPaused  = false;
 83 	
 84 	THREE.AnimationHandler.removeFromUpdate( this );
 85 	
 86 	
 87 	// reset JIT matrix and remove cache
 88 	
 89 	for ( var h = 0; h < this.hierarchy.length; h++ ) {
 90 		
 91 		if ( this.hierarchy[ h ].animationCache !== undefined ) {
 92 			
 93 			delete this.hierarchy[ h ].animationCache;	
 94 		}
 95 
 96 	}
 97 
 98 }
 99 
100 
101 /*
102  * Update
103  */
104 
105 THREE.AnimationMorphTarget.prototype.update = function( deltaTimeMS ) {
106 
107 	// early out
108 
109 	if( !this.isPlaying ) return;
110 
111 
112 	// vars
113 
114 	var scale;
115 	var vector;
116 	var prevXYZ, nextXYZ;
117 	var prevKey, nextKey;
118 	var object;
119 	var animationCache;
120 	var currentTime, unloopedCurrentTime;
121 	
122 
123 	// update time
124 	
125 	this.currentTime += deltaTimeMS * this.timeScale;
126 
127 	unloopedCurrentTime = this.currentTime;
128 	currentTime         = this.currentTime = this.currentTime % this.data.length;
129 
130 
131 	// update
132 
133 	for ( var h = 0, hl = this.hierarchy.length; h < hl; h++ ) {
134 
135 		object = this.hierarchy[ h ];
136 		animationCache = object.animationCache;
137 
138 
139 		// get keys
140 
141 		prevKey = animationCache.prevKey;
142 		nextKey = animationCache.nextKey;
143 
144 
145 		// switch keys?
146 
147 		if ( nextKey.time <= unloopedCurrentTime ) {
148 
149 			// did we loop?
150 
151 			if ( currentTime < unloopedCurrentTime ) {
152 
153 				if ( this.loop ) {
154 
155 					prevKey = this.data.hierarchy[ h ].keys[ 0 ];
156 					nextKey = this.data.hierarchy[ h ].keys[ 1 ];
157 
158 					while( nextKey.time < currentTime ) {
159 
160 						prevKey = nextKey;
161 						nextKey = this.data.hierarchy[ h ].keys[ nextKey.index + 1 ];
162 
163 					}
164 
165 				} else {
166 
167 					this.stop();
168 					return;
169 
170 				}
171 
172 			} else {
173 
174 				do {
175 
176 					prevKey = nextKey;
177 					nextKey = this.data.hierarchy[ h ].keys[ nextKey.index + 1 ];
178 
179 				} while( nextKey.time < currentTime )
180 
181 			}
182 
183 			animationCache.prevKey = prevKey;
184 			animationCache.nextKey = nextKey;
185 
186 		}
187 
188 
189 		// calc scale and check for error
190 
191 		scale = ( currentTime - prevKey.time ) / ( nextKey.time - prevKey.time );
192 
193 		if ( scale < 0 || scale > 1 ) {
194 
195 			console.log( "THREE.AnimationMorphTarget.update: Warning! Scale out of bounds:" + scale ); 
196 			scale = scale < 0 ? 0 : 1;
197 
198 		}
199 
200 
201 		// interpolate
202 		
203 		var pi, pmti = prevKey.morphTargetsInfluences;
204 		var ni, nmti = nextKey.morphTargetsInfluences;
205 		var mt, i;
206 		
207 		for( mt in pmti ) {
208 			
209 			pi = pmti[ mt ];
210 			ni = nmti[ mt ];
211 			i = this.root.getMorphTargetIndexByName( mt );
212 			
213 			this.root.morphTargetInfluences[ i ] = ( pi + ( ni - pi ) * scale ) * this.influence;
214 		}
215 
216 	}
217 
218 };
219 
220 

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