Orbit Camera Add Offset in Y

Hello,

I am using the orbit camera script, but I am facing an issue which is that when ever I give a model to the script to focus on, the model is always in the middle of the screen, but I want it to be above the middle mark, in the blue box in the image.
I have studied and tried its different options but it just messes up some other functionality.

Yes, they orbit camera will calculate its focus point to be at the center of the combined aabb calculated by all mesh instances provided.

You could add a property setter for the this.pivotPoint property in the orbit camera script when the value changes, the newly calculated value is offset by a couple of units in Y positive.

1 Like

The orbit camera should already have a property to change the pivot point (we use it for panning IIRC). I recommend setting it at a known value and getting rid of the ‘focus’ code.

1 Like

Hey,

I added this line in the initialize after the AABB is built,
this._modelsAabb.center.y = 0.5;
and its working correctly, but the rotation is messed up!

Thanks

1 Like

Instead of changing a property of the bounding box of the model, you can copy that position to a new vector. That new vector can have its Y value updated and given to the camera. This way your bounding box will still have correct values, as you might need them for something else in the future.

1 Like