worldShadowLight()

Purpose

Create a world light source that casts a shadow

Description

Creates a world light source in the specified direction and with the specified colour and brightness

Syntax

handle = worldShadowLight( centre, direction, colour, brightness, range, resolution )

Arguments

centre centre of the range for shadows

direction direction the light source is pointing { x, y, z }

colour colour name or RGB values { red, green, blue, opacity } between 0 and 1

brightness brightness of the light source (0 - 100)

range range of shadows

resolution resolution of shadows (higher is smoother)

handle handle of the light source

Example

obj1 = placeObject( cube, { -3, 0, 0 }, { 1, 1, 1 } )
obj2 = placeObject( cube, { 3, 0, 0 }, { 1, 1, 1 } )
setObjectMaterial( obj1, white, 0, 0.05 ) // white, smooth, shiny
setobjectmaterial( obj2, white, 0, 0.05 ) // white, smooth, shiny
floor = placeObject( cube, { 0, -2, 0 }, { 10, 0.05, 10 } )
setObjectMaterial( floor, grey, 0, 1 ) // grey, smooth, not shiny
setCamera( { 1, 0.5, 5 }, { 0, 0, 0 } ) // back a bit and off centre, facing world centre
worldShadowLight( { 0, 0, 0 }, { -1, -0.5, -0.5 }, white, 1, 10, 512 )

loop
    rotateObject( obj1, { 1, 1, 1 }, 1 ) // in all directions by 1 degree
    rotateObject( obj2, { 1, 1, 1 }, -1 ) // in all directions by -1 degree
    drawObjects()
    update()
repeat

Associated Commands

pointLight(), pointShadowLight(), removeLight(), setAmbientLight(), setLightBrightness(), setLightColour(), setLightDir(), setLightPos(), setLightSpread(), spotLight(), worldLight()