I think I have all my issues I was having with exporting, except for the rotation.
I have set Y+ is UP and Z+ is FORWARD in the FBX export, which matches the coordinate system of Terragen, but unfortunately, when I convert the rotations to 360 degrees, they are not matching the source cameras. Have I done something wrong?
And the code I am using to convert the rotations (found here):
// Camera Rotation in XYZ Degrees
cameraRotation = ( Math.round( THREE.Math.radToDeg( camera.rotation.x ) % 360 ) ) + ' ' + ( Math.round( THREE.Math.radToDeg( camera.rotation.y ) % 360 ) )
+ ' ' + ( Math.round( THREE.Math.radToDeg( camera.rotation.z ) % 360 ) );
The XML shader value expects a three value vector separated by spaces, that’s why it is formatted strangely.
For some reason it seems 90s degrees is just inexplicitly lost form the Y axis. If I add 90 degrees to the formula, I get the correct rotation. But why? And that is only for Y and not accounting for errors in any other axis, so it’s still not correct if you start tilting cameras on X and Z.
// Camera Rotation in XYZ Degrees
cameraRotation = ( Math.round( THREE.Math.radToDeg( camera.rotation.x ) % 360 ) ) + ' ' + ( ( Math.round( THREE.Math.radToDeg( camera.rotation.y ) ) + 90 ) % 360 )
+ ' ' + ( Math.round( THREE.Math.radToDeg( camera.rotation.z ) % 360 ) );