@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.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +5 -2
- package/package.json +6 -3
- package/dist/DashSubsurfaceViewer.d.ts +0 -56
- package/dist/DashSubsurfaceViewer.js +0 -160
- package/dist/DashSubsurfaceViewer.js.map +0 -1
- package/src/DashSubsurfaceViewer.tsx +0 -270
- package/src/SubsurfaceViewer.stories.tsx +0 -449
- package/src/SubsurfaceViewer.test.tsx +0 -98
- package/src/SubsurfaceViewer.tsx +0 -356
- package/src/__snapshots__/SubsurfaceViewer.test.tsx.snap +0 -178
- package/src/assets/glTF/north_arrow/scene.bin +0 -0
- package/src/assets/glTF/north_arrow/scene.gltf +0 -315
- package/src/assets/glTF/north_arrow/textures/Arrow5_baseColor.png +0 -0
- package/src/assets/glTF/north_arrow/textures/Arrow5_metallicRoughness.png +0 -0
- package/src/assets/glTF/north_arrow/textures/Arrow5_normal.png +0 -0
- package/src/components/ColorLegend.test.tsx +0 -32
- package/src/components/ColorLegend.tsx +0 -80
- package/src/components/ColorLegends.test.tsx +0 -97
- package/src/components/ColorLegends.tsx +0 -46
- package/src/components/DistanceScale.stories.tsx +0 -28
- package/src/components/DistanceScale.test.tsx +0 -36
- package/src/components/DistanceScale.tsx +0 -84
- package/src/components/InfoCard.test.tsx +0 -110
- package/src/components/InfoCard.tsx +0 -263
- package/src/components/Map.test.tsx +0 -142
- package/src/components/Map.tsx +0 -1435
- package/src/components/StatusIndicator.test.tsx +0 -14
- package/src/components/StatusIndicator.tsx +0 -38
- package/src/components/ViewAnnotation.tsx +0 -16
- package/src/components/ViewFooter.test.tsx +0 -12
- package/src/components/ViewFooter.tsx +0 -30
- package/src/components/__snapshots__/ColorLegends.test.tsx.snap +0 -15
- package/src/components/__snapshots__/DistanceScale.test.tsx.snap +0 -33
- package/src/components/__snapshots__/InfoCard.test.tsx.snap +0 -561
- package/src/components/__snapshots__/Map.test.tsx.snap +0 -119
- package/src/components/__snapshots__/StatusIndicator.test.tsx.snap +0 -3
- package/src/components/__snapshots__/ViewFooter.test.tsx.snap +0 -7
- package/src/components/settings/DrawModeSelector.test.tsx +0 -45
- package/src/components/settings/DrawModeSelector.tsx +0 -58
- package/src/components/settings/DrawModeSelector_performance.test.tsx +0 -35
- package/src/components/settings/LayerProperty.test.tsx +0 -35
- package/src/components/settings/LayerProperty.tsx +0 -153
- package/src/components/settings/LayerProperty_performance.test.tsx +0 -39
- package/src/components/settings/LayerSettingsButton.test.tsx +0 -133
- package/src/components/settings/LayerSettingsButton.tsx +0 -95
- package/src/components/settings/LayersButton.test.tsx +0 -102
- package/src/components/settings/LayersButton.tsx +0 -97
- package/src/components/settings/NumericInput.test.tsx +0 -25
- package/src/components/settings/NumericInput.tsx +0 -67
- package/src/components/settings/Settings.tsx +0 -71
- package/src/components/settings/SliderInput.test.tsx +0 -28
- package/src/components/settings/SliderInput.tsx +0 -71
- package/src/components/settings/ToggleButton.test.tsx +0 -25
- package/src/components/settings/ToggleButton.tsx +0 -53
- package/src/components/settings/__snapshots__/DrawModeSelector.test.tsx.snap +0 -124
- package/src/components/settings/__snapshots__/LayerProperty.test.tsx.snap +0 -124
- package/src/components/settings/__snapshots__/LayerSettingsButton.test.tsx.snap +0 -36
- package/src/components/settings/__snapshots__/LayersButton.test.tsx.snap +0 -83
- package/src/components/settings/__snapshots__/NumericInput.test.tsx.snap +0 -123
- package/src/components/settings/__snapshots__/SliderInput.test.tsx.snap +0 -244
- package/src/components/settings/__snapshots__/ToggleButton.test.tsx.snap +0 -182
- package/src/custom.d.ts +0 -9
- package/src/index.ts +0 -5
- package/src/inputSchema/ColorTables.json +0 -51
- package/src/inputSchema/FaultPolygons.json +0 -80
- package/src/inputSchema/Grid.json +0 -39
- package/src/inputSchema/PieChart.json +0 -72
- package/src/inputSchema/WellLog.json +0 -126
- package/src/inputSchema/WellLogTemplate.json +0 -136
- package/src/inputSchema/WellLogs.json +0 -5
- package/src/inputSchema/Wells.json +0 -106
- package/src/inputSchema/schemaValidationUtil.tsx +0 -55
- package/src/inputSchema/validator.tsx +0 -72
- package/src/inputSchema/wellCompletions.json +0 -108
- package/src/layers/BoxSelectionLayer/boxSelectionLayer.stories.tsx +0 -172
- package/src/layers/BoxSelectionLayer/boxSelectionLayer.tsx +0 -136
- package/src/layers/axes/axes-fragment.glsl.ts +0 -15
- package/src/layers/axes/axesLayer.stories.tsx +0 -87
- package/src/layers/axes/axesLayer.ts +0 -692
- package/src/layers/axes/boxLayer.ts +0 -71
- package/src/layers/axes/grid-vertex.glsl.ts +0 -14
- package/src/layers/axes2d/axes2DLayer.stories.tsx +0 -150
- package/src/layers/axes2d/axes2DLayer.ts +0 -841
- package/src/layers/axes2d/font-atlas.png +0 -0
- package/src/layers/axes2d/label-fragment.glsl.js +0 -37
- package/src/layers/axes2d/label-vertex.glsl.js +0 -20
- package/src/layers/axes2d/line-fragment.glsl.js +0 -14
- package/src/layers/axes2d/line-vertex.glsl.js +0 -13
- package/src/layers/colormap/colormap.fs.glsl.ts +0 -42
- package/src/layers/colormap/colormapLayer.ts +0 -247
- package/src/layers/drawing/drawingLayer.tsx +0 -256
- package/src/layers/fault_polygons/faultPolygonsLayer.ts +0 -54
- package/src/layers/grid3d/fragment.fs.glsl.ts +0 -109
- package/src/layers/grid3d/fragment_lines.glsl.ts +0 -21
- package/src/layers/grid3d/grid3dLayer.stories.tsx +0 -172
- package/src/layers/grid3d/grid3dLayer.ts +0 -248
- package/src/layers/grid3d/privateLayer.ts +0 -292
- package/src/layers/grid3d/vertex.glsl.ts +0 -43
- package/src/layers/grid3d/vertex_lines.glsl.ts +0 -15
- package/src/layers/grid3d/webworker.ts +0 -173
- package/src/layers/hillshading2d/hillshading2d.fs.glsl.ts +0 -62
- package/src/layers/hillshading2d/hillshading2dLayer.ts +0 -172
- package/src/layers/index.ts +0 -35
- package/src/layers/intersection/intersectionView.stories.tsx +0 -294
- package/src/layers/intersection/unfoldedGeoJsonLayer.ts +0 -92
- package/src/layers/map/fragment.fs.glsl.ts +0 -127
- package/src/layers/map/fragment_lines.glsl.ts +0 -21
- package/src/layers/map/mapLayer.stories.tsx +0 -1369
- package/src/layers/map/mapLayer.ts +0 -470
- package/src/layers/map/privateMapLayer.ts +0 -317
- package/src/layers/map/vertex.glsl.ts +0 -45
- package/src/layers/map/vertex_lines.glsl.ts +0 -15
- package/src/layers/map/webworker.ts +0 -479
- package/src/layers/northarrow/northArrow.stories.tsx +0 -108
- package/src/layers/northarrow/northArrow3DLayer.ts +0 -204
- package/src/layers/northarrow/northarrow-fragment.glsl.js +0 -14
- package/src/layers/northarrow/northarrow-vertex.glsl.js +0 -13
- package/src/layers/piechart/fragment.glsl.js +0 -42
- package/src/layers/piechart/pieChartLayer.ts +0 -246
- package/src/layers/piechart/vertex.glsl.js +0 -42
- package/src/layers/points/pointsLayer.stories.tsx +0 -141
- package/src/layers/points/pointsLayer.ts +0 -143
- package/src/layers/polylines/polylinesLayer.stories.tsx +0 -144
- package/src/layers/polylines/polylinesLayer.ts +0 -263
- package/src/layers/selectable_geojson/selectableGeoJsonLayer.ts +0 -25
- package/src/layers/shader_modules/decoder.fs.glsl.ts +0 -41
- package/src/layers/shader_modules/decoder.ts +0 -46
- package/src/layers/shader_modules/index.ts +0 -1
- package/src/layers/terrain/map3DLayer.stories.tsx +0 -340
- package/src/layers/terrain/map3DLayer.ts +0 -556
- package/src/layers/terrain/terrainMapLayer.ts +0 -334
- package/src/layers/terrain/terrainmap.fs.glsl.ts +0 -134
- package/src/layers/triangle/fragment.fs.glsl.ts +0 -126
- package/src/layers/triangle/fragment_lines.glsl.ts +0 -21
- package/src/layers/triangle/privateTriangleLayer.ts +0 -203
- package/src/layers/triangle/test_data/surfacePoints.ts +0 -4344
- package/src/layers/triangle/test_data/surfaceTriangles.ts +0 -7392
- package/src/layers/triangle/triangleLayer.stories.tsx +0 -191
- package/src/layers/triangle/triangleLayer.ts +0 -273
- package/src/layers/triangle/vertex.glsl.ts +0 -35
- package/src/layers/triangle/vertex_lines.glsl.ts +0 -15
- package/src/layers/triangle/webworker.ts +0 -165
- package/src/layers/utils/glsl.d.ts +0 -4
- package/src/layers/utils/layerTools.ts +0 -182
- package/src/layers/utils/propertyMapTools.ts +0 -43
- package/src/layers/wells/utils/spline.ts +0 -318
- package/src/layers/wells/wellsLayer.stories.tsx +0 -625
- package/src/layers/wells/wellsLayer.ts +0 -1377
- package/src/redux/actions.ts +0 -8
- package/src/redux/reducer.ts +0 -43
- package/src/redux/store.ts +0 -15
- package/src/redux/types.ts +0 -114
- package/src/storybook/SubsurfaceViewer.stories.jsx +0 -644
- package/src/storybook/components/InfoCard.stories.jsx +0 -39
- package/src/storybook/components/colorLegends/ContinuousLegend.stories.jsx +0 -32
- package/src/storybook/components/colorLegends/DiscreteLegend.stories.jsx +0 -33
- package/src/storybook/components/colorLegends/IndividualScaleForMap.stories.jsx +0 -99
- package/src/storybook/components/colorLegends/SingleScaleForMap.stories.jsx +0 -120
- package/src/storybook/components/settings/LayerSettingsButton.stories.jsx +0 -34
- package/src/storybook/components/settings/NumericInput.stories.jsx +0 -17
- package/src/storybook/components/settings/ToggleButton.stories.jsx +0 -16
- package/src/storybook/schemaValidation/sampleData.js +0 -177
- package/src/storybook/schemaValidation/schemaValidation.stories.jsx +0 -91
- package/src/test/TestWrapper.tsx +0 -13
- package/src/utils/configuration.ts +0 -61
- package/src/utils/fit-bounds.js +0 -85
- package/src/utils/measurement.ts +0 -61
- package/src/utils/northArrow.ts +0 -4
- package/src/utils/specExtractor.ts +0 -36
- package/src/viewports/index.js +0 -1
- package/src/viewports/intersectionViewport.ts +0 -137
- package/src/views/index.js +0 -1
- package/src/views/intersectionView.ts +0 -38
- package/tsconfig.json +0 -7
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Layer,
|
|
3
|
-
Viewport,
|
|
4
|
-
LayerContext,
|
|
5
|
-
UpdateParameters,
|
|
6
|
-
project,
|
|
7
|
-
OrthographicViewport,
|
|
8
|
-
} from "@deck.gl/core/typed";
|
|
9
|
-
import GL from "@luma.gl/constants";
|
|
10
|
-
import { Model, Geometry } from "@luma.gl/engine";
|
|
11
|
-
import { Vector3 } from "@math.gl/core";
|
|
12
|
-
import { Color } from "@deck.gl/core/typed";
|
|
13
|
-
import vertexShader from "./northarrow-vertex.glsl";
|
|
14
|
-
import fragmentShader from "./northarrow-fragment.glsl";
|
|
15
|
-
import { ExtendedLayerProps } from "../utils/layerTools";
|
|
16
|
-
|
|
17
|
-
export interface NorthArrow3DLayerProps<D> extends ExtendedLayerProps<D> {
|
|
18
|
-
color: Color;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const defaultProps = {
|
|
22
|
-
"@@type": "NorthArrow3DLayer",
|
|
23
|
-
name: "NorthArrow3D",
|
|
24
|
-
id: "north-arrow-layer",
|
|
25
|
-
visible: true,
|
|
26
|
-
color: [0, 0, 0, 1],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default class NorthArrow3DLayer extends Layer<
|
|
30
|
-
NorthArrow3DLayerProps<unknown>
|
|
31
|
-
> {
|
|
32
|
-
initializeState(context: LayerContext): void {
|
|
33
|
-
const { gl } = context;
|
|
34
|
-
this.setState(this._getModels(gl));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
shouldUpdateState(): boolean {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
updateState({ context }: UpdateParameters<this>): void {
|
|
42
|
-
if (context.gl) {
|
|
43
|
-
this.setState(this._getModels(context.gl));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Signature from the base class, eslint doesn't like the any type.
|
|
48
|
-
// eslint-disable-next-line
|
|
49
|
-
draw({ moduleParameters, uniforms, context }: any): void {
|
|
50
|
-
const { gl } = context;
|
|
51
|
-
gl.disable(gl.DEPTH_TEST);
|
|
52
|
-
super.draw({ moduleParameters, uniforms, context });
|
|
53
|
-
gl.enable(gl.DEPTH_TEST);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
//eslint-disable-next-line
|
|
57
|
-
_getModels(gl: any) {
|
|
58
|
-
const model_lines = GetArrowLines();
|
|
59
|
-
|
|
60
|
-
const is_orthographic =
|
|
61
|
-
this.context.viewport.constructor === OrthographicViewport;
|
|
62
|
-
|
|
63
|
-
const view_at = new Vector3(this.unproject([100, 100, 0]));
|
|
64
|
-
let view_from = new Vector3(this.context.viewport.cameraPosition);
|
|
65
|
-
|
|
66
|
-
if (is_orthographic) {
|
|
67
|
-
const cam_pos_z = new Vector3(
|
|
68
|
-
(this.context.viewport as Viewport).cameraPosition
|
|
69
|
-
)[2];
|
|
70
|
-
view_from = new Vector3([view_at[0], view_at[1], cam_pos_z]);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const dir = new Vector3([
|
|
74
|
-
view_at[0] - view_from[0],
|
|
75
|
-
view_at[1] - view_from[1],
|
|
76
|
-
view_at[2] - view_from[2],
|
|
77
|
-
]);
|
|
78
|
-
dir.normalize();
|
|
79
|
-
dir.scale(9999);
|
|
80
|
-
|
|
81
|
-
// pos: World coordinate for north arrow. Will be fixed relative to camera.
|
|
82
|
-
const pos = new Vector3([
|
|
83
|
-
view_from[0] + dir[0],
|
|
84
|
-
view_from[1] + dir[1],
|
|
85
|
-
view_from[2] + dir[2],
|
|
86
|
-
]);
|
|
87
|
-
|
|
88
|
-
const lines: number[] = [];
|
|
89
|
-
|
|
90
|
-
const zoom = this.context.viewport.zoom;
|
|
91
|
-
const zoom_scale = Math.pow(2, zoom);
|
|
92
|
-
const scale = is_orthographic ? 15 / zoom_scale : 99;
|
|
93
|
-
|
|
94
|
-
for (let i = 0; i < model_lines.length / 3; i = i + 1) {
|
|
95
|
-
const x = model_lines[i * 3 + 0] * scale + pos[0];
|
|
96
|
-
const y = model_lines[i * 3 + 1] * scale + pos[1];
|
|
97
|
-
const z = model_lines[i * 3 + 2] * scale + pos[2];
|
|
98
|
-
lines.push(x, y, z);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const color = this.props.color.map((x?: number) => (x ?? 0) / 255);
|
|
102
|
-
color[3] = 1;
|
|
103
|
-
|
|
104
|
-
const grids = new Model(gl, {
|
|
105
|
-
id: `${this.props.id}-grids`,
|
|
106
|
-
vs: vertexShader,
|
|
107
|
-
fs: fragmentShader,
|
|
108
|
-
uniforms: { uColor: color },
|
|
109
|
-
geometry: new Geometry({
|
|
110
|
-
drawMode: GL.LINES,
|
|
111
|
-
attributes: {
|
|
112
|
-
positions: new Float32Array(lines),
|
|
113
|
-
},
|
|
114
|
-
vertexCount: lines.length / 3,
|
|
115
|
-
}),
|
|
116
|
-
|
|
117
|
-
modules: [project],
|
|
118
|
-
isInstanced: false, // This only works when set to false.
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
model: grids,
|
|
123
|
-
models: [grids].filter(Boolean),
|
|
124
|
-
modelsByName: { grids },
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
NorthArrow3DLayer.layerName = "NorthArrow3DLayer";
|
|
130
|
-
NorthArrow3DLayer.defaultProps = defaultProps;
|
|
131
|
-
|
|
132
|
-
//-- Local functions. --------------------------------------
|
|
133
|
-
|
|
134
|
-
function GetArrowLines(): number[] {
|
|
135
|
-
const lines: number[][] = [];
|
|
136
|
-
|
|
137
|
-
let z = 0.5;
|
|
138
|
-
lines.push([-1, -2, z]);
|
|
139
|
-
lines.push([-1, 2, z]);
|
|
140
|
-
|
|
141
|
-
lines.push([-1, 2, z]);
|
|
142
|
-
lines.push([-1.5, 2, z]);
|
|
143
|
-
|
|
144
|
-
lines.push([-1.5, 2, z]);
|
|
145
|
-
lines.push([0, 4, z]);
|
|
146
|
-
|
|
147
|
-
lines.push([0, 4, z]);
|
|
148
|
-
lines.push([1.5, 2, z]);
|
|
149
|
-
|
|
150
|
-
lines.push([1.5, 2, z]);
|
|
151
|
-
lines.push([1, 2, z]);
|
|
152
|
-
|
|
153
|
-
lines.push([1, 2, z]);
|
|
154
|
-
lines.push([1, -2, z]);
|
|
155
|
-
|
|
156
|
-
lines.push([1, -2, z]);
|
|
157
|
-
lines.push([-1, -2, z]);
|
|
158
|
-
|
|
159
|
-
z = -0.5;
|
|
160
|
-
lines.push([-1, -2, z]);
|
|
161
|
-
lines.push([-1, 2, z]);
|
|
162
|
-
|
|
163
|
-
lines.push([-1, 2, z]);
|
|
164
|
-
lines.push([-1.5, 2, z]);
|
|
165
|
-
|
|
166
|
-
lines.push([-1.5, 2, z]);
|
|
167
|
-
lines.push([0, 4, z]);
|
|
168
|
-
|
|
169
|
-
lines.push([0, 4, z]);
|
|
170
|
-
lines.push([1.5, 2, z]);
|
|
171
|
-
|
|
172
|
-
lines.push([1.5, 2, z]);
|
|
173
|
-
lines.push([1, 2, z]);
|
|
174
|
-
|
|
175
|
-
lines.push([1, 2, z]);
|
|
176
|
-
lines.push([1, -2, z]);
|
|
177
|
-
|
|
178
|
-
lines.push([1, -2, z]);
|
|
179
|
-
lines.push([-1, -2, z]);
|
|
180
|
-
|
|
181
|
-
// stolper
|
|
182
|
-
lines.push([-1, -2, -0.5]);
|
|
183
|
-
lines.push([-1, -2, 0.5]);
|
|
184
|
-
|
|
185
|
-
lines.push([-1, 2, -0.5]);
|
|
186
|
-
lines.push([-1, 2, 0.5]);
|
|
187
|
-
|
|
188
|
-
lines.push([-1.5, 2, -0.5]);
|
|
189
|
-
lines.push([-1.5, 2, 0.5]);
|
|
190
|
-
|
|
191
|
-
lines.push([0, 4, -0.5]);
|
|
192
|
-
lines.push([0, 4, 0.5]);
|
|
193
|
-
|
|
194
|
-
lines.push([1.5, 2, -0.5]);
|
|
195
|
-
lines.push([1.5, 2, 0.5]);
|
|
196
|
-
|
|
197
|
-
lines.push([1, 2, -0.5]);
|
|
198
|
-
lines.push([1, 2, 0.5]);
|
|
199
|
-
|
|
200
|
-
lines.push([1, -2, -0.5]);
|
|
201
|
-
lines.push([1, -2, 0.5]);
|
|
202
|
-
|
|
203
|
-
return lines.flat();
|
|
204
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default `\
|
|
2
|
-
#version 300 es
|
|
3
|
-
#define SHADER_NAME graph-layer-axis-vertex-shader
|
|
4
|
-
|
|
5
|
-
precision highp float;
|
|
6
|
-
|
|
7
|
-
in vec3 positions;
|
|
8
|
-
|
|
9
|
-
void main(void) {
|
|
10
|
-
vec3 position_commonspace = project_position(positions);
|
|
11
|
-
gl_Position = project_common_position_to_clipspace(vec4(position_commonspace, 0.0));
|
|
12
|
-
}
|
|
13
|
-
`;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export default `\
|
|
2
|
-
#version 300 es
|
|
3
|
-
#define SHADER_NAME graph-layer-fragment-shader
|
|
4
|
-
|
|
5
|
-
precision highp float;
|
|
6
|
-
|
|
7
|
-
flat in int pie_index_;
|
|
8
|
-
|
|
9
|
-
out vec4 fragColor;
|
|
10
|
-
|
|
11
|
-
in vec4 vColor;
|
|
12
|
-
|
|
13
|
-
void main(void) {
|
|
14
|
-
|
|
15
|
-
//Picking pass.
|
|
16
|
-
if (picking_uActive) {
|
|
17
|
-
// Express triangle index in 255 system.
|
|
18
|
-
float r = 0.0;
|
|
19
|
-
float g = 0.0;
|
|
20
|
-
float b = 0.0;
|
|
21
|
-
|
|
22
|
-
int idx = pie_index_;
|
|
23
|
-
|
|
24
|
-
if (idx >= (256 * 256) - 1) {
|
|
25
|
-
r = floor(float(idx) / (256.0 * 256.0));
|
|
26
|
-
idx -= int(r * (256.0 * 256.0));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (idx >= 256 - 1) {
|
|
30
|
-
g = floor(float(idx) / 256.0);
|
|
31
|
-
idx -= int(g * 256.0);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
b = float(idx);
|
|
35
|
-
|
|
36
|
-
fragColor = vec4(r / 255.0, g / 255.0, b / 255.0, 1.0);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
fragColor = vColor;
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Layer,
|
|
3
|
-
PickingInfo,
|
|
4
|
-
picking,
|
|
5
|
-
Color,
|
|
6
|
-
UpdateParameters,
|
|
7
|
-
project,
|
|
8
|
-
} from "@deck.gl/core/typed";
|
|
9
|
-
import {
|
|
10
|
-
LayerPickInfo,
|
|
11
|
-
PropertyDataType,
|
|
12
|
-
createPropertyData,
|
|
13
|
-
} from "../utils/layerTools";
|
|
14
|
-
import { ExtendedLayerProps } from "../utils/layerTools";
|
|
15
|
-
import { Vector2 } from "@math.gl/core";
|
|
16
|
-
import vertexShader from "./vertex.glsl";
|
|
17
|
-
import fragmentShader from "./fragment.glsl";
|
|
18
|
-
import GL from "@luma.gl/constants";
|
|
19
|
-
import { Model, Geometry } from "@luma.gl/engine";
|
|
20
|
-
|
|
21
|
-
type PieProperties = [{ color: Color; label: string }];
|
|
22
|
-
|
|
23
|
-
type PieData = {
|
|
24
|
-
x: number;
|
|
25
|
-
y: number;
|
|
26
|
-
R: number;
|
|
27
|
-
fractions: [{ value: number; idx: number }];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// These are the data PieChartLayer expects.
|
|
31
|
-
interface PiesData {
|
|
32
|
-
pies: PieData[];
|
|
33
|
-
properties: PieProperties;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface PieChartLayerProps<D> extends ExtendedLayerProps<D> {
|
|
37
|
-
selectedPie: D;
|
|
38
|
-
|
|
39
|
-
// Enable/disable depth testing when rendering layer. Default true.
|
|
40
|
-
depthTest: boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const defaultProps = {
|
|
44
|
-
"@@type": "PieChartLayer",
|
|
45
|
-
name: "Pie chart",
|
|
46
|
-
id: "pie-layer",
|
|
47
|
-
pickable: true,
|
|
48
|
-
visible: true,
|
|
49
|
-
selectedPie: "@@editedData.selectedPie", // used to get data from deckgl layer
|
|
50
|
-
depthTest: true,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default class PieChartLayer extends Layer<PieChartLayerProps<PiesData>> {
|
|
54
|
-
initializeState(): void {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
shouldUpdateState(): boolean {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
updateState({ context }: UpdateParameters<this>): void {
|
|
63
|
-
if (!this.state?.["model"]) {
|
|
64
|
-
const pieData = this.props.data as unknown as PiesData;
|
|
65
|
-
if (pieData?.pies) {
|
|
66
|
-
const { gl } = context;
|
|
67
|
-
this.setState(this.getModel(gl, pieData));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
//eslint-disable-next-line
|
|
73
|
-
getModel(gl: any, pieData: PiesData) {
|
|
74
|
-
const vertexs: number[] = [];
|
|
75
|
-
const colors: number[] = [];
|
|
76
|
-
const mx: number[] = [];
|
|
77
|
-
const my: number[] = [];
|
|
78
|
-
const doScale: number[] = [];
|
|
79
|
-
const pieInfo: string[][] = [];
|
|
80
|
-
const pieInfoIndex: number[] = [];
|
|
81
|
-
|
|
82
|
-
const dA = 5; // delta angle
|
|
83
|
-
|
|
84
|
-
let infoIndex = 0;
|
|
85
|
-
for (const pie of pieData.pies) {
|
|
86
|
-
const x = pie.x;
|
|
87
|
-
const y = pie.y;
|
|
88
|
-
const R = pie.R;
|
|
89
|
-
|
|
90
|
-
// Normalize
|
|
91
|
-
let sum = 0;
|
|
92
|
-
for (const frac of pie.fractions) {
|
|
93
|
-
sum += frac.value;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (sum === 0) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let start_a = -90.0;
|
|
101
|
-
for (let i = 0; i < pie.fractions.length; i++) {
|
|
102
|
-
const frac = pie.fractions[i].value / sum;
|
|
103
|
-
const end_a = start_a + frac * 360.0;
|
|
104
|
-
|
|
105
|
-
const prop = pieData.properties[pie.fractions[i].idx];
|
|
106
|
-
let col: number[] = (prop?.color as number[]) ?? [
|
|
107
|
-
255, 0, 255, 255,
|
|
108
|
-
]; // magenta
|
|
109
|
-
col = col.map(
|
|
110
|
-
(x) => (x ?? 0) / 255 // Normalize to [0,1] range.
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const name = prop?.label ?? "no label";
|
|
114
|
-
const frac_string = (frac * 100).toFixed(1) + "%";
|
|
115
|
-
pieInfo.push([name, frac_string]);
|
|
116
|
-
|
|
117
|
-
// Make triangles for one pie pice.
|
|
118
|
-
for (let a = start_a; a < end_a; a += dA) {
|
|
119
|
-
const a1 = a;
|
|
120
|
-
const rad1 = (a1 * (2.0 * Math.PI)) / 360.0;
|
|
121
|
-
const xx1 = R * Math.cos(rad1) + x;
|
|
122
|
-
const yy1 = R * Math.sin(rad1) + y;
|
|
123
|
-
|
|
124
|
-
const a2 = Math.min(a1 + dA, end_a);
|
|
125
|
-
const rad2 = (a2 * (2.0 * Math.PI)) / 360.0;
|
|
126
|
-
const xx2 = R * Math.cos(rad2) + x;
|
|
127
|
-
const yy2 = R * Math.sin(rad2) + y;
|
|
128
|
-
|
|
129
|
-
vertexs.push(x, y, 0);
|
|
130
|
-
mx.push(x);
|
|
131
|
-
my.push(y);
|
|
132
|
-
colors.push(...col);
|
|
133
|
-
pieInfoIndex.push(infoIndex);
|
|
134
|
-
doScale.push(0);
|
|
135
|
-
|
|
136
|
-
vertexs.push(xx1, yy1, 0);
|
|
137
|
-
mx.push(x);
|
|
138
|
-
my.push(y);
|
|
139
|
-
colors.push(...col);
|
|
140
|
-
pieInfoIndex.push(infoIndex);
|
|
141
|
-
doScale.push(1);
|
|
142
|
-
|
|
143
|
-
vertexs.push(xx2, yy2, 0);
|
|
144
|
-
mx.push(x);
|
|
145
|
-
my.push(y);
|
|
146
|
-
colors.push(...col);
|
|
147
|
-
pieInfoIndex.push(infoIndex);
|
|
148
|
-
doScale.push(1);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
infoIndex++;
|
|
152
|
-
|
|
153
|
-
start_a = end_a;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const model = new Model(gl, {
|
|
158
|
-
id: `${this.props.id}-pie`,
|
|
159
|
-
vs: vertexShader,
|
|
160
|
-
fs: fragmentShader,
|
|
161
|
-
geometry: new Geometry({
|
|
162
|
-
drawMode: GL.TRIANGLES,
|
|
163
|
-
attributes: {
|
|
164
|
-
positions: { value: new Float32Array(vertexs), size: 3 },
|
|
165
|
-
colors: { value: new Float32Array(colors), size: 3 },
|
|
166
|
-
pie_index: { value: new Int32Array(pieInfoIndex), size: 1 },
|
|
167
|
-
mx: { value: new Float32Array(mx), size: 1 },
|
|
168
|
-
my: { value: new Float32Array(my), size: 1 },
|
|
169
|
-
do_scale: { value: new Float32Array(doScale), size: 1 },
|
|
170
|
-
},
|
|
171
|
-
vertexCount: vertexs.length / 3,
|
|
172
|
-
}),
|
|
173
|
-
|
|
174
|
-
modules: [project, picking],
|
|
175
|
-
isInstanced: false, // This only works when set to false.
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
return { model, pieInfo };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Signature from the base class, eslint doesn't like the any type.
|
|
182
|
-
// eslint-disable-next-line
|
|
183
|
-
draw(args: any): void {
|
|
184
|
-
if (!this.state?.["model"]) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const { context } = args;
|
|
189
|
-
const { gl } = context;
|
|
190
|
-
|
|
191
|
-
const npixels = 100;
|
|
192
|
-
const p1 = [0, 0];
|
|
193
|
-
const p2 = [npixels, 0];
|
|
194
|
-
|
|
195
|
-
const p1_unproj = this.context.viewport.unproject(p1);
|
|
196
|
-
const p2_unproj = this.context.viewport.unproject(p2);
|
|
197
|
-
|
|
198
|
-
const v1 = new Vector2(p1_unproj[0], p1_unproj[1]);
|
|
199
|
-
const v2 = new Vector2(p2_unproj[0], p2_unproj[1]);
|
|
200
|
-
const d = v1.distance(v2);
|
|
201
|
-
|
|
202
|
-
// Factor to convert a length in pixels to a length in world space.
|
|
203
|
-
const pixels2world = d / npixels;
|
|
204
|
-
const scale = pixels2world;
|
|
205
|
-
|
|
206
|
-
const model = this.state["model"];
|
|
207
|
-
|
|
208
|
-
if (!this.props.depthTest) {
|
|
209
|
-
gl.disable(GL.DEPTH_TEST);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
model.setUniforms({ scale }).draw();
|
|
213
|
-
|
|
214
|
-
if (!this.props.depthTest) {
|
|
215
|
-
gl.enable(GL.DEPTH_TEST);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
decodePickingColor(): number {
|
|
220
|
-
return this.nullPickingColor() as unknown as number;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
getPickingInfo({ info }: { info: PickingInfo }): LayerPickInfo {
|
|
224
|
-
if (!info.color) {
|
|
225
|
-
return info;
|
|
226
|
-
}
|
|
227
|
-
// Note these colors are in the 0-255 range.
|
|
228
|
-
const r = info.color[0];
|
|
229
|
-
const g = info.color[1];
|
|
230
|
-
const b = info.color[2];
|
|
231
|
-
|
|
232
|
-
const pieIndex = 256 * 256 * r + 256 * g + b;
|
|
233
|
-
|
|
234
|
-
const [pie_label, pie_frac] = this.state["pieInfo"][pieIndex];
|
|
235
|
-
const layer_properties: PropertyDataType[] = [];
|
|
236
|
-
layer_properties.push(createPropertyData(pie_label, pie_frac));
|
|
237
|
-
|
|
238
|
-
return {
|
|
239
|
-
...info,
|
|
240
|
-
properties: layer_properties,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
PieChartLayer.layerName = "PieChartLayer";
|
|
246
|
-
PieChartLayer.defaultProps = defaultProps;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export default `\
|
|
2
|
-
#version 300 es
|
|
3
|
-
#define SHADER_NAME graph-layer-axis-vertex-shader
|
|
4
|
-
|
|
5
|
-
precision highp float;
|
|
6
|
-
|
|
7
|
-
in vec3 positions;
|
|
8
|
-
in vec3 colors;
|
|
9
|
-
in float do_scale;
|
|
10
|
-
in float mx;
|
|
11
|
-
in float my;
|
|
12
|
-
in int pie_index;
|
|
13
|
-
|
|
14
|
-
flat out int pie_index_;
|
|
15
|
-
|
|
16
|
-
uniform float scale;
|
|
17
|
-
|
|
18
|
-
out vec4 vColor;
|
|
19
|
-
|
|
20
|
-
void main(void) {
|
|
21
|
-
|
|
22
|
-
vec3 v = positions;
|
|
23
|
-
|
|
24
|
-
if (do_scale == 1.0) {
|
|
25
|
-
// Triangle vertex' are (mx,my) and two more. The
|
|
26
|
-
// latter two will be scaled so that the triangle (or the pie piece its part of) will
|
|
27
|
-
// have constant size depending on zoom.
|
|
28
|
-
float x = scale * (positions.x - mx);
|
|
29
|
-
float y = scale * (positions.y - my);
|
|
30
|
-
|
|
31
|
-
v = vec3(x + mx, y + my, 0.0);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
vec3 position_commonspace = project_position(v);
|
|
35
|
-
|
|
36
|
-
vColor = vec4(colors.rgb, 1.0);
|
|
37
|
-
|
|
38
|
-
pie_index_ = pie_index;
|
|
39
|
-
|
|
40
|
-
gl_Position = project_common_position_to_clipspace(vec4(position_commonspace, 0.0));
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ComponentStory, ComponentMeta } from "@storybook/react";
|
|
3
|
-
import { create, all } from "mathjs";
|
|
4
|
-
|
|
5
|
-
import SubsurfaceViewer from "../../SubsurfaceViewer";
|
|
6
|
-
import { default as PointsLayer } from "./pointsLayer";
|
|
7
|
-
import { default as AxesLayer } from "../axes/axesLayer";
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
component: SubsurfaceViewer,
|
|
11
|
-
title: "SubsurfaceViewer / Points Layer",
|
|
12
|
-
} as ComponentMeta<typeof SubsurfaceViewer>;
|
|
13
|
-
|
|
14
|
-
const defaultParameters = {
|
|
15
|
-
docs: {
|
|
16
|
-
inlineStories: false,
|
|
17
|
-
iframeHeight: 500,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Small example using PointsLayer.
|
|
22
|
-
const smallPointsLayer = new PointsLayer({
|
|
23
|
-
id: "small_points_layer",
|
|
24
|
-
/*eslint-disable */
|
|
25
|
-
pointsData: [ 0, 0, 5, // Vertex 1, x, y, z
|
|
26
|
-
10, 0, 5, // Vertex 2, x, y, z
|
|
27
|
-
10, 10, 5, // ...
|
|
28
|
-
0, 10, 0,
|
|
29
|
-
5, -5, 10,
|
|
30
|
-
11, -4, 6,
|
|
31
|
-
11, 0, 7,
|
|
32
|
-
17, 0, 8
|
|
33
|
-
],
|
|
34
|
-
/*eslint-enable */
|
|
35
|
-
color: [255, 100, 100],
|
|
36
|
-
pointRadius: 10,
|
|
37
|
-
radiusUnits: "pixels",
|
|
38
|
-
ZIncreasingDownwards: true,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const smallAxesLayer = new AxesLayer({
|
|
42
|
-
id: "small_axes_layer",
|
|
43
|
-
bounds: [-10, -10, 0, 20, 10, 10],
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export const SmallPointsLayer: ComponentStory<typeof SubsurfaceViewer> = (
|
|
47
|
-
args
|
|
48
|
-
) => {
|
|
49
|
-
return <SubsurfaceViewer {...args} />;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
SmallPointsLayer.args = {
|
|
53
|
-
id: "map",
|
|
54
|
-
layers: [smallAxesLayer, smallPointsLayer],
|
|
55
|
-
bounds: [-10, -10, 17, 10],
|
|
56
|
-
views: {
|
|
57
|
-
layout: [1, 1],
|
|
58
|
-
viewports: [
|
|
59
|
-
{
|
|
60
|
-
id: "view_1",
|
|
61
|
-
show3D: true,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
SmallPointsLayer.parameters = {
|
|
68
|
-
docs: {
|
|
69
|
-
...defaultParameters.docs,
|
|
70
|
-
description: {
|
|
71
|
-
story: "Point coordinates are given as native javascript array.",
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// Huge example using PointsLayer.
|
|
77
|
-
const sideSize = 10000;
|
|
78
|
-
const pointsCount = 100000;
|
|
79
|
-
|
|
80
|
-
const math = create(all, { randomSeed: "1234" });
|
|
81
|
-
|
|
82
|
-
type TRandomNumberFunc = () => number;
|
|
83
|
-
|
|
84
|
-
const randomFunc = ((): TRandomNumberFunc => {
|
|
85
|
-
if (math?.random) {
|
|
86
|
-
return () => {
|
|
87
|
-
const val = math.random?.(sideSize);
|
|
88
|
-
return val ? val : 0.0;
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return () => Math.random() * sideSize;
|
|
92
|
-
})();
|
|
93
|
-
|
|
94
|
-
const hugePointsLayer = new PointsLayer({
|
|
95
|
-
id: "huge_points_layer",
|
|
96
|
-
pointsData: Array(pointsCount * 3)
|
|
97
|
-
.fill(0)
|
|
98
|
-
.map(() => randomFunc()),
|
|
99
|
-
color: [255, 100, 100],
|
|
100
|
-
pointRadius: 1,
|
|
101
|
-
radiusUnits: "pixels",
|
|
102
|
-
ZIncreasingDownwards: true,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const hugeAxesLayer = new AxesLayer({
|
|
106
|
-
id: "huge_axes_layer",
|
|
107
|
-
bounds: [0, 0, 0, sideSize, sideSize, sideSize],
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
export const HugePointsLayer: ComponentStory<typeof SubsurfaceViewer> = (
|
|
111
|
-
args
|
|
112
|
-
) => {
|
|
113
|
-
return <SubsurfaceViewer {...args} />;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
HugePointsLayer.args = {
|
|
117
|
-
id: "map",
|
|
118
|
-
layers: [hugeAxesLayer, hugePointsLayer],
|
|
119
|
-
bounds: [0, 0, sideSize, sideSize],
|
|
120
|
-
coords: {
|
|
121
|
-
visible: false,
|
|
122
|
-
},
|
|
123
|
-
views: {
|
|
124
|
-
layout: [1, 1],
|
|
125
|
-
viewports: [
|
|
126
|
-
{
|
|
127
|
-
id: "view_1",
|
|
128
|
-
show3D: true,
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
HugePointsLayer.parameters = {
|
|
135
|
-
docs: {
|
|
136
|
-
...defaultParameters.docs,
|
|
137
|
-
description: {
|
|
138
|
-
story: "Point coordinates are randomly generated in runtime and given as native javascript array.",
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
};
|