@webviz/subsurface-viewer 0.0.1-alpha.1 → 0.0.2-alpha.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 (171) hide show
  1. package/dist/package.json +5 -2
  2. package/package.json +6 -3
  3. package/src/DashSubsurfaceViewer.tsx +0 -270
  4. package/src/SubsurfaceViewer.stories.tsx +0 -449
  5. package/src/SubsurfaceViewer.test.tsx +0 -98
  6. package/src/SubsurfaceViewer.tsx +0 -356
  7. package/src/__snapshots__/SubsurfaceViewer.test.tsx.snap +0 -178
  8. package/src/assets/glTF/north_arrow/scene.bin +0 -0
  9. package/src/assets/glTF/north_arrow/scene.gltf +0 -315
  10. package/src/assets/glTF/north_arrow/textures/Arrow5_baseColor.png +0 -0
  11. package/src/assets/glTF/north_arrow/textures/Arrow5_metallicRoughness.png +0 -0
  12. package/src/assets/glTF/north_arrow/textures/Arrow5_normal.png +0 -0
  13. package/src/components/ColorLegend.test.tsx +0 -32
  14. package/src/components/ColorLegend.tsx +0 -80
  15. package/src/components/ColorLegends.test.tsx +0 -97
  16. package/src/components/ColorLegends.tsx +0 -46
  17. package/src/components/DistanceScale.stories.tsx +0 -28
  18. package/src/components/DistanceScale.test.tsx +0 -36
  19. package/src/components/DistanceScale.tsx +0 -84
  20. package/src/components/InfoCard.test.tsx +0 -110
  21. package/src/components/InfoCard.tsx +0 -263
  22. package/src/components/Map.test.tsx +0 -142
  23. package/src/components/Map.tsx +0 -1435
  24. package/src/components/StatusIndicator.test.tsx +0 -14
  25. package/src/components/StatusIndicator.tsx +0 -38
  26. package/src/components/ViewAnnotation.tsx +0 -16
  27. package/src/components/ViewFooter.test.tsx +0 -12
  28. package/src/components/ViewFooter.tsx +0 -30
  29. package/src/components/__snapshots__/ColorLegends.test.tsx.snap +0 -15
  30. package/src/components/__snapshots__/DistanceScale.test.tsx.snap +0 -33
  31. package/src/components/__snapshots__/InfoCard.test.tsx.snap +0 -561
  32. package/src/components/__snapshots__/Map.test.tsx.snap +0 -119
  33. package/src/components/__snapshots__/StatusIndicator.test.tsx.snap +0 -3
  34. package/src/components/__snapshots__/ViewFooter.test.tsx.snap +0 -7
  35. package/src/components/settings/DrawModeSelector.test.tsx +0 -45
  36. package/src/components/settings/DrawModeSelector.tsx +0 -58
  37. package/src/components/settings/DrawModeSelector_performance.test.tsx +0 -35
  38. package/src/components/settings/LayerProperty.test.tsx +0 -35
  39. package/src/components/settings/LayerProperty.tsx +0 -153
  40. package/src/components/settings/LayerProperty_performance.test.tsx +0 -39
  41. package/src/components/settings/LayerSettingsButton.test.tsx +0 -133
  42. package/src/components/settings/LayerSettingsButton.tsx +0 -95
  43. package/src/components/settings/LayersButton.test.tsx +0 -102
  44. package/src/components/settings/LayersButton.tsx +0 -97
  45. package/src/components/settings/NumericInput.test.tsx +0 -25
  46. package/src/components/settings/NumericInput.tsx +0 -67
  47. package/src/components/settings/Settings.tsx +0 -71
  48. package/src/components/settings/SliderInput.test.tsx +0 -28
  49. package/src/components/settings/SliderInput.tsx +0 -71
  50. package/src/components/settings/ToggleButton.test.tsx +0 -25
  51. package/src/components/settings/ToggleButton.tsx +0 -53
  52. package/src/components/settings/__snapshots__/DrawModeSelector.test.tsx.snap +0 -124
  53. package/src/components/settings/__snapshots__/LayerProperty.test.tsx.snap +0 -124
  54. package/src/components/settings/__snapshots__/LayerSettingsButton.test.tsx.snap +0 -36
  55. package/src/components/settings/__snapshots__/LayersButton.test.tsx.snap +0 -83
  56. package/src/components/settings/__snapshots__/NumericInput.test.tsx.snap +0 -123
  57. package/src/components/settings/__snapshots__/SliderInput.test.tsx.snap +0 -244
  58. package/src/components/settings/__snapshots__/ToggleButton.test.tsx.snap +0 -182
  59. package/src/custom.d.ts +0 -9
  60. package/src/index.ts +0 -5
  61. package/src/inputSchema/ColorTables.json +0 -51
  62. package/src/inputSchema/FaultPolygons.json +0 -80
  63. package/src/inputSchema/Grid.json +0 -39
  64. package/src/inputSchema/PieChart.json +0 -72
  65. package/src/inputSchema/WellLog.json +0 -126
  66. package/src/inputSchema/WellLogTemplate.json +0 -136
  67. package/src/inputSchema/WellLogs.json +0 -5
  68. package/src/inputSchema/Wells.json +0 -106
  69. package/src/inputSchema/schemaValidationUtil.tsx +0 -55
  70. package/src/inputSchema/validator.tsx +0 -72
  71. package/src/inputSchema/wellCompletions.json +0 -108
  72. package/src/layers/BoxSelectionLayer/boxSelectionLayer.stories.tsx +0 -172
  73. package/src/layers/BoxSelectionLayer/boxSelectionLayer.tsx +0 -136
  74. package/src/layers/axes/axes-fragment.glsl.ts +0 -15
  75. package/src/layers/axes/axesLayer.stories.tsx +0 -87
  76. package/src/layers/axes/axesLayer.ts +0 -692
  77. package/src/layers/axes/boxLayer.ts +0 -71
  78. package/src/layers/axes/grid-vertex.glsl.ts +0 -14
  79. package/src/layers/axes2d/axes2DLayer.stories.tsx +0 -150
  80. package/src/layers/axes2d/axes2DLayer.ts +0 -841
  81. package/src/layers/axes2d/font-atlas.png +0 -0
  82. package/src/layers/axes2d/label-fragment.glsl.js +0 -37
  83. package/src/layers/axes2d/label-vertex.glsl.js +0 -20
  84. package/src/layers/axes2d/line-fragment.glsl.js +0 -14
  85. package/src/layers/axes2d/line-vertex.glsl.js +0 -13
  86. package/src/layers/colormap/colormap.fs.glsl.ts +0 -42
  87. package/src/layers/colormap/colormapLayer.ts +0 -247
  88. package/src/layers/drawing/drawingLayer.tsx +0 -256
  89. package/src/layers/fault_polygons/faultPolygonsLayer.ts +0 -54
  90. package/src/layers/grid3d/fragment.fs.glsl.ts +0 -109
  91. package/src/layers/grid3d/fragment_lines.glsl.ts +0 -21
  92. package/src/layers/grid3d/grid3dLayer.stories.tsx +0 -172
  93. package/src/layers/grid3d/grid3dLayer.ts +0 -248
  94. package/src/layers/grid3d/privateLayer.ts +0 -292
  95. package/src/layers/grid3d/vertex.glsl.ts +0 -43
  96. package/src/layers/grid3d/vertex_lines.glsl.ts +0 -15
  97. package/src/layers/grid3d/webworker.ts +0 -173
  98. package/src/layers/hillshading2d/hillshading2d.fs.glsl.ts +0 -62
  99. package/src/layers/hillshading2d/hillshading2dLayer.ts +0 -172
  100. package/src/layers/index.ts +0 -35
  101. package/src/layers/intersection/intersectionView.stories.tsx +0 -294
  102. package/src/layers/intersection/unfoldedGeoJsonLayer.ts +0 -92
  103. package/src/layers/map/fragment.fs.glsl.ts +0 -127
  104. package/src/layers/map/fragment_lines.glsl.ts +0 -21
  105. package/src/layers/map/mapLayer.stories.tsx +0 -1369
  106. package/src/layers/map/mapLayer.ts +0 -470
  107. package/src/layers/map/privateMapLayer.ts +0 -317
  108. package/src/layers/map/vertex.glsl.ts +0 -45
  109. package/src/layers/map/vertex_lines.glsl.ts +0 -15
  110. package/src/layers/map/webworker.ts +0 -479
  111. package/src/layers/northarrow/northArrow.stories.tsx +0 -108
  112. package/src/layers/northarrow/northArrow3DLayer.ts +0 -204
  113. package/src/layers/northarrow/northarrow-fragment.glsl.js +0 -14
  114. package/src/layers/northarrow/northarrow-vertex.glsl.js +0 -13
  115. package/src/layers/piechart/fragment.glsl.js +0 -42
  116. package/src/layers/piechart/pieChartLayer.ts +0 -246
  117. package/src/layers/piechart/vertex.glsl.js +0 -42
  118. package/src/layers/points/pointsLayer.stories.tsx +0 -141
  119. package/src/layers/points/pointsLayer.ts +0 -143
  120. package/src/layers/polylines/polylinesLayer.stories.tsx +0 -144
  121. package/src/layers/polylines/polylinesLayer.ts +0 -263
  122. package/src/layers/selectable_geojson/selectableGeoJsonLayer.ts +0 -25
  123. package/src/layers/shader_modules/decoder.fs.glsl.ts +0 -41
  124. package/src/layers/shader_modules/decoder.ts +0 -46
  125. package/src/layers/shader_modules/index.ts +0 -1
  126. package/src/layers/terrain/map3DLayer.stories.tsx +0 -340
  127. package/src/layers/terrain/map3DLayer.ts +0 -556
  128. package/src/layers/terrain/terrainMapLayer.ts +0 -334
  129. package/src/layers/terrain/terrainmap.fs.glsl.ts +0 -134
  130. package/src/layers/triangle/fragment.fs.glsl.ts +0 -126
  131. package/src/layers/triangle/fragment_lines.glsl.ts +0 -21
  132. package/src/layers/triangle/privateTriangleLayer.ts +0 -203
  133. package/src/layers/triangle/test_data/surfacePoints.ts +0 -4344
  134. package/src/layers/triangle/test_data/surfaceTriangles.ts +0 -7392
  135. package/src/layers/triangle/triangleLayer.stories.tsx +0 -191
  136. package/src/layers/triangle/triangleLayer.ts +0 -273
  137. package/src/layers/triangle/vertex.glsl.ts +0 -35
  138. package/src/layers/triangle/vertex_lines.glsl.ts +0 -15
  139. package/src/layers/triangle/webworker.ts +0 -165
  140. package/src/layers/utils/glsl.d.ts +0 -4
  141. package/src/layers/utils/layerTools.ts +0 -182
  142. package/src/layers/utils/propertyMapTools.ts +0 -43
  143. package/src/layers/wells/utils/spline.ts +0 -318
  144. package/src/layers/wells/wellsLayer.stories.tsx +0 -625
  145. package/src/layers/wells/wellsLayer.ts +0 -1377
  146. package/src/redux/actions.ts +0 -8
  147. package/src/redux/reducer.ts +0 -43
  148. package/src/redux/store.ts +0 -15
  149. package/src/redux/types.ts +0 -114
  150. package/src/storybook/SubsurfaceViewer.stories.jsx +0 -644
  151. package/src/storybook/components/InfoCard.stories.jsx +0 -39
  152. package/src/storybook/components/colorLegends/ContinuousLegend.stories.jsx +0 -32
  153. package/src/storybook/components/colorLegends/DiscreteLegend.stories.jsx +0 -33
  154. package/src/storybook/components/colorLegends/IndividualScaleForMap.stories.jsx +0 -99
  155. package/src/storybook/components/colorLegends/SingleScaleForMap.stories.jsx +0 -120
  156. package/src/storybook/components/settings/LayerSettingsButton.stories.jsx +0 -34
  157. package/src/storybook/components/settings/NumericInput.stories.jsx +0 -17
  158. package/src/storybook/components/settings/ToggleButton.stories.jsx +0 -16
  159. package/src/storybook/schemaValidation/sampleData.js +0 -177
  160. package/src/storybook/schemaValidation/schemaValidation.stories.jsx +0 -91
  161. package/src/test/TestWrapper.tsx +0 -13
  162. package/src/utils/configuration.ts +0 -61
  163. package/src/utils/fit-bounds.js +0 -85
  164. package/src/utils/measurement.ts +0 -61
  165. package/src/utils/northArrow.ts +0 -4
  166. package/src/utils/specExtractor.ts +0 -36
  167. package/src/viewports/index.js +0 -1
  168. package/src/viewports/intersectionViewport.ts +0 -137
  169. package/src/views/index.js +0 -1
  170. package/src/views/intersectionView.ts +0 -38
  171. package/tsconfig.json +0 -7
