@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,334 +0,0 @@
1
- import {
2
- SimpleMeshLayer,
3
- SimpleMeshLayerProps,
4
- } from "@deck.gl/mesh-layers/typed";
5
- import { COORDINATE_SYSTEM } from "@deck.gl/core/typed";
6
- import { Color, PickingInfo } from "@deck.gl/core/typed";
7
- import fsShader from "./terrainmap.fs.glsl";
8
- import GL from "@luma.gl/constants";
9
- import { Texture2D } from "@luma.gl/webgl";
10
- import { DeckGLLayerContext } from "../../components/Map";
11
- import { colorTablesArray, rgbValues } from "@emerson-eps/color-tables/";
12
- import { createDefaultContinuousColorScale } from "@emerson-eps/color-tables/dist/component/Utils/legendCommonFunction";
13
- import {
14
- createPropertyData,
15
- PropertyDataType,
16
- colorMapFunctionType,
17
- } from "../utils/layerTools";
18
-
19
- const DEFAULT_TEXTURE_PARAMETERS = {
20
- [GL.TEXTURE_MIN_FILTER]: GL.LINEAR_MIPMAP_LINEAR,
21
- [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
22
- [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
23
- [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE,
24
- };
25
-
26
- export type Material =
27
- | {
28
- ambient: number;
29
- diffuse: number;
30
- shininess: number;
31
- specularColor: [number, number, number];
32
- }
33
- | boolean;
34
-
35
- export const DECODER = {
36
- rScaler: 256 * 256,
37
- gScaler: 256,
38
- bScaler: 1,
39
- offset: 0,
40
- };
41
-
42
- function getImageData(
43
- colorMapName: string,
44
- colorTables: colorTablesArray,
45
- colorMapFunction: colorMapFunctionType | undefined
46
- ) {
47
- const isColorMapFunctionDefined = typeof colorMapFunction !== "undefined";
48
- const isColorMapNameDefined = !!colorMapName;
49
-
50
- const data = new Uint8Array(256 * 3);
51
-
52
- const defaultColorMap = createDefaultContinuousColorScale;
53
-
54
- const colorMap = isColorMapFunctionDefined
55
- ? colorMapFunction
56
- : isColorMapNameDefined
57
- ? (value: number) => rgbValues(value, colorMapName, colorTables)
58
- : defaultColorMap();
59
-
60
- for (let i = 0; i < 256; i++) {
61
- const value = i / 255.0;
62
- const color = colorMap ? colorMap(value) : [0, 0, 0];
63
- if (color) {
64
- data[3 * i + 0] = color[0];
65
- data[3 * i + 1] = color[1];
66
- data[3 * i + 2] = color[2];
67
- }
68
- }
69
-
70
- return data ? data : [0, 0, 0];
71
- }
72
-
73
- export type DataItem = {
74
- position: [number, number];
75
- angle: number;
76
- color: [number, number, number];
77
- };
78
-
79
- export type TerrainMapLayerData = [DataItem?];
80
-
81
- export interface TerrainMapLayerProps<D> extends SimpleMeshLayerProps<D> {
82
- // texture as ImageData.
83
- textureImageData: ImageData;
84
-
85
- // mesh as ImageData.
86
- meshImageData: ImageData;
87
-
88
- // Min and max of map height values values.
89
- meshValueRange: [number, number];
90
-
91
- // Contourlines reference point and interval.
92
- contours: [number, number];
93
-
94
- // Contourlines may be calculated either on depth/z-value or on property/texture value
95
- isContoursDepth: boolean;
96
-
97
- // Name of color map.
98
- colorMapName: string;
99
-
100
- // Optional function property.
101
- // If defined this function will override the color map.
102
- // Takes a value in the range [0,1] and returns a color.
103
- colorMapFunction?: colorMapFunctionType;
104
-
105
- // Min and max property values.
106
- propertyValueRange: [number, number];
107
-
108
- // Use color map in this range.
109
- colorMapRange: [number, number];
110
-
111
- // Clamp colormap to this color at ends.
112
- // Given as array of three values (r,g,b) e.g: [255, 0, 0]
113
- // If not set or set to true, it will clamp to color map min and max values.
114
- // If set to false the clamp color will be completely transparent.
115
- colorMapClampColor: Color | undefined | boolean;
116
-
117
- depthTest: boolean;
118
- }
119
-
120
- const defaultProps = {
121
- data: [{ position: [0, 0], angle: 0, color: [255, 0, 0, 0] }], // dummy data
122
-
123
- getPosition: (d: DataItem) => d.position,
124
- getColor: (d: DataItem) => d.color,
125
- getOrientation: (d: DataItem): [number, number, number] => [0, d.angle, 0],
126
- contours: [-1, -1],
127
- colorMapName: "",
128
- propertyValueRange: [0.0, 1.0],
129
- isContoursDepth: true,
130
- coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
131
- textureImageData: { value: null, type: "object", async: true },
132
- meshImageData: { value: null, type: "object", async: true },
133
- meshValueRange: [0.0, 1.0],
134
- depthTest: true,
135
- };
136
-
137
- // This is a private layer used only by the composite Map3DLayer.
138
- // It is an extension of SimpleMeshLayer but with modified fragment shader
139
- // so that the texture pixel values can be used as lookup in a supplied color map.
140
- export default class TerrainMapLayer extends SimpleMeshLayer<
141
- TerrainMapLayerData,
142
- TerrainMapLayerProps<TerrainMapLayerData>
143
- > {
144
- properties?: PropertyDataType[];
145
- // Signature from the base class, eslint doesn't like the any type.
146
- // eslint-disable-next-line
147
- draw({ uniforms, context }: any): void {
148
- const { gl } = context;
149
-
150
- const contourReferencePoint = this.props.contours[0] ?? -1.0;
151
- const contourInterval = this.props.contours[1] ?? -1.0;
152
- const isContoursDepth = this.props.isContoursDepth;
153
-
154
- const valueRangeMin = this.props.propertyValueRange[0] ?? 0.0;
155
- const valueRangeMax = this.props.propertyValueRange[1] ?? 1.0;
156
-
157
- // If specified color map will extend from colorMapRangeMin to colorMapRangeMax.
158
- // Otherwise it will extend from valueRangeMin to valueRangeMax.
159
- const colorMapRangeMin = this.props.colorMapRange?.[0] ?? valueRangeMin;
160
- const colorMapRangeMax = this.props.colorMapRange?.[1] ?? valueRangeMax;
161
-
162
- const isClampColor: boolean =
163
- this.props.colorMapClampColor !== undefined &&
164
- this.props.colorMapClampColor !== true &&
165
- this.props.colorMapClampColor !== false;
166
- let colorMapClampColor = isClampColor
167
- ? this.props.colorMapClampColor
168
- : [0, 0, 0];
169
-
170
- // Normalize to [0,1] range.
171
- colorMapClampColor = (colorMapClampColor as Color).map(
172
- (x) => (x ?? 0) / 255
173
- );
174
-
175
- const isColorMapClampColorTransparent: boolean =
176
- (this.props.colorMapClampColor as boolean) === false;
177
-
178
- if (!this.props.depthTest) {
179
- gl.disable(GL.DEPTH_TEST);
180
- }
181
-
182
- super.draw({
183
- uniforms: {
184
- ...uniforms,
185
- colormap: new Texture2D(context.gl, {
186
- width: 256,
187
- height: 1,
188
- format: GL.RGB,
189
- data: getImageData(
190
- this.props.colorMapName,
191
- (this.context as DeckGLLayerContext).userData
192
- .colorTables,
193
- this.props.colorMapFunction
194
- ),
195
- parameters: DEFAULT_TEXTURE_PARAMETERS,
196
- }),
197
- valueRangeMin,
198
- valueRangeMax,
199
- colorMapRangeMin,
200
- colorMapRangeMax,
201
- contourReferencePoint,
202
- contourInterval,
203
- isContoursDepth,
204
- colorMapClampColor,
205
- isColorMapClampColorTransparent,
206
- isClampColor,
207
- },
208
- });
209
-
210
- if (!this.props.depthTest) {
211
- gl.enable(GL.DEPTH_TEST);
212
- }
213
- }
214
-
215
- getShaders(): unknown {
216
- const parentShaders = super.getShaders();
217
- // Overwrite the default fragment shader with ours.
218
- parentShaders.fs = fsShader;
219
-
220
- return {
221
- ...parentShaders,
222
-
223
- // Inject this into vertex shader. Vi want to export vertex world position to
224
- // fragment shader for making contour lines.
225
- inject: {
226
- "vs:#decl": `
227
- out vec3 worldPos;
228
- `,
229
-
230
- "vs:#main-start": `
231
- worldPos = positions;
232
- `,
233
- },
234
- };
235
- }
236
-
237
- decodePickingColor(): number {
238
- return 0;
239
- }
240
-
241
- getPickingInfo({ info }: { info: PickingInfo }): PickingInfo & {
242
- properties?: PropertyDataType[];
243
- } {
244
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
245
- const pickColor = info.color as Color;
246
- if (!pickColor) {
247
- return info;
248
- }
249
-
250
- // Texture coordinates.
251
- const s = pickColor[0] / 255.0;
252
- const t = pickColor[1] / 255.0;
253
-
254
- const is_outside: boolean = pickColor[2] == 0;
255
- if (is_outside) {
256
- // Mouse is outside the non-transparent part of the map.
257
- return info;
258
- }
259
-
260
- // MESH HEIGHT VALUE.
261
- const meshImageData: ImageData = this.props.meshImageData;
262
- const isMeshImageData = meshImageData !== null;
263
- const value_mesh = isMeshImageData
264
- ? getValue(meshImageData, s, t, DECODER)
265
- : 0;
266
-
267
- // TEXTURE PROPERTY VALUE.
268
- const textureImageData: ImageData = this.props.textureImageData;
269
- const value_property = getValue(textureImageData, s, t, DECODER);
270
-
271
- const layer_properties: PropertyDataType[] = [];
272
- layer_properties.push(
273
- getMapProperty(
274
- "Property",
275
- value_property,
276
- this.props.propertyValueRange
277
- ),
278
- isMeshImageData
279
- ? getMapProperty("Depth", value_mesh, this.props.meshValueRange)
280
- : { name: "Depth", value: 0 }
281
- );
282
-
283
- return {
284
- ...info,
285
- properties: layer_properties,
286
- };
287
- }
288
- }
289
-
290
- TerrainMapLayer.layerName = "TerrainMapLayer";
291
- TerrainMapLayer.defaultProps = defaultProps;
292
-
293
- //================= Local help functions. ==================
294
-
295
- function getMapProperty(
296
- name: string,
297
- value: number,
298
- value_range: [number, number]
299
- ): PropertyDataType {
300
- // Remap the [0, 1] decoded value to property value range.
301
- const [min, max] = value_range;
302
-
303
- const floatScaler = 1.0 / (256.0 * 256.0 * 256.0 - 1.0);
304
- const scaled_value = value * floatScaler;
305
-
306
- value = scaled_value * (max - min) + min;
307
- return createPropertyData(name, value);
308
- }
309
-
310
- function getValue(
311
- imageData: ImageData,
312
- s: number,
313
- t: number,
314
- decoder: { rScaler: number; gScaler: number; bScaler: number }
315
- ): number {
316
- const int_view = new Uint8ClampedArray(
317
- imageData.data,
318
- 0,
319
- imageData.data.length
320
- );
321
-
322
- const w = imageData.width;
323
- const h = imageData.height;
324
- const j = Math.min(Math.floor(w * s), w - 1);
325
- const i = Math.min(Math.floor(h * t), h - 1);
326
-
327
- const pixelNo = i * w + j;
328
- const r = int_view[pixelNo * 4 + 0] * decoder.rScaler;
329
- const g = int_view[pixelNo * 4 + 1] * decoder.gScaler;
330
- const b = int_view[pixelNo * 4 + 2] * decoder.bScaler;
331
- const value = r + g + b;
332
-
333
- return value;
334
- }
@@ -1,134 +0,0 @@
1
- const fsShader = `#version 300 es
2
- #define SHADER_NAME terrainmap-shader
3
-
4
- precision highp float;
5
-
6
- uniform bool hasTexture;
7
- uniform sampler2D sampler;
8
- uniform bool flatShading;
9
- uniform float opacity;
10
-
11
- uniform bool isContoursDepth;
12
-
13
- uniform float contourReferencePoint;
14
- uniform float contourInterval;
15
-
16
- in vec2 vTexCoord;
17
- in vec3 cameraPosition;
18
- in vec3 normals_commonspace;
19
- in vec4 position_commonspace;
20
- in vec4 vColor;
21
- in vec4 positions;
22
-
23
- out vec4 fragColor;
24
-
25
- in vec3 worldPos; // we export this from vertex shader (by injecting into it).
26
-
27
- uniform sampler2D colormap;
28
-
29
- uniform float valueRangeMin;
30
- uniform float valueRangeMax;
31
- uniform float colorMapRangeMin;
32
- uniform float colorMapRangeMax;
33
-
34
- uniform vec3 colorMapClampColor;
35
- uniform bool isClampColor;
36
- uniform bool isColorMapClampColorTransparent;
37
-
38
-
39
- void main(void) {
40
- geometry.uv = vTexCoord;
41
-
42
- vec3 normal;
43
- if (flatShading) {
44
- #ifdef DERIVATIVES_AVAILABLE
45
- normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
46
- #else
47
- normal = vec3(0.0, 0.0, 1.0);
48
- #endif
49
- } else {
50
- normal = normals_commonspace;
51
- }
52
-
53
- vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;
54
-
55
- float texture_alpha = color.a;
56
-
57
- // Discard transparent pixels.
58
- if (!picking_uActive && color.w < 0.99) {
59
- discard;
60
- return;
61
- }
62
-
63
- // Picking pass.
64
- if (picking_uActive) {
65
- // Send texture coordinates.
66
- float s = vTexCoord.x;
67
- float t = vTexCoord.y;
68
- float b = texture_alpha > 0.95 ? 255.0 : 0.0;
69
-
70
- fragColor = vec4(s, t, b, 1.0);
71
- return;
72
- }
73
-
74
- float propertyValue = 0.0;
75
- if (hasTexture) {
76
- float opcacity = color.w;
77
- float floatScaler = 1.0 / (256.0 * 256.0 * 256.0 - 1.0);
78
- vec3 rgb = color.rgb;
79
- rgb *= vec3(16711680.0, 65280.0, 255.0); //255*256*256, 255*256, 255
80
- float propertyValue_norm = (rgb.r + rgb.g + rgb.b) * floatScaler; // propertyValue_norm will be in range [0-1]
81
-
82
- // If colorMapRangeMin/Max specified, color map will span this interval.
83
- propertyValue = propertyValue_norm * (valueRangeMax - valueRangeMin) + valueRangeMin;
84
- float x = (propertyValue - colorMapRangeMin) / (colorMapRangeMax - colorMapRangeMin);
85
- ;
86
- if (x < 0.0 || x > 1.0) {
87
- // Out of range. Use clampcolor.
88
- if (isClampColor) {
89
- color = vec4(colorMapClampColor.rgb, 1.0);
90
-
91
- }
92
- else if (isColorMapClampColorTransparent) {
93
- discard;
94
- return;
95
- }
96
- else {
97
- // Use min/max color to clamp.
98
- x = max(0.0, x);
99
- x = min(1.0, x);
100
-
101
- color = texture2D(colormap, vec2(x, 0.5));
102
- color.a = opcacity;
103
- }
104
- }
105
- else {
106
- color = texture2D(colormap, vec2(x, 0.5));
107
- color.a = opcacity;
108
- }
109
- }
110
-
111
- bool is_contours = contourReferencePoint != -1.0 && contourInterval != -1.0;
112
- if (is_contours) {
113
- // Contours are made of either depths or properties.
114
- float val = (hasTexture && !isContoursDepth) ? (propertyValue - contourReferencePoint) / contourInterval
115
- : (abs(worldPos.z) - contourReferencePoint) / contourInterval;
116
-
117
- float f = fract(val);
118
- float df = fwidth(val);
119
-
120
- // keep: float c = smoothstep(df * 1.0, df * 2.0, f); // smootstep from/to no of pixels distance fronm contour line.
121
- float c = smoothstep(0.0, df * 2.0, f);
122
-
123
- color = color * vec4(c, c, c, 1.0);
124
- }
125
-
126
- // Use normal lighting.
127
- vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
128
- fragColor = vec4(lightColor, color.a * opacity);
129
-
130
- DECKGL_FILTER_COLOR(fragColor, geometry);
131
- }
132
- `;
133
-
134
- export default fsShader;
@@ -1,126 +0,0 @@
1
- const fsShader = `#version 300 es
2
- #define SHADER_NAME terrainmap-shader
3
-
4
- precision highp float;
5
-
6
- uniform bool isContoursDepth;
7
- uniform float contourReferencePoint;
8
- uniform float contourInterval;
9
-
10
- in vec2 vTexCoord;
11
- in vec3 cameraPosition;
12
- in vec3 normals_commonspace;
13
- in vec4 position_commonspace;
14
- in vec3 worldPos;
15
- in float property;
16
-
17
- out vec4 fragColor;
18
-
19
- uniform sampler2D colormap;
20
- uniform vec4 uColor;
21
- uniform bool smoothShading;
22
-
23
-
24
- vec3 getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {
25
-
26
- vec3 halfway_direction = normalize(light_direction + view_direction);
27
- float lambertian = abs(dot(light_direction, normal_worldspace));
28
-
29
- float specular_angle = abs(dot(normal_worldspace, halfway_direction));
30
-
31
- float specular = pow(specular_angle, lighting_uShininess);
32
- return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;
33
- }
34
-
35
- vec3 getLightColor(vec3 surfaceColor,vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
36
-
37
- vec3 lightColor = surfaceColor;
38
-
39
- if (lighting_uEnabled) {
40
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
41
- lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;
42
-
43
- for (int i = 0; i < MAX_LIGHTS; i++) {
44
- if (i >= lighting_uPointLightCount) {
45
- break;
46
- }
47
- PointLight pointLight = lighting_uPointLight[i];
48
- vec3 light_position_worldspace = pointLight.position;
49
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
50
- lightColor += getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
51
- }
52
-
53
- for (int i = 0; i < MAX_LIGHTS; i++) {
54
- if (i >= lighting_uDirectionalLightCount) {
55
- break;
56
- }
57
- DirectionalLight directionalLight = lighting_uDirectionalLight[i];
58
- lightColor += getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
59
- }
60
- }
61
- return lightColor;
62
- }
63
-
64
- void main(void) {
65
- //geometry.uv = vTexCoord;
66
-
67
- vec3 normal = normals_commonspace;
68
-
69
- if (!smoothShading) {
70
- normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
71
- }
72
-
73
- //Picking pass.
74
- if (picking_uActive) {
75
- // Readout is surface height (z value).
76
- float range = 10000.0; // May represent depths in range 0 - 10000 meter.
77
-
78
- // Express in 255 system.
79
- float depth = abs(worldPos.z);
80
- float depthScaled = (256.0 * 256.0 * 256.0) * (depth / range); // scaled to within max range in 256 system.
81
-
82
- float r = 0.0;
83
- float g = 0.0;
84
- float b = 0.0;
85
-
86
- if (depthScaled >= (256.0 * 256.0) - 1.0) {
87
- r = floor(depthScaled / (256.0 * 256.0));
88
- depthScaled -= r * (256.0 * 256.0);
89
- }
90
-
91
- if (depthScaled >= 256.0 - 1.0) {
92
- g = floor(depthScaled / 256.0);
93
- depthScaled -= g * 256.0;
94
- }
95
-
96
- b = floor(depthScaled);
97
-
98
- fragColor = vec4(r / 255.0, g / 255.0, b / 255.0, 1.0);
99
- return;
100
- }
101
-
102
- vec4 color = uColor;
103
-
104
- bool is_contours = contourReferencePoint != -1.0 && contourInterval != -1.0;
105
- if (is_contours) {
106
- // Contours are made of either depths or properties.
107
- float val = (abs(worldPos.z) - contourReferencePoint) / contourInterval;
108
-
109
- float f = fract(val);
110
- float df = fwidth(val);
111
-
112
- // keep: float c = smoothstep(df * 1.0, df * 2.0, f); // smootstep from/to no of pixels distance fronm contour line.
113
- float c = smoothstep(0.0, df * 2.0, f);
114
-
115
- color = color * vec4(c, c, c, 1.0);
116
- }
117
-
118
- // Use normal lighting. This has no effect if "material" property is not set.
119
- vec3 lightColor = getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
120
- fragColor = vec4(lightColor, 1.0);
121
-
122
- DECKGL_FILTER_COLOR(fragColor, geometry);
123
- }
124
- `;
125
-
126
- export default fsShader;
@@ -1,21 +0,0 @@
1
- const fragmentShader = `\
2
- #version 300 es
3
- #define SHADER_NAME graph-layer-fragment-shader
4
-
5
- precision highp float;
6
-
7
- out vec4 fragColor;
8
-
9
- void main(void) {
10
-
11
- // Picking pass.
12
- if (picking_uActive) {
13
- discard;
14
- return;
15
- }
16
-
17
- fragColor = vec4(0.0, 0.0, 0.0, 1.0);
18
- }
19
- `;
20
-
21
- export default fragmentShader;