Moving the orbit-camera.js focus smoothly

Hi, I’m using the orbit camera script which does 95% of what I need but I want to be able to move the focus point smoothly in real time on certain events.

I tried moving the focus point smoothly but in the existing script the camera focus point only updates on initialization or if the focus object changes.

Is there a quick way to have the focus position update every frame? I had a look at the code but couldn’t figure out quite how to do this.

Any help appreciated.

You can either update the pivot point (see the pan function on mouse input for an example).

Or you can use the function resetAndLookAtPoint on the OrbitCamera script

Thanks, I tried…


in the update loop, but I just aget a blank screen, presumably the camera is pointing somewhere odd.

resetAndLookAtPoint takes two pc.Vec3, not a pc.Vec3 and an entity.

Oop, Thanks, it sort of works if I put :


in the update loop, but it loses all the inertia and mouse scroll sensitivity. Any idea how I could keep that?

This shouldn’t be used for every update, only for the camera transition period.

Reading back, I’m not 100% what the effect you are looking for now. I assumed you wanted to do a camera transition to another model or another part of the model.

This is all good thanks. The only thing I need now is how to find the position of the camera focus in world space after the camera has been panned around. The effect I’m after works perfectly until you pan about, if you do the transition after this it just snaps back before panning.

For this reason I think I need my focus point to move as the user pans the camera .

Thinking about it I guess I could just stick an empty child entity in front of the camera all the time.

Going to try… :slight_smile:

You can access the pivot point to know the current ‘focus point’ on the orbit camera script.

I tried that but I couldn’t return its position for some reason (Maybe its not an entity?). Either way I seem to have got it work as I want by just dropping an empty entity directly in front of the camera. Cheers

It’s not an entity, just a pc.Vec3

1 Like