@webviz/subsurface-viewer 0.0.1-alpha.1 → 0.0.2-alpha.2

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 (177) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/package.json +5 -2
  5. package/package.json +6 -3
  6. package/dist/DashSubsurfaceViewer.d.ts +0 -56
  7. package/dist/DashSubsurfaceViewer.js +0 -160
  8. package/dist/DashSubsurfaceViewer.js.map +0 -1
  9. package/src/DashSubsurfaceViewer.tsx +0 -270
  10. package/src/SubsurfaceViewer.stories.tsx +0 -449
  11. package/src/SubsurfaceViewer.test.tsx +0 -98
  12. package/src/SubsurfaceViewer.tsx +0 -356
  13. package/src/__snapshots__/SubsurfaceViewer.test.tsx.snap +0 -178
  14. package/src/assets/glTF/north_arrow/scene.bin +0 -0
  15. package/src/assets/glTF/north_arrow/scene.gltf +0 -315
  16. package/src/assets/glTF/north_arrow/textures/Arrow5_baseColor.png +0 -0
  17. package/src/assets/glTF/north_arrow/textures/Arrow5_metallicRoughness.png +0 -0
  18. package/src/assets/glTF/north_arrow/textures/Arrow5_normal.png +0 -0
  19. package/src/components/ColorLegend.test.tsx +0 -32
  20. package/src/components/ColorLegend.tsx +0 -80
  21. package/src/components/ColorLegends.test.tsx +0 -97
  22. package/src/components/ColorLegends.tsx +0 -46
  23. package/src/components/DistanceScale.stories.tsx +0 -28
  24. package/src/components/DistanceScale.test.tsx +0 -36
  25. package/src/components/DistanceScale.tsx +0 -84
  26. package/src/components/InfoCard.test.tsx +0 -110
  27. package/src/components/InfoCard.tsx +0 -263
  28. package/src/components/Map.test.tsx +0 -142
  29. package/src/components/Map.tsx +0 -1435
  30. package/src/components/StatusIndicator.test.tsx +0 -14
  31. package/src/components/StatusIndicator.tsx +0 -38
  32. package/src/components/ViewAnnotation.tsx +0 -16
  33. package/src/components/ViewFooter.test.tsx +0 -12
  34. package/src/components/ViewFooter.tsx +0 -30
  35. package/src/components/__snapshots__/ColorLegends.test.tsx.snap +0 -15
  36. package/src/components/__snapshots__/DistanceScale.test.tsx.snap +0 -33
  37. package/src/components/__snapshots__/InfoCard.test.tsx.snap +0 -561
  38. package/src/components/__snapshots__/Map.test.tsx.snap +0 -119
  39. package/src/components/__snapshots__/StatusIndicator.test.tsx.snap +0 -3
  40. package/src/components/__snapshots__/ViewFooter.test.tsx.snap +0 -7
  41. package/src/components/settings/DrawModeSelector.test.tsx +0 -45
  42. package/src/components/settings/DrawModeSelector.tsx +0 -58
  43. package/src/components/settings/DrawModeSelector_performance.test.tsx +0 -35
  44. package/src/components/settings/LayerProperty.test.tsx +0 -35
  45. package/src/components/settings/LayerProperty.tsx +0 -153
  46. package/src/components/settings/LayerProperty_performance.test.tsx +0 -39
  47. package/src/components/settings/LayerSettingsButton.test.tsx +0 -133
  48. package/src/components/settings/LayerSettingsButton.tsx +0 -95
  49. package/src/components/settings/LayersButton.test.tsx +0 -102
  50. package/src/components/settings/LayersButton.tsx +0 -97
  51. package/src/components/settings/NumericInput.test.tsx +0 -25
  52. package/src/components/settings/NumericInput.tsx +0 -67
  53. package/src/components/settings/Settings.tsx +0 -71
  54. package/src/components/settings/SliderInput.test.tsx +0 -28
  55. package/src/components/settings/SliderInput.tsx +0 -71
  56. package/src/components/settings/ToggleButton.test.tsx +0 -25
  57. package/src/components/settings/ToggleButton.tsx +0 -53
  58. package/src/components/settings/__snapshots__/DrawModeSelector.test.tsx.snap +0 -124
  59. package/src/components/settings/__snapshots__/LayerProperty.test.tsx.snap +0 -124
  60. package/src/components/settings/__snapshots__/LayerSettingsButton.test.tsx.snap +0 -36
  61. package/src/components/settings/__snapshots__/LayersButton.test.tsx.snap +0 -83
  62. package/src/components/settings/__snapshots__/NumericInput.test.tsx.snap +0 -123
  63. package/src/components/settings/__snapshots__/SliderInput.test.tsx.snap +0 -244
  64. package/src/components/settings/__snapshots__/ToggleButton.test.tsx.snap +0 -182
  65. package/src/custom.d.ts +0 -9
  66. package/src/index.ts +0 -5
  67. package/src/inputSchema/ColorTables.json +0 -51
  68. package/src/inputSchema/FaultPolygons.json +0 -80
  69. package/src/inputSchema/Grid.json +0 -39
  70. package/src/inputSchema/PieChart.json +0 -72
  71. package/src/inputSchema/WellLog.json +0 -126
  72. package/src/inputSchema/WellLogTemplate.json +0 -136
  73. package/src/inputSchema/WellLogs.json +0 -5
  74. package/src/inputSchema/Wells.json +0 -106
  75. package/src/inputSchema/schemaValidationUtil.tsx +0 -55
  76. package/src/inputSchema/validator.tsx +0 -72
  77. package/src/inputSchema/wellCompletions.json +0 -108
  78. package/src/layers/BoxSelectionLayer/boxSelectionLayer.stories.tsx +0 -172
  79. package/src/layers/BoxSelectionLayer/boxSelectionLayer.tsx +0 -136
  80. package/src/layers/axes/axes-fragment.glsl.ts +0 -15
  81. package/src/layers/axes/axesLayer.stories.tsx +0 -87
  82. package/src/layers/axes/axesLayer.ts +0 -692
  83. package/src/layers/axes/boxLayer.ts +0 -71
  84. package/src/layers/axes/grid-vertex.glsl.ts +0 -14
  85. package/src/layers/axes2d/axes2DLayer.stories.tsx +0 -150
  86. package/src/layers/axes2d/axes2DLayer.ts +0 -841
  87. package/src/layers/axes2d/font-atlas.png +0 -0
  88. package/src/layers/axes2d/label-fragment.glsl.js +0 -37
  89. package/src/layers/axes2d/label-vertex.glsl.js +0 -20
  90. package/src/layers/axes2d/line-fragment.glsl.js +0 -14
  91. package/src/layers/axes2d/line-vertex.glsl.js +0 -13
  92. package/src/layers/colormap/colormap.fs.glsl.ts +0 -42
  93. package/src/layers/colormap/colormapLayer.ts +0 -247
  94. package/src/layers/drawing/drawingLayer.tsx +0 -256
  95. package/src/layers/fault_polygons/faultPolygonsLayer.ts +0 -54
  96. package/src/layers/grid3d/fragment.fs.glsl.ts +0 -109
  97. package/src/layers/grid3d/fragment_lines.glsl.ts +0 -21
  98. package/src/layers/grid3d/grid3dLayer.stories.tsx +0 -172
  99. package/src/layers/grid3d/grid3dLayer.ts +0 -248
  100. package/src/layers/grid3d/privateLayer.ts +0 -292
  101. package/src/layers/grid3d/vertex.glsl.ts +0 -43
  102. package/src/layers/grid3d/vertex_lines.glsl.ts +0 -15
  103. package/src/layers/grid3d/webworker.ts +0 -173
  104. package/src/layers/hillshading2d/hillshading2d.fs.glsl.ts +0 -62
  105. package/src/layers/hillshading2d/hillshading2dLayer.ts +0 -172
  106. package/src/layers/index.ts +0 -35
  107. package/src/layers/intersection/intersectionView.stories.tsx +0 -294
  108. package/src/layers/intersection/unfoldedGeoJsonLayer.ts +0 -92
  109. package/src/layers/map/fragment.fs.glsl.ts +0 -127
  110. package/src/layers/map/fragment_lines.glsl.ts +0 -21
  111. package/src/layers/map/mapLayer.stories.tsx +0 -1369
  112. package/src/layers/map/mapLayer.ts +0 -470
  113. package/src/layers/map/privateMapLayer.ts +0 -317
  114. package/src/layers/map/vertex.glsl.ts +0 -45
  115. package/src/layers/map/vertex_lines.glsl.ts +0 -15
  116. package/src/layers/map/webworker.ts +0 -479
  117. package/src/layers/northarrow/northArrow.stories.tsx +0 -108
  118. package/src/layers/northarrow/northArrow3DLayer.ts +0 -204
  119. package/src/layers/northarrow/northarrow-fragment.glsl.js +0 -14
  120. package/src/layers/northarrow/northarrow-vertex.glsl.js +0 -13
  121. package/src/layers/piechart/fragment.glsl.js +0 -42
  122. package/src/layers/piechart/pieChartLayer.ts +0 -246
  123. package/src/layers/piechart/vertex.glsl.js +0 -42
  124. package/src/layers/points/pointsLayer.stories.tsx +0 -141
  125. package/src/layers/points/pointsLayer.ts +0 -143
  126. package/src/layers/polylines/polylinesLayer.stories.tsx +0 -144
  127. package/src/layers/polylines/polylinesLayer.ts +0 -263
  128. package/src/layers/selectable_geojson/selectableGeoJsonLayer.ts +0 -25
  129. package/src/layers/shader_modules/decoder.fs.glsl.ts +0 -41
  130. package/src/layers/shader_modules/decoder.ts +0 -46
  131. package/src/layers/shader_modules/index.ts +0 -1
  132. package/src/layers/terrain/map3DLayer.stories.tsx +0 -340
  133. package/src/layers/terrain/map3DLayer.ts +0 -556
  134. package/src/layers/terrain/terrainMapLayer.ts +0 -334
  135. package/src/layers/terrain/terrainmap.fs.glsl.ts +0 -134
  136. package/src/layers/triangle/fragment.fs.glsl.ts +0 -126
  137. package/src/layers/triangle/fragment_lines.glsl.ts +0 -21
  138. package/src/layers/triangle/privateTriangleLayer.ts +0 -203
  139. package/src/layers/triangle/test_data/surfacePoints.ts +0 -4344
  140. package/src/layers/triangle/test_data/surfaceTriangles.ts +0 -7392
  141. package/src/layers/triangle/triangleLayer.stories.tsx +0 -191
  142. package/src/layers/triangle/triangleLayer.ts +0 -273
  143. package/src/layers/triangle/vertex.glsl.ts +0 -35
  144. package/src/layers/triangle/vertex_lines.glsl.ts +0 -15
  145. package/src/layers/triangle/webworker.ts +0 -165
  146. package/src/layers/utils/glsl.d.ts +0 -4
  147. package/src/layers/utils/layerTools.ts +0 -182
  148. package/src/layers/utils/propertyMapTools.ts +0 -43
  149. package/src/layers/wells/utils/spline.ts +0 -318
  150. package/src/layers/wells/wellsLayer.stories.tsx +0 -625
  151. package/src/layers/wells/wellsLayer.ts +0 -1377
  152. package/src/redux/actions.ts +0 -8
  153. package/src/redux/reducer.ts +0 -43
  154. package/src/redux/store.ts +0 -15
  155. package/src/redux/types.ts +0 -114
  156. package/src/storybook/SubsurfaceViewer.stories.jsx +0 -644
  157. package/src/storybook/components/InfoCard.stories.jsx +0 -39
  158. package/src/storybook/components/colorLegends/ContinuousLegend.stories.jsx +0 -32
  159. package/src/storybook/components/colorLegends/DiscreteLegend.stories.jsx +0 -33
  160. package/src/storybook/components/colorLegends/IndividualScaleForMap.stories.jsx +0 -99
  161. package/src/storybook/components/colorLegends/SingleScaleForMap.stories.jsx +0 -120
  162. package/src/storybook/components/settings/LayerSettingsButton.stories.jsx +0 -34
  163. package/src/storybook/components/settings/NumericInput.stories.jsx +0 -17
  164. package/src/storybook/components/settings/ToggleButton.stories.jsx +0 -16
  165. package/src/storybook/schemaValidation/sampleData.js +0 -177
  166. package/src/storybook/schemaValidation/schemaValidation.stories.jsx +0 -91
  167. package/src/test/TestWrapper.tsx +0 -13
  168. package/src/utils/configuration.ts +0 -61
  169. package/src/utils/fit-bounds.js +0 -85
  170. package/src/utils/measurement.ts +0 -61
  171. package/src/utils/northArrow.ts +0 -4
  172. package/src/utils/specExtractor.ts +0 -36
  173. package/src/viewports/index.js +0 -1
  174. package/src/viewports/intersectionViewport.ts +0 -137
  175. package/src/views/index.js +0 -1
  176. package/src/views/intersectionView.ts +0 -38
  177. package/tsconfig.json +0 -7
