@webviz/subsurface-viewer 0.9.1 → 0.10.0

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 (37) hide show
  1. package/dist/SubsurfaceViewer.d.ts +2 -5
  2. package/dist/SubsurfaceViewer.js +1 -1
  3. package/dist/SubsurfaceViewer.js.map +1 -1
  4. package/dist/components/Map.d.ts +15 -5
  5. package/dist/components/Map.js +121 -136
  6. package/dist/components/Map.js.map +1 -1
  7. package/dist/layers/axes/axesLayer.d.ts +3 -2
  8. package/dist/layers/axes/axesLayer.js +2 -2
  9. package/dist/layers/axes/axesLayer.js.map +1 -1
  10. package/dist/layers/colormap/colormapLayer.d.ts +3 -1
  11. package/dist/layers/colormap/colormapLayer.js +4 -3
  12. package/dist/layers/colormap/colormapLayer.js.map +1 -1
  13. package/dist/layers/grid3d/grid3dLayer.d.ts +3 -1
  14. package/dist/layers/grid3d/grid3dLayer.js +2 -2
  15. package/dist/layers/grid3d/grid3dLayer.js.map +1 -1
  16. package/dist/layers/hillshading2d/hillshading2dLayer.d.ts +3 -1
  17. package/dist/layers/hillshading2d/hillshading2dLayer.js +4 -3
  18. package/dist/layers/hillshading2d/hillshading2dLayer.js.map +1 -1
  19. package/dist/layers/map/mapLayer.d.ts +3 -1
  20. package/dist/layers/map/mapLayer.js +4 -9
  21. package/dist/layers/map/mapLayer.js.map +1 -1
  22. package/dist/layers/points/pointsLayer.d.ts +2 -1
  23. package/dist/layers/points/pointsLayer.js +2 -2
  24. package/dist/layers/points/pointsLayer.js.map +1 -1
  25. package/dist/layers/polylines/polylinesLayer.d.ts +2 -1
  26. package/dist/layers/polylines/polylinesLayer.js +2 -2
  27. package/dist/layers/polylines/polylinesLayer.js.map +1 -1
  28. package/dist/layers/terrain/map3DLayer.d.ts +3 -1
  29. package/dist/layers/terrain/map3DLayer.js +4 -9
  30. package/dist/layers/terrain/map3DLayer.js.map +1 -1
  31. package/dist/layers/triangle/triangleLayer.d.ts +2 -1
  32. package/dist/layers/triangle/triangleLayer.js +4 -9
  33. package/dist/layers/triangle/triangleLayer.js.map +1 -1
  34. package/dist/layers/wells/wellsLayer.d.ts +3 -0
  35. package/dist/layers/wells/wellsLayer.js +2 -2
  36. package/dist/layers/wells/wellsLayer.js.map +1 -1
  37. package/package.json +1 -1
