pex-gl / pex-cam

Cameras models and controllers for 3D rendering in PEX.
MIT License
2 stars 3 forks source link

maxDistance is never set and defaults to 10 #20

Open vorg opened 2 years ago

vorg commented 2 years ago

It got lost here and causes large gilt scenes to be zoomed in into the mesh.

https://github.com/pex-gl/pex-cam/commit/6e2881caad1a8cf47c75df7adb493519a4ef7d10#diff-78aa8fa08464681459d97cd46fe608ab83a8944ec030fa9796ad452ddaa8d1cfL80

Screenshot 2022-07-02 at 01 23 41
dmnsgn commented 2 years ago

True, I see its purpose. A few points that come to mind:

I see 3 options:

orbiter.set({
  maxDistance: vec3.add(aabb.size(scene.bounds), aabb.center(scene.bounds))
})

Thoughts?

vorg commented 2 years ago

It's convenience to protect you from inertia scrolling on Mac but pain on bigger scenes like Expo.

It is a convenience method and I assume / 10 and * 10 work in most case but is it just an arbitrary number?

In most cases you set your camera outside of the scene if you use orbiter to rotate around it. 10x was good guesstimate to prevent it shrinking to 1x1 px if you zoom out too far.

Overrides already set defaults on the orbiter object

That's ok. Because if you know what you want you just provide maxDistance and otherwise (most cases) you don't have to do extra steps.

vorg commented 2 years ago

I think we should probably disable it by default, remove to automagic guessing on position set and let user set it manually if really needed.

minDistance: Number.EPSILON,
maxDistance: Infinity,

Cases where you zoom out too far should be handled on the user side by e.g. having reset camera button.