You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
710 B
26 lines
710 B
const setSize = (container, camera, renderer) => {
|
|
camera.aspect = window.innerWidth / window.innerHeight;
|
|
camera.updateProjectionMatrix();
|
|
|
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
renderer.setPixelRatio(window.devicePixelRatio);
|
|
};
|
|
|
|
class Resizer {
|
|
constructor(container, camera, renderer) {
|
|
// set initial size on load
|
|
setSize(container, camera, renderer);
|
|
|
|
window.addEventListener("resize", () => {
|
|
// set the size again if a resize occurs
|
|
setSize(container, camera, renderer);
|
|
// perform any custom actions
|
|
this.onResize();
|
|
});
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
onResize() {}
|
|
}
|
|
|
|
export { Resizer };
|
|
|