Directly set Camera's projection matrix

Is there a way to directly modify and set the camera’s projectionMatrix via its frustum? I see the ability to set the camera’s transform, but the only way I see of setting the frustum’s projection matrix is piecemeal, involving some math to set the near/far/fov/aspect ratio…etc.
EDIT:
Is there also a way to directly set the camera’s viewMatrix?

For example, what I would like to be able to do is something like:

Cesium.Matrix4.multiply(baseCameraViewMatrix, otherViewMatrix, camera.viewMatrix);

This would allow me to apply a view matrix (rotation and translation) on top of a base camera view matrix in order to apply rotation/translation local to the “baseCameraViewMatrix”

Thanks!!

Welcome to the Cesium Community!

Both the camera’s projectionMatrix and viewMatrix are read-only from the API side. You can rotate the camera with the rotate function (API link) and translate the camera with the move function (API link). You can also set the camera’s view with setView (API link).

Thanks for the reply @dzung! Unfortunately these methods do not provide what I need, at least not what I think I need anyways, that would be great if they did! I’m currently trying to get webxr working with cesium and the first bit bit I’m trying to do is integrate the pose and projection data coming from webxr. I’m trying to understand how I can apply a view matrix coming from webxr on top of a base transformation in cesium and am not having much luck. The next battle would be to get the projection matrix coming from webxr applied to the cesium camera.

Hi, I managed to control cesium camera with webxr device pose, with both chrome webxr emulater and a pico neo3(but not in immersive-vr mode).But I have problems getting my cesium webglcontext framebuffers to webxr layer buffers, so the immersive-vr is just a black screen. May I know how you get your cesium context to webxr context?

Please see below for how I sync cesium camera with headset pose
function getDevice () {
let device = navigator.xr[Object.getOwnPropertySymbols(navigator.xr)[1]]?.device;
return device;
}
function getDeviceHeadingPitchRoll () {
let device = getDevice(),
quaternion = new Cesium.Quaternion(…device.quaternion),
// axis = Cesium.Quaternion.computeAxis(quaternion, new Cesium.Cartesian3()),
headingPitchRollOrigin = Cesium.HeadingPitchRoll.fromQuaternion(quaternion),
headingPitchRoll = new Cesium.HeadingPitchRoll(headingPitchRollOrigin.pitch, headingPitchRollOrigin.roll, headingPitchRollOrigin.heading);
// console.debug('headset headingPitchRoll: ')
// console.debug(headingPitchRoll)
return headingPitchRoll;
}
export function syncCamera () {
let headingPitchRoll = getDeviceHeadingPitchRoll(),
center = Cesium.Cartesian3.fromDegrees(your webxr center);
viewer.camera.setView({
destination: center,
orientation: {
heading: -headingPitchRoll.heading,
pitch: -headingPitchRoll.pitch,
roll: -headingPitchRoll.roll
}
})
}