superframe icon indicating copy to clipboard operation
superframe copied to clipboard

rotateTo

Open Perhelion opened this issue 8 years ago • 2 comments

Could this function be added from the old https://github.com/tizzle/aframe-orbit-controls-component/ !?

Perhelion avatar Oct 16 '18 09:10 Perhelion

Up! That would be great. I've been able to simulate the "look-at" swapping the orbit-controls.target value:

AFRAME.registerComponent( 'mytest-click', {
  schema: {
    active: { type: "boolean" }
  },
  init: function () {
    var data = this.data;
    var el = this.el;
    el.addEventListener( 'click', function ( evt ) {
      // Calculate real position
      var targetPosition = new THREE.Vector3();
      targetPosition.setFromMatrixPosition( evt.target.object3D.matrixWorld );
      var cameraPosition = document.querySelector( '#camera' ).getAttribute( 'position' );

      // camera height offset
      targetPosition.y -= cameraPosition.y;

      var currOrbit = document.querySelector( '#camera' ).getAttribute( 'orbit-controls' );
      currOrbit.target = targetPosition;

      document.querySelector( '#camera' ).setAttribute( 'orbit-controls', currOrbit );
    } );
  }
});

..I only need to understand how to animate the thing and to "move" the camera to another position

Strae avatar Nov 04 '18 13:11 Strae

Hi,

Here is a patch in which I have the rotateTo functionality available for three views: front, side and top. This can be changed by managing the azimuth and polar angles as desired in the rotateTo function. rotateTo.patch.txt

yyvus avatar Aug 22 '19 09:08 yyvus