@webviz/subsurface-viewer 2.3.9 → 2.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/layers/colormap/colormapLayer.js +2 -2
  2. package/dist/layers/colormap/colormapLayer.js.map +1 -1
  3. package/dist/layers/gpglLayers/gpglValueMappedSurfaceLayer.js +4 -2
  4. package/dist/layers/gpglLayers/gpglValueMappedSurfaceLayer.js.map +1 -1
  5. package/dist/layers/grid3d/grid3dLayer.js +10 -7
  6. package/dist/layers/grid3d/grid3dLayer.js.map +1 -1
  7. package/dist/layers/grid3d/privateGrid3dLayer.d.ts +3 -2
  8. package/dist/layers/grid3d/privateGrid3dLayer.js +20 -8
  9. package/dist/layers/grid3d/privateGrid3dLayer.js.map +1 -1
  10. package/dist/layers/grid3d/webworker.js +2 -8
  11. package/dist/layers/grid3d/webworker.js.map +1 -1
  12. package/dist/layers/map/map.fs.glsl.d.ts +1 -1
  13. package/dist/layers/map/map.fs.glsl.js +36 -30
  14. package/dist/layers/map/map.fs.glsl.js.map +1 -1
  15. package/dist/layers/map/map.vs.glsl.d.ts +1 -1
  16. package/dist/layers/map/map.vs.glsl.js +6 -4
  17. package/dist/layers/map/map.vs.glsl.js.map +1 -1
  18. package/dist/layers/map/mapLayer.d.ts +55 -32
  19. package/dist/layers/map/mapLayer.js +114 -55
  20. package/dist/layers/map/mapLayer.js.map +1 -1
  21. package/dist/layers/map/map_discrete.fs.glsl.d.ts +1 -1
  22. package/dist/layers/map/map_discrete.fs.glsl.js +42 -13
  23. package/dist/layers/map/map_discrete.fs.glsl.js.map +1 -1
  24. package/dist/layers/map/map_discrete.vs.glsl.d.ts +1 -1
  25. package/dist/layers/map/map_discrete.vs.glsl.js +14 -15
  26. package/dist/layers/map/map_discrete.vs.glsl.js.map +1 -1
  27. package/dist/layers/map/privateMapLayer.d.ts +6 -7
  28. package/dist/layers/map/privateMapLayer.js +142 -121
  29. package/dist/layers/map/privateMapLayer.js.map +1 -1
  30. package/dist/layers/map/typeDefs.d.ts +2 -5
  31. package/dist/layers/map/typeDefs.js.map +1 -1
  32. package/dist/layers/map/webworker.js +45 -44
  33. package/dist/layers/map/webworker.js.map +1 -1
  34. package/dist/layers/triangle/privateTriangleLayer.js +2 -0
  35. package/dist/layers/triangle/privateTriangleLayer.js.map +1 -1
  36. package/dist/layers/utils/colormapTools.d.ts +10 -6
  37. package/dist/layers/utils/colormapTools.js +26 -25
  38. package/dist/layers/utils/colormapTools.js.map +1 -1
  39. package/dist/layers/wells/layers/dashedSectionsPathLayer.d.ts +4 -3956
  40. package/dist/layers/wells/layers/dashedSectionsPathLayer.js +4 -6
  41. package/dist/layers/wells/layers/dashedSectionsPathLayer.js.map +1 -1
  42. package/dist/viewports/sectionViewport.d.ts +1 -2
  43. package/dist/viewports/sectionViewport.js.map +1 -1
  44. package/dist/views/viewport.d.ts +15 -16
  45. package/dist/views/viewport.js.map +1 -1
  46. package/package.json +2 -2
