Skip to main content

BatchedText

Struct BatchedText 

Source
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: VectorFontAtlas

this.atlas.

Implementations§

Source§

impl BatchedText

Source

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.

Source

pub fn node(&self) -> &ObjectRef

The scene-graph node: scene.add( batch.node() ).

Source

pub fn count(&self) -> usize

InstancedMesh.count — the glyph quads the renderer draws.

Source

pub fn member_count(&self) -> usize

get memberCount().

Source

pub fn max_glyph_count(&self) -> usize

The glyph capacity this batch was created with.

Source

pub fn texture(&self) -> &Texture

The atlas texture the material samples.

Source

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.

Source

pub fn font(&self) -> Option<&Rc<VectorFont>>

The font set by BatchedText::set_font, if any.

Source

pub fn reset_atlas(&mut self)

resetAtlas().

Source

pub fn add_text(&mut self, text: Text) -> Option<usize>

addText( text ) — the member id, or None at capacity (-1 in the JS).

Source

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.

Source

pub fn text_at(&self, member_id: usize) -> Option<&Text>

getTextAt( memberId ).

Source

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.

Source

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.

Source

pub fn member_glyphs(&self, member_id: usize) -> Option<(usize, usize)>

_memberGlyphs[ memberId ].

Source

pub fn glyph_uv_array(&self) -> &[f32]

aGlyphUV, for tests and for callers checking the packing without a GPU.

Source

pub fn glyph_bounds_array(&self) -> &[f32]

aGlyphBounds.

Source

pub fn color_array(&self) -> &[f32]

aColor.

Source

pub fn opacity_array(&self) -> &[f32]

aOpacity.

Source

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).

Source

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.

Source

pub fn outline_color(&self) -> Option<Color>

get outlineColor().

Source

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.

Source

pub fn outline_width(&self) -> f64

Outline/halo band width, in SDF units.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.