Skip to content

Commit

Permalink
support resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacbowen committed Feb 24, 2024
1 parent 9557bc4 commit 7258a61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ class SphereWithRods {
constructor() {
this.constructSphere();
this.constructSparkline();
this.addEventListeners();
}

addEventListeners(): void {
window.addEventListener('resize', this.onWindowResize.bind(this), false);
}

onWindowResize(): void {
// Update camera aspect ratio and renderer size
this.camera.aspect = window.innerWidth / window.innerHeight;
this.camera.updateProjectionMatrix();
this.renderer.setSize(window.innerWidth, window.innerHeight);
}

constructSphere(): void {
Expand Down

0 comments on commit 7258a61

Please sign in to comment.