@@ -1,2 +1,2 @@
1
- declare const _default: "#version 300 es\n#define SHADER_NAME map-discrete-fragment-shader\n\n\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec4 position_commonspace;\nin vec4 vColor;\nin vec3 worldPos;\n\nflat in uint property;\nflat in int vertexIndex;\n\nflat in vec3 vertexColor_;\n\nout vec4 fragColor;\n\n\nvoid main(void) {\n geometry.uv = vTexCoord;\n\n vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n\n uint propertyValue = property;\n\n vec4 color = vec4(vertexColor_, 1.0);\n\n\n bool is_contours = map_d.contourReferencePoint != -1.0 && map_d.contourInterval != -1.0;\n if (is_contours) {\n float val = map_d.isContoursDepth ? (abs(worldPos.z) - map_d.contourReferencePoint) / map_d.contourInterval\n : (float(propertyValue) - map_d.contourReferencePoint) / map_d.contourInterval;\n\n float f = fract(val);\n float df = fwidth(val);\n\n // keep: float c = smoothstep(df * 1.0, df * 2.0, f); // smootstep from/to no of pixels distance from contour line.\n float c = smoothstep(0.0, df * 2.0, f);\n\n color = color * vec4(c, c, c, 1.0);\n }\n\n\n // Use two sided phong lighting. This has no effect if \"material\" property is not set.\n vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\n\n fragColor = vec4(lightColor, vColor.a);\n DECKGL_FILTER_COLOR(fragColor, geometry);\n\n // Below code is modified version of \"picking_filterPickingColor\" function.\n // Original function is in deckgl's shader modules/picking.glsl.ts\n // \"GetPickingInfo\" retrieves this color as \"pickingColor\" on the JS side.\n // Encodes vertexIndex and is used to retrieve picked info from input data.\n if ( bool(picking.isActive) && !bool(picking.isAttribute) ) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n vec4 encodedProperty = encodeIndexToRGB(int(propertyValue));\n fragColor = vec4(encodedProperty.rgb, picking_vRGBcolor_Avalid.a);\n }\n}\n";
1
+ declare const _default: "#version 300 es\n#define SHADER_NAME map-discrete-fragment-shader\n\n// Primitive attributes\nin vec4 position_commonspace;\nflat in uint property;\nin vec3 normals_commonspace;\nin vec4 vColor;\n\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 worldPos;\n\nflat in int vertexIndex;\n\n// Uniforms\nuniform sampler2D colormap;\n\n// Outputs\nout vec4 fragColor;\n\n// Normalize the value to the range [0, 1]\nfloat normalizeValue(uint value) {\n return (float(value) - map.colormapRange[0]) / (map.colormapRange[1] - map.colormapRange[0]);\n}\n\nvec4 valueColor(uint value) {\n if(value == map.undefinedValue) {\n return map.undefinedColor;\n }\n float normalizedValue = normalizeValue(value);\n\n if(map.useClampColor) {\n if(normalizedValue < map.colormapRange[0] || normalizedValue > map.colormapRange[1]) {\n // Out of range. Use clampcolor.\n return map.colormapClampColor;\n }\n }\n // apply colormap\n return texture(colormap, vec2(normalizedValue, 0.5));\n}\n\n\nvoid main(void) {\n geometry.uv = vTexCoord;\n\n vec3 normal = normals_commonspace;\n\n if(!map.smoothShading || (normal[0] == 0.0 && normal[1] == 0.0 && normal[2] == 0.0)) {\n normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n }\n\n uint propertyValue = property;\n \n vec4 color = vColor;\n // compute color\n color = valueColor(propertyValue);\n\n bool is_contours = map.contourReferencePoint != -1.0 && map.contourInterval != -1.0;\n if (is_contours) {\n float val = map.isContoursDepth ? (abs(worldPos.z) - map.contourReferencePoint) / map.contourInterval\n : (float(propertyValue) - map.contourReferencePoint) / map.contourInterval;\n\n float f = fract(val);\n float df = fwidth(val);\n\n // keep: float c = smoothstep(df * 1.0, df * 2.0, f); // smootstep from/to no of pixels distance from contour line.\n float c = smoothstep(0.0, df * 2.0, f);\n\n color = color * vec4(c, c, c, 1.0);\n }\n\n // Use two sided phong lighting. This has no effect if \"material\" property is not set.\n vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\n\n fragColor = vec4(lightColor, color.a * vColor.a);\n DECKGL_FILTER_COLOR(fragColor, geometry);\n\n // Below code is modified version of \"picking_filterPickingColor\" function.\n // Original function is in deckgl's shader modules/picking.glsl.ts\n // \"GetPickingInfo\" retrieves this color as \"pickingColor\" on the JS side.\n // Encodes vertexIndex and is used to retrieve picked info from input data.\n if ( bool(picking.isActive) && !bool(picking.isAttribute) ) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n vec4 encodedProperty = encodeIndexToRGB(int(propertyValue));\n fragColor = vec4(encodedProperty.rgb, picking_vRGBcolor_Avalid.a);\n }\n}\n";
2
2
  export default _default;
