spotLight()
Purpose
Create a spotlight light source in 3D space
Description
Creates a spotlight source in the specified position of the specified colour, brightness and with the specified spread angle
Syntax
handle = spotLight( position, direction, colour, brightness, spread )
Arguments
handle handle of the light source
position A position vector in 3 dimensional space { x, y, z } where the light source is located
direction A vector to describe the direction in which the light is pointing
colour colour name or RGB values { red, green, blue, opacity } between 0 and 1
brightness A value to indicate the brightness of the light source
spread angle (in degrees) of the spread of the light
Example
setCamera( { 0, 6, 10 }, { 0, 0, 0 } )
spread = 50
light = spotLight( { 0, 4, 0 }, { 0, -1, 0 }, white, 100, spread )
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 )
spread += c.ly
spread = clamp( spread, 0, 100 )
setLightSpread( light, spread )
rotateObject( obj[1], { 0, 1, 0 }, 1.0 )
drawObjects()
printAt( 0, 0, "Use Joy-Con left control stick adjust spread: " + spread )
update()
repeat
Associated Commands
pointLight(), pointShadowLight(), removeLight(), setAmbientLight(), setLightBrightness(), setLightColour(), setLightDir(), setLightPos(), setLightSpread(), worldLight(), worldShadowLight()