@kognifai/cogsengine
    Preparing search index...

    Class TransformComponent

    Defines a 4x4 transformation matrix for the entity and a global offset for root entities. The transformation can either be set using position, scaling and orientation or by explicit setting of the 4x4 matrix. Transforms can also be parented by setting the parent field. This makes the transform data of a component instance relative to the parent transform.

    Hierarchy (View Summary)

    Index

    Constructors

    • Internal: Component constructor

      Parameters

      • type: string

        type of the component. Ex. "TransformComponent"

      • entity: Entity

        Owning entity. Entity only passed when wrapping existing entity.

      Returns TransformComponent

    Properties

    coordinates: dvec3

    Global coordinates. The global coordinates are absolute and are used to compute the offset from the global origin coordinate stored in the TransformSystem. After computing the offset value, this is combined with the position to form the final translation of the component. Component World coordinate offset = (coordinates - Origin + position). If the Entity is a child entity, the coordinate field is ignored.

    isTyped: boolean

    Internal flag set if component is a Cogs Core component.

    position: vec3

    Local position relative to the global coordinates, or the parent coordinate system if the parent field is set. Do Not set or get if transformFlags is non-zero.

    rotation: quat

    Rotation given as a quaternion. Do Not set or get if transformFlags is non-zero.

    scale: vec3

    Scale factor to apply to each of the axes. Do Not set or get if transformFlags is non-zero.

    transform: mat4

    Complete transformation. Only used if field transformFlags is set. Do Not set or get if transformFlags is zero.

    transformFlags: number

    Transform flags. Set to 0 if individual scale, rotate, translate fields shall be used. Non-zero if the Field transform shall be used. If the transform field has been used and switching back to value 0 if this field, all the fields: rotation, position and scale must be set.

    Accessors

    • get entity(): Entity

      Gets the optional owning entity

      Returns Entity

    • set entity(entity: Entity): void

      Internal: set owning entity.

      Parameters

      Returns void

    • get name(): string

      Component name == type. For compatibility

      Returns string

    • get type(): string

      Gets the type of the component. Ex. "TransformComponent", "SceneComponent" etc.

      Returns string

    Methods

    • Internal: Creates a new component of the given type (name). Component is wrapped when adding to an entity.

      Parameters

      • type: string

        Type of the component. Ex. "TransformComponent"

      Returns Component

      Created Cogs.js component.

    • Internal: Creates a new component being wrapped as an existing member of the entity

      Parameters

      • type: string

        Type of the component. Ex. "TransformComponent"

      • entity: Entity

        The owning entity

      Returns Component

      Created Cogs.js component.