@@ -1,35 +1,65 @@
1
1
  export default `#version 300 es
2
2
  #define SHADER_NAME map-discrete-fragment-shader
3
3
 
4
+ // Primitive attributes
5
+ in vec4 position_commonspace;
6
+ flat in uint property;
7
+ in vec3 normals_commonspace;
8
+ in vec4 vColor;
4
9
 
5
10
  in vec2 vTexCoord;
6
11
  in vec3 cameraPosition;
7
- in vec4 position_commonspace;
8
- in vec4 vColor;
9
12
  in vec3 worldPos;
10
13
 
11
- flat in uint property;
12
14
  flat in int vertexIndex;
13
15
 
14
- flat in vec3 vertexColor_;
16
+ // Uniforms
17
+ uniform sampler2D colormap;
15
18
 
19
+ // Outputs
16
20
  out vec4 fragColor;
17
21
 
22
+ // Normalize the value to the range [0, 1]
23
+ float normalizeValue(uint value) {
24
+ return (float(value) - map.colormapRange[0]) / (map.colormapRange[1] - map.colormapRange[0]);
25
+ }
26
+
27
+ vec4 valueColor(uint value) {
28
+ if(value == map.undefinedValue) {
29
+ return map.undefinedColor;
30
+ }
31
+ float normalizedValue = normalizeValue(value);
32
+
33
+ if(map.useClampColor) {
34
+ if(normalizedValue < map.colormapRange[0] || normalizedValue > map.colormapRange[1]) {
35
+ // Out of range. Use clampcolor.
36
+ return map.colormapClampColor;
37
+ }
38
+ }
39
+ // apply colormap
40
+ return texture(colormap, vec2(normalizedValue, 0.5));
41
+ }
42
+
18
43
 
19
44
  void main(void) {
20
45
  geometry.uv = vTexCoord;
21
46
 
22
- vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
47
+ vec3 normal = normals_commonspace;
23
48
 
24
- uint propertyValue = property;
25
-
26
- vec4 color = vec4(vertexColor_, 1.0);
49
+ if(!map.smoothShading || (normal[0] == 0.0 && normal[1] == 0.0 && normal[2] == 0.0)) {
50
+ normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
51
+ }
27
52
 
53
+ uint propertyValue = property;
54
+
55
+ vec4 color = vColor;
56
+ // compute color
57
+ color = valueColor(propertyValue);
28
58
 
29
- bool is_contours = map_d.contourReferencePoint != -1.0 && map_d.contourInterval != -1.0;
59
+ bool is_contours = map.contourReferencePoint != -1.0 && map.contourInterval != -1.0;
30
60
  if (is_contours) {
31
- float val = map_d.isContoursDepth ? (abs(worldPos.z) - map_d.contourReferencePoint) / map_d.contourInterval
32
- : (float(propertyValue) - map_d.contourReferencePoint) / map_d.contourInterval;
61
+ float val = map.isContoursDepth ? (abs(worldPos.z) - map.contourReferencePoint) / map.contourInterval
62
+ : (float(propertyValue) - map.contourReferencePoint) / map.contourInterval;
33
63
 
34
64
  float f = fract(val);
35
65
  float df = fwidth(val);
@@ -40,11 +70,10 @@ void main(void) {
40
70
  color = color * vec4(c, c, c, 1.0);
41
71
  }
42
72
 
43
-
44
73
  // Use two sided phong lighting. This has no effect if "material" property is not set.
45
74
  vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
46
75
 
47
- fragColor = vec4(lightColor, vColor.a);
76
+ fragColor = vec4(lightColor, color.a * vColor.a);
48
77
  DECKGL_FILTER_COLOR(fragColor, geometry);
49
78
 
50
79
  // Below code is modified version of "picking_filterPickingColor" function.
@@ -1 +1 @@
1
- {"version":3,"file":"map_discrete.fs.glsl.js","sourceRoot":"","sources":["../../../src/layers/map/map_discrete.fs.glsl.ts"],"names":[],"mappings":"AAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Dd,CAAC"}
1
+ {"version":3,"file":"map_discrete.fs.glsl.js","sourceRoot":"","sources":["../../../src/layers/map/map_discrete.fs.glsl.ts"],"names":[],"mappings":"AAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Fd,CAAC"}
@@ -1,2 +1,2 @@
1
- declare const _default: "#version 300 es\n#define SHADER_NAME map-discrete-vertex-shader\n\nin vec3 positions;\n\nin vec3 colors;\nin vec3 pickingColors;\n\nin vec3 vertexColor;\nflat out vec3 vertexColor_;\n\n// Outputs to fragment shader\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec4 position_commonspace;\nout vec4 vColor;\nout vec3 worldPos;\n\nin uint properties;\nflat out uint property;\n\nflat out lowp int vertexIndex;\n\nvoid main(void) {\n property = properties;\n\n vertexColor_ = vertexColor;\n\n geometry.pickingColor = pickingColors;\n vertexIndex = gl_VertexID;\n\n vec3 position = positions;\n position[2] *= map_d.ZIncreasingDownwards ? -1.0 : 1.0;\n\n cameraPosition = project.cameraPosition;\n\n worldPos = position;\n geometry.worldPosition = position;\n\n position_commonspace = vec4(project_position(position), 0.0);\n gl_Position = project_common_position_to_clipspace(position_commonspace);\n\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vColor = vec4(colors.rgb, layer.opacity);\n DECKGL_FILTER_COLOR(vColor, geometry);\n}\n";
1
+ declare const _default: "#version 300 es\n#define SHADER_NAME map-discrete-vertex-shader\n\n// Primitive attributes\nin vec3 positions;\nin uint properties;\nin vec3 normals;\nin vec3 colors;\nin vec3 pickingColors;\n\n// Outputs to fragment shader\nout vec4 position_commonspace;\nflat out uint property;\nout vec3 normals_commonspace;\nout vec4 vColor;\n\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 worldPos;\n\nflat out int vertexIndex;\n\nvoid main(void) {\n geometry.pickingColor = pickingColors;\n vertexIndex = gl_VertexID;\n\n vec3 position = positions;\n position[2] *= map.ZIncreasingDownwards ? -1.0 : 1.0;\n\n cameraPosition = project.cameraPosition;\n\n worldPos = position;\n geometry.worldPosition = position;\n\n normals_commonspace = normals;\n\n property = properties;\n\n position_commonspace = vec4(project_position(position), 0.0);\n gl_Position = project_common_position_to_clipspace(position_commonspace);\n\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vColor = vec4(colors.rgb, layer.opacity);\n DECKGL_FILTER_COLOR(vColor, geometry);\n}\n";
2
2
  export default _default;
@@ -2,42 +2,41 @@ export default `\
2
2
  #version 300 es
