Skip to content

SalatielSauer/WEBGE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WEBGE: Web-based interface for Blender/UPBGE 2.79

webge_opt.mp4

Setup

  1. Download the WEBGE_30-04-2026.zip zip from the releases page.
  2. Install it in Blender from User Preferences -> Install Add-on from File.
  3. Enable the add-on and click "Install CEF" in the add-on panel to download the dependency.
  4. Click "Embed Runtime for Standalone Player" so the webge.py module is available inside your .blend file.

You are all set.

Optionally, to create a quick test template, select an object and go to Templates -> WEBGE Basic Setup in the text editor menu. This creates a basic WEBGE setup that you can test immediately by pressing P to start the game.

When you click "WEBGE Basic Setup", the add-on automatically adds an Always sensor connected to a Python controller on the selected object.

Common Issues

  • I do not see the interface when the game starts:

    Because WEBGE depends on cefpython3, it is only available for UPBGE 2.79 and vanilla Blender 2.79.

    Make sure webge.py is embedded in your .blend file by using the add-on menu in User Preferences -> Embed Runtime for Standalone Player. Otherwise, WEBGE will work when you press P, but not when you launch the standalone player.

  • I see the interface, but I cannot see the game behind it (transparency):

    Make sure your element CSS uses a transparent color. Make sure your scene is lit; otherwise, you will not see anything behind the web interface, duh :P

  • I do not want to include HTML as text inside Python. I want a separate file:

    This is fully supported with webge.load("file.html"). You can also reference the name of a text block that only exists inside Blender, and it will work. External files are resolved relative to the directory where your .blend file is saved.

  • It does not work in newer UPBGE versions:

    Newer UPBGE versions use newer Python versions. WEBGE depends on cefpython3, whose latest version only supports Python 3.9, so WEBGE is not currently available for newer UPBGE versions.

WEBGE API

import webge

webge.init()
webge.load("https://www.google.com")
webge.load("ui/menu.html")
webge.load("internal://anyfile.html")
webge.execute_js("alert('running javascript!')")
webge.call_js("someJavaScriptFunction", "hello", 123, {"testing": True})
webge.open_devtools()
webge.close_devtools()
webge.register_py("somePythonFunction", lambda name, data: "Hello " + name)
webge.shutdown()

init() can be called without a page URL. Relative paths passed to init() or load() are resolved from the current .blend file directory.

call_js(function_name, *args) is the preferred API for logic brick Python controllers. Arguments are JSON-encoded before they are passed to JavaScript, so strings, numbers, booleans, lists, and dictionaries can be passed without manually building JavaScript source.

JavaScript can call registered Python functions through the injected bridge:

WEBGE.py.call("somePythonFunction", "The Unnamed",).then(function (result) {
  console.log("Python returned:", result);
}).catch(function (error) {
  console.error(error.message);
});

Register only explicit callable names with register_py(function_name, function). The bridge intentionally does not evaluate arbitrary Python source from the UI. Use unregister_py(function_name) or clear_py_functions() to remove exposed functions.

DevTools

Open Chromium DevTools from any UPBGE Python controller after init():

import webge

webge.open_devtools()

Close it with:

webge.close_devtools()

The overlay closes any open DevTools window when init() starts or replaces a player overlay. shutdown() closes DevTools, closes the overlay browser, and then shuts CEF down.


WEBGE was put together by Salatiel S., but it only exists thanks to cefpython:

cztomczak/cefpython

upbge.org

blender.org

Discord: @Salatiel#5274

About

Web-based interface API for Blender Game Engine & UPBGE

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages