pub struct RenderPrimitiveBuilder { /* private fields */ }Expand description
Builds one renderer-ready primitive from programmatic vertex data.
Required asset references use typed identifiers. Missing optional vertex attributes receive the same safe defaults as loaded glTF primitives, and triangle normals are generated when they are omitted.
Implementations§
Source§impl RenderPrimitiveBuilder
impl RenderPrimitiveBuilder
Sourcepub fn new(node_id: NodeId, positions: Vec<[f32; 3]>, indices: Vec<u32>) -> Self
pub fn new(node_id: NodeId, positions: Vec<[f32; 3]>, indices: Vec<u32>) -> Self
Creates a triangle primitive attached to node_id.
Use Self::with_topology for point or line geometry. Indices are
always explicit; use 0..positions.len() for non-indexed input.
Sourcepub const fn with_world_transform(self, transform: Transform) -> Self
pub const fn with_world_transform(self, transform: Transform) -> Self
Sets the accumulated rest-pose transform for an unskinned primitive.
Skinned primitives use the identity transform, matching loaded VRM assets whose skinning palette already places the surface in world space.
Sourcepub fn with_normals(self, normals: Vec<[f32; 3]>) -> Self
pub fn with_normals(self, normals: Vec<[f32; 3]>) -> Self
Supplies one normal per position instead of generating defaults.
Sourcepub fn with_skinning(
self,
joints: Vec<[u16; 4]>,
weights: Vec<[f32; 4]>,
) -> Self
pub fn with_skinning( self, joints: Vec<[u16; 4]>, weights: Vec<[f32; 4]>, ) -> Self
Supplies joint indices and weights, one pair per position.
Sourcepub fn with_skinning_sets(self, skinning_sets: Vec<SkinningSet>) -> Self
pub fn with_skinning_sets(self, skinning_sets: Vec<SkinningSet>) -> Self
Replaces every consecutive skinning attribute set.
Sourcepub const fn with_skin(self, skin_id: SkinId) -> Self
pub const fn with_skin(self, skin_id: SkinId) -> Self
Attaches the primitive to a skin in the completed asset.
Sourcepub fn with_morph_target(
self,
position_deltas: Vec<[f32; 3]>,
normal_deltas: Option<Vec<[f32; 3]>>,
tangent_deltas: Option<Vec<[f32; 3]>>,
) -> Self
pub fn with_morph_target( self, position_deltas: Vec<[f32; 3]>, normal_deltas: Option<Vec<[f32; 3]>>, tangent_deltas: Option<Vec<[f32; 3]>>, ) -> Self
Appends a morph target without requiring direct access to its storage.
Sourcepub fn with_morph_targets(self, morph_targets: Vec<MorphTarget>) -> Self
pub fn with_morph_targets(self, morph_targets: Vec<MorphTarget>) -> Self
Replaces the complete morph-target list.
Sourcepub fn with_morph_weights(self, morph_weights: Vec<f32>) -> Self
pub fn with_morph_weights(self, morph_weights: Vec<f32>) -> Self
Sets the base weights, one value per morph target.
Sourcepub fn with_texcoords(self, texcoords: Vec<[f32; 2]>) -> Self
pub fn with_texcoords(self, texcoords: Vec<[f32; 2]>) -> Self
Supplies UV set 0, one coordinate per position.
Sourcepub fn with_secondary_texcoords(self, texcoords: Vec<[f32; 2]>) -> Self
pub fn with_secondary_texcoords(self, texcoords: Vec<[f32; 2]>) -> Self
Supplies UV set 1, one coordinate per position.
Sourcepub fn with_texcoord_sets(self, texcoord_sets: Vec<Vec<[f32; 2]>>) -> Self
pub fn with_texcoord_sets(self, texcoord_sets: Vec<Vec<[f32; 2]>>) -> Self
Replaces every consecutive texture coordinate set.
Sourcepub fn with_tangents(self, tangents: Vec<[f32; 4]>) -> Self
pub fn with_tangents(self, tangents: Vec<[f32; 4]>) -> Self
Supplies tangent vectors, one per position.
Sourcepub fn with_colors(self, colors: Vec<[f32; 4]>) -> Self
pub fn with_colors(self, colors: Vec<[f32; 4]>) -> Self
Supplies vertex colors, one per position.
Sourcepub const fn with_material(self, material_id: MaterialId) -> Self
pub const fn with_material(self, material_id: MaterialId) -> Self
Associates the primitive with a material in the completed asset.
Sourcepub const fn with_base_color_texture(
self,
texture_id: TextureId,
tex_coord: u32,
) -> Self
pub const fn with_base_color_texture( self, texture_id: TextureId, tex_coord: u32, ) -> Self
Sets the legacy base-color texture shortcut retained by RenderPrimitive.
Renderers should normally resolve all texture slots from the material.
This value is kept for consumers of RenderPrimitive::texture_id.
Sourcepub const fn with_topology(self, topology: PrimitiveTopology) -> Self
pub const fn with_topology(self, topology: PrimitiveTopology) -> Self
Selects how the index buffer is interpreted.
Sourcepub fn build(self) -> Result<RenderPrimitive, BuildError>
pub fn build(self) -> Result<RenderPrimitive, BuildError>
Validates local vertex invariants and creates an immutable primitive.
Cross-object identifiers are validated later by
crate::AvatarAssetBuilder::build.