-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenderer.js
More file actions
31 lines (27 loc) · 849 Bytes
/
Renderer.js
File metadata and controls
31 lines (27 loc) · 849 Bytes
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
import * as THREE from "three";
import Experience from "../Experience.js";
export default class Renderer {
constructor() {
this.experience = new Experience();
this.canvas = this.experience.canvas;
this.sizes = this.experience.sizes;
this.scene = this.experience.scene;
this.camera = this.experience.camera;
this.setInstance();
}
setInstance() {
this.instance = new THREE.WebGLRenderer({
canvas: this.canvas,
antialias: true,
});
this.instance.setSize(this.sizes.width, this.sizes.height);
this.instance.setPixelRatio(Math.min(this.sizes.pixelRatio, 2));
}
resize() {
this.instance.setSize(this.sizes.width, this.sizes.height);
this.instance.setPixelRatio(Math.min(this.sizes.pixelRatio, 2));
}
update() {
this.instance.render(this.scene, this.camera.instance);
}
}