Mesh.js 1.5 KB

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