Camera.js 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.matrixWorldInverse = new THREE.Matrix4();
  9. this.projectionMatrix = new THREE.Matrix4();
  10. };
  11. THREE.Camera.prototype = Object.create( THREE.Object3D.prototype );
  12. THREE.Camera.prototype.lookAt = function () {
  13. // This routine does not support cameras with rotated and/or translated parent(s)
  14. var m1 = new THREE.Matrix4();
  15. return function ( vector ) {
  16. m1.lookAt( this.position, vector, this.up );
  17. this.quaternion.setFromRotationMatrix( m1 );
  18. };
  19. }();
  20. THREE.Camera.prototype.clone = function (camera) {
  21. if ( camera === undefined ) camera = new THREE.Camera();
  22. THREE.Object3D.prototype.clone.call( this, camera );
  23. camera.matrixWorldInverse.copy( this.matrixWorldInverse );
  24. camera.projectionMatrix.copy( this.projectionMatrix );
  25. return camera;
  26. };