pub struct Scene { /* private fields */ }Implementations§
Source§impl Scene
impl Scene
pub fn add_anchor( &mut self, anchor: AnchorFrame, ) -> Result<AnchorKey, ConnectionError>
pub fn anchor(&self, anchor: AnchorKey) -> Result<&AnchorFrame, ConnectionError>
pub fn anchor_named(&self, name: &str) -> Result<AnchorKey, ConnectionError>
Source§impl Scene
impl Scene
pub fn set_annotation_anchor( &mut self, anchor: AnnotationAnchor, ) -> Result<(), LookupError>
pub fn clear_annotation_anchor(&mut self, id: &str) -> bool
pub fn annotation_anchor(&self, id: &str) -> Option<&AnnotationAnchor>
pub fn annotation_anchors(&self) -> impl Iterator<Item = &AnnotationAnchor>
pub fn annotation_projection_report( &self, camera: CameraKey, viewport_width: u32, viewport_height: u32, ) -> Result<AnnotationProjectionReportV1, LookupError>
pub fn annotation_projection_report_with_node_handles( &self, camera: CameraKey, viewport_width: u32, viewport_height: u32, node_handles: &BTreeMap<NodeKey, u64>, ) -> Result<AnnotationProjectionReportV1, LookupError>
Source§impl Scene
impl Scene
pub fn add_callout<F: AssetFetcher>( &mut self, assets: &Assets<F>, callout: Callout, ) -> Result<CalloutReport, LookupError>
pub fn clear_callout(&mut self, id: &str) -> bool
pub fn callout(&self, id: &str) -> Option<CalloutReport>
Source§impl Scene
impl Scene
pub fn add_clipping_plane(&mut self, plane: ClippingPlane) -> ClippingPlaneKey
pub fn clipping_plane(&self, plane: ClippingPlaneKey) -> Option<ClippingPlane>
pub fn set_clipping_planes( &mut self, set: ClippingPlaneSet, ) -> Result<(), LookupError>
pub fn clipping_planes(&self) -> &ClippingPlaneSet
pub fn set_section_box( &mut self, section: SectionBox, ) -> Result<bool, LookupError>
pub fn clear_section_box(&mut self) -> bool
pub fn invert_section_box( &mut self, inverted: bool, ) -> Result<bool, LookupError>
pub fn section_box(&self) -> Option<SectionBox>
pub fn section_box_planes(&self) -> Option<Vec<ClippingPlane>>
Source§impl Scene
impl Scene
pub fn connect_import_connectors( &mut self, source_import: &SceneImport, source_name: &str, target_import: &SceneImport, target_name: &str, options: ConnectOptions, ) -> Result<ConnectionPreview, ConnectionError>
Sourcepub fn mate(
&mut self,
source: &SceneImport,
source_name: &str,
target: &SceneImport,
target_name: &str,
) -> Result<ConnectionPreview, ConnectionError>
pub fn mate( &mut self, source: &SceneImport, source_name: &str, target: &SceneImport, target_name: &str, ) -> Result<ConnectionPreview, ConnectionError>
Mate two imported parts by named connector using default options.
Short form of Self::connect_import_connectors with ConnectOptions::default.
For non-default alignment, roll policy, or mate offset, call the full form directly.
Source§impl Scene
impl Scene
pub fn lock_node_for_connections( &mut self, node: NodeKey, ) -> Result<(), ConnectionError>
pub fn unlock_node_for_connections( &mut self, node: NodeKey, ) -> Result<(), ConnectionError>
pub fn node_connections_locked( &self, node: NodeKey, ) -> Result<bool, ConnectionError>
Source§impl Scene
impl Scene
pub fn preview_connector_magnet( &self, source: ConnectorFrame, target: ConnectorFrame, options: ConnectOptions, ) -> Result<ConnectionMagnetPreview, ConnectionError>
Source§impl Scene
impl Scene
pub fn add_connector( &mut self, connector: ConnectorFrame, ) -> Result<ConnectorKey, ConnectionError>
pub fn connector( &self, connector: ConnectorKey, ) -> Result<&ConnectorFrame, ConnectionError>
pub fn connector_named( &self, name: &str, ) -> Result<ConnectorKey, ConnectionError>
pub fn validate_connections( &self, requests: &[ConnectionRequest], ) -> Result<Vec<ConnectionPreview>, ConnectionError>
pub fn connect_by_key( &mut self, source: ConnectorKey, target: ConnectorKey, options: ConnectOptions, ) -> Result<ConnectionPreview, ConnectionError>
pub fn preview_connection( &self, source: ConnectorFrame, target: ConnectorFrame, options: ConnectOptions, ) -> Result<ConnectionPreview, ConnectionError>
pub fn connect( &mut self, source: ConnectorFrame, target: ConnectorFrame, options: ConnectOptions, ) -> Result<ConnectionPreview, ConnectionError>
Source§impl Scene
impl Scene
pub fn dirty_state(&self) -> SceneDirtyState
Source§impl Scene
impl Scene
Sourcepub fn add_grid_floor<F>(
&mut self,
assets: &Assets<F>,
options: GridFloorOptions,
) -> Result<GridFloorHandles, LookupError>
pub fn add_grid_floor<F>( &mut self, assets: &Assets<F>, options: GridFloorOptions, ) -> Result<GridFloorHandles, LookupError>
Adds a matte grid floor sized from GridFloorOptions.
§Errors
Returns LookupError::InvalidFramingOption if the floor options are
invalid and LookupError::NodeNotFound if the floor mesh nodes cannot
be inserted under the scene root.
Source§impl Scene
impl Scene
Sourcepub fn add_perspective_camera_default_for(
&mut self,
bounds: Aabb,
viewport: (u32, u32),
) -> Result<CameraKey, LookupError>
pub fn add_perspective_camera_default_for( &mut self, bounds: Aabb, viewport: (u32, u32), ) -> Result<CameraKey, LookupError>
Adds a standard perspective camera under the scene root and frames it to bounds.
The helper is the scene-level equivalent of the viewer default: callers provide
world-space bounds and a target viewport, and scena creates an active camera using
PerspectiveCamera::standard plus Scene::frame_bounds. It does not prepare
renderer resources, upload GPU data, fetch assets, or render a frame.
§Examples
use scena::{Aabb, Scene, Vec3};
let mut scene = Scene::new();
let bounds = Aabb::new(Vec3::new(-1.0, -0.5, -0.5), Vec3::new(1.0, 0.5, 0.5));
let camera = scene
.add_perspective_camera_default_for(bounds, (1280, 720))
.unwrap();
assert_eq!(scene.active_camera(), Some(camera));§Errors
Returns LookupError::InvalidViewport when either viewport dimension is zero,
LookupError::InvalidBounds or LookupError::ImportHasNoBounds for invalid
bounds, and the same insertion/framing errors as Scene::add_perspective_camera
and Scene::frame_bounds.
Sourcepub fn frame_bounds(
&mut self,
camera: CameraKey,
bounds: Aabb,
options: FramingOptions,
) -> Result<FramingOutcome, LookupError>
pub fn frame_bounds( &mut self, camera: CameraKey, bounds: Aabb, options: FramingOptions, ) -> Result<FramingOutcome, LookupError>
Fits a perspective camera to world-space bounds without preparing or rendering.
The camera is moved so the projected AABB fits the requested viewport fill and margin. This mutates scene camera state and marks the camera transform dirty; it does not prepare renderer resources, upload GPU data, fetch assets, or render a frame.
This writes crate::PerspectiveCamera::aspect from
FramingOptions::viewport. Any pre-existing aspect on the camera is
ignored so the solved camera pose matches the actual target viewport.
§Examples
use scena::{Aabb, FramingOptions, OrbitControls, PerspectiveCamera, Scene, Transform, Vec3};
let mut scene = Scene::new();
let camera = scene
.add_perspective_camera(scene.root(), PerspectiveCamera::default(), Transform::default())
.unwrap();
let bounds = Aabb::new(Vec3::new(-1.0, -0.5, -0.5), Vec3::new(1.0, 0.5, 0.5));
let framing = scene
.frame_bounds(
camera,
bounds,
FramingOptions::new()
.isometric()
.fill(0.72)
.margin_px(48.0)
.viewport(1280, 720),
)
.unwrap();
let controls = OrbitControls::from_framing(framing);§Errors
Returns LookupError::CameraNotFound when camera is missing,
LookupError::UnsupportedCameraType for non-perspective cameras,
LookupError::InvalidBounds for empty or non-projectable bounds, and
LookupError::InvalidFramingOption for invalid viewport, fill, margin,
or direction options.
Sourcepub fn project_world_point(
&self,
camera: CameraKey,
world_position: Vec3,
viewport_width: u32,
viewport_height: u32,
) -> Result<Option<ProjectedPoint>, LookupError>
pub fn project_world_point( &self, camera: CameraKey, world_position: Vec3, viewport_width: u32, viewport_height: u32, ) -> Result<Option<ProjectedPoint>, LookupError>
Projects a world-space point through a scene camera into viewport pixels.
Returns Ok(None) when the point is outside the camera frustum or
behind the camera.
§Errors
Returns LookupError::InvalidViewport when either viewport dimension
is zero and LookupError::CameraNotFound when camera is missing.
Sourcepub fn bounds_for_transforms<F>(
&self,
node: NodeKey,
transforms: &[Transform],
assets: &Assets<F>,
) -> Result<Aabb, LookupError>
pub fn bounds_for_transforms<F>( &self, node: NodeKey, transforms: &[Transform], assets: &Assets<F>, ) -> Result<Aabb, LookupError>
Computes union bounds for the same node evaluated at multiple transforms.
This is useful for replay/animation setup where a camera or floor must contain every sampled pose, not only the current transform.
§Errors
Returns LookupError::NodeNotFound when node is missing,
LookupError::InvalidFramingOption when transforms is empty, and
LookupError::ImportHasNoBounds when the node subtree has no
renderable bounds.
Source§impl Scene
impl Scene
pub fn instantiate( &mut self, scene_asset: &SceneAsset, ) -> Result<SceneImport, InstantiateError>
pub fn instantiate_with( &mut self, scene_asset: &SceneAsset, options: ImportOptions, ) -> Result<SceneImport, InstantiateError>
pub fn instantiate_under( &mut self, parent: NodeKey, scene_asset: &SceneAsset, options: ImportOptions, ) -> Result<SceneImport>
Source§impl Scene
impl Scene
pub async fn import<F: AssetFetcher>( &mut self, assets: &Assets<F>, path: impl Into<AssetPath>, ) -> Result<SceneImport, ImportError>
pub async fn import_with<F: AssetFetcher>( &mut self, assets: &Assets<F>, path: impl Into<AssetPath>, options: ImportOptions, ) -> Result<SceneImport, ImportError>
pub fn replace_import( &mut self, import: &SceneImport, scene_asset: &SceneAsset, ) -> Result<SceneImport, InstantiateError>
Source§impl Scene
impl Scene
Sourcepub fn set_active_variant(
&mut self,
import: &SceneImport,
name: Option<&str>,
) -> Result<(), LookupError>
pub fn set_active_variant( &mut self, import: &SceneImport, name: Option<&str>, ) -> Result<(), LookupError>
Phase 2B step 3: activate a KHR_materials_variants variant by
name, updating every imported mesh node’s MeshNode::material
to the variant’s bound MaterialHandle and reverting to the
primitive default for unmapped variants. Pass None to clear
the active variant and restore every default material. Returns
LookupError::VariantNotFound when name is not declared by
the source asset; the active variant slot remains unchanged in
that case.
Source§impl Scene
impl Scene
pub fn inspect(&self) -> SceneInspectionReport
pub fn inspect_with_assets<F>( &self, assets: &Assets<F>, ) -> SceneInspectionReport
Source§impl Scene
impl Scene
pub fn hide(&mut self, node: NodeKey) -> Result<(), LookupError>
pub fn show(&mut self, node: NodeKey) -> Result<(), LookupError>
pub fn toggle_visibility(&mut self, node: NodeKey) -> Result<bool, LookupError>
pub fn show_only( &mut self, nodes: impl IntoIterator<Item = NodeKey>, ) -> Result<SceneVisibilitySnapshot, LookupError>
pub fn isolate( &mut self, nodes: impl IntoIterator<Item = NodeKey>, ) -> Result<SceneVisibilitySnapshot, LookupError>
pub fn restore_visibility( &mut self, snapshot: &SceneVisibilitySnapshot, ) -> Result<(), LookupError>
pub fn ghost( &mut self, node: NodeKey, alpha: f32, ) -> Result<SceneTintSnapshot, LookupError>
pub fn ghost_with_tint( &mut self, node: NodeKey, tint: Color, ) -> Result<SceneTintSnapshot, LookupError>
pub fn restore_tints( &mut self, snapshot: &SceneTintSnapshot, ) -> Result<(), LookupError>
pub fn fit_selection_with_assets<F>( &mut self, camera: CameraKey, nodes: impl IntoIterator<Item = NodeKey>, assets: &Assets<F>, ) -> Result<Aabb, LookupError>
pub fn add_bounding_box_overlay<F>( &mut self, assets: &Assets<F>, node: NodeKey, ) -> Result<InspectionHelperReport, LookupError>
pub fn add_world_axes_triad<F>( &mut self, assets: &Assets<F>, length: f32, ) -> Result<InspectionHelperReport, LookupError>
pub fn add_local_axes_triad<F>( &mut self, assets: &Assets<F>, node: NodeKey, length: f32, ) -> Result<InspectionHelperReport, LookupError>
pub fn inspection_toolkit_report(&self) -> InspectionToolkitReport
Source§impl Scene
impl Scene
pub fn add_instance_set( &mut self, parent: NodeKey, geometry: GeometryHandle, material: MaterialHandle, transform: Transform, ) -> Result<InstanceSetKey, LookupError>
pub fn add_instance_set_node( &mut self, parent: NodeKey, geometry: GeometryHandle, material: MaterialHandle, transform: Transform, ) -> Result<(NodeKey, InstanceSetKey), LookupError>
pub fn instance_set(&self, instance_set: InstanceSetKey) -> Option<&InstanceSet>
pub fn reserve_instances( &mut self, instance_set: InstanceSetKey, additional: usize, ) -> Result<(), LookupError>
pub fn push_instance( &mut self, instance_set: InstanceSetKey, transform: Transform, ) -> Result<InstanceId, LookupError>
pub fn set_instance_transform( &mut self, instance_set: InstanceSetKey, instance: InstanceId, transform: Transform, ) -> Result<(), LookupError>
pub fn set_instance_visible( &mut self, instance_set: InstanceSetKey, instance: InstanceId, visible: bool, ) -> Result<(), LookupError>
pub fn set_instance_tint( &mut self, instance_set: InstanceSetKey, instance: InstanceId, tint: Option<Color>, ) -> Result<(), LookupError>
pub fn remove_instance( &mut self, instance_set: InstanceSetKey, instance: InstanceId, ) -> Result<Option<Instance>, LookupError>
pub fn clear_instances( &mut self, instance_set: InstanceSetKey, ) -> Result<(), LookupError>
Source§impl Scene
impl Scene
pub fn add_label( &mut self, parent: NodeKey, label: LabelDesc, transform: Transform, ) -> Result<LabelKey, LookupError>
pub fn label(&self, label: LabelKey) -> Option<&LabelDesc>
pub fn set_label_text( &mut self, label: LabelKey, text: impl Into<String>, ) -> Result<(), LookupError>
Source§impl Scene
impl Scene
pub fn light(&self, light: LightKey) -> Option<&Light>
pub fn directional_light(&mut self, light: DirectionalLight) -> LightBuilder<'_>
Sourcepub fn add_studio_lighting(
&mut self,
) -> Result<StudioLightingHandles, LookupError>
pub fn add_studio_lighting( &mut self, ) -> Result<StudioLightingHandles, LookupError>
Inserts a studio-style three-point directional rig.
The rig contains a key light, cool fill, and warm rim light. The returned handles are ordered as key, fill, and rim so callers can adjust or remove individual lights after insertion. Intensities are tuned for neutral glTF product/model-viewer scenes without over-exposing PBR metallic body materials.
This preset uses moderate intensities (key 13,500 lux, fill 4,500 lux, rim 3,500 lux). Only the key casts shadows because the renderer supports one shadowed directional light per scene.
§Errors
Returns a LookupError if the scene cannot insert one of the light
nodes under the root.
pub fn point_light(&mut self, light: PointLight) -> LightBuilder<'_>
pub fn spot_light(&mut self, light: SpotLight) -> LightBuilder<'_>
pub fn area_light(&mut self, light: AreaLight) -> LightBuilder<'_>
Source§impl Scene
impl Scene
pub fn set_mesh_lods( &mut self, node: NodeKey, levels: Vec<MeshLodLevel>, ) -> Result<(), LookupError>
Source§impl Scene
impl Scene
pub fn set_mesh_material( &mut self, node: NodeKey, material: MaterialHandle, ) -> Result<(), LookupError>
pub fn set_node_tint( &mut self, node: NodeKey, tint: Option<Color>, ) -> Result<(), LookupError>
pub fn node_tint(&self, node: NodeKey) -> Result<Option<Color>, LookupError>
Source§impl Scene
impl Scene
pub fn add_measurement_overlay<F>( &mut self, assets: &Assets<F>, overlay: MeasurementOverlay, ) -> Result<MeasurementOverlayReport, LookupError>
pub fn clear_measurement_overlay(&mut self, id: &str) -> bool
Source§impl Scene
impl Scene
Sourcepub fn create_animation_mixer(
&mut self,
import: &SceneImport,
clip_name: &str,
) -> Result<AnimationMixerKey, AnimationError>
pub fn create_animation_mixer( &mut self, import: &SceneImport, clip_name: &str, ) -> Result<AnimationMixerKey, AnimationError>
Creates a paused mixer for a named imported animation clip.
Returns the mixer key without starting playback. For the one-call “play
this now” path, use Self::play_animation_by_name.
Sourcepub fn play_animation_by_name(
&mut self,
import: &SceneImport,
clip_name: &str,
) -> Result<AnimationMixerKey, AnimationError>
pub fn play_animation_by_name( &mut self, import: &SceneImport, clip_name: &str, ) -> Result<AnimationMixerKey, AnimationError>
Creates and starts a mixer for a named imported animation clip.
This is the one-call path for “play this clip now”. The returned
mixer key can still be passed to Self::update_animation,
Self::set_animation_loop_mode, Self::set_animation_speed,
pause, seek, and stop helpers.
§Examples
let assets = Assets::new();
let model = assets.load_scene("machine.glb").await?;
let mut scene = Scene::new();
let import = scene.instantiate(&model)?;
let mixer = scene.play_animation_by_name(&import, "idle")?;
scene.update_animation(mixer, 1.0 / 60.0)?;Creates a paused mixer for a caller-authored animation clip.
Authored clips are not tied to a glTF import lifecycle, so the mixer is
not invalidated by import replacement. The host still owns ticking by
calling Self::update_animation or explicit sampling with
Self::seek_animation.
Creates and starts a mixer for a caller-authored animation clip.
Sourcepub fn animation_mixer(
&self,
mixer: AnimationMixerKey,
) -> Result<&AnimationMixer, AnimationError>
pub fn animation_mixer( &self, mixer: AnimationMixerKey, ) -> Result<&AnimationMixer, AnimationError>
Borrows the mixer state for a given key.
Sourcepub fn play_animation(
&mut self,
mixer: AnimationMixerKey,
) -> Result<(), AnimationError>
pub fn play_animation( &mut self, mixer: AnimationMixerKey, ) -> Result<(), AnimationError>
Starts the mixer; resumes from the current time if it was paused.
Sourcepub fn pause_animation(
&mut self,
mixer: AnimationMixerKey,
) -> Result<(), AnimationError>
pub fn pause_animation( &mut self, mixer: AnimationMixerKey, ) -> Result<(), AnimationError>
Pauses the mixer at its current time. The next
Self::play_animation resumes from the same time.
Sourcepub fn stop_animation(
&mut self,
mixer: AnimationMixerKey,
) -> Result<(), AnimationError>
pub fn stop_animation( &mut self, mixer: AnimationMixerKey, ) -> Result<(), AnimationError>
Stops the mixer and snaps the animated nodes back to time zero.
Sourcepub fn seek_animation(
&mut self,
mixer: AnimationMixerKey,
time_seconds: f32,
) -> Result<(), AnimationError>
pub fn seek_animation( &mut self, mixer: AnimationMixerKey, time_seconds: f32, ) -> Result<(), AnimationError>
Seeks the mixer to a specific time in seconds and applies the resulting pose to the animated nodes.
Sourcepub fn set_animation_speed(
&mut self,
mixer: AnimationMixerKey,
speed: f32,
) -> Result<(), AnimationError>
pub fn set_animation_speed( &mut self, mixer: AnimationMixerKey, speed: f32, ) -> Result<(), AnimationError>
Sets the playback speed multiplier. 1.0 is real-time; negative values
play the clip in reverse.
Sourcepub fn set_animation_loop_mode(
&mut self,
mixer: AnimationMixerKey,
loop_mode: AnimationLoopMode,
) -> Result<(), AnimationError>
pub fn set_animation_loop_mode( &mut self, mixer: AnimationMixerKey, loop_mode: AnimationLoopMode, ) -> Result<(), AnimationError>
Sets the loop mode (loop, once, ping-pong).
Sourcepub fn update_animation(
&mut self,
mixer: AnimationMixerKey,
delta_seconds: f32,
) -> Result<(), AnimationError>
pub fn update_animation( &mut self, mixer: AnimationMixerKey, delta_seconds: f32, ) -> Result<(), AnimationError>
Advances the mixer by delta_seconds and applies the resulting pose to
animated nodes. Hosts are expected to call this once per frame for
every active mixer.
Source§impl Scene
impl Scene
pub fn morph_weights(&self, node: NodeKey) -> Option<&[f32]>
pub fn set_morph_weights( &mut self, node: NodeKey, weights: impl Into<Vec<f32>>, ) -> Result<(), LookupError>
Source§impl Scene
impl Scene
pub fn set_origin_shift(&mut self, origin_shift: Vec3)
pub fn origin_shift(&self) -> Vec3
Source§impl Scene
impl Scene
pub fn add_particle_set( &mut self, parent: NodeKey, particles: ParticleSet, transform: Transform, ) -> Result<ParticleSetKey, LookupError>
pub fn add_particle_set_node( &mut self, parent: NodeKey, particles: ParticleSet, transform: Transform, ) -> Result<(NodeKey, ParticleSetKey), LookupError>
pub fn particle_set(&self, particle_set: ParticleSetKey) -> Option<&ParticleSet>
pub fn set_particle_set( &mut self, particle_set: ParticleSetKey, replacement: ParticleSet, ) -> Result<(), LookupError>
Source§impl Scene
impl Scene
pub fn pick( &self, camera: CameraKey, cursor: CursorPosition, viewport: Viewport, ) -> Result<Option<Hit>, LookupError>
pub fn pick_with_assets<F>( &self, camera: CameraKey, cursor: CursorPosition, viewport: Viewport, assets: &Assets<F>, ) -> Result<Option<Hit>, LookupError>
pub fn pick_pointer( &self, camera: CameraKey, physical_x: f32, physical_y: f32, physical_width: u32, physical_height: u32, device_pixel_ratio: f32, ) -> Result<Option<Hit>, LookupError>
pub fn pick_and_select( &mut self, camera: CameraKey, physical_x: f32, physical_y: f32, physical_width: u32, physical_height: u32, device_pixel_ratio: f32, ) -> Result<Option<Hit>, LookupError>
pub fn pick_and_select_with_assets<F>( &mut self, camera: CameraKey, cursor: CursorPosition, viewport: Viewport, assets: &Assets<F>, ) -> Result<Option<Hit>, LookupError>
pub fn pick_and_hover( &mut self, camera: CameraKey, physical_x: f32, physical_y: f32, physical_width: u32, physical_height: u32, device_pixel_ratio: f32, ) -> Result<Option<Hit>, LookupError>
pub fn pick_and_hover_with_assets<F>( &mut self, camera: CameraKey, cursor: CursorPosition, viewport: Viewport, assets: &Assets<F>, ) -> Result<Option<Hit>, LookupError>
pub fn set_hover_target(&mut self, target: Option<HitTarget>)
pub fn set_primary_selection_target(&mut self, target: Option<HitTarget>)
pub fn interaction(&self) -> &InteractionContext
pub fn interaction_mut(&mut self) -> &mut InteractionContext
Source§impl Scene
impl Scene
Sourcepub fn remove_node(&mut self, node: NodeKey) -> Result<(), LookupError>
pub fn remove_node(&mut self, node: NodeKey) -> Result<(), LookupError>
Removes node and its descendants from the scene graph.
The root node is permanent and cannot be removed. Removing a subtree also drops node-owned cameras, lights, labels, instance sets, bounds, morph weights, skin bindings, anchors, measurements, and connectors that point at the removed nodes.
Sourcepub fn remove_import(&mut self, import: &SceneImport) -> Result<(), LookupError>
pub fn remove_import(&mut self, import: &SceneImport) -> Result<(), LookupError>
Removes every root owned by an import and marks the import stale.
Source§impl Scene
impl Scene
pub fn skin_binding(&self, node: NodeKey) -> Option<&SceneSkinBinding>
pub fn skin_matrices(&self, node: NodeKey) -> Option<Vec<SkinningMatrix>>
pub fn set_skin_binding( &mut self, node: NodeKey, binding: SceneSkinBinding, ) -> Result<(), LookupError>
Source§impl Scene
impl Scene
pub fn set_transform( &mut self, node: NodeKey, transform: Transform, ) -> Result<(), LookupError>
pub fn set_transforms( &mut self, transforms: &[(NodeKey, Transform)], ) -> Result<(), LookupError>
pub fn world_transform(&self, node: NodeKey) -> Option<Transform>
Source§impl Scene
impl Scene
Sourcepub fn camera_node(&self, camera: CameraKey) -> Option<NodeKey>
pub fn camera_node(&self, camera: CameraKey) -> Option<NodeKey>
Returns the scene node that owns a camera descriptor.
Sourcepub fn frame(
&mut self,
camera: CameraKey,
bounds: Aabb,
) -> Result<(), LookupError>
pub fn frame( &mut self, camera: CameraKey, bounds: Aabb, ) -> Result<(), LookupError>
Frames bounds with the selected camera and tightens the camera depth range.
Sourcepub fn add_default_camera(&mut self) -> Result<CameraKey, LookupError>
pub fn add_default_camera(&mut self) -> Result<CameraKey, LookupError>
Adds a perspective camera under the root and makes it active.
Sourcepub fn with_default_camera() -> Result<(Self, CameraKey), LookupError>
pub fn with_default_camera() -> Result<(Self, CameraKey), LookupError>
Convenience constructor returning a fresh Scene plus a default
active camera in one call. The renderer-as-library analog of
Three.js’s new THREE.Scene() + camera one-liner: callers who
only need a default perspective camera framed at z=2 can drop the
two-step Scene::new() + add_default_camera() boilerplate.
Closes scena-api-ergonomics-reviewer Phase 6 finding F1.
Sourcepub fn frame_import(
&mut self,
camera: CameraKey,
import: &SceneImport,
) -> Result<(), LookupError>
pub fn frame_import( &mut self, camera: CameraKey, import: &SceneImport, ) -> Result<(), LookupError>
Frames the world-space bounds of an imported scene.
Sourcepub fn frame_all(&mut self, camera: CameraKey) -> Result<(), LookupError>
pub fn frame_all(&mut self, camera: CameraKey) -> Result<(), LookupError>
Frames all currently visible mesh bounds known to the scene.
Sourcepub fn frame_all_with_assets<F>(
&mut self,
camera: CameraKey,
assets: &Assets<F>,
) -> Result<(), LookupError>
pub fn frame_all_with_assets<F>( &mut self, camera: CameraKey, assets: &Assets<F>, ) -> Result<(), LookupError>
Frames all visible mesh and instance bounds, resolving direct geometry handles through
Assets.
Sourcepub fn frame_all_with_overlays<F>(
&mut self,
camera: CameraKey,
assets: &Assets<F>,
viewport_width: u32,
viewport_height: u32,
) -> Result<FramingOutcome, LookupError>
pub fn frame_all_with_overlays<F>( &mut self, camera: CameraKey, assets: &Assets<F>, viewport_width: u32, viewport_height: u32, ) -> Result<FramingOutcome, LookupError>
Frames visible scene content plus overlay anchors with enough viewport margin for screen-aligned label glyphs.
This is intended for documentation, callout, and measurement captures where the generated leader lines are part of the scene bounds but the label glyphs are screen-space billboards. The helper keeps the camera solve geometric and only reserves pixel margin derived from visible label metrics.
Sourcepub fn frame_node(
&mut self,
camera: CameraKey,
node: NodeKey,
) -> Result<(), LookupError>
pub fn frame_node( &mut self, camera: CameraKey, node: NodeKey, ) -> Result<(), LookupError>
Frames the world-space bounds of a node and any bounded descendants.
Sourcepub fn frame_node_with_assets<F>(
&mut self,
camera: CameraKey,
node: NodeKey,
assets: &Assets<F>,
) -> Result<(), LookupError>
pub fn frame_node_with_assets<F>( &mut self, camera: CameraKey, node: NodeKey, assets: &Assets<F>, ) -> Result<(), LookupError>
Frames a node or bounded descendants, resolving direct geometry handles through
Assets.
Sourcepub fn node_world_bounds<F>(
&self,
node: NodeKey,
assets: &Assets<F>,
) -> Result<Option<Aabb>, LookupError>
pub fn node_world_bounds<F>( &self, node: NodeKey, assets: &Assets<F>, ) -> Result<Option<Aabb>, LookupError>
Returns the world-space bounds for a node subtree, including geometry
resolved through Assets.
Sourcepub fn world_distance(&self, a: NodeKey, b: NodeKey) -> Result<f32, LookupError>
pub fn world_distance(&self, a: NodeKey, b: NodeKey) -> Result<f32, LookupError>
Returns the distance between two node origins in world space.
Sourcepub fn look_at(
&mut self,
camera: CameraKey,
target: NodeKey,
) -> Result<(), LookupError>
pub fn look_at( &mut self, camera: CameraKey, target: NodeKey, ) -> Result<(), LookupError>
Rotates the selected camera node so its local -Z axis points at target.
Sourcepub fn look_at_point(
&mut self,
camera: CameraKey,
target_position: Vec3,
) -> Result<(), LookupError>
pub fn look_at_point( &mut self, camera: CameraKey, target_position: Vec3, ) -> Result<(), LookupError>
Rotates the selected camera node so its local -Z axis points at a world-space point.
pub fn center_on( &mut self, node: NodeKey, center: Vec3, ) -> Result<(), LookupError>
pub fn align_to( &mut self, node: NodeKey, transform: Transform, ) -> Result<(), LookupError>
pub fn snap_anchor( &mut self, node: NodeKey, anchor: &ImportAnchor, ) -> Result<(), LookupError>
pub fn fit_inside( &mut self, node: NodeKey, source: Aabb, target: Aabb, ) -> Result<(), LookupError>
Source§impl Scene
impl Scene
pub fn set_visible( &mut self, node: NodeKey, visible: bool, ) -> Result<(), LookupError>
pub fn visible(&self, node: NodeKey) -> Option<bool>
pub fn add_tag( &mut self, node: NodeKey, tag: impl Into<String>, ) -> Result<(), LookupError>
pub fn remove_tag( &mut self, node: NodeKey, tag: &str, ) -> Result<bool, LookupError>
pub fn has_tag(&self, node: NodeKey, tag: &str) -> bool
pub fn tagged<'scene>( &'scene self, tag: &'scene str, ) -> impl Iterator<Item = NodeKey> + 'scene
pub fn set_layer_mask( &mut self, node: NodeKey, mask: u64, ) -> Result<(), LookupError>
pub fn layer_mask(&self, node: NodeKey) -> Option<u64>
pub fn set_camera_layer_mask( &mut self, camera: CameraKey, mask: u64, ) -> Result<(), LookupError>
pub fn camera_layer_mask(&self, camera: CameraKey) -> Option<u64>
pub fn set_render_group( &mut self, node: NodeKey, group: i16, ) -> Result<(), LookupError>
pub fn render_group(&self, node: NodeKey) -> Option<i16>
pub fn set_helper_on_top( &mut self, node: NodeKey, on_top: bool, ) -> Result<(), LookupError>
pub fn helper_on_top(&self, node: NodeKey) -> Option<bool>
Source§impl Scene
impl Scene
pub fn new() -> Self
pub fn root(&self) -> NodeKey
pub fn active_camera(&self) -> Option<CameraKey>
pub fn set_active_camera( &mut self, camera: CameraKey, ) -> Result<(), LookupError>
pub fn node(&self, node: NodeKey) -> Option<&Node>
pub fn camera(&self, camera: CameraKey) -> Option<&Camera>
pub fn add_empty( &mut self, parent: NodeKey, transform: Transform, ) -> Result<NodeKey, LookupError>
pub fn add_renderable( &mut self, parent: NodeKey, primitives: Vec<Primitive>, transform: Transform, ) -> Result<NodeKey, LookupError>
Sourcepub fn mesh(
&mut self,
geometry: GeometryHandle,
material: MaterialHandle,
) -> MeshBuilder<'_>
pub fn mesh( &mut self, geometry: GeometryHandle, material: MaterialHandle, ) -> MeshBuilder<'_>
Starts a mesh-node builder under the scene root.
Use MeshBuilder::parent and MeshBuilder::transform to override the default
root parent and identity transform, then call MeshBuilder::add to insert the node.
let _ = scene.mesh(geometry, texture);Sourcepub fn model(&mut self, model: ModelHandle) -> ModelBuilder<'_>
pub fn model(&mut self, model: ModelHandle) -> ModelBuilder<'_>
Starts a model-node builder under the scene root.
Use ModelBuilder::parent and ModelBuilder::transform to override the default
root parent and identity transform, then call ModelBuilder::add to insert the node.
pub fn add_perspective_camera( &mut self, parent: NodeKey, camera: PerspectiveCamera, transform: Transform, ) -> Result<CameraKey, LookupError>
pub fn add_orthographic_camera( &mut self, parent: NodeKey, camera: OrthographicCamera, transform: Transform, ) -> Result<CameraKey, LookupError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Scene
impl !Sync for Scene
impl Freeze for Scene
impl Send for Scene
impl Unpin for Scene
impl UnsafeUnpin for Scene
impl UnwindSafe for Scene
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more