How can I fix the 3D camera view?

Supreme Blorgon shared this question 3 years ago
Answered

I'm working on a project in which a user can select between different objects, and which will draw a sphere on the origin according to the selected object's characteristics. Basically, it's a slider that's linked to a list of different radii and other necessary parameters to show a model of a given planet in the solar system.


Since the size difference between the smallest and largest planets is so great, I'd like for the 3D graphics view to automatically adjust the camera distance, but remain at a fixed angle. In other words, I want the angle to remain fixed in an orthographic projection, but have the camera distance automatically adjust according to the planet's radius so that no matter which planet is selected, it will always be in view without the user needing to zoom in or out.


Is there a way to do this? I know how to do it in 2D graphics, but I don't see similar controls for 3D graphics viewing options.

Comments (7)

photo
1

see the help for SetViewDirection[]

CentreView[ <Centre Point> ]

zoomin[]

zoomout[]

these commands can be used in a 'on clicscript' for focalizing each planet when you do clic on it

you can need a reset button also

saludos

photo
1

I've gotten SetViewDirection and CenterView to work, but ZoomIn doesn't work. I've been using ZoomIn[min x, min y, max x, max y], with the x and y values being dependent on the radius of the selected planet, but when I switch planets, nothing happens.


Why can't I use the magnitude of the vector used in SetViewDirection to determine the camera distance from the origin?

photo
1

I think not, but you can use corner[] for calculating the scale for zoomin[] because I see that ZoomIn[min x, min y, max x, max y] works only in 2D

photo
1

I'm not quite sure I understand—can you be more specific?

photo
photo
1

yes

more specific (the circles in the works can be deleted)

Files: foro.ggb
photo
1

Figured it out!

Still don't really understand how it works, but it does, so thanks!

photo
photo
1

the inputbox has this on update script:

SetActiveView[-1] select 3D view

ZoomIn[high/a] zoom at the desired size

CentreView[(0,0,0)] center the view


if you modify the value in the inputbox (ie: 100 to 80) you can see the effect. I can not calculate that you want but I think you have already enough info

© 2020 International GeoGebra Institute