@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,191 +0,0 @@
1
- import React from "react";
2
- import SubsurfaceViewer from "../../SubsurfaceViewer";
3
- import { ComponentStory, ComponentMeta } from "@storybook/react";
4
-
5
- import * as SurfacePoints from "./test_data/surfacePoints";
6
- import * as SurfaceTriangles from "./test_data/surfaceTriangles";
7
-
8
- export default {
9
- component: SubsurfaceViewer,
10
- title: "SubsurfaceViewer / Triangle Layer",
11
- } as ComponentMeta<typeof SubsurfaceViewer>;
12
-
13
- const defaultParameters = {
14
- docs: {
15
- inlineStories: false,
16
- iframeHeight: 500,
17
- },
18
- };
19
-
20
- const northArrowLayer = {
21
- "@@type": "NorthArrow3DLayer",
22
- id: "north-arrow-layer",
23
- };
24
-
25
- // Small example using triangleLayer.
26
- const triangleLayer = {
27
- "@@type": "TriangleLayer",
28
- id: "triangle-layer",
29
-
30
- /*eslint-disable */
31
- pointsData: [ 0, 0, 5, // Vertex 1, x, y, z
32
- 10, 0, 5, // Vertex 2, x, y, z
33
- 10, 10, 5, // ...
34
- 0, 10, 0,
35
- 5, -5, 10,
36
- 11, -4, 6,
37
- 11, 0, 7,
38
- 17, 0, 8
39
- ],
40
-
41
-
42
- triangleData: [2, 1, 0, // Indexs' to first triangle.
43
- 3, 2, 0, // ...
44
- 1, 4, 0,
45
- 6, 7, 5],
46
-
47
-
48
- color: [100, 100, 255], // Surface color.
49
- gridLines: true, // If true will draw lines around triangles.
50
- material: true, // If true will use triangle normals for shading.
51
- smoothShading: true, // If true will use vertex calculated mean normals for shading.
52
- ZIncreasingDownwards: true,
53
- //contours: [0, 1], // If used will display contour lines.
54
- /*eslint-enable */
55
- };
56
-
57
- const axesLayer = {
58
- "@@type": "AxesLayer",
59
- id: "axes_small",
60
- bounds: [-10, -10, 0, 20, 10, 10],
61
- };
62
-
63
- export const SmallTriangleLayer: ComponentStory<typeof SubsurfaceViewer> = (
64
- args
65
- ) => {
66
- return <SubsurfaceViewer {...args} />;
67
- };
68
-
69
- SmallTriangleLayer.args = {
70
- id: "map",
71
- layers: [axesLayer, triangleLayer, northArrowLayer],
72
- bounds: [-10, -10, 17, 10],
73
- views: {
74
- layout: [1, 1],
75
- viewports: [
76
- {
77
- id: "view_1",
78
- show3D: true,
79
- },
80
- ],
81
- },
82
- };
83
-
84
- SmallTriangleLayer.parameters = {
85
- docs: {
86
- ...defaultParameters.docs,
87
- description: {
88
- story: "Both mesh and property data given as native javascript arrays (as opposed to URL).",
89
- },
90
- },
91
- };
92
-
93
- const flipOrientation = (triangles: number[]) => {
94
- const res: number[] = [];
95
- for (let i = 0; i < triangles.length; i += 3) {
96
- res.push(triangles[i]);
97
- res.push(triangles[i + 2]);
98
- res.push(triangles[i + 1]);
99
- }
100
- return res;
101
- };
102
-
103
- const shiftPointsByZ = (points: number[], shift: number) => {
104
- const res: number[] = [];
105
- for (let i = 0; i < points.length; i += 3) {
106
- res.push(points[i]);
107
- res.push(points[i + 1]);
108
- res.push(points[i + 2] + shift);
109
- }
110
- return res;
111
- };
112
-
113
- const upperSurfaceLayer = {
114
- "@@type": "TriangleLayer",
115
- id: "upper_surface_layer",
116
-
117
- /*eslint-disable */
118
- pointsData: SurfacePoints.default,
119
- triangleData: SurfaceTriangles.default,
120
-
121
- color: [100, 100, 255], // Surface color.
122
- gridLines: true, // If true will draw lines around triangles.
123
- material: {
124
- ambient: 0.35,
125
- diffuse: 0.6,
126
- shininess: 100,
127
- specularColor: [255, 255, 255]
128
- }, // If true will use triangle normals for shading.
129
- smoothShading: true, // If true will use vertex calculated mean normals for shading.
130
- ZIncreasingDownwards: true,
131
- debug: true
132
- /*eslint-enable */
133
- };
134
-
135
- const lowerSurfaceLayer = {
136
- "@@type": "TriangleLayer",
137
- id: "lowers_surface_layer",
138
-
139
- /*eslint-disable */
140
- pointsData: shiftPointsByZ(SurfacePoints.default, 1000),
141
- triangleData: flipOrientation(SurfaceTriangles.default),
142
-
143
- color: [100, 255, 100], // Surface color.
144
- gridLines: true, // If true will draw lines around triangles.
145
- material: {
146
- ambient: 0.35,
147
- diffuse: 0.6,
148
- shininess: 100,
149
- specularColor: [255, 255, 255]
150
- }, // If true will use triangle normals for shading.
151
- smoothShading: true, // If true will use vertex calculated mean normals for shading.
152
- ZIncreasingDownwards: true,
153
- debug: true
154
- /*eslint-enable */
155
- };
156
-
157
- const surfaceAxesLayer = {
158
- "@@type": "AxesLayer",
159
- id: "mandaros_axes_small",
160
- bounds: [-2000, -2000, 1500, 2500, 2000, 3000],
161
- };
162
-
163
- export const TwoSideLighting: ComponentStory<typeof SubsurfaceViewer> = (
164
- args
165
- ) => {
166
- return <SubsurfaceViewer {...args} />;
167
- };
168
-
169
- TwoSideLighting.args = {
170
- id: "map",
171
- layers: [surfaceAxesLayer, upperSurfaceLayer, lowerSurfaceLayer],
172
- bounds: [-2000, -2000, 2500, 2000],
173
- views: {
174
- layout: [1, 1],
175
- viewports: [
176
- {
177
- id: "view_1",
178
- show3D: true,
179
- },
180
- ],
181
- },
182
- };
183
-
184
- TwoSideLighting.parameters = {
185
- docs: {
186
- ...defaultParameters.docs,
187
- description: {
188
- story: "Both mesh and property data given as native javascript arrays (as opposed to URL).",
189
- },
190
- },
191
- };
@@ -1,273 +0,0 @@
1
- import { CompositeLayer, UpdateParameters } from "@deck.gl/core/typed";
2
- import PrivateTriangleLayer, { Material } from "./privateTriangleLayer";
3
- import { ExtendedLayerProps } from "../utils/layerTools";
4
- import { isEqual } from "lodash";
5
- import { makeFullMesh } from "./webworker";
6
- import React from "react";
7
-
8
- export type Params = {
9
- vertexArray: Float32Array;
10
- indexArray: Uint32Array;
11
- smoothShading: boolean;
12
- displayNormals: boolean;
13
- };
14
-
15
- async function loadData(
16
- pointsData: string | number[],
17
- triangleData: string | number[],
18
- ZIncreasingDownwards: boolean
19
- ) {
20
- // Keep
21
- //const t0 = performance.now();
22
-
23
- //-- Vertexes --
24
- let vertexArray: Float32Array = new Float32Array();
25
- if (Array.isArray(pointsData)) {
26
- // Input data is native javascript array.
27
- vertexArray = new Float32Array(pointsData);
28
- } else {
29
- // Input data is an URL.
30
- const response_mesh = await fetch(pointsData);
31
- if (!response_mesh.ok) {
32
- console.error("Could not load vertex data");
33
- }
34
-
35
- const blob_mesh = await response_mesh.blob();
36
-
37
- // Load as binary array of floats.
38
- const buffer = await blob_mesh.arrayBuffer();
39
- vertexArray = new Float32Array(buffer);
40
- }
41
-
42
- if (ZIncreasingDownwards) {
43
- for (let i = 0; i < pointsData.length / 3; i++) {
44
- vertexArray[3 * i + 2] *= -1;
45
- }
46
- }
47
-
48
- //-- Triangle indexes --
49
- let indexArray: Uint32Array = new Uint32Array();
50
- if (Array.isArray(triangleData)) {
51
- // Input data is native javascript array.
52
- indexArray = new Uint32Array(triangleData);
53
- } else {
54
- // Input data is an URL.
55
- const response_mesh = await fetch(triangleData);
56
- if (!response_mesh.ok) {
57
- console.error("Could not load triangle index data");
58
- }
59
-
60
- const blob_mesh = await response_mesh.blob();
61
-
62
- // Load as binary array of floats.
63
- const buffer = await blob_mesh.arrayBuffer();
64
- indexArray = new Uint32Array(buffer);
65
- }
66
-
67
- //const t1 = performance.now();
68
- // Keep this.
69
- //console.log(`Task loading took ${(t1 - t0) * 0.001} seconds.`);
70
-
71
- return Promise.all([vertexArray, indexArray]);
72
- }
73
-
74
- export interface TriangleLayerProps<D> extends ExtendedLayerProps<D> {
75
- /** Triangle vertexes.
76
- * Either an URL or an array of numbers.
77
- */
78
- pointsData: string | number[];
79
-
80
- triangleData: string | number[];
81
-
82
- color: [number, number, number];
83
-
84
- /** Contourlines reference point and interval.
85
- */
86
- contours: [number, number];
87
-
88
- /** Enable lines around triangles.
89
- * default: false.
90
- */
91
- gridLines: boolean;
92
-
93
- /** Surface material properties.
94
- * material: true = default material, coloring depends on surface orientation and lighting.
95
- * false = no material, coloring is independent on surface orientation and lighting.
96
- * or full spec:
97
- * material: {
98
- * ambient: 0.35,
99
- * diffuse: 0.6,
100
- * shininess: 32,
101
- * specularColor: [255, 255, 255],
102
- * }
103
- * Default value: true.
104
- */
105
- material: Material;
106
-
107
- /** Will calculate normals for each vertex and enable phong shading.
108
- * If not set the shader will calculate constant normal for each triangle.
109
- * Only has effect if "material" is not set to false.
110
- */
111
- smoothShading: boolean;
112
-
113
- /** Enable/disable depth testing when rendering layer. Default true.
114
- */
115
- depthTest: boolean;
116
-
117
- /** If true means that input z values are interpreted as depths.
118
- * For example depth of z = 1000 corresponds to -1000 on the z axis. Default true.
119
- */
120
- ZIncreasingDownwards: boolean;
121
-
122
- /** If true will display normals on all vertex's
123
- */
124
- debug: boolean;
125
-
126
- // Non public properties:
127
- setReportedBoundingBox?: React.Dispatch<
128
- React.SetStateAction<[number, number, number, number, number, number]>
129
- >;
130
- }
131
-
132
- const defaultProps = {
133
- "@@type": "TriangleLayer",
134
- name: "TriangleLayer",
135
- id: "triangle-layer",
136
- pickable: true,
137
- visible: true,
138
- contours: [-1.0, -1.0],
139
- color: [100, 100, 255],
140
- gridLines: false,
141
- smoothShading: true,
142
- material: true,
143
- depthTest: true,
144
- ZIncreasingDownwards: true,
145
- debug: false,
146
- };
147
-
148
- export default class TriangleLayer extends CompositeLayer<
149
- TriangleLayerProps<unknown>
150
- > {
151
- rebuildData(reportBoundingBox: boolean): void {
152
- const pointsData = this.props.pointsData;
153
- const triangleData = this.props.triangleData;
154
-
155
- const p = loadData(
156
- pointsData,
157
- triangleData,
158
- this.props.ZIncreasingDownwards
159
- );
160
-
161
- p.then(([vertexArray, indexArray]) => {
162
- // Using inline web worker for calculating the triangle mesh from
163
- // loaded input data so not to halt the GUI thread.
164
- const blob = new Blob(
165
- ["self.onmessage = ", makeFullMesh.toString()],
166
- { type: "text/javascript" }
167
- );
168
- const url = URL.createObjectURL(blob);
169
- const webWorker = new Worker(url);
170
-
171
- const webworkerParams: Params = {
172
- vertexArray,
173
- indexArray,
174
- smoothShading: this.props.smoothShading,
175
- displayNormals: this.props.debug,
176
- };
177
-
178
- webWorker.postMessage(webworkerParams);
179
- webWorker.onmessage = (e) => {
180
- const [geometryTriangles, geometryLines] = e.data;
181
-
182
- this.setState({
183
- geometryTriangles,
184
- geometryLines,
185
- });
186
-
187
- if (
188
- typeof this.props.setReportedBoundingBox !== "undefined" &&
189
- reportBoundingBox
190
- ) {
191
- let xmax = -99999999;
192
- let xmin = 99999999;
193
-
194
- let ymax = -99999999;
195
- let ymin = 99999999;
196
-
197
- let zmax = -99999999;
198
- let zmin = 99999999;
199
-
200
- for (let i = 0; i < vertexArray.length / 3; i++) {
201
- xmax = vertexArray[3 * i + 0] > xmax ? vertexArray[3 * i + 0] : xmax; //eslint-disable-line
202
- xmin = vertexArray[3 * i + 0] < xmin ? vertexArray[3 * i + 0] : xmin; //eslint-disable-line
203
-
204
- ymax = vertexArray[3 * i + 1] > ymax ? vertexArray[3 * i + 1] : ymax; //eslint-disable-line
205
- ymin = vertexArray[3 * i + 1] < ymin ? vertexArray[3 * i + 1] : ymin; //eslint-disable-line
206
-
207
- zmax = vertexArray[3 * i + 2] > zmax ? vertexArray[3 * i + 2] : zmax; //eslint-disable-line
208
- zmin = vertexArray[3 * i + 2] < zmin ? vertexArray[3 * i + 2] : zmin; //eslint-disable-line
209
- }
210
-
211
- if (this.props.ZIncreasingDownwards) {
212
- const tmp = zmin;
213
- zmin = zmax;
214
- zmax = tmp;
215
- }
216
-
217
- this.props.setReportedBoundingBox([
218
- xmin,
219
- ymin,
220
- zmin,
221
- xmax,
222
- ymax,
223
- zmax,
224
- ]);
225
- }
226
-
227
- webWorker.terminate();
228
- };
229
- });
230
- }
231
-
232
- initializeState(): void {
233
- const reportBoundingBox = true;
234
- this.rebuildData(reportBoundingBox);
235
- }
236
-
237
- updateState({ props, oldProps }: UpdateParameters<TriangleLayer>): void {
238
- const needs_reload =
239
- !isEqual(props.debug, oldProps.debug) ||
240
- !isEqual(props.pointsData, oldProps.pointsData) ||
241
- !isEqual(props.triangleData, oldProps.triangleData) ||
242
- !isEqual(props.ZIncreasingDownwards, oldProps.ZIncreasingDownwards);
243
-
244
- if (needs_reload) {
245
- const reportBoundingBox = false;
246
- this.rebuildData(reportBoundingBox);
247
- }
248
- }
249
-
250
- renderLayers(): [PrivateTriangleLayer?] {
251
- if (Object.keys(this.state).length === 0) {
252
- return [];
253
- }
254
-
255
- const layer = new PrivateTriangleLayer(
256
- this.getSubLayerProps({
257
- geometryTriangles: this.state["geometryTriangles"],
258
- geometryLines: this.state["geometryLines"],
259
- pickable: this.props.pickable,
260
- contours: this.props.contours,
261
- gridLines: this.props.gridLines,
262
- color: this.props.color,
263
- material: this.props.material,
264
- smoothShading: this.props.smoothShading,
265
- depthTest: this.props.depthTest,
266
- })
267
- );
268
- return [layer];
269
- }
270
- }
271
-
272
- TriangleLayer.layerName = "TriangleLayer";
273
- TriangleLayer.defaultProps = defaultProps;
@@ -1,35 +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
-
12
- // Outputs to fragment shader
13
- //out vec2 vTexCoord;
14
- out vec3 cameraPosition;
15
- out vec3 normals_commonspace;
16
- out vec4 position_commonspace;
17
- out vec3 worldPos;
18
- out float property;
19
-
20
-
21
- void main(void) {
22
- cameraPosition = project_uCameraPosition;
23
-
24
- worldPos = positions;
25
-
26
- normals_commonspace = normals;
27
-
28
- property = properties;
29
-
30
- position_commonspace = vec4(project_position(positions), 0.0);
31
- gl_Position = project_common_position_to_clipspace(position_commonspace);
32
- }
33
- `;
34
-
35
- 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,165 +0,0 @@
1
- import { GeometryTriangles, GeometryLines } from "./privateTriangleLayer";
2
- import { Params } from "./triangleLayer";
3
-
4
- type Vec = [number, number, number];
5
-
6
- export function makeFullMesh(e: { data: Params }): void {
7
- const params = e.data;
8
-
9
- const t0 = performance.now();
10
-
11
- function crossProduct(a: Vec, b: Vec): Vec {
12
- const c = [
13
- a[1] * b[2] - a[2] * b[1],
14
- a[2] * b[0] - a[0] * b[2],
15
- a[0] * b[1] - a[1] * b[0],
16
- ];
17
- return c as Vec;
18
- }
19
-
20
- function normalize(a: Vec): void {
21
- const L = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
22
- a[0] /= L;
23
- a[1] /= L;
24
- a[2] /= L;
25
- }
26
-
27
- const line_positions: number[] = [];
28
-
29
- const vertexArray = params.vertexArray;
30
- const indexArray = params.indexArray;
31
-
32
- const ntriangles = indexArray.length / 3;
33
- const nvertices = vertexArray.length / 3;
34
- const trianglesNormals = Array(ntriangles * 3).fill(0);
35
- const vertexsNormals = Array(vertexArray.length).fill(0);
36
-
37
- // Generate lines around each triangle and one normal for each triangle.
38
- for (let t_no = 0; t_no < ntriangles; t_no++) {
39
- let indx = indexArray[3 * t_no + 0];
40
- const x0 = vertexArray[3 * indx + 0];
41
- const y0 = vertexArray[3 * indx + 1];
42
- const z0 = vertexArray[3 * indx + 2];
43
-
44
- indx = indexArray[3 * t_no + 1];
45
- const x1 = vertexArray[3 * indx + 0];
46
- const y1 = vertexArray[3 * indx + 1];
47
- const z1 = vertexArray[3 * indx + 2];
48
-
49
- indx = indexArray[3 * t_no + 2];
50
- const x2 = vertexArray[3 * indx + 0];
51
- const y2 = vertexArray[3 * indx + 1];
52
- const z2 = vertexArray[3 * indx + 2];
53
-
54
- // Triangle lines.
55
- line_positions.push(x0, y0, z0);
56
- line_positions.push(x1, y1, z1);
57
-
58
- line_positions.push(x0, y0, z0);
59
- line_positions.push(x2, y2, z2);
60
-
61
- line_positions.push(x1, y1, z1);
62
- line_positions.push(x2, y2, z2);
63
-
64
- // Normal.
65
- const v1 = [x2 - x0, y2 - y0, z2 - z0] as Vec;
66
- const v2 = [x2 - x1, y2 - y1, z2 - z1] as Vec;
67
- const normal = crossProduct(v2, v1);
68
-
69
- trianglesNormals[3 * t_no + 0] = normal[0];
70
- trianglesNormals[3 * t_no + 1] = normal[1];
71
- trianglesNormals[3 * t_no + 2] = normal[2];
72
- }
73
-
74
- // For each vertex keep a list of which triangles it is part of.
75
- const vertexTrianglesArray = Array(vertexArray.length / 3);
76
- for (let i = 0; i < vertexTrianglesArray.length; i++) {
77
- vertexTrianglesArray[i] = new Array(0);
78
- }
79
-
80
- for (let t_no = 0; t_no < ntriangles; t_no++) {
81
- const v1_idx = indexArray[3 * t_no + 0];
82
- vertexTrianglesArray[v1_idx].push(t_no);
83
-
84
- const v2_idx = indexArray[3 * t_no + 1];
85
- vertexTrianglesArray[v2_idx].push(t_no);
86
-
87
- const v3_idx = indexArray[3 * t_no + 2];
88
- vertexTrianglesArray[v3_idx].push(t_no);
89
- }
90
-
91
- // The normal for each vertex is the mean of the normals belonging to the triangles that
92
- // share this vertex.
93
- for (let vertex_no = 0; vertex_no < nvertices; vertex_no++) {
94
- const n_triangles = vertexTrianglesArray[vertex_no].length; // No triangles this vertex is part of. Will be at leat 1.
95
- const t0 = vertexTrianglesArray[vertex_no][0]; // first triangle
96
- const normal_mean = [
97
- trianglesNormals[3 * t0 + 0],
98
- trianglesNormals[3 * t0 + 1],
99
- trianglesNormals[3 * t0 + 2],
100
- ];
101
- // possible rest of triangles
102
- for (let t_no = 1; t_no < n_triangles; t_no++) {
103
- const t = vertexTrianglesArray[vertex_no][t_no];
104
- const normal = [
105
- trianglesNormals[3 * t + 0],
106
- trianglesNormals[3 * t + 1],
107
- trianglesNormals[3 * t + 2],
108
- ];
109
-
110
- normal_mean[0] += normal[0];
111
- normal_mean[1] += normal[1];
112
- normal_mean[2] += normal[2];
113
- }
114
-
115
- normalize(normal_mean as Vec);
116
-
117
- vertexsNormals[3 * vertex_no + 0] = normal_mean[0];
118
- vertexsNormals[3 * vertex_no + 1] = normal_mean[1];
119
- vertexsNormals[3 * vertex_no + 2] = normal_mean[2];
120
-
121
- // Debug. Verify normal calculations by displaying normals.
122
- const isDebug = params.displayNormals;
123
- if (isDebug) {
124
- const x0 = vertexArray[3 * vertex_no + 0];
125
- const y0 = vertexArray[3 * vertex_no + 1];
126
- const z0 = vertexArray[3 * vertex_no + 2];
127
-
128
- const scale = 50;
129
- const x1 = x0 + normal_mean[0] * scale;
130
- const y1 = y0 + normal_mean[1] * scale;
131
- const z1 = z0 + normal_mean[2] * scale;
132
-
133
- line_positions.push(x0, y0, z0);
134
- line_positions.push(x1, y1, z1);
135
- }
136
- }
137
-
138
- const geometryTriangles: GeometryTriangles = {
139
- drawMode: 4, // corresponds to GL.TRIANGLES,
140
- attributes: {
141
- positions: { value: new Float32Array(vertexArray), size: 3 },
142
- normals: { value: new Float32Array(vertexsNormals), size: 3 },
143
- vertex_indexs: { value: new Int32Array(indexArray), size: 1 },
144
- },
145
- vertexCount: indexArray.length,
146
- indices: { value: new Uint32Array(indexArray), size: 1 },
147
- };
148
-
149
- const geometryLines: GeometryLines = {
150
- drawMode: 1, // corresponds to GL.LINES,
151
- attributes: {
152
- positions: { value: new Float32Array(line_positions), size: 3 },
153
- },
154
- vertexCount: line_positions.length / 3,
155
- };
156
-
157
- const t1 = performance.now();
158
- console.debug(`Task makeMesh took ${(t1 - t0) * 0.001} seconds.`);
159
-
160
- // Note: typescript gives this error "error TS2554: Expected 2-3 arguments, but got 1."
161
- // Disabling this for now as the second argument should be optional.
162
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
163
- // @ts-ignore
164
- postMessage([geometryTriangles, geometryLines]);
165
- }
@@ -1,4 +0,0 @@
1
- declare module "*.glsl" {
2
- const value: string;
3
- export default value;
4
- }