@webviz/subsurface-viewer 1.12.5 → 1.13.1

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 (55) hide show
  1. package/dist/layers/gpglLayers/gpglValueMappedSurfaceLayer.d.ts +120 -0
  2. package/dist/layers/gpglLayers/gpglValueMappedSurfaceLayer.js +495 -0
  3. package/dist/layers/gpglLayers/gpglValueMappedSurfaceLayer.js.map +1 -0
  4. package/dist/layers/gpglLayers/texTriangle.fs.glsl.d.ts +2 -0
  5. package/dist/layers/gpglLayers/texTriangle.fs.glsl.js +59 -0
  6. package/dist/layers/gpglLayers/texTriangle.fs.glsl.js.map +1 -0
  7. package/dist/layers/gpglLayers/texTriangle.vs.glsl.d.ts +2 -0
  8. package/dist/layers/gpglLayers/texTriangle.vs.glsl.js +45 -0
  9. package/dist/layers/gpglLayers/texTriangle.vs.glsl.js.map +1 -0
  10. package/dist/layers/gpglLayers/triangle.fs.glsl.d.ts +2 -0
  11. package/dist/layers/gpglLayers/triangle.fs.glsl.js +29 -0
  12. package/dist/layers/gpglLayers/triangle.fs.glsl.js.map +1 -0
  13. package/dist/layers/gpglLayers/triangle.vs.glsl.d.ts +2 -0
  14. package/dist/layers/gpglLayers/triangle.vs.glsl.js +45 -0
  15. package/dist/layers/gpglLayers/triangle.vs.glsl.js.map +1 -0
  16. package/dist/layers/gpglLayers/triangleLine.fs.glsl.d.ts +2 -0
  17. package/dist/layers/gpglLayers/triangleLine.fs.glsl.js +21 -0
  18. package/dist/layers/gpglLayers/triangleLine.fs.glsl.js.map +1 -0
  19. package/dist/layers/gpglLayers/triangleLine.vs.glsl.d.ts +2 -0
  20. package/dist/layers/gpglLayers/triangleLine.vs.glsl.js +30 -0
  21. package/dist/layers/gpglLayers/triangleLine.vs.glsl.js.map +1 -0
  22. package/dist/layers/gpglLayers/typeDefs.d.ts +7 -1
  23. package/dist/layers/gpglLayers/typeDefs.js.map +1 -1
  24. package/dist/layers/grid3d/grid3dLayer.d.ts +1 -1
  25. package/dist/layers/grid3d/grid3dLayer.js +1 -1
  26. package/dist/layers/grid3d/grid3dLayer.js.map +1 -1
  27. package/dist/layers/index.d.ts +4 -0
  28. package/dist/layers/index.js +2 -0
  29. package/dist/layers/index.js.map +1 -1
  30. package/dist/layers/map/mapLayer.d.ts +6 -6
  31. package/dist/layers/map/mapLayer.js +1 -1
  32. package/dist/layers/map/mapLayer.js.map +1 -1
  33. package/dist/layers/map/webworker.js +3 -1
  34. package/dist/layers/map/webworker.js.map +1 -1
  35. package/dist/layers/seismic/seismicLayer.d.ts +105 -0
  36. package/dist/layers/seismic/seismicLayer.js +182 -0
  37. package/dist/layers/seismic/seismicLayer.js.map +1 -0
  38. package/dist/layers/shader_modules/test-precision/precisionForTests-shaders-glsl.js +1 -1
  39. package/dist/layers/triangle/triangleLayer.d.ts +1 -1
  40. package/dist/layers/triangle/triangleLayer.js +1 -1
  41. package/dist/layers/triangle/triangleLayer.js.map +1 -1
  42. package/dist/layers/utils/colormapTools.d.ts +38 -13
  43. package/dist/layers/utils/colormapTools.js +1 -1
  44. package/dist/layers/utils/colormapTools.js.map +1 -1
  45. package/dist/utils/Color.d.ts +10 -0
  46. package/dist/utils/Color.js +19 -1
  47. package/dist/utils/Color.js.map +1 -1
  48. package/dist/utils/index.d.ts +1 -0
  49. package/dist/utils/index.js +1 -0
  50. package/dist/utils/index.js.map +1 -1
  51. package/dist/utils/serialize.d.ts +1 -1
  52. package/dist/utils/serialize.js +2 -2
  53. package/dist/utils/serialize.js.map +1 -1
  54. package/dist/utils/typedArray.js.map +1 -1
  55. package/package.json +2 -2
