pub struct RenderPrimitive { /* private fields */ }Expand description
A single drawable primitive and its canonical CPU-side vertex attributes.
All buffers are CPU-side, decoded to a canonical layout (f32 vectors) so a renderer can upload them to the GPU as-is. Unskinned primitives retain their owning node’s rest-pose world transform; skinned primitives use the identity transform because their joint palette produces world-space output.
Implementations§
Source§impl RenderPrimitive
impl RenderPrimitive
Sourcepub fn builder(
node_id: NodeId,
positions: Vec<[f32; 3]>,
indices: Vec<u32>,
) -> RenderPrimitiveBuilder
pub fn builder( node_id: NodeId, positions: Vec<[f32; 3]>, indices: Vec<u32>, ) -> RenderPrimitiveBuilder
Starts a type-safe builder for programmatic primitive data.
Sourcepub fn node_index(&self) -> u32
pub fn node_index(&self) -> u32
Returns the raw glTF node index that instantiates this primitive.
Sourcepub fn node_id(&self) -> NodeId
pub fn node_id(&self) -> NodeId
Returns the stable node identifier that instantiates this primitive.
Sourcepub fn world_transform(&self) -> &Transform
pub fn world_transform(&self) -> &Transform
Returns the transform applied when rendering the primitive.
This is the owning node’s rest-pose world transform for an unskinned primitive and identity for a skinned primitive, whose joint palette already produces world-space output.
Sourcepub fn indices(&self) -> &[u32]
pub fn indices(&self) -> &[u32]
Returns element indices in the topology described by Self::topology.
Sourcepub fn joints(&self) -> &[[u16; 4]]
pub fn joints(&self) -> &[[u16; 4]]
Returns the first JOINTS_0 set, or an empty slice if unskinned.
Sourcepub fn weights(&self) -> &[[f32; 4]]
pub fn weights(&self) -> &[[f32; 4]]
Returns the first WEIGHTS_0 set, or an empty slice if unskinned.
Sourcepub fn skinning_sets(&self) -> &[SkinningSet]
pub fn skinning_sets(&self) -> &[SkinningSet]
Returns every consecutive JOINTS_n / WEIGHTS_n pair.
Sourcepub fn morph_targets(&self) -> &[MorphTarget]
pub fn morph_targets(&self) -> &[MorphTarget]
Returns morph targets in glTF target order.
Sourcepub fn texcoord_sets(&self) -> &[Vec<[f32; 2]>]
pub fn texcoord_sets(&self) -> &[Vec<[f32; 2]>]
Returns all consecutive TEXCOORD_n buffers.
Sourcepub fn texcoord_set(&self, set: u32) -> Option<&[[f32; 2]]>
pub fn texcoord_set(&self, set: u32) -> Option<&[[f32; 2]]>
Returns one texture coordinate set by its glTF set index.
Sourcepub fn tangents(&self) -> &[[f32; 4]]
pub fn tangents(&self) -> &[[f32; 4]]
Returns tangent vectors, with handedness stored in the fourth component.
Sourcepub fn secondary_texcoords(&self) -> &[[f32; 2]]
pub fn secondary_texcoords(&self) -> &[[f32; 2]]
Returns TEXCOORD_1, or an empty slice when absent.
Sourcepub fn texture_index(&self) -> Option<usize>
pub fn texture_index(&self) -> Option<usize>
Returns the raw base-color glTF texture index, if present.
Sourcepub fn texture_id(&self) -> Option<TextureId>
pub fn texture_id(&self) -> Option<TextureId>
Returns the stable base-color texture identifier, if present.
Sourcepub fn material_index(&self) -> Option<usize>
pub fn material_index(&self) -> Option<usize>
Returns the raw glTF material index, if present.
Sourcepub fn material_id(&self) -> Option<MaterialId>
pub fn material_id(&self) -> Option<MaterialId>
Returns the stable material identifier, if present.
Sourcepub fn topology(&self) -> PrimitiveTopology
pub fn topology(&self) -> PrimitiveTopology
Returns the primitive assembly topology.
Sourcepub fn morph_weights(&self) -> &[f32]
pub fn morph_weights(&self) -> &[f32]
Returns the primitive’s current mutable morph weights.
Sourcepub fn base_morph_weights(&self) -> &[f32]
pub fn base_morph_weights(&self) -> &[f32]
The original morph weights as defined by the glTF node/mesh, never
modified by Self::apply_morph_update. Expression evaluation reads
these as the base state.
Sourcepub fn set_morph_weights(&mut self, weights: &[f32])
pub fn set_morph_weights(&mut self, weights: &[f32])
Overrides the current morph weights. The slice is clamped to the number of morph targets (extra values ignored, missing ones become zero).
Sourcepub fn apply_morph_update(&mut self, target_index: u32, weight: f32)
pub fn apply_morph_update(&mut self, target_index: u32, weight: f32)
Sets the weight of one morph target, ignoring out-of-range indices.
Values are clamped to 0..=1; any previously accumulated weight for
this target is replaced. Missing slots (vector shorter than the target
list) are extended with zeros first.
Sourcepub fn reset_morph_weights(&mut self)
pub fn reset_morph_weights(&mut self)
Restores the morph weights to the original glTF base state, so a frame that only drives some targets does not leave stale weights on the others.
Sourcepub fn morphed_vertices(&self) -> MorphedVertices
pub fn morphed_vertices(&self) -> MorphedVertices
Returns the vertex attributes with the current morph weights applied:
each attribute is base + Σ(weight · delta).
Normals are renormalized after applying their deltas; flat-normal primitives (no NORMAL attribute) recompute flat normals from the morphed positions. Tangents only move when morph targets carry tangent deltas, otherwise they stay at their base value.
Sourcepub fn morphed_vertices_with_weights(
&self,
morph_weights: &[f32],
) -> MorphedVertices
pub fn morphed_vertices_with_weights( &self, morph_weights: &[f32], ) -> MorphedVertices
Returns morphed vertices for explicit instance weights without changing the immutable asset data.
Sourcepub fn skin_index(&self) -> Option<usize>
pub fn skin_index(&self) -> Option<usize>
Returns the raw glTF skin index, if this primitive is skinned.
Sourcepub fn skin_id(&self) -> Option<SkinId>
pub fn skin_id(&self) -> Option<SkinId>
Returns the stable skin identifier, if this primitive is skinned.
Sourcepub fn base_color_texcoord(&self) -> u32
pub fn base_color_texcoord(&self) -> u32
Returns the resolved UV-set index used by the base-color texture.