Camera.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { WebGLCoordinateSystem } from '../constants.js';
  2. import { Matrix4 } from '../math/Matrix4.js';
  3. import { Object3D } from '../core/Object3D.js';
  4. class Camera extends Object3D {
  5. constructor() {
  6. super();
  7. this.isCamera = true;
  8. this.type = 'Camera';
  9. this.matrixWorldInverse = new Matrix4();
  10. this.projectionMatrix = new Matrix4();
  11. this.projectionMatrixInverse = new Matrix4();
  12. this.coordinateSystem = WebGLCoordinateSystem;
  13. }
  14. copy( source, recursive ) {
  15. super.copy( source, recursive );
  16. this.matrixWorldInverse.copy( source.matrixWorldInverse );
  17. this.projectionMatrix.copy( source.projectionMatrix );
  18. this.projectionMatrixInverse.copy( source.projectionMatrixInverse );
  19. this.coordinateSystem = source.coordinateSystem;
  20. return this;
  21. }
  22. getWorldDirection( target ) {
  23. return super.getWorldDirection( target ).negate();
  24. }
  25. updateMatrixWorld( force ) {
  26. super.updateMatrixWorld( force );
  27. this.matrixWorldInverse.copy( this.matrixWorld ).invert();
  28. }
  29. updateWorldMatrix( updateParents, updateChildren ) {
  30. super.updateWorldMatrix( updateParents, updateChildren );
  31. this.matrixWorldInverse.copy( this.matrixWorld ).invert();
  32. }
  33. clone() {
  34. return new this.constructor().copy( this );
  35. }
  36. }
  37. export { Camera };
粤ICP备19079148号