Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
fix: setSize method of PointCloudViewer does not scale correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxuhai committed Sep 21, 2022
1 parent fdecff3 commit 6781d94
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/visualization/PointCloudViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class PointCloudViewer {
canvas,
antialias: true,
});
this.renderer.setPixelRatio(window.devicePixelRatio);
this.renderer.setSize(width, height);
this.renderer.setAnimationLoop(this.render);
this.controls = this.createOrbitControls();
this.setOrbitControls({ minDistance: 0.1, maxDistance: 100 });
this.setCameraParameters({
Expand All @@ -64,6 +61,9 @@ class PointCloudViewer {
z: 10,
},
});
this.setSize(width, height);
this.renderer.setPixelRatio(window.devicePixelRatio);
this.renderer.setAnimationLoop(this.render);
}

// public function
Expand Down Expand Up @@ -106,7 +106,10 @@ class PointCloudViewer {
}

public removePointCloud(id = this.cloudProperties.id) {
this.scene.getObjectByName(id)?.removeFromParent();
const object = this.scene.getObjectByName(id) as PointsObject3D;
object?.material?.dispose();
object?.geometry?.dispose();
object?.removeFromParent();
this.cloud = undefined;
}

Expand Down Expand Up @@ -188,7 +191,7 @@ class PointCloudViewer {
public setSize(width: number, height: number) {
this.camera.aspect = width / height;
this.camera.updateProjectionMatrix();
this.renderer.setSize(width, width);
this.renderer.setSize(width, height);
}

public show() {
Expand Down

1 comment on commit 6781d94

@vercel
Copy link

@vercel vercel bot commented on 6781d94 Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pcl-js – ./

pcl-js-darkce.vercel.app
pcljs.org
pcl-js-git-master-darkce.vercel.app
www.pcljs.org

Please sign in to comment.