Mesh.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.flipSided = false;
  11. this.doubleSided = false;
  12. this.overdraw = false; // TODO: Move to material?
  13. if ( this.geometry ) {
  14. // calc bound radius
  15. if( !this.geometry.boundingSphere ) {
  16. this.geometry.computeBoundingSphere();
  17. }
  18. this.boundRadius = geometry.boundingSphere.radius;
  19. // setup morph targets
  20. if( this.geometry.morphTargets.length ) {
  21. this.morphTargetBase = -1;
  22. this.morphTargetForcedOrder = [];
  23. this.morphTargetInfluences = [];
  24. this.morphTargetDictionary = {};
  25. for( var m = 0; m < this.geometry.morphTargets.length; m++ ) {
  26. this.morphTargetInfluences.push( 0 );
  27. this.morphTargetDictionary[ this.geometry.morphTargets[ m ].name ] = m;
  28. }
  29. }
  30. }
  31. }
  32. THREE.Mesh.prototype = new THREE.Object3D();
  33. THREE.Mesh.prototype.constructor = THREE.Mesh;
  34. THREE.Mesh.prototype.supr = THREE.Object3D.prototype;
  35. /*
  36. * Get Morph Target Index by Name
  37. */
  38. THREE.Mesh.prototype.getMorphTargetIndexByName = function( name ) {
  39. if( this.morphTargetDictionary[ name ] !== undefined ) {
  40. return this.morphTargetDictionary[ name ];
  41. }
  42. console.log( "THREE.Mesh.getMorphTargetIndexByName: morph target " + name + " does not exist. Returning 0." );
  43. return 0;
  44. }
粤ICP备19079148号