Sprite.js 954 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @author mikael emtinger / http://gomo.se/
  3. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.Sprite = function ( material ) {
  6. THREE.Object3D.call( this );
  7. this.material = ( material !== undefined ) ? material : new THREE.SpriteMaterial();
  8. this.rotation3d = this.rotation;
  9. this.rotation = 0;
  10. };
  11. THREE.Sprite.prototype = Object.create( THREE.Object3D.prototype );
  12. /*
  13. * Custom update matrix
  14. */
  15. THREE.Sprite.prototype.updateMatrix = function () {
  16. this.matrix.setPosition( this.position );
  17. this.rotation3d.set( 0, 0, this.rotation );
  18. this.matrix.setRotationFromEuler( this.rotation3d );
  19. if ( this.scale.x !== 1 || this.scale.y !== 1 ) {
  20. this.matrix.scale( this.scale );
  21. }
  22. this.matrixWorldNeedsUpdate = true;
  23. };
  24. THREE.Sprite.prototype.clone = function ( object ) {
  25. if ( object === undefined ) object = new THREE.Sprite( this.material );
  26. THREE.Object3D.prototype.clone.call( this, object );
  27. return object;
  28. };
粤ICP备19079148号