Enables or disables perspective for lines in 3D sketches.
In WebGL mode, lines can be drawn with a thinner stroke when they’re further from the camera. Doing so gives them a more realistic appearance.
By default, lines are drawn differently based on the type of perspective being used:
perspective()
andfrustum()
simulate a realistic perspective. In these modes, stroke weight is affected by the line’s distance from the camera. Doing so results in a more natural appearance.perspective()
is the default mode for 3D sketches.ortho()
doesn’t simulate a realistic perspective. In this mode, stroke weights are consistent regardless of the line’s distance from the camera. Doing so results in a more predictable and consistent appearance.
linePerspective()
can override the default line drawing mode.
The parameter, enable
, is optional. It’s a Boolean
value that sets the way lines are drawn. If true
is passed, as in linePerspective(true)
, then lines will appear thinner when they are further from the camera. If false
is passed, as in linePerspective(false)
, then lines will have consistent stroke weights regardless of their distance from the camera. By default, linePerspective()
is enabled.
Calling linePerspective()
without passing an argument returns true
if it's enabled and false
if not.
Note: linePerspective()
can only be used in WebGL mode.
Examples
Syntax
linePerspective(enable)
linePerspective()
Parameters
whether to enable line perspective.