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. * @author jonobr1 / http://jonobr1.com/
  6. */
  7. THREE.Mesh = function ( geometry, material ) {
  8. THREE.Object3D.call( this );
  9. this.geometry = geometry;
  10. this.material = ( material !== undefined ) ? material : new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, wireframe: true } );
  11. if ( this.geometry !== undefined ) {
  12. if ( this.geometry.boundingSphere === null ) {
  13. this.geometry.computeBoundingSphere();
  14. }
  15. this.updateMorphTargets();
  16. }
  17. };
  18. THREE.Mesh.prototype = Object.create( THREE.Object3D.prototype );
  19. THREE.Mesh.prototype.updateMorphTargets = function () {
  20. if ( this.geometry.morphTargets.length > 0 ) {
  21. this.morphTargetBase = -1;
  22. this.morphTargetForcedOrder = [];
  23. this.morphTargetInfluences = [];
  24. this.morphTargetDictionary = {};
  25. for ( var m = 0, ml = this.geometry.morphTargets.length; m < ml; m ++ ) {
  26. this.morphTargetInfluences.push( 0 );
  27. this.morphTargetDictionary[ this.geometry.morphTargets[ m ].name ] = m;
  28. }
  29. }
  30. };
  31. THREE.Mesh.prototype.getMorphTargetIndexByName = function ( name ) {
  32. if ( this.morphTargetDictionary[ name ] !== undefined ) {
  33. return this.morphTargetDictionary[ name ];
  34. }
  35. console.log( "THREE.Mesh.getMorphTargetIndexByName: morph target " + name + " does not exist. Returning 0." );
  36. return 0;
  37. };
  38. THREE.Mesh.prototype.clone = function ( object ) {
  39. if ( object === undefined ) object = new THREE.Mesh( this.geometry, this.material );
  40. THREE.Object3D.prototype.clone.call( this, object );
  41. return object;
  42. };
粤ICP备19079148号