Garry's Mod Wiki

Revision Difference

game.Get3DSkyboxInfo#566240

<function name="Get3DSkyboxInfo" parent="game" type="libraryfunc">⤶ <description>Returns table with `"origin"` and `"scale"` keys.</description>⤶ <added>2026.02.13</added>⤶ <realm>Shared</realm>⤶ <rets>⤶ <ret name="sky3dparams" type="table<Structures/Sky3DParams>">Returns `nil` if no 3d skybox.</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>⤶ Visualizes the wind's speed and direction with a line in the center of the screen.⤶ </description>⤶ <code>⤶ local color_green = Color( 0, 255, 0 )⤶ ⤶ hook.Add( "PostDrawTranslucentRenderables", "MySuper3DHook", function()⤶ local client = LocalPlayer()⤶ if !IsValid(client) then return end -- remove it⤶ ⤶ local eyepos = client:EyePos()⤶ local forward = client:EyeAngles():Forward()⤶ ⤶ local sky3dparams = game.Get3DSkyboxInfo()⤶ local skyboxOrigin = sky3dparams.origin⤶ local skyboxScale = sky3dparams.scale⤶ ⤶ local dir = forward * 100000000⤶ ⤶ local tr = util.TraceLine({⤶ start = eyepos;⤶ endpos = eyepos + dir;⤶ filter = {client:GetVehicle(), client:GetViewEntity() or client};⤶ mask = MASK_BLOCKLOS_AND_NPCS;⤶ })⤶ ⤶ local hitPos = tr.HitPos⤶ local hitSky = tr.HitSky⤶ ⤶ if hitSky and sky3dparams and GetConVar("r_3dsky"):GetBool() == true then⤶ local eye_sky = skyboxOrigin + eyepos / skyboxScale -- transform eyepos to 3d skybox space⤶ ⤶ local tr = util.TraceLine({⤶ start = eye_sky;⤶ endpos = eye_sky + dir;⤶ mask = MASK_BLOCKLOS_AND_NPCS;⤶ })⤶ ⤶ hitPos = ( tr.HitPos - skyboxOrigin ) * skyboxScale -- transform hitpos from 3d skybox space to world space⤶ end⤶ ⤶ render.SetColorMaterial()⤶ render.DrawSphere(hitPos, 64, 16, 16, color_green)⤶ end )⤶ </code>⤶ ⤶ </example>⤶