Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Nov 18, 2024
1 parent f7b9109 commit 3ddc0af
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ export function ReadoutWrapper(props: ReadooutWrapperProps): React.ReactNode {
setTriggerHomeCounter((prev) => prev + 1);
}

function handleMouseEvent(event: MapMouseEvent): void {
const handleMouseEvent = React.useCallback(function handleMouseEvent(event: MapMouseEvent): void {
if (event.type === "hover") {
assembler.current?.getMultiViewPickingInfo(event);
}
}
}, []);

const currentCursorWorldCoordinates: [number, number] | null = pickingInfo[activeViewPortId]?.coordinates
? [pickingInfo[activeViewPortId].coordinates?.x ?? 0, pickingInfo[activeViewPortId].coordinates?.y ?? 0]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { CompositeLayer } from "@deck.gl/core";
import { CompositeLayer, CompositeLayerProps, Layer, UpdateParameters } from "@deck.gl/core";
import { IconLayer } from "@deck.gl/layers";

const CROSSHAIR_SVG = `<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 28.7.2, SVG Export Plug-In . SVG Version: 9.03 Build 54978) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 150 150" style="enable-background:new 0 0 150 150;" xml:space="preserve">
<rect x="72" y="72" width="9" height="9"/>
<rect x="9" y="72" width="54" height="9"/>
<rect x="72" y="9" width="9" height="54"/>
<rect x="90" y="72" width="54" height="9"/>
<rect x="72" y="90" width="9" height="54"/>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="150px" height="150px"
viewBox="0 0 150 150" xml:space="preserve">
<rect x="72" y="72" width="9" height="9" fill="#eb4034" />
<rect x="9" y="72" width="54" height="9" fill="#eb4034" />
<rect x="72" y="9" width="9" height="54" fill="#eb4034" />
<rect x="90" y="72" width="54" height="9" fill="#eb4034" />
<rect x="72" y="90" width="9" height="54" fill="#eb4034" />
</svg>`;

export type CursorTrackingLayerProps = {
Expand All @@ -23,26 +22,33 @@ function svgToDataURL(svg: string): string {

export class CursorTrackingLayer extends CompositeLayer<CursorTrackingLayerProps> {
static layerName: string = "CursorTrackingLayer";
private _icon = {
id: "cursor-tracking-icon",
url: svgToDataURL(CROSSHAIR_SVG),
width: 150,
height: 150,
};
private _data: [number, number, number][] = [];

updateState(params: UpdateParameters<Layer<CursorTrackingLayerProps & Required<CompositeLayerProps>>>): void {

Check failure on line 33 in frontend/src/modules/2DViewer/view/customDeckGlLayers/CursorTrackingLayer.ts

View workflow job for this annotation

GitHub Actions / frontend

'params' is defined but never used
this._data = this.props.worldCoordinates ? [[...this.props.worldCoordinates, 0]] : [];
}

renderLayers() {
if (!this.props.worldCoordinates) {
return [];
}

return [
new IconLayer(
this.getSubLayerProps({
id: "cursor-tracking-icon-layer",
getIcon: () => ({
id: "cursor-tracking-icon",
url: svgToDataURL(CROSSHAIR_SVG),
width: 150,
height: 150,
}),
data: [...this.props.worldCoordinates, 0],
getIcon: () => this._icon,
data: this._data,
getPosition: (d: [number, number, number]) => d,
getSize: () => 24,
getSize: 24,
sizeUnits: "pixels",
getColor: [255, 0, 0],
getColor: () => [0, 0, 0],
pickable: false,
})
),
Expand Down

0 comments on commit 3ddc0af

Please sign in to comment.