122 3D: Spatial inspection and exact picking
3D reference map · First 3D picture
Spatial inspection exposes the hierarchy that an already sampled view3d submits to its renderer. Inspection is immutable query data; it never adds a wireframe, selection flag, acceleration structure, or other hidden state to an authored Scene. The preview uses the same query data after a viewport click and paints its AABB, exact triangle, normal, local frame, and ray-pixel marker only after the cached bitmap has been drawn.
struct
(struct spatial-inspection ( path kind local-transform world-transform local-bounds world-bounds material triangle-count vertex-count camera-position view-position projected-position view-depth metadata) #:transparent) path : (listof symbol?) kind : symbol? local-transform : transform3? world-transform : affine3? local-bounds : aabb3? world-bounds : aabb3? material : any/c triangle-count : exact-nonnegative-integer? vertex-count : exact-nonnegative-integer? camera-position : vec3? view-position : (or/c #f vec3?) projected-position : (or/c #f vec2?) view-depth : (or/c #f nonnegative-real?) metadata : immutable-hash?
struct
(struct spatial-pick ( inspection path triangle-index point distance barycentric normal ray metadata) #:transparent) inspection : spatial-inspection? path : (listof symbol?) triangle-index : (or/c #f exact-nonnegative-integer?) point : vec3? distance : nonnegative-real? barycentric : vec3? normal : vec3? ray : ray3? metadata : immutable-hash?
struct
(struct topology-inspection3d ( path semantic-vertex-ids semantic-edge-ids nearest-vertex-id nearest-edge-id nearest-edge-incident-face-ids render-triangle-id polygonal-face-id polygonal-face-policy connected-component boundary-components topology) #:transparent) path : (listof symbol?) semantic-vertex-ids : vector? semantic-edge-ids : vector? nearest-vertex-id : any/c nearest-edge-id : any/c nearest-edge-incident-face-ids : vector? render-triangle-id : any/c polygonal-face-id : any/c polygonal-face-policy : any/c connected-component : any/c boundary-components : vector? topology : hash?
procedure
→ (or/c #f topology-inspection3d?) pick : spatial-pick?
struct
(struct spatial-topology-overlay3d ( vertex edge face component-faces boundary-segments halfedges) #:transparent) vertex : vec3? edge : vector? face : vector? component-faces : vector? boundary-segments : vector? halfedges : vector?
procedure
(spatial-pick-topology-overlay3d view pick)
→ (or/c #f spatial-topology-overlay3d?) view : view3d? pick : spatial-pick?
struct
(struct surface-pick3d ( spatial-pick surface-kind parameter trim-boundary source-cell interpolated-normal) #:transparent) spatial-pick : spatial-pick? surface-kind : symbol? parameter : (or/c #f vector?) trim-boundary : any/c source-cell : any/c interpolated-normal : (or/c #f vec3?)
procedure
(spatial-pick-kind pick)
→ (or/c 'mesh-triangle 'stroke-segment 'point-marker 'arrow-marker) pick : spatial-pick?
procedure
(view3d-spatial-inspections view)
→ (listof spatial-inspection?) view : view3d?
procedure
→ (listof spatial-inspection?) view : view3d?
procedure
(view3d-spatial-inspection-at view path)
→ (or/c #f spatial-inspection?) view : view3d? path : (listof symbol?)
procedure
(view3d-pick view ray) → (or/c #f spatial-pick?)
view : view3d? ray : ray3?
procedure
(view3d-surface-pick view ray) → (or/c #f surface-pick3d?)
view : view3d? ray : ray3?
procedure
(view3d-pixel-pick view pixel-x pixel-y #:width width #:height height) → (or/c #f spatial-pick?) view : view3d? pixel-x : finite-real? pixel-y : finite-real? width : exact-positive-integer? height : exact-positive-integer?
procedure
(mesh3d-bvh mesh) → mesh3d-bvh?
mesh : mesh3d?
procedure
(mesh3d-bvh? value) → boolean?
value : any/c
procedure
(bvh3d-node? value) → boolean?
value : any/c
procedure
(bvh3d-leaf? value) → boolean?
value : any/c
procedure
(bvh3d-bounds tree) → aabb3?
tree : mesh3d-bvh?
procedure
(bvh3d-triangle-indices tree)
→ (listof exact-nonnegative-integer?) tree : mesh3d-bvh?
procedure
(bvh3d-ray-candidates tree ray)
→ (listof exact-nonnegative-integer?) tree : mesh3d-bvh? ray : ray3?
The canonical preview probe is "examples/3d/spatial-inspector-picking.rkt". Open it with animate/preview, click a visible facet, then use the 3D topology inspector section to see semantic part IDs and invariants; the post-render overlay marks its face, component, boundaries, half-edges, and normal. Animate → 3D selection can copy the spatial path, hit point, or normal; its scratch action also supplies a clipping plane. Focusing the inspection camera changes only the preview override, never the authored camera or timeline. The raw mesh uses render triangles as polygonal faces, so the probe does not claim an unretained higher-level polygonal-face mapping.