({ nodes, path, onTarget }: { nodes: readonly GraphNode[]; path: ScenePath; onTarget: (target: CameraTarget) => void })
| 535 | const PATH_PANEL_INSET = 440; |
| 536 | |
| 537 | function PathFrame({ nodes, path, onTarget }: { nodes: readonly GraphNode[]; path: ScenePath; onTarget: (target: CameraTarget) => void }): null { |
| 538 | const camera = useThree((state) => state.camera); |
| 539 | const size = useThree((state) => state.size); |
| 540 | const key = `${path.labels}:${path.steps.map((step) => `${step.from}>${step.to}`).join(',')}`; |
| 541 | const latest = useRef({ nodes, size, onTarget }); |
| 542 | latest.current = { nodes, size, onTarget }; |
| 543 | useEffect(() => { |
| 544 | const { nodes: drawn, size: viewport, onTarget: report } = latest.current; |
| 545 | if (!(camera instanceof THREE.PerspectiveCamera) || viewport.height <= 0) return; |
| 546 | const ids = new Set(pathNodeIds(path)); |
| 547 | const points = drawn.filter((node) => ids.has(node.id)).map((node) => ({ x: node.x, y: node.y, z: node.z })); |
| 548 | if (points.length === 0) return; |
| 549 | const direction = camera.getWorldDirection(new THREE.Vector3()); |
| 550 | const frame = pathFrame(points, { direction, up: camera.up }, viewport, camera.fov, |
| 551 | { left: Math.min(PATH_PANEL_INSET, viewport.width * 0.4), top: 0 }); |
| 552 | report({ position: new THREE.Vector3(frame.position.x, frame.position.y, frame.position.z), |
| 553 | lookAt: new THREE.Vector3(frame.lookAt.x, frame.lookAt.y, frame.lookAt.z) }); |
| 554 | // Nur ein neuer Pfad rahmt neu, siehe oben. |
| 555 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 556 | }, [key, camera]); |
| 557 | return null; |
| 558 | } |
| 559 | |
| 560 | /* Bildratenmesser und Bildratendeckel (W10) */ |
| 561 |
nothing calls this directly
no test coverage detected