2
0

Bone.js 950 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * @author mikael emtinger / http://gomo.se/
  3. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.Bone = function( belongsToSkin ) {
  6. THREE.Object3D.call( this );
  7. this.skin = belongsToSkin;
  8. this.skinMatrix = new THREE.Matrix4();
  9. };
  10. THREE.Bone.prototype = Object.create( THREE.Object3D.prototype );
  11. THREE.Bone.prototype.update = function ( parentSkinMatrix, forceUpdate ) {
  12. // update local
  13. if ( this.matrixAutoUpdate ) {
  14. forceUpdate |= this.updateMatrix();
  15. }
  16. // update skin matrix
  17. if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
  18. if( parentSkinMatrix ) {
  19. this.skinMatrix.multiplyMatrices( parentSkinMatrix, this.matrix );
  20. } else {
  21. this.skinMatrix.copy( this.matrix );
  22. }
  23. this.matrixWorldNeedsUpdate = false;
  24. forceUpdate = true;
  25. }
  26. // update children
  27. var child, i, l = this.children.length;
  28. for ( i = 0; i < l; i ++ ) {
  29. this.children[ i ].update( this.skinMatrix, forceUpdate );
  30. }
  31. };