Mesh.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author alteredq / http://alteredqualia.com/
  4. * @author mikael emtinger / http://gomo.se/
  5. */
  6. THREE.Mesh = function ( geometry, material ) {
  7. THREE.Object3D.call( this );
  8. this.geometry = geometry;
  9. this.material = ( material !== undefined ) ? material : new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, wireframe: true } );
  10. if ( this.geometry ) {
  11. // calc bound radius
  12. if ( ! this.geometry.boundingSphere ) {
  13. this.geometry.computeBoundingSphere();
  14. }
  15. this.boundRadius = geometry.boundingSphere.radius;
  16. // setup morph targets
  17. if( this.geometry.morphTargets.length ) {
  18. this.morphTargetBase = -1;
  19. this.morphTargetForcedOrder = [];
  20. this.morphTargetInfluences = [];
  21. this.morphTargetDictionary = {};
  22. for( var m = 0; m < this.geometry.morphTargets.length; m ++ ) {
  23. this.morphTargetInfluences.push( 0 );
  24. this.morphTargetDictionary[ this.geometry.morphTargets[ m ].name ] = m;
  25. }
  26. }
  27. }
  28. }
  29. THREE.Mesh.prototype = Object.create( THREE.Object3D.prototype );
  30. /*
  31. * Get Morph Target Index by Name
  32. */
  33. THREE.Mesh.prototype.getMorphTargetIndexByName = function( name ) {
  34. if ( this.morphTargetDictionary[ name ] !== undefined ) {
  35. return this.morphTargetDictionary[ name ];
  36. }
  37. console.log( "THREE.Mesh.getMorphTargetIndexByName: morph target " + name + " does not exist. Returning 0." );
  38. return 0;
  39. }