[Lite] Creating text renderable on the fly

So I cannot make the text renderable to work when it’s added on the fly. It seems that after the scene was registered, you cannot add more text renderables.

This always adds a text:

addTextRenderable(scene, your_text_renderable)
registerScene(scene)

And this will never add it:

registerScene(scene)
addTextRenderable(scene, your_text_renderable)

Adding meshes after the scene was registered works, but not the text. Is this intentional? If yes, then how can I add a text on the fly?

The TextRenderable is the renderable, so


        // Rebuild the renderable groups so the new
        // text renderable becomes part of the render path.
        await rebuildSceneRenderables(scene);
    });

This doesn’t have any affect at all. When inspecting a scene after adding text renderables, I noticed that scene._renderables is not changing, no new text renderable is added. I’m quite confused if this is a bug, or intentional.

Yes, the first answer was not good :slight_smile:
Here is the working example with privates

Okay, this somehow proves my point. But I guess to be able to add a new text renderable on the fly I have to re-register the scene. I was just surprised I don’t need the same thing when adding new meshes.

That makes sense. Text renderables can behave differently from meshes, so needing to re-register the scene can be an unexpected detail.

This is not intentional; it’s a gap in the current runtime scene-mutation support. addTextRenderable() currently queues work that is processed by registerScene(). Once the scene is registered, calling registerScene() again is a no-op. Meshes already have a dedicated incremental runtime-build path, but 3D text renderables do not yet.

As a temporary workaround, unregister and re-register the scene:

unregisterScene(scene);
addTextRenderable(scene, textRenderable);
await registerScene(scene);

Use registerSceneWithShadowSupport() instead if that is how the scene was originally registered.

If you only need to change the contents of existing text, add the renderable before registration and call updateTextData() at runtime; those changes are uploaded automatically.

Thanks for reporting this—we should treat runtime addition of a new TextRenderable as a bug to fix.