Skip to content

Components ​

All components extend AbstractComponent and use #[Serializable] for automatic serialization. Attributes live in PHPolygon\ECS\Attribute.

3D Components ​

ComponentKey PropertiesPurpose
Transform3Dposition: Vec3, rotation: Quaternion, scale: Vec3, parentEntityId: ?intWorld/local transform with hierarchy
Camera3DComponentfov: float, near: float, far: float, projectionType: ProjectionType, active: boolProjection settings
MeshRenderermeshId: string, materialId: string, castShadows: boolRenderable mesh
DirectionalLightdirection: Vec3, color: Color, intensity: floatSun/moon light
PointLightcolor: Color, intensity: float, radius: float, castsShadow: boolPositional light
SpotLightdirection: Vec3, color: Color, intensity: float, range: float, angle: float, penumbra: float, castsShadow: boolCone light
RectAreaLightwidth: float, depth: float, color: Color, intensity: float, range: floatOne-sided rectangular area light
EmissiveAreaLightmaterialId: string, radius: float, scale: floatAn emissive material that lights its surroundings
AmbientLightcolor: Color, intensity: floatScene ambient light
LightConedensity, length, edgeSoftness, axisFade, maxDistance, enabledVisible beam of the SpotLight on the same entity
Outlineenabled: bool, color: Color, widthPx: float, includeChildren: boolScreen-space outline around the entity's mesh
SurfaceTexttext or textKey, width, height, color, background, fontIdText fixed on a surface in world space, by literal or translation key
WorldTexttext, fontSize, color, maxDistanceScreen-facing label at a world position

2D Components ​

ComponentKey PropertiesPurpose
Transform2Dposition: Vec2, rotation: float, scale: Vec2, parentEntityId: ?int2D transform with hierarchy
Camera2DComponentzoom: float, bounds: ?Rect, active: bool2D orthographic camera
SpriteRenderertextureId: string, region: ?Rect, color: Color, layer: int, flipX/Y: bool, opacity: float2D sprite rendering

Physics 3D Components ​

ComponentKey PropertiesPurpose
CharacterController3Dheight, radius, stepHeight, slopeLimitCapsule collision controller
RigidBody3DbodyType: BodyType, mass, gravityScale, linearDamping, restitution, frictionPhysics body (Static/Kinematic/Dynamic)
BoxCollider3Dsize: Vec3, offset: Vec3, isTrigger: bool, isStatic: boolAABB box collider
MeshCollider3DmeshId: string, isStatic: bool, isTrigger: boolTriangle mesh collider with BVH
HeightmapCollider3DgridWidth, gridDepth, worldMinX/MaxX/MinZ/MaxZO(1) terrain collision
HingeJointanchorOffset: Vec3, axis: Vec3, angle, minAngle, maxAngle, dampingRevolute joint for doors/gates
LinearJointslideAxis: Vec3, position, minPosition, maxPosition, dampingPrismatic joint for sliding doors

Physics 2D Components ​

ComponentKey PropertiesPurpose
RigidBody2Dvelocity: Vec2, mass, drag, angularVelocity, gravityScale, restitution, isKinematic2D physics body
BoxCollider2Doffset: Vec2, size: Vec2, isTrigger: bool2D box collider

Environmental Components ​

ComponentKey PropertiesPurpose
AtmospherecloudBaseAltitude, airPressureAtmospheric simulation (pressure, visibility, thermals)
WindbaseIntensity, gustiness, gustFrequencyWind simulation with layered gusts
DayNightCycletimeOfDay: float, dayDuration, speed, paused: bool, lunarCycleDaysDay/night cycle (0.0-1.0 time)
WeathercloudCoverage, humidity, transitionDurationWeather state machine (Clear/Cloudy/Rain/Snow/Storm/Fog)
SeasonyearProgress, yearDuration, speedSeasonal cycle (spring/summer/fall/winter)

Animation Components ​

ComponentKey PropertiesPurpose
PalmSwayswayStrength, phaseOffset, isTrunk: boolWind-driven sway for vegetation
ParticleEmitterrate, lifetime, velocity, velocityJitter, gravity, startSize/endSize, startColor/endColor, maxParticles, renderMode, spawnRadius, activeDistanceGPU-friendly particle source (sparks, smoke, dust)

Environment Volumes ​

ComponentKey PropertiesPurpose
HeightFogdensity, falloff, baseHeight, colorFog that thins out with height
FogVolumehalfExtents: Vec3, density, color, edgeA local box of fog
HeatSourceradius, strengthHeat haze above hot things
DecalVolumehalfExtents: Vec3, kind, color, strengthProjects a decal onto the surfaces inside the box
AgingVolumehalfExtents: Vec3, age, edgeWeathers the surfaces inside the box
InteriorVolumehalfExtents: Vec3, strengthMarks an interior for the interior light mask

Vegetation, Navigation and Motion ​

ComponentKey PropertiesPurpose
FoliageInstancesvariant: stringInstanced plants of one variant (drawn by FoliageInstanceSystem)
GrassFieldminX/minZ/maxX/maxZ, groundAt, mask, baseColor, tipColor, seedArea that grows grass blades near the camera
NavMeshAgentspeed, angularSpeed, acceleration, stoppingDistance, avoidanceRadiusFollows NavMesh paths and authored waypoints
Signalsbools, numbersNamed channels that drive signal motion
SignalTrack / SignalSpin / SignalSwitchpoints, speed, runChannel / axis, speed / channel, invertItems moving along a track / a spinning part / a part switched by a channel
PosePlayerrig, bindings, clipPlays pose clips onto a figure built from parts
WaterDisturberkind, strengthLeaves wakes or rings on the water surface

Terrain Components ​

ComponentKey PropertiesPurpose
InstancedTerrainmeshId: string, matricesByMaterial: array<string, list<Mat4>>Pre-computed instanced terrain

Audio Components ​

ComponentKey PropertiesPurpose
AudioSourceclipId: string, volume: float, loop: bool, playOnAwake: boolAudio playback

Utility Components ​

ComponentKey PropertiesPurpose
NameTagname: stringEntity name for debugging/referencing

Custom Components ​

php
use PHPolygon\ECS\AbstractComponent;
use PHPolygon\ECS\Attribute\Serializable;
use PHPolygon\ECS\Attribute\Property;
use PHPolygon\ECS\Attribute\Category;
use PHPolygon\ECS\Attribute\Range;
use PHPolygon\ECS\Attribute\Hidden;

#[Serializable]
#[Category('Gameplay')]
class Inventory extends AbstractComponent
{
    #[Property]
    public int $maxSlots = 20;

    #[Property(editorHint: 'slider')]
    #[Range(min: 0, max: 100)]
    public int $weight = 0;

    #[Hidden]
    public array $items = [];

    public function addItem(string $itemId): bool
    {
        if (count($this->items) >= $this->maxSlots) {
            return false;
        }
        $this->items[] = $itemId;
        return true;
    }
}

Component Attributes ​

AttributeTargetParametersPurpose
#[Serializable]Class?string $nameMarks component for serialization & editor discovery
#[Property]Property?string $name, ?string $type, ?string $editorHint, ?string $descriptionExposes property to editor
#[Hidden]Property-Hides property from editor
#[Category]Classstring $nameGroups properties in inspector (Core, Rendering, Physics, etc.)
#[Range]Propertyfloat $min, float $maxNumeric range constraints for sliders

Naming Convention ​

Component classes use noun names without suffix: MeshRenderer, BoxCollider2D, Transform3D.

Released under the MIT License.