Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
how to get X and y a axis as vectors from euler rotations or quaternion

I want to get the the camera y and x axis as individual vectors so i can rotate around them. How can i get that from either the euler rotations, or quaternion of the camera.

_euler.setFromQuaternion( camera.quaternion );  // sets euler rotation in order XYZ

_A = new Vector3(1, 0, _euler.z);  // this is wrong, it needs to be the camera y axis
_R.copy(camera.quaternion);
_Q.setFromAxisAngle(_A, movementX);  // _euler.y -= movementX;
_R.multiply(_Q);
camera.quaternion.copy(_R);

_A = new Vector3(1, 0, _euler.z);  // needs to be the camera x axis
_R.copy(camera.quaternion);
_Q.setFromAxisAngle(_A, movementY);  // _euler.x -= movementY;
_R.multiply(_Q);
camera.quaternion.copy(_R);

thirdpersoncamera.js work how i want ( i think)

export const third_person_camera = (() => {

  class ThirdPersonCamera extends entity.Component {
    constructor(params) {
      super();

      this._params = params;
      this._camera = params.camera;

      this._currentPosition = new THREE.Vector3();
    }

    _CalculateIdealOffset() {
      const cameraXYZ = new THREE.Vector3
      this._params.camera.getWorldDirection(cameraXYZ);

      if (this._camera.isspaceshipcamera) {
        const cameraY = (cameraXYZ.y*80);
        this.idealOffset = new THREE.Vector3(0, 20 , -80); 
      }
      else {
        const cameraY = (Math.abs(cameraXYZ.y*50));
        this.idealOffset = new THREE.Vector3(0, 20 + (cameraY/2), -50 + cameraY);
      }

      this.idealOffset.applyQuaternion(this._params.target._rotation);
      this.idealOffset.add(this._params.target._position);
      return this.idealOffset;
    }


  _CalculateIdealLookat() {
    const idealLookat = new THREE.Vector3(0, 10, 50);
    idealLookat.applyQuaternion(this._params.target.Rotation);
    idealLookat.add(this._params.target.Position);
    return idealLookat;
  }

  Update(timeElapsed) {
    const idealOffset = this._CalculateIdealOffset();
    const t = 1.0 - Math.pow(0.0000000000001, timeElapsed);
    this._currentPosition.lerp(idealOffset, t);
    this._camera.position.copy(this._currentPosition);

  }

after one of the 2 keys below are pressed mousemovex and y are no longer the cameras X and Y , I do want them to be tho

      _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);
      }
almost 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!