# How to calculate camera view matrix from world transform, specifically the orientation?

In my engine, camera is just any other object in the scene. It has a transform -- position, rotation (quaternion), and scale (ignored for camera view matrix). I want to convert this to the camera's view matrix. I tried the following formula (currently, there is no rotation) but for some reason, the position in the X axis is incorrect:

mat4 cameraTransform = translate(identity, transform.position) * to_mat4(transform.rotation); // rotation is quaternion

auto viewMatrix = inverse(cameraTransform);


Camera's transform (from perspective of a generic lookUp camera for testing purposes):

Camera's view:

The issue here is that, the camera's position is somehow flipped. The camera is positioned to look in the X direction (the red axis line); however, from camera's view matrix, it is looking in the Z direction (blue axis line). The thing is, from the looks of it, the camera's position is actually correct (I counted the grid boxes on the ground). The problem is that, it is rotated. I can't seem to figure out why. There is currently no rotation ((0,0,0) in euler angles).

How should I calculate this? Also, what does the view matrix represent in terms of what valeus are in the matrix? Does it represent where the camera is looking at or where the camera actually is?