Skip to content

Commit

Permalink
wasted more time on resize, no joy
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcatbuzz committed Jun 30, 2024
1 parent 4a74be0 commit d2f3452
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class HomeComponent implements OnInit, OnDestroy {
// this.scene.add(this.mesh);

this.renderer = new THREE.WebGLRenderer({ antialias: true });
console.log('this is running', this.renderer)
// console.log('this is running', this.renderer)
this.rendererContainer.nativeElement.appendChild(this.renderer.domElement);
this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
this.renderer.setSize(window.innerWidth, window.innerHeight);
Expand Down Expand Up @@ -133,6 +133,8 @@ export class HomeComponent implements OnInit, OnDestroy {
y * (size + gap) - (gridSize / 2) * (size + gap),
z * (size + gap) - (gridSize / 2) * (size + gap)
);

// cube.scale.set(0.5, 0.5, 0.5)
this.scene.add(cube);
this.cubes.push(cube);
}
Expand Down Expand Up @@ -233,15 +235,25 @@ export class HomeComponent implements OnInit, OnDestroy {

@HostListener('window:resize')
onWindowResize() {
console.log('this function is working')
// console.log('this function is working')
// const width = this.rendererContainer.nativeElement.offsetWidth;
// const height = this.rendererContainer.nativeElement.offsetHeight;
// original below
const width = this.rendererContainer.nativeElement.clientWidth || window.innerWidth;
const height = this.rendererContainer.nativeElement.clientHeight || window.innerHeight;
// const rect = this.rendererContainer.nativeElement.getBoundingClientRect();
// console.log(rect, 'what is the rect????')
// const width = rect.width;
// const height = rect.height;
console.log(width, "width")
this.camera.aspect = width / height;
this.camera.updateProjectionMatrix();
this.renderer.setSize(width, height, false);
// attempt at resize cube(mesh) not working
// const scale = Math.min(width, height) / 500;
// this.cubes.forEach(cube => {
// cube.scale.set(scale, scale, scale);
// })

// Update the mesh scale
// const aspectRatio = width / height;
Expand Down

0 comments on commit d2f3452

Please sign in to comment.