This addon extends the glTF 2.0 exporter to support the MOZ_hubs_components
and MOZ_lightmap
extensions allowing you to add behavior to glTF assets for Mozilla Hubs.
Find the latest release and download the add-on zip file.
In Blender: Edit > Preferences > Add-ons
Click install and select the zip file of the latest release.
Ensure the hubs component exporter is checked and enabled.
To add components, go to the "Hubs" section of the properties panel for the thing you want to add a component to. Currently adding components is supported on Scenes, Objects, Bones, and Materials.
Click "Add Component" and select the component you wish to add from the list. Only components appropriate for the object type you are currently editing and have not already been added will be shown.
To use a lightmap, create a MOZ_lightmap
node from the Add > Hubs
menu and hook up a image texture to the Lightmap
input. Use a UV Map
node to control what UV set should be used for the lightmap, as you would any other texture in Blender.
Note that for use in Hubs, you currently MUST use the second UV set, as ThreeJS is currently hardcoded to use that for lightmaps. This will likely be fixed in the future so the exporter does not enforce this.
This addon works in conjunction with the official glTF exporter, so exporting is done through it. Select "File > Export > glTF 2.0" and then ensure "Hubs Components" is enabled under "Extensions".
The easiest way to use your scene file is through the Spoke project creation page and selecting Import From Blender:
This will bring up the Publish Scene From Blender dialog where you can upload your GLB file and a thumbnail picture for your scene:
It is also possible to use the GLB file to replace the scene for an existing Hubs room directly by going to Room Settings > Change Scene > Custom Scene and entering the URL of the GLB file. This assumes the file has been already uploaded to an online storage provider.
To enable code completion for the Blender Python API you can install the Fake Blender Python API module collection. You can download the modules using the setup.sh
script from the repository root or using pip.
It might be useful while developing to be able to load the addon directly from the checkout folder without needing to install it. You can do it in two ways:
You can override the Blender user scripts directory from the console to point to the addon repo directory.
MacOS
BLENDER_USER_SCRIPTS=full_path_to_/hubs-blender-exporter /Applications/Blender.app/Contents/MacOS/Blender
Linux
BLENDER_USER_SCRIPTS=full_path_to_/hubs-blender-exporter blender
You can create a symbolic link pointing to full_path_to_/hubs-blender-exporter/addons/io_hubs_addon
in your current Python scripts directory in Blender. This way you will also load any other addons that you have in that directory.
MacOS and Linux
ln -s full_path_to/hubs-blender-exporter/addons/io_hubs_addon full_path_to/blender_user_scrips_dir
You can set or see the current Blender user scripts in the Preferences -> File Paths -> Scripts
You can debug the addon code with PyCharm or VSCode:
- Debug with PyCharm NOTE: If you are using Blender 2.80+, you need the updated debugger script
- Debug with VSCode
To run the tests locally, your system should have a blender executable in the path that launches the desired version of Blender.
The latest version of Yarn should also be installed.
Then, in the tests folder of this repository, run yarn install, followed by yarn run test.