Skip to content

Class: CrosshairManager ​

Defined in: CrosshairManager.ts:15

Manages a 3D crosshair (three orthogonal lines) that can be positioned at a vertex on a surface mesh. Supports selection and hover modes.

Constructors ​

Constructor ​

ts
new CrosshairManager(requestRender): CrosshairManager;

Defined in: CrosshairManager.ts:34

Parameters ​

requestRender ​

() => void

Returns ​

CrosshairManager

Properties ​

size ​

ts
size: number = 1.5;

Defined in: CrosshairManager.ts:20


color ​

ts
color: number = 0xffcc00;

Defined in: CrosshairManager.ts:21


surfaceId ​

ts
surfaceId: string | null = null;

Defined in: CrosshairManager.ts:22


vertexIndex ​

ts
vertexIndex: number | null = null;

Defined in: CrosshairManager.ts:23


visible ​

ts
visible: boolean = false;

Defined in: CrosshairManager.ts:24


mode ​

ts
mode: CrosshairMode | null = null;

Defined in: CrosshairManager.ts:25


hoverThrottleMs ​

ts
hoverThrottleMs: number = 80;

Defined in: CrosshairManager.ts:27


lastHoverUpdate ​

ts
lastHoverUpdate: number = -Infinity;

Defined in: CrosshairManager.ts:28

Methods ​

show() ​

ts
show(
   mesh, 
   surfaceId, 
   vertexIndex, 
   options?
): void;

Defined in: CrosshairManager.ts:41

Show the crosshair at a specific vertex on a mesh.

Parameters ​

mesh ​

Mesh

surfaceId ​

string

vertexIndex ​

number

options? ​

CrosshairOptions

Returns ​

void


hide() ​

ts
hide(): void;

Defined in: CrosshairManager.ts:83

Hide the crosshair and clear tracking state.

Returns ​

void


toggle() ​

ts
toggle(
   mesh, 
   surfaceId?, 
   vertexIndex?, 
   options?
): void;

Defined in: CrosshairManager.ts:102

Toggle crosshair visibility. If hidden and a target is provided (or remembered from a previous show()), it will be re-shown.

Parameters ​

mesh ​

| Mesh<BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>, | Material<MaterialEventMap> | Material<MaterialEventMap>[], Object3DEventMap> | null

surfaceId? ​

string

vertexIndex? ​

number

options? ​

CrosshairOptions

Returns ​

void


canHoverUpdate() ​

ts
canHoverUpdate(): boolean;

Defined in: CrosshairManager.ts:124

Returns true if a hover update is allowed (throttle has elapsed).

Returns ​

boolean


scheduleHoverUpdate() ​

ts
scheduleHoverUpdate(run): void;

Defined in: CrosshairManager.ts:138

Leading + trailing hover throttle. Runs run immediately when the throttle window has elapsed; otherwise remembers the latest run and invokes it once the window closes, so the final pointer position is never dropped. Pending work is discarded by cancelPendingHover and dispose.

Parameters ​

run ​

() => void

Returns ​

void


cancelPendingHover() ​

ts
cancelPendingHover(): void;

Defined in: CrosshairManager.ts:158

Drop a trailing hover update scheduled by scheduleHoverUpdate.

Returns ​

void


toStateJSON() ​

ts
toStateJSON(): object;

Defined in: CrosshairManager.ts:166

Returns ​

object

visible ​
ts
visible: boolean;
surfaceId ​
ts
surfaceId: string | null;
vertexIndex ​
ts
vertexIndex: number | null;
size ​
ts
size: number;
color ​
ts
color: number;
mode ​
ts
mode: string | null;

dispose() ​

ts
dispose(): void;

Defined in: CrosshairManager.ts:181

Dispose all GPU resources (geometries, material) and drop any pending trailing hover update.

Returns ​

void

Released under the MIT License.