Hi, somehow I’m not able to focus my objects perfectly with the oribitcamera script at runtime.
It focuses my objects on startup, but after changing the geometrie (with bones) I’m unable to focus the entity again so that it fits to the window size. I’m calling the
OrbitCamera.prototype.focus to update the focus but it doesn’t fit.
The camera is too far away and I just wonder why.
Before that I’ve tried
OrbitCamera.prototype.resetAndLookAtEntity but then it looks from a fixed reset point which is also not what I want.
What I really want it the function from the PlayCanvas Editor here ^^
If you know what distance to set the camera from the entity, that can be used instead to ‘focus’ on the entity.
The math could use some tweaking in
OrbitCamera.prototype.focus as I think it may be overly safe?
Yeah, if you don’t want to edit the min and max distances in the editor, you can always just manually set the
this.distance value in the OrbitCamera script. Probably something to do with the bounding box for that model or the entity you’re containing the model in. Might need to play with
OrbitCamera.prototype._buildAabb which works with
.focus() as @yaustar mentioned.
thanks for your support.
I’ve written two functions
lookAndFocusAtHotspot and added it to the
smoothFocus: smoothly change distance to look at whole entity with children
lookAndFocusAtHotspot: smoothly change distance, rotation and position (optional) to look at whole entity with children
I’m sure this can be done cleaner and easier. But I didn’t understand the tween.js lib and was looking for a quick solution.