-- constants
local SPEED = settings.speed * math.pi * 2.0 -- radians per second
local SATURATE = Color.new(1.5, 1)

-- options
ym.setCullMode( false )
ym.setGlobalLight( Vector3.new( 0, -1, 0 ) )

-- setup
local mesh = Mesh.new({
    vertices = {
        -- side face 1
        0.0,  0.0,   0.0,
        1.6,  0.433,-0.25,
        1.6, -0.433,-0.25,
        -- side face 2
        0.0,  0.0,   0.0,
        1.6, -0.433,-0.25,
        1.6,  0.0,   0.5,
        -- side face 3
        0.0,  0.0,   0.0,
        1.6,  0.0,   0.5,
        1.6,  0.433,-0.25,
        -- bottom face
        1.6,  0.0,   0.5,
        1.6, -0.433,-0.25,
        1.6,  0.433,-0.25,
    },
    
    colors = {
        -- side faces
        settings.color1, settings.color2, settings.color2,
        settings.color1, settings.color2, settings.color2,
        settings.color1, settings.color2, settings.color2,
        -- bottom face
        settings.color2, settings.color2, settings.color2,
    }
})
local prism = Node.new()
prism:addMesh( mesh )
prism.scale = Vector3.new( settings.scale )
prism.rotation = Rotation.euler( math.pi / 4, -math.pi / 8, 0 )
prism.color = SATURATE
prism:spawn()

-- events
function step(deltaTime)
    -- rotate prism about its local X axis relative to frame time
    prism.rotation:rotateX( deltaTime * SPEED )

    -- update prism position based on mouse position
    prism.position = Vector3.new( ym.getCursorPosition(), 0 )
end
