Skip to main content

GltfScene

Struct GltfScene 

Source
pub struct GltfScene {
    pub nodes: Vec<GltfNode>,
    pub meshes: Vec<GltfMesh>,
    pub accessors: Vec<GltfAccessor>,
    pub buffer_views: Vec<GltfBufferView>,
    pub animations: Vec<GltfAnimation>,
    pub materials: Vec<GltfMaterial>,
    pub cameras: Vec<SceneCamera>,
    pub lights: Vec<SceneLight>,
}
Expand description

A glTF 2.0 scene: a collection of nodes and meshes.

Fields§

§nodes: Vec<GltfNode>

Scene nodes.

§meshes: Vec<GltfMesh>

Scene meshes.

§accessors: Vec<GltfAccessor>

Accessors.

§buffer_views: Vec<GltfBufferView>

Buffer views.

§animations: Vec<GltfAnimation>

Animations.

§materials: Vec<GltfMaterial>

Materials.

§cameras: Vec<SceneCamera>

Cameras.

§lights: Vec<SceneLight>

Lights (KHR_lights_punctual).

Implementations§

Source§

impl GltfScene

Source

pub fn new() -> Self

Create an empty scene.

Source

pub fn add_camera(&mut self, cam: SceneCamera) -> usize

Add a camera and return its index.

Source

pub fn add_light(&mut self, light: SceneLight) -> usize

Add a light and return its index.

Source

pub fn to_json_with_hierarchy(&self) -> String

Serialize the scene as a glTF 2.0 JSON string including cameras and lights.

Cameras are written in the cameras array. Lights use the KHR_lights_punctual extension.

Source

pub fn add_mesh(&mut self, mesh: GltfMesh) -> usize

Add a mesh to the scene and return its index.

Source

pub fn add_node(&mut self, node: GltfNode)

Add a node to the scene.

Source

pub fn mesh_count(&self) -> usize

Return the number of meshes in the scene.

Source

pub fn node_count(&self) -> usize

Return the number of nodes in the scene.

Source

pub fn traverse_depth_first<F>(&self, visitor: F)
where F: FnMut(usize, usize, [f64; 3]),

Traverse the scene graph depth-first, calling visitor with (node_index, depth, accumulated_translation) for each node.

Source

pub fn collect_mesh_primitives(&self) -> Vec<(&str, &GltfPrimitive)>

Collect all mesh primitives in the scene with their associated node names.

Source

pub fn add_material(&mut self, mat: GltfMaterial) -> usize

Add a material and return its index.

Source

pub fn add_animation(&mut self, anim: GltfAnimation) -> usize

Add an animation and return its index.

Source

pub fn nodes_using_mesh(&self, mesh_idx: usize) -> Vec<usize>

Find all nodes that reference a given mesh index.

Source

pub fn total_vertex_count(&self) -> usize

Return the total vertex count across all meshes.

Source

pub fn total_triangle_count(&self) -> usize

Return the total triangle count across all meshes.

Source

pub fn to_json(&self) -> String

Serialize the scene as a glTF 2.0 JSON string.

Accessor and bufferView entries are written as stubs (no binary buffer).

Trait Implementations§

Source§

impl Default for GltfScene

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.