Mesh.js 1.4 KB

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