@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.
- package/dist/package.json +5 -2
- package/package.json +6 -3
- 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,692 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
COORDINATE_SYSTEM,
|
|
3
|
-
Color,
|
|
4
|
-
CompositeLayer,
|
|
5
|
-
Viewport,
|
|
6
|
-
UpdateParameters,
|
|
7
|
-
LayersList,
|
|
8
|
-
OrthographicViewport,
|
|
9
|
-
} from "@deck.gl/core/typed";
|
|
10
|
-
import BoxLayer from "./boxLayer";
|
|
11
|
-
import { Position3D, ExtendedLayerProps } from "../utils/layerTools";
|
|
12
|
-
import { TextLayer } from "@deck.gl/layers/typed";
|
|
13
|
-
import { cloneDeep } from "lodash";
|
|
14
|
-
|
|
15
|
-
export interface AxesLayerProps<D> extends ExtendedLayerProps<D> {
|
|
16
|
-
/**
|
|
17
|
-
* [xmin, ymin, zmin, xmax, ymax, zmax]
|
|
18
|
-
* Note that z values are default interptreted as going downwards. See property "ZIncreasingDownwards".
|
|
19
|
-
* So by default zmax is expected to be bigger than zmin.
|
|
20
|
-
*/
|
|
21
|
-
bounds: [number, number, number, number, number, number];
|
|
22
|
-
labelColor?: Color;
|
|
23
|
-
labelFontSize?: number;
|
|
24
|
-
fontFamily?: string;
|
|
25
|
-
axisColor?: Color;
|
|
26
|
-
/** If true means that input z values are interpreted as depths.
|
|
27
|
-
* For example a depth of 2000 will be further down than a depth value of 1000.
|
|
28
|
-
* Default true.
|
|
29
|
-
*/
|
|
30
|
-
ZIncreasingDownwards: boolean;
|
|
31
|
-
|
|
32
|
-
// Non public properties:
|
|
33
|
-
setReportedBoundingBox?: React.Dispatch<
|
|
34
|
-
React.SetStateAction<[number, number, number, number, number, number]>
|
|
35
|
-
>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const defaultProps = {
|
|
39
|
-
"@@type": "AxesLayer",
|
|
40
|
-
name: "Axes",
|
|
41
|
-
id: "axes-layer",
|
|
42
|
-
visible: true,
|
|
43
|
-
ZIncreasingDownwards: true,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
type TextLayerData = {
|
|
47
|
-
label: string;
|
|
48
|
-
from: Position3D; // tick line start
|
|
49
|
-
to: Position3D; // tick line end
|
|
50
|
-
size: number; // font size
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default class AxesLayer extends CompositeLayer<AxesLayerProps<unknown>> {
|
|
54
|
-
rebuildData(reportBoundingBox: boolean): void {
|
|
55
|
-
const bounds = cloneDeep(this.props.bounds);
|
|
56
|
-
|
|
57
|
-
if (this.props.ZIncreasingDownwards) {
|
|
58
|
-
bounds[2] *= -1;
|
|
59
|
-
bounds[5] *= -1;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (bounds[2] > bounds[5]) {
|
|
63
|
-
// Swap z values to ensure smallest first.
|
|
64
|
-
[bounds[2], bounds[5]] = [bounds[5], bounds[2]];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (bounds[0] > bounds[3]) {
|
|
68
|
-
// Swap x values to ensure smallest first.
|
|
69
|
-
[bounds[0], bounds[3]] = [bounds[3], bounds[0]];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (bounds[1] > bounds[4]) {
|
|
73
|
-
// Swap y values to ensure smallest first.
|
|
74
|
-
[bounds[1], bounds[4]] = [bounds[4], bounds[1]];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const box_lines = GetBoxLines(bounds);
|
|
78
|
-
|
|
79
|
-
const is_orthographic =
|
|
80
|
-
this.context.viewport.constructor === OrthographicViewport;
|
|
81
|
-
|
|
82
|
-
const [tick_lines, tick_labels] = GetTickLines(
|
|
83
|
-
this.props.ZIncreasingDownwards,
|
|
84
|
-
is_orthographic,
|
|
85
|
-
bounds,
|
|
86
|
-
this.context.viewport
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const textlayerData = maketextLayerData(
|
|
90
|
-
is_orthographic,
|
|
91
|
-
tick_lines,
|
|
92
|
-
tick_labels,
|
|
93
|
-
bounds,
|
|
94
|
-
this.props.labelFontSize
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
this.setState({ box_lines, tick_lines, textlayerData });
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
typeof this.props.setReportedBoundingBox !== "undefined" &&
|
|
101
|
-
reportBoundingBox
|
|
102
|
-
) {
|
|
103
|
-
this.props.setReportedBoundingBox(bounds);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
initializeState(): void {
|
|
108
|
-
const reportBoundingBox = true;
|
|
109
|
-
this.rebuildData(reportBoundingBox);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
shouldUpdateState({
|
|
113
|
-
props,
|
|
114
|
-
oldProps,
|
|
115
|
-
context,
|
|
116
|
-
changeFlags,
|
|
117
|
-
}: UpdateParameters<this>): boolean {
|
|
118
|
-
return (
|
|
119
|
-
super.shouldUpdateState({
|
|
120
|
-
props,
|
|
121
|
-
oldProps,
|
|
122
|
-
context,
|
|
123
|
-
changeFlags,
|
|
124
|
-
}) || changeFlags.viewportChanged
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
updateState(): void {
|
|
129
|
-
const reportBoundingBox = false;
|
|
130
|
-
this.rebuildData(reportBoundingBox);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
getAnchor(d: TextLayerData, is_orthographic: boolean): string {
|
|
134
|
-
const is_xaxis = d.from[1] !== d.to[1];
|
|
135
|
-
if (is_orthographic && is_xaxis) {
|
|
136
|
-
return "middle";
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const screen_from = this.context.viewport.project(d.from);
|
|
140
|
-
const screen_to = this.context.viewport.project(d.to);
|
|
141
|
-
const is_labels = d.label !== "X" && d.label !== "Y" && d.label !== "Z"; // labels on axis or XYZ annotations
|
|
142
|
-
if (is_labels) {
|
|
143
|
-
if (screen_from[0] < screen_to[0]) {
|
|
144
|
-
return "start";
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return "end";
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
getLabelPosition(d: TextLayerData): Position3D {
|
|
152
|
-
const is_labels = d.label !== "X" && d.label !== "Y" && d.label !== "Z"; // labels on axis or XYZ annotations
|
|
153
|
-
if (is_labels) {
|
|
154
|
-
const tick_vec = [d.to[0] - d.from[0], d.to[1] - d.from[1]];
|
|
155
|
-
if (d.to[2] && d.from[2]) tick_vec.push(d.to[2] - d.from[2]);
|
|
156
|
-
|
|
157
|
-
const s = 0.5;
|
|
158
|
-
return [
|
|
159
|
-
d.to[0] + s * tick_vec[0],
|
|
160
|
-
d.to[1] + s * tick_vec[1],
|
|
161
|
-
d.to[2] + s * tick_vec[2],
|
|
162
|
-
];
|
|
163
|
-
} else {
|
|
164
|
-
// XYZ axis annotaion.
|
|
165
|
-
return d.to;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
getBaseLine(d: TextLayerData, is_orthographic: boolean): string {
|
|
170
|
-
const is_x_annotaion = d.label === "X";
|
|
171
|
-
if (is_x_annotaion) {
|
|
172
|
-
return "center";
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const is_xaxis_label = d.from[1] !== d.to[1];
|
|
176
|
-
return is_orthographic && is_xaxis_label ? "top" : "center";
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
renderLayers(): LayersList {
|
|
180
|
-
const is_orthographic =
|
|
181
|
-
this.context.viewport.constructor === OrthographicViewport;
|
|
182
|
-
|
|
183
|
-
const lines = [...this.state["box_lines"], ...this.state["tick_lines"]];
|
|
184
|
-
|
|
185
|
-
const box_layer = new BoxLayer(
|
|
186
|
-
this.getSubLayerProps({
|
|
187
|
-
lines,
|
|
188
|
-
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
189
|
-
color: this.props.axisColor || [0, 0, 0, 255],
|
|
190
|
-
})
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
const text_layer = new TextLayer(
|
|
194
|
-
this.getSubLayerProps({
|
|
195
|
-
fontFamily: this.props.fontFamily ?? "Monaco, monospace",
|
|
196
|
-
data: this.state["textlayerData"],
|
|
197
|
-
id: "text-layer",
|
|
198
|
-
pickable: true,
|
|
199
|
-
getPosition: (d: TextLayerData) => this.getLabelPosition(d),
|
|
200
|
-
getText: (d: TextLayerData) => d.label,
|
|
201
|
-
sizeUnits: "pixels",
|
|
202
|
-
getSize: (d: TextLayerData) => d.size,
|
|
203
|
-
getAngle: 0,
|
|
204
|
-
getTextAnchor: (d: TextLayerData) =>
|
|
205
|
-
this.getAnchor(d, is_orthographic),
|
|
206
|
-
getAlignmentBaseline: (d: TextLayerData) =>
|
|
207
|
-
this.getBaseLine(d, is_orthographic),
|
|
208
|
-
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
209
|
-
getColor: this.props.labelColor || [0, 0, 0, 255],
|
|
210
|
-
})
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
return [box_layer, text_layer];
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
AxesLayer.layerName = "AxesLayer";
|
|
218
|
-
AxesLayer.defaultProps = defaultProps;
|
|
219
|
-
|
|
220
|
-
//-- Local functions. -------------------------------------------------
|
|
221
|
-
|
|
222
|
-
function LineLengthInPixels(
|
|
223
|
-
p0: Position3D,
|
|
224
|
-
p1: Position3D,
|
|
225
|
-
viewport: Viewport
|
|
226
|
-
): number {
|
|
227
|
-
const screen_from = viewport.project(p0);
|
|
228
|
-
const screen_to = viewport.project(p1);
|
|
229
|
-
|
|
230
|
-
const v = [
|
|
231
|
-
screen_from[0] - screen_to[0],
|
|
232
|
-
screen_from[1] - screen_to[1],
|
|
233
|
-
screen_from[2] - screen_to[2],
|
|
234
|
-
];
|
|
235
|
-
const L = Math.sqrt(v[0] * v[0] + v[1] * v[1]); // Length of axis on screen in pixles.
|
|
236
|
-
return L;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function maketextLayerData(
|
|
240
|
-
is_orthographic: boolean,
|
|
241
|
-
tick_lines: number[],
|
|
242
|
-
tick_labels: string[],
|
|
243
|
-
bounds: [number, number, number, number, number, number],
|
|
244
|
-
labelFontSize?: number
|
|
245
|
-
): [TextLayerData] {
|
|
246
|
-
const x_min = bounds[0];
|
|
247
|
-
const x_max = bounds[3];
|
|
248
|
-
|
|
249
|
-
const y_min = bounds[1];
|
|
250
|
-
const y_max = bounds[4];
|
|
251
|
-
|
|
252
|
-
const z_min = bounds[2];
|
|
253
|
-
const z_max = bounds[5];
|
|
254
|
-
|
|
255
|
-
const dx = Math.abs(x_max - x_min);
|
|
256
|
-
const dy = Math.abs(y_max - y_min);
|
|
257
|
-
const dz = Math.abs(z_max - z_min);
|
|
258
|
-
|
|
259
|
-
const offset = ((dx + dy + dz) / 3.0) * 0.1;
|
|
260
|
-
|
|
261
|
-
const data = [
|
|
262
|
-
{
|
|
263
|
-
label: "X",
|
|
264
|
-
from: [0.0, 0.0, 0.0],
|
|
265
|
-
to: [x_max + offset, y_min, z_min],
|
|
266
|
-
size: labelFontSize ?? 26,
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
label: "Y",
|
|
270
|
-
from: [0.0, 0.0, 0.0],
|
|
271
|
-
to: [x_min, y_max + offset, z_min],
|
|
272
|
-
size: labelFontSize ?? 26,
|
|
273
|
-
},
|
|
274
|
-
];
|
|
275
|
-
|
|
276
|
-
if (!is_orthographic) {
|
|
277
|
-
const z_axis_annotaion = {
|
|
278
|
-
label: "Z",
|
|
279
|
-
from: [0.0, 0.0, 0.0],
|
|
280
|
-
to: [x_min, y_min, z_max + offset],
|
|
281
|
-
size: labelFontSize ?? 26,
|
|
282
|
-
};
|
|
283
|
-
data.push(z_axis_annotaion);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
for (let i = 0; i < tick_lines.length / 6; i++) {
|
|
287
|
-
const from = [
|
|
288
|
-
tick_lines[6 * i + 0],
|
|
289
|
-
tick_lines[6 * i + 1],
|
|
290
|
-
tick_lines[6 * i + 2],
|
|
291
|
-
];
|
|
292
|
-
const to = [
|
|
293
|
-
tick_lines[6 * i + 3],
|
|
294
|
-
tick_lines[6 * i + 4],
|
|
295
|
-
tick_lines[6 * i + 5],
|
|
296
|
-
];
|
|
297
|
-
const label = tick_labels[i];
|
|
298
|
-
|
|
299
|
-
data.push({
|
|
300
|
-
label: label,
|
|
301
|
-
from: from,
|
|
302
|
-
to: to,
|
|
303
|
-
size: labelFontSize ?? 11,
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return data as [TextLayerData];
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function GetTicks(
|
|
311
|
-
min: number,
|
|
312
|
-
max: number,
|
|
313
|
-
axis_pixel_length: number
|
|
314
|
-
): number[] {
|
|
315
|
-
let step = Math.min(Math.round(axis_pixel_length / 100) + 1, 20);
|
|
316
|
-
const range = max - min;
|
|
317
|
-
|
|
318
|
-
const delta = Math.abs(range) / step;
|
|
319
|
-
let decade = 1;
|
|
320
|
-
if (delta >= 10) {
|
|
321
|
-
const logde = Math.log10(delta);
|
|
322
|
-
const pot = Math.floor(logde);
|
|
323
|
-
decade = Math.pow(10.0, pot);
|
|
324
|
-
}
|
|
325
|
-
let scaled_delta = Math.round(delta / decade);
|
|
326
|
-
if (scaled_delta == 3) scaled_delta = 2;
|
|
327
|
-
else if (scaled_delta == 4 || scaled_delta == 6 || scaled_delta == 7)
|
|
328
|
-
scaled_delta = 5;
|
|
329
|
-
else if (scaled_delta > 7) scaled_delta = 10;
|
|
330
|
-
else if (scaled_delta < 1) scaled_delta = 1;
|
|
331
|
-
|
|
332
|
-
const incr = scaled_delta * decade;
|
|
333
|
-
const start = Math.ceil(min / incr) * incr;
|
|
334
|
-
const stop = Math.floor(max / incr) * incr;
|
|
335
|
-
const calc_step = Math.floor(Math.abs(stop - start) / incr);
|
|
336
|
-
step = calc_step > 0 ? calc_step : 0;
|
|
337
|
-
|
|
338
|
-
const ticks: number[] = [];
|
|
339
|
-
|
|
340
|
-
//ticks.push(min);
|
|
341
|
-
for (let i = 0; i <= step; i++) {
|
|
342
|
-
const x = start + i * incr;
|
|
343
|
-
ticks.push(x);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return ticks;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
function GetTickLines(
|
|
350
|
-
isZIncreasingDownwards: boolean,
|
|
351
|
-
is_orthographic: boolean,
|
|
352
|
-
bounds: [number, number, number, number, number, number],
|
|
353
|
-
viewport: Viewport
|
|
354
|
-
): [number[], string[]] {
|
|
355
|
-
const ndecimals = 0;
|
|
356
|
-
const n_minor_ticks = 3;
|
|
357
|
-
|
|
358
|
-
const x_min = bounds[0];
|
|
359
|
-
const x_max = bounds[3];
|
|
360
|
-
|
|
361
|
-
const y_min = bounds[1];
|
|
362
|
-
const y_max = bounds[4];
|
|
363
|
-
|
|
364
|
-
const z_min = bounds[2];
|
|
365
|
-
const z_max = bounds[5];
|
|
366
|
-
|
|
367
|
-
const lines: number[] = [];
|
|
368
|
-
const tick_labels: string[] = [];
|
|
369
|
-
|
|
370
|
-
// ADD TICK LINES.
|
|
371
|
-
const dx = x_max - x_min;
|
|
372
|
-
const dy = y_max - y_min;
|
|
373
|
-
const dz = z_max - z_min;
|
|
374
|
-
|
|
375
|
-
let x_tick = 0.0;
|
|
376
|
-
let y_tick = 0;
|
|
377
|
-
let z_tick = 0;
|
|
378
|
-
|
|
379
|
-
const delta = ((dx + dy + dz) / 3.0) * 0.025;
|
|
380
|
-
|
|
381
|
-
const Lz = LineLengthInPixels(
|
|
382
|
-
[x_min, y_min, z_min],
|
|
383
|
-
[x_min, y_min, z_max],
|
|
384
|
-
viewport
|
|
385
|
-
);
|
|
386
|
-
|
|
387
|
-
// Z tick marks. Only in 3D.
|
|
388
|
-
if (!is_orthographic) {
|
|
389
|
-
const z_ticks = GetTicks(z_min, z_max, Lz);
|
|
390
|
-
|
|
391
|
-
x_tick = x_min;
|
|
392
|
-
y_tick = y_min;
|
|
393
|
-
for (let i = 0; i < z_ticks.length; i++) {
|
|
394
|
-
const tick = z_ticks[i];
|
|
395
|
-
|
|
396
|
-
const sign = isZIncreasingDownwards ? -1 : 1;
|
|
397
|
-
const tick_label_num = sign * tick;
|
|
398
|
-
const label = tick_label_num.toFixed(ndecimals);
|
|
399
|
-
tick_labels.push(label);
|
|
400
|
-
|
|
401
|
-
// tick line start
|
|
402
|
-
lines.push(x_tick, y_tick, tick);
|
|
403
|
-
|
|
404
|
-
// tick line end. let tick mark point 45 degrees out from z axis.
|
|
405
|
-
const x = -delta * Math.cos(3.14157 / 4);
|
|
406
|
-
const y = -delta * Math.sin(3.14157 / 4);
|
|
407
|
-
lines.push(x_tick + x, y_tick + y, tick);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Add minor Z ticks.
|
|
411
|
-
if (z_ticks.length > 1) {
|
|
412
|
-
const tick1 = z_ticks[0];
|
|
413
|
-
const tick2 = z_ticks[1];
|
|
414
|
-
const d = (tick2 - tick1) / (n_minor_ticks + 1);
|
|
415
|
-
const z_start = tick1;
|
|
416
|
-
|
|
417
|
-
// up
|
|
418
|
-
let i = 0;
|
|
419
|
-
while (z_start + (i + 1) * d < z_max) {
|
|
420
|
-
const tick = z_start + (i + 1) * d;
|
|
421
|
-
tick_labels.push("");
|
|
422
|
-
i++;
|
|
423
|
-
// tick line start
|
|
424
|
-
lines.push(x_tick, y_tick, tick);
|
|
425
|
-
|
|
426
|
-
// tick line end.
|
|
427
|
-
const x = -0.5 * delta * Math.cos(3.14157 / 4);
|
|
428
|
-
const y = -0.5 * delta * Math.sin(3.14157 / 4);
|
|
429
|
-
lines.push(x_tick + x, y_tick + y, tick);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// down
|
|
433
|
-
i = 0;
|
|
434
|
-
while (z_start - (i + 1) * d > z_min) {
|
|
435
|
-
const tick = z_start - (i + 1) * d;
|
|
436
|
-
tick_labels.push("");
|
|
437
|
-
i++;
|
|
438
|
-
// tick line start
|
|
439
|
-
lines.push(x_tick, y_tick, tick);
|
|
440
|
-
|
|
441
|
-
// tick line end.
|
|
442
|
-
const x = -0.5 * delta * Math.cos(3.14157 / 4);
|
|
443
|
-
const y = -0.5 * delta * Math.sin(3.14157 / 4);
|
|
444
|
-
lines.push(x_tick + x, y_tick + y, tick);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// X axis labels.
|
|
450
|
-
const Lx = LineLengthInPixels(
|
|
451
|
-
[x_min, y_min, z_min],
|
|
452
|
-
[x_max, y_min, z_min],
|
|
453
|
-
viewport
|
|
454
|
-
);
|
|
455
|
-
const x_ticks = GetTicks(x_min, x_max, Lx);
|
|
456
|
-
y_tick = y_min;
|
|
457
|
-
z_tick = z_min;
|
|
458
|
-
for (let i = 0; i < x_ticks.length; i++) {
|
|
459
|
-
const tick = x_ticks[i];
|
|
460
|
-
|
|
461
|
-
const label = tick.toFixed(ndecimals);
|
|
462
|
-
tick_labels.push(label);
|
|
463
|
-
|
|
464
|
-
// tick line start
|
|
465
|
-
lines.push(tick, y_tick, z_tick);
|
|
466
|
-
|
|
467
|
-
// tick line end.
|
|
468
|
-
const z = 0.0;
|
|
469
|
-
const y = -delta;
|
|
470
|
-
lines.push(tick, y_tick + y, z_tick + z);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// Add minor X ticks.
|
|
474
|
-
if (x_ticks.length > 1) {
|
|
475
|
-
const tick1 = x_ticks[0];
|
|
476
|
-
const tick2 = x_ticks[1];
|
|
477
|
-
const d = (tick2 - tick1) / (n_minor_ticks + 1);
|
|
478
|
-
const x_start = tick1;
|
|
479
|
-
|
|
480
|
-
// up
|
|
481
|
-
let i = 0;
|
|
482
|
-
while (x_start + (i + 1) * d < x_max) {
|
|
483
|
-
const tick = x_start + (i + 1) * d;
|
|
484
|
-
tick_labels.push("");
|
|
485
|
-
i++;
|
|
486
|
-
// tick line start
|
|
487
|
-
lines.push(tick, y_tick, z_tick);
|
|
488
|
-
|
|
489
|
-
// tick line end.
|
|
490
|
-
const z = 0.0;
|
|
491
|
-
const y = -0.5 * delta;
|
|
492
|
-
lines.push(tick, y_tick + y, z_tick + z);
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// down
|
|
496
|
-
i = 0;
|
|
497
|
-
while (x_start - (i + 1) * d > x_min) {
|
|
498
|
-
const tick = x_start - (i + 1) * d;
|
|
499
|
-
tick_labels.push("");
|
|
500
|
-
i++;
|
|
501
|
-
// tick line start
|
|
502
|
-
lines.push(tick, y_tick, z_tick);
|
|
503
|
-
|
|
504
|
-
// tick line end.
|
|
505
|
-
const z = 0.0;
|
|
506
|
-
const y = -0.5 * delta;
|
|
507
|
-
lines.push(tick, y_tick + y, z_tick + z);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
// Y axis labels.
|
|
512
|
-
const Ly = LineLengthInPixels(
|
|
513
|
-
[x_min, y_min, z_min],
|
|
514
|
-
[x_min, y_max, z_min],
|
|
515
|
-
viewport
|
|
516
|
-
);
|
|
517
|
-
const y_ticks = GetTicks(y_min, y_max, Ly);
|
|
518
|
-
for (let i = 0; i < y_ticks.length; i++) {
|
|
519
|
-
const tick = y_ticks[i];
|
|
520
|
-
|
|
521
|
-
const label = tick.toFixed(ndecimals);
|
|
522
|
-
tick_labels.push(label);
|
|
523
|
-
|
|
524
|
-
const x_tick = x_min;
|
|
525
|
-
const z_tick = z_min;
|
|
526
|
-
|
|
527
|
-
// tick line start
|
|
528
|
-
lines.push(x_tick, tick, z_tick);
|
|
529
|
-
|
|
530
|
-
// tick line end.
|
|
531
|
-
const z = 0.0;
|
|
532
|
-
const x = -delta;
|
|
533
|
-
lines.push(x_tick + x, tick, z_tick + z);
|
|
534
|
-
|
|
535
|
-
// Add minor Y ticks.
|
|
536
|
-
if (y_ticks.length > 1) {
|
|
537
|
-
const tick1 = y_ticks[0];
|
|
538
|
-
const tick2 = y_ticks[1];
|
|
539
|
-
const d = (tick2 - tick1) / (n_minor_ticks + 1);
|
|
540
|
-
const y_start = tick1;
|
|
541
|
-
|
|
542
|
-
// up
|
|
543
|
-
let i = 0;
|
|
544
|
-
while (y_start + (i + 1) * d < y_max) {
|
|
545
|
-
const tick = y_start + (i + 1) * d;
|
|
546
|
-
tick_labels.push("");
|
|
547
|
-
i++;
|
|
548
|
-
// tick line start
|
|
549
|
-
lines.push(x_tick, tick, z_tick);
|
|
550
|
-
|
|
551
|
-
// tick line end.
|
|
552
|
-
const z = 0.0;
|
|
553
|
-
const x = -0.5 * delta;
|
|
554
|
-
lines.push(x_tick + x, tick, z_tick + z);
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
// down
|
|
558
|
-
i = 0;
|
|
559
|
-
while (y_start - (i + 1) * d > y_min) {
|
|
560
|
-
const tick = y_start - (i + 1) * d;
|
|
561
|
-
tick_labels.push("");
|
|
562
|
-
i++;
|
|
563
|
-
// tick line start
|
|
564
|
-
lines.push(x_tick, tick, z_tick);
|
|
565
|
-
|
|
566
|
-
// tick line end.
|
|
567
|
-
const z = 0.0;
|
|
568
|
-
const x = -0.5 * delta;
|
|
569
|
-
lines.push(x_tick + x, tick, z_tick + z);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
return [lines, tick_labels];
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
function GetBoxLines(
|
|
578
|
-
bounds: [number, number, number, number, number, number]
|
|
579
|
-
): number[] {
|
|
580
|
-
const x_min = bounds[0];
|
|
581
|
-
const x_max = bounds[3];
|
|
582
|
-
|
|
583
|
-
const y_min = bounds[1];
|
|
584
|
-
const y_max = bounds[4];
|
|
585
|
-
|
|
586
|
-
const z_min = bounds[2];
|
|
587
|
-
const z_max = bounds[5];
|
|
588
|
-
|
|
589
|
-
// ADD LINES OF BOUNDING BOX.
|
|
590
|
-
const lines = [
|
|
591
|
-
// TOP
|
|
592
|
-
x_min,
|
|
593
|
-
y_min,
|
|
594
|
-
z_min,
|
|
595
|
-
|
|
596
|
-
x_max,
|
|
597
|
-
y_min,
|
|
598
|
-
z_min,
|
|
599
|
-
|
|
600
|
-
x_min,
|
|
601
|
-
y_min,
|
|
602
|
-
z_min,
|
|
603
|
-
|
|
604
|
-
x_min,
|
|
605
|
-
y_max,
|
|
606
|
-
z_min,
|
|
607
|
-
|
|
608
|
-
x_min,
|
|
609
|
-
y_max,
|
|
610
|
-
z_min,
|
|
611
|
-
|
|
612
|
-
x_max,
|
|
613
|
-
y_max,
|
|
614
|
-
z_min,
|
|
615
|
-
|
|
616
|
-
x_max,
|
|
617
|
-
y_max,
|
|
618
|
-
z_min,
|
|
619
|
-
|
|
620
|
-
x_max,
|
|
621
|
-
y_min,
|
|
622
|
-
z_min,
|
|
623
|
-
|
|
624
|
-
// BOTTOM
|
|
625
|
-
x_min,
|
|
626
|
-
y_min,
|
|
627
|
-
z_max,
|
|
628
|
-
|
|
629
|
-
x_max,
|
|
630
|
-
y_min,
|
|
631
|
-
z_max,
|
|
632
|
-
|
|
633
|
-
x_min,
|
|
634
|
-
y_min,
|
|
635
|
-
z_max,
|
|
636
|
-
|
|
637
|
-
x_min,
|
|
638
|
-
y_max,
|
|
639
|
-
z_max,
|
|
640
|
-
|
|
641
|
-
x_min,
|
|
642
|
-
y_max,
|
|
643
|
-
z_max,
|
|
644
|
-
|
|
645
|
-
x_max,
|
|
646
|
-
y_max,
|
|
647
|
-
z_max,
|
|
648
|
-
|
|
649
|
-
x_max,
|
|
650
|
-
y_max,
|
|
651
|
-
z_max,
|
|
652
|
-
|
|
653
|
-
x_max,
|
|
654
|
-
y_min,
|
|
655
|
-
z_max,
|
|
656
|
-
|
|
657
|
-
// PILLARS
|
|
658
|
-
x_min,
|
|
659
|
-
y_min,
|
|
660
|
-
z_min,
|
|
661
|
-
|
|
662
|
-
x_min,
|
|
663
|
-
y_min,
|
|
664
|
-
z_max,
|
|
665
|
-
|
|
666
|
-
x_max,
|
|
667
|
-
y_min,
|
|
668
|
-
z_min,
|
|
669
|
-
|
|
670
|
-
x_max,
|
|
671
|
-
y_min,
|
|
672
|
-
z_max,
|
|
673
|
-
|
|
674
|
-
x_max,
|
|
675
|
-
y_max,
|
|
676
|
-
z_min,
|
|
677
|
-
|
|
678
|
-
x_max,
|
|
679
|
-
y_max,
|
|
680
|
-
z_max,
|
|
681
|
-
|
|
682
|
-
x_min,
|
|
683
|
-
y_max,
|
|
684
|
-
z_min,
|
|
685
|
-
|
|
686
|
-
x_min,
|
|
687
|
-
y_max,
|
|
688
|
-
z_max,
|
|
689
|
-
];
|
|
690
|
-
|
|
691
|
-
return lines;
|
|
692
|
-
}
|