pub trait Geometry {
fn render_with_material(
&self,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
) -> ThreeDResult<()>;
fn aabb(&self) -> AxisAlignedBoundingBox;
}Expand description
Represents a 3D geometry that, together with a material, can be rendered using Geometry::render_with_material. Alternatively, a geometry and a material can be combined in a Gm, thereby creating an Object which can be used in a render call, for example render_pass.
If requested by the material, the geometry has to support the following attributes in the vertex shader source code.
- position:
out vec3 pos;(must be in world space) - normal:
out vec3 nor; - tangent:
out vec3 tang; - bitangent:
out vec3 bitang; - uv coordinates:
out vec2 uvs;(must be flipped in v compared to standard uv coordinates, ie. douvs = vec2(uvs.x, 1.0 - uvs.y);in the vertex shader or do the flip before constructing the uv coordinates vertex buffer) - color:
out vec4 col;
Required Methods
fn render_with_material(
&self,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
) -> ThreeDResult<()>
fn render_with_material(
&self,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
) -> ThreeDResult<()>
Render the geometry with the given material.
Must be called in the callback given as input to a RenderTarget, ColorTarget or DepthTarget write method.
Use an empty array for the lights argument, if the objects does not require lights to be rendered.
fn aabb(&self) -> AxisAlignedBoundingBox
fn aabb(&self) -> AxisAlignedBoundingBox
Returns the AxisAlignedBoundingBox for this geometry in the global coordinate system.