phemt.latd
phemt.latd

Reputation: 1803

Move camera to a fixed position and axis

I've a demo with a 3D model, work with webGL and Three.js, i import orbit, set it and everything work with it. Now i've the problem to restore a camera position after i've change it with orbit gesture.

The problem is that i want a button that on click repositioning the camera in a way that the model seems to be in a isometric position.

Upvotes: 1

Views: 1645

Answers (1)

phemt.latd
phemt.latd

Reputation: 1803

I found that the best solution is the banal one.

  1. Position in the classic way the camera and object to lookAt a isonometric vector

    this.camera.position.set(x,y,z);
    
  2. Save this position as start position:

    this.startPosition = this.camera.position.clone();
    
  3. Use this vector to restore the initial position after Orbit had changed it:

    this.camera.position.set(this.startPosition.x, this.startPosition.y, this.startPosition.z);
    

This is more simple that calculate the rotation's angle computer by orbit and for my porpouse work pretty well.

Upvotes: 2

Related Questions