Skip to content

Commit e3d04fc

Browse files
committed
Code review fixes.
1 parent 73ae130 commit e3d04fc

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

typescript/packages/subsurface-viewer/src/extensions/collision-modifier-extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { CollisionFilterExtension } from "@deck.gl/extensions";
33

44
const injectionVs = {
55
"vs:DECKGL_FILTER_COLOR": `
6-
color.a = 1.0 / collision_fade; // Note: this will counteract the fading of the labels caused by deck.gl's CollisionFilterExtension
6+
if (collision_fade != 0.0) {
7+
color.a = 1.0 / collision_fade; // Note: this will counteract the fading of the labels caused by deck.gl's CollisionFilterExtension
8+
}
79
`,
810
};
911

typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ import {
5252
invertPath,
5353
splineRefine,
5454
} from "./utils/spline";
55+
import { create, all } from "mathjs";
56+
57+
const math = create(all, { randomSeed: "a" });
58+
const randomFunc = math?.random ? math.random : Math.random;
5559

5660
type StyleAccessorFunction = (
5761
object: Feature,
@@ -117,7 +121,7 @@ export interface WellsLayerProps extends ExtendedLayerProps {
117121
/** If true will prevent well name cluttering by not displaying overlapping names.
118122
* default false.
119123
*/
120-
wellNameReduceClutter: boolean;
124+
hideOverlappingWellNames: boolean;
121125
isLog: boolean;
122126
depthTest: boolean;
123127
/** If true means that input z values are interpreted as depths.
@@ -154,7 +158,7 @@ const defaultProps = {
154158
wellNameAtTop: false,
155159
wellNameSize: 14,
156160
wellNameColor: [0, 0, 0, 255],
157-
wellNameReduceClutter: false,
161+
hideOverlappingWellNames: false,
158162
selectedWell: "@@#editedData.selectedWells", // used to get data from deckgl layer
159163
depthTest: true,
160164
ZIncreasingDownwards: true,
@@ -628,7 +632,6 @@ export default class WellsLayer extends CompositeLayer<WellsLayerProps> {
628632
collisionEnabled: true,
629633
getCollisionPriority: (d: Feature<Geometry, GeoJsonProperties>) => {
630634
const labelSize = d.properties?.["name"].length ?? 1;
631-
//return labelSize;
632635
if (is3d) {
633636
// In 3D prioritize according to label size.
634637
return labelSize;
@@ -642,7 +645,7 @@ export default class WellsLayer extends CompositeLayer<WellsLayerProps> {
642645
);
643646

644647
const priority = labelPosition
645-
? (labelPosition?.[2] ?? 1) / 10 + Math.random() // priority must be in [-1000, 1000]
648+
? (labelPosition?.[2] ?? 1) / 10 + randomFunc() // priority must be in [-1000, 1000]
646649
: labelSize;
647650
return priority;
648651
}
@@ -680,7 +683,7 @@ export default class WellsLayer extends CompositeLayer<WellsLayerProps> {
680683
parameters,
681684
visible: this.props.wellNameVisible && !fastDrawing,
682685

683-
...(this.props.wellNameReduceClutter ? clutterProps : {}),
686+
...(this.props.hideOverlappingWellNames ? clutterProps : {}),
684687
})
685688
);
686689

typescript/packages/subsurface-viewer/src/storybook/layers/WellsLayer.stories.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ export const SimplifiedRendering: StoryObj<typeof SubsurfaceViewer> = {
659659
};
660660

661661
type ClutterProps = {
662-
wellNameReduceClutter: boolean;
662+
hideOverlappingWellNames: boolean;
663663
wellNameAtTop: boolean;
664664
};
665665

@@ -674,7 +674,7 @@ const ReducedWellNameClutterComponent: React.FC<ClutterProps> = (
674674
wellNameVisible: true,
675675
wellNameAtTop: props.wellNameAtTop,
676676
wellHeadStyle: { size: 4 },
677-
wellNameReduceClutter: props.wellNameReduceClutter,
677+
hideOverlappingWellNames: props.hideOverlappingWellNames,
678678
refine: true,
679679
outline: true,
680680
ZIncreasingDownwards: false,
@@ -712,7 +712,7 @@ export const ReducedWellNameClutter3D: StoryObj<
712712
typeof ReducedWellNameClutterComponent
713713
> = {
714714
args: {
715-
wellNameReduceClutter: false,
715+
hideOverlappingWellNames: false,
716716
wellNameAtTop: true,
717717
},
718718
render: (args) => <ReducedWellNameClutterComponent {...args} />,
@@ -729,7 +729,7 @@ const ReducedWellNameClutterComponent2D: React.FC<ClutterProps> = (
729729
wellNameVisible: true,
730730
wellNameAtTop: props.wellNameAtTop,
731731
wellHeadStyle: { size: 4 },
732-
wellNameReduceClutter: props.wellNameReduceClutter,
732+
hideOverlappingWellNames: props.hideOverlappingWellNames,
733733
refine: true,
734734
outline: true,
735735
ZIncreasingDownwards: false,
@@ -758,7 +758,7 @@ export const ReducedWellNameClutter2D: StoryObj<
758758
typeof ReducedWellNameClutterComponent
759759
> = {
760760
args: {
761-
wellNameReduceClutter: false,
761+
hideOverlappingWellNames: false,
762762
wellNameAtTop: true,
763763
},
764764
render: (args) => <ReducedWellNameClutterComponent2D {...args} />,

0 commit comments

Comments
 (0)