Skip to content

Commit

Permalink
Merge pull request #53 from rapyuta-robotics/bugfix/2d_viewer_camera_…
Browse files Browse the repository at this point in the history
…rotate

Bugfix/2d viewer camera rotate
  • Loading branch information
tocttou committed Sep 3, 2019
2 parents 630f86c + 62afe60 commit 8216a54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/2dControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ const MapControls2D = function(object, domElement) {
this.rotate = function(rotationDelta) {
vector.copy(object.position).sub(center);

spherical.setFromVector3(vector);
// spherical.setFromVector3( vector );
spherical.setFromCartesianCoords(-1 * vector.x, vector.z, vector.y);

spherical.theta += rotationDelta.x * scope.rotationSpeed;
// spherical.phi += rotationDelta.y * scope.rotationSpeed;

spherical.makeSafe();

vector.setFromSpherical(spherical);
const tempRelPosition = vector.setFromSpherical(spherical);
vector.set(-1 * tempRelPosition.x, tempRelPosition.z, tempRelPosition.y);

object.position.copy(center).add(vector);

Expand Down
1 change: 1 addition & 0 deletions src/viewers/2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Viewer2d {
this.camera = new THREE.OrthographicCamera(-100, 100, 100, -100, 0.1, 1000);
this.camera.zoom = 0.5;
this.camera.position.set(0, 0, 10);
this.camera.up = new THREE.Vector3(0, 0, 1);
this.camera.lookAt(new THREE.Vector3());

this.scene.add(this.camera);
Expand Down

0 comments on commit 8216a54

Please sign in to comment.