Keeps a node aimed at another node, turning a chosen axis to face it — the way to make an object (or camera) track a moving point.
Declarative element:
<sk-target-at-constraint>
Not on the sk.* global — construct via the declarative element or a module import.
This is the look-at member of the Constraint family: like every constraint
it drives its constrained target by recomputing from live scene state each frame —
here it recomputes the target's
orientation so the chosen axis keeps pointing at another node, so the aimer
tracks that node even as it moves.
Key attributes. target names the node to aim at, by #id — either any
scene node or a dedicated TargetAt node used as a movable look-at point.
axis chooses which of the aimer's local axes points at the target (e.g. +y
for an arrow, whose geometry heads along +Y); pick the axis that matches the
object's natural "forward". up-node optionally references a node that fixes the
roll about the aim direction when the default up would be ambiguous.
Related. Pairs with the sk-target-at support node (a movable,
optionally visualized look-at point) and its class TargetAt. Sibling
constraints in the Constraint family include
sk-orbit-constraint (revolve around a pivot) and
sk-align-to-spline-constraint (follow a path); the GPU-parallel
sk-target-at-point-constraint aims every clone of a Cloner at a
shared target at once.
constructor(config?: { source: TargetAt | SceneNode | string; axis?: AxisOrientation; upNode?: SceneNode | string; id?: string })
Inherited from: Constraint, SkenraAnimatable
— see those pages for inherited members.
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
sourceconfig-only |
TargetAt | SceneNode | string |
— | The look-at source: a TargetAt, or a SceneNode used |
TargetAtConstraintConfig |
axisanimatable |
AxisOrientation |
"+z" |
Which local axis of the constrained node points at the target. | TargetAtConstraint |
upNodeanimatable |
SceneNode | string |
— | Node whose Y-axis supplies the up direction, keeping the look-at | TargetAtConstraint |
idconfig-only |
string |
— | Optional unique identifier for the constraint. | TargetAtConstraintConfig |
| Property | Type | Default | Description | Declared by |
|---|---|---|---|---|
targetread-onlyanimatable |
TargetAt |
— | The look-at reference: the TargetAt whose position the |
TargetAtConstraint |
priority |
number |
— | Gets the priority for this modifier in the effect stack. | Constraint |
sceneread-only |
any |
— | Gets the Scene this animatable belongs to, if any. | SkenraAnimatable |
animationsread-only |
SkenraAnimation[] |
— | Public getter for the animations affecting this target. | SkenraAnimatable |
| Method | Description | Declared by |
|---|---|---|
setTargetAtNode(value: TargetAt | null): void |
Replaces the TargetAt helper, removing any previous | TargetAtConstraint |
animate(firstArg: TypedKeyframe<this>[] | TypedPropertyIndexedKeyframes<this> | Record<string, any> | globalThis.Keyframe[] | globalThis.PropertyIndexedKeyframes | null, secondArg?: number | KeyframeAnimationOptions | globalThis.KeyframeAnimationOptions): SkenraAnimation & Animation |
Creates a new SkenraAnimation for this target per Web Animations API. | SkenraAnimatable |
removeAnimation(animation: SkenraAnimation): boolean |
Removes a specific animation from this object. | SkenraAnimatable |
constrain(type: K, config: ConstraintConfigMap[K]): ConstraintReturnMap[K] |
Creates a constraint on this Animatable using a fluent API. | SkenraAnimatable |
// Aim a camera's -z at a movable look-at node.
const lookAtNode = new TargetAt({ id: 'target', visualize: true });
scene.appendChild(lookAtNode);
camera.constrain('targetAt', { source: lookAtNode, axis: '-z' });