Moving camera along a 'track'

Is it possible to move the camera along a predefined route, ie with a scrubber slider that allows it to go forward and back along that track?

I think the easiest way to do that is to create an entity that moves along a path, and then attach the camera to that entity (either using the viewer.trackedEntity or by updating the camera position every frame to match the entity).

The latter is how the camera orbit in this project is done: Projecting flags on Matterhorn mountain - behind the scenes

// Run each frame or onTick:
let entityPosition = entity.position.getValue(viewer.clock.currentTime);
viewer.camera.position.x = entityPosition.x;
viewer.camera.position.y = entityPosition.y;
viewer.camera.position.z = entityPosition.z;

The nice thing about doing this on top of an entity is it can be hooked up to the timeline, so you can scrub the timeline back and forth to move the camera long the path.

@omar
I’m trying the same but it’s not working for me.
let entityPosition = entity.position.getValue(viewer.clock.currentTime);
Given line provided some incorrect values in negative.