@@ -0,0 +1,120 @@
1
+ import type { PickingInfo, UpdateParameters } from "@deck.gl/core";
2
+ import { Layer } from "@deck.gl/core";
3
+ import { Model } from "@luma.gl/engine";
4
+ import type { Material } from "../gpglLayers/typeDefs";
5
+ import type { DeckGLLayerContext, ExtendedLayerProps, LayerPickInfo } from "../utils/layerTools";
6
+ import { type ColormapProps, type ColormapSetup } from "../utils/colormapTools";
7
+ import type { RGBColor, TypedFloatArray, TypedIntArray } from "../../utils";
8
+ import type { ValueArray2D } from "./typeDefs";
9
+ /**
10
+ * Props for defining a triangle surfaces with optional value mapping and texture coordinates.
11
+ * If a value map, ie. a 2D array of values, is provided, it will be used to generate a 2D texture
12
+ * of values which will be mapped on the surface and converted to colors using the colormap
13
+ *
14
+ * @property topology The type of triangle topology to use: either `triangle-list` or `triangle-strip`.
15
+ * @property vertices The array of vertex positions, as either a typed float array or a number array.
16
+ * @property normals (Optional) The array of vertex normals, as either a typed float array or a number array.
17
+ * @property texCoords (Optional) The array of texture coordinates, as either a typed float array or a number array.
18
+ * @property valueMap (Optional) A 2D array of values used to generate a value texture.
19
+ * @property vertexIndices An object containing the indices of vertices and the size of each index group.
20
+ * @property vertexIndices.value The array of vertex indices, as either a typed int array or a number array.
21
+ * @property vertexIndices.size The number of indices per group (e.g., 3 for triangles).
22
+ */
23
+ export type ValueMappedTriangleProps = {
24
+ topology: "triangle-list" | "triangle-strip";
25
+ vertices: TypedFloatArray | number[];
26
+ normals?: TypedFloatArray | number[];
27
+ texCoords?: TypedFloatArray | number[];
28
+ valueMap?: ValueArray2D;
29
+ vertexIndices: {
30
+ value: TypedIntArray | number[];
31
+ size: number;
32
+ };
33
+ };
34
+ /**
35
+ * Props for defining a triangle mesh geometry.
36
+ *
37
+ * @property topology Specifies the type of mesh topology. Can be either `line-list` or `line-strip`.
38
+ * @property vertices Optional array of vertex positions. Accepts either a typed float array or a regular number array.
39
+ * If not provided, the vertices of the ValueMappedTriangleProps will be used.
40
+ * @property vertexIndices Object containing the indices for the vertices and the size of each index group.
41
+ * @property vertexIndices.value The indices referencing vertices, as a typed integer array or a number array.
42
+ * @property vertexIndices.size The number of indices per primitive (e.g., 1 for vertex indices).
43
+ */
44
+ export type TriangleMeshProps = {
45
+ topology: "line-list" | "line-strip";
46
+ vertices?: TypedFloatArray | number[];
47
+ vertexIndices: {
48
+ value: TypedIntArray | number[];
49
+ size: number;
50
+ };
51
+ };
52
+ /**
53
+ * Props for the GpglValueMappedSurfaceLayer component, which renders surfaces with value-mapped textures.
54
+ *
55
+ * @remarks
56
+ * This interface extends `ExtendedLayerProps` and provides configuration for rendering surfaces
57
+ * with value-mapped textures, optional triangle meshes, and various rendering options such as
58
+ * shading, lighting, and depth testing.
59
+ */
60
+ export interface GpglValueMappedSurfaceLayerProps extends ExtendedLayerProps {
61
+ /** Surfaces with a value map used as texture. */
62
+ valueMappedTriangles: ValueMappedTriangleProps[];
63
+ /** Optional triangle meshes. Inferred from `valueMappedTriangles` if not specified. */
64
+ triangleMeshes: TriangleMeshProps[];
65
+ /** Whether to display the mesh overlay. */
66
+ showMesh: boolean;
67
+ /** Definition of the colormap to use for mapping values to colors. */
68
+ colormap?: ColormapProps;
69
+ /** Setup of the colormap. */
70
+ colormapSetup?: ColormapSetup;
71
+ /** Plain color if no value map is provided. */
72
+ color: RGBColor;
73
+ /** Surface material properties.
74
+ * material: true = default material, coloring depends on surface orientation and lighting.
75
+ * false = no material, coloring is independent on surface orientation and lighting.
76
+ * or full spec:
77
+ * material: {
78
+ * ambient: 0.35,
79
+ * diffuse: 0.9,
80
+ * shininess: 32,
81
+ * specularColor: [38, 38, 38],
82
+ * }
83
+ * Default value: true.
84
+ */
85
+ material: Material;
86
+ /** Enables smooth shading for the surface.
87
+ * If true, the per-vertex normals will be interpolated across triangles and used for shading.
88
+ * Otherwise, a constant normal will be computed and used across each triangle.
89
+ */
90
+ smoothShading: boolean;
91
+ /** Enables depth testing for rendering. */
92
+ depthTest: boolean;
93
+ /** Indicates if the Z axis increases downwards. */
94
+ ZIncreasingDownwards: boolean;
95
+ }
96
+ /**
97
+ * GpglValueMappedSurfaceLayer is a layer handling surfaces textured by a value map.
98
+ * These values are converted to color using a colormap and associated setup.
99
+ *
100
+ * A primary use case is to display seismic data.
101
+ * The surfaces are expected to be small compared to the ones handled by the triangles layer.
102
+ */
103
+ export declare class GpglValueMappedSurfaceLayer extends Layer<GpglValueMappedSurfaceLayerProps> {
104
+ setShaderModuleProps(args: Partial<{
105
+ [x: string]: Partial<Record<string, unknown> | undefined>;
106
+ }>): void;
107
+ initializeState(context: DeckGLLayerContext): void;
108
+ updateState(params: UpdateParameters<Layer<GpglValueMappedSurfaceLayerProps>>): void;
109
+ private _consolidateColormap;
110
+ private _createColormapTexture;
111
+ private _createValuesTexture;
112
+ private _createModels;
113
+ getModels(): Model[];
114
+ private _getClampColors;
115
+ draw(args: any): void;
116
+ decodePickingColor(): number;
117
+ getPickingInfo({ info }: {
118
+ info: PickingInfo;
119
+ }): LayerPickInfo;
120
+ }
@@ -0,0 +1,495 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { COORDINATE_SYSTEM, Layer, picking, project32 } from "@deck.gl/core";
11
+ import { GL } from "@luma.gl/constants";
12
+ import { Geometry, Model } from "@luma.gl/engine";
13
+ import { lighting } from "@luma.gl/shadertools";
14
+ import { phongMaterial } from "../shader_modules/phong-lighting/phong-material";
15
+ import { precisionForTests } from "../shader_modules/test-precision/precisionForTests";
16
+ import { createPropertyData } from "../utils/layerTools";
17
+ import { getImageData, } from "../utils/colormapTools";
18
+ import { isTypedArray, loadDataArray, toNormalizedColor, toTypedArray, } from "../../utils";
19
+ import fsShader from "./triangle.fs.glsl";
20
+ import vsShader from "./triangle.vs.glsl";
21
+ import fsTexShader from "./texTriangle.fs.glsl";
22
+ import vsTexShader from "./texTriangle.vs.glsl";
23
+ import fsLineShader from "./triangleLine.fs.glsl";
24
+ import vsLineShader from "./triangleLine.vs.glsl";
25
+ const defaultMaterial = {
26
+ ambient: 0.35,
27
+ diffuse: 0.9,
28
+ shininess: 32,
29
+ specularColor: [38, 38, 38],
30
+ };
31
+ const defaultColormapSetup = {
32
+ valueRange: [0, 1],
33
+ clampRange: undefined,
34
+ clampColor: [0, 255, 0, 200], // green color for clamped values
35
+ undefinedValue: Number.NaN,
36
+ undefinedColor: [255, 0, 0, 200], // red color for undefined values
37
+ smooth: true,
38
+ };
39
+ const defaultProps = {
40
+ "@@type": "GpglValueMappedSurfaceLayer",
41
+ name: "Value Mapped Surface Layer",
42
+ id: "value-mapped-surface",
43
+ data: ["dummy"],
44
+ showMesh: false,
45
+ colormap: {
46
+ colormapName: "seismic",
47
+ },
48
+ colormapSetup: defaultColormapSetup,
49
+ color: [100, 100, 255],
50
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
51
+ material: true, // default material
52
+ smoothShading: false,
53
+ depthTest: true,
54
+ ZIncreasingDownwards: true,
55
+ // deck.gl default props
56
+ visible: true,
57
+ pickable: true,
58
+ };
59
+ /**
60
+ * GpglValueMappedSurfaceLayer is a layer handling surfaces textured by a value map.
61
+ * These values are converted to color using a colormap and associated setup.
62
+ *
63
+ * A primary use case is to display seismic data.
64
+ * The surfaces are expected to be small compared to the ones handled by the triangles layer.
65
+ */
66
+ export class GpglValueMappedSurfaceLayer extends Layer {
67
+ setShaderModuleProps(args) {
68
+ // If material is a boolean, convert it to the default material
69
+ // We need to set a different default material than in the shader module
70
+ if (typeof args["phongMaterial"] === "boolean" &&
71
+ args["phongMaterial"] === true) {
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
+ args["phongMaterial"] = defaultMaterial;
74
+ }
75
+ super.setShaderModuleProps(Object.assign(Object.assign({}, args), { lighting: Object.assign(Object.assign({}, args["lighting"]), { enabled: this.props.material !== false }) }));
76
+ }
77
+ initializeState(context) {
78
+ const gl = context.device;
79
+ this._createModels(gl).then(([triangleModels, meshModels]) => {
80
+ this.setState({
81
+ triangleModels: triangleModels,
82
+ meshModels: meshModels,
83
+ });
84
+ });
85
+ }
86
+ updateState(params) {
87
+ const rebuild = params.props.valueMappedTriangles !==
88
+ params.oldProps.valueMappedTriangles ||
89
+ params.props.triangleMeshes !== params.oldProps.triangleMeshes ||
90
+ params.props.showMesh !== params.oldProps.showMesh ||
91
+ params.props.colormap !== params.oldProps.colormap;
92
+ super.updateState(params);
93
+ if (rebuild) {
94
+ this.initializeState(params.context);
95
+ }
96
+ }
97
+ _consolidateColormap(colormap) {
98
+ var _a;
99
+ if (colormap instanceof Uint8Array) {
100
+ // If colormapProps is a Uint8Array, return it directly
101
+ return colormap;
102
+ }
103
+ if (!colormap || "colormapName" in colormap) {
104
+ return {
105
+ colormapName: (_a = colormap === null || colormap === void 0 ? void 0 : colormap.colormapName) !== null && _a !== void 0 ? _a : "seismic",
106
+ colorTables: this.context.userData
107
+ .colorTables,
108
+ };
109
+ }
110
+ return colormap;
111
+ }
112
+ _createColormapTexture(device, colormap) {
113
+ const textureProps = {
114
+ sampler: {
115
+ addressModeU: "clamp-to-edge",
116
+ addressModeV: "clamp-to-edge",
117
+ minFilter: "linear",
118
+ magFilter: "linear",
119
+ },
120
+ width: 256,
121
+ height: 1,
122
+ format: "rgb8unorm-webgl",
123
+ };
124
+ return device.createTexture(Object.assign(Object.assign({}, textureProps), { data: getImageData(this._consolidateColormap(colormap)) }));
125
+ }
126
+ _createValuesTexture(device, valueMap) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ var _a, _b;
129
+ if ((valueMap === null || valueMap === void 0 ? void 0 : valueMap.values) === undefined) {
130
+ return undefined;
131
+ }
132
+ // fetch data
133
+ const propertiesData = yield loadDataArray(valueMap.values, Float32Array);
134
+ if (!propertiesData) {
135
+ return undefined;
136
+ }
137
+ const smooth = (_b = (_a = this.props.colormapSetup) === null || _a === void 0 ? void 0 : _a.smooth) !== null && _b !== void 0 ? _b : defaultColormapSetup.smooth;
138
+ const textureProps = {
139
+ sampler: {
140
+ addressModeU: "clamp-to-edge",
141
+ addressModeV: "clamp-to-edge",
142
+ minFilter: smooth ? "linear" : "nearest",
143
+ magFilter: smooth ? "linear" : "nearest",
144
+ },
145
+ width: valueMap.width,
146
+ height: valueMap.height,
147
+ format: "r32float",
148
+ };
149
+ return device.createTexture(Object.assign(Object.assign({}, textureProps), { width: valueMap.width, height: valueMap.height, data: propertiesData }));
150
+ });
151
+ }
152
+ _createModels(device) {
153
+ const _super = Object.create(null, {
154
+ getShaders: { get: () => super.getShaders }
155
+ });
156
+ return __awaiter(this, void 0, void 0, function* () {
157
+ var _a, _b, _c;
158
+ const models = [];
159
+ const meshModels = [];
160
+ // Collect promises for all valueMappedTriangles
161
+ const triangleModelPromises = (_b = (_a = this.props.valueMappedTriangles) === null || _a === void 0 ? void 0 : _a.map((texturedTrgs, i) => __awaiter(this, void 0, void 0, function* () {
162
+ var _d, _e, _f;
163
+ const trglGeometry = {
164
+ topology: texturedTrgs.topology,
165
+ attributes: {
166
+ positions: {
167
+ value: yield loadDataArray(texturedTrgs.vertices, Float32Array),
168
+ size: 3,
169
+ },
170
+ normals: {
171
+ value: yield loadDataArray((_d = texturedTrgs.normals) !== null && _d !== void 0 ? _d : [], Float32Array),
172
+ size: 3,
173
+ },
174
+ texCoords: {
175
+ value: yield loadDataArray((_e = texturedTrgs.texCoords) !== null && _e !== void 0 ? _e : [], Float32Array),
176
+ size: 2,
177
+ },
178
+ },
179
+ vertexCount: texturedTrgs.vertexIndices.size,
180
+ indices: {
181
+ value: yield loadDataArray(texturedTrgs.vertexIndices.value, Uint32Array),
182
+ size: 1,
183
+ },
184
+ };
185
+ const colormap = texturedTrgs.valueMap
186
+ ? this._createColormapTexture(device, this.props.colormap)
187
+ : undefined;
188
+ const floatValues = texturedTrgs.valueMap
189
+ ? yield this._createValuesTexture(device, texturedTrgs.valueMap)
190
+ : undefined;
191
+ const bindings = colormap && floatValues
192
+ ? { colormap, valueTexture: floatValues }
193
+ : undefined;
194
+ const fs = bindings ? fsTexShader : fsShader;
195
+ const vs = bindings ? vsTexShader : vsShader;
196
+ const uniforms = bindings
197
+ ? texTrianglesUniforms
198
+ : trianglesUniforms;
199
+ const model = new Model(device, Object.assign(Object.assign({ id: `${this.props.id}-trgl-${i}` }, _super.getShaders.call(this, {
200
+ vs: vs,
201
+ fs: fs,
202
+ modules: [
203
+ project32,
204
+ picking,
205
+ lighting,
206
+ phongMaterial,
207
+ uniforms,
208
+ precisionForTests,
209
+ ],
210
+ })), { bufferLayout: this.getAttributeManager().getBufferLayouts(), geometry: new Geometry(trglGeometry), bindings: bindings, isInstanced: false }));
211
+ // default mesh model if none if provided
212
+ let meshModel = undefined;
213
+ if (!((_f = this.props.triangleMeshes) === null || _f === void 0 ? void 0 : _f.length) && this.props.showMesh) {
214
+ const indices = computeMeshIndices(texturedTrgs.vertexIndices.value, texturedTrgs.topology);
215
+ const meshGeometry = {
216
+ topology: meshTopology(texturedTrgs.topology),
217
+ attributes: {
218
+ positions: {
219
+ value: toTypedArray(texturedTrgs.vertices, Float32Array),
220
+ size: 3,
221
+ },
222
+ },
223
+ vertexCount: indices.length,
224
+ indices: {
225
+ value: toTypedArray(indices, Uint32Array),
226
+ size: 1,
227
+ },
228
+ };
229
+ meshModel = new Model(device, Object.assign(Object.assign({ id: `${this.props.id}-mesh-line-${i}` }, _super.getShaders.call(this, {
230
+ vs: vsLineShader,
231
+ fs: fsLineShader,
232
+ modules: [
233
+ project32,
234
+ picking,
235
+ triangleMeshUniforms,
236
+ precisionForTests,
237
+ ],
238
+ })), { bufferLayout: this.getAttributeManager().getBufferLayouts(), geometry: new Geometry(meshGeometry), isInstanced: false }));
239
+ }
240
+ return { model, meshModel };
241
+ }))) !== null && _b !== void 0 ? _b : [];
242
+ // Await all promises and push to models/meshModels arrays
243
+ const triangleResults = yield Promise.all(triangleModelPromises);
244
+ triangleResults.forEach(({ model, meshModel }) => {
245
+ models.push(model);
246
+ if (meshModel) {
247
+ meshModels.push(meshModel);
248
+ }
249
+ });
250
+ (_c = this.props.triangleMeshes) === null || _c === void 0 ? void 0 : _c.forEach((mesh, i) => {
251
+ var _a, _b;
252
+ const meshGeometry = {
253
+ topology: mesh.topology,
254
+ attributes: {
255
+ positions: {
256
+ value: toTypedArray((_a = mesh.vertices) !== null && _a !== void 0 ? _a : (_b = this.props.valueMappedTriangles[i]) === null || _b === void 0 ? void 0 : _b.vertices, Float32Array),
257
+ size: 3,
258
+ },
259
+ },
260
+ vertexCount: mesh.vertexIndices.size,
261
+ indices: {
262
+ value: toTypedArray(mesh.vertexIndices.value, Uint32Array),
263
+ size: 1,
264
+ },
265
+ };
266
+ meshModels.push(new Model(device, Object.assign(Object.assign({ id: `${this.props.id}-mesh-line-${i}` }, _super.getShaders.call(this, {
267
+ vs: vsLineShader,
268
+ fs: fsLineShader,
269
+ modules: [
270
+ project32,
271
+ picking,
272
+ triangleMeshUniforms,
273
+ precisionForTests,
274
+ ],
275
+ })), { bufferLayout: this.getAttributeManager().getBufferLayouts(), geometry: new Geometry(meshGeometry), isInstanced: false })));
276
+ });
277
+ return [models, meshModels];
278
+ });
279
+ }
280
+ getModels() {
281
+ var _a, _b;
282
+ const triangleModels = ((_a = this.state["triangleModels"]) !== null && _a !== void 0 ? _a : []);
283
+ const meshModels = ((_b = this.state["meshModels"]) !== null && _b !== void 0 ? _b : []);
284
+ return [...triangleModels, ...meshModels];
285
+ }
286
+ _getClampColors(color) {
287
+ if (isTypedArray(color)) {
288
+ // If clampColor is a Uint8Array, return it directly
289
+ if (color.length >= 8) {
290
+ return [
291
+ toNormalizedColor(color.slice(0, 4)),
292
+ toNormalizedColor(color.slice(4, 8)),
293
+ ];
294
+ }
295
+ else if (color.length === 6) {
296
+ return [
297
+ toNormalizedColor(color.slice(0, 3)),
298
+ toNormalizedColor(color.slice(3, 6)),
299
+ ];
300
+ }
301
+ const col = toNormalizedColor(color);
302
+ return [col, col];
303
+ }
304
+ if (Array.isArray(color) && color.length === 2) {
305
+ return [toNormalizedColor(color[0]), toNormalizedColor(color[1])];
306
+ }
307
+ const col = color ? toNormalizedColor(color) : undefined;
308
+ return [col, col];
309
+ }
310
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
311
+ draw(args) {
312
+ var _a, _b;
313
+ if (!this.state["triangleModels"] && !this.state["meshModels"]) {
314
+ return;
315
+ }
316
+ const triangleModels = this.state["triangleModels"];
317
+ const meshModels = this.state["meshModels"];
318
+ const { gl } = args.context;
319
+ if (!this.props.depthTest) {
320
+ gl.disable(GL.DEPTH_TEST);
321
+ }
322
+ gl.enable(GL.POLYGON_OFFSET_FILL);
323
+ gl.polygonOffset(1, 1);
324
+ //
325
+ const [lowClampColors, highClampColor] = this._getClampColors((_b = (_a = this.props.colormapSetup) === null || _a === void 0 ? void 0 : _a.clampColor) !== null && _b !== void 0 ? _b : defaultColormapSetup.clampColor);
326
+ // render all the triangle surfaces
327
+ triangleModels === null || triangleModels === void 0 ? void 0 : triangleModels.forEach((model) => {
328
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
329
+ model.shaderInputs.setProps(Object.assign(Object.assign({}, args.uniforms), { triangles: {
330
+ colormapRange: (_b = (_a = this.props.colormapSetup) === null || _a === void 0 ? void 0 : _a.valueRange) !== null && _b !== void 0 ? _b : defaultColormapSetup.valueRange,
331
+ clampRange: ((_c = this.props.colormapSetup) === null || _c === void 0 ? void 0 : _c.clampRange) === null
332
+ ? null
333
+ : ((_g = (_e = (_d = this.props.colormapSetup) === null || _d === void 0 ? void 0 : _d.clampRange) !== null && _e !== void 0 ? _e : (_f = this.props.colormapSetup) === null || _f === void 0 ? void 0 : _f.valueRange) !== null && _g !== void 0 ? _g : defaultColormapSetup.valueRange),
334
+ useClampColors: ((_h = this.props.colormapSetup) === null || _h === void 0 ? void 0 : _h.clampColor) !== null &&
335
+ ((_j = this.props.colormapSetup) === null || _j === void 0 ? void 0 : _j.clampRange) !== null,
336
+ lowClampColor: lowClampColors,
337
+ highClampColor: highClampColor,
338
+ undefinedValue: (_l = (_k = this.props.colormapSetup) === null || _k === void 0 ? void 0 : _k.undefinedValue) !== null && _l !== void 0 ? _l : defaultColormapSetup.undefinedValue,
339
+ undefinedColor: toNormalizedColor((_o = (_m = this.props.colormapSetup) === null || _m === void 0 ? void 0 : _m.undefinedColor) !== null && _o !== void 0 ? _o : defaultColormapSetup.undefinedColor),
340
+ // Normalize color to [0,1] range.
341
+ uColor: toNormalizedColor((_p = this.props.color) !== null && _p !== void 0 ? _p : defaultProps.color),
342
+ smoothShading: (_q = this.props.smoothShading) !== null && _q !== void 0 ? _q : defaultProps.smoothShading,
343
+ ZIncreasingDownwards: (_r = this.props.ZIncreasingDownwards) !== null && _r !== void 0 ? _r : defaultProps.ZIncreasingDownwards,
344
+ } }));
345
+ model.draw(args.context.renderPass);
346
+ });
347
+ gl.disable(GL.POLYGON_OFFSET_FILL);
348
+ // render all the triangle meshes
349
+ if (this.props.showMesh) {
350
+ meshModels === null || meshModels === void 0 ? void 0 : meshModels.forEach((meshModel) => {
351
+ var _a;
352
+ meshModel.shaderInputs.setProps(Object.assign(Object.assign({}, args.uniforms), { triangleMesh: {
353
+ ZIncreasingDownwards: (_a = this.props.ZIncreasingDownwards) !== null && _a !== void 0 ? _a : defaultProps.ZIncreasingDownwards,
354
+ } }));
355
+ meshModel.draw(args.context.renderPass);
356
+ });
357
+ }
358
+ if (!this.props.depthTest) {
359
+ gl.enable(GL.DEPTH_TEST);
360
+ }
361
+ }
362
+ decodePickingColor() {
363
+ return 0;
364
+ }
365
+ getPickingInfo({ info }) {
366
+ var _a;
367
+ if (!info.color) {
368
+ return info;
369
+ }
370
+ const layer_properties = [];
371
+ const zScale = this.props.modelMatrix ? this.props.modelMatrix[10] : 1;
372
+ if (typeof ((_a = info.coordinate) === null || _a === void 0 ? void 0 : _a[2]) !== "undefined") {
373
+ const depth = (this.props.ZIncreasingDownwards
374
+ ? -info.coordinate[2]
375
+ : info.coordinate[2]) / Math.max(0.001, zScale);
376
+ layer_properties.push(createPropertyData("Depth", depth));
377
+ }
378
+ return Object.assign(Object.assign({}, info), { properties: layer_properties });
379
+ }
380
+ }
381
+ GpglValueMappedSurfaceLayer.layerName = "GpglValueMappedSurfaceLayer";
382
+ GpglValueMappedSurfaceLayer.defaultProps = defaultProps;
383
+ const triangleMeshUniformsBlock = `\
384
+ uniform triangleMeshUniforms {
385
+ bool ZIncreasingDownwards;
386
+ } triangleMesh;
387
+ `;
388
+ // NOTE: this must exactly the same name than in the uniform block
389
+ const triangleMeshUniforms = {
390
+ name: "triangleMesh",
391
+ vs: triangleMeshUniformsBlock,
392
+ fs: undefined,
393
+ uniformTypes: {
394
+ ZIncreasingDownwards: "f32",
395
+ },
396
+ };
397
+ const triangleUniformsBlock = /*glsl*/ `\
398
+ uniform trianglesUniforms {
399
+ vec4 uColor;
400
+ bool smoothShading;
401
+ bool ZIncreasingDownwards;
402
+ } triangles;
403
+ `;
404
+ // NOTE: this must exactly the same name than in the uniform block
405
+ const trianglesUniforms = {
406
+ name: "triangles",
407
+ vs: triangleUniformsBlock,
408
+ fs: triangleUniformsBlock,
409
+ uniformTypes: {
410
+ uColor: "vec4<f32>",
411
+ smoothShading: "u32",
412
+ ZIncreasingDownwards: "u32",
413
+ },
414
+ };
415
+ const texTriangleUniformsBlock = /*glsl*/ `\
416
+ uniform trianglesUniforms {
417
+ vec2 colormapRange;
418
+ vec2 clampRange;
419
+ bool useClampColors;
420
+ vec4 lowClampColor;
421
+ vec4 highClampColor;
422
+ float undefinedValue;
423
+ vec4 undefinedColor;
424
+ bool smoothShading;
425
+ bool ZIncreasingDownwards;
426
+ } triangles;
427
+ `;
428
+ // NOTE: this must exactly the same name than in the uniform block
429
+ const texTrianglesUniforms = {
430
+ name: "triangles",
431
+ vs: texTriangleUniformsBlock,
432
+ fs: texTriangleUniformsBlock,
433
+ uniformTypes: {
434
+ colormapRange: "vec2<f32>",
435
+ clampRange: "vec2<f32>",
436
+ useClampColors: "u32",
437
+ lowClampColor: "vec4<f32>",
438
+ highClampColor: "vec4<f32>",
439
+ undefinedValue: "f32",
440
+ undefinedColor: "vec4<f32>",
441
+ smoothShading: "u32",
442
+ ZIncreasingDownwards: "u32",
443
+ },
444
+ };
445
+ // Helper functions
446
+ function meshTopology(topology) {
447
+ switch (topology) {
448
+ case "triangle-list":
449
+ return "line-list";
450
+ case "triangle-strip":
451
+ return "line-strip";
452
+ default:
453
+ throw new Error(`Unknown topology: ${topology}`);
454
+ }
455
+ }
456
+ function computeMeshIndices(trglIndices, topology) {
457
+ if (topology === "triangle-list") {
458
+ // non optimal, and some edges might be missing
459
+ // non trivial to fix that :/
460
+ return trglIndices;
461
+ }
462
+ if (trglIndices.length === 4) {
463
+ // special case for a rectangle
464
+ return [
465
+ trglIndices[2],
466
+ trglIndices[0],
467
+ trglIndices[1],
468
+ trglIndices[2],
469
+ trglIndices[3],
470
+ trglIndices[1],
471
+ ];
472
+ }
473
+ // triangle strip.
474
+ // missing edges must be added
475
+ if (Array.isArray(trglIndices) && typeof trglIndices[0] === "number") {
476
+ const indices1 = trglIndices
477
+ .filter((_v, index) => index !== 0 && index % 2 === 0)
478
+ .reverse();
479
+ const indices2 = trglIndices.filter((_v, index) => index !== trglIndices.length - 1 && index % 2 === 1);
480
+ return indices1.concat(trglIndices, indices2);
481
+ }
482
+ else {
483
+ const idxArray = trglIndices;
484
+ const indices1 = idxArray
485
+ .filter((_v, index) => index !== 0 && index % 2 === 0)
486
+ .reverse();
487
+ const indices2 = idxArray.filter((_v, index) => index !== trglIndices.length - 1 && index % 2 === 1);
488
+ const mergedIndices = new Uint32Array(idxArray.length + indices1.length + indices2.length);
489
+ mergedIndices.set(indices1, 0);
490
+ mergedIndices.set(idxArray, indices1.length);
491
+ mergedIndices.set(indices2, indices1.length + idxArray.length);
492
+ return mergedIndices;
493
+ }
494
+ }
495
+ //# sourceMappingURL=gpglValueMappedSurfaceLayer.js.map
@@ -0,0 +1 @@
1
+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AC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACJ,MAAM,QAAQ,GAAG,WAA4B,CAAC;QAC9C,MAAM,QAAQ,GAAG,QAAQ;aACpB,MAAM,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC;aACrD,OAAO,EAAE,CAAC;QACf,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAC5B,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,CACrE,CAAC;QAEF,MAAM,aAAa,GAAG,IAAI,WAAW,CACjC,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CACtD,CAAC;QAEF,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC/B,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC7C,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/D,OAAO,aAAa,CAAC;IACzB,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const _default: "#version 300 es\n#define SHADER_NAME texture-fragment-shader\n\nuniform sampler2D valueTexture;\nuniform sampler2D colormap;\n\nin vec3 cameraPosition;\n\nin vec4 vPosition;\nin vec3 vNormal;\nin vec2 vTexCoords;\nin vec4 vColor;\n\nout vec4 fragColor;\n\n // Normalize the value to the range [0, 1]\nfloat normalizeValue(float value) {\n return (value - triangles.colormapRange[0]) / (triangles.colormapRange[1] - triangles.colormapRange[0]);\n}\n\nvec4 valueColor(float value) {\n if(value == triangles.undefinedValue) {\n return triangles.undefinedColor;\n }\n if(triangles.useClampColors) {\n if(value < triangles.clampRange[0]) {\n return triangles.lowClampColor;\n } else if(value > triangles.clampRange[1]) {\n return triangles.highClampColor;\n }\n }\n float normalizedValue = normalizeValue(value);\n // apply colormap\n return texture(colormap, vec2(normalizedValue, 0.0));\n}\n\nvoid main(void) {\n vec3 normal = vNormal;\n\n if (!triangles.smoothShading) {\n normal = normalize(cross(dFdx(vPosition.xyz), dFdy(vPosition.xyz)));\n }\n\n vec4 color = vColor;\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, vPosition.xyz, normal);\n\n // get value from texture\n float value = texture(valueTexture, vTexCoords).r;\n // compute color\n vec4 colormapColor = valueColor(value);\n\n // multiply by colormap color and apply alpha\n fragColor = vec4(lightColor * colormapColor.rgb, colormapColor.a * vColor.a);\n DECKGL_FILTER_COLOR(fragColor, geometry);\n}\n";
2
+ export default _default;