Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cesium bind camera to model

I have put Cesium model

let modelMatrix = Transforms.eastNorthUpToFixedFrame(
  Cartesian3.fromDegrees(
    longitude,
    latitude,
    altitude
  )
);

let model = this.viewer.scene.primitives.add(Model.fromGltf({
    url : URL,
    modelMatrix : modelMatrix,
    minimumPixelSize : 1,
    maximumScale : 1
}));

And im going to change its position (model will fly) And I would like to know is there a way to bind camera to this model. Something like this:

let camera = this.viewer.camera.bindToModel(model, OPTIONS);

So when model will change its position - camera will also move. Thanks

like image 516
Sasha Kos Avatar asked May 21 '26 13:05

Sasha Kos


1 Answers

The reason why my

viewer.trackedEntity = myModel;

did not focus camera on model, is that i used

let myModel = viewer.scene.primitives.add(MODEL);
viewer.trackedEntity = myModel;

to add model on scence and focus on it. When i changed to

let myModel = viewer.entities.add(MODEL_DESC);
viewer.trackedEntity = myModel;

My camera focused on model and follow it on position change, as i need. Thanks emackey for useful example Multipart CZML Demo that helped to solve my task

like image 200
Sasha Kos Avatar answered May 24 '26 02:05

Sasha Kos