constructor(entity: EntityHandle)
View sourceCreates a remote transform that follows entity.
Class
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.
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(entity: EntityHandle)Creates a remote transform that follows entity.
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
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
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
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.
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: ...
copy(source: RemoteTransform3D, target?: RemoteTransform3D): RemoteTransform3DCopies 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.
clone(target: RemoteTransform3D): RemoteTransform3DCreates an independent copy of a remote transform.
default(): RemoteTransform3Dserialize(value: RemoteTransform3D): RemoteTransform3DSerialConverts 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.
validateSerial(value: unknown): value is RemoteTransform3DSerialChecks 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.
deserialize(value: RemoteTransform3DSerial, out?: RemoteTransform3D): RemoteTransform3DReconstructs 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.