pub struct Scene { /* private fields */ }Expand description
A 3D scene. Renders one <div data-three="scene"> element.
use autumn_plugin_three::{Camera, Color, Controls, Light, Mesh, Scene};
use autumn_web::html;
let scene = Scene::new()
.label("A spinning orange torus knot")
.camera(Camera::perspective().position([0.0, 0.0, 4.0]))
.controls(Controls::OrbitNoZoom)
.add(Mesh::torus_knot(0.8, 0.25).color(Color::hex(0xff7a18)).spin([0.0, 45.0, 0.0]))
.add(Light::directional().position([3.0, 5.0, 2.0]))
.fallback(html! { p { "3D preview needs WebGL." } });
let html = html! { (scene) }.into_string();
assert!(html.starts_with(r#"<div role="img""#), "{html}");
assert!(html.contains(r#"data-three="scene""#));
assert!(html.contains(r#"data-three-mesh="torus-knot""#));Implementations§
Source§impl Scene
impl Scene
Sourcepub fn class(self, class: impl Into<String>) -> Self
pub fn class(self, class: impl Into<String>) -> Self
Sets the element class, for your own size or layout CSS.
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> Self
Sets an accessible label. The element gets role="img" and
aria-label.
Sourcepub const fn aspect(self, aspect: Aspect) -> Self
pub const fn aspect(self, aspect: Aspect) -> Self
Sets the aspect ratio. Default: Aspect::Wide (16 / 9).
Sourcepub const fn background(self, color: Color) -> Self
pub const fn background(self, color: Color) -> Self
Sets a solid background color. Default: transparent.
Sourcepub const fn controls(self, controls: Controls) -> Self
pub const fn controls(self, controls: Controls) -> Self
Sets the camera controls. Default: Controls::None.
Sourcepub const fn environment(self, environment: Environment) -> Self
pub const fn environment(self, environment: Environment) -> Self
Sets the image-based light.
Sourcepub const fn turntable(self, degrees_per_second: f32) -> Self
pub const fn turntable(self, degrees_per_second: f32) -> Self
Turns the whole scene around the Y axis, in degrees per second. Negative values turn clockwise (seen from above).
Sourcepub const fn animate_reduced_motion(self) -> Self
pub const fn animate_reduced_motion(self) -> Self
Keeps automatic motion (spin, turntable, clips) when the user prefers reduced motion. Default: automatic motion stops.
Sourcepub fn add(self, object: impl Into<SceneObject>) -> Self
pub fn add(self, object: impl Into<SceneObject>) -> Self
Adds a mesh, model, or light.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Scene
impl Freeze for Scene
impl RefUnwindSafe for Scene
impl Send for Scene
impl Sync for Scene
impl Unpin for Scene
impl UnsafeUnpin for Scene
impl UnwindSafe for Scene
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
Mutably borrows from an owned value. Read more
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
Open a deferred
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.