[SOLVED] Light is black unless position/rotation in app.update

Hello, was wondering if anyone knows the best setup for light outside the editor. I have a light that I’m adding/creating on initialization and then on app.on(“update”) I have the light’s rotateLocal() and setLocalPosition() being set. Originally I figured it isn’t necessary to have it’s position/rotation constantly set on the game logic loop so I took it out and put it after the light declaration/after app.start but this seemed to create a giant black circle where the light should be shining. I thought there might be a specific function that the position/rotation has to be called after so I tried a setTimeout of 10 seconds outside the update loop but same thing happened. Do all light position/rotation have to be set on the update loop or is there a better way to do this? Thanks!

Do you have a small project that you can share to show the repro?

There are too many moving components to show the project but essentially the code for the lights consists of

    // Create an spot light
    light = new Entity();
    light.addComponent("light", {
        type: "spot",
        color: new Color(1, 1, 1),
        outerConeAngle: 60,
        innerConeAngle: 40,
        range: 100,
        intensity: 1,
        castShadows: true,
        shadowBias: 0.005,
        normalOffsetBias: 0.01,
        shadowResolution: 2048

    const cone = new Entity();

    cone.addComponent("model", {
        type: "cone"

    cone.model.material = white;

For the light and

app.on("update", (dt) => {
            light.rotateLocal(90, 30, 50);
            light.setLocalPosition(val, val, val);

for the update loop. If I take that rotate/setposition code out of the update loop it’s black on the ground where the light should be hitting

Silly question: Have you added the light entity to the scene hierarchy?

ah, yes I have a


right after declaring light

OK so I actually had light.lookAt(center) as part of that block and THAT method specifically was causing this issue for some reason. With only rotate/setposition it works fine :sweat_smile:

1 Like

Lol, that happens sometimes

1 Like