pub struct Scene3d { /* private fields */ }Expand description
Ready 3D visual state rendered with one camera and depth attachment.
Implementations§
Source§impl Scene3d
impl Scene3d
Sourcepub fn new(background: Color) -> Result<Self, Scene3dError>
pub fn new(background: Color) -> Result<Self, Scene3dError>
Creates an empty scene with a normalized opaque clear color.
Sourcepub fn with_budget(
background: Color,
budget: Scene3dBudget,
) -> Result<Self, Scene3dError>
pub fn with_budget( background: Color, budget: Scene3dBudget, ) -> Result<Self, Scene3dError>
Creates a lazily allocated scene with explicit live-resource limits.
Sourcepub fn with_alpha_background(background: Color) -> Result<Self, Scene3dError>
pub fn with_alpha_background(background: Color) -> Result<Self, Scene3dError>
Creates an empty scene with a normalized straight-linear RGBA clear color. Offscreen clear RGB is premultiplied; transparent black preserves alpha for later target composition. This explicit API accepts alpha below one.
Sourcepub fn with_alpha_background_and_budget(
background: Color,
budget: Scene3dBudget,
) -> Result<Self, Scene3dError>
pub fn with_alpha_background_and_budget( background: Color, budget: Scene3dBudget, ) -> Result<Self, Scene3dError>
Creates an alpha-capable offscreen scene with explicit resource limits.
Sourcepub fn set_lighting(&mut self, lighting: Lighting3d)
pub fn set_lighting(&mut self, lighting: Lighting3d)
Replaces validated ambient and directional scene illumination.
Sourcepub const fn lighting(&self) -> Lighting3d
pub const fn lighting(&self) -> Lighting3d
Returns scene illumination; surfaces remain Unlit unless explicitly opted in.
Sourcepub fn set_fog(&mut self, fog: Option<Fog3d>)
pub fn set_fog(&mut self, fog: Option<Fog3d>)
Replaces or disables camera-forward distance fog without changing topology.
Sourcepub const fn fog(&self) -> Option<Fog3d>
pub const fn fog(&self) -> Option<Fog3d>
Returns optional scene fog; only explicitly participating surfaces use it.
Sourcepub fn try_push(
&mut self,
mesh: &RetainedMesh3d,
transform: Transform3d,
style: MeshStyle3d,
) -> Result<Object3dId, Scene3dError>
pub fn try_push( &mut self, mesh: &RetainedMesh3d, transform: Transform3d, style: MeshStyle3d, ) -> Result<Object3dId, Scene3dError>
Adds a retained object and returns a stable handle for later updates.
Sourcepub const fn background(&self) -> Color
pub const fn background(&self) -> Color
Returns the normalized straight-linear RGBA target clear color.
Sourcepub fn set_background(&mut self, background: Color) -> Result<(), Scene3dError>
pub fn set_background(&mut self, background: Color) -> Result<(), Scene3dError>
Changes only the normalized straight-linear RGBA clear color, accepting
alpha in 0..=1 even on a scene created with the opaque constructor.
This explicit mutation performs no allocation, geometry update or upload;
IDs, resources, capacities, materials and the environment are untouched.
Non-finite or out-of-range channels return InvalidBackground without
changing the previous color. Rendering premultiplies clear RGB exactly
as it does for with_alpha_background.
Sourcepub fn instances(&self) -> &[Mesh3dInstance]
pub fn instances(&self) -> &[Mesh3dInstance]
Returns objects in host insertion order; depth determines visibility.
Sourcepub fn object_count(&self) -> usize
pub fn object_count(&self) -> usize
Returns the number of independently transformed objects.
Sourcepub const fn budget(&self) -> Scene3dBudget
pub const fn budget(&self) -> Scene3dBudget
Returns the configured simultaneous-live and retained-capacity limits.
Sourcepub fn statistics(&self) -> Scene3dStatistics
pub fn statistics(&self) -> Scene3dStatistics
Returns deduplicated allocation accounting in constant time without allocating scratch.
Sourcepub fn instance(
&self,
object_id: Object3dId,
) -> Result<&Mesh3dInstance, Scene3dError>
pub fn instance( &self, object_id: Object3dId, ) -> Result<&Mesh3dInstance, Scene3dError>
Resolves a live scene-provenance-checked handle in constant time.
Sourcepub fn remove(
&mut self,
object_id: Object3dId,
) -> Result<Mesh3dInstance, Scene3dError>
pub fn remove( &mut self, object_id: Object3dId, ) -> Result<Mesh3dInstance, Scene3dError>
Removes an object, preserving survivor IDs and insertion order.
Removal shifts dense storage in O(N); transform/style/visibility lookups remain O(1). Lookup slots are reused with never-repeated numeric IDs. The returned instance owns its retired mesh reference. Dropping it releases that reference, not necessarily in-flight driver memory.
Sourcepub fn set_texture_material(
&mut self,
object_id: Object3dId,
material: Option<&TextureMaterial3d>,
) -> Result<Scene3dMeshUpdateReport, Scene3dError>
pub fn set_texture_material( &mut self, object_id: Object3dId, material: Option<&TextureMaterial3d>, ) -> Result<Scene3dMeshUpdateReport, Scene3dError>
Attaches/replaces (Some) or removes (None) only this object’s texture
material, sharing all existing topology and attribute buffers. There are
no geometry/texture uploads, GPU allocations or GPU copies. Existing mesh
aliases and other objects retain their materials; IDs, transform, style,
visibility and reserved mesh capacity are unchanged.
Rebinding validates object provenance, texture device ownership, UVs and
final scene resource/storage limits before publication. Fallible scene
bookkeeping reservation may be needed. The returned report uses the same
unique old-plus-incoming overlap accounting as set_mesh; it does not
impose a new peak limit or promise immediate in-flight GPU retirement.
Detaching retains UVs for later rebinding and does not create geometry.
Sourcepub fn set_mesh(
&mut self,
object_id: Object3dId,
mesh: &RetainedMesh3d,
) -> Result<Scene3dMeshUpdateReport, Scene3dError>
pub fn set_mesh( &mut self, object_id: Object3dId, mesh: &RetainedMesh3d, ) -> Result<Scene3dMeshUpdateReport, Scene3dError>
Rebinds only this object to an immutable mesh after complete validation.
Shared users of the old mesh are unchanged. Transform, style, visibility and ID survive. The accepted resource limits apply to final scene state; replacement overlap is at most old plus incoming mesh and is reported. Synchronous errors preserve all live visual state. In-flight submissions retain their old GPU references; no immediate driver retirement is promised.
Sourcepub fn visible_object_count(&self) -> usize
pub fn visible_object_count(&self) -> usize
Returns the number of objects currently participating in rendering in constant time.
Sourcepub fn set_transform(
&mut self,
object_id: Object3dId,
transform: Transform3d,
) -> Result<(), Scene3dError>
pub fn set_transform( &mut self, object_id: Object3dId, transform: Transform3d, ) -> Result<(), Scene3dError>
Replaces one object’s model transform without touching retained topology.
Sourcepub fn set_style(
&mut self,
object_id: Object3dId,
style: MeshStyle3d,
) -> Result<(), Scene3dError>
pub fn set_style( &mut self, object_id: Object3dId, style: MeshStyle3d, ) -> Result<(), Scene3dError>
Replaces one object’s complete extensible visual material bundle.
Sourcepub fn set_visible(
&mut self,
object_id: Object3dId,
visible: bool,
) -> Result<(), Scene3dError>
pub fn set_visible( &mut self, object_id: Object3dId, visible: bool, ) -> Result<(), Scene3dError>
Shows or hides one object without releasing retained topology.
Sourcepub fn set_wireframe(
&mut self,
object_id: Object3dId,
wireframe: Option<WireframeStyle3d>,
) -> Result<(), Scene3dError>
pub fn set_wireframe( &mut self, object_id: Object3dId, wireframe: Option<WireframeStyle3d>, ) -> Result<(), Scene3dError>
Enables or disables explicit visible/hidden edges for one object.