def addFlickeringLight(model=MODEL, scene=viz.MainScene):
    global flickerOff
    fanLight = model.getChild("Sphere001")
    if flickerOff:
        vizfx.setAmbientColor(viz.BLACK)
        fanLight.emissive(viz.BLACK)
    else:
        vizfx.setAmbientColor(viz.SLATE)
        fanLight.emissive(viz.WHITE)
    flickerOff = not flickerOff
    flickering = fanLight.playsound("Audio/Apartment Scene/light_flicker.wav")
    flickering.play()
def addFlickeringLight(model=MODEL, scene=viz.MainScene):
    global flickerOff
    fanLight = model.getChild("Sphere001")
    if flickerOff:
        vizfx.setAmbientColor(viz.BLACK)
        fanLight.emissive(viz.BLACK)
    else:
        vizfx.setAmbientColor(viz.SLATE)
        fanLight.emissive(viz.WHITE)
    flickerOff = not flickerOff
    flickering = fanLight.playsound("Audio/Apartment Scene/light_flicker.wav")
    flickering.play()


if __name__ == "__main__":
    vhilGo(rift=False)
    SCENE = viz.Scene1
    MODEL = "Apartment_Final.OSGB"
    apartment = vizfx.addChild(MODEL, scene=SCENE)
    control.control(viz.MainView)
    apartment.setPosition([0, 0.17, 0])
    apartment.setScale([30, 30, 30])
    vizfx.setAmbientColor([0.1, 0.1, 0.1])
    viz.MainView.setPosition([-2.2, 1.6, -1.2])
    viz.MainView.setEuler([90, 0, 0])
    viz.MainView.setEuler([90, 0, 0])
    viz.MainView.getHeadLight().disable()
    rotateFan(model=apartment, scene=SCENE)
    addOutsideLighting(apartment, SCENE)
    vizact.ontimer2(0.1, 10, addFlickeringLight, apartment, SCENE)