Garry's Mod Wiki

game.Get3DSkyboxInfo

  table game.Get3DSkyboxInfo()

Recently Added

This was recently added in version (2026.02.13). It might only be available on the Dev Branch right now.

Description

Returns table with "origin" and "scale" keys.

Returns

1 sequential table<Sky3DParams structure> sky3dparams
Returns nil if no 3d skybox.
If the player hasn't been created yet, this will not work.

Example

Shows hit position of ray on world and 3d skybox.

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 sky3dparams = game.Get3DSkyboxInfo() local skyboxOrigin = sky3dparams.origin local skyboxScale = sky3dparams.scale local dir = client:EyeAngles():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 )
Output: