432

Writing program scripts with JavaScript
Using a color selector

  • Use the color selector to change the lamp bulb color
    DEF LightSwitch TouchSensor { }
    DEF LampLight SpotLight { . . . }
    DEF BulbMaterial Material { . . . }
    
    DEF Toggle Script { . . . }
    DEF ColorSelector Script { . . . }
    
    ROUTE LightSwitch.isActive TO Toggle.set_active
    ROUTE Toggle.on_changed    TO LampLight.set_on
    ROUTE Toggle.on_changed    TO ColorSelector.set_selection
    ROUTE ColorSelector.color_changed TO BulbMaterial.set_emissiveColor