@@ -4,12 +4,13 @@ use nohash_hasher::IntMap;
44use re_chunk_store:: LatestAtQuery ;
55use re_log_types:: EntityPathHash ;
66use re_tf:: { TransformFrameId , TransformFrameIdHash } ;
7- use re_types:: { archetypes, components:: ImagePlaneDistance } ;
7+ use re_types:: { archetypes, blueprint , components:: ImagePlaneDistance } ;
88use re_view:: { DataResultQuery as _, latest_at_with_blueprint_resolved_data} ;
99use re_viewer_context:: {
1010 DataResult , IdentifiedViewSystem , ViewContext , ViewContextSystem ,
1111 ViewContextSystemOncePerFrameResult , typed_fallback_for,
1212} ;
13+ use re_viewport_blueprint:: ViewProperty ;
1314use vec1:: smallvec_v1:: SmallVec1 ;
1415
1516use crate :: caches:: TransformDatabaseStoreCache ;
@@ -106,8 +107,35 @@ impl ViewContextSystem for TransformTreeContext {
106107 // Currently, we don't keep it around during the frame, but we may do so in the future.
107108 self . entity_transform_id_mapping = EntityTransformIdMapping :: new ( ctx, query) ;
108109
109- // Target frame is the coordinate frame of the space origin entity.
110- self . target_frame = self . transform_frame_id_for ( query. space_origin . hash ( ) ) ;
110+ // Target frame - check for blueprint override first, otherwise use space origin's coordinate frame.
111+ self . target_frame = {
112+ let spatial_info_prop = ViewProperty :: from_archetype :: <
113+ blueprint:: archetypes:: SpatialInformation ,
114+ > (
115+ ctx. blueprint_db ( ) , ctx. blueprint_query ( ) , ctx. view_id
116+ ) ;
117+
118+ let target_frame_component = spatial_info_prop
119+ . component_or_fallback :: < TransformFrameId > (
120+ ctx,
121+ blueprint:: archetypes:: SpatialInformation :: descriptor_target_frame ( ) . component ,
122+ ) ;
123+
124+ match target_frame_component {
125+ Ok ( target_frame) => {
126+ let target_frame_str = target_frame. as_str ( ) ;
127+ if !target_frame_str. is_empty ( ) {
128+ TransformFrameIdHash :: from_str ( target_frame. as_str ( ) )
129+ } else {
130+ self . transform_frame_id_for ( query. space_origin . hash ( ) )
131+ }
132+ }
133+ Err ( err) => {
134+ re_log:: error_once!( "Failed to query target frame: {err}" ) ;
135+ self . transform_frame_id_for ( query. space_origin . hash ( ) )
136+ }
137+ }
138+ } ;
111139
112140 let latest_at_query = query. latest_at_query ( ) ;
113141
0 commit comments