Skip to main content

RenderScene

Trait RenderScene 

Source
pub trait RenderScene {
    type HitTarget: HitTestTarget + Clone;

    // Required methods
    fn clear(&mut self);
    fn hit_test(&self, x: f32, y: f32) -> Vec<Self::HitTarget>;
    fn find_target(&self, node_id: NodeId) -> Option<Self::HitTarget>;

    // Provided methods
    fn hit_test_near(&self, _x: f32, _y: f32) -> Option<Self::HitTarget> { ... }
    fn hit_test_nodes(&self, x: f32, y: f32) -> Vec<NodeId> ⓘ { ... }
    fn hit_test_ray(&self, _scene: NodeId, _ray: Ray) -> Vec<Self::HitTarget> { ... }
    fn surface_windows(
        &self,
        _visit: &mut dyn FnMut(NodeId, ProjectiveTransform),
    ) { ... }
    fn surface_window_bounds(&self, _node_id: NodeId) -> Option<Rect> { ... }
    fn collect_retained_visual_observation_nodes(
        &self,
        nodes: &mut HashSet<NodeId>,
    ) -> bool { ... }
}
Expand description

Trait describing the minimal surface area required by the application shell to process pointer events and refresh the frame graph.

Required Associated Types§

Source

type HitTarget: HitTestTarget + Clone

The hit target type that hit testing returns.

Required Methods§

Source

fn clear(&mut self)

Removes the render graph and all hit targets.

Source

fn hit_test(&self, x: f32, y: f32) -> Vec<Self::HitTarget>

Performs hit testing at the given coordinates. Returns hit targets ordered by z-index (top-to-bottom).

Source

fn find_target(&self, node_id: NodeId) -> Option<Self::HitTarget>

Finds a hit target by NodeId with fresh geometry from the current scene.

This is the key method for HitPathTracker-style gesture handling:

  • On PointerDown, we cache NodeIds (not geometry)
  • On Move/Up/Cancel, we call this to get fresh HitTarget with current geometry
  • Handler closures are preserved (same Rc), so internal state survives

Returns None if the node no longer exists in the scene (e.g., removed during gesture).

Provided Methods§

Source

fn hit_test_near(&self, _x: f32, _y: f32) -> Option<Self::HitTarget>

The one target a press reaches when it misses every target but lands inside a small target grown to the minimum touch size: the nearest such target, and none when the point is outside every grown target.

Source

fn hit_test_nodes(&self, x: f32, y: f32) -> Vec<NodeId> ⓘ

Returns NodeIds of all hit regions at the given coordinates. This is a convenience method equivalent to hit_test().map(|h| h.node_id()).

Source

fn hit_test_ray(&self, _scene: NodeId, _ray: Ray) -> Vec<Self::HitTarget>

The hit targets on the mesh surfaces of the scene the node scene shows that ray reaches, in the space the scene’s eye stands in, ordered by z-index (top-to-bottom): a controller’s, a hand’s or a gaze’s, which need not start at the eye.

Source

fn surface_windows(&self, _visit: &mut dyn FnMut(NodeId, ProjectiveTransform))

Visits each mesh surface the eyes of the window’s scenes see, by its node, with the map from its content to the window as the eye shows it, through the doorways it lies behind: where the nodes on it show.

Source

fn surface_window_bounds(&self, _node_id: NodeId) -> Option<Rect>

Where the hit target of node_id shows in the window when it lies on a mesh surface of a 3D scene: its bounds as the scene’s camera shows them, also through a doorway and for an eye that walked through one. None for a flat target, a target behind the eye or no target.

Source

fn collect_retained_visual_observation_nodes( &self, nodes: &mut HashSet<NodeId>, ) -> bool

Replaces the set with retained visual observation owners, preserving its capacity. Returns whether the scene provides this information.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§