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

  1. Import omni.ui so the ViewportWidget can be created inside an omni.ui.Window

import omni.ui as ui
  1. Import the class from the package:

from omni.kit.widget.viewport import ViewportWidget
  1. Choose the resolution and camera this instance will start rendering with.

resolution=(512, 512)
camera_path="/OmniverseKit_Persp"
  1. Create an empty omni.ui.Window and instantiate a new ViewportWidget in its omni.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)
  1. 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

Further reading

Viewport Documentation

Tutorials