Jump to content

Overlay dynamic texture over canvas


Recommended Posts


I'm preparing some kind of proof of concept demo using scene exporter from blender.

Loading the scene works fine using such code:


    if (BABYLON.Engine.isSupported()) {
        var canvas = document.getElementById("renderCanvas");
        var engine = new BABYLON.Engine(canvas, true);

        BABYLON.SceneLoader.Load("", "scene.babylon", engine, function (newScene) {
            // Wait for textures and shaders to be ready
            newScene.executeWhenReady(function () {
                // Attach camera to canvas inputs

                // Once the scene is loaded, just register a render loop to render it
                engine.runRenderLoop(function() {
                window.addEventListener("keydown", function (evt) {
                        switch (evt.keyCode) {
                            case 82:  
                                //do something to display overlay with texture
                            default: break;

               window.addEventListener("resize", function () {


        }, function (progress) {
            // To do: give progress feedback to user

It works fine, but now I need to load load image file when button is pressed and be able to show/hide it over on the top of rendered scene.

What will be the best solution?


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...