3
3
  #define SHADER_NAME map-discrete-vertex-shader
4
4
 
5
+ // Primitive attributes
5
6
  in vec3 positions;
6
-
7
+ in uint properties;
8
+ in vec3 normals;
7
9
  in vec3 colors;
8
10
  in vec3 pickingColors;
9
11
 
10
- in vec3 vertexColor;
11
- flat out vec3 vertexColor_;
12
-
13
12
  // Outputs to fragment shader
14
- out vec2 vTexCoord;
15
- out vec3 cameraPosition;
16
13
  out vec4 position_commonspace;
14
+ flat out uint property;
15
+ out vec3 normals_commonspace;
17
16
  out vec4 vColor;
18
- out vec3 worldPos;
19
17
 
20
- in uint properties;
21
- flat out uint property;
18
+ out vec2 vTexCoord;
19
+ out vec3 cameraPosition;
20
+ out vec3 worldPos;
22
21
 
23
- flat out lowp int vertexIndex;
22
+ flat out int vertexIndex;
24
23
 
25
24
  void main(void) {
26
- property = properties;
27
-
28
- vertexColor_ = vertexColor;
29
-
30
25
  geometry.pickingColor = pickingColors;
31
26
  vertexIndex = gl_VertexID;
32
27
 
33
28
  vec3 position = positions;
34
- position[2] *= map_d.ZIncreasingDownwards ? -1.0 : 1.0;
29
+ position[2] *= map.ZIncreasingDownwards ? -1.0 : 1.0;
35
30
 
36
31
  cameraPosition = project.cameraPosition;
37
32
 
38
33
  worldPos = position;
39
34
  geometry.worldPosition = position;
40
35
 
36
+ normals_commonspace = normals;
37
+
38
+ property = properties;
39
+
41
40
  position_commonspace = vec4(project_position(position), 0.0);
42
41
  gl_Position = project_common_position_to_clipspace(position_commonspace);
43
42
 
@@ -1 +1 @@
1
- {"version":3,"file":"map_discrete.vs.glsl.js","sourceRoot":"","sources":["../../../src/layers/map/map_discrete.vs.glsl.ts"],"names":[],"mappings":"AAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDd,CAAC"}
1
+ {"version":3,"file":"map_discrete.vs.glsl.js","sourceRoot":"","sources":["../../../src/layers/map/map_discrete.vs.glsl.ts"],"names":[],"mappings":"AAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Cd,CAAC"}
@@ -4,8 +4,7 @@ import type { Device, UniformValue } from "@luma.gl/core";
4
4
  import { Model } from "@luma.gl/engine";
5
5
  import type { DeckGLLayerContext, ExtendedLayerProps, LayerPickInfo } from "../utils/deckglTools";
6
6
  import { type ColormapFunctionType } from "../utils/colormapTools";
7
- import type { RGBColor } from "../../utils";
8
- import type { IMapDiscretePropertyValueName } from "./typeDefs";
7
+ import { type IMapDiscretePropertyValueName, TMapColoringMode } from "./typeDefs";
9
8
  export interface PrivateMapLayerProps extends ExtendedLayerProps {
10
9
  positions: Float32Array;
11
10
  normals: Float32Array;
@@ -14,20 +13,21 @@ export interface PrivateMapLayerProps extends ExtendedLayerProps {
14
13
  vertexIndices: Int32Array;
15
14
  lineIndices: Uint32Array;
16
15
  contours: [number, number];
17
- gridLines: boolean;
18
16
  isContoursDepth: boolean;
19
17
  colormapName: string;
20
18
  colormapRange: [number, number];
21
19
  colormapClampColor: Color | undefined | boolean;
22
20
  colormapFunction?: ColormapFunctionType;
23
- undefinedPropertyColor: RGBColor;
21
+ undefinedPropertyColor: Color;
24
22
  undefinedPropertyValue: number;
23
+ coloringMode: TMapColoringMode;
24
+ gridLines: boolean;
25
25
  propertyValueRange: [number, number];
26
+ discretePropertyValueNames?: IMapDiscretePropertyValueName[];
26
27
  smoothShading: boolean;
27
28
  depthTest: boolean;
28
29
  ZIncreasingDownwards: boolean;
29
30
  enableLighting: boolean;
30
- discretePropertyValueNames?: IMapDiscretePropertyValueName[];
31
31
  }
32
32
  export declare class PrivateMapLayer extends Layer<PrivateMapLayerProps> {
33
33
  get isLoaded(): boolean;
@@ -36,11 +36,9 @@ export declare class PrivateMapLayer extends Layer<PrivateMapLayerProps> {
36
36
  }>): void;
37
37
  calculatePickingColors(attribute: Attribute): void;
38
38
  private getColoringHints;
39
- private getVertexColorAttributes;
40
39
  initializeState(context: DeckGLLayerContext): void;
41
40
  shouldUpdateState({ props, oldProps, context, changeFlags, }: UpdateParameters<this>): boolean;
42
41
  updateState({ context }: UpdateParameters<this>): void;
43
- isPropertiesCategorical(): boolean;
44
42
  getContinuousPropModel(): Model;
45
43
  getDiscretePropModel(): Model;
46
44
  getLinesModel(device: Device): Model;
@@ -55,4 +53,5 @@ export declare class PrivateMapLayer extends Layer<PrivateMapLayerProps> {
55
53
  getPickingInfo({ info }: {
56
54
  info: PickingInfo;
57
55
  }): LayerPickInfo;
56
+ private getPropertyText;
58
57
  }
@@ -1,24 +1,29 @@
1
- import { COORDINATE_SYSTEM, Layer, project32, picking } from "@deck.gl/core";
2
- import { lighting } from "@luma.gl/shadertools";
1
+ import { Layer, project32, picking } from "@deck.gl/core";
3
2
  import { Model, Geometry } from "@luma.gl/engine";
4
- import { phongMaterial } from "../shader_modules/phong-lighting/phong-material";
5
- import { precisionForTests } from "../shader_modules/test-precision/precisionForTests";
3
+ import { lighting } from "@luma.gl/shadertools";
6
4
  import { decodeIndexFromRGB, utilities } from "../shader_modules";
7
5
  import { encodeIndexToRGB } from "../shader_modules/utilities";
6
+ import { phongMaterial } from "../shader_modules/phong-lighting/phong-material";
7
+ import { precisionForTests } from "../shader_modules/test-precision/precisionForTests";
8
8
  import { createPropertyData, initPropertyData } from "../utils/deckglTools";
9
- import { createColormapTexture, getColormapDiscreteColors, } from "../utils/colormapTools";
9
+ import { createColormapTexture, getColormapColorArray, } from "../utils/colormapTools";
10
+ import { toNormalizedRGBAColor } from "../../utils";
10
11
  import fs from "./map.fs.glsl";
11
12
  import vs from "./map.vs.glsl";
12
13
  import fsDiscrete from "./map_discrete.fs.glsl";
13
14
  import vsDiscrete from "./map_discrete.vs.glsl";
14
15
  import fsLineShader from "./line.fs.glsl";
15
16
  import vsLineShader from "./line.vs.glsl";
17
+ import { TMapColoringMode, } from "./typeDefs";
18
+ import { isDiscreteProperty } from "./mapLayer";
16
19
  const defaultProps = {
17
20
  contours: [-1, -1],
18
21
  isContoursDepth: true,
19
22
  gridLines: false,
20
23
  colormapName: "",
21
- coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
24
+ colormapClampColor: [0, 255, 0, 200], // green color for clamped values
25
+ coloringMode: TMapColoringMode.Property,
26
+ undefinedPropertyColor: [255, 0, 0, 200], // red color for undefined property values
22
27
  propertyValueRange: [0.0, 1.0],
23
28
  meshValueRange: [0.0, 1.0],
24
29
  depthTest: true,
@@ -31,13 +36,18 @@ export class PrivateMapLayer extends Layer {
31
36
  return this.state["isLoaded"] ?? false;
32
37
  }
33
38
  setShaderModuleProps(args) {
34
- super.setShaderModuleProps({
35
- ...args,
36
- lighting: {
37
- ...args["lighting"],
38
- enabled: this.props.enableLighting,
39
- },
40
- });
39
+ if ("lighting" in args) {
40
+ super.setShaderModuleProps({
41
+ ...args,
42
+ lighting: {
43
+ ...args["lighting"],
44
+ enabled: this.props.enableLighting,
45
+ },
46
+ });
47
+ }
48
+ else {
49
+ super.setShaderModuleProps(args);
50
+ }
41
51
  }
42
52
  calculatePickingColors(attribute) {
43
53
  const n = this.props.positions.length / 3;
@@ -57,17 +67,17 @@ export class PrivateMapLayer extends Layer {
57
67
  colormapSize: Math.max(this.props.colormapFunction.length / 3, 1),
58
68
  };
59
69
  }
60
- if (this.props.vertexProperties instanceof Uint16Array ||
61
- this.props.discretePropertyValueNames !== undefined) {
62
- const namedPropertyCount = this.props.discretePropertyValueNames?.length;
70
+ if (isDiscreteProperty(this.props.coloringMode)) {
71
+ // It is expected that the property values are integers ranging from 0 to N.
72
+ // Thus this.props.propertyValueRange?.[0] should be 0
73
+ // and this.props.propertyValueRange?.[1] should be N
63
74
  const maxPropertyValue = Number.isFinite(this.props.propertyValueRange[1])
64
- ? Math.max(0, Math.floor(this.props.propertyValueRange[1]))
75
+ ? Math.round(this.props.propertyValueRange[1]) + 1
65
76
  : 0;
77
+ const namedPropertyCount = this.props.discretePropertyValueNames?.length ?? 0;
66
78
  return {
67
79
  discreteData: true,
68
- colormapSize: namedPropertyCount && namedPropertyCount > 0
69
- ? namedPropertyCount
70
- : Math.max(maxPropertyValue + 1, 1),
80
+ colormapSize: Math.max(maxPropertyValue, namedPropertyCount),
71
81
  };
72
82
  }
73
83
  return {
@@ -75,57 +85,6 @@ export class PrivateMapLayer extends Layer {
75
85
  colormapSize: 256,
76
86
  };
77
87
  }
78
- getVertexColorAttributes() {
79
- const hints = this.getColoringHints();
80
- const colors = getColormapDiscreteColors(this.props.colormapFunction ?? {
81
- colormapName: this.props.colormapName,
82
- colorTables: this.context.userData
83
- .colorTables,
84
- }, hints);
85
- const colormapSize = Math.max(colors.length / 3, 1);
86
- const length = this.props.vertexProperties.length;
87
- const entries = this.props.discretePropertyValueNames ?? [];
88
- const codeToIndex = new Map();
89
- for (let idx = 0; idx < entries.length; idx++) {
90
- codeToIndex.set(entries[idx].code, idx);
91
- }
92
- const vertexColors = new Float32Array(length * 3);
93
- for (let i = 0; i < length; i++) {
94
- const property = this.props.vertexProperties[i];
95
- let index = -1;
96
- if (entries.length > 0) {
97
- index = codeToIndex.get(property) ?? -1;
98
- }
99
- else if (Number.isInteger(property)) {
100
- index = property;
101
- }
102
- let color = property === this.props.undefinedPropertyValue
103
- ? undefined
104
- : entries[index]?.color;
105
- if (color === undefined) {
106
- if (index >= 0 &&
107
- property !== this.props.undefinedPropertyValue) {
108
- const colorIndex = index % colormapSize;
109
- const colorOffset = colorIndex * 3;
110
- color = [
111
- colors[colorOffset] ??
112
- this.props.undefinedPropertyColor[0],
113
- colors[colorOffset + 1] ??
114
- this.props.undefinedPropertyColor[1],
115
- colors[colorOffset + 2] ??
116
- this.props.undefinedPropertyColor[2],
117
- ];
118
- }
119
- else {
120
- color = this.props.undefinedPropertyColor;
121
- }
122
- }
123
- vertexColors[i * 3 + 0] = color[0] / 255;
124
- vertexColors[i * 3 + 1] = color[1] / 255;
125
- vertexColors[i * 3 + 2] = color[2] / 255;
126
- }
127
- return vertexColors;
128
- }
129
88
  initializeState(context) {
130
89
  const gl = context.device;
131
90
  const [mesh_model, mesh_lines_model] = this._getModels(gl);
@@ -153,9 +112,6 @@ export class PrivateMapLayer extends Layer {
153
112
  updateState({ context }) {
154
113
  this.initializeState(context);
155
114
  }
156
- isPropertiesCategorical() {
157
- return this.getColoringHints().discreteData;
158
- }
159
115
  getContinuousPropModel() {
160
116
  const colormap = createColormapTexture(this.props.colormapFunction ?? {
161
117
  colormapName: this.props.colormapName,
@@ -166,23 +122,17 @@ export class PrivateMapLayer extends Layer {
166
122
  const contourReferencePoint = this.props.contours[0] ?? -1.0;
167
123
  const contourInterval = this.props.contours[1] ?? -1.0;
168
124
  const isContoursDepth = this.props.isContoursDepth;
169
- const valueRangeMin = this.props.propertyValueRange[0] ?? 0.0;
170
- const valueRangeMax = this.props.propertyValueRange[1] ?? 1.0;
125
+ const valueRange = this.props.propertyValueRange ?? [0.0, 1.0];
171
126
  // If specified color map will extend from colormapRangeMin to colormapRangeMax.
172
127
  // Otherwise it will extend from valueRangeMin to valueRangeMax.
173
- const colormapRangeMin = this.props.colormapRange?.[0] ?? valueRangeMin;
174
- const colormapRangeMax = this.props.colormapRange?.[1] ?? valueRangeMax;
175
- const isClampColor = this.props.colormapClampColor !== undefined &&
128
+ const colormapRange = this.props.colormapRange ?? valueRange;
129
+ const isClampColorDefined = this.props.colormapClampColor !== undefined &&
176
130
  this.props.colormapClampColor !== true &&
177
131
  this.props.colormapClampColor !== false;
178
- let colormapClampColor = isClampColor
179
- ? this.props.colormapClampColor
180
- : [0, 0, 0];
181
- // Normalize to [0,1] range.
182
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
183
- // @ts-ignore
184
- colormapClampColor = colormapClampColor.map((x) => (x ?? 0) / 255);
185
- const isColormapClampColorTransparent = this.props.colormapClampColor === false;
132
+ const useClampColor = isClampColorDefined || this.props.colormapClampColor === false;
133
+ const colormapClampColor = isClampColorDefined
134
+ ? toNormalizedRGBAColor(this.props.colormapClampColor)
135
+ : [0, 0, 0, 0];
186
136
  const smoothShading = this.props.normals.length == 0 ? false : this.props.smoothShading;
187
137
  const model = new Model(this.context.device, {
188
138
  id: `${this.props.id}-mesh`,
@@ -219,16 +169,16 @@ export class PrivateMapLayer extends Layer {
219
169
  });
220
170
  model.shaderInputs.setProps({
221
171
  map: {
172
+ isContoursDepth,
222
173
  contourReferencePoint,
223
174
  contourInterval,
224
- isContoursDepth,
225
- valueRangeMin,
226
- valueRangeMax,
227
- colormapRangeMin,
228
- colormapRangeMax,
175
+ valueRange,
176
+ colormapRange,
229
177
  colormapClampColor,
230
- isColormapClampColorTransparent,
231
- isClampColor,
178
+ useClampColor,
179
+ undefinedValue: this.props.undefinedPropertyValue,
180
+ undefinedColor: toNormalizedRGBAColor(this.props.undefinedPropertyColor ??
181
+ defaultProps.undefinedPropertyColor),
232
182
  smoothShading,
233
183
  ZIncreasingDownwards: this.props.ZIncreasingDownwards,
234
184
  },
@@ -236,10 +186,29 @@ export class PrivateMapLayer extends Layer {
236
186
  return model;
237
187
  }
238
188
  getDiscretePropModel() {
189
+ const hints = this.getColoringHints();
190
+ const colors = getColormapColorArray(this.props.colormapFunction ?? {
191
+ colormapName: this.props.colormapName,
192
+ colorTables: this.context.userData
193
+ .colorTables,
194
+ }, hints);
195
+ const colormap = createColormapTexture(colors, this.context, this.getColoringHints());
196
+ // MESH MODEL
239
197
  const contourReferencePoint = this.props.contours[0] ?? -1.0;
240
198
  const contourInterval = this.props.contours[1] ?? -1.0;
241
199
  const isContoursDepth = this.props.isContoursDepth;
242
- const vertexColors = this.getVertexColorAttributes();
200
+ const valueRange = this.props.propertyValueRange ?? [0.0, 1.0];
201
+ // If specified color map will extend from colormapRangeMin to colormapRangeMax.
202
+ // Otherwise it will extend from valueRangeMin to valueRangeMax.
203
+ const colormapRange = this.props.colormapRange ?? valueRange;
204
+ const isClampColorDefined = this.props.colormapClampColor !== undefined &&
205
+ this.props.colormapClampColor !== true &&
206
+ this.props.colormapClampColor !== false;
207
+ const useClampColor = isClampColorDefined || this.props.colormapClampColor === false;
208
+ const colormapClampColor = isClampColorDefined
209
+ ? toNormalizedRGBAColor(this.props.colormapClampColor)
210
+ : [0, 0, 0, 0];
211
+ const smoothShading = this.props.normals.length == 0 ? false : this.props.smoothShading;
243
212
  const model = new Model(this.context.device, {
244
213
  id: `${this.props.id}-mesh`,
245
214
  ...super.getShaders({
@@ -259,7 +228,11 @@ export class PrivateMapLayer extends Layer {
259
228
  topology: "triangle-list",
260
229
  attributes: {
261
230
  positions: { value: this.props.positions, size: 3 },
262
- vertexColor: { value: vertexColors, size: 3 },
231
+ // Only add normals if they are defined.
232
+ ...(this.props.normals.length ===
233
+ this.props.positions.length && {
234
+ normals: { value: this.props.normals, size: 3 },
235
+ }),
263
236
  properties: {
264
237
  value: this.props.vertexProperties,
265
238
  size: 1,
@@ -269,13 +242,24 @@ export class PrivateMapLayer extends Layer {
269
242
  indices: { value: this.props.triangleIndices, size: 1 },
270
243
  }),
271
244
  bufferLayout: this.getAttributeManager().getBufferLayouts(),
245
+ bindings: {
246
+ colormap: colormap,
247
+ },
272
248
  isInstanced: false,
273
249
  });
274
250
  model.shaderInputs.setProps({
275
251
  map: {
252
+ isContoursDepth,
276
253
  contourReferencePoint,
277
254
  contourInterval,
278
- isContoursDepth,
255
+ valueRange,
256
+ colormapRange,
257
+ colormapClampColor,
258
+ useClampColor,
259
+ undefinedValue: this.props.undefinedPropertyValue,
260
+ undefinedColor: toNormalizedRGBAColor(this.props.undefinedPropertyColor ??
261
+ defaultProps.undefinedPropertyColor),
262
+ smoothShading,
279
263
  ZIncreasingDownwards: this.props.ZIncreasingDownwards,
280
264
  },
281
265
  });
@@ -292,6 +276,8 @@ export class PrivateMapLayer extends Layer {
292
276
  picking,
293
277
  mapLinesUniforms,
294
278
  precisionForTests,
279
+ // not used by this model, but added to fix warnings while picking
280
+ lighting,
295
281
  ],
296
282
  }),
297
283
  geometry: new Geometry({
@@ -312,7 +298,7 @@ export class PrivateMapLayer extends Layer {
312
298
  return model;
313
299
  }
314
300
  _getModels(device) {
315
- const mesh_model = this.isPropertiesCategorical()
301
+ const mesh_model = isDiscreteProperty(this.props.coloringMode)
316
302
  ? this.getDiscretePropModel()
317
303
  : this.getContinuousPropModel();
318
304
  const mesh_lines_model = this.getLinesModel(device);
@@ -369,15 +355,19 @@ export class PrivateMapLayer extends Layer {
369
355
  return info;
370
356
  }
371
357
  const layer_properties = initPropertyData(info.coordinate?.[2], this.props.ZIncreasingDownwards, this.props.modelMatrix);
372
- if (this.isPropertiesCategorical()) {
358
+ if (isDiscreteProperty(this.props.coloringMode)) {
373
359
  const [r, g, b] = info.color;
374
- const code = decodeIndexFromRGB([r, g, b]);
375
- layer_properties.push(createPropertyData("Code", code));
376
- const index = this.props.discretePropertyValueNames?.findIndex((e) => e.code === code) ?? -1;
377
- const name = index !== -1
378
- ? this.props.discretePropertyValueNames?.[index]?.name
379
- : "No name";
380
- layer_properties.push(createPropertyData("Name", name));
360
+ const propertyValue = decodeIndexFromRGB([r, g, b]);
361
+ if (propertyValue != undefined && Number.isFinite(propertyValue)) {
362
+ const propertyText = this.getPropertyText(propertyValue);
363
+ if (propertyText) {
364
+ layer_properties.push(createPropertyData("Property", propertyText.text));
365
+ layer_properties.push(createPropertyData("Value", propertyText.value));
366
+ }
367
+ else {
368
+ layer_properties.push(createPropertyData("Property", propertyValue));
369
+ }
370
+ }
381
371
  return {
382
372
  ...info,
383
373
  properties: layer_properties,
@@ -394,6 +384,20 @@ export class PrivateMapLayer extends Layer {
394
384
  properties: layer_properties,
395
385
  };
396
386
  }
387
+ getPropertyText(index) {
388
+ if (!this.props.discretePropertyValueNames) {
389
+ return undefined;
390
+ }
391
+ if (index < 0 ||
392
+ index >= this.props.discretePropertyValueNames.length) {
393
+ return undefined;
394
+ }
395
+ const valueName = this.props.discretePropertyValueNames[index];
396
+ return {
397
+ text: valueName.name,
398
+ value: valueName.value,
399
+ };
400
+ }
397
401
  }
398
402
  PrivateMapLayer.layerName = "privateMapLayer";
399
403
  PrivateMapLayer.defaultProps = defaultProps;
@@ -404,14 +408,15 @@ uniform mapUniforms {
404
408
  float contourReferencePoint;
405
409
  float contourInterval;
406
410
 
407
- float valueRangeMin;
408
- float valueRangeMax;
409
- float colormapRangeMin;
410
- float colormapRangeMax;
411
+ vec2 valueRange;
412
+ vec2 colormapRange;
413
+
414
+ vec4 colormapClampColor;
415
+ bool useClampColor;
416
+
417
+ float undefinedValue;
418
+ vec4 undefinedColor;
411
419
 
412
- vec3 colormapClampColor;
413
- bool isClampColor;
414
- bool isColormapClampColorTransparent;
415
420
  bool smoothShading;
416
421
  bool ZIncreasingDownwards;
417
422
  } map;
@@ -425,13 +430,12 @@ const mapUniforms = {
425
430
  isContoursDepth: "u32",
426
431
  contourReferencePoint: "f32",
427
432
  contourInterval: "f32",
428
- valueRangeMin: "f32",
429
- valueRangeMax: "f32",
430
- colormapRangeMin: "f32",
431
- colormapRangeMax: "f32",
432
- colormapClampColor: "vec3<f32>",
433
- isClampColor: "u32",
434
- isColormapClampColorTransparent: "u32",
433
+ valueRange: "vec2<f32>",
434
+ colormapRange: "vec2<f32>",
435
+ colormapClampColor: "vec4<f32>",
436
+ useClampColor: "u32",
437
+ undefinedValue: "f32",
438
+ undefinedColor: "vec4<f32>",
435
439
  smoothShading: "u32",
436
440
  ZIncreasingDownwards: "u32",
437
441
  },
@@ -443,8 +447,18 @@ uniform mapUniforms {
443
447
  float contourReferencePoint;
444
448
  float contourInterval;
445
449
 
450
+ vec2 valueRange;
451
+ vec2 colormapRange;
452
+
453
+ vec4 colormapClampColor;
454
+ bool useClampColor;
455
+
456
+ uint undefinedValue;
457
+ vec4 undefinedColor;
458
+
459
+ bool smoothShading;
446
460
  bool ZIncreasingDownwards;
447
- } map_d;
461
+ } map;
448
462
  `;
449
463
  // NOTE: this must exactly the same name as in the uniform block
450
464
  const mapDiscreteUniforms = {
@@ -456,6 +470,13 @@ const mapDiscreteUniforms = {
456
470
  isContoursDepth: "u32",
457
471
  contourReferencePoint: "f32",
458
472
  contourInterval: "f32",
473
+ valueRange: "vec2<u32>",
474
+ colormapRange: "vec2<f32>",
475
+ colormapClampColor: "vec4<f32>",
476
+ useClampColor: "u32",
477
+ undefinedValue: "u32",
478
+ undefinedColor: "vec4<f32>",
479
+ smoothShading: "u32",
459
480
  ZIncreasingDownwards: "u32",
460
481
  },
461
482
  };