Simulate documentation

Creating a scene

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Creating a scene

This section describes how to create and save a simple scene. The code in this section is reflected in examples/basic/create_and_save.py.

Start by creating an empty scene:

import simulate as sm
scene = sm.Scene()

Then, add a light source and a box to the scene:

scene += sm.LightSun()
scene += sm.Box()

A full list of available built-in objects can be found here.

You can save the scene using the glTF 2.0 specification, allowing it to be shared across multiple platforms:

scene.save("output/test.gltf")

Finally, call show() to display the scene:

scene.show()

Loading scenes

Scenes can also be loaded from the hub:

scene = sm.Scene.create_from("simulate-tests/Box/glTF-Embedded/Box.gltf")

or, they can be treated as individual assets, and added to the scene:

scene += sm.Asset.create_from("simulate-tests/Box/glTF-Embedded/Box.gltf")