Hi, I’m syncing cameras Three and Cesium. I also draw objects using Three on the scene and I have them moving. There is a problem. When I switch to Columbus mode, the Three objects I have continue to fly in 3D mode and do not shift to the plane. How can I solve this problem? Here is the function where I sync the camera:
function updateThreeJS() {
// Update Three.js camera field of view to match Cesium camera's vertical FOV
threeCamera.fov = Cesium.Math.toDegrees(cesiumViewer.camera.frustum.fovy);
threeCamera.updateProjectionMatrix();
// Sync Three.js camera with Cesium camera
const cesiumCamera = cesiumViewer.camera;
const cvm = cesiumCamera.viewMatrix;
const civm = cesiumCamera.inverseViewMatrix;
// Fix the extraction of camera position and direction from matrices
const cameraPosition = Cesium.Cartesian3.clone(cesiumCamera.positionWC);
const cameraDirection = new Cesium.Cartesian3(-cvm[2], -cvm[6], -cvm[10]);
const cameraUp = new Cesium.Cartesian3(cvm[1], cvm[5], cvm[9]);
// Convert Cesium camera position to Three.js Vector3
const cameraPositionVec3 = new THREE.Vector3(cameraPosition.x, cameraPosition.y, cameraPosition.z);
// Convert Cesium camera direction and up vector to Three.js Vector3
const cameraDirectionVec3 = new THREE.Vector3(cameraDirection.x, cameraDirection.y, cameraDirection.z);
const cameraUpVec3 = new THREE.Vector3(cameraUp.x, cameraUp.y, cameraUp.z);
// Update Three.js camera position and orientation
threeCamera.position.copy(cameraPositionVec3);
threeCamera.up.copy(cameraUpVec3);
threeCamera.lookAt(cameraPositionVec3.clone().add(cameraDirectionVec3));
// Apply rotation to the cube
cube.rotation.x += 0.01;
// Render the scene with the updated camera
threeRenderer.render(threeScene, threeCamera);
};