#[non_exhaustive]pub struct Keep {}Expand description
Which parts of a model a load keeps. Meshes and the node hierarchy are always kept; each
switch here drops one kind of data on top of that. Keep::default keeps everything.
Keep::max_triangles caps how big a model a load takes at all, and Keep::max_points
how many points and lines Document::flatten draws.
Readers skip reading what isn’t kept, so a narrow Keep also makes a load faster: no
texture files, embedded images or (without materials) material libraries and shaders are
read, nor animations, skins, morph targets, cameras or lights where the format keeps them
apart. What a reader did read and Document::prune then dropped leaves its buffer views
and accessors behind, unreferenced.
Without textures, a material’s factors are its own: a reader that would have found a color texture doesn’t turn the base color white for it.
A Keep is built from Keep::ALL (or Keep::MESHES, Keep::LIGHT) with a with_
setter for each switch, which chain and work in consts:
use polysmelt::Keep;
// Static meshes for an engine that animates nothing, but still skins them.
let keep = Keep::ALL.with_animations(false);
// A 100-million-triangle scan, past the default limit.
let keep = Keep::ALL.with_max_triangles(120_000_000);
// A 40-million-point lidar scan, drawn as points, read on every core.
const SCAN: Keep = Keep::ALL.with_max_points(40_000_000).with_threads(0);
// Only the surfaces: no points or lines in the flattened mesh.
let keep = Keep::ALL.with_lines_and_points(false);New switches may come in later versions, each keeping by default what it switches, so a
Keep can’t be written out field by field.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.animations: boolAnimations.
skins: boolSkins: skeletons, their inverse bind matrices, and the joints and weights on vertices. The joint nodes stay either way, as part of the hierarchy.
morph_targets: boolMorph targets and their weights (and animation channels that set them).
materials: boolMaterials; without them every primitive takes the default material, and textures go too.
textures: boolTextures, their images and samplers, and where materials use them.
image_bytes: boolThe images’ bytes. Without them, kept textures’ images are found but not read or
converted: each is a glTF image with a uri, and Document::images has a handle on it
that says where it is (its file, if it’s in one) and reads it on request.
Document::embed_images reads them all. Document::prune leaves images as they
are: once read, they stay read. Images a reader must look into to make a texture (an OBJ’s
roughness and metalness maps packed into one) are read all the same, so the textures match.
cameras: boolCameras.
lights: boolLights (KHR_lights_punctual).
extras: boolextras everywhere: custom properties and each format’s own details. What the file says
about itself in the keys SourceInfo reads (units, up axis,
author…) stays in asset.extras.source, and the document’s facts stay, either way.
max_triangles: usizeThe most triangles a load accepts, against hostile or runaway files: a model that draws
more is refused (and Document::flatten refuses to draw more). Defaults to
MAX_TRIANGLES; raise it for big scans. Values past TRIANGLE_CEILING are clamped
to it.
lines_and_points: boolPoints and lines (glTF’s POINTS, LINES, LINE_LOOP and LINE_STRIP primitives) in
what Document::flatten draws: point clouds, wireframes, curves. Without them it draws
only triangles, and a model of points and lines alone flattens to nothing. The document
keeps them either way.
max_points: usizeThe most points and line segments Document::flatten draws, against huge point clouds:
a model that draws more is refused (unless Keep::lines_and_points leaves them out).
Counted apart from triangles. Defaults to MAX_POINTS; raise it for big scans. Values
past TRIANGLE_CEILING are clamped to it.
threads: usizeThreads a reader may split its work over, where it can: OBJ text and SPZ, so far. 1, the default, reads on the calling thread; 0 takes one per core. The model read is the same either way. Where threads can’t be had (WebAssembly without shared memory, or a platform that refuses to start one), it reads on the calling thread.
Implementations§
Source§impl Keep
impl Keep
Sourcepub const MESHES: Keep
pub const MESHES: Keep
The meshes and what shapes or shades them (skins, morph targets, materials, textures, extras), without animations, cameras or lights.
Sourcepub const LIGHT: Keep
pub const LIGHT: Keep
Keep::MESHES without reading the images: textures stay, as references to their
images (see Keep::image_bytes).
Sourcepub const fn with_animations(self, animations: bool) -> Self
pub const fn with_animations(self, animations: bool) -> Self
With Keep::animations set to animations.
Sourcepub const fn with_skins(self, skins: bool) -> Self
pub const fn with_skins(self, skins: bool) -> Self
With Keep::skins set to skins.
Sourcepub const fn with_morph_targets(self, morph_targets: bool) -> Self
pub const fn with_morph_targets(self, morph_targets: bool) -> Self
With Keep::morph_targets set to morph_targets.
Sourcepub const fn with_materials(self, materials: bool) -> Self
pub const fn with_materials(self, materials: bool) -> Self
With Keep::materials set to materials.
Sourcepub const fn with_textures(self, textures: bool) -> Self
pub const fn with_textures(self, textures: bool) -> Self
With Keep::textures set to textures.
Sourcepub const fn with_image_bytes(self, image_bytes: bool) -> Self
pub const fn with_image_bytes(self, image_bytes: bool) -> Self
With Keep::image_bytes set to image_bytes.
Sourcepub const fn with_cameras(self, cameras: bool) -> Self
pub const fn with_cameras(self, cameras: bool) -> Self
With Keep::cameras set to cameras.
Sourcepub const fn with_lights(self, lights: bool) -> Self
pub const fn with_lights(self, lights: bool) -> Self
With Keep::lights set to lights.
Sourcepub const fn with_extras(self, extras: bool) -> Self
pub const fn with_extras(self, extras: bool) -> Self
With Keep::extras set to extras.
Sourcepub const fn with_max_triangles(self, max_triangles: usize) -> Self
pub const fn with_max_triangles(self, max_triangles: usize) -> Self
With Keep::max_triangles set to max_triangles.
Sourcepub const fn with_lines_and_points(self, lines_and_points: bool) -> Self
pub const fn with_lines_and_points(self, lines_and_points: bool) -> Self
With Keep::lines_and_points set to lines_and_points.
Sourcepub const fn with_max_points(self, max_points: usize) -> Self
pub const fn with_max_points(self, max_points: usize) -> Self
With Keep::max_points set to max_points.
Sourcepub const fn with_threads(self, threads: usize) -> Self
pub const fn with_threads(self, threads: usize) -> Self
With Keep::threads set to threads.
Trait Implementations§
impl Copy for Keep
impl Eq for Keep
impl StructuralPartialEq for Keep
Auto Trait Implementations§
impl Forget for Keep
impl Freeze for Keep
impl Move for Keep
impl RefUnwindSafe for Keep
impl Send for Keep
impl Sync for Keep
impl Unpin for Keep
impl UnsafeUnpin for Keep
impl UnwindSafe for Keep
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.