UNPKG

@webviz/subsurface-viewer

Version:

3D visualization component for subsurface reservoir data

28 lines 1.18 kB
import React from "react"; import { v4 } from "uuid"; import { CrosshairLayer } from "../../layers"; export function useMultiViewCursorTracking(props) { var _a, _b; const id = React.useRef(`crosshair-${v4()}`); let worldCoordinates = null; if (((_a = props.worldCoordinates) === null || _a === void 0 ? void 0 : _a.length) === 3) { worldCoordinates = props.worldCoordinates; } if (((_b = props.worldCoordinates) === null || _b === void 0 ? void 0 : _b.length) === 2) { worldCoordinates = [...props.worldCoordinates, 0]; } const crosshairLayer = new CrosshairLayer(Object.assign({ id: id.current, worldCoordinates }, props.crosshairProps)); const layers = [...props.layers, crosshairLayer]; const viewports = props.viewports.map((viewport) => { var _a; if (viewport.id !== props.activeViewportId) { return Object.assign(Object.assign({}, viewport), { layerIds: [...((_a = viewport.layerIds) !== null && _a !== void 0 ? _a : []), id.current] }); } return viewport; }); return { viewports, layers, }; } //# sourceMappingURL=useMultiViewCursorTracking.js.map