# Camera Transform from Unity to Three

I am trying to transform a scene in Unity to the same in Three.js.
I tried several approaches and all the web articles I could find. One rotation is eluding me though.

Unity is Left Handed, ZXY order of rotation
Three is Right handed, XYZ

Those are my camera and objects:
this.camera = new THREE.PerspectiveCamera( 60, ratio, 512, 4096 ); //21.23931

``````        this.camera.position.set( 1735, 1968.4, -1191) ;
const posR = new THREE.Vector3(1581, 1.0,551);
const posG = new THREE.Vector3(1415.26, 1.0, 666.77);
const posB = new THREE.Vector3(1540.04, 1.07, 846.82);
``````

I am flipping the Y and Z axis

``````    this.camera.position.set( this.camera.position.x, this.camera.position.z, this.camera.position.y) ;
mesh1.position.set( mesh1.position.x, mesh1.position.z, mesh1.position.y) ;
mesh2.position.set( mesh2.position.x, mesh2.position.z, mesh2.position.y) ;
mesh3.position.set( mesh3.position.x, mesh3.position.z, mesh3.position.y) ;
``````

The rotation works well for X,Y axis.
Quaternion approach :

``````   let angleX = 45;
let angleY = 0;
let angleZ = 0;
var unityQuat = new THREE.Quaternion();
unityQuat.setFromEuler(unityEuler);
const UQuat = unityQuat;
var q = new THREE.Quaternion( UQuat.x, -UQuat.z, -UQuat.y, UQuat.w );
var v = new THREE.Euler();
v.setFromQuaternion( q );
unityEuler = v;
this.camera.setRotationFromEuler( unityEuler );
``````

or Euler approach

``````        let cameraRot = [THREE.MathUtils.degToRad(90 - angleX),THREE.MathUtils.degToRad(-angleZ), THREE.MathUtils.degToRad(-angleY)]
var unityEuler = new THREE.Euler( cameraRot[0], cameraRot[1], cameraRot[2], 'YZX' );``````

with AngleY of 30, all is good

With AngleZ of 15, it does not work.

In Unity it rotate around Z first, then apply the X. Make sense.

In Three.js it rotate around the X first it seems.

In my quaternion implementation, I can only get the X rotation working without the -1 multiplication, which does not make sense to me.

Euler apporach makes more sense to me,
var unityEuler = new THREE.Euler( cameraRot[0], cameraRot[1], cameraRot[2], ‘YZX’ );

But present the exact same defect.

I understand I could try to flip the matrices directly but this seems heavy lifting to do that at every frame.

Instead of flipping Y & Z, I tried to negate Z.
It works now with:

``````       let cameraRot = [THREE.MathUtils.degToRad(-angleX),THREE.MathUtils.degToRad(-angleY), THREE.MathUtils.degToRad(angleZ)]
var unityEuler = new THREE.Euler( cameraRot[0], cameraRot[1], cameraRot[2], 'YXZ' );
this.camera.setRotationFromEuler( unityEuler );
this.camera.position.set( this.camera.position.x, this.camera.position.y, -this.camera.position.z) ;
mesh1.position.set( mesh1.position.x, mesh1.position.y, -mesh1.position.z) ;``````