pub struct ViewportRuntime { /* private fields */ }Expand description
Per-frame scene orchestration layer.
Owns plugins, an optional fixed timestep accumulator, and a transform snapshot table. Does not own the scene, selection, GPU resources, or window.
§Priority execution order
Each call to step executes plugins in ascending priority order:
[i32::MIN, SELECT)– Prepare (100), Pick (200): once, at wall dt[SELECT, MANIPULATE)– Select (300): once (built-in SelectionSystem runs first)[MANIPULATE, SIMULATE)– Manipulate (400), Animate (500): once[SIMULATE, POST_SIM)– Simulate (600): once per fixed step or once at wall dt[POST_SIM, i32::MAX]– PostSim (700), Writeback (800): once at wall dt
Implementations§
Source§impl ViewportRuntime
impl ViewportRuntime
Sourcepub fn with_selection_system(self) -> Self
pub fn with_selection_system(self) -> Self
Enable the built-in click-to-select system.
The SelectionSystem runs before the Select phase each frame. It reads
RuntimeFrameContext::clicked, pick_hit, and shift_held to produce
SelectionOp entries in RuntimeOutput.
Sourcepub fn with_manipulation_system(self) -> Self
pub fn with_manipulation_system(self) -> Self
Enable the built-in manipulation system.
The ManipulationSystem runs before the Manipulate phase each frame. It
drives G/R/S sessions and gizmo drag from RuntimeFrameContext inputs, writing
transform changes via TransformWriteback.
Sourcepub fn is_manipulating(&self) -> bool
pub fn is_manipulating(&self) -> bool
True while the built-in manipulation system has an active G/R/S session or gizmo drag.
Use this to suppress orbit camera movement while manipulating objects.
Sourcepub fn manipulation_system(&self) -> Option<&ManipulationSystem>
pub fn manipulation_system(&self) -> Option<&ManipulationSystem>
Access the built-in manipulation system, if enabled.
Sourcepub fn with_mode(self, mode: SceneRuntimeMode) -> Self
pub fn with_mode(self, mode: SceneRuntimeMode) -> Self
Set the runtime mode.
Sourcepub fn with_plugin(self, plugin: impl RuntimePlugin) -> Self
pub fn with_plugin(self, plugin: impl RuntimePlugin) -> Self
Register a plugin. Plugins run in ascending priority order each frame. Plugins with equal priority run in registration order (stable sort).
Sourcepub fn with_fixed_timestep(self, ts: FixedTimestep) -> Self
pub fn with_fixed_timestep(self, ts: FixedTimestep) -> Self
Enable fixed-timestep accumulation for physics plugins.
When set, plugins in the [SIMULATE, POST_SIM) range run once per
accumulated fixed step rather than once per frame at wall dt. All other
priority ranges always run once per frame.
Sourcepub fn set_fixed_timestep(&mut self, ts: FixedTimestep)
pub fn set_fixed_timestep(&mut self, ts: FixedTimestep)
Replace the fixed timestep at runtime. Resets the accumulator.
Use this to change the simulation rate after construction without rebuilding the runtime or its plugins.
Sourcepub fn clear_fixed_timestep(&mut self)
pub fn clear_fixed_timestep(&mut self)
Remove the fixed timestep, reverting to one simulate call per frame at wall dt.
Sourcepub fn mode(&self) -> SceneRuntimeMode
pub fn mode(&self) -> SceneRuntimeMode
The current runtime mode.
Sourcepub fn snapshots(&self) -> &TransformSnapshotTable
pub fn snapshots(&self) -> &TransformSnapshotTable
The transform snapshot table for interpolated rendering.
Updated each frame during writeback. Pass alpha as the
blend factor to TransformSnapshotTable::interpolated.
Sourcepub fn resources(&self) -> &RuntimeResources
pub fn resources(&self) -> &RuntimeResources
Read access to the shared resource registry.
Use this after step to inspect resources without running the frame loop.
During the frame loop, access resources through RuntimeStepContext::resources.
Sourcepub fn resources_mut(&mut self) -> &mut RuntimeResources
pub fn resources_mut(&mut self) -> &mut RuntimeResources
Write access to the shared resource registry.
Use this to pre-populate resources before the first step, or to inject
resources from outside the plugin system (e.g. from the application).
Sourcepub fn alpha(&self) -> f32
pub fn alpha(&self) -> f32
Blend factor for rendering interpolation between fixed steps.
Returns 1.0 if no fixed timestep is configured (render directly from
current scene transforms without interpolation).
Sourcepub fn step_index(&self) -> u64
pub fn step_index(&self) -> u64
Monotonically increasing simulation step counter.
Incremented once per simulate execution. With a fixed timestep this means it may increment multiple times per rendered frame. Wraps on overflow.
Sourcepub fn with_camera_follow(self, follow: CameraFollow) -> Self
pub fn with_camera_follow(self, follow: CameraFollow) -> Self
Set a camera follow binding (builder style).
Each call to step will compute a suggested camera center
from the followed node and return it in RuntimeOutput::camera_follow_target.
Sourcepub fn set_camera_follow(&mut self, follow: CameraFollow)
pub fn set_camera_follow(&mut self, follow: CameraFollow)
Update the camera follow binding at runtime.
Sourcepub fn clear_camera_follow(&mut self)
pub fn clear_camera_follow(&mut self)
Remove the camera follow binding. RuntimeOutput::camera_follow_target
will be None after this call.
Sourcepub fn camera_follow(&self) -> Option<&CameraFollow>
pub fn camera_follow(&self) -> Option<&CameraFollow>
The current camera follow binding.
Sourcepub fn step(
&mut self,
scene: &mut Scene,
selection: &mut Selection,
frame: &RuntimeFrameContext,
) -> RuntimeOutput
pub fn step( &mut self, scene: &mut Scene, selection: &mut Selection, frame: &RuntimeFrameContext, ) -> RuntimeOutput
Run one frame of the runtime.
Plugins run in ascending priority order. The simulate range
[SIMULATE, POST_SIM) runs once per accumulated fixed step (or once at
frame.dt when no fixed timestep is configured). All other ranges run
once per frame. Transform ops are flushed to scene and the snapshot
table is updated after the writeback range.
Selection ops produced by plugins are applied to selection before returning.
Contact events and the applied transform ops are returned in RuntimeOutput.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ViewportRuntime
impl !RefUnwindSafe for ViewportRuntime
impl Send for ViewportRuntime
impl !Sync for ViewportRuntime
impl Unpin for ViewportRuntime
impl UnsafeUnpin for ViewportRuntime
impl !UnwindSafe for ViewportRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.