Mesh.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 === null ) {
  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. THREE.Mesh.prototype.getMorphTargetIndexByName = function ( name ) {
  31. if ( this.morphTargetDictionary[ name ] !== undefined ) {
  32. return this.morphTargetDictionary[ name ];
  33. }
  34. console.log( "THREE.Mesh.getMorphTargetIndexByName: morph target " + name + " does not exist. Returning 0." );
  35. return 0;
  36. };
  37. THREE.Mesh.prototype.clone = function ( object ) {
  38. if ( object === undefined ) object = new THREE.Mesh( this.geometry, this.material );
  39. THREE.Object3D.prototype.clone.call( this, object );
  40. return object;
  41. };
粤ICP备19079148号