diff --git a/typescript/packages/subsurface-viewer/src/extensions/collision-modifier-extension.ts b/typescript/packages/subsurface-viewer/src/extensions/collision-modifier-extension.ts index e93ee4ad3..2a5f7cdfb 100644 --- a/typescript/packages/subsurface-viewer/src/extensions/collision-modifier-extension.ts +++ b/typescript/packages/subsurface-viewer/src/extensions/collision-modifier-extension.ts @@ -3,7 +3,9 @@ import { CollisionFilterExtension } from "@deck.gl/extensions"; const injectionVs = { "vs:DECKGL_FILTER_COLOR": ` - color.a = 1.0 / collision_fade; // Note: this will counteract the fading of the labels caused by deck.gl's CollisionFilterExtension + if (collision_fade != 0.0) { + color.a = 1.0 / collision_fade; // Note: this will counteract the fading of the labels caused by deck.gl's CollisionFilterExtension + } `, }; diff --git a/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts b/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts index 5df70725f..4b69f46bc 100644 --- a/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts +++ b/typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts @@ -52,6 +52,10 @@ import { invertPath, splineRefine, } from "./utils/spline"; +import { create, all } from "mathjs"; + +const math = create(all, { randomSeed: "a" }); +const randomFunc = math?.random ? math.random : Math.random; type StyleAccessorFunction = ( object: Feature, @@ -117,7 +121,7 @@ export interface WellsLayerProps extends ExtendedLayerProps { /** If true will prevent well name cluttering by not displaying overlapping names. * default false. */ - wellNameReduceClutter: boolean; + hideOverlappingWellNames: boolean; isLog: boolean; depthTest: boolean; /** If true means that input z values are interpreted as depths. @@ -154,7 +158,7 @@ const defaultProps = { wellNameAtTop: false, wellNameSize: 14, wellNameColor: [0, 0, 0, 255], - wellNameReduceClutter: false, + hideOverlappingWellNames: false, selectedWell: "@@#editedData.selectedWells", // used to get data from deckgl layer depthTest: true, ZIncreasingDownwards: true, @@ -628,7 +632,6 @@ export default class WellsLayer extends CompositeLayer { collisionEnabled: true, getCollisionPriority: (d: Feature) => { const labelSize = d.properties?.["name"].length ?? 1; - //return labelSize; if (is3d) { // In 3D prioritize according to label size. return labelSize; @@ -642,7 +645,7 @@ export default class WellsLayer extends CompositeLayer { ); const priority = labelPosition - ? (labelPosition?.[2] ?? 1) / 10 + Math.random() // priority must be in [-1000, 1000] + ? (labelPosition?.[2] ?? 1) / 10 + randomFunc() // priority must be in [-1000, 1000] : labelSize; return priority; } @@ -680,10 +683,20 @@ export default class WellsLayer extends CompositeLayer { parameters, visible: this.props.wellNameVisible && !fastDrawing, - ...(this.props.wellNameReduceClutter ? clutterProps : {}), + ...(this.props.hideOverlappingWellNames ? clutterProps : {}), }) ); + console.log(randomFunc()) + console.log(randomFunc()) + console.log(randomFunc()) + console.log(randomFunc()) + console.log(randomFunc()) + console.log(randomFunc()) + console.log(randomFunc()) + console.log(randomFunc()) + console.log(randomFunc()) + const layers = [ outlineLayer, logLayer, diff --git a/typescript/packages/subsurface-viewer/src/storybook/layers/WellsLayer.stories.tsx b/typescript/packages/subsurface-viewer/src/storybook/layers/WellsLayer.stories.tsx index 71f734b1d..469957e74 100644 --- a/typescript/packages/subsurface-viewer/src/storybook/layers/WellsLayer.stories.tsx +++ b/typescript/packages/subsurface-viewer/src/storybook/layers/WellsLayer.stories.tsx @@ -659,7 +659,7 @@ export const SimplifiedRendering: StoryObj = { }; type ClutterProps = { - wellNameReduceClutter: boolean; + hideOverlappingWellNames: boolean; wellNameAtTop: boolean; }; @@ -674,7 +674,7 @@ const ReducedWellNameClutterComponent: React.FC = ( wellNameVisible: true, wellNameAtTop: props.wellNameAtTop, wellHeadStyle: { size: 4 }, - wellNameReduceClutter: props.wellNameReduceClutter, + hideOverlappingWellNames: props.hideOverlappingWellNames, refine: true, outline: true, ZIncreasingDownwards: false, @@ -712,7 +712,7 @@ export const ReducedWellNameClutter3D: StoryObj< typeof ReducedWellNameClutterComponent > = { args: { - wellNameReduceClutter: false, + hideOverlappingWellNames: false, wellNameAtTop: true, }, render: (args) => , @@ -729,7 +729,7 @@ const ReducedWellNameClutterComponent2D: React.FC = ( wellNameVisible: true, wellNameAtTop: props.wellNameAtTop, wellHeadStyle: { size: 4 }, - wellNameReduceClutter: props.wellNameReduceClutter, + hideOverlappingWellNames: props.hideOverlappingWellNames, refine: true, outline: true, ZIncreasingDownwards: false, @@ -758,7 +758,7 @@ export const ReducedWellNameClutter2D: StoryObj< typeof ReducedWellNameClutterComponent > = { args: { - wellNameReduceClutter: false, + hideOverlappingWellNames: false, wellNameAtTop: true, }, render: (args) => ,