You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose new options for controlling the 3d view (for threejs, eventually for other viewers)
camera_position, a non-zero triplet (x,y,z) of coordinates: The position of the camera, relative to the center of the bounding box. The camera view is directed from there towards the center of the bounding box. A larger distance of the camera will produce a gradually more and more orthographic image, while a small distance will produce a fisheye view. The size of the image is scaled to ensure that the complete bounding box is shown, provided that the camera is sufficently far away. [There could be a warning if the camera is too close; or there could be an additional option that allows to specify the "opening-angle" and would then scale the camera position accordingly.] (The "zoom" option is independent: It just scales the two-dimensional projection.) With the projection="orthographic" option, the triplet is interpreted as a direction, and its length is irrelevant.
camera_up (optional): The "upward" direction of the camera. This is either a three-dimensional vector (triplet) or a single number. If a vector is given, it should not be parallel to the view direction, and its projection to the plane orthogonal to the view direction is used as the direction that appears "upward" in the picture. The length of the vector is irrelevant. If a single number is given, it is interpreted as a "tilt angle", measured in degrees, that specifies how much the camera is tilted with respect to the default natural "up" orientation that results from an "up" vector of (0,0,1). A positive angle tilts the camera to the left, causing the image to rotate right. The default is a tilt angle of 0. For view directions that are close to perpendicular, the default up-direction is ill-defined, and it is recommended to specify a vector.
Correspondingly, the display in threejs should have an option to export the current view settings (like currently with viewpoint). The export should export the complete options string "capera_pos=(2,3,4),camera_up=10.23" etc. (Currently the user needs to supply extra brackets.) UPDATE: the threejs viewer always maintains the UP position. I have implemented a preliminary option to retrieve the "raw" camera position "as is" in the related ticket variable camera position, light, etc. for tachyon ray tracer #13111. It needs some processing to be useful.
These parameters should eventually also work for other plot viewers, like
tachyon, tikz, and allow a smooth workflow: Use threejs for interactive previewing, and other viewers for high-quality output that might be used in a publication.
The current "viewpoint" option should be kept for backward compatibility. I found out its meaning only by looking at the source code: The default POSITION of the camera is rotated by the given angle about the given axis. The ORIENTATION of the camera is determined always by the default "up" direction. I find this "viewpoint" option unsatisfactory for several reasons: 1) The parameters are not intuitive. (and not documented) 2) A tilted camera cannot be produced by the parameters 3) It uses 4 parameters for a 2d resulting parameter space 4) Correspondingly, the parameterization is not very expressive. The camera distance is always the same. 5) It is discontinuous for vertical view directions. 6) It does not integrate with other viewers.
As far as I saw, threejs has all the expressiveness to implement the new proposed options painlessly.
UPDATE: I saw that the "zoom" option is implemented in some viewers by scaling the scene and not as described above. Unfortunately, this will change the perspective. The zoom=0.5 should rather look the same as zoom=1, only half as big. In ticket #13111, I have disabled the change to the scene by the zoom parameter, I let tachyon do the zooming.
I propose new options for controlling the 3d view (for threejs, eventually for other viewers)
camera_position, a non-zero triplet (x,y,z) of coordinates: The position of the camera, relative to the center of the bounding box. The camera view is directed from there towards the center of the bounding box. A larger distance of the camera will produce a gradually more and more orthographic image, while a small distance will produce a fisheye view. The size of the image is scaled to ensure that the complete bounding box is shown, provided that the camera is sufficently far away. [There could be a warning if the camera is too close; or there could be an additional option that allows to specify the "opening-angle" and would then scale the camera position accordingly.] (The "zoom" option is independent: It just scales the two-dimensional projection.) With the projection="orthographic" option, the triplet is interpreted as a direction, and its length is irrelevant.
camera_up (optional): The "upward" direction of the camera. This is either a three-dimensional vector (triplet) or a single number. If a vector is given, it should not be parallel to the view direction, and its projection to the plane orthogonal to the view direction is used as the direction that appears "upward" in the picture. The length of the vector is irrelevant. If a single number is given, it is interpreted as a "tilt angle", measured in degrees, that specifies how much the camera is tilted with respect to the default natural "up" orientation that results from an "up" vector of (0,0,1). A positive angle tilts the camera to the left, causing the image to rotate right. The default is a tilt angle of 0. For view directions that are close to perpendicular, the default up-direction is ill-defined, and it is recommended to specify a vector.
Correspondingly, the display in threejs should have an option to export the current view settings (like currently with viewpoint). The export should export the complete options string "capera_pos=(2,3,4),camera_up=10.23" etc. (Currently the user needs to supply extra brackets.) UPDATE: the threejs viewer always maintains the UP position. I have implemented a preliminary option to retrieve the "raw" camera position "as is" in the related ticket variable camera position, light, etc. for tachyon ray tracer #13111. It needs some processing to be useful.
These parameters should eventually also work for other plot viewers, like
tachyon, tikz, and allow a smooth workflow: Use threejs for interactive previewing, and other viewers for high-quality output that might be used in a publication.
The current "viewpoint" option should be kept for backward compatibility. I found out its meaning only by looking at the source code: The default POSITION of the camera is rotated by the given angle about the given axis. The ORIENTATION of the camera is determined always by the default "up" direction. I find this "viewpoint" option unsatisfactory for several reasons: 1) The parameters are not intuitive. (and not documented) 2) A tilted camera cannot be produced by the parameters 3) It uses 4 parameters for a 2d resulting parameter space 4) Correspondingly, the parameterization is not very expressive. The camera distance is always the same. 5) It is discontinuous for vertical view directions. 6) It does not integrate with other viewers.
As far as I saw, threejs has all the expressiveness to implement the new proposed options painlessly.
UPDATE: I saw that the "zoom" option is implemented in some viewers by scaling the scene and not as described above. Unfortunately, this will change the perspective. The zoom=0.5 should rather look the same as zoom=1, only half as big. In ticket #13111, I have disabled the change to the scene by the zoom parameter, I let tachyon do the zooming.
CC: @egourgoulhon @jcamp0x2a @paulmasson @slel
Component: graphics
Keywords: camera
Issue created by migration from https://trac.sagemath.org/ticket/31149
The text was updated successfully, but these errors were encountered: