2

Im looking to set the value of y in the commented code cameraDir.y = 0; to be the y = 0 plane of the camera after q or e is pressed in if (input._keys.a)

//    if (input._keys.a) {

      _R.copy(this._params.camera.quaternion);
      if (input._keys.q) {
        _A.set(0, 0, 1);
        _Q.setFromAxisAngle(_A, 0.5 * Math.PI * timeInSeconds);
        _R.multiply(_Q);
        this._params.camera.quaternion.copy(_R);
      }
      if (input._keys.e) {
        _A.set(0, 0, -1);
        _Q.setFromAxisAngle(_A, 0.5 * Math.PI * timeInSeconds);
        _R.multiply(_Q);
        this._params.camera.quaternion.copy(_R);
      }
      _A.set(0, 1, 0);  // over Y
      _Q.setFromAxisAngle(_A, Math.PI);
      _R.multiply(_Q);
      controlObject.quaternion.copy(_R);

//    }

//    if (!input._keys.a) {
//      cameraDir.y = 0; 
//      cameraDir.normalize();
//      controlObject.quaternion.setFromUnitVectors(from, cameraDir);
//    }

cubesareneat
  • 302
  • 2
  • 14
  • 1
    To start, see the first part of this answer: https://stackoverflow.com/a/14816480/1461008. It works for any axis. – WestLangley Sep 28 '22 at 05:06
  • thanks West, that works for x and y, but after roationg over z it dosent change my world axis. `` _R.copy(this._params.camera.quaternion); _A.set(0, 0, 1); _Q.setFromAxisAngle(_A, 0.5 * Math.PI * timeInSeconds); _R.multiply(_Q); this._params.camera.quaternion.copy(_R); `` the vector for camera direction is still pointed the correct way but dosent represent the rotations over z – cubesareneat Sep 28 '22 at 12:10
  • i added some more detail to my question – cubesareneat Sep 28 '22 at 15:47
  • Sorry, but I have no idea what your question is... Try `camera.rotateX( angle );` – WestLangley Oct 02 '22 at 15:49
  • sorry @WestLangley I think i missinterpreted my problem, the rotations are confusing me, i hope i fixed the question now – cubesareneat Oct 02 '22 at 20:44

0 Answers0