OverlayAnnotationNode

← prev index next →

Pins HTML/SVG/Markdown to a point in the 3D scene that is ALWAYS on top — a HUD, tooltip, or badge that geometry can never hide.

Remarks

This is the always-on-top member of the AbstractDomAnnotationNode annotation family: like every annotation its content is the element's own body and it tracks a world position as the camera moves. What distinguishes it from a sk-live-annotation is that it never participates in depth testing — its layer draws above all scene content and every other annotation, so it is never occluded. That makes it the choice for UI that must stay readable no matter what is in front of it: heads-up displays, tooltips, always-accessible panels, debug overlays.

Key attributes. The body content is the element's children (HTML, SVG, or — with md — Markdown), not an attribute; it is real, interactive DOM with full CSS (including animations). anchor chooses which edge sits on the world point; scale-with-distance makes it shrink with perspective. Content is not sanitized, so untrusted markup must be sanitized by the author first.

Related. When an annotation should read as part of the world and be hidden by geometry in front of it, use sk-live-annotation instead; for SVG drawn into the scene as a depth-tested texture, use sk-rasterized-annotation.

Constructor

constructor(config?: { content?: string; md?: boolean; anchor?: AnchorAlignment; scaleWithDistance?: boolean; class?: string; style?: string; overlay?: boolean; overlayOccludedOpacity?: number; id?: string; x?: number; y?: number; z?: number; h?: number; p?: number; b?: number; quaternion?: Quaternion; sx?: number; sy?: number; sz?: number; s?: number })

Properties

Config Properties

PropertyTypeDefaultDescriptionDeclared by
contentconfig-only string The annotation body content as an inline markup string. AbstractDomAnnotationConfig
md boolean false Whether this annotation's light-DOM body is Markdown source. AbstractDomAnnotationNode
anchor AnchorAlignment "center" Gets the anchor alignment for this annotation. AbstractDomAnnotationNode
scaleWithDistance boolean false Gets whether this annotation scales with camera distance. AbstractDomAnnotationNode
classconfig-only string Standard HTML class for the annotation host element. AbstractDomAnnotationConfig
styleconfig-only string Standard inline style for the annotation host element. AbstractDomAnnotationConfig
overlay boolean false Whether this node renders as an overlay with depth-aware translucency. RenderableNode
overlayOccludedOpacity number 0.3 Alpha multiplier for overlay fragments occluded by scene geometry. RenderableNode
idconfig-only string Unique identifier for the node, reflected to the host id attribute. SceneNodeConfig
xanimatable number 0 Gets the X position component. SceneNode
yanimatable number 0 Gets the Y position component. SceneNode
zanimatable number 0 Gets the Z position component. SceneNode
hanimatable number 0 Gets the heading (Y-axis) rotation in radians. SceneNode
panimatable number 0 Gets the pitch (X-axis) rotation in radians. SceneNode
banimatable number 0 Gets the bank (Z-axis) rotation in radians. SceneNode
quaternionanimatable Quaternion Gets the rotation as a quaternion. SceneNode
sxanimatable number 1 Gets the X-axis scale factor. SceneNode
syanimatable number 1 Gets the Y-axis scale factor. SceneNode
szanimatable number 1 Gets the Z-axis scale factor. SceneNode
sconfig-only number Uniform scale factor for all axes (overrides sx, sy, sz if provided) SceneNodeConfig

Other Properties

PropertyTypeDefaultDescriptionDeclared by
hRad number 0 Gets the heading (Y-axis) rotation in radians. SceneNode
pRad number 0 Gets the pitch (X-axis) rotation in radians. SceneNode
bRad number 0 Gets the bank (Z-axis) rotation in radians. SceneNode
hDeg number 0 Gets the heading (Y-axis) rotation in degrees. SceneNode
pDeg number 0 Gets the pitch (X-axis) rotation in degrees. SceneNode
bDeg number 0 Gets the bank (Z-axis) rotation in degrees. SceneNode
xBasebase value number Gets the base (non-animated) value of X position. SceneNode
yBasebase value number Gets the base (non-animated) value of Y position. SceneNode
zBasebase value number Gets the base (non-animated) value of Z position. SceneNode
hBasebase value number 0 Gets the base (non-animated) value of heading (Y-axis rotation). SceneNode
pBasebase value number 0 Gets the base (non-animated) value of pitch (X-axis rotation). SceneNode
bBasebase value number 0 Gets the base (non-animated) value of bank (Z-axis rotation). SceneNode
quaternionBasebase value Quaternion Gets the base (non-animated) quaternion rotation. SceneNode
sxBasebase value number Gets the base (non-animated) value of X-axis scale. SceneNode
syBasebase value number Gets the base (non-animated) value of Y-axis scale. SceneNode
szBasebase value number Gets the base (non-animated) value of Z-axis scale. SceneNode
draggable boolean false Gets whether this node can be dragged. SceneNode
parentread-only SceneNode | null The parent node in the scene graph, or null at the root. SceneNode
sceneread-only any Gets the Scene this node belongs to, if any. SceneNode
posread-only Point3D Gets the world-space position of this node. SceneNode
matrixread-only Float32Array<ArrayBufferLike> Gets the computed 4x4 transformation matrix. SceneNode
animationsread-only SkenraAnimation[] Public getter for the animations affecting this target. SkenraAnimatable

Methods

MethodDescriptionDeclared by
getBoundsInSpace(targetSpaceMatrix: Float32Array): { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number; } | null Computes the bounding box of this annotation in the specified target space. AbstractDomAnnotationNode
addMaterialPaint(material: Material, paintTarget: PaintTarget, options?: any): Paint Applies a material to this node for a specific paint target. SceneNode
getPaints(): ReadonlyMap<PaintTarget, Paint> SceneNode
getOwnPaints(): readonly Paint[] Gets only the paints directly applied to this node (not inherited). SceneNode
removePaint(paint: Paint): void Removes a paint from this node. SceneNode
getWorldPosition(): number[] Returns this node’s origin in world space. SceneNode
getWorldMatrix(): Float32Array<ArrayBufferLike> Returns this node’s world transform — its local transform composed with all ancestor transforms. SceneNode
setViewportPosition(camera: AbstractCamera, x: number, y: number, z: number = 0.5): boolean Sets the node's local translation so that it appears at the specified viewport position. SceneNode
getViewportPosition(camera?: AbstractCamera): [number, number, number] | null Returns the node's current world position projected to viewport CSS pixel coordinates. SceneNode
setNDCPosition(camera: AbstractCamera, ndcX: number, ndcY: number, ndcZ: number = 0.5): boolean Sets the node's local translation so that it appears at the specified NDC position in the viewport. SceneNode
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

Example

// HUD element that's always visible
const hud = new OverlayAnnotationNode({
    id: 'hud',
    content: `
        <style>.hud { position: fixed; padding: 16px; background: rgba(0,0,0,0.8); }</style>
        <div class="hud"><span>Score: 100</span></div>
    `
});

// Access DOM for event listeners
hud.domRoot?.querySelector('span')?.addEventListener('click', () => {
    console.log('HUD clicked!');
});

// Tooltip that stays visible
const tooltip = new OverlayAnnotationNode({
    id: 'tooltip',
    content: '**Tip:** Click to interact', md: true
});

scene.appendChild(hud);
scene.appendChild(tooltip);