Can I programmatically adjust the lighting?


#1

I’m brand new to HiFi, so forgive me if this is a dumb question.

I couldn’t find in the documentation anywhere that gives an example of adjusting the properties on a light at runtime.

Is that possible?


#2

Definitely, lights are just entities and all the properties you can adjust with Entities.editEntity can be manipulated.

You would want to do the edits in an update loop with Script.update.connect(function(){//function to run on each update})or Script.setInterval(function, msToNextInterval)

Grab the ID of the entity and in the console you can do something like:
var props = Entities.getEntityProperties(id);
JSON.stringify(props);
or something like
for (var key in props) { print ( "key: " + key + "\n " + JSON.stringify(props[key]) )}

Then you can see what you have access to edit in each loop


#3

Ah brilliant! Thanks so much for the reply and easy to understand explanation. :slight_smile: