Skip to main content

Scene

Struct Scene 

Source
pub struct Scene {
    pub meshes: Arena<Mesh>,
    pub textures: Arena<Texture>,
    pub objects: Arena<RenderObject>,
    pub light: DirectionalLight,
}
Expand description

Owns meshes, textures, render objects, and the scene light. 拥有网格、纹理、渲染对象和场景光。

Resources live in Arenas; the scene exposes the arenas directly so callers can insert assets and get stable handles back. 资源存放在 Arena 中;场景直接暴露这些 arena,以便调用方可以插入资源并获得稳定的句柄。

Fields§

§meshes: Arena<Mesh>

Mesh storage. 网格存储。

§textures: Arena<Texture>

Texture storage. 纹理存储。

§objects: Arena<RenderObject>

Render-object storage. 渲染对象存储。

§light: DirectionalLight

The single directional light of the scene. 场景中唯一的方向光。

Implementations§

Source§

impl Scene

Source

pub fn new() -> Self

Create an empty scene. 创建一个空场景。

§Examples

示例

use he3d_core::{Material, Mesh, RenderObject, Rgb, Scene, Transform};

let mut scene = Scene::new();
let mesh = scene.meshes.insert(Mesh::triangle(1.0, 1.0)?);
let object = scene.spawn(RenderObject {
   mesh,
   texture: None,
   transform: Transform::default(),
   material: Material::new(Rgb::WHITE),
   visible: true,
});
assert!(scene.objects.contains(object));
Source

pub fn spawn(&mut self, object: RenderObject) -> ObjectId

Insert a render object and return its handle. 插入一个渲染对象并返回其句柄。

Trait Implementations§

Source§

impl Default for Scene

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.