-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.js
More file actions
40 lines (39 loc) · 1.08 KB
/
Camera.js
File metadata and controls
40 lines (39 loc) · 1.08 KB
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
import * as THREE from "three";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
import Experience from "../Experience.js";
export default class Camera {
constructor() {
this.experience = new Experience();
this.sizes = this.experience.sizes;
this.scene = this.experience.scene;
this.cameraGroup = this.experience.cameraGroup;
this.canvas = this.experience.canvas;
this.setInstance();
this.setOrbitControls();
}
setInstance() {
this.instance = new THREE.PerspectiveCamera(
35,
this.sizes.width / this.sizes.height,
0.1,
1000
);
this.instance.position.set(
-3.6277092514077784,
1.6242714732329864,
2.729361431631495
);
this.instance.lookAt(new THREE.Vector3(0, 0, 0));
this.cameraGroup.add(this.instance);
}
setOrbitControls() {
this.controls = new OrbitControls(this.instance, this.canvas);
}
resize() {
this.instance.aspect = this.sizes.width / this.sizes.height;
this.instance.updateProjectionMatrix();
}
update() {
this.controls.update();
}
}