MCPcopy
hub / github.com/opentrace/opentrace / findNodeAt

Method findNodeAt

ui/src/components/pixi/PixiRenderer.ts:2148–2159  ·  view source on GitHub ↗

Find the nearest node to (worldX, worldY) within maxDistance.

(
    worldX: number,
    worldY: number,
    maxDistance = 20,
  )

Source from the content-addressed store, hash-verified

2146
2147 /** Find the nearest node to (worldX, worldY) within maxDistance. */
2148 findNodeAt(
2149 worldX: number,
2150 worldY: number,
2151 maxDistance = 20,
2152 ): PixiNode | null {
2153 if (!this._quadtree) return null;
2154 // In 3D mode, rebuild quadtree every hit test since projected positions
2155 // change every frame from rotation. This is O(n log n) but only runs
2156 // on click/hover (~20fps), not every render frame.
2157 if (this.mode3d) this.rebuildQuadtree();
2158 return this._quadtree.find(worldX, worldY, maxDistance) ?? null;
2159 }
2160
2161 /**
2162 * Find the nearest edge to (worldX, worldY) within maxDistance.

Callers 2

setupInteractionMethod · 0.95
pointerUpMethod · 0.95

Calls 1

rebuildQuadtreeMethod · 0.95

Tested by

no test coverage detected