Garry's Mod Wiki

cam.Start3D

  cam.Start3D( Vector pos = <current view pos>, Angle angles = <current view angles>, number fov = <current view FOV>, number x = <current view X>, number y = <<current view Y>, number w = <current view width>, number h = <current view height>, number zNear = <current view zNear>, number zFar = <current view zFar> )

Description

Sets up a new 3D rendering context. Must be finished by cam.End3D.

For more advanced settings such as an orthographic view, use cam.Start instead, which this is an alias of basically.

This is a rendering hook which provides a 3d rendering context.
Negative x/y values won't work.

Issue Tracker: 1995
This will not update current view properties.

Issue Tracker: 2682

Arguments

1 Vector pos = <current view pos>
Render cam position.
2 Angle angles = <current view angles>
Render cam angles.
3 number fov = <current view FOV>
Field of view.
4 number x = <current view X>
X coordinate of where to start the new view port.
5 number y = <<current view Y>
Y coordinate of where to start the new view port.
6 number w = <current view width>
Width of the new viewport.
7 number h = <current view height>
Height of the new viewport.
8 number zNear = <current view zNear>
Distance to near clipping plane.
Both zNear and zFar need a value before any of them work.

zNear also requires a value higher than 0.

9 number zFar = <current view zFar>
Distance to far clipping plane.

Example

Set up a 3D rendering environment in a 2D rendering hook to render models on HUD.

hook.Add( "HUDPaint", "3d_camera_example", function() cam.Start3D() for id, ply in ipairs( player.GetAll() ) do ply:DrawModel() end cam.End3D() end )
Output: All players can be seen through walls.