[][src]Struct three::Factory

pub struct Factory { /* fields omitted */ }

Factory is used to instantiate game objects.

Methods

impl Factory
[src]

Create new empty Scene.

Creates an instance of all the objects described in the template.

Returns a Group that is the root object for all objects created from the template, as well as a list of all animation clips instantiated from the template.

See the module documentation for template for more information on the template system.

Examples

Create an empty template and then instantiate it, effectively the most verbose way to call Factory::group:

use three::template::Template;

let template = Template::new();
let (group, animations) = window.factory.instantiate_template(&template);

Create a new Bone, one component of a Skeleton.

Create a new Skeleton from a set of Bone instances.

  • bones is the array of bones that form the skeleton.
  • inverses is an optional array of inverse bind matrices for each bone. Skeleton: ../skeleton/struct.Skeleton.html Bone: ../skeleton/struct.Bone.html

Create a new camera using the provided projection.

This allows you to create a camera from a predefined projection, which is useful if you e.g. load projection data from a file and don't necessarily know ahead of time what type of projection the camera uses. If you're manually creating a camera, you should use [perspective_camera] or [orthographic_camera].

Create new Orthographic Camera. It's used to render 2D.

Create new Perspective Camera.

It's used to render 3D.

Examples

Creating a finite perspective camera.

let camera = factory.perspective_camera(60.0, 0.1 .. 1.0);

Creating an infinite perspective camera.

let camera = factory.perspective_camera(60.0, 0.1 ..);

Create empty Group.

Uploads geometry data to the GPU so that it can be reused for instanced rendering.

See the module documentation in template for information on mesh instancing and its benefits.

Examples

use three::Geometry;

// Create geometry for a triangle.
let vertices = vec![
    [-0.5, -0.5, -0.5].into(),
    [0.5, -0.5, -0.5].into(),
    [0.0, 0.5, -0.5].into(),
];
let geometry = Geometry::with_vertices(vertices);

// Upload the triangle data to the GPU.
let upload_geometry = window.factory.upload_geometry(geometry);

// Create multiple meshes with the same GPU data and material.
let material = three::material::Basic {
    color: 0xFFFF00,
    map: None,
};
let first = window.factory.create_instanced_mesh(&upload_geometry, material.clone());
let second = window.factory.create_instanced_mesh(&upload_geometry, material.clone());
let third = window.factory.create_instanced_mesh(&upload_geometry, material.clone());

Create new Mesh with desired Geometry and Material.

Creates a Mesh using geometry that has already been loaded to the GPU.

See the module documentation in template for information on mesh instancing and its benefits.

Examples

use three::Geometry;

// Create geometry for a triangle.
let vertices = vec![
    [-0.5, -0.5, -0.5].into(),
    [0.5, -0.5, -0.5].into(),
    [0.0, 0.5, -0.5].into(),
];
let geometry = Geometry::with_vertices(vertices);

// Upload the triangle data to the GPU.
let upload_geometry = window.factory.upload_geometry(geometry);

// Create multiple meshes with the same GPU data and material.
let material = three::material::Basic {
    color: 0xFFFF00,
    map: None,
};
let first = window.factory.create_instanced_mesh(&upload_geometry, material.clone());
let second = window.factory.create_instanced_mesh(&upload_geometry, material.clone());
let third = window.factory.create_instanced_mesh(&upload_geometry, material.clone());

Create a new DynamicMesh with desired Geometry and Material.

Create a Mesh sharing the geometry with another one. Rendering a sequence of meshes with the same geometry is faster. The material is duplicated from the template.

Create a Mesh sharing the geometry with another one but with a different material. Rendering a sequence of meshes with the same geometry is faster.

Create new sprite from Material.

Create a Sprite sharing the material with another one. Rendering a sequence of instanced sprites is much faster.

Create new AmbientLight.

Create new DirectionalLight.

Create new HemisphereLight.

Create new PointLight.

Create a Sampler with default properties.

The default sampler has Clamp as its horizontal and vertical wrapping mode and Scale as its filtering method.

Create new Sampler.

Create new ShadowMap.

Create a basic mesh pipeline using a custom shader.

Create new UI (on-screen) text. See Text for default settings.

Create new audio source.

Map vertices for updating their data.

Interpolate between the shapes of a DynamicMesh.

Load TrueTypeFont (.ttf) from file.

Panics

Panics if I/O operations with file fails (e.g. file not found or corrupted)

Load the Karla font

Load texture from pre-loaded data.

Load texture from file, with default Sampler. Supported file formats are: PNG, JPEG, GIF, WEBP, PPM, TIFF, TGA, BMP, ICO, HDR.

Load texture from file, with custom Sampler. Supported file formats are: PNG, JPEG, GIF, WEBP, PPM, TIFF, TGA, BMP, ICO, HDR.

Load cubemap from files. Supported file formats are: PNG, JPEG, GIF, WEBP, PPM, TIFF, TGA, BMP, ICO, HDR.

Load mesh from Wavefront Obj format.

Load audio from file. Supported formats are Flac, Vorbis and WAV.

Auto Trait Implementations

impl !Send for Factory

impl !Sync for Factory

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> SetParameter for T

Sets value as a parameter of self.

impl<T> Erased for T