Skip to main content

Component

Trait Component 

Source
pub trait Component:
    Any
    + Clone
    + Debug
    + Send
    + Sync {
    const NAME: &'static str;
    const GEOMETRY: Geometry;
    const VERSION: u32 = 1;

    // Provided methods
    fn to_json(&self) -> Result<Option<Value>, JsonError> { ... }
    fn verify(&self, _e: Entity, _w: &World) -> Result<(), String> { ... }
    fn references(&self, _out: &mut Vec<Entity>) { ... }
    fn payload_bytes(&self) -> u64 { ... }
    fn remap_primitives(&self, _from: &[usize]) -> Option<Result<Self, String>> { ... }
    fn remap_vertices(
        &self,
        _primitive: usize,
        _from: &[u32],
    ) -> Option<Result<Self, String>> { ... }
    fn blend_vertices(
        &self,
        _primitive: usize,
        _from: &[VertexBlend],
    ) -> Option<Result<Self, String>> { ... }
    fn apply_linear(&self, _l: &Linear) -> Linearity<Self> { ... }
    fn restate(&self, _resolved: &Resolved<'_>) -> Restated<Self> { ... }
}
Expand description

A typed component. NAME is namespaced and stable (core.transform, a destination’s material, a source’s layered_material): serialisation, pass declarations and reports use it, so renaming one is a format change.

Required Associated Constants§

Source

const NAME: &'static str

Source

const GEOMETRY: Geometry

What the value holds of its entity’s mesh primitives and vertices (Geometry). Stated by every component, with no default, so data that describes a mesh can’t be left behind by an edit of it unawares: the World’s edit paths take it from there.

Provided Associated Constants§

Source

const VERSION: u32 = 1

Schema version of the component’s content. Bump it when the meaning or layout of a field changes.

Provided Methods§

Source

fn to_json(&self) -> Result<Option<Value>, JsonError>

The component as JSON, for glTF extras, the debug text form and golden tests; Ok(None) for components that are not shown (bulk data, handles). The view must never lose a value: components that can be shown derive serde::Serialize and return crate::json::to_value(self).map(Some), which refuses non-finite floats instead of writing them as null.

Source

fn verify(&self, _e: Entity, _w: &World) -> Result<(), String>

The component’s own invariants on entity e (indices in range, stream lengths equal, …). The pass manager runs it on every component after the reader, after every pass and before the writer, together with the world’s own check that every entity of Component::references is alive. World-wide rules (one name -> one payload) are pass::Validators instead.

Source

fn references(&self, _out: &mut Vec<Entity>)

The entities this component refers to (a prototype, materials, textures), appended to out: the edges World::closure follows. A component holding entity references must declare every one of them.

Source

fn payload_bytes(&self) -> u64

The bytes of bulk payload the value holds (vertex streams and indices, texture levels, triangle soups), for memory reports: element counts times element sizes, not allocated capacity. 0 for small components.

Source

fn remap_primitives(&self, _from: &[usize]) -> Option<Result<Self, String>>

The component after its entity’s mesh primitives were rebuilt, for a component that holds something per primitive (Geometry::PerPrimitive, Geometry::PerVertex): new primitive i comes from old primitive from[i] (a source may repeat, when a primitive is split, or be absent, when one is dropped). Such a component always answers (a value holding nothing per primitive answers with itself); None, the default, is for components of Geometry::None, and World::remap_primitives refuses a dependent component that gives it. An index the component does not have is an error. remap_list does the work for a list with one entry per primitive.

Source

fn remap_vertices( &self, _primitive: usize, _from: &[u32], ) -> Option<Result<Self, String>>

The component after the vertices of its entity’s mesh primitive primitive were compacted or reordered, for a component that holds something per vertex (Geometry::PerVertex): new vertex i of that primitive is old vertex from[i] (a source may repeat or be absent). Such a component always answers (with itself when it holds nothing for that primitive); None, the default, is for the others, and World::remap_vertices refuses a per-vertex component that gives it. An index the component does not have is an error. Every pass that compacts or reorders a primitive’s vertices calls World::remap_vertices. After a rebuild of the primitive list (World::rebuild_primitives, Component::remap_primitives) a primitive’s per-vertex data is its source primitive’s, and the vertex map is relative to that source.

Source

fn blend_vertices( &self, _primitive: usize, _from: &[VertexBlend], ) -> Option<Result<Self, String>>

The component after the vertices of its entity’s mesh primitive primitive were rebuilt as blends of old ones (VertexBlend), for a component that holds something per vertex (Geometry::PerVertex): new vertex i is the combination from[i] of old vertices, in whatever way the component’s data combines (a morph target’s delta is interpolated, the way the surface it moves is). It answers as Component::remap_vertices does: with itself when it holds nothing for that primitive; None, the default, is for a component that does not know how to combine its data, and World::blend_vertices refuses a per-vertex component that gives it. An index the component does not have is an error. A vertex that is a copy of one old vertex (VertexBlend::copy) is the case Component::remap_vertices states, and a component answering one answers the other alike.

Source

fn apply_linear(&self, _l: &Linear) -> Linearity<Self>

The component after its entity’s local space was mapped by l (a pass that bakes a placement’s mirror or shear into a copy of its geometry, so transforms stay rigid). World::apply_linear calls it for every component of the entity. The default is Linearity::Unsupported: a component that holds local-space geometry and does not say how it follows is never silently left behind; one without geometry says Linearity::Invariant.

Source

fn restate(&self, _resolved: &Resolved<'_>) -> Restated<Self>

The component after resolve-state (crate::state::ResolveState) gave the axes in resolved their values: a component that holds crate::state::Clauses of its own (a record of parts each present in some states) reduces them as core.condition is reduced (crate::state::Resolved::reduce: a clause that fails is dropped, a clause left with no literal holds whatever the other axes are). Restated::Absent says the entity is not present in this state (every clause failed): it is despawned as one whose core.condition fails is. The default holds no clause: Restated::Unchanged.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Component for AssemblyReference

Source§

const NAME: &'static str = "core.assembly_reference"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Asset

Source§

const NAME: &'static str = "core.asset"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Attachment

Source§

const NAME: &'static str = "core.attachment"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Clip

Source§

const NAME: &'static str = "core.clip"

Source§

const VERSION: u32 = 2

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for ClipBinding

Source§

const NAME: &'static str = "core.clip_binding"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for ClipEffects

Source§

const NAME: &'static str = "core.clip_effects"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for ClipEvents

Source§

const NAME: &'static str = "core.clip_events"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for ClipKey

Source§

const NAME: &'static str = "core.clip_key"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for ClipLength

Source§

const NAME: &'static str = "core.clip_length"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for Collider

Source§

const NAME: &'static str = "core.collider"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Collision

Source§

const NAME: &'static str = "core.collision"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Condition

Source§

const NAME: &'static str = "core.condition"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for ContentNote

Source§

const NAME: &'static str = "core.content_note"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for Controller

Source§

const NAME: &'static str = "core.controller"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for ControllerBinding

Source§

const NAME: &'static str = "core.controller_binding"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for Curve

Source§

const NAME: &'static str = "core.curve"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

const VERSION: u32 = 2

Source§

impl Component for DetailedMaterial

Source§

const NAME: &'static str = "pbr.detail"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

const VERSION: u32 = REVISION

Source§

impl Component for DisplayName

Source§

const NAME: &'static str = "core.display_name"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for DrawGroupDefaults

Source§

const NAME: &'static str = "core.draw_group_defaults"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for DrawGroups

Source§

const NAME: &'static str = "core.draw_groups"

Source§

const GEOMETRY: Geometry = Geometry::PerPrimitive

Source§

impl Component for DrawOrder

Source§

const NAME: &'static str = "core.draw_order"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

const VERSION: u32 = 3

Source§

impl Component for Heightfield

Source§

const NAME: &'static str = "core.heightfield"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for IncomingTransition

Source§

const NAME: &'static str = "core.incoming_transition"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for Instance

Source§

const NAME: &'static str = "core.instance"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for IrradianceVolume

Source§

const NAME: &'static str = "core.irradiance_volume"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for JointMap

Source§

const NAME: &'static str = "core.joint_map"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for JointPlacement

Source§

const NAME: &'static str = "core.joint_placement"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for LayeredMaterial

Source§

const NAME: &'static str = "core.layered"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

const VERSION: u32 = 7

Source§

impl Component for LiftedShader

Source§

const NAME: &'static str = "core.lifted_shader"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Light

Source§

const NAME: &'static str = "core.light"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

const VERSION: u32 = 4

Source§

impl Component for LightFalloff

Source§

const NAME: &'static str = "core.light_falloff"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for LightTranslucency

Source§

const NAME: &'static str = "core.light_translucency"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for LodSwitch

Source§

const NAME: &'static str = "core.lod_switch"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Lods

Source§

const NAME: &'static str = "core.lods"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Marker

Source§

const NAME: &'static str = "core.marker"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

const VERSION: u32 = 2

Source§

impl Component for MaterialParameters

Source§

const NAME: &'static str = "core.material_parameters"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for MaterialPrograms

Source§

const NAME: &'static str = "core.material_programs"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for MaterialUsage

Source§

const NAME: &'static str = "core.material_usage"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for MaterialVariants

Source§

const NAME: &'static str = "core.material_variants"

Source§

const GEOMETRY: Geometry = crate::Geometry::PerPrimitive

Source§

impl Component for Mesh

Source§

const NAME: &'static str = "core.mesh"

Source§

const VERSION: u32 = 2

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for MeshFile

Source§

const NAME: &'static str = "core.mesh_file"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for MorphWeights

Source§

const NAME: &'static str = "core.morph_weights"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Morphs

Source§

const NAME: &'static str = "core.morphs"

Source§

const GEOMETRY: Geometry = crate::Geometry::PerVertex

Source§

impl Component for Name

Source§

const NAME: &'static str = "core.name"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for ParticleSystem

Source§

const NAME: &'static str = "core.particles"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for PbrMaterial

Source§

const NAME: &'static str = "pbr.material"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

const VERSION: u32 = 5

Source§

impl Component for PrimitiveCondition

Source§

const NAME: &'static str = "core.primitive_condition"

Source§

const GEOMETRY: Geometry = crate::Geometry::PerPrimitive

Source§

impl Component for PrimitiveKeys

Source§

const NAME: &'static str = "core.primitive_keys"

Source§

const GEOMETRY: Geometry = Geometry::PerPrimitive

Source§

impl Component for Priority

Source§

const NAME: &'static str = "core.priority"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for ProgramFacts

Source§

const NAME: &'static str = "core.program_facts"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for Provenance

Source§

const NAME: &'static str = "core.provenance"

Source§

const GEOMETRY: Geometry = crate::Geometry::PerPrimitive

Source§

impl Component for Record

Source§

const NAME: &'static str = "core.record"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for ReflectionProbeRegion

Source§

const NAME: &'static str = "core.reflection_probe_region"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for RigInstance

Source§

const NAME: &'static str = "core.rig_instance"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for RigPose

Source§

const NAME: &'static str = "core.rig_pose"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Shader

Source§

const NAME: &'static str = "core.shader"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for ShaderBinding

Source§

const NAME: &'static str = "core.shader_binding"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for ShaderDerivation

Source§

const NAME: &'static str = "core.shader_derivation"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for ShaderSpecialisations

Source§

const NAME: &'static str = "core.shader_specialisations"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for Shadows

Source§

const NAME: &'static str = "core.shadows"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

const VERSION: u32 = 2

Source§

impl Component for Skeleton

Source§

const NAME: &'static str = "core.skeleton"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Skin

Source§

const NAME: &'static str = "core.skin"

Source§

const GEOMETRY: Geometry = crate::Geometry::PerPrimitive

Source§

impl Component for SkinInstance

Source§

const NAME: &'static str = "core.skin_instance"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for SkyAnchor

Source§

const NAME: &'static str = "core.sky_anchor"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Sockets

Source§

const NAME: &'static str = "core.sockets"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Source

Source§

const NAME: &'static str = "core.source"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for SpotFrustum

Source§

const NAME: &'static str = "core.spot_frustum"

Source§

const GEOMETRY: Geometry = Geometry::None

Source§

impl Component for StateAxis

Source§

const NAME: &'static str = "core.state_axis"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for StateOverride

Source§

const NAME: &'static str = "core.state_override"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for StepBindings

Source§

const NAME: &'static str = "core.step_bindings"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for StepDraws

Source§

const NAME: &'static str = "core.step_draws"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Texture

Source§

const NAME: &'static str = "core.texture"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

const VERSION: u32 = 3

Source§

impl Component for TextureAbsent

Source§

const NAME: &'static str = "core.texture_absent"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for TextureFile

Source§

const NAME: &'static str = "core.texture_file"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for TextureForms

Source§

const NAME: &'static str = "core.texture_forms"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for TextureLayers

Source§

const NAME: &'static str = "core.texture_layers"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for TextureSwitch

Source§

const NAME: &'static str = "core.texture_switch"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Tile

Source§

const NAME: &'static str = "core.tile"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for Transform

Source§

const NAME: &'static str = "core.transform"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for VertexColor

Source§

const NAME: &'static str = "core.vertex_color"

Source§

const GEOMETRY: Geometry = crate::Geometry::None

Source§

impl Component for WaterBody

Source§

const NAME: &'static str = "core.water_body"

Source§

const GEOMETRY: Geometry = Geometry::None