Crate three_d[−][src]
Expand description
Modules
camera | Perspective and orthographic camera. |
context | Thin and low-level graphics abstraction layer which maps one-to-one with the OpenGL graphics API on desktop and WebGL2 bindings provided by the web-sys crate on web. Can be used in combination with more high-level features or be ignored entirely. |
core | Modular abstractions of common graphics concepts such as GPU shader program, buffer (vertex buffer, uniform buffer, element buffer), texture (2D texture, cube texture, ..) and render target. They are higher level than context but lower level than other features. |
definition | Structs for constructing a CPU-side version of a GPU feature (for example a triangle mesh) before transferring it to the GPU. Can be constructed manually or loaded via io. |
effect | Effects applied to each pixel, for example fog or anti-aliasing. |
frame | Input/output from/to the window each frame. |
function | Additional functionality not related to any specific type. |
gui | Graphical User Interface support. |
io | Contain a loader for loading any type of asset runtime on both desktop and web and a saver for saving (available on desktop only). |
light | A collection of light types. Currently implemented light types are ambient light, directional light, spot light and point light. Directional and spot lights can cast shadows. |
math | Math functionality. |
object | A collection of objects that can be rendered, for example a mesh. |
phong | Adds functionality for rendering objects based on the phong reflection model. |
window | Default windows for easy setup and event handling. Currently glutin for cross-platform desktop and canvas using wasm-bindgen for web, but can be replaced by any other window with similar functionality. |
Structs
AmbientLight | A light which shines equally on all parts of any surface. |
Axes | Three arrows indicating the three main axes; the x-axis (red), the y-axis (green) and the z-axis (blue). Used for easily debugging where objects are placed in the 3D world. |
AxisAlignedBoundingBox | A bounding box that aligns with the x, y and z axes. |
BlendParameters | Defines which type of blending to use for a render call. Blending allows combining each color channel of a render call with the color already in the color channels of the render target. This is usually used to simulate transparency. |
CPUMaterial | A CPU-side version of a material (for example phong material). Can be constructed manually or loaded via io. |
CPUMesh | A CPU-side version of a triangle mesh (for example Mesh). Can be constructed manually or loaded via io or via the utility functions for generating simple triangle meshes. |
CPUTexture | A CPU-side version of a texture, for example 2D texture. Can be constructed manually or loaded via io. |
Camera | Used in a render call to define how to view the 3D world. |
CameraControl | 3D controls for a camera. Use this to add additional control functionality to a camera. |
ClearState | Defines which channels (red, green, blue, alpha and depth) to clear when starting to write to a
render target or the screen.
If |
ColorTargetTexture2D | A 2D color texture that can be rendered into and read from. |
ColorTargetTexture2DArray | A array of 2D color textures that can be rendered into. |
Context | Contains the graphics API for almost direct calls to OpenGL/WebGL. Used internally in the higher level features and can safely be ignored unless you want more control. |
DepthTargetTexture2D | A 2D depth texture that can be rendered into and read from. See also RenderTarget. |
DepthTargetTexture2DArray | An array of 2D depth textures that can be rendered into and read from. See also RenderTargetArray. |
DirectionalLight | A light which shines in the given direction. The light will cast shadows if you generate a shadow map. |
ElementBuffer | A buffer containing indices for rendering, see for example draw_elements. Also known as an index buffer. |
FXAAEffect | A simple anti-aliasing approach which smooths otherwise jagged edges (for example lines) but also smooths the rest of the image. |
FogEffect | An effect that simulates fog, ie. the entire screen gets hazy white when objects are far away. |
FrameInput | Input from the window to the rendering (and whatever else needs it) each frame. |
FrameOutput | Output from the rendering to the window each frame. |
GUI | Integration of egui, an immediate mode GUI. |
ImageEffect | A customizable 2D effect. Can for example be used for adding an effect on top of the rendered 3D scene, like fog. |
Imposters | A level-of-detail technique to replace rendering high-poly meshes at a distance. A mesh is rendered from different angles into a set of textures and the textures are then rendered continuously instead of the high-poly meshes. |
InstancedMesh | Similar to Mesh, except it is possible to render many instances of the same triangle mesh efficiently. |
InstancedMeshProgram | A shader program used for rendering one or more instances of a InstancedMesh. It has a fixed vertex shader and customizable fragment shader for custom lighting. Use this in combination with render. |
Loaded | The resources loaded using the Loader. Use the bytes function to extract the raw byte array for the loaded resource or one of the other methods to both extract and deserialize a loaded resource. |
Loader | Functionality for loading any type of resource runtime on both desktop and web. |
Mesh | A triangle mesh which can be rendered with one of the default render functions or with a custom MeshProgram. See also PhongMesh for rendering a mesh with lighting. |
MeshProgram | A shader program used for rendering one or more instances of a Mesh. It has a fixed vertex shader and customizable fragment shader for custom lighting. Use this in combination with render. |
Modifiers | State of modifiers (alt, ctrl, shift and command). |
ParticleData | Used to define the initial position and velocity of a particle in Particles. |
Particles | Particle effect with fixed vertex shader and customizable fragment shader (see also ParticlesProgram). |
ParticlesProgram | Shader program used for rendering Particles.
The fragment shader code can use position ( |
PhongDeferredPipeline | Deferred pipeline based on the Phong reflection model supporting a performance-limited amount of directional, point and spot lights with shadows. |
PhongInstancedMesh | Extends a InstancedMesh by adding functionality to render it based on the Phong shading model. |
PhongMaterial | A material used for shading an object based on the Phong shading model. |
PhongMesh | Extends a Mesh by adding functionality to render it based on the Phong shading model. |
PointLight | A light which shines from the given position in all directions. |
Program | A shader program consisting of a programmable vertex shader followed by a programmable fragment shader. Functionality includes transferring per vertex data to the vertex shader (see the use_attribute functionality) and transferring uniform data to both shader stages (see the use_uniform and use_texture functionality) and execute the shader program (see the draw functionality). |
RenderStates | A set of render specific states that has to be specified at each render call. |
RenderTarget | Adds additional functionality to write to and copy from both a ColorTargetTexture2D and a DepthTargetTexture2D at the same time. It purely adds functionality, so it can be created each time it is needed, the data is saved in the textures. |
RenderTargetArray | Adds additional functionality to write to and copy from both a ColorTargetTexture2DArray and a DepthTargetTexture2DArray at the same time. It purely adds functionality, so it can be created each time it is needed, the data is saved in the textures. |
Saver | Functionality for saving resources. Only available on desktop at the moment. |
Screen | The screen render target which is essential to get something on the screen (see the write function). |
Skybox | An illusion of a sky. |
SpotLight | A light which shines from the given position and in the given direction. The light will cast shadows if you generate a shadow map. |
Texture2D | A 2D texture, basically an image that is transferred to the GPU. For a texture that can be rendered into, see ColorTargetTexture2D. |
TextureCubeMap | A texture that covers all 6 sides of a cube. |
UniformBuffer | A buffer for transferring a set of uniform variables to the shader program (see also use_uniform_block). |
VertexBuffer | A buffer containing per vertex data, for example positions, normals, uv coordinates or colors (see also use_attribute, use_attribute_vec2, etc.). |
Viewport | Defines the part of the screen/render target that is rendered to. |
Window | Default window and event handler for easy setup. |
WindowSettings | Window settings. |
WriteMask | Defines which channels (red, green, blue, alpha and depth) to write to in a render call. |
Enums
BlendEquationType | How the source and target color or alpha value are combined in blend parameters. |
BlendMultiplierType | Value multiplied with the source or target color or alpha value in blend parameters. |
ColorSource | The source of color on an object, either a fixed value or a texture. |
CopyDestination | The destination of applying a copy. |
CullType | Defines whether the triangles that are backfacing, frontfacing or both should be skipped in a render call. |
DebugType | Used for debug purposes. |
DepthFormat | Type of formats for depth render targets (DepthTargetTexture2D and DepthTargetTexture2DArray). |
DepthTestType | Determines whether or not a fragment/pixel from the current render call should be discarded when comparing its depth with the depth of the current fragment/pixel. |
Error | Error in some part of the render engine. |
Event | An input event (from mouse, keyboard or similar). |
Format | Possible formats for pixels in a texture. |
IOError | Error message from the core module. |
Interpolation | Possible modes of interpolation which determines the texture output between texture pixels. |
Key | Keyboard key input. |
MouseButton | Type of mouse button. |
State | State of a key or button click. |
WindowError | Error message from the window module. |
Wrapping | Possible wrapping modes for a texture which determines how the texture is applied outside of the [0..1] uv coordinate range. |
Traits
Geometry | |
PhongGeometry | Used for deferred Phong rendering. Implemented by PhongMesh and PhongInstancedMesh. |
Texture | A texture that can be sampled in a fragment shader (see use_texture). |
TextureArray | A texture array that can be sampled in a fragment shader (see use_texture_array). |
TextureCube | A texture cube that can be sampled in a fragment shader (see use_texture_cube). |
TextureValueType |
Functions
degrees | |
radians | |
ray_intersect | |
rotation_matrix_from_dir_to_dir | |
vec2 | |
vec3 | |
vec4 |
Type Definitions
Degrees | |
Mat2 | |
Mat3 | |
Mat4 | |
Point | |
Radians | |
Vec2 | |
Vec3 | |
Vec4 |