newton.viewer.Layer#

class newton.viewer.Layer(layer_id)[source]#

Bases: object

Container holding per-model viewer state for one layer.

A layer represents the rendering output of a single model/solver inside a viewer. The layer owns the model reference, all shape-instance batches, contact/joint/COM caches, world offsets, visibility toggles, and any other state that is normally bound to one model.

Each layer carries a visible flag, a per-layer rendering xform (applied to every drawn position/orientation in the layer; defaults to the identity transform so layers overlay), and a stable layer_id string used as a prefix for every backend object name emitted while the layer is active. The prefix prevents name collisions when more than one layer logs into the same backend.

Layers are managed by ViewerBase. Use ViewerBase.activate() to switch which layer receives subsequent set_model / log_state / log_* calls; use ViewerBase.set_layer_visible() to toggle visibility and ViewerBase.set_layer_transform() to position layers independently (e.g. overlay vs. side-by-side vs. rotated comparison).

__init__(layer_id)#

Initialize an empty layer.

Parameters:

layer_id (str) – Stable identifier used as a name prefix for objects logged while this layer is active.

property name_prefix: str#

Backend-name prefix applied to every logged object in this layer.

Whitespace in layer_id is replaced with underscores so the prefix remains a valid path segment in backends that disallow spaces (e.g. USD prim paths). The original layer_id (with any spaces) is still used for UI display.

Returns:

Empty string for the default sentinel layer (preserves legacy unprefixed paths), otherwise "/layers/<sanitized_layer_id>".