File size: 1,166 Bytes
2b7aae2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Matrix4 } from '../math/Matrix4.js';
import { Object3D } from '../core/Object3D.js';

class Camera extends Object3D {
	constructor() {
		super();

		this.type = 'Camera';

		this.matrixWorldInverse = new Matrix4();

		this.projectionMatrix = new Matrix4();
		this.projectionMatrixInverse = new Matrix4();
	}

	copy(source, recursive) {
		super.copy(source, recursive);

		this.matrixWorldInverse.copy(source.matrixWorldInverse);

		this.projectionMatrix.copy(source.projectionMatrix);
		this.projectionMatrixInverse.copy(source.projectionMatrixInverse);

		return this;
	}

	getWorldDirection(target) {
		this.updateWorldMatrix(true, false);

		const e = this.matrixWorld.elements;

		return target.set(-e[8], -e[9], -e[10]).normalize();
	}

	updateMatrixWorld(force) {
		super.updateMatrixWorld(force);

		this.matrixWorldInverse.copy(this.matrixWorld).invert();
	}

	updateWorldMatrix(updateParents, updateChildren) {
		super.updateWorldMatrix(updateParents, updateChildren);

		this.matrixWorldInverse.copy(this.matrixWorld).invert();
	}

	clone() {
		return new this.constructor().copy(this);
	}
}

Camera.prototype.isCamera = true;

export { Camera };