@@ -1,556 +0,0 @@
1
- import { CompositeLayer, Color } from "@deck.gl/core/typed";
2
- import TerrainMapLayer, { DECODER, Material } from "./terrainMapLayer";
3
- import { ExtendedLayerProps, colorMapFunctionType } from "../utils/layerTools";
4
- import { TerrainLoader } from "@loaders.gl/terrain";
5
- import { ImageLoader } from "@loaders.gl/images";
6
- import { load } from "@loaders.gl/core";
7
- import { Vector3 } from "@math.gl/core";
8
- import { getModelMatrix } from "../utils/layerTools";
9
- import { isEqual } from "lodash";
10
- import { ContinuousLegendDataType } from "../../components/ColorLegend";
11
- import { Matrix4 } from "math.gl";
12
-
13
- type MeshType = {
14
- attributes: {
15
- POSITION: { value: Float32Array; size: number };
16
- TEXCOORD_0: { value: Float32Array; size: number };
17
- normals?: { value: Float32Array; size: number };
18
- };
19
- indices: { value: Uint32Array; size: number };
20
- };
21
-
22
- // These two types both describes the mesh' extent in the horizontal plane.
23
- type Bounds = [number, number, number, number];
24
- type Frame = {
25
- // mesh origin
26
- origin: [number, number];
27
-
28
- // cells size in each direction.
29
- increment: [number, number];
30
-
31
- // no cells in each direction.
32
- count: [number, number];
33
-
34
- // Rotates map counterclockwise in degrees around 'rotPoint' specified below.
35
- rotDeg?: number;
36
-
37
- // Point to rotate around using 'rotDeg'. Defaults to mesh origin.
38
- rotPoint?: [number, number];
39
- };
40
-
41
- function getMinMax(dim: Frame): Bounds {
42
- const nx = dim.count[0];
43
- const ny = dim.count[1];
44
-
45
- const dx = dim.increment[0];
46
- const dy = dim.increment[1];
47
-
48
- const xmin = dim.origin[0];
49
- const ymin = dim.origin[1];
50
-
51
- const xmax = xmin + nx * dx;
52
- const ymax = ymin + ny * dy;
53
-
54
- return [xmin, ymin, xmax, ymax];
55
- }
56
-
57
- function mapToRange(resolved_mesh: MeshType, meshValueRange: [number, number]) {
58
- const floatScaler = 1.0 / (256.0 * 256.0 * 256.0 - 1.0);
59
- const [min, max] = meshValueRange;
60
- const delta = max - min;
61
-
62
- const vertexs = resolved_mesh.attributes.POSITION.value;
63
- const nvertexs = vertexs.length / 3;
64
-
65
- for (let i = 0; i < nvertexs; i++) {
66
- let Z = vertexs[i * 3 + 2];
67
- Z = Z * floatScaler; // maps to [0-1]
68
- Z = min + Z * delta;
69
- vertexs[i * 3 + 2] = -Z; // depths are positive along negative z axis.
70
- }
71
-
72
- return resolved_mesh;
73
- }
74
-
75
- function add_normals(
76
- resolved_mesh: MeshType,
77
- meshImageData: ImageData,
78
- bounds: [number, number, number, number]
79
- ) {
80
- const vertexs = resolved_mesh.attributes.POSITION.value;
81
- let indices = resolved_mesh.indices.value;
82
- let ntriangles = indices.length / 3;
83
-
84
- ////////////////////////////////////////////////////////////////
85
- // Remove all triangles that are in undefined areas. That is triangles which
86
- const [xmin, ymin, xmax, ymax] = bounds;
87
-
88
- const w = meshImageData.width;
89
- const h = meshImageData.height;
90
-
91
- const int_view = new Uint8ClampedArray(
92
- meshImageData.data,
93
- 0,
94
- meshImageData.data.length
95
- );
96
-
97
- const dx = (xmax - xmin) / (w - 1);
98
- const dy = (ymax - ymin) / (h - 1);
99
-
100
- const indices_reduced: number[] = [];
101
- for (let tn = 0; tn < ntriangles; tn++) {
102
- const i0 = indices[tn * 3 + 0];
103
- const i1 = indices[tn * 3 + 1];
104
- const i2 = indices[tn * 3 + 2];
105
-
106
- const triangle_indices = [i0, i1, i2];
107
-
108
- const alphas = triangle_indices.map((index) => {
109
- const x = vertexs[index * 3 + 0];
110
- const y = vertexs[index * 3 + 1];
111
-
112
- // Note: assumes increasing 'j' along increasing X axis and Y axis and
113
- // increasing 'i' along decreasing Y axis.
114
- // 'j' along image width. 'i' along image height.
115
- const j = Math.round((x - xmin) / dx);
116
- const i = h - Math.round((y - ymin) / dy);
117
- const pixelNo = i * w + j;
118
-
119
- // Check alpha (transparency) for this triangle corner.
120
- const is_transparent = int_view[pixelNo * 4 + 3] < 255;
121
- return is_transparent;
122
- });
123
-
124
- const do_remove = alphas.some((a) => a);
125
-
126
- if (!do_remove) {
127
- indices_reduced.push(i0);
128
- indices_reduced.push(i1);
129
- indices_reduced.push(i2);
130
- }
131
- }
132
-
133
- resolved_mesh.indices.value = new Uint32Array(indices_reduced);
134
- indices = resolved_mesh.indices.value;
135
- ntriangles = indices.length / 3;
136
-
137
- ////////////////////////////////////////////////////////////////
138
- // Calculate one normal pr triangle. And record the triangles each vertex' belongs to.
139
- const no_unique_vertexes = vertexs.length / 3;
140
- const vertex_triangles = Array(no_unique_vertexes); // for each vertex a list of triangles it belongs to.
141
- for (let i = 0; i < no_unique_vertexes; i++) {
142
- vertex_triangles[i] = new Set();
143
- }
144
-
145
- const triangle_normals = Array(ntriangles);
146
- for (let t = 0; t < ntriangles; t++) {
147
- const i0 = indices[t * 3 + 0];
148
- const i1 = indices[t * 3 + 1];
149
- const i2 = indices[t * 3 + 2];
150
-
151
- vertex_triangles[i0].add(t);
152
- vertex_triangles[i1].add(t);
153
- vertex_triangles[i2].add(t);
154
-
155
- // Triangles' three corners.
156
- const v0 = new Vector3(
157
- vertexs[i0 * 3 + 0],
158
- vertexs[i0 * 3 + 1],
159
- vertexs[i0 * 3 + 2]
160
- );
161
- const v1 = new Vector3(
162
- vertexs[i1 * 3 + 0],
163
- vertexs[i1 * 3 + 1],
164
- vertexs[i1 * 3 + 2]
165
- );
166
- const v2 = new Vector3(
167
- vertexs[i2 * 3 + 0],
168
- vertexs[i2 * 3 + 1],
169
- vertexs[i2 * 3 + 2]
170
- );
171
-
172
- const vec1 = v1.subtract(v0);
173
- const vec2 = v2.subtract(v0);
174
-
175
- const normal = vec1.cross(vec2).normalize();
176
- triangle_normals[t] = normal;
177
- }
178
-
179
- // Calculate normals. The vertex normal will be the mean of the normals of every triangle the vertex
180
- // belongs to.
181
- const normals = Array(vertexs.length).fill(0.0);
182
-
183
- for (let i = 0; i < no_unique_vertexes; i++) {
184
- const triangles = [...vertex_triangles[i]];
185
- // Set normal to mean of all triangle normals.
186
- const v =
187
- triangles.length !== 0
188
- ? triangle_normals[triangles[0]]
189
- : new Vector3(0.0, 0.0, 1.0);
190
- for (let t = 1; t < triangles.length; t++) {
191
- v.add(triangle_normals[triangles[t]]);
192
- }
193
- v.normalize();
194
-
195
- const idx = i * 3;
196
- normals[idx + 0] = v[0];
197
- normals[idx + 1] = v[1];
198
- normals[idx + 2] = v[2];
199
- }
200
-
201
- resolved_mesh.attributes.normals = {
202
- value: new Float32Array(normals),
203
- size: 3,
204
- };
205
-
206
- return resolved_mesh;
207
- }
208
-
209
- async function load_mesh_and_texture(
210
- mesh_name: string,
211
- bounds: Bounds,
212
- meshMaxError: number,
213
- meshValueRange: [number, number],
214
- smoothShading: boolean,
215
- texture_name: string
216
- ) {
217
- const isMesh = mesh_name !== "";
218
- const isTexture = texture_name !== "";
219
-
220
- if (!isMesh && !isTexture) {
221
- console.error("Error. One or both of texture and mesh must be given!");
222
- }
223
-
224
- const image_name = isTexture ? texture_name : mesh_name;
225
- const texture = await load(image_name, ImageLoader, {
226
- image: { type: "data" }, // Will load as ImageData.
227
- });
228
-
229
- let meshImageData: ImageData | null = null;
230
-
231
- let mesh: MeshType;
232
- if (isMesh) {
233
- mesh = await load(mesh_name, TerrainLoader, {
234
- terrain: {
235
- elevationDecoder: DECODER,
236
- bounds,
237
- meshMaxError,
238
- skirtHeight: 0.0,
239
- },
240
- worker: false,
241
- });
242
-
243
- // Remap height to meshValueRange
244
- mesh = mapToRange(mesh, meshValueRange);
245
-
246
- meshImageData = await load(mesh_name, ImageLoader, {
247
- image: { type: "data" }, // Will load as ImageData.
248
- });
249
-
250
- // Note: mesh contains triangles. No normals they must be added.
251
- if (smoothShading && meshImageData) {
252
- mesh = add_normals(mesh, meshImageData, bounds);
253
- }
254
- } else {
255
- // Mesh data is missing.
256
- // Make a flat square size of enclosing dim using two triangles. z = 0.
257
- const [minX, minY, maxX, maxY] = bounds;
258
- const p0 = [minX, minY, 0.0];
259
- const p1 = [minX, maxY, 0.0];
260
- const p2 = [maxX, maxY, 0.0];
261
- const p3 = [maxX, minY, 0.0];
262
- const vertexes = [...p0, ...p1, ...p2, ...p3];
263
- const texture_coord = [0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0];
264
-
265
- mesh = {
266
- attributes: {
267
- POSITION: { value: new Float32Array(vertexes), size: 3 },
268
- TEXCOORD_0: { value: new Float32Array(texture_coord), size: 2 },
269
- },
270
- indices: { value: new Uint32Array([0, 1, 3, 1, 3, 2]), size: 1 },
271
- };
272
- }
273
-
274
- return Promise.all([mesh, meshImageData, texture]);
275
- }
276
-
277
- export interface Map3DLayerProps<D> extends ExtendedLayerProps<D> {
278
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
279
- setReportedBoundingBox?: any;
280
-
281
- // Url to png image representing the height mesh.
282
- mesh: string;
283
-
284
- // Horizontal extent of the terrain mesh.
285
- frame?: Frame;
286
-
287
- // Deprecated: mesh's horizonal extent as [xmin, ymin, xmax, ymax]
288
- bounds?: [number, number, number, number];
289
-
290
- // Mesh error in meters. The output mesh is in higher resolution (more vertices) if the error is smaller.
291
- meshMaxError: number;
292
-
293
- // Url to png image for map properties. (ex, poro or perm values as a texture)
294
- propertyTexture: string;
295
-
296
- // Deprecated: Rotates map counterclockwise in degrees around 'rotPoint' specified below.
297
- rotDeg?: number;
298
-
299
- // Deprecated: Point to rotate around using 'rotDeg'. Defaults to mesh origin.
300
- rotPoint?: [number, number];
301
-
302
- // Contourlines reference point and interval.
303
- // A value of [-1.0, -1.0] will disable contour lines.
304
- // default value: [-1.0, -1.0]
305
- contours: [number, number];
306
-
307
- // Contourlines may be calculated either on depth/z-value or on property/texture value
308
- // If this is set to false, lines will follow properties instead of depth.
309
- // In 2D mode this is always the case regardless.
310
- // default: true
311
- isContoursDepth: boolean;
312
-
313
- // Name of color map. E.g "PORO"
314
- colorMapName: string;
315
-
316
- // Min and max of map height values values.
317
- meshValueRange: [number, number];
318
-
319
- // Min and max property values.
320
- propertyValueRange: [number, number];
321
-
322
- // Use color map in this range.
323
- colorMapRange: [number, number];
324
-
325
- // Clamp colormap to this color at ends.
326
- // Given as array of three values (r,g,b) e.g: [255, 0, 0]
327
- // If not set or set to true, it will clamp to color map min and max values.
328
- // If set to false the clamp color will be completely transparent.
329
- colorMapClampColor: Color | undefined | boolean;
330
-
331
- // Optional function property.
332
- // If defined this function will override the color map.
333
- // Takes a value in the range [0,1] and returns a color.
334
- colorMapFunction?: colorMapFunctionType;
335
-
336
- // Will calculate normals and enable phong shading.
337
- smoothShading: boolean;
338
-
339
- // Surface material properties.
340
- // material: true = default material,
341
- // false = no material,
342
- // or full spec:
343
- // material: {
344
- // ambient: 0.35,
345
- // diffuse: 0.6,
346
- // shininess: 32,
347
- // specularColor: [255, 255, 255],
348
- // }
349
- material: Material;
350
-
351
- // Enable/disable depth testing when rendering layer. Default true.
352
- depthTest: boolean;
353
- }
354
-
355
- const defaultProps = {
356
- "@@type": "Map3DLayer",
357
- name: "Map 3D",
358
- id: "map3d-layer",
359
- pickable: true,
360
- visible: true,
361
- // Url to png image for height field.
362
- mesh: "",
363
- meshValueRange: { type: "array", value: [0, 1] },
364
- // Mesh error in meters. The output mesh is in higher resolution (more vertices) if the error is smaller.
365
- meshMaxError: { type: "number", value: 5 },
366
- // Url to png image for map properties. (ex, poro or perm values as a texture)
367
- propertyTexture: "",
368
- propertyValueRange: { type: "array", value: [0, 1] },
369
- contours: [-1.0, -1.0],
370
- // If contour lines should follow depth or properties.
371
- isContoursDepth: true,
372
- smoothShading: true,
373
- material: true,
374
- depthTest: true,
375
- };
376
-
377
- export default class Map3DLayer extends CompositeLayer<
378
- Map3DLayerProps<unknown>
379
- > {
380
- initializeState(): void {
381
- // Load mesh and texture and store in state.
382
- const isBounds = typeof this.props.bounds !== "undefined";
383
- if (isBounds) {
384
- console.warn('"bounds" is deprecated. Use "frame" instead.');
385
- }
386
-
387
- const isFrame = typeof this.props.frame !== "undefined";
388
-
389
- if (!isBounds && !isFrame) {
390
- console.error(
391
- 'Error. Either "Frame" or "bounds" must be given for map3DLayer!'
392
- );
393
- }
394
-
395
- const bounds = (
396
- isFrame ? getMinMax(this.props.frame as Frame) : this.props.bounds
397
- ) as Bounds;
398
-
399
- const p = load_mesh_and_texture(
400
- this.props.mesh,
401
- bounds,
402
- this.props.meshMaxError,
403
- this.props.meshValueRange,
404
- this.props.smoothShading,
405
- this.props.propertyTexture
406
- );
407
-
408
- p.then(([mesh, meshImageData, texture]) => {
409
- this.setState({
410
- mesh,
411
- meshImageData,
412
- texture,
413
- });
414
- });
415
-
416
- // Report back calculated bounding box now that data is loaded.
417
- p.then(() => {
418
- const xinc = this.props.frame?.increment?.[0] ?? 0;
419
- const yinc = this.props.frame?.increment?.[1] ?? 0;
420
-
421
- const xcount = this.props.frame?.count?.[0] ?? 1;
422
- const ycount = this.props.frame?.count?.[1] ?? 1;
423
-
424
- const xMin = this.props.frame?.origin?.[0] ?? bounds[0];
425
- const yMin = this.props.frame?.origin?.[1] ?? bounds[1];
426
- const zMin = -this.props.meshValueRange[1];
427
- const xMax = isFrame ? xMin + xinc * xcount : bounds[2];
428
- const yMax = isFrame ? yMin + yinc * ycount : bounds[3];
429
- const zMax = -this.props.meshValueRange[0];
430
-
431
- if (typeof this.props.setReportedBoundingBox !== "undefined") {
432
- this.props.setReportedBoundingBox([
433
- xMin,
434
- yMin,
435
- zMin,
436
- xMax,
437
- yMax,
438
- zMax,
439
- ]);
440
- }
441
- });
442
- }
443
-
444
- updateState({
445
- props,
446
- oldProps,
447
- }: {
448
- props: Map3DLayerProps<unknown>;
449
- oldProps: Map3DLayerProps<unknown>;
450
- }): void {
451
- const needs_reload =
452
- !isEqual(props.mesh, oldProps.mesh) ||
453
- !isEqual(props.bounds, oldProps.bounds) ||
454
- !isEqual(props.frame, oldProps.frame) ||
455
- !isEqual(props.meshMaxError, oldProps.meshMaxError) ||
456
- !isEqual(props.meshValueRange, oldProps.meshValueRange) ||
457
- !isEqual(props.smoothShading, oldProps.smoothShading) ||
458
- !isEqual(props.propertyTexture, oldProps.propertyTexture);
459
-
460
- if (needs_reload) {
461
- // Reload mesh and texture.
462
- this.initializeState();
463
- }
464
- }
465
-
466
- renderLayers(): [TerrainMapLayer] {
467
- const isBounds = typeof this.props.bounds !== "undefined";
468
- const bounds = (
469
- isBounds ? this.props.bounds : getMinMax(this.props.frame as Frame)
470
- ) as Bounds;
471
-
472
- // Note: these are deprecated so this code may be deleted later.
473
- const isRotDegDefined = typeof this.props.rotDeg !== "undefined";
474
- const isRotPointDefined = typeof this.props.rotPoint !== "undefined";
475
-
476
- if (isRotDegDefined) {
477
- console.warn('"rotDeg" is deprecated. Use "frame.rotDeg" instead.');
478
- }
479
-
480
- if (isRotPointDefined) {
481
- console.warn(
482
- '"rotPoint" is deprecated. Use "frame.rotPoint" instead.'
483
- );
484
- }
485
-
486
- const [minX, minY] = [bounds[0], bounds[1]];
487
- const center =
488
- this.props.frame?.rotPoint ??
489
- ((isRotPointDefined ? this.props.rotPoint : [minX, minY]) as [
490
- number,
491
- number
492
- ]);
493
-
494
- const rotatingModelMatrix = getModelMatrix(
495
- this.props.frame?.rotDeg ??
496
- ((isRotDegDefined ? this.props.rotDeg : 0) as number),
497
- center[0],
498
- center[1]
499
- );
500
-
501
- const isModelMatrix =
502
- typeof this.props.modelMatrix !== "undefined" &&
503
- this.props.modelMatrix !== null;
504
-
505
- if (isModelMatrix) {
506
- rotatingModelMatrix.multiplyRight(
507
- this.props.modelMatrix as Matrix4
508
- );
509
- }
510
-
511
- const isMesh =
512
- typeof this.props.mesh !== "undefined" && this.props.mesh !== "";
513
-
514
- const layer = new TerrainMapLayer(
515
- this.getSubLayerProps({
516
- mesh: this.state["mesh"],
517
- texture: this.state["texture"],
518
- textureImageData: this.state["texture"],
519
- meshImageData: this.state["meshImageData"],
520
- meshValueRange: this.props.meshValueRange,
521
- pickable: this.props.pickable,
522
- modelMatrix: rotatingModelMatrix,
523
- contours: this.props.contours,
524
- colorMapName: this.props.colorMapName,
525
- colorMapFunction: this.props.colorMapFunction,
526
- propertyValueRange: this.props.propertyValueRange,
527
- colorMapRange: this.props.colorMapRange,
528
- colorMapClampColor: this.props.colorMapClampColor,
529
- isContoursDepth: !isMesh ? false : this.props.isContoursDepth,
530
- material: this.props.material,
531
- wireframe: false,
532
- depthTest: this.props.depthTest,
533
- })
534
- );
535
- return [layer];
536
- }
537
-
538
- getLegendData(): ContinuousLegendDataType {
539
- const colorRange = this.props.colorMapRange;
540
- const propertyRange =
541
- this.props.propertyTexture && this.props.propertyValueRange;
542
- const meshRange = this.props.mesh && this.props.meshValueRange;
543
- const legendRange = colorRange || propertyRange || meshRange;
544
-
545
- return {
546
- discrete: false,
547
- valueRange: legendRange,
548
- colorName: this.props.colorMapName,
549
- title: "Map3dLayer",
550
- colorMapFunction: this.props.colorMapFunction,
551
- };
552
- }
553
- }
554
-
555
- Map3DLayer.layerName = "Map3DLayer";
556
- Map3DLayer.defaultProps = defaultProps;