setLightDir()
Purpose
Set the direction of a light source
Description
Set the direction of a light source to the specified value
Syntax
setLightDir( light, direction )
Arguments
light handle of the light source
direction direction the light source is pointing { x, y, z }
Example
setCamera( { 0, 6, 10 }, { 0, 0, 0 } )
setAmbientLight( { 0.1, 0.1, 0.1 } )
lightDir = { 0, -1, -1 }
light = spotLight( { 0, 4, 4 }, lightDir, white, 50, 2 )
obj = [
placeObject( cube, { 0, 0, 0 }, { 4, 0.1, 4 } ),
placeObject( cube, { 0, 1.1, 0 }, { 1, 1, 1 } )
]
setObjectMaterial( obj[0], white, 0, 1 )
setObjectMaterial( obj[1], cyan, 0, 1 )
loop
c = controls( 0 )
lightDir += { c.lx, c.ry, -c.ly } * 0.1
setLightDir( light, lightDir )
rotateObject( obj[1], { 0, 1, 0 }, 1.0 )
drawObjects()
printAt( 0, 0, "Use Joy-Con control sticks to adjust light direction" )
printAt( 0, 2, "Left Control stick left and right adjusts the X direction: " + lightDir.x )
printAt( 0, 3, "Left Control stick up and down adjusts the Z direction: " + lightDir.z )
printAt( 0, 4, "Right Control stick up and down adjusts the Y direction: " + lightDir.y )
update()
repeat
Associated Commands
pointLight(), pointShadowLight(), removeLight(), setAmbientLight(), setLightBrightness(), setLightColour(), setLightPos(), setLightSpread(), spotLight(), worldLight(), worldShadowLight()