pub struct BatchedText {
pub atlas: VectorFontAtlas,
/* private fields */
}Expand description
The instanced draw for a batch of Text members — a port of lib3’s
BatchedText. See the module doc for the shape of the instance data and
where it deliberately diverges from the JS.
Fields§
§atlas: VectorFontAtlasthis.atlas.
Implementations§
Source§impl BatchedText
impl BatchedText
Sourcepub fn new(
max_text_count: usize,
max_glyph_count: usize,
options: BatchedTextOptions,
) -> Self
pub fn new( max_text_count: usize, max_glyph_count: usize, options: BatchedTextOptions, ) -> Self
new BatchedText( maxTextCount = 64, maxGlyphCount = 1024, undefined, options ). The constructor ends with this.count = 0.
Sourcepub fn member_count(&self) -> usize
pub fn member_count(&self) -> usize
get memberCount().
Sourcepub fn max_glyph_count(&self) -> usize
pub fn max_glyph_count(&self) -> usize
The glyph capacity this batch was created with.
Sourcepub fn set_font(&mut self, font: Rc<VectorFont>)
pub fn set_font(&mut self, font: Rc<VectorFont>)
The font-loaded continuation of the JS constructor:
this.vectorFont = font; this.atlas.setFont( font ); … t._needsSync = true.
VectorFontAtlas here takes the font per call rather than holding it
(README deviation 11), so setFont’s whole effect is its reset.
Sourcepub fn font(&self) -> Option<&Rc<VectorFont>>
pub fn font(&self) -> Option<&Rc<VectorFont>>
The font set by BatchedText::set_font, if any.
Sourcepub fn reset_atlas(&mut self)
pub fn reset_atlas(&mut self)
resetAtlas().
Sourcepub fn add_text(&mut self, text: Text) -> Option<usize>
pub fn add_text(&mut self, text: Text) -> Option<usize>
addText( text ) — the member id, or None at capacity (-1 in the
JS).
Sourcepub fn remove_text(&mut self, member_id: usize)
pub fn remove_text(&mut self, member_id: usize)
removeText( text ), by id: the slot is cleared, and _memberCount
shrinks only when the last member went.
Sourcepub fn text_at_mut(&mut self, member_id: usize) -> Option<&mut Text>
pub fn text_at_mut(&mut self, member_id: usize) -> Option<&mut Text>
getTextAt( memberId ), for mutation. A layout property changed through
this needs a BatchedText::sync to reach the attributes, as in the JS.
Sourcepub fn member_node(&self, member_id: usize) -> Option<&ObjectRef>
pub fn member_node(&self, member_id: usize) -> Option<&ObjectRef>
The member’s own Object3D — text.position / text.quaternion in the
JS, where Text extends Object3D. sync() composes its matrixWorld.
Every glyph of the member is drawn with that whole matrix_world as its
instance matrix, so rotation and scale are honoured along with position:
member_node( id ).borrow_mut().set_rotation( -PI / 2.0, 0.0, 0.0 ) lays
the label flat on the floor. Members are not billboarded.
Sourcepub fn member_glyphs(&self, member_id: usize) -> Option<(usize, usize)>
pub fn member_glyphs(&self, member_id: usize) -> Option<(usize, usize)>
_memberGlyphs[ memberId ].
Sourcepub fn glyph_uv_array(&self) -> &[f32]
pub fn glyph_uv_array(&self) -> &[f32]
aGlyphUV, for tests and for callers checking the packing without a GPU.
Sourcepub fn glyph_bounds_array(&self) -> &[f32]
pub fn glyph_bounds_array(&self) -> &[f32]
aGlyphBounds.
Sourcepub fn color_array(&self) -> &[f32]
pub fn color_array(&self) -> &[f32]
aColor.
Sourcepub fn opacity_array(&self) -> &[f32]
pub fn opacity_array(&self) -> &[f32]
aOpacity.
Sourcepub fn set_color_at(&mut self, member_id: usize, color: Color)
pub fn set_color_at(&mut self, member_id: usize, color: Color)
setColorAt( memberId, color ). The colour is linear, as
THREE.Color stores it (plan §5.3).
Sourcepub fn set_opacity_at(&mut self, member_id: usize, opacity: f64)
pub fn set_opacity_at(&mut self, member_id: usize, opacity: f64)
setOpacityAt( memberId, opacity ). text._opacity = opacity is
Text::set_opacity here: the batch owns the member, so its
write-through sink is None and there is no recursion.
Sourcepub fn outline_color(&self) -> Option<Color>
pub fn outline_color(&self) -> Option<Color>
get outlineColor().
Sourcepub fn set_outline_color(&mut self, color: Option<Color>)
pub fn set_outline_color(&mut self, color: Option<Color>)
set outlineColor( color ) — None restores the legacy same-colour
outline by zeroing the mix uniform.
Sourcepub fn outline_width(&self) -> f64
pub fn outline_width(&self) -> f64
Outline/halo band width, in SDF units.
Sourcepub fn set_matrix_at(&mut self, member_id: usize, matrix: &Matrix4)
pub fn set_matrix_at(&mut self, member_id: usize, matrix: &Matrix4)
setMatrixAt( memberId, matrix ) — the member’s world matrix when
memberId names a registered member, rewriting that member’s glyph
matrices; past _memberCount it is InstancedMesh.setMatrixAt, i.e. one
glyph instance.
Sourcepub fn sync(&mut self)
pub fn sync(&mut self)
sync( callback ) — lay every member out, grow the atlas, pack the
attributes. The callback is an idiom for a path that never awaits and is
dropped, as in Text::sync.
Sourcepub fn bounding_sphere(&self) -> Option<Sphere>
pub fn bounding_sphere(&self) -> Option<Sphere>
The batch’s bounding sphere as BatchedText::sync last computed it, in
the batch node’s own space. None before the first sync() that packs a
glyph.