SpatialEngine
SpatialEngine renders, queries, and edits spatial data. Start with a native engine and Python, or run the engine inside your browser with TypeScript.
Install
Get the native engine binary and its matching Python wheel. Use Python 3.10 or newer. Install the supplied wheel with its gRPC dependency:
python -m pip install "./spatialengine-<version>-py3-none-any.whl[grpc]"Replace <version> with the version on your wheel. SpatialStudio installs the matching SDK
and starts the engine for your app.
Start the engine
Start the native engine in a separate terminal:
SpatialEngineThen connect from Python:
import spatialengine
with spatialengine.connect() as client:
print(client.print(message="Connected to SpatialEngine"))The default gRPC address is localhost:50051. connect() reads FDK_HOST and FDK_PORT
and waits up to 120 seconds for startup. Studio supplies these values. Outside Studio, read
the engine’s startup output and set them if the engine uses another address.
To time render passes on the GPU for performance diagnostics, start the engine with
SpatialEngine --gpu-profiling. GPU timing needs instrumentation that can only be installed when
the engine starts, so it cannot be switched on later. Without the option the engine creates no
timing resources and does no timing work. Browser builds do not include GPU timing, so the
TypeScript package has no such option.
Open a viewport
Open the engine’s web portal at http://localhost:8080/streaming/viewport to see the scene.
Use the portal address printed at startup if it differs from the default.
To display the viewport inside your app, follow Embed a viewport.
Draw a shape
With the viewport open, create a cube and frame it:
import spatialengine
from spatialengine.types.scene import Cube, Geometry, Shape, ShapeAppearance
with spatialengine.connect() as client:
cube = client.scene.spawn()
client.scene.shape.set(
node=cube,
shape=Shape(
geometry=Geometry.Cube(Cube(half_extents=1.0)),
appearance=ShapeAppearance(wireframe=False),
),
)
client.viewport.camera.zoom_extents()Try the browser demos to explore more shapes, rendering settings, and streamed data. For another language, generate a gRPC client.