if car.index ~= 0 then
	return nil
end

local LED =  {}
local LEDCollar =  {}
local LEDRPMlut =  ac.DataLUT11.load("assets/".."ledrpm.lut")
local Yellow = vec3(60,60,0)
local Green = vec3(0,60,0)
local Red = vec3(60,0,0)
local INITIALIZED = false

local function initialize()

    for i = 0,9 do
        LED[i] = ac.findNodes("carRoot:" .. car.index):findMeshes("RPM_LED_"..i):ensureUniqueMaterials()
        LEDCollar[i] = i < 4 and Green or i < 7 and Yellow or Red
    end
    INITIALIZED = true
end

function update(dt)

    if not INITIALIZED then initialize() end

	for i = 0,9 do
        LED[i]:setMaterialProperty("ksEmissive",vec3(0,0,0))
        if LEDRPMlut:get(i) < car.rpm then
            LED[i]:setMaterialProperty("ksEmissive", LEDCollar[i])
        end
    end

end