1 /**
  2  * @author alteredq / http://alteredqualia.com/
  3  */
  4 
  5 /**@constructor*/
  6 THREE.MorphAnimMesh = function ( geometry, material ) {
  7 
  8 	THREE.Mesh.call( this, geometry, material );
  9 
 10 	// API
 11 
 12 	this.duration = 1000; // milliseconds
 13 	this.mirroredLoop = false;
 14 	this.time = 0;
 15 
 16 	// internals
 17 
 18 	this.lastKeyframe = 0;
 19 	this.currentKeyframe = 0;
 20 
 21 	this.direction = 1;
 22 	this.directionBackwards = false;
 23 
 24 	this.setFrameRange( 0, this.geometry.morphTargets.length - 1 );
 25 
 26 };
 27 
 28 THREE.MorphAnimMesh.prototype = Object.create( THREE.Mesh.prototype );
 29 
 30 THREE.MorphAnimMesh.prototype.setFrameRange = function ( start, end ) {
 31 
 32 	this.startKeyframe = start;
 33 	this.endKeyframe = end;
 34 
 35 	this.length = this.endKeyframe - this.startKeyframe + 1;
 36 
 37 };
 38 
 39 THREE.MorphAnimMesh.prototype.setDirectionForward = function () {
 40 
 41 	this.direction = 1;
 42 	this.directionBackwards = false;
 43 
 44 };
 45 
 46 THREE.MorphAnimMesh.prototype.setDirectionBackward = function () {
 47 
 48 	this.direction = -1;
 49 	this.directionBackwards = true;
 50 
 51 };
 52 
 53 THREE.MorphAnimMesh.prototype.parseAnimations = function () {
 54 
 55 	var geometry = this.geometry;
 56 
 57 	if ( ! geometry.animations ) geometry.animations = {};
 58 
 59 	var firstAnimation, animations = geometry.animations;
 60 
 61 	var pattern = /([a-z]+)(\d+)/;
 62 
 63 	for ( var i = 0, il = geometry.morphTargets.length; i < il; i ++ ) {
 64 
 65 		var morph = geometry.morphTargets[ i ];
 66 		var parts = morph.name.match( pattern );
 67 
 68 		if ( parts && parts.length > 1 ) {
 69 
 70 			var label = parts[ 1 ];
 71 			var num = parts[ 2 ];
 72 
 73 			if ( ! animations[ label ] ) animations[ label ] = { start: Infinity, end: -Infinity };
 74 
 75 			var animation = animations[ label ];
 76 
 77 			if ( i < animation.start ) animation.start = i;
 78 			if ( i > animation.end ) animation.end = i;
 79 
 80 			if ( ! firstAnimation ) firstAnimation = label;
 81 
 82 		}
 83 
 84 	}
 85 
 86 	geometry.firstAnimation = firstAnimation;
 87 
 88 };
 89 
 90 THREE.MorphAnimMesh.prototype.setAnimationLabel = function ( label, start, end ) {
 91 
 92 	if ( ! this.geometry.animations ) this.geometry.animations = {};
 93 
 94 	this.geometry.animations[ label ] = { start: start, end: end };
 95 
 96 };
 97 
 98 THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) {
 99 
100 	var animation = this.geometry.animations[ label ];
101 
102 	if ( animation ) {
103 
104 		this.setFrameRange( animation.start, animation.end );
105 		this.duration = 1000 * ( ( animation.end - animation.start ) / fps );
106 		this.time = 0;
107 
108 	} else {
109 
110 		console.warn( "animation[" + label + "] undefined" );
111 
112 	}
113 
114 };
115 
116 THREE.MorphAnimMesh.prototype.updateAnimation = function ( delta ) {
117 
118 	var frameTime = this.duration / this.length;
119 
120 	this.time += this.direction * delta;
121 
122 	if ( this.mirroredLoop ) {
123 
124 		if ( this.time > this.duration || this.time < 0 ) {
125 
126 			this.direction *= -1;
127 
128 			if ( this.time > this.duration ) {
129 
130 				this.time = this.duration;
131 				this.directionBackwards = true;
132 
133 			}
134 
135 			if ( this.time < 0 ) {
136 
137 				this.time = 0;
138 				this.directionBackwards = false;
139 
140 			}
141 
142 		}
143 
144 	} else {
145 
146 		this.time = this.time % this.duration;
147 
148 		if ( this.time < 0 ) this.time += this.duration;
149 
150 	}
151 
152 	var keyframe = this.startKeyframe + THREE.Math.clamp( Math.floor( this.time / frameTime ), 0, this.length - 1 );
153 
154 	if ( keyframe !== this.currentKeyframe ) {
155 
156 		this.morphTargetInfluences[ this.lastKeyframe ] = 0;
157 		this.morphTargetInfluences[ this.currentKeyframe ] = 1;
158 
159 		this.morphTargetInfluences[ keyframe ] = 0;
160 
161 		this.lastKeyframe = this.currentKeyframe;
162 		this.currentKeyframe = keyframe;
163 
164 	}
165 
166 	var mix = ( this.time % frameTime ) / frameTime;
167 
168 	if ( this.directionBackwards ) {
169 
170 		mix = 1 - mix;
171 
172 	}
173 
174 	this.morphTargetInfluences[ this.currentKeyframe ] = mix;
175 	this.morphTargetInfluences[ this.lastKeyframe ] = 1 - mix;
176 
177 };
178 
179 THREE.MorphAnimMesh.prototype.clone = function ( object ) {
180 
181 	if ( object === undefined ) object = new THREE.MorphAnimMesh( this.geometry, this.material );
182 
183 	object.duration = this.duration;
184 	object.mirroredLoop = this.mirroredLoop;
185 	object.time = this.time;
186 
187 	object.lastKeyframe = this.lastKeyframe;
188 	object.currentKeyframe = this.currentKeyframe;
189 
190 	object.direction = this.direction;
191 	object.directionBackwards = this.directionBackwards;
192 
193 	THREE.Mesh.prototype.clone.call( this, object );
194 
195 	return object;
196 
197 };
198 

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