Computes the 3D view frustum of a viewpoint and returns it as a meshgeom object.
Syntax
meshgeom ST_ComputeFrustum(cstring viewpoint);Parameters
| Parameter | Description |
|---|---|
viewpoint | The viewpoint definition in JSON format. See the field reference below. |
Viewpoint JSON fields
| Field | Description | Default | Valid values |
|---|---|---|---|
x | The x-coordinate of the viewpoint. | 0 | (-inf, +inf) |
y | The y-coordinate of the viewpoint. | 0 | (-inf, +inf) |
z | The z-coordinate of the viewpoint. | 0 | (-inf, +inf) |
h | The height of the viewpoint. | 0 | [0, +inf) |
azimuth | The horizontal viewing direction, measured clockwise from north (the positive y-axis direction). Unit: degrees. | 0 | [-180, 180] |
pitch | The vertical tilt of the viewing direction relative to the XOY plane. Positive values tilt upward (above the XOY plane); negative values tilt downward (below the XOY plane). Unit: degrees. | 0 | [-90, 90] |
distance | The maximum viewing distance. A larger value produces a frustum with wider coverage. | 100 | (0, +inf) |
horizontalFov | The horizontal field of view (FOV). Unit: degrees. | 90 | (0, 180) |
verticalFov | The vertical FOV. Unit: degrees. | 60 | (0, 180) |
depthMapSize | The depth map resolution used to compute the frustum shape. A larger value produces a finer frustum. | 128 | (0, 2048] |
Description
ST_ComputeFrustum computes a 3D view frustum from the given viewpoint parameters. The returned meshgeom object represents the visible volume from that viewpoint and is composed of 3D triangles.
The following diagrams illustrate the computed frustum shape.
View frustum (top view)

View frustum (side view)

Examples
The following example computes a view frustum at a specific viewpoint and uses ST_NumPatches to count the 3D triangles in the result.
SELECT ST_NumPatches(ST_ComputeFrustum('{"x" : 2938, "y" : 750, "z" : 90, "h" : 1.8, "azimuth" : 90, "pitch" : -35, "horizontalFov" : 90, "verticalFov" : 60, "distance" : 600, "depthMapSize" : 128}'));
--------
32766The result 32766 is the number of 3D triangles that make up the computed view frustum.