[][src]Struct three::Geometry

pub struct Geometry {
    pub base: Shape,
    pub tex_coords: Vec<Point2<f32>>,
    pub faces: Vec<[u32; 3]>,
    pub joints: Joints,
    pub shapes: Vec<Shape>,
}

A collection of vertices, their normals, and faces that defines the shape of a polyhedral object.

Examples

Tetrahedron of unit height and base radius.

use std::f32::consts::PI;

let vertices = vec![
    [0.0, 1.0, 0.0].into(),
    [0.0, 0.0, 1.0].into(),
    [(2.0 * PI / 3.0).sin(), 0.0, (2.0 * PI / 3.0).cos()].into(),
    [(4.0 * PI / 3.0).sin(), 0.0, (4.0 * PI / 3.0).cos()].into(),
];

let faces = vec![
    [0, 1, 2],
    [0, 2, 3],
    [0, 3, 1],
    [1, 3, 2],
];

three::Geometry {
    faces,
    base: three::Shape {
        vertices,
        .. three::Shape::default()
    },
    .. three::Geometry::default()
}

Notes

  • If any vertex normals, tangents, or texture co-ordinates are provided, the number of entries in each array must match the number of entries in vertices.
  • If joints are provided, the number of entries in joints.indices must match the number of entries in joints.weights.

Fields

Idle shape of the geometry.

Texture co-ordinates.

Face indices.

When omitted, the vertex order [[0, 1, 2], [3, 4, 5], ...] is assumed.

Properties for vertex skinning.

A list of blend shapes.

Methods

impl Geometry
[src]

Create Geometry from vector of vertices.

Examples

Triangle in the XY plane.

let vertices = vec![
    [-0.5, -0.5, 0.0].into(),
    [ 0.5, -0.5, 0.0].into(),
    [ 0.5, -0.5, 0.0].into(),
];
let geometry = three::Geometry::with_vertices(vertices);

Creates planar geometry in the XY plane.

The width and height parameters specify the total length of the geometry along the X and Y axes respectively.

Examples

Unit square in the XY plane, centered at the origin.

fn make_square() -> three::Geometry {
    three::Geometry::plane(1.0, 1.0)
}

Creates cuboidal geometry.

The width, height, and depth parameters specify the total length of the geometry along the X, Y, and Z axes respectively.

Examples

Unit cube, centered at the origin.

fn make_cube() -> three::Geometry {
    three::Geometry::cuboid(1.0, 1.0, 1.0)
}

Creates cylindrial geometry.

Examples

Cylinder of unit height and radius, using 12 segments at each end.

fn make_cylinder() -> three::Geometry {
    three::Geometry::cylinder(1.0, 1.0, 1.0, 12)
}

Cone of unit height and unit radius at the bottom.

fn make_cone() -> three::Geometry {
    three::Geometry::cylinder(0.0, 1.0, 1.0, 12)
}

Creates geometry for a sphere, using the UV method.

  • equatorial_divisions specifies the number of segments about the sphere equator that lies in the XZ plane.
  • meridional_segments specifies the number of segments around the sphere meridian that lies in the YZ plane.
fn make_sphere() -> three::Geometry {
    three::Geometry::uv_sphere(1.0, 12, 12)
}

Trait Implementations

impl Clone for Geometry
[src]

Performs copy-assignment from source. Read more

impl Default for Geometry
[src]

impl Debug for Geometry
[src]

Auto Trait Implementations

impl Send for Geometry

impl Sync for Geometry

Blanket Implementations

impl<T> From for T
[src]

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

impl<T> ToOwned for T where
    T: Clone
[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