@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,292 +0,0 @@
1
- import {
2
- COORDINATE_SYSTEM,
3
- Layer,
4
- picking,
5
- project,
6
- phongLighting,
7
- PickingInfo,
8
- UpdateParameters,
9
- Color,
10
- } from "@deck.gl/core/typed";
11
- import {
12
- createPropertyData,
13
- LayerPickInfo,
14
- PropertyDataType,
15
- } from "../utils/layerTools";
16
- import { Model, Geometry } from "@luma.gl/engine";
17
- import { DeckGLLayerContext } from "../../components/Map";
18
- import { ExtendedLayerProps, colorMapFunctionType } from "../utils/layerTools";
19
- import vsShader from "./vertex.glsl";
20
- import fsShader from "./fragment.fs.glsl";
21
- import vsLineShader from "./vertex_lines.glsl";
22
- import fsLineShader from "./fragment_lines.glsl";
23
-
24
- import { colorTablesArray, rgbValues } from "@emerson-eps/color-tables/";
25
- import { createDefaultContinuousColorScale } from "@emerson-eps/color-tables/dist/component/Utils/legendCommonFunction";
26
- import { Texture2D } from "@luma.gl/webgl";
27
- import GL from "@luma.gl/constants";
28
-
29
- const DEFAULT_TEXTURE_PARAMETERS = {
30
- [GL.TEXTURE_MIN_FILTER]: GL.LINEAR_MIPMAP_LINEAR,
31
- [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
32
- [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
33
- [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE,
34
- };
35
-
36
- export type MeshType = {
37
- drawMode?: number;
38
- attributes: {
39
- positions: { value: Float32Array; size: number };
40
- TEXCOORD_0?: { value: Float32Array; size: number };
41
- normals?: { value: Float32Array; size: number };
42
- properties: { value: Float32Array; size: number };
43
- vertex_indexs: { value: Int32Array; size: number };
44
- };
45
- vertexCount: number;
46
- indices: { value: Uint32Array; size: number };
47
- };
48
-
49
- export type MeshTypeLines = {
50
- drawMode: number;
51
- attributes: {
52
- positions: { value: Float32Array; size: number };
53
- };
54
- vertexCount: number;
55
- };
56
-
57
- export type Material =
58
- | {
59
- ambient: number;
60
- diffuse: number;
61
- shininess: number;
62
- specularColor: [number, number, number];
63
- }
64
- | boolean;
65
-
66
- function getImageData(
67
- colorMapName: string,
68
- colorTables: colorTablesArray,
69
- colorMapFunction: colorMapFunctionType | false | undefined
70
- ) {
71
- const isColorMapFunctionDefined = typeof colorMapFunction === "function";
72
- const isColorMapNameDefined = !!colorMapName;
73
-
74
- const data = new Uint8Array(256 * 3);
75
-
76
- const defaultColorMap = createDefaultContinuousColorScale;
77
-
78
- const colorMap = isColorMapFunctionDefined
79
- ? colorMapFunction
80
- : isColorMapNameDefined
81
- ? (value: number) => rgbValues(value, colorMapName, colorTables)
82
- : defaultColorMap();
83
-
84
- for (let i = 0; i < 256; i++) {
85
- const value = i / 255.0;
86
- const color = colorMap ? colorMap(value) : [0, 0, 0];
87
- if (color) {
88
- data[3 * i + 0] = color[0];
89
- data[3 * i + 1] = color[1];
90
- data[3 * i + 2] = color[2];
91
- }
92
- }
93
-
94
- return data ? data : [0, 0, 0];
95
- }
96
-
97
- export interface privateLayerProps<D> extends ExtendedLayerProps<D> {
98
- mesh: MeshType;
99
- meshLines: MeshTypeLines;
100
- colorMapName: string;
101
- colorMapRange: [number, number];
102
- colorMapClampColor: Color | undefined | boolean;
103
- colorMapFunction?: colorMapFunctionType | false;
104
- propertyValueRange: [number, number];
105
- depthTest: boolean;
106
- }
107
-
108
- const defaultProps = {
109
- colorMapName: "",
110
- coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
111
- propertyValueRange: [0.0, 1.0],
112
- depthTest: true,
113
- };
114
-
115
- // This is a private layer used only by the composite Map3DLayer
116
- export default class privateLayer extends Layer<privateLayerProps<unknown>> {
117
- initializeState(context: DeckGLLayerContext): void {
118
- const { gl } = context;
119
- const [model_mesh, mesh_lines_model] = this._getModels(gl);
120
- this.setState({ models: [model_mesh, mesh_lines_model] });
121
- }
122
-
123
- shouldUpdateState({
124
- props,
125
- oldProps,
126
- context,
127
- changeFlags,
128
- }: UpdateParameters<this>): boolean {
129
- return (
130
- super.shouldUpdateState({
131
- props,
132
- oldProps,
133
- context,
134
- changeFlags,
135
- }) || changeFlags.propsOrDataChanged
136
- );
137
- }
138
-
139
- updateState({ context }: UpdateParameters<this>): void {
140
- this.initializeState(context as DeckGLLayerContext);
141
- }
142
-
143
- //eslint-disable-next-line
144
- _getModels(gl: any) {
145
- // MESH MODEL
146
- const mesh_model = new Model(gl, {
147
- id: `${this.props.id}-mesh`,
148
- vs: vsShader,
149
- fs: fsShader,
150
- geometry: new Geometry({
151
- drawMode: this.props.mesh.drawMode,
152
- attributes: {
153
- positions: this.props.mesh.attributes.positions,
154
- properties: this.props.mesh.attributes.properties,
155
- vertex_indexs: this.props.mesh.attributes.vertex_indexs,
156
- },
157
- vertexCount: this.props.mesh.vertexCount,
158
- indices: this.props.mesh.indices,
159
- }),
160
- modules: [project, picking, phongLighting],
161
- isInstanced: false, // This only works when set to false.
162
- });
163
-
164
- // MESH LINES
165
- const mesh_lines_model = new Model(gl, {
166
- id: `${this.props.id}-lines`,
167
- vs: vsLineShader,
168
- fs: fsLineShader,
169
- geometry: new Geometry(this.props.meshLines),
170
- modules: [project, picking],
171
- isInstanced: false,
172
- });
173
-
174
- return [mesh_model, mesh_lines_model];
175
- }
176
-
177
- // Signature from the base class, eslint doesn't like the any type.
178
- // eslint-disable-next-line
179
- draw(args: any): void {
180
- if (!this.state["models"]) {
181
- return;
182
- }
183
-
184
- const { uniforms, context } = args;
185
- const { gl } = context;
186
-
187
- const [model_mesh, mesh_lines_model] = this.state["models"];
188
-
189
- const valueRangeMin = this.props.propertyValueRange?.[0] ?? 0.0;
190
- const valueRangeMax = this.props.propertyValueRange?.[1] ?? 1.0;
191
-
192
- // If specified color map will extend from colorMapRangeMin to colorMapRangeMax.
193
- // Otherwise it will extend from valueRangeMin to valueRangeMax.
194
- const colorMapRangeMin = this.props.colorMapRange?.[0] ?? valueRangeMin;
195
- const colorMapRangeMax = this.props.colorMapRange?.[1] ?? valueRangeMax;
196
-
197
- const isClampColor: boolean =
198
- this.props.colorMapClampColor !== undefined &&
199
- this.props.colorMapClampColor !== true &&
200
- this.props.colorMapClampColor !== false;
201
- let colorMapClampColor = isClampColor
202
- ? this.props.colorMapClampColor
203
- : [0, 0, 0];
204
-
205
- // Normalize to [0,1] range.
206
- colorMapClampColor = (colorMapClampColor as Color).map(
207
- (x) => (x ?? 0) / 255
208
- );
209
-
210
- const isColorMapClampColorTransparent: boolean =
211
- (this.props.colorMapClampColor as boolean) === false;
212
-
213
- gl.enable(gl.POLYGON_OFFSET_FILL);
214
- gl.polygonOffset(1, 1);
215
-
216
- if (!this.props.depthTest) {
217
- gl.disable(gl.DEPTH_TEST);
218
- }
219
-
220
- model_mesh
221
- .setUniforms({
222
- ...uniforms,
223
- colormap: new Texture2D(context.gl, {
224
- width: 256,
225
- height: 1,
226
- format: GL.RGB,
227
- data: getImageData(
228
- this.props.colorMapName,
229
- (this.context as DeckGLLayerContext).userData
230
- .colorTables,
231
- this.props.colorMapFunction
232
- ),
233
- parameters: DEFAULT_TEXTURE_PARAMETERS,
234
- }),
235
- valueRangeMin,
236
- valueRangeMax,
237
- colorMapRangeMin,
238
- colorMapRangeMax,
239
- colorMapClampColor,
240
- isColorMapClampColorTransparent,
241
- isClampColor,
242
- })
243
- .draw();
244
- gl.disable(gl.POLYGON_OFFSET_FILL);
245
-
246
- // Draw lines.
247
- mesh_lines_model.draw();
248
-
249
- if (!this.props.depthTest) {
250
- gl.enable(gl.DEPTH_TEST);
251
- }
252
- }
253
-
254
- decodePickingColor(): number {
255
- return this.nullPickingColor() as unknown as number;
256
- }
257
-
258
- encodePickingColor(): number[] {
259
- return this.nullPickingColor();
260
- }
261
-
262
- getPickingInfo({ info }: { info: PickingInfo }): LayerPickInfo {
263
- if (!info.color) {
264
- return info;
265
- }
266
-
267
- const layer_properties: PropertyDataType[] = [];
268
-
269
- // Note these colors are in the 0-255 range.
270
- const r = info.color[0];
271
- const g = info.color[1];
272
- const b = info.color[2];
273
-
274
- const vertexIndex = 256 * 256 * r + 256 * g + b;
275
-
276
- const vertexs = this.props.mesh.attributes.positions.value;
277
- const depth = -vertexs[3 * vertexIndex + 2];
278
- layer_properties.push(createPropertyData("Depth", depth));
279
-
280
- const properties = this.props.mesh.attributes.properties.value;
281
- const property = properties[vertexIndex];
282
- layer_properties.push(createPropertyData("Property", property));
283
-
284
- return {
285
- ...info,
286
- properties: layer_properties,
287
- };
288
- }
289
- }
290
-
291
- privateLayer.layerName = "privateLayer";
292
- privateLayer.defaultProps = defaultProps;
@@ -1,43 +0,0 @@
1
- const vsShader = `\
2
- #version 300 es
3
- #define SHADER_NAME vertex-shader
4
-
5
- precision highp float;
6
-
7
- // Primitive attributes
8
- in vec3 positions;
9
- in float properties;
10
- //in vec3 normals;
11
- in vec3 colors;
12
-
13
- in int vertex_indexs;
14
- flat out int vertex_indexs_;
15
-
16
-
17
- // Outputs to fragment shader
18
- out vec2 vTexCoord;
19
- out vec3 cameraPosition;
20
- // out vec3 normals_commonspace;
21
- out vec4 position_commonspace;
22
- out vec4 vColor;
23
- out vec3 worldPos;
24
- out float property;
25
-
26
-
27
- void main(void) {
28
- cameraPosition = project_uCameraPosition;
29
-
30
- worldPos = positions;
31
-
32
- vertex_indexs_ = vertex_indexs;
33
-
34
- vColor = vec4(colors.rgb, 1.0);
35
-
36
- property = properties;
37
-
38
- position_commonspace = vec4(project_position(positions), 0.0);
39
- gl_Position = project_common_position_to_clipspace(position_commonspace);
40
- }
41
- `;
42
-
43
- export default vsShader;
@@ -1,15 +0,0 @@
1
- export default `\
2
- #version 300 es
3
- #define SHADER_NAME vertex-lines-shader
4
-
5
- precision highp float;
6
-
7
- in vec3 positions;
8
-
9
- out vec4 position_commonspace;
10
-
11
- void main(void) {
12
- vec3 position_commonspace = project_position(positions);
13
- gl_Position = project_common_position_to_clipspace(vec4(position_commonspace, 0.0));
14
- }
15
- `;
@@ -1,173 +0,0 @@
1
- import { MeshType, MeshTypeLines } from "./privateLayer";
2
- import { WebWorkerParams } from "./grid3dLayer";
3
-
4
- export function makeFullMesh(e: { data: WebWorkerParams }): void {
5
- // Keep
6
- const t0 = performance.now();
7
-
8
- const params = e.data;
9
-
10
- const points = params.points;
11
- const polys = params.polys;
12
- const properties = params.properties;
13
- const isZIncreasingDownwards = params.isZIncreasingDownwards;
14
-
15
- const positions: number[] = [];
16
- const indices: number[] = [];
17
- const vertexProperties: number[] = [];
18
- const line_positions: number[] = [];
19
-
20
- let propertyValueRangeMin = +99999999;
21
- let propertyValueRangeMax = -99999999;
22
-
23
- const z_sign = isZIncreasingDownwards ? -1 : 1;
24
-
25
- let pn = 0;
26
- let indice = 0;
27
- let i = 0;
28
- while (i < polys.length) {
29
- const n = polys[i];
30
- const propertyValue = properties[pn++];
31
-
32
- if (propertyValue !== null) {
33
- // For some reason propertyValue happens to be null.
34
- propertyValueRangeMin =
35
- propertyValue < propertyValueRangeMin
36
- ? propertyValue
37
- : propertyValueRangeMin;
38
- propertyValueRangeMax =
39
- propertyValue > propertyValueRangeMax
40
- ? propertyValue
41
- : propertyValueRangeMax;
42
- }
43
-
44
- // Lines.
45
- for (let j = i + 1; j < i + n; j++) {
46
- const i1 = polys[j];
47
- const i2 = polys[j + 1];
48
-
49
- const x0 = points[3 * i1 + 0];
50
- const y0 = points[3 * i1 + 1];
51
- const z0 = points[3 * i1 + 2] * z_sign;
52
-
53
- const x1 = points[3 * i2 + 0];
54
- const y1 = points[3 * i2 + 1];
55
- const z1 = points[3 * i2 + 2] * z_sign;
56
-
57
- line_positions.push(x0, y0, z0);
58
- line_positions.push(x1, y1, z1);
59
- }
60
-
61
- // Triangles.
62
- if (n == 4) {
63
- const i1 = polys[i + 1];
64
- const i2 = polys[i + 2];
65
- const i3 = polys[i + 3];
66
- const i4 = polys[i + 4];
67
-
68
- const x1 = points[3 * i1 + 0];
69
- const y1 = points[3 * i1 + 1];
70
- const z1 = points[3 * i1 + 2] * z_sign;
71
-
72
- const x2 = points[3 * i2 + 0];
73
- const y2 = points[3 * i2 + 1];
74
- const z2 = points[3 * i2 + 2] * z_sign;
75
-
76
- const x3 = points[3 * i3 + 0];
77
- const y3 = points[3 * i3 + 1];
78
- const z3 = points[3 * i3 + 2] * z_sign;
79
-
80
- const x4 = points[3 * i4 + 0];
81
- const y4 = points[3 * i4 + 1];
82
- const z4 = points[3 * i4 + 2] * z_sign;
83
-
84
- // t1
85
- indices.push(indice++, indice++, indice++);
86
-
87
- positions.push(x1, y1, z1);
88
- positions.push(x2, y2, z2);
89
- positions.push(x3, y3, z3);
90
-
91
- vertexProperties.push(propertyValue);
92
- vertexProperties.push(propertyValue);
93
- vertexProperties.push(propertyValue);
94
-
95
- // t2
96
- indices.push(indice++, indice++, indice++);
97
-
98
- positions.push(x1, y1, z1);
99
- positions.push(x3, y3, z3);
100
- positions.push(x4, y4, z4);
101
-
102
- vertexProperties.push(propertyValue);
103
- vertexProperties.push(propertyValue);
104
- vertexProperties.push(propertyValue);
105
- } else if (n == 3) {
106
- // Refactor this n == 3 && n == 4.
107
- const i1 = polys[i + 1];
108
- const i2 = polys[i + 2];
109
- const i3 = polys[i + 3];
110
-
111
- const x1 = points[3 * i1 + 0];
112
- const y1 = points[3 * i1 + 1];
113
- const z1 = points[3 * i1 + 2] * z_sign;
114
-
115
- const x2 = points[3 * i2 + 0];
116
- const y2 = points[3 * i2 + 1];
117
- const z2 = points[3 * i2 + 2] * z_sign;
118
-
119
- const x3 = points[3 * i3 + 0];
120
- const y3 = points[3 * i3 + 1];
121
- const z3 = points[3 * i3 + 2] * z_sign;
122
-
123
- // t1
124
- indices.push(indice++, indice++, indice++);
125
-
126
- positions.push(x1, y1, z1);
127
- positions.push(x2, y2, z2);
128
- positions.push(x3, y3, z3);
129
-
130
- vertexProperties.push(propertyValue);
131
- vertexProperties.push(propertyValue);
132
- vertexProperties.push(propertyValue);
133
- } else {
134
- console.error("Only triangles or four corners are expected.");
135
- }
136
-
137
- i = i + n + 1;
138
- }
139
- console.log("Number of polygons: ", pn);
140
-
141
- const mesh: MeshType = {
142
- drawMode: 4, // corresponds to GL.TRIANGLES,
143
- attributes: {
144
- positions: { value: new Float32Array(positions), size: 3 },
145
- properties: { value: new Float32Array(vertexProperties), size: 1 },
146
- vertex_indexs: { value: new Int32Array(indices), size: 1 },
147
- },
148
- vertexCount: indices.length,
149
- indices: { value: new Uint32Array(indices), size: 1 },
150
- };
151
-
152
- const mesh_lines: MeshTypeLines = {
153
- drawMode: 1, // corresponds to GL.LINES,
154
- attributes: {
155
- positions: { value: new Float32Array(line_positions), size: 3 },
156
- },
157
- vertexCount: line_positions.length / 3,
158
- };
159
-
160
- const t1 = performance.now();
161
- //Keep this.
162
- console.log(`Task makeMesh took ${(t1 - t0) * 0.001} seconds.`);
163
-
164
- // Note: typescript gives this error "error TS2554: Expected 2-3 arguments, but got 1."
165
- // Disabling this for now as the second argument should be optional.
166
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
167
- // @ts-ignore
168
- postMessage([
169
- mesh,
170
- mesh_lines,
171
- [propertyValueRangeMin, propertyValueRangeMax],
172
- ]);
173
- }
@@ -1,62 +0,0 @@
1
- const fsHillshading = `#define SHADER_NAME hillshading2d-shader
2
-
3
- #ifdef GL_ES
4
- precision highp float;
5
- #endif
6
-
7
- varying vec2 vTexCoord;
8
-
9
- uniform sampler2D bitmapTexture; // Property map
10
- uniform vec2 bitmapResolution;
11
-
12
- uniform float valueRangeSize;
13
-
14
- uniform vec3 lightDirection;
15
- uniform float ambientLightIntensity;
16
- uniform float diffuseLightIntensity;
17
- uniform float opacity;
18
-
19
- // Compute the normal value for every pixel, based on the current value and two values aroud it.
20
- vec3 normal(float val) {
21
- vec2 dr = 1.0 / bitmapResolution;
22
- float p0 = valueRangeSize * val;
23
- float px = valueRangeSize * decode_rgb2float(texture2D(bitmapTexture, vTexCoord + vec2(1.0, 0.0) / bitmapResolution).rgb);
24
- float py = valueRangeSize * decode_rgb2float(texture2D(bitmapTexture, vTexCoord + vec2(0.0, 1.0) / bitmapResolution).rgb);
25
- vec3 dx = vec3(1.0, 0.0, px - p0);
26
- vec3 dy = vec3(0.0, 1.0, py - p0);
27
-
28
- return normalize(cross(dx, dy));
29
- }
30
-
31
- // Compute how much a pixel is in the shadow based on its normal and where the light comes from.
32
- float shadow(vec3 normal) {
33
- float diffuse = diffuseLightIntensity * dot(normal, normalize(lightDirection));
34
- return clamp(ambientLightIntensity + diffuse, 0.0, 1.0);
35
- }
36
-
37
- void main(void) {
38
- vec4 bitmapColor = texture2D(bitmapTexture, vTexCoord);
39
-
40
- // If it's a picking pass, we just return the raw property map value.
41
- if (picking_uActive) {
42
- gl_FragColor = bitmapColor;
43
- return;
44
- }
45
-
46
- // Decode the RGB value into a float. See decoder.fs.glsl for more details.
47
- float val = decode_rgb2float(bitmapColor.rgb);
48
- // Compute the shadow value, how dark a pixel will be, 1 is in complete shadow, 0 is in complete light.
49
- float shadow = shadow(normal(val));
50
-
51
- // The final pixel is black, with the opacity based on the shadow value,
52
- // opacity 0 if pixel is completely in the light, opacity 1 if pixel is completely in the shadow.
53
- // The property map opacity (some portions of the property map can be transparent) and
54
- // the user provided image-wide opacity value are also taken into account.
55
- gl_FragColor = vec4(vec3(0.0), (1.0-shadow) * bitmapColor.a * opacity);
56
-
57
- geometry.uv = vTexCoord;
58
- DECKGL_FILTER_COLOR(gl_FragColor, geometry);
59
- }
60
- `;
61
-
62
- export default fsHillshading;