Skip to content

Commit 3201944

Browse files
Merge branch 'master' into multiColorLegend
2 parents 1545150 + 2f54e65 commit 3201944

File tree

6 files changed

+202
-91
lines changed

6 files changed

+202
-91
lines changed

react/src/lib/components/SubsurfaceViewer/layers/axes/axesLayer.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ import BoxLayer from "./boxLayer";
1111
import { Position3D, ExtendedLayerProps } from "../utils/layerTools";
1212
import { layersDefaultProps } from "../layersDefaultProps";
1313
import { TextLayer } from "@deck.gl/layers/typed";
14+
import { cloneDeep } from "lodash";
1415

1516
export interface AxesLayerProps<D> extends ExtendedLayerProps<D> {
1617
bounds: [number, number, number, number, number, number];
1718
labelColor?: Color;
1819
labelFontSize?: number;
1920
fontFamily?: string;
2021
axisColor?: Color;
22+
/** If true means that input z values are interpreted as depths.
23+
* For example depth of z = 1000 corresponds to -1000 on the z axis. Default false.
24+
*/
25+
isZDepth: boolean;
2126
}
2227

2328
type TextLayerData = {
@@ -29,22 +34,28 @@ type TextLayerData = {
2934

3035
export default class AxesLayer extends CompositeLayer<AxesLayerProps<unknown>> {
3136
initializeState(): void {
32-
const box_lines = GetBoxLines(this.props.bounds);
37+
const bounds = cloneDeep(this.props.bounds);
38+
if (this.props.isZDepth) {
39+
bounds[2] *= -1;
40+
bounds[5] *= -1;
41+
}
42+
43+
const box_lines = GetBoxLines(bounds);
3344

3445
const is_orthographic =
3546
this.context.viewport.constructor === OrthographicViewport;
3647

3748
const [tick_lines, tick_labels] = GetTickLines(
3849
is_orthographic,
39-
this.props.bounds,
50+
bounds,
4051
this.context.viewport
4152
);
4253

4354
const textlayerData = maketextLayerData(
4455
is_orthographic,
4556
tick_lines,
4657
tick_labels,
47-
this.props.bounds,
58+
bounds,
4859
this.props.labelFontSize
4960
);
5061

@@ -71,19 +82,25 @@ export default class AxesLayer extends CompositeLayer<AxesLayerProps<unknown>> {
7182
const is_orthographic =
7283
this.context.viewport.constructor === OrthographicViewport;
7384

74-
const box_lines = GetBoxLines(this.props.bounds);
85+
const bounds = cloneDeep(this.props.bounds);
86+
if (this.props.isZDepth) {
87+
bounds[2] *= -1;
88+
bounds[5] *= -1;
89+
}
90+
91+
const box_lines = GetBoxLines(bounds);
7592

7693
const [tick_lines, tick_labels] = GetTickLines(
7794
is_orthographic,
78-
this.props.bounds,
95+
bounds,
7996
this.context.viewport
8097
);
8198

8299
const textlayerData = maketextLayerData(
83100
is_orthographic,
84101
tick_lines,
85102
tick_labels,
86-
this.props.bounds,
103+
bounds,
87104
this.props.labelFontSize
88105
);
89106

@@ -214,11 +231,12 @@ function maketextLayerData(
214231
const z_min = bounds[2];
215232
const z_max = bounds[5];
216233

217-
const dx = x_max - x_min;
218-
const dy = y_max - y_min;
219-
const dz = z_max - z_min;
234+
const dx = Math.abs(x_max - x_min);
235+
const dy = Math.abs(y_max - y_min);
236+
const dz = Math.abs(z_max - z_min);
220237

221238
const offset = ((dx + dy + dz) / 3.0) * 0.1;
239+
222240
const data = [
223241
{
224242
label: "X",

react/src/lib/components/SubsurfaceViewer/layers/grid3d/grid3dLayer.ts

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ function GetBBox(
3636
return [xmin, ymin, zmin, xmax, ymax, zmax];
3737
}
3838

39+
function FlipZ(points: number[]): void {
40+
for (let i = 0; i < points.length / 3; i++) {
41+
points[3 * i + 2] *= -1;
42+
}
43+
}
44+
3945
async function load_data(
4046
pointsUrl: string,
4147
polysUrl: string,
@@ -57,38 +63,49 @@ export interface Grid3DLayerProps<D> extends ExtendedLayerProps<D> {
5763
polysUrl: string;
5864
propertiesUrl: string;
5965

60-
// Name of color map. E.g "PORO"
66+
/** Name of color map. E.g "PORO"
67+
*/
6168
colorMapName: string;
6269

63-
// Use color map in this range.
70+
/** Use color map in this range.
71+
*/
6472
colorMapRange?: [number, number];
6573

66-
// Clamp colormap to this color at ends.
67-
// Given as array of three values (r,g,b) e.g: [255, 0, 0]
68-
// If not set or set to true, it will clamp to color map min and max values.
69-
// If set to false the clamp color will be completely transparent.
74+
/** Clamp colormap to this color at ends.
75+
* Given as array of three values (r,g,b) e.g: [255, 0, 0]
76+
* If not set or set to true, it will clamp to color map min and max values.
77+
* If set to false the clamp color will be completely transparent.
78+
*/
7079
colorMapClampColor: Color | undefined | boolean;
7180

72-
// Optional function property.
73-
// If defined this function will override the color map.
74-
// Takes a value in the range [0,1] and returns a color.
75-
// E.g. (x) => [x * 255, x * 255, x * 255]
81+
/** Optional function property.
82+
* If defined this function will override the color map.
83+
* Takes a value in the range [0,1] and returns a color.
84+
* E.g. (x) => [x * 255, x * 255, x * 255]
85+
*/
7686
colorMapFunction?: colorMapFunctionType | false;
7787

78-
// Surface material properties.
79-
// material: true = default material, coloring depends on surface orientation and lighting.
80-
// false = no material, coloring is independent on surface orientation and lighting.
81-
// or full spec:
82-
// material: {
83-
// ambient: 0.35,
84-
// diffuse: 0.6,
85-
// shininess: 32,
86-
// specularColor: [255, 255, 255],
87-
// }
88+
/** Surface material properties.
89+
* material: true = default material, coloring depends on surface orientation and lighting.
90+
* false = no material, coloring is independent on surface orientation and lighting.
91+
* or full spec:
92+
* material: {
93+
* ambient: 0.35,
94+
* diffuse: 0.6,
95+
* shininess: 32,
96+
* specularColor: [255, 255, 255],
97+
* }
98+
*/
8899
material: Material;
89100

90-
// Enable/disable depth testing when rendering layer. Default true.
101+
/** Enable/disable depth testing when rendering layer. Default true.
102+
*/
91103
depthTest: boolean;
104+
105+
/** If true means that input z values are interpreted as depths.
106+
* For example depth of z = 1000 corresponds to -1000 on the z axis. Default true.
107+
*/
108+
isZDepth: boolean;
92109
}
93110

94111
export default class Grid3DLayer extends CompositeLayer<
@@ -102,6 +119,10 @@ export default class Grid3DLayer extends CompositeLayer<
102119
);
103120

104121
p.then(([points, polys, properties]) => {
122+
if (!this.props.isZDepth) {
123+
FlipZ(points);
124+
}
125+
105126
const bbox = GetBBox(points);
106127

107128
// Using inline web worker for calculating the triangle mesh from

react/src/lib/components/SubsurfaceViewer/layers/layersDefaultProps.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ export const layersDefaultProps: Record<string, unknown> = {
7070
outline: true,
7171
logRadius: 10,
7272
logCurves: true,
73-
refine: true,
73+
refine: false,
7474
visible: true,
7575
wellNameVisible: false,
7676
wellNameAtTop: false,
7777
wellNameSize: 14,
7878
wellNameColor: [0, 0, 0, 255],
7979
selectedWell: "@@#editedData.selectedWells", // used to get data from deckgl layer
8080
depthTest: true,
81+
isZDepth: true,
8182
},
8283
FaultPolygonsLayer: {
8384
"@@type": "FaultPolygonsLayer",
@@ -103,6 +104,7 @@ export const layersDefaultProps: Record<string, unknown> = {
103104
name: "Axes",
104105
id: "axes-layer",
105106
visible: true,
107+
isZDepth: false,
106108
},
107109
Axes2DLayer: {
108110
"@@type": "Axes2DLayer",
@@ -157,5 +159,6 @@ export const layersDefaultProps: Record<string, unknown> = {
157159
colorMapName: "",
158160
propertyValueRange: [0.0, 1.0],
159161
depthTest: true,
162+
isZDepth: true,
160163
},
161164
};

0 commit comments

Comments
 (0)