@@ -38,6 +38,8 @@ export interface SubsurfaceViewerProps {
38
38
  resources?: Record<string, unknown>;
39
39
  layers?: Record<string, unknown>[] | LayersList;
40
40
  bounds?: [number, number, number, number] | BoundsAccessor;
41
+ cameraPosition?: ViewStateType | undefined;
42
+ triggerHome?: number;
41
43
  views?: ViewsType;
42
44
  coords?: {
43
45
  visible?: boolean | null;
@@ -69,10 +71,6 @@ export interface SubsurfaceViewerProps {
69
71
  isRenderedCallback?: (arg: boolean) => void;
70
72
  onDragStart?: (info: PickingInfo, event: MjolnirGestureEvent) => void;
71
73
  onDragEnd?: (info: PickingInfo, event: MjolnirGestureEvent) => void;
72
- /**
73
- * If changed will reset camera to default position.
74
- */
75
- triggerHome?: number;
76
74
  triggerResetMultipleWells?: number;
77
75
  /**
78
76
  * Range selection of the current well
@@ -85,7 +83,6 @@ export interface SubsurfaceViewerProps {
85
83
  * Override default tooltip with a callback.
86
84
  */
87
85
  getTooltip?: TooltipCallback;
88
- cameraPosition?: ViewStateType | undefined;
89
86
  lights?: LightsType;
90
87
  children?: React.ReactNode;
91
88
  }
@@ -3,7 +3,7 @@ import Map, { jsonToObject } from "./components/Map";
3
3
  import React from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import convert from "convert-units";
6
- const SubsurfaceViewer = ({ id, resources, layers, bounds, views, coords, scale, coordinateUnit, colorTables, editedData, setProps, checkDatafileSchema, onMouseEvent, selection, getTooltip, cameraPosition, getCameraPosition, isRenderedCallback: isRenderedCallback, onDragStart, onDragEnd, triggerHome, triggerResetMultipleWells, lights, children, }) => {
6
+ const SubsurfaceViewer = ({ id, resources, layers, bounds, cameraPosition, triggerHome, views, coords, scale, coordinateUnit, colorTables, editedData, setProps, checkDatafileSchema, onMouseEvent, selection, getTooltip, getCameraPosition, isRenderedCallback, onDragStart, onDragEnd, triggerResetMultipleWells, lights, children, }) => {
7
7
  // Contains layers data received from map layers by user interaction
8
8
  const [layerEditedData, setLayerEditedData] = React.useState(editedData);
9
9
  const [layerInstances, setLayerInstances] = React.useState([]);
@@ -1 +1 @@
1
- {"version":3,"file":"SubsurfaceViewer.js","sourceRoot":"","sources":["../src/SubsurfaceViewer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAQ5C,OAAO,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAGnC,OAAO,OAAO,MAAM,eAAe,CAAC;AA4GpC,MAAM,gBAAgB,GAAoC,CAAC,EACvD,EAAE,EACF,SAAS,EACT,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,EACL,cAAc,EACd,WAAW,EACX,UAAU,EACV,QAAQ,EACR,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAAE,kBAAkB,EACtC,WAAW,EACX,SAAS,EACT,WAAW,EACX,yBAAyB,EACzB,MAAM,EACN,QAAQ,GACY,EAAE,EAAE;IACxB,oEAAoE;IACpE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEzE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAa,EAAE,CAAC,CAAC;IAE3E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,CAAC,MAAM,EAAE;YACT,iBAAiB,CAAC,EAAE,CAAC,CAAC;YACtB,OAAO;SACV;QAED,IAA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ACH,SAAS,EAAE,SAAS,CAAC,MAAM;KAC9B,CAAC;IAEF;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC;QACnB;;WAEG;QACH,OAAO,EAAE,SAAS,CAAC,IAAI;QACvB;;WAEG;QACH,cAAc,EAAE,SAAS,CAAC,MAAM;QAChC;;WAEG;QACH,YAAY,EAAE,SAAS,CAAC,MAAM;QAC9B;;WAEG;QACH,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC;KAC9C,CAAC;IAEF;;;OAGG;IACH,cAAc,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE,CAAC;IAE1D;;OAEG;IACH,WAAW,EAAE,SAAS,CAAC,KAAK;IAE5B;;OAEG;IACH,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC;IAE7C;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC,IAAI;IAExB;;OAEG;IACH,mBAAmB,EAAE,SAAS,CAAC,IAAI;CACtC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -8,6 +8,9 @@ import type { MjolnirGestureEvent } from "mjolnir.js";
8
8
  * 3D bounding box defined as [xmin, ymin, zmin, xmax, ymax, zmax].
9
9
  */
10
10
  export type BoundingBox3D = [number, number, number, number, number, number];
11
+ export type ReportBoundingBoxAction = {
12
+ layerBoundingBox: BoundingBox3D;
13
+ };
11
14
  /**
12
15
  * Type of the function returning coordinate boundary for the view defined as [left, bottom, right, top].
13
16
  */
@@ -98,8 +101,20 @@ export interface MapProps {
98
101
  layers?: LayersList;
99
102
  /**
100
103
  * Coordinate boundary for the view defined as [left, bottom, right, top].
104
+ * Should be used for 2D view only.
101
105
  */
102
106
  bounds?: [number, number, number, number] | BoundsAccessor;
107
+ /**
108
+ * Camera state for the view defined as [left, bottom, right, top].
109
+ * Should be used for 3D view only.
110
+ * If the zoom is given as a 3D bounding box, the camera state is computed to
111
+ * display the full box.
112
+ */
113
+ cameraPosition?: ViewStateType;
114
+ /**
115
+ * If changed will reset view settings (bounds or camera) to default position.
116
+ */
117
+ triggerHome?: number;
103
118
  /**
104
119
  * Views configuration for map. If not specified, all the layers will be
105
120
  * displayed in a single 2D viewport
@@ -156,10 +171,6 @@ export interface MapProps {
156
171
  isRenderedCallback?: (arg: boolean) => void;
157
172
  onDragStart?: (info: PickingInfo, event: MjolnirGestureEvent) => void;
158
173
  onDragEnd?: (info: PickingInfo, event: MjolnirGestureEvent) => void;
159
- /**
160
- * If changed will reset camera to default position.
161
- */
162
- triggerHome?: number;
163
174
  triggerResetMultipleWells?: number;
164
175
  selection?: {
165
176
  well: string | undefined;
@@ -168,7 +179,6 @@ export interface MapProps {
168
179
  lights?: LightsType;
169
180
  children?: React.ReactNode;
170
181
  getTooltip?: TooltipCallback;
171
- cameraPosition?: ViewStateType;
172
182
  }
173
183
  export interface MapMouseEvent {
174
184
  type: "click" | "hover" | "contextmenu";
@@ -1,7 +1,7 @@
1
1
  import { JSONConfiguration, JSONConverter } from "@deck.gl/json/typed";
2
2
  import DeckGL from "@deck.gl/react/typed";
3
3
  import { OrthographicView, OrbitView, PointLight } from "@deck.gl/core/typed";
4
- import React, { useEffect, useState, useCallback, useRef } from "react";
4
+ import React, { useEffect, useState, useCallback, useMemo } from "react";
5
5
  import JSON_CONVERTER_CONFIG from "../utils/configuration";
6
6
  import InfoCard from "./InfoCard";
7
7
  import DistanceScale from "./DistanceScale";
@@ -112,6 +112,9 @@ function addBoundingBoxes(b1, b2) {
112
112
  const zmax = Math.max(b1[5], b2[5]);
113
113
  return [xmin, ymin, zmin, xmax, ymax, zmax];
114
114
  }
115
+ function mapBoundingBoxReducer(mapBoundingBox, action) {
116
+ return addBoundingBoxes(mapBoundingBox, action.layerBoundingBox);
117
+ }
115
118
  function boundingBoxCenter(box) {
116
119
  const xmin = box[0];
117
120
  const ymin = box[1];
@@ -140,8 +143,8 @@ function compareViewsProp(views) {
140
143
  return JSON.stringify(copy);
141
144
  }
142
145
  export function useHoverInfo() {
143
- const [hoverInfo, setHoverInfo] = React.useState([]);
144
- const callback = React.useCallback((pickEvent) => {
146
+ const [hoverInfo, setHoverInfo] = useState([]);
147
+ const callback = useCallback((pickEvent) => {
145
148
  setHoverInfo(pickEvent.infos);
146
149
  }, []);
147
150
  return [hoverInfo, callback];
@@ -168,7 +171,7 @@ function adjustCameraTarget(viewStates, scale, newScale) {
168
171
  }
169
172
  return vs;
170
173
  }
171
- function calculateZoomFromBBox3D(camera, deck) {
174
+ function calculateZoomFromBBox3D(camera, size) {
172
175
  const DEGREES_TO_RADIANS = Math.PI / 180;
173
176
  const RADIANS_TO_DEGREES = 180 / Math.PI;
174
177
  const IDENTITY = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
@@ -176,13 +179,11 @@ function calculateZoomFromBBox3D(camera, deck) {
176
179
  if (typeof camera_ === "undefined" || !Array.isArray(camera_.zoom)) {
177
180
  return camera;
178
181
  }
179
- if (!(deck === null || deck === void 0 ? void 0 : deck.width) || !(deck === null || deck === void 0 ? void 0 : deck.height)) {
182
+ if (size.width === 0 || size.height === 0) {
180
183
  camera_.zoom = 0;
181
184
  camera_.target = [0, 0, 0];
182
185
  return camera_;
183
186
  }
184
- const width = deck.width;
185
- const height = deck.height;
186
187
  // camera fov eye position. see deck.gl file orbit-viewports.ts
187
188
  const fovy = 50; // default in deck.gl. May also be set construction OrbitView
188
189
  const fD = fovyToAltitude(fovy);
@@ -200,9 +201,9 @@ function calculateZoomFromBBox3D(camera, deck) {
200
201
  ];
201
202
  const cameraFovVertical = 50;
202
203
  const angle_ver = (cameraFovVertical / 2) * DEGREES_TO_RADIANS;
203
- const L = height / 2 / Math.sin(angle_ver);
204
+ const L = size.height / 2 / Math.sin(angle_ver);
204
205
  const r = L * Math.cos(angle_ver);
205
- const cameraFov = 2 * Math.atan(width / 2 / r) * RADIANS_TO_DEGREES;
206
+ const cameraFov = 2 * Math.atan(size.width / 2 / r) * RADIANS_TO_DEGREES;
206
207
  const angle_hor = (cameraFov / 2) * DEGREES_TO_RADIANS;
207
208
  const points = [];
208
209
  points.push([xMin, yMin, zMin]);
@@ -215,9 +216,9 @@ function calculateZoomFromBBox3D(camera, deck) {
215
216
  points.push([xMax, yMin, zMax]);
216
217
  let zoom = 999;
217
218
  for (const point of points) {
218
- const x_ = (point[0] - target[0]) / height;
219
- const y_ = (point[1] - target[1]) / height;
220
- const z_ = (point[2] - target[2]) / height;
219
+ const x_ = (point[0] - target[0]) / size.height;
220
+ const y_ = (point[1] - target[1]) / size.height;
221
+ const z_ = (point[2] - target[2]) / size.height;
221
222
  const m = new Matrix4(IDENTITY);
222
223
  m.rotateX(camera_.rotationX * DEGREES_TO_RADIANS);
223
224
  m.rotateZ(camera_.rotationOrbit * DEGREES_TO_RADIANS);
@@ -240,29 +241,33 @@ function calculateZoomFromBBox3D(camera, deck) {
240
241
  camera_.target = target;
241
242
  return camera_;
242
243
  }
243
- const Map = ({ id, layers, bounds, views, coords, scale, coordinateUnit, colorTables, setEditedData, checkDatafileSchema, onMouseEvent, selection, children, getTooltip = defaultTooltip, cameraPosition, getCameraPosition, isRenderedCallback, onDragStart, onDragEnd, triggerHome, lights, triggerResetMultipleWells, }) => {
244
- var _a, _b, _c, _d, _e, _f, _g;
245
- const deckRef = useRef(null);
246
- const bboxInitial = [0, 0, 0, 1, 1, 1];
244
+ const Map = ({ id, layers, bounds, cameraPosition, triggerHome, views, coords, scale, coordinateUnit, colorTables, setEditedData, checkDatafileSchema, onMouseEvent, selection, children, getTooltip = defaultTooltip, getCameraPosition, isRenderedCallback, onDragStart, onDragEnd, lights, triggerResetMultipleWells, }) => {
245
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
246
+ const deckRef = React.useRef(null);
247
+ // From react doc, ref should not be read nor modified during rendering.
248
+ // Extract the needed size in an effect to respect this rule (which proved true)
249
+ const [deckSize, setDeckSize] = useState({ width: 0, height: 0 });
250
+ useEffect(() => {
251
+ var _a, _b, _c, _d;
252
+ if (((_b = (_a = deckRef.current) === null || _a === void 0 ? void 0 : _a.deck) === null || _b === void 0 ? void 0 : _b.width) &&
253
+ ((_d = (_c = deckRef.current) === null || _c === void 0 ? void 0 : _c.deck) === null || _d === void 0 ? void 0 : _d.height) &&
254
+ deckRef.current.deck.width !== deckSize.width &&
255
+ deckRef.current.deck.height !== deckSize.height) {
256
+ setDeckSize({
257
+ width: deckRef.current.deck.width,
258
+ height: deckRef.current.deck.height,
259
+ });
260
+ }
261
+ // eslint-disable-next-line react-hooks/exhaustive-deps
262
+ }, [(_b = (_a = deckRef.current) === null || _a === void 0 ? void 0 : _a.deck) === null || _b === void 0 ? void 0 : _b.width, (_d = (_c = deckRef.current) === null || _c === void 0 ? void 0 : _c.deck) === null || _d === void 0 ? void 0 : _d.height]);
247
263
  // Deck.gl View's and viewStates as input to Deck.gl
248
264
  const [deckGLViews, setDeckGLViews] = useState([]);
249
265
  const [viewStates, setViewStates] = useState({});
250
- const [reportedBoundingBox, setReportedBoundingBox] = useState(bboxInitial);
251
- const [reportedBoundingBoxAcc, setReportedBoundingBoxAcc] = useState(bboxInitial);
252
- const [deckGLLayers, setDeckGLLayers] = useState([]);
266
+ const [dataBoundingBox3d, dispatchBoundingBox] = React.useReducer(mapBoundingBoxReducer, [0, 0, 0, 1, 1, 1]);
253
267
  const [viewStateChanged, setViewStateChanged] = useState(false);
254
- const [viewPortMargins, setViewPortMargins] = useState({
255
- left: 0,
256
- right: 0,
257
- top: 0,
258
- bottom: 0,
259
- });
260
- const [camera, setCamera] = useState();
261
- React.useEffect(() => {
262
- var _a;
263
- const camera = calculateZoomFromBBox3D(cameraPosition, (_a = deckRef.current) === null || _a === void 0 ? void 0 : _a.deck);
264
- setCamera(camera);
265
- }, [cameraPosition, (_a = deckRef === null || deckRef === void 0 ? void 0 : deckRef.current) === null || _a === void 0 ? void 0 : _a.deck]);
268
+ const camera = useMemo(() => {
269
+ return calculateZoomFromBBox3D(cameraPosition, deckSize);
270
+ }, [cameraPosition, deckSize]);
266
271
  // Used for scaling in z direction using arrow keys.
267
272
  const [scaleZ, setScaleZ] = useState(1);
268
273
  const [scaleZUp, setScaleZUp] = useState(Number.MAX_VALUE);
@@ -274,15 +279,13 @@ const Map = ({ id, layers, bounds, views, coords, scale, coordinateUnit, colorTa
274
279
  ZScaleOrbitController.setZScaleDownReference(setScaleZDown);
275
280
  }, [setScaleZDown]);
276
281
  useEffect(() => {
277
- var _a;
278
282
  const [Views, viewStates] = createViewsAndViewStates(views, viewPortMargins, bounds, undefined, // Use bounds not cameraPosition,
279
- reportedBoundingBoxAcc, (_a = deckRef.current) === null || _a === void 0 ? void 0 : _a.deck);
283
+ dataBoundingBox3d, deckSize);
280
284
  setDeckGLViews(Views);
281
285
  setViewStates(viewStates);
282
286
  // eslint-disable-next-line react-hooks/exhaustive-deps
283
287
  }, [triggerHome]);
284
288
  useEffect(() => {
285
- var _a;
286
289
  const isBoundsDefined = typeof bounds !== "undefined";
287
290
  const isCameraPositionDefined = typeof cameraPosition !== "undefined" &&
288
291
  Object.keys(cameraPosition).length !== 0;
@@ -290,15 +293,14 @@ const Map = ({ id, layers, bounds, views, coords, scale, coordinateUnit, colorTa
290
293
  // User has changed viewState or camera is defined, do not recalculate.
291
294
  return;
292
295
  }
293
- const [Views, viewStates] = createViewsAndViewStates(views, viewPortMargins, bounds, camera, reportedBoundingBoxAcc, (_a = deckRef.current) === null || _a === void 0 ? void 0 : _a.deck);
296
+ const [Views, viewStates] = createViewsAndViewStates(views, viewPortMargins, bounds, camera, dataBoundingBox3d, deckSize);
294
297
  setDeckGLViews(Views);
295
298
  setViewStates(viewStates);
296
299
  setViewStateChanged(false);
297
300
  // eslint-disable-next-line react-hooks/exhaustive-deps
298
- }, [reportedBoundingBoxAcc]);
301
+ }, [dataBoundingBox3d]);
299
302
  useEffect(() => {
300
- var _a;
301
- const [Views, viewStates] = createViewsAndViewStates(views, viewPortMargins, bounds, camera, reportedBoundingBoxAcc, (_a = deckRef.current) === null || _a === void 0 ? void 0 : _a.deck);
303
+ const [Views, viewStates] = createViewsAndViewStates(views, viewPortMargins, bounds, camera, dataBoundingBox3d, deckSize);
302
304
  setDeckGLViews(Views);
303
305
  setViewStates(viewStates);
304
306
  setViewStateChanged(false);
@@ -306,15 +308,10 @@ const Map = ({ id, layers, bounds, views, coords, scale, coordinateUnit, colorTa
306
308
  }, [
307
309
  bounds,
308
310
  camera,
309
- (_b = deckRef === null || deckRef === void 0 ? void 0 : deckRef.current) === null || _b === void 0 ? void 0 : _b.deck,
311
+ deckSize,
310
312
  // eslint-disable-next-line react-hooks/exhaustive-deps
311
313
  compareViewsProp(views),
312
314
  ]);
313
- useEffect(() => {
314
- const union_of_reported_bboxes = addBoundingBoxes(reportedBoundingBoxAcc, reportedBoundingBox);
315
- setReportedBoundingBoxAcc(union_of_reported_bboxes);
316
- // eslint-disable-next-line react-hooks/exhaustive-deps
317
- }, [reportedBoundingBox]);
318
315
  useEffect(() => {
319
316
  if (scaleZUp !== Number.MAX_VALUE) {
320
317
  const newScaleZ = scaleZ * 1.05;
@@ -335,68 +332,6 @@ const Map = ({ id, layers, bounds, views, coords, scale, coordinateUnit, colorTa
335
332
  }
336
333
  // eslint-disable-next-line react-hooks/exhaustive-deps
337
334
  }, [scaleZDown]);
338
- useEffect(() => {
339
- if (typeof layers === "undefined") {
340
- return;
341
- }
342
- if (layers.length === 0) {
343
- // Empty layers array makes deck.gl set deckRef to undefined (no opengl context).
344
- // Hence insert dummy layer.
345
- const dummy_layer = new LineLayer({
346
- id: "webviz_internal_dummy_layer",
347
- visible: false,
348
- });
349
- layers.push(dummy_layer);
350
- }
351
- // Margins on the viewport are extracted from a potenial axes2D layer.
352
- const axes2DLayer = layers === null || layers === void 0 ? void 0 : layers.find((e) => {
353
- return (e === null || e === void 0 ? void 0 : e.constructor) === Axes2DLayer;
354
- });
355
- const left = axes2DLayer && axes2DLayer.props.isLeftRuler
356
- ? axes2DLayer.props.marginH
357
- : 0;
358
- const right = axes2DLayer && axes2DLayer.props.isRightRuler
359
- ? axes2DLayer.props.marginH
360
- : 0;
361
- const top = axes2DLayer && axes2DLayer.props.isTopRuler
362
- ? axes2DLayer.props.marginV
363
- : 0;
364
- const bottom = axes2DLayer && axes2DLayer.props.isBottomRuler
365
- ? axes2DLayer.props.marginV
366
- : 0;
367
- setViewPortMargins({ left, right, top, bottom });
368
- const layers_copy = layers.map((item) => {
369
- if ((item === null || item === void 0 ? void 0 : item.constructor.name) === NorthArrow3DLayer.name) {
370
- return item;
371
- }
372
- // Inject "setReportedBoundingBox" function into layer for it to report
373
- // back its respective bounding box.
374
- return item.clone({
375
- // eslint-disable-next-line
376
- // @ts-ignore
377
- setReportedBoundingBox: setReportedBoundingBox,
378
- });
379
- });
380
- setDeckGLLayers(layers_copy);
381
- // eslint-disable-next-line react-hooks/exhaustive-deps
382
- }, [layers]);
383
- useEffect(() => {
384
- if (typeof layers === "undefined") {
385
- return;
386
- }
387
- const m = getModelMatrixScale(scaleZ);
388
- const layers_copy = deckGLLayers.map((item) => {
389
- if ((item === null || item === void 0 ? void 0 : item.constructor.name) === NorthArrow3DLayer.name) {
390
- return item;
391
- }
392
- // Set "modelLayer" matrix to reflect correct z scaling.
393
- return item.clone({
394
- modelMatrix: m,
395
- });
396
- });
397
- setDeckGLLayers(layers_copy);
398
- // eslint-disable-next-line react-hooks/exhaustive-deps
399
- }, [scaleZ]);
400
335
  useEffect(() => {
401
336
  var _a, _b, _c;
402
337
  const layers = (_b = (_a = deckRef.current) === null || _a === void 0 ? void 0 : _a.deck) === null || _b === void 0 ? void 0 : _b.props.layers;
@@ -516,6 +451,56 @@ const Map = ({ id, layers, bounds, views, coords, scale, coordinateUnit, colorTa
516
451
  const infos = getPickingInfos(pickInfo, event);
517
452
  callOnMouseEvent === null || callOnMouseEvent === void 0 ? void 0 : callOnMouseEvent("click", infos, event);
518
453
  }, [callOnMouseEvent, getPickingInfos]);
454
+ // compute the viewport margins
455
+ const viewPortMargins = React.useMemo(() => {
456
+ if (typeof layers === "undefined") {
457
+ return {
458
+ left: 0,
459
+ right: 0,
460
+ top: 0,
461
+ bottom: 0,
462
+ };
463
+ }
464
+ // Margins on the viewport are extracted from a potential axes2D layer.
465
+ const axes2DLayer = layers === null || layers === void 0 ? void 0 : layers.find((e) => {
466
+ return (e === null || e === void 0 ? void 0 : e.constructor) === Axes2DLayer;
467
+ });
468
+ const axes2DProps = axes2DLayer === null || axes2DLayer === void 0 ? void 0 : axes2DLayer.props;
469
+ return {
470
+ left: (axes2DProps === null || axes2DProps === void 0 ? void 0 : axes2DProps.isLeftRuler) ? axes2DProps.marginH : 0,
471
+ right: (axes2DProps === null || axes2DProps === void 0 ? void 0 : axes2DProps.isRightRuler) ? axes2DProps.marginH : 0,
472
+ top: (axes2DProps === null || axes2DProps === void 0 ? void 0 : axes2DProps.isTopRuler) ? axes2DProps.marginV : 0,
473
+ bottom: (axes2DProps === null || axes2DProps === void 0 ? void 0 : axes2DProps.isBottomRuler) ? axes2DProps.marginV : 0,
474
+ };
475
+ }, [layers]);
476
+ const deckGLLayers = React.useMemo(() => {
477
+ if (typeof layers === "undefined") {
478
+ return [];
479
+ }
480
+ if (layers.length === 0) {
481
+ // Empty layers array makes deck.gl set deckRef to undefined (no OpenGL context).
482
+ // Hence insert dummy layer.
483
+ const dummy_layer = new LineLayer({
484
+ id: "webviz_internal_dummy_layer",
485
+ visible: false,
486
+ });
487
+ layers.push(dummy_layer);
488
+ }
489
+ const m = getModelMatrixScale(scaleZ);
490
+ return layers.map((item) => {
491
+ if ((item === null || item === void 0 ? void 0 : item.constructor.name) === NorthArrow3DLayer.name) {
492
+ return item;
493
+ }
494
+ return item.clone({
495
+ // Inject "dispatchBoundingBox" function into layer for it to report back its respective bounding box.
496
+ // eslint-disable-next-line
497
+ // @ts-ignore
498
+ reportBoundingBox: dispatchBoundingBox,
499
+ // Set "modelLayer" matrix to reflect correct z scaling.
500
+ modelMatrix: m,
501
+ });
502
+ });
503
+ }, [layers, scaleZ]);
519
504
  const [isLoaded, setIsLoaded] = useState(false);
520
505
  const onAfterRender = useCallback(() => {
521
506
  if (deckGLLayers) {
@@ -552,7 +537,7 @@ const Map = ({ id, layers, bounds, views, coords, scale, coordinateUnit, colorTa
552
537
  }, [
553
538
  checkDatafileSchema,
554
539
  colorTables,
555
- (_d = (_c = deckRef === null || deckRef === void 0 ? void 0 : deckRef.current) === null || _c === void 0 ? void 0 : _c.deck) === null || _d === void 0 ? void 0 : _d.props.layers,
540
+ (_f = (_e = deckRef === null || deckRef === void 0 ? void 0 : deckRef.current) === null || _e === void 0 ? void 0 : _e.deck) === null || _f === void 0 ? void 0 : _f.props.layers,
556
541
  isLoaded,
557
542
  ]);
558
543
  const layerFilter = useCallback((args) => {
@@ -576,7 +561,7 @@ const Map = ({ id, layers, bounds, views, coords, scale, coordinateUnit, colorTa
576
561
  ({ viewId, viewState }) => {
577
562
  const viewports = (views === null || views === void 0 ? void 0 : views.viewports) || [];
578
563
  if (viewState.target.length === 2) {
579
- // In orthograpic mode viewState.target contains only x and y. Add existing z value.
564
+ // In orthographic mode viewState.target contains only x and y. Add existing z value.
580
565
  viewState.target.push(viewStates[viewId].target[2]);
581
566
  }
582
567
  const isSyncIds = viewports
@@ -625,7 +610,7 @@ const Map = ({ id, layers, bounds, views, coords, scale, coordinateUnit, colorTa
625
610
  },
626
611
  colorTables: colorTables,
627
612
  }, getCursor: ({ isDragging }) => isDragging ? "grabbing" : "default", getTooltip: getTooltip, ref: deckRef, onViewStateChange: onViewStateChange, onHover: onHover, onClick: onClick, onAfterRender: onAfterRender, effects: effects, onDragStart: onDragStart, onDragEnd: onDragEnd }, children),
628
- (scale === null || scale === void 0 ? void 0 : scale.visible) ? (React.createElement(DistanceScale, Object.assign({}, scale, { zoom: (_f = (_e = viewStates[Object.keys(viewStates)[0]]) === null || _e === void 0 ? void 0 : _e.zoom) !== null && _f !== void 0 ? _f : -5, scaleUnit: coordinateUnit, style: (_g = scale.cssStyle) !== null && _g !== void 0 ? _g : {} }))) : null,
613
+ (scale === null || scale === void 0 ? void 0 : scale.visible) ? (React.createElement(DistanceScale, Object.assign({}, scale, { zoom: (_h = (_g = viewStates[Object.keys(viewStates)[0]]) === null || _g === void 0 ? void 0 : _g.zoom) !== null && _h !== void 0 ? _h : -5, scaleUnit: coordinateUnit, style: (_j = scale.cssStyle) !== null && _j !== void 0 ? _j : {} }))) : null,
629
614
  React.createElement(StatusIndicator, { layers: deckGLLayers, isLoaded: isLoaded }),
630
615
  (coords === null || coords === void 0 ? void 0 : coords.visible) ? React.createElement(InfoCard, { pickInfos: hoverInfo }) : null,
631
616
  errorText && (React.createElement("pre", { style: {
@@ -679,7 +664,7 @@ export function jsonToObject(data, enums = undefined) {
679
664
  return jsonConverter.convert(filtered_data);
680
665
  }
681
666
  // return viewstate with computed bounds to fit the data in viewport
682
- function getViewState(viewPortMargins, bounds_accessor, centerOfData, views, viewPort, deck) {
667
+ function getViewState(viewPortMargins, bounds_accessor, centerOfData, views, viewPort, size) {
683
668
  var _a;
684
669
  let bounds = [0, 0, 1, 1];
685
670
  if (typeof bounds_accessor == "function") {
@@ -694,7 +679,7 @@ function getViewState(viewPortMargins, bounds_accessor, centerOfData, views, vie
694
679
  const fb = fitBounds({ width: w, height: h, bounds });
695
680
  let fb_target = [fb.x, fb.y, z];
696
681
  let fb_zoom = fb.zoom;
697
- if (deck && deck.width > 0 && deck.height > 0) {
682
+ if (size.width > 0 && size.height > 0) {
698
683
  // If there are margins/rulers in the viewport (axes2DLayer) we have to account for that.
699
684
  // Camera target should be in the middle of viewport minus the rulers.
700
685
  const w_bounds = w;
@@ -706,8 +691,8 @@ function getViewState(viewPortMargins, bounds_accessor, centerOfData, views, vie
706
691
  // Subtract margins.
707
692
  const marginH = (ml > 0 ? ml : 0) + (mr > 0 ? mr : 0);
708
693
  const marginV = (mb > 0 ? mb : 0) + (mt > 0 ? mt : 0);
709
- w = deck.width - marginH; // width of the viewport minus margin.
710
- h = deck.height - marginV;
694
+ w = size.width - marginH; // width of the viewport minus margin.
695
+ h = size.height - marginV;
711
696
  // Special case if matrix views.
712
697
  // Use width and heigt for a subview instead of full viewport.
713
698
  if (typeof (views === null || views === void 0 ? void 0 : views.layout) !== "undefined") {
@@ -717,10 +702,10 @@ function getViewState(viewPortMargins, bounds_accessor, centerOfData, views, vie
717
702
  const mPixels = (_a = views === null || views === void 0 ? void 0 : views.marginPixels) !== null && _a !== void 0 ? _a : 0;
718
703
  const w_ = 99.5 / nX; // Using 99.5% of viewport to avoid flickering of deckgl canvas
719
704
  const h_ = 99.5 / nY;
720
- const marginHorPercentage = 100 * 100 * (mPixels / (w_ * deck.width)); //percentage of sub view
721
- const marginVerPercentage = 100 * 100 * (mPixels / (h_ * deck.height));
722
- const sub_w = (w_ / 100) * deck.width;
723
- const sub_h = (h_ / 100) * deck.height;
705
+ const marginHorPercentage = 100 * 100 * (mPixels / (w_ * size.width)); //percentage of sub view
706
+ const marginVerPercentage = 100 * 100 * (mPixels / (h_ * size.height));
707
+ const sub_w = (w_ / 100) * size.width;
708
+ const sub_h = (h_ / 100) * size.height;
724
709
  w = sub_w * (1 - 2 * (marginHorPercentage / 100)) - marginH;
725
710
  h = sub_h * (1 - 2 * (marginVerPercentage / 100)) - marginV;
726
711
  }
@@ -766,7 +751,7 @@ function getViewState(viewPortMargins, bounds_accessor, centerOfData, views, vie
766
751
  }
767
752
  ///////////////////////////////////////////////////////////////////////////////////////////
768
753
  // return viewstate with computed bounds to fit the data in viewport
769
- function getViewState3D(is3D, bounds, zoom, deck) {
754
+ function getViewState3D(is3D, bounds, zoom, size) {
770
755
  const xMin = bounds[0];
771
756
  const yMin = bounds[1];
772
757
  const zMin = bounds[2];
@@ -775,9 +760,9 @@ function getViewState3D(is3D, bounds, zoom, deck) {
775
760
  const zMax = bounds[5];
776
761
  let width = xMax - xMin;
777
762
  let height = yMax - yMin;
778
- if (deck && (deck === null || deck === void 0 ? void 0 : deck.width) > 0 && (deck === null || deck === void 0 ? void 0 : deck.height) > 0) {
779
- width = deck.width;
780
- height = deck.height;
763
+ if (size.width > 0 && size.height > 0) {
764
+ width = size.width;
765
+ height = size.height;
781
766
  }
782
767
  const target = [
783
768
  xMin + (xMax - xMin) / 2,
@@ -801,23 +786,22 @@ function getViewState3D(is3D, bounds, zoom, deck) {
801
786
  return view_state;
802
787
  }
803
788
  // construct views and viewStates for DeckGL component
804
- function createViewsAndViewStates(views, viewPortMargins, bounds, cameraPosition, boundingBox, deck) {
789
+ function createViewsAndViewStates(views, viewPortMargins, bounds, cameraPosition, boundingBox, size) {
805
790
  var _a, _b, _c, _d;
806
791
  const deckgl_views = [];
807
792
  let viewStates = {};
808
793
  const centerOfData = boundingBoxCenter(boundingBox);
809
- const widthViewPort = (_a = deck === null || deck === void 0 ? void 0 : deck.width) !== null && _a !== void 0 ? _a : 1;
810
- const heightViewPort = (_b = deck === null || deck === void 0 ? void 0 : deck.height) !== null && _b !== void 0 ? _b : 1;
811
- const mPixels = (_c = views === null || views === void 0 ? void 0 : views.marginPixels) !== null && _c !== void 0 ? _c : 0;
812
- const isOk = deck &&
813
- views &&
814
- Object.keys(views).length !== 0 &&
815
- views.layout[0] >= 1 &&
816
- views.layout[1] >= 1 &&
794
+ const widthViewPort = size.width;
795
+ const heightViewPort = size.height;
796
+ const mPixels = (_a = views === null || views === void 0 ? void 0 : views.marginPixels) !== null && _a !== void 0 ? _a : 0;
797
+ const isOk = (views === null || views === void 0 ? void 0 : views.layout) !== undefined &&
798
+ ((_b = views === null || views === void 0 ? void 0 : views.layout) === null || _b === void 0 ? void 0 : _b[0]) >= 1 &&
799
+ ((_c = views === null || views === void 0 ? void 0 : views.layout) === null || _c === void 0 ? void 0 : _c[1]) >= 1 &&
817
800
  widthViewPort > 0 &&
818
801
  heightViewPort > 0;
819
- // if props for multiple viewport are not proper, or deck is not yet initialized, return 2d view
820
- if (!isOk) {
802
+ // if props for multiple viewport are not proper, or deck size is not yet initialized, return 2d view
803
+ // add redundant check on views to please lint
804
+ if (!views || !isOk) {
821
805
  deckgl_views.push(new OrthographicView({
822
806
  id: "main",
823
807
  controller: { doubleClickZoom: false },
@@ -829,14 +813,15 @@ function createViewsAndViewStates(views, viewPortMargins, bounds, cameraPosition
829
813
  far: +99999,
830
814
  near: -99999,
831
815
  }));
832
- viewStates = Object.assign(Object.assign({}, viewStates), { ["dummy"]: {
816
+ viewStates["dummy"] =
817
+ cameraPosition !== null && cameraPosition !== void 0 ? cameraPosition : {
833
818
  target: [0, 0],
834
819
  zoom: 0,
835
820
  rotationX: 0,
836
821
  rotationOrbit: 0,
837
822
  minZoom: minZoom2D,
838
823
  maxZoom: maxZoom2D,
839
- } });
824
+ };
840
825
  }
841
826
  else {
842
827
  let yPos = 0;
@@ -891,8 +876,8 @@ function createViewsAndViewStates(views, viewPortMargins, bounds, cameraPosition
891
876
  let viewState = cameraPosition;
892
877
  if (!isCameraPositionDefined) {
893
878
  viewState = isBoundsDefined
894
- ? getViewState(viewPortMargins, bounds !== null && bounds !== void 0 ? bounds : [0, 0, 1, 1], centerOfData, views, currentViewport, deck)
895
- : getViewState3D((_d = currentViewport.show3D) !== null && _d !== void 0 ? _d : false, boundingBox, currentViewport.zoom, deck);
879
+ ? getViewState(viewPortMargins, bounds !== null && bounds !== void 0 ? bounds : [0, 0, 1, 1], centerOfData, views, currentViewport, size)
880
+ : getViewState3D((_d = currentViewport.show3D) !== null && _d !== void 0 ? _d : false, boundingBox, currentViewport.zoom, size);
896
881
  }
897
882
  viewStates = Object.assign(Object.assign({}, viewStates), { [currentViewport.id]: viewState });
898
883
  xPos = xPos + w;