RemoteTransform3D

View source

Copies selected local 3D transform channels from a source entity to the entity that owns this component.

Add this component together with Position3D, Orientation3D, and Scale3D. The entity handle identifies the source by its slot index and generation. Selected channels copy the source position, orientation, or scale, while disabled channels retain the target’s current local value. The source is skipped when its handle is stale, its entity is missing, or its complete local transform is unavailable.

The component also stores an offsetTransform, which defaults to the identity Affine3. The current implementation decomposes this affine, but does not write the non-mutating arithmetic results back to the target. Selected channels therefore receive the source values without a translation, orientation, or scale offset.

Examples

import { World } from '@wimaengine/ecs'
import {
  Orientation3D,
  Position3D,
  RemoteTransform3D,
  Scale3D
} from '@wimaengine/transform'

const world = new World()
const source = world.spawn([
  new Position3D(3, 0, 0),
  new Orientation3D(),
  new Scale3D()
])

const follower = new RemoteTransform3D(source)
follower.copyScale = false
world.spawn([
  new Position3D(),
  new Orientation3D(),
  new Scale3D(),
  follower
])

// With RemoteTransform3DPlugin enabled, the follower follows the source's
// position and orientation while retaining its own local scale.

Constructor


constructor(entity: EntityHandle)

View source

Creates a remote transform that follows entity.

Parameters

NameDescriptionDefault
entity

Generation-aware handle of the source entity.

—

Properties


copyTranslation: boolean

View source

Whether to copy the source’s local position to the target.

When false, the target keeps its current local position. The current implementation copies the source position without applying an offset.

Default: true

  • @defaultValue `true`

copyOrientation: boolean

View source

Whether to copy the source’s local orientation to the target.

When false, the target keeps its current local orientation. The current implementation copies the source orientation without applying an offset.

Default: true

  • @defaultValue `true`

copyScale: boolean

View source

Whether to copy the source’s local scale to the target.

When false, the target keeps its current local scale. The current implementation copies the source scale without applying an offset.

Default: true

  • @defaultValue `true`

entity: EntityHandle

View source

Generation-aware handle for the source entity whose local transform is followed. A stale handle does not follow a different entity that later reuses the same slot.

offsetTransform: Affine3

View source

Affine offset stored with this component.

It starts as the identity affine. The current implementation decomposes it before processing selected channels, but does not write the resulting non-mutating arithmetic values back to the target. Enabled channels therefore receive source values without an offset.

Default: ...

Methods


staticcopy(source: RemoteTransform3D, target?: RemoteTransform3D): RemoteTransform3D

View source

Copies a remote transform into an output component.

The entity handle is assigned to the output, while offsetTransform is copied into a new Affine3, so later offset changes do not share the source affine object.

Parameters

NameDescriptionDefault
source

Remote transform to copy.

—
target?

Component to populate.

...

Returns

The populated output component.

staticclone(target: RemoteTransform3D): RemoteTransform3D

View source

Creates an independent copy of a remote transform.

Parameters

NameDescriptionDefault
target

Remote transform to clone.

—

Returns

A new component with the same settings.

staticserialize(value: RemoteTransform3D): RemoteTransform3DSerial

View source

Converts a remote transform to its serialized representation.

The copy flags are written as booleans. The entity is delegated to EntityHandle.serialize, and the offset is delegated to Affine3.serialize. The current serializer emits the entity value in the representation returned by EntityHandle.serialize; validation and deserialization use the representation accepted by EntityHandle.validateSerial and EntityHandle.deserialize, so the serialized entity value is not currently accepted by validateSerial as-is.

Parameters

NameDescriptionDefault
value

Remote transform to serialize.

—

Returns

Serialized remote transform.

staticvalidateSerial(value: unknown): value is RemoteTransform3DSerial

View source

Checks whether a value has the fields and primitive shapes expected by the remote transform serializers.

The three copy settings must be booleans. The entity and offset values are checked with EntityHandle.validateSerial and Affine3.validateSerial; this validates their serialized shapes, not whether the referenced entity is currently alive in a world.

Parameters

NameDescriptionDefault
value——

Returns

Whether value is valid serialized data.

staticdeserialize(value: RemoteTransform3DSerial, out?: RemoteTransform3D): RemoteTransform3D

View source

Reconstructs a remote transform from serialized values.

The optional output component is updated in place. Its entity handle and offset affine are also reused when their deserializers support an output value. This method does not check the value first; call RemoteTransform3D.validateSerial when input may be untrusted.

Parameters

NameDescriptionDefault
value

Serialized remote transform.

—
out?

Component to populate.

...

Returns

The populated or newly created component.