Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions typescript/packages/subsurface-viewer/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ const Map: React.FC<MapProps> = ({
radius: pickingRadius,
});

pickInfos.forEach((itemPick) => {
const extendedPickInfos = pickInfos.map((itemPick) => {
const extItemPick = makeExtendedPickingInfo(itemPick);
// Z value should not take into account the Z scale factor.
viewController.unscaledTarget(
Expand All @@ -663,8 +663,10 @@ const Map: React.FC<MapProps> = ({
}
});
}

return extItemPick;
});
return pickInfos;
return extendedPickInfos;
},
[pickingDepth, pickingRadius, viewController]
);
Expand All @@ -687,12 +689,8 @@ const Map: React.FC<MapProps> = ({
event.tapCount == 2 // Note. Detect double click.
) {
// Left button click identifies new camera rotation anchor.
if (infos.length >= 1) {
if (infos[0].coordinate) {
viewController.setScaledTarget(
infos[0].scaledCoordinate
);
}
if (infos.length >= 1 && infos[0].coordinate) {
viewController.setScaledTarget(infos[0].scaledCoordinate);
}
}

Expand Down Expand Up @@ -1195,6 +1193,10 @@ class ViewController {
* @param scaledTarget scaled 3D point.
*/
public setScaledTarget(scaledTarget: Point2D | Point3D | undefined): void {
if (!scaledTarget) {
return console.warn("Undefined scale-target! Skipping...");
}

const vsKey = Object.keys(this.result_.deckglViewStates).at(0);
if (vsKey) {
// deep clone to notify change (memo checks object address)
Expand Down