1 /**
  2  * @author mikael emtinger / http://gomo.se/
  3  * @author alteredq / http://alteredqualia.com/
  4  */
  5 
  6 /**@constructor*/
  7 THREE.SkinnedMesh = function ( geometry, material, useVertexTexture ) {
  8 
  9 	THREE.Mesh.call( this, geometry, material );
 10 
 11 	//
 12 
 13 	this.useVertexTexture = useVertexTexture !== undefined ? useVertexTexture : true;
 14 
 15 	// init bones
 16 
 17 	this.identityMatrix = new THREE.Matrix4();
 18 
 19 	this.bones = [];
 20 	this.boneMatrices = [];
 21 
 22 	var b, bone, gbone, p, q, s;
 23 
 24 	if ( this.geometry && this.geometry.bones !== undefined ) {
 25 
 26 		for ( b = 0; b < this.geometry.bones.length; b ++ ) {
 27 
 28 			gbone = this.geometry.bones[ b ];
 29 
 30 			p = gbone.pos;
 31 			q = gbone.rotq;
 32 			s = gbone.scl;
 33 
 34 			bone = this.addBone();
 35 
 36 			bone.name = gbone.name;
 37 			bone.position.set( p[0], p[1], p[2] );
 38 			bone.quaternion.set( q[0], q[1], q[2], q[3] );
 39 			bone.useQuaternion = true;
 40 
 41 			if ( s !== undefined ) {
 42 
 43 				bone.scale.set( s[0], s[1], s[2] );
 44 
 45 			} else {
 46 
 47 				bone.scale.set( 1, 1, 1 );
 48 
 49 			}
 50 
 51 		}
 52 
 53 		for ( b = 0; b < this.bones.length; b ++ ) {
 54 
 55 			gbone = this.geometry.bones[ b ];
 56 			bone = this.bones[ b ];
 57 
 58 			if ( gbone.parent === -1 ) {
 59 
 60 				this.add( bone );
 61 
 62 			} else {
 63 
 64 				this.bones[ gbone.parent ].add( bone );
 65 
 66 			}
 67 
 68 		}
 69 
 70 		//
 71 
 72 		var nBones = this.bones.length;
 73 
 74 		if ( this.useVertexTexture ) {
 75 
 76 			// layout (1 matrix = 4 pixels)
 77 			//	RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
 78 			//  with  8x8  pixel texture max   16 bones  (8 * 8  / 4)
 79 			//  	 16x16 pixel texture max   64 bones (16 * 16 / 4)
 80 			//  	 32x32 pixel texture max  256 bones (32 * 32 / 4)
 81 			//  	 64x64 pixel texture max 1024 bones (64 * 64 / 4)
 82 
 83 			var size;
 84 
 85 			if ( nBones > 256 )
 86 				size = 64;
 87 			else if ( nBones > 64 )
 88 				size = 32;
 89 			else if ( nBones > 16 )
 90 				size = 16;
 91 			else
 92 				size = 8;
 93 
 94 			this.boneTextureWidth = size;
 95 			this.boneTextureHeight = size;
 96 
 97 			this.boneMatrices = new Float32Array( this.boneTextureWidth * this.boneTextureHeight * 4 ); // 4 floats per RGBA pixel
 98 			this.boneTexture = new THREE.DataTexture( this.boneMatrices, this.boneTextureWidth, this.boneTextureHeight, THREE.RGBAFormat, THREE.FloatType );
 99 			this.boneTexture.minFilter = THREE.NearestFilter;
100 			this.boneTexture.magFilter = THREE.NearestFilter;
101 			this.boneTexture.generateMipmaps = false;
102 			this.boneTexture.flipY = false;
103 
104 		} else {
105 
106 			this.boneMatrices = new Float32Array( 16 * nBones );
107 
108 		}
109 
110 		this.pose();
111 
112 	}
113 
114 };
115 
116 THREE.SkinnedMesh.prototype = Object.create( THREE.Mesh.prototype );
117 
118 THREE.SkinnedMesh.prototype.addBone = function( bone ) {
119 
120 	if ( bone === undefined ) {
121 
122 		bone = new THREE.Bone( this );
123 
124 	}
125 
126 	this.bones.push( bone );
127 
128 	return bone;
129 
130 };
131 
132 THREE.SkinnedMesh.prototype.updateMatrixWorld = function ( force ) {
133 
134 	this.matrixAutoUpdate && this.updateMatrix();
135 
136 	// update matrixWorld
137 
138 	if ( this.matrixWorldNeedsUpdate || force ) {
139 
140 		if ( this.parent ) {
141 
142 			this.matrixWorld.multiply( this.parent.matrixWorld, this.matrix );
143 
144 		} else {
145 
146 			this.matrixWorld.copy( this.matrix );
147 
148 		}
149 
150 		this.matrixWorldNeedsUpdate = false;
151 
152 		force = true;
153 
154 	}
155 
156 	// update children
157 
158 	for ( var i = 0, l = this.children.length; i < l; i ++ ) {
159 
160 		var child = this.children[ i ];
161 
162 		if ( child instanceof THREE.Bone ) {
163 
164 			child.update( this.identityMatrix, false );
165 
166 		} else {
167 
168 			child.updateMatrixWorld( true );
169 
170 		}
171 
172 	}
173 
174 	// make a snapshot of the bones' rest position
175 
176 	if ( this.boneInverses == undefined ) {
177 
178 		this.boneInverses = [];
179 
180 		for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
181 
182 			var inverse = new THREE.Matrix4();
183 
184 			inverse.getInverse( this.bones[ b ].skinMatrix );
185 
186 			this.boneInverses.push( inverse );
187 
188 		}
189 
190 	}
191 
192 	// flatten bone matrices to array
193 
194 	for ( var b = 0, bl = this.bones.length; b < bl; b ++ ) {
195 
196 		// compute the offset between the current and the original transform;
197 
198 		//TODO: we could get rid of this multiplication step if the skinMatrix
199 		// was already representing the offset; however, this requires some
200 		// major changes to the animation system
201 
202 		THREE.SkinnedMesh.offsetMatrix.multiply( this.bones[ b ].skinMatrix, this.boneInverses[ b ] );
203 
204 		THREE.SkinnedMesh.offsetMatrix.flattenToArrayOffset( this.boneMatrices, b * 16 );
205 
206 	}
207 
208 	if ( this.useVertexTexture ) {
209 
210 		this.boneTexture.needsUpdate = true;
211 
212 	}
213 
214 };
215 
216 THREE.SkinnedMesh.prototype.pose = function() {
217 
218 	this.updateMatrixWorld( true );
219 
220 	for ( var i = 0; i < this.geometry.skinIndices.length; i ++ ) {
221 
222 		// normalize weights
223 
224 		var sw = this.geometry.skinWeights[ i ];
225 
226 		var scale = 1.0 / sw.lengthManhattan();
227 
228 		if ( scale !== Infinity ) {
229 
230 			sw.multiplyScalar( scale );
231 
232 		} else {
233 
234 			sw.set( 1 ); // this will be normalized by the shader anyway
235 
236 		}
237 
238 	}
239 
240 };
241 
242 THREE.SkinnedMesh.prototype.clone = function ( object ) {
243 
244 	if ( object === undefined ) object = new THREE.SkinnedMesh( this.geometry, this.material, this.useVertexTexture );
245 
246 	THREE.Mesh.prototype.clone.call( this, object );
247 
248 	return object;
249 
250 };
251 
252 THREE.SkinnedMesh.offsetMatrix = new THREE.Matrix4();
253 

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