@@ -1,479 +0,0 @@
1
- import { MeshType, MeshTypeLines } from "./privateMapLayer";
2
- import { Params } from "./mapLayer";
3
-
4
- type Vec = [number, number, number];
5
-
6
- export function makeFullMesh(e: { data: Params }): void {
7
- const params = e.data;
8
-
9
- // Keep
10
- //const t0 = performance.now();
11
-
12
- const meshData = params.meshData;
13
- const propertiesData = params.propertiesData;
14
- const isMesh = params.isMesh;
15
- const frame = params.frame;
16
- const smoothShading = params.smoothShading;
17
-
18
- function getFloat32ArrayMinMax(data: Float32Array) {
19
- let max = -99999999;
20
- let min = 99999999;
21
- for (let i = 0; i < data.length; i++) {
22
- max = data[i] > max ? data[i] : max;
23
- min = data[i] < min ? data[i] : min;
24
- }
25
- return [min, max];
26
- }
27
-
28
- function crossProduct(a: Vec, b: Vec): Vec {
29
- const c = [
30
- a[1] * b[2] - a[2] * b[1],
31
- a[2] * b[0] - a[0] * b[2],
32
- a[0] * b[1] - a[1] * b[0],
33
- ];
34
- return c as Vec;
35
- }
36
-
37
- function normalize(a: Vec): void {
38
- const L = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
39
- a[0] /= L;
40
- a[1] /= L;
41
- a[2] /= L;
42
- }
43
-
44
- function calcNormal(
45
- w: number,
46
- h: number,
47
- nx: number,
48
- ny: number,
49
- isMesh: boolean,
50
- smoothShading: boolean,
51
- meshData: Float32Array,
52
- ox: number,
53
- oy: number
54
- ) {
55
- if (!smoothShading) {
56
- return [1, 1, 1];
57
- }
58
-
59
- if (!isMesh) {
60
- return [0, 0, 1];
61
- }
62
-
63
- const i0 = h * nx + w;
64
- const i1 = h * nx + (w - 1);
65
- const i2 = (h + 1) * nx + w;
66
- const i3 = h * nx + (w + 1);
67
- const i4 = (h - 1) * nx + w;
68
-
69
- const i0_act = !isNaN(meshData[i0]); // eslint-disable-line
70
- const i1_act = (w - 1) >= 0 && !isNaN(meshData[i1]); // eslint-disable-line
71
- const i2_act = (h + 1) < ny && !isNaN(meshData[i2]); // eslint-disable-line
72
- const i3_act = (w + 1) < nx && !isNaN(meshData[i3]); // eslint-disable-line
73
- const i4_act = (h - 1) >= 0 && !isNaN(meshData[i4]); // eslint-disable-line
74
-
75
- const noNormal = [0, 0, 1]; // signals a normal could not be calculated.
76
- if (!i0_act) {
77
- return noNormal;
78
- }
79
-
80
- const hh = ny - 1 - h; // Note use hh for h for getting y values.
81
- const p0 = [ox + w * dx, oy + hh * dy, i0_act ? -meshData[i0] : 0]; // eslint-disable-line
82
- const p1 = [ ox + (w - 1) * dx, oy + hh * dy, i1_act ? -meshData[i1] : 0]; // eslint-disable-line
83
- const p2 = [ ox + w * dx, oy + (hh + 1) * dy, i2_act ? -meshData[i2] : 0]; // eslint-disable-line
84
- const p3 = [ ox + (w + 1) * dx, oy + hh * dy, i3_act ? -meshData[i3] : 0]; // eslint-disable-line
85
- const p4 = [ ox + w * dx, oy + (hh - 1) * dy, i4_act ? -meshData[i4] : 0]; // eslint-disable-line
86
-
87
- const v1 = [p1[0] - p0[0], p1[1] - p0[1], p1[2] - p0[2]] as Vec;
88
- const v2 = [p2[0] - p0[0], p2[1] - p0[1], p2[2] - p0[2]] as Vec;
89
- const v3 = [p3[0] - p0[0], p3[1] - p0[1], p3[2] - p0[2]] as Vec;
90
- const v4 = [p4[0] - p0[0], p4[1] - p0[1], p4[2] - p0[2]] as Vec;
91
-
92
- // Estimating a normal vector at p0:
93
- // Take cross product of vectors v1, v2,
94
- // Do this for all 4 quadrants.
95
- // The resulting normal will be the mean of these four normals.
96
- // p2
97
- // |
98
- // p1 - p0 - p3
99
- // |
100
- // p4
101
-
102
- const normals: Vec[] = [];
103
- if (i1_act && i2_act) {
104
- const normal = crossProduct(v2, v1);
105
- normals.push(normal);
106
- }
107
-
108
- if (i2_act && i3_act) {
109
- const normal = crossProduct(v3, v2);
110
- normals.push(normal);
111
- }
112
-
113
- if (i3_act && i4_act) {
114
- const normal = crossProduct(v4, v3);
115
- normals.push(normal);
116
- }
117
-
118
- if (i4_act && i1_act) {
119
- const normal = crossProduct(v1, v4);
120
- normals.push(normal);
121
- }
122
-
123
- if (normals.length === 0) {
124
- return noNormal;
125
- }
126
-
127
- const mean = normals[0];
128
- for (let i = 1; i < normals.length; i++) {
129
- mean[0] += normals[i][0];
130
- mean[1] += normals[i][1];
131
- mean[2] += normals[i][2];
132
- }
133
-
134
- normalize(mean);
135
- return mean;
136
- }
137
-
138
- const meshZValueRange = getFloat32ArrayMinMax(meshData);
139
- const propertyValueRange = getFloat32ArrayMinMax(propertiesData);
140
-
141
- // Dimensions.
142
- const ox = frame.origin[0];
143
- const oy = frame.origin[1];
144
-
145
- const dx = frame.increment[0];
146
- const dy = frame.increment[1];
147
-
148
- const nx = frame.count[0];
149
- const ny = frame.count[1];
150
-
151
- const propLength = propertiesData.length;
152
- const isCellCenteredProperties = propLength === (nx - 1) * (ny - 1);
153
-
154
- if (propLength !== (nx - 1) * (ny - 1) && propLength !== nx * ny) {
155
- console.error(
156
- "There should be as many property values as nodes (nx*ny) OR as many as cells (nx - 1) * (ny - 1)."
157
- );
158
- }
159
-
160
- const positions: number[] = [];
161
- const normals: number[] = [];
162
- const indices: number[] = [];
163
- const vertexProperties: number[] = [];
164
- const vertexIndexs: number[] = [];
165
- const line_positions: number[] = [];
166
-
167
- // Note: Assumed layout of the incomming 2D array of data:
168
- // First coloumn corresponds to lowest x value. Last column highest x value.
169
- // First row corresponds to max y value. Last row corresponds to lowest y value.
170
- // This must be taken into account when calculating vertex x,y values and texture coordinates.
171
-
172
- if (!isCellCenteredProperties) {
173
- // PROPERTIES IS SET INTERPOLATED OVER A CELL.
174
- let i = 0;
175
- // Loop over nodes.
176
- for (let h = 0; h < ny; h++) {
177
- for (let w = 0; w < nx; w++) {
178
- const i0 = h * nx + w;
179
-
180
- const x0 = ox + w * dx;
181
- const y0 = oy + (ny - 1 - h) * dy; // See note above.
182
- const z = isMesh ? -meshData[i0] : 0;
183
-
184
- const propertyValue = propertiesData[i0];
185
-
186
- positions.push(x0, y0, z);
187
-
188
- const normal = calcNormal(w, h, nx, ny, isMesh, smoothShading, meshData, ox, oy); // eslint-disable-line
189
- normals.push(normal[0], normal[1], normal[2]);
190
-
191
- vertexProperties.push(propertyValue);
192
- vertexIndexs.push(i++);
193
- }
194
- }
195
-
196
- for (let h = 0; h < ny - 1; h++) {
197
- for (let w = 0; w < nx - 1; w++) {
198
- const i0 = h * nx + w;
199
- const i1 = h * nx + (w + 1);
200
- const i2 = (h + 1) * nx + (w + 1);
201
- const i3 = (h + 1) * nx + w;
202
-
203
- const i0_act = !isMesh || (!isNaN(meshData[i0]) && !isNaN(propertiesData[i0])); // eslint-disable-line
204
- const i1_act = !isMesh || (!isNaN(meshData[i1]) && !isNaN(propertiesData[i1])); // eslint-disable-line
205
- const i2_act = !isMesh || (!isNaN(meshData[i2]) && !isNaN(propertiesData[i2])); // eslint-disable-line
206
- const i3_act = !isMesh || (!isNaN(meshData[i3]) && !isNaN(propertiesData[i3])); // eslint-disable-line
207
-
208
- const hh = ny - h - 1; // See note above.
209
-
210
- const x0 = ox + w * dx;
211
- const y0 = oy + hh * dy;
212
- const z0 = isMesh ? -meshData[i0] : 0;
213
-
214
- const x1 = ox + (w + 1) * dx;
215
- const y1 = oy + hh * dy;
216
- const z1 = isMesh ? -meshData[i1] : 0;
217
-
218
- const x2 = ox + (w + 1) * dx;
219
- const y2 = oy + (hh - 1) * dy;
220
- const z2 = isMesh ? -meshData[i2] : 0;
221
-
222
- const x3 = ox + w * dx;
223
- const y3 = oy + (hh - 1) * dy;
224
- const z3 = isMesh ? -meshData[i3] : 0;
225
-
226
- if (i1_act && i3_act) {
227
- // diagonal i1, i3
228
- if (i0_act) {
229
- indices.push(i1, i3, i0); // t1 - i0 provoking index.
230
-
231
- line_positions.push(x0, y0, z0);
232
- line_positions.push(x3, y3, z3);
233
-
234
- line_positions.push(x0, y0, z0);
235
- line_positions.push(x1, y1, z1);
236
- }
237
-
238
- if (i2_act) {
239
- indices.push(i1, i3, i2); // t2 - i2 provoking index.
240
-
241
- line_positions.push(x2, y2, z2);
242
- line_positions.push(x3, y3, z3);
243
-
244
- line_positions.push(x2, y2, z2);
245
- line_positions.push(x1, y1, z1);
246
- }
247
-
248
- // diagonal
249
- if ((i0_act && !i2_act) || (!i0_act && i2_act)) {
250
- line_positions.push(x1, y1, z1);
251
- line_positions.push(x3, y3, z3);
252
- }
253
- } else if (i0_act && i2_act) {
254
- // diagonal i0, i2
255
- if (i1_act) {
256
- indices.push(i1, i2, i0); // t1 - i0 provoking index.
257
- }
258
-
259
- if (i3_act) {
260
- indices.push(i3, i0, i2); // t2 - i2 provoking index.
261
- }
262
-
263
- // diagonal
264
- if ((i3_act && !i1_act) || (!i3_act && i1_act)) {
265
- line_positions.push(x0, y0, z0);
266
- line_positions.push(x2, y2, z2);
267
- }
268
- }
269
- }
270
- }
271
- } else {
272
- // PROPERTIES IS SET CONSTANT OVER A CELL.
273
- let i_indices = 0;
274
- let i_vertices = 0;
275
- // Loop over cells.
276
- for (let h = 0; h < ny - 1; h++) {
277
- for (let w = 0; w < nx - 1; w++) {
278
- const hh = ny - 1 - h; // See note above.
279
-
280
- const i0 = h * nx + w;
281
- const i1 = h * nx + (w + 1);
282
- const i2 = (h + 1) * nx + (w + 1);
283
- const i3 = (h + 1) * nx + w;
284
-
285
- const normal0 = calcNormal(w, h, nx, ny, isMesh, smoothShading, meshData, ox, oy); // eslint-disable-line
286
- const normal1 = calcNormal(w + 1, h, nx, ny, isMesh, smoothShading, meshData, ox, oy); // eslint-disable-line
287
- const normal2 = calcNormal(w + 1, h + 1, nx, ny, isMesh, smoothShading, meshData, ox, oy); // eslint-disable-line
288
- const normal3 = calcNormal(w, h + 1, nx, ny, isMesh, smoothShading, meshData, ox, oy); // eslint-disable-line
289
-
290
- const i0_act = !isMesh || !isNaN(meshData[i0]); // eslint-disable-line
291
- const i1_act = !isMesh || !isNaN(meshData[i1]); // eslint-disable-line
292
- const i2_act = !isMesh || !isNaN(meshData[i2]); // eslint-disable-line
293
- const i3_act = !isMesh || !isNaN(meshData[i3]); // eslint-disable-line
294
-
295
- const x0 = ox + w * dx;
296
- const y0 = oy + hh * dy;
297
- const z0 = isMesh ? -meshData[i0] : 0;
298
-
299
- const x1 = ox + (w + 1) * dx;
300
- const y1 = oy + hh * dy;
301
- const z1 = isMesh ? -meshData[i1] : 0;
302
-
303
- const x2 = ox + (w + 1) * dx;
304
- const y2 = oy + (hh - 1) * dy; // Note hh - 1 here.
305
- const z2 = isMesh ? -meshData[i2] : 0;
306
-
307
- const x3 = ox + w * dx;
308
- const y3 = oy + (hh - 1) * dy; // Note hh - 1 here.
309
- const z3 = isMesh ? -meshData[i3] : 0;
310
-
311
- const propertyIndex = h * (nx - 1) + w; // (nx - 1) -> the width of the property 2D array is one less than for the nodes in this case.
312
- const propertyValue = propertiesData[propertyIndex];
313
-
314
- if (isNaN(propertyValue)) {
315
- // Inactive cell, dont draw.
316
- continue;
317
- }
318
-
319
- if (i1_act && i3_act) {
320
- // diagonal i1, i3
321
- if (i0_act) {
322
- // t1 - i0 provoking index.
323
- positions.push(x1, y1, z1);
324
- positions.push(x3, y3, z3);
325
- positions.push(x0, y0, z0);
326
-
327
- normals.push(normal1[0], normal1[1], normal1[2]);
328
- normals.push(normal3[0], normal3[1], normal3[2]);
329
- normals.push(normal0[0], normal0[1], normal0[2]);
330
-
331
- vertexIndexs.push(
332
- i_vertices++,
333
- i_vertices++,
334
- i_vertices++
335
- );
336
-
337
- indices.push(i_indices++, i_indices++, i_indices++);
338
- vertexProperties.push(propertyValue);
339
- vertexProperties.push(propertyValue);
340
- vertexProperties.push(propertyValue);
341
-
342
- line_positions.push(x0, y0, z0);
343
- line_positions.push(x3, y3, z3);
344
-
345
- line_positions.push(x0, y0, z0);
346
- line_positions.push(x1, y1, z1);
347
- }
348
-
349
- if (i2_act) {
350
- // t2 - i2 provoking index.
351
- positions.push(x1, y1, z1);
352
- positions.push(x3, y3, z3);
353
- positions.push(x2, y2, z2);
354
-
355
- normals.push(normal1[0], normal1[1], normal1[2]);
356
- normals.push(normal3[0], normal3[1], normal3[2]);
357
- normals.push(normal2[0], normal2[1], normal2[2]);
358
-
359
- vertexIndexs.push(
360
- i_vertices++,
361
- i_vertices++,
362
- i_vertices++
363
- );
364
-
365
- indices.push(i_indices++, i_indices++, i_indices++);
366
- vertexProperties.push(propertyValue);
367
- vertexProperties.push(propertyValue);
368
- vertexProperties.push(propertyValue);
369
-
370
- line_positions.push(x2, y2, z2);
371
- line_positions.push(x3, y3, z3);
372
-
373
- line_positions.push(x2, y2, z2);
374
- line_positions.push(x1, y1, z1);
375
- }
376
-
377
- // diagonal
378
- if ((i0_act && !i2_act) || (!i0_act && i2_act)) {
379
- line_positions.push(x1, y1, z1);
380
- line_positions.push(x3, y3, z3);
381
- }
382
- } else if (i0_act && i2_act) {
383
- // diagonal i0, i2
384
- if (i1_act) {
385
- // t1 - i0 provoking index.
386
- positions.push(x1, y1, z1);
387
- positions.push(x2, y2, z2);
388
- positions.push(x0, y0, z0);
389
-
390
- normals.push(normal1[0], normal1[1], normal1[2]);
391
- normals.push(normal2[0], normal2[1], normal2[2]);
392
- normals.push(normal0[0], normal0[1], normal0[2]);
393
-
394
- vertexIndexs.push(
395
- i_vertices++,
396
- i_vertices++,
397
- i_vertices++
398
- );
399
-
400
- indices.push(i_indices++, i_indices++, i_indices++);
401
- vertexProperties.push(propertyValue);
402
- vertexProperties.push(propertyValue);
403
- vertexProperties.push(propertyValue);
404
-
405
- line_positions.push(x1, y1, z1);
406
- line_positions.push(x0, y0, z0);
407
-
408
- line_positions.push(x1, y1, z1);
409
- line_positions.push(x2, y2, z2);
410
- }
411
-
412
- if (i3_act) {
413
- // t2 - i2 provoking index.
414
- positions.push(x0, y0, z0);
415
- positions.push(x3, y3, z3);
416
- positions.push(x2, y2, z2);
417
-
418
- normals.push(normal0[0], normal0[1], normal0[2]);
419
- normals.push(normal3[0], normal3[1], normal3[2]);
420
- normals.push(normal2[0], normal2[1], normal2[2]);
421
-
422
- vertexIndexs.push(
423
- i_vertices++,
424
- i_vertices++,
425
- i_vertices++
426
- );
427
-
428
- indices.push(i_indices++, i_indices++, i_indices++);
429
- vertexProperties.push(propertyValue);
430
- vertexProperties.push(propertyValue);
431
- vertexProperties.push(propertyValue);
432
-
433
- line_positions.push(x3, y3, z3);
434
- line_positions.push(x0, y0, z0);
435
-
436
- line_positions.push(x3, y3, z3);
437
- line_positions.push(x2, y2, z2);
438
- }
439
-
440
- // diagonal
441
- if ((i3_act && !i1_act) || (!i3_act && i1_act)) {
442
- line_positions.push(x0, y0, z0);
443
- line_positions.push(x2, y2, z2);
444
- }
445
- }
446
- }
447
- }
448
- }
449
-
450
- const mesh: MeshType = {
451
- drawMode: 4, // corresponds to GL.TRIANGLES,
452
- attributes: {
453
- positions: { value: new Float32Array(positions), size: 3 },
454
- normals: { value: new Float32Array(normals), size: 3 },
455
- properties: { value: new Float32Array(vertexProperties), size: 1 },
456
- vertex_indexs: { value: new Int32Array(vertexIndexs), size: 1 },
457
- },
458
- vertexCount: indices.length,
459
- indices: { value: new Uint32Array(indices), size: 1 },
460
- };
461
-
462
- const mesh_lines: MeshTypeLines = {
463
- drawMode: 1, // corresponds to GL.LINES,
464
- attributes: {
465
- positions: { value: new Float32Array(line_positions), size: 3 },
466
- },
467
- vertexCount: line_positions.length / 3,
468
- };
469
-
470
- //const t1 = performance.now();
471
- // Keep this.
472
- //console.log(`Task makeMesh took ${(t1 - t0) * 0.001} seconds.`);
473
-
474
- // Note: typescript gives this error "error TS2554: Expected 2-3 arguments, but got 1."
475
- // Disabling this for now as the second argument should be optional.
476
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
477
- // @ts-ignore
478
- postMessage([mesh, mesh_lines, meshZValueRange, propertyValueRange]);
479
- }
@@ -1,108 +0,0 @@
1
- import React from "react";
2
- import SubsurfaceViewer from "../../SubsurfaceViewer";
3
- import { ComponentStory, ComponentMeta } from "@storybook/react";
4
-
5
- export default {
6
- component: SubsurfaceViewer,
7
- title: "SubsurfaceViewer / North Arrow Layer",
8
- } as ComponentMeta<typeof SubsurfaceViewer>;
9
-
10
- type NumberQuad = [number, number, number, number];
11
-
12
- const white = [255, 255, 255, 255];
13
-
14
- const axes = {
15
- "@@type": "AxesLayer",
16
- id: "axes-layer2",
17
- bounds: [432150, 6475800, 0, 439400, 6481500, 100],
18
- };
19
-
20
- const north_arrow_layer = {
21
- "@@type": "NorthArrow3DLayer",
22
- id: "north-arrow-layer",
23
- };
24
-
25
- const defaultParameters = {
26
- docs: {
27
- inlineStories: false,
28
- iframeHeight: 500,
29
- },
30
- };
31
-
32
- const defaultArgs = {
33
- id: "map",
34
- bounds: [432150, 6475800, 439400, 6481500] as NumberQuad,
35
- layers: [axes, north_arrow_layer],
36
- views: {
37
- layout: [1, 1] as [number, number],
38
- viewports: [
39
- {
40
- id: "view_1",
41
- show3D: true,
42
- },
43
- ],
44
- },
45
- };
46
-
47
- export const NorthArrow3d: ComponentStory<typeof SubsurfaceViewer> = (args) => {
48
- return <SubsurfaceViewer {...args} />;
49
- };
50
-
51
- NorthArrow3d.args = {
52
- ...defaultArgs,
53
- views: {
54
- layout: [1, 1],
55
- viewports: [
56
- {
57
- id: "view_1",
58
- show3D: true,
59
- },
60
- ],
61
- },
62
- };
63
-
64
- NorthArrow3d.parameters = {
65
- docs: {
66
- ...defaultParameters.docs,
67
- description: {
68
- story: "Example using north arrow in 3D.",
69
- },
70
- },
71
- };
72
-
73
- export const NorthArrow2dDarkMode: ComponentStory<typeof SubsurfaceViewer> = (
74
- args
75
- ) => {
76
- return <SubsurfaceViewer {...args} />;
77
- };
78
-
79
- NorthArrow2dDarkMode.args = {
80
- ...defaultArgs,
81
- layers: [
82
- { ...axes, labelColor: white, axisColor: white },
83
- { ...north_arrow_layer, color: white },
84
- ],
85
- views: {
86
- layout: [1, 1],
87
- viewports: [
88
- {
89
- id: "view_1",
90
- show3D: false,
91
- },
92
- ],
93
- },
94
- scale: {
95
- visible: true,
96
- cssStyle: { color: "white" },
97
- },
98
- };
99
-
100
- NorthArrow2dDarkMode.parameters = {
101
- docs: {
102
- ...defaultParameters.docs,
103
- description: {
104
- story: "Example using north arrow in 2D Dark Mode.",
105
- },
106
- },
107
- backgrounds: { default: "dark" },
108
- };