GetRange

This function gets a camera's near and far ranges.

Syntax

Returns

Returns the near and far camera range in the X and Y components of the returned Vec2, respectively.

Example

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:Move(0,0,-3)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

model = Model:Box()
model:SetColor(0.0,0.0,1.0)

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

model:Turn(0,Time:GetSpeed(),0)

local range = camera:GetRange()
local deltarange = ((window:KeyDown(Key.Up) and 1 or 0) - (window:KeyDown(Key.Down)and 1 or 0)) * Time:GetSpeed() * 0.01
range.x = range.x + deltarange
range.x = Math:Clamp(range.x,0.1,10)
camera:SetRange(range.x,range.y)

Time:Update()
world:Update()
world:Render()

context:SetBlendMode(Blend.Alpha)
context:DrawText("Range: "..camera:GetRange():ToString(),2,2)

context:Sync()
end