9.3
94 3D: Projected labels
procedure
(projected-label template #:view view-id #:target target [ #:offset offset #:occlusion occlusion #:placement placement #:leader leader #:visibility visibility]) → projected-label? template : visual? view-id : symbol? target : (or/c vec3? spatial-path?) offset : vec2? = origin
occlusion : (or/c 'always-visible 'hide 'fade) = 'always-visible placement : label-placement3d? = default-label-placement3d leader : (or/c #f leader-style3d?) = #f
visibility :
(or/c 'always 'inside-frustum 'anchor-visible) = 'always
Creates an ordinary 2D text, formula, or other concrete Visual whose centre
follows a point projected through a sampled view3d. offset
is in screen pixels (with Animate’s y-up convention), so it is not enlarged
or rotated by the spatial camera. The final compositor jointly measures and
places sibling labels. 'inside-frustum suppresses an anchor outside
the camera rectangle; 'anchor-visible additionally suppresses an
anchor behind opaque geometry. A leader-style3d requests a crisp
two-dimensional grey connector from the selected label-box attachment to its
projected anchor; 'nearest and 'center are the supported
attachments, and elbow? selects a horizontal-first elbow.
procedure
(projected-label? value) → boolean?
value : any/c
Recognizes a projected
label definition.
struct
(struct label-placement3d ( preferred distance candidates keep-inside? avoid-overlap? avoid stability-weight leader-threshold) #:transparent) preferred : list? distance : nonnegative-real? candidates : exact-positive-integer? keep-inside? : boolean? avoid-overlap? : boolean? avoid : list? stability-weight : nonnegative-real? leader-threshold : nonnegative-real?
The immutable direct-mode placement policy. Directions are
chosen in declared preferred order when candidate costs tie.
The standard
north-east-first direct placement policy.
struct
(struct leader-style3d (attachment elbow? minimum-length) #:transparent) attachment : (or/c 'nearest 'center) elbow? : boolean? minimum-length : nonnegative-real?
Requests a compositor leader. Its length is measured in
output pixels after label placement.
procedure
(follow-projected-point template #:view view-id #:point point [ #:offset offset #:occlusion occlusion #:placement placement #:leader leader #:visibility visibility]) → projected-label? template : visual? view-id : symbol? point : vec3? offset : vec2? = origin
occlusion : (or/c 'always-visible 'hide 'fade) = 'always-visible placement : label-placement3d? = default-label-placement3d leader : (or/c #f leader-style3d?) = #f
visibility :
(or/c 'always 'inside-frustum 'anchor-visible) = 'always
The literal-point spelling of projected-label.
procedure
(follow-projected-spatial template #:view view-id #:target target [ #:offset offset #:occlusion occlusion #:placement placement #:leader leader #:visibility visibility]) → projected-label? template : visual? view-id : symbol? target : spatial-path? offset : vec2? = origin
occlusion : (or/c 'always-visible 'hide 'fade) = 'always-visible placement : label-placement3d? = default-label-placement3d leader : (or/c #f leader-style3d?) = #f
visibility :
(or/c 'always 'inside-frustum 'anchor-visible) = 'always
The spatial-path spelling of projected-label.
The canonical example uses all of this without a second timeline:
(define label-a (follow-projected-spatial (math-tex #:id 'label-a "A") #:view 'world #:target '(tetrahedron A) #:offset (vec2 -20 -18))) (scene-play (scene-add (make-scene) world label-a) (rotate3d-by '(world tetrahedron) (axis-angle y-axis3 pi)) (camera3d-orbit-by 'world #:azimuth pi) #:duration 2)
For the complete moving tetrahedron with labels A–D, see "examples/3d/projected-labels.rkt".