newton.viewer.Layer#
- class newton.viewer.Layer(layer_id)[source]#
Bases:
objectContainer 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
visibleflag, a per-layer renderingxform(applied to every drawn position/orientation in the layer; defaults to the identity transform so layers overlay), and a stablelayer_idstring 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. UseViewerBase.activate()to switch which layer receives subsequentset_model/log_state/log_*calls; useViewerBase.set_layer_visible()to toggle visibility andViewerBase.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_idis replaced with underscores so the prefix remains a valid path segment in backends that disallow spaces (e.g. USD prim paths). The originallayer_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>".