You can now easily search and import models from Sketchfab inside Castle Game Engine editor! This feature was fun to make and I’m sure it will be fun to use too 🙂
How to use
- Open any project.
Use the menu item “Data -> Import from Sketchfab…”.
Search for any query, like
tree… Your imagination is your only limit, Sketchfab has an incredible number of models. There’s a checkbox to limit the results to contain “Only Animated” models.
Pick the model you want to download. You can view the models using a list (with license, description, face count) or using a grid view (with thumbnail). You can also open the corresponding model in the Sketchfab website viewer.
Press “Download” to download the glTF version of the model from Sketchfab.
Make sure to fill the “API token” field first — find your token on the Sketchfab “Password & API” page. You need a (completely free) Sketchfab account for this.
The downloaded model is placed inside the data subdirectory of your project, in a file like
data/sketchfab/<name>-<id>/scene.gltf. There are accompanying files with textures, license, we also leave the downloaded zip.
If you have some design open, with some viewport selected, then you can even “Download and Add To Viewport”. This is just a shortcut to download and drag-and-drop the glTF model into the viewport, instantiating
TCastleScenepointing to the proper glTF model.
Along with this, I have also improved the automatic
Name assigned to dragged-and-dropped components. It now reflects the model URL. E.g. drag-and-dropping the
knight.gltf will now create
SceneKnight1. There is a smart rule to also generate useful names for models from Sketchfab-imported directories.
The models’ licenses are clearly specified (in the search dialog and in downloaded
license.txt files). They use various versions of the Creative Commons licenses or Public Domain.
Following Sketchfab docs: Sketchfab provides a library of over 1 million free models, available under Creative Commons licenses. Most models allow commercial use. Read the model licensing for more details.
Note: Be wary of using Non-Commercial or Non-Derivatives variants of the Creative Commons licenses. They are incompatible with general open-source definition, which has been stated explicitly e.g. by Debian (DFSG) and FSF. See Creative Commons at Wikipedia for more information. So works including these models cannot be distributed as freely as most open-source software. Other CC variants are cool.
Sketchfab export to glTF is not perfect.
TODO: New material components will allow you to easily override faulty materials.
Sometimes the exported glTF says to use blending when it actually should not. For example this chunky knight has rendering issues, in Castle Game Engine and other glTF viewers, due to using blending when it should not.
This likely follows Sketchfab docs saying that they don’t export Refraction, Dithered, and Additive transparency (will be converted to Blending).
The solution is just to disable blending in CGE for these models, setting
A minority of Sketchfab models use a “specular glossiness” PBR workflow through a deprecated (by Khronos) KHR_materials_pbrSpecularGlossiness. We support it in CGE only partially — some models may look dark or too contrasting, like this knight.
Possibly Sketchfab can switch to the new approach in the future. In the meantime you can ask Sketchfab authors to use metallic-roughness PBR workflow.
Some models expose just one big animation like
Take 001, which is an artifact how some 3D software exports them.
You can follow examples/animations/split_long_animation to split such long animation into multiple “sub animations” in CGE. I have actually just upgraded this demo, to show a Halloween Pumpkin Lantern Knight model from Sketchfab created by outcast945.