Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to make the earth rotate #642

Open
SeongminJaden opened this issue Nov 21, 2023 · 0 comments
Open

I want to make the earth rotate #642

SeongminJaden opened this issue Nov 21, 2023 · 0 comments

Comments

@SeongminJaden
Copy link

SeongminJaden commented Nov 21, 2023

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant