Camera.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author mikael emtinger / http://gomo.se/
  4. * @author WestLangley / http://github.com/WestLangley
  5. */
  6. THREE.Camera = function () {
  7. THREE.Object3D.call( this );
  8. this.type = 'Camera';
  9. this.matrixWorldInverse = new THREE.Matrix4();
  10. this.projectionMatrix = new THREE.Matrix4();
  11. };
  12. THREE.Camera.prototype = Object.create( THREE.Object3D.prototype );
  13. THREE.Camera.prototype.constructor = THREE.Camera;
  14. THREE.Camera.prototype.getWorldDirection = function () {
  15. var quaternion = new THREE.Quaternion();
  16. return function getWorldDirection( optionalTarget ) {
  17. var result = optionalTarget || new THREE.Vector3();
  18. this.getWorldQuaternion( quaternion );
  19. return result.set( 0, 0, - 1 ).applyQuaternion( quaternion );
  20. };
  21. }();
  22. THREE.Camera.prototype.lookAt = function () {
  23. // This routine does not support cameras with rotated and/or translated parent(s)
  24. var m1 = new THREE.Matrix4();
  25. return function lookAt( vector ) {
  26. m1.lookAt( this.position, vector, this.up );
  27. this.quaternion.setFromRotationMatrix( m1 );
  28. };
  29. }();
  30. THREE.Camera.prototype.clone = function () {
  31. return new this.constructor().copy( this );
  32. };
  33. THREE.Camera.prototype.copy = function ( source ) {
  34. THREE.Object3D.prototype.copy.call( this, source );
  35. this.matrixWorldInverse.copy( source.matrixWorldInverse );
  36. this.projectionMatrix.copy( source.projectionMatrix );
  37. return this;
  38. };
粤ICP备19079148号