Sun (scene.sun) position relative to the craft 3D viewport?

Hi.

Does anyone know where the sun is positioned relative to the craft 3D viewport? I’m learning how to adjust the lighting in my scene. Based on the reflections I see on the objects I position at 0,0,0 it seems the scene.sun is projecting from a position in the middle, superior, and behind the 3D viewport (i.e. x=0, y = + value, z = - value in 3D world terms). I see that I can then rotate the sunlight coming from the sun (e.g. scene.sun.eulerAngles = vec3(45,0,0)) although for some reason it doesn’t look like I can rotate the sun along the y axis (the lighting and reflection don’t see to change when I change the y component of the eulerAngle).

Thanks :slight_smile:

@SugarRay Try this. If you change the yy slider, nothing seems to happen. If you change either the xx or zz slider from 0, then the reflection will change when you move the yy slider.

viewer.mode=STANDARD

function setup()
    parameter.integer("xx",-180,180,0)
    parameter.integer("yy",-180,180,0)
    parameter.integer("zz",-180,180,0)
    assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
    scene = craft.scene()
    v=scene.camera:add(OrbitViewer, vec3(0,0,0), 50, 0, 300)
    sphere1=scene:entity()
    sphere1.position=vec3(0,0,0)
    sphere1.model = craft.model.icosphere(5,3)
    sphere1.material = craft.material(asset.builtin.Materials.Specular)
    sphere1.material.diffuse=color(255,0,0)
end

function draw()
    update(DeltaTime)
    scene:draw()	    
end

function update(dt)
    scene:update(dt)
    scene.sun.rotation=quat.eulerAngles(xx,yy,zz)
end

Thanks, @dave1707, very nice example! I do see that once x or z changes then you can rotate the sunlight using the y axis. Not sure I understand “y” :slight_smile: but that helps me plan the sunlight in my seen better.