Extension: omni.kit.widget.viewport-107.0.6 |
Documentation Generated: Nov 07, 2024 |
Overview
Introduction
A low level implementation of an omni.ui.Widget
that displays rendered output.
The omni.kit.widget.viewport.ViewportWidget
does not include any additional features (such as menu-items or
manipulators). It is used by omni.kit.viewport.window.ViewportWindow
to provide a higher level, default Viewport
experience in Kit based apps.
How to create a new ViewportWidget
Python
Import
omni.ui
so theViewportWidget
can be created inside anomni.ui.Window
import omni.ui as ui
Import the class from the package:
from omni.kit.widget.viewport import ViewportWidget
Choose the resolution and camera this instance will start rendering with.
resolution=(512, 512)
camera_path="/OmniverseKit_Persp"
Create an empty
omni.ui.Window
and instantiate a newViewportWidget
in itsomni.ui.Frame
window = ui.Window("Demo ViewportWidget", width=resolution[0], height=resolution[1])
with window.frame:
vp_widget = ViewportWidget(camera_path=camera_path, resolution=resolution)
Get the active ViewportAPI attached to the
ViewportWidget
and inspect some properties.
viewport_api = vp_widget.viewport_api
usd_context = viewport_api.usd_context
usd_context_name = viewport_api.usd_context_name
usd_stage = viewport_api.stage
camera_path = viewport_api.camera_path
resolution = viewport_api.resolution