Skip to content

Commit

Permalink
fix orbit control bug on mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
joschi1212 committed Jun 28, 2024
1 parent 69d649a commit a2abb57
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions web/src/edit/EditComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,21 @@ class Edit extends Component {

const gridHelper = new THREE.GridHelper( 10, 50 );
this.scene.add( gridHelper );
this.labelRenderer = new CSS2DRenderer();

if (isMobile) {
this.camera = new THREE.PerspectiveCamera(75, (window.innerWidth - 20) / (window.innerHeight - 20), 0.1, 1000);
this.renderer.setPixelRatio(window.devicePixelRatio);
this.labelRenderer.setSize(window.innerWidth - 20, window.innerHeight - 20);
} else {
this.camera = new THREE.PerspectiveCamera(75, (window.innerWidth - 300) / (window.innerHeight - 105), 0.1, 1000);
this.labelRenderer.setSize(window.innerWidth - 300, window.innerHeight - 105);

}
this.labelRenderer = new CSS2DRenderer();
this.labelRenderer.setSize(window.innerWidth - 300, window.innerHeight - 105);
this.labelRenderer.domElement.setAttribute("name", "orbit_controls");
this.labelRenderer.domElement.style.position = 'absolute';
this.labelRenderer.domElement.style.top = '0px';
this.labelRenderer.domElement.style.left = '10px';
this.mount.appendChild(this.labelRenderer.domElement);

this.camera.position.z = 5;
Expand Down

0 comments on commit a2abb57

Please sign in to comment.