resium
resium copied to clipboard
I want to make the earth rotate
Please tell me how to use it in Resium. I successfully implemented this code in CesiumJS's sandcastle, but I can't do it in Resium. Please help.
const viewer = new Cesium.Viewer("cesiumContainer"); const scene = viewer.scene; const clock = viewer.clock;
viewer.dataSources.add(Cesium.CzmlDataSource.load(czml));
const camera = new Cesium.Camera(scene);
// 1. Fly to a position with a top-down view viewer.camera.flyTo({ destination : Cesium.Cartesian3.fromDegrees(126, 37, 15000000.0) });
// 1. Using a cartesian offset //const center = Cesium.Cartesian3.fromDegrees(-98.0, 40.0); //viewer.camera.lookAt(center, new Cesium.Cartesian3(0.0, -4790000.0, 3930000.0));
function icrf(scene, time) { if (scene.mode !== Cesium.SceneMode.SCENE3D) { return; }
var icrfToFixed = Cesium.Transforms.computeIcrfToFixedMatrix(time);
if (Cesium.defined(icrfToFixed)) {
var camera = viewer.camera;
var offset = Cesium.Cartesian3.clone(camera.position);
var transform = Cesium.Matrix4.fromRotationTranslation(icrfToFixed);
camera.lookAtTransform(transform, offset);
}
}
viewer.scene.postUpdate.addEventListener(icrf);