@equinor/esv-intersection 3.0.9 → 3.0.11

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 (155) hide show
  1. package/dist/control/ExtendedCurveInterpolator.d.ts +0 -1
  2. package/dist/index.cjs +2 -2
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.mjs +2188 -2087
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/index.umd.js +2 -2
  8. package/dist/index.umd.js.map +1 -1
  9. package/dist/interfaces.d.ts +1 -3
  10. package/dist/utils/arc-length.d.ts +0 -1
  11. package/dist/utils/binary-search.d.ts +0 -1
  12. package/dist/utils/root-finder.d.ts +1 -2
  13. package/package.json +25 -25
  14. package/src/components/axis.ts +23 -30
  15. package/src/control/ExtendedCurveInterpolator.ts +7 -7
  16. package/src/control/IntersectionReferenceSystem.ts +33 -41
  17. package/src/control/LayerManager.ts +33 -31
  18. package/src/control/MainController.ts +5 -7
  19. package/src/control/ZoomPanHandler.ts +50 -45
  20. package/src/control/interfaces.ts +3 -3
  21. package/src/control/overlay.ts +42 -35
  22. package/src/datautils/colortable.ts +4 -4
  23. package/src/datautils/findsample.ts +8 -7
  24. package/src/datautils/picks.ts +13 -13
  25. package/src/datautils/schematicShapeGenerator.ts +47 -17
  26. package/src/datautils/seismicimage.ts +12 -13
  27. package/src/datautils/surfacedata.ts +27 -26
  28. package/src/datautils/trajectory.ts +34 -32
  29. package/src/interfaces.ts +1 -1
  30. package/src/layers/CalloutCanvasLayer.ts +55 -58
  31. package/src/layers/CustomDisplayObjects/ComplexRopeGeometry.ts +23 -20
  32. package/src/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.ts +9 -10
  33. package/src/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.ts +13 -13
  34. package/src/layers/GeomodelCanvasLayer.ts +43 -36
  35. package/src/layers/GeomodelLabelsLayer.ts +99 -96
  36. package/src/layers/GeomodelLayerV2.ts +11 -11
  37. package/src/layers/GridLayer.ts +25 -21
  38. package/src/layers/ImageCanvasLayer.ts +17 -11
  39. package/src/layers/ReferenceLineLayer.ts +53 -45
  40. package/src/layers/SchematicLayer.ts +78 -75
  41. package/src/layers/WellborePathLayer.ts +48 -46
  42. package/src/layers/base/CanvasLayer.ts +18 -18
  43. package/src/layers/base/HTMLLayer.ts +5 -5
  44. package/src/layers/base/Layer.ts +18 -18
  45. package/src/layers/base/PixiLayer.ts +24 -20
  46. package/src/layers/base/SVGLayer.ts +5 -5
  47. package/src/utils/arc-length.ts +3 -10
  48. package/src/utils/binary-search.ts +2 -2
  49. package/src/utils/color.ts +9 -5
  50. package/src/utils/root-finder.ts +4 -4
  51. package/src/utils/text.ts +5 -5
  52. package/src/utils/vectorUtils.ts +13 -6
  53. package/src/vendor/pixi-dashed-line/index.ts +3 -2
  54. package/dist/components/axis.d.ts +0 -48
  55. package/dist/components/axis.d.ts.map +0 -1
  56. package/dist/components/index.d.ts +0 -2
  57. package/dist/components/index.d.ts.map +0 -1
  58. package/dist/constants.d.ts +0 -12
  59. package/dist/constants.d.ts.map +0 -1
  60. package/dist/control/ExtendedCurveInterpolator.d.ts.map +0 -1
  61. package/dist/control/IntersectionReferenceSystem.d.ts +0 -97
  62. package/dist/control/IntersectionReferenceSystem.d.ts.map +0 -1
  63. package/dist/control/LayerManager.d.ts +0 -77
  64. package/dist/control/LayerManager.d.ts.map +0 -1
  65. package/dist/control/MainController.d.ts +0 -155
  66. package/dist/control/MainController.d.ts.map +0 -1
  67. package/dist/control/ZoomPanHandler.d.ts +0 -159
  68. package/dist/control/ZoomPanHandler.d.ts.map +0 -1
  69. package/dist/control/index.d.ts +0 -6
  70. package/dist/control/index.d.ts.map +0 -1
  71. package/dist/control/interfaces.d.ts +0 -38
  72. package/dist/control/interfaces.d.ts.map +0 -1
  73. package/dist/control/overlay.d.ts +0 -21
  74. package/dist/control/overlay.d.ts.map +0 -1
  75. package/dist/datautils/colortable.d.ts +0 -2
  76. package/dist/datautils/colortable.d.ts.map +0 -1
  77. package/dist/datautils/findsample.d.ts +0 -3
  78. package/dist/datautils/findsample.d.ts.map +0 -1
  79. package/dist/datautils/index.d.ts +0 -7
  80. package/dist/datautils/index.d.ts.map +0 -1
  81. package/dist/datautils/interfaces.d.ts +0 -64
  82. package/dist/datautils/interfaces.d.ts.map +0 -1
  83. package/dist/datautils/picks.d.ts +0 -75
  84. package/dist/datautils/picks.d.ts.map +0 -1
  85. package/dist/datautils/schematicShapeGenerator.d.ts +0 -60
  86. package/dist/datautils/schematicShapeGenerator.d.ts.map +0 -1
  87. package/dist/datautils/seismicimage.d.ts +0 -46
  88. package/dist/datautils/seismicimage.d.ts.map +0 -1
  89. package/dist/datautils/surfacedata.d.ts +0 -11
  90. package/dist/datautils/surfacedata.d.ts.map +0 -1
  91. package/dist/datautils/trajectory.d.ts +0 -15
  92. package/dist/datautils/trajectory.d.ts.map +0 -1
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/interfaces.d.ts.map +0 -1
  95. package/dist/layers/CalloutCanvasLayer.d.ts +0 -61
  96. package/dist/layers/CalloutCanvasLayer.d.ts.map +0 -1
  97. package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts +0 -22
  98. package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts.map +0 -1
  99. package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts +0 -24
  100. package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts.map +0 -1
  101. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts +0 -21
  102. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts.map +0 -1
  103. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts +0 -27
  104. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts.map +0 -1
  105. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts +0 -18
  106. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts.map +0 -1
  107. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts +0 -25
  108. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts.map +0 -1
  109. package/dist/layers/GeomodelCanvasLayer.d.ts +0 -29
  110. package/dist/layers/GeomodelCanvasLayer.d.ts.map +0 -1
  111. package/dist/layers/GeomodelLabelsLayer.d.ts +0 -50
  112. package/dist/layers/GeomodelLabelsLayer.d.ts.map +0 -1
  113. package/dist/layers/GeomodelLayerV2.d.ts +0 -13
  114. package/dist/layers/GeomodelLayerV2.d.ts.map +0 -1
  115. package/dist/layers/GridLayer.d.ts +0 -30
  116. package/dist/layers/GridLayer.d.ts.map +0 -1
  117. package/dist/layers/ImageCanvasLayer.d.ts +0 -21
  118. package/dist/layers/ImageCanvasLayer.d.ts.map +0 -1
  119. package/dist/layers/ReferenceLineLayer.d.ts +0 -30
  120. package/dist/layers/ReferenceLineLayer.d.ts.map +0 -1
  121. package/dist/layers/SchematicLayer.d.ts +0 -114
  122. package/dist/layers/SchematicLayer.d.ts.map +0 -1
  123. package/dist/layers/SeismicCanvasLayer.d.ts +0 -19
  124. package/dist/layers/SeismicCanvasLayer.d.ts.map +0 -1
  125. package/dist/layers/WellborePathLayer.d.ts +0 -18
  126. package/dist/layers/WellborePathLayer.d.ts.map +0 -1
  127. package/dist/layers/base/CanvasLayer.d.ts +0 -20
  128. package/dist/layers/base/CanvasLayer.d.ts.map +0 -1
  129. package/dist/layers/base/HTMLLayer.d.ts +0 -14
  130. package/dist/layers/base/HTMLLayer.d.ts.map +0 -1
  131. package/dist/layers/base/Layer.d.ts +0 -70
  132. package/dist/layers/base/Layer.d.ts.map +0 -1
  133. package/dist/layers/base/PixiLayer.d.ts +0 -33
  134. package/dist/layers/base/PixiLayer.d.ts.map +0 -1
  135. package/dist/layers/base/SVGLayer.d.ts +0 -14
  136. package/dist/layers/base/SVGLayer.d.ts.map +0 -1
  137. package/dist/layers/base/index.d.ts +0 -6
  138. package/dist/layers/base/index.d.ts.map +0 -1
  139. package/dist/layers/index.d.ts +0 -17
  140. package/dist/layers/index.d.ts.map +0 -1
  141. package/dist/layers/schematicInterfaces.d.ts +0 -210
  142. package/dist/layers/schematicInterfaces.d.ts.map +0 -1
  143. package/dist/utils/arc-length.d.ts.map +0 -1
  144. package/dist/utils/binary-search.d.ts.map +0 -1
  145. package/dist/utils/color.d.ts +0 -6
  146. package/dist/utils/color.d.ts.map +0 -1
  147. package/dist/utils/index.d.ts +0 -2
  148. package/dist/utils/index.d.ts.map +0 -1
  149. package/dist/utils/root-finder.d.ts.map +0 -1
  150. package/dist/utils/text.d.ts +0 -15
  151. package/dist/utils/text.d.ts.map +0 -1
  152. package/dist/utils/vectorUtils.d.ts +0 -16
  153. package/dist/utils/vectorUtils.d.ts.map +0 -1
  154. package/dist/vendor/pixi-dashed-line/index.d.ts +0 -57
  155. package/dist/vendor/pixi-dashed-line/index.d.ts.map +0 -1
@@ -16,7 +16,7 @@ export type ReferenceLine = {
16
16
  fontSize?: string;
17
17
  };
18
18
 
19
- export interface ReferenceLineLayerOptions extends LayerOptions<ReferenceLine[]> {}
19
+ export type ReferenceLineLayerOptions = LayerOptions<ReferenceLine[]>;
20
20
 
21
21
  const foldReferenceLine = <T>(
22
22
  options: {
@@ -66,36 +66,41 @@ export class ReferenceLineLayer extends CanvasLayer<ReferenceLine[]> {
66
66
  private drawDashed(dashed: ReferenceLine) {
67
67
  const { ctx } = this;
68
68
  const { canvas } = this;
69
- const y = this.yScale(dashed.depth);
70
- ctx.save();
71
- ctx.strokeStyle = dashed.color;
72
- this.setCtxLineStyle(ctx, dashed);
73
- this.setCtxLineWidth(ctx, dashed);
74
- ctx.beginPath();
75
- ctx.moveTo(0, y);
76
- ctx.lineTo(canvas.width, y);
77
- ctx.stroke();
78
- ctx.restore();
79
- if (dashed.text) {
80
- this.drawText(ctx, dashed, ctx.canvas.width, y);
69
+
70
+ if (ctx != null && canvas != null) {
71
+ const y = this.yScale?.(dashed.depth)!;
72
+ ctx.save();
73
+ ctx.strokeStyle = dashed.color;
74
+ this.setCtxLineStyle(ctx, dashed);
75
+ this.setCtxLineWidth(ctx, dashed);
76
+ ctx.beginPath();
77
+ ctx.moveTo(0, y);
78
+ ctx.lineTo(canvas.width, y);
79
+ ctx.stroke();
80
+ ctx.restore();
81
+ if (dashed.text) {
82
+ this.drawText(ctx, dashed, ctx.canvas.width, y);
83
+ }
81
84
  }
82
85
  }
83
86
 
84
87
  private drawSolid(solid: ReferenceLine) {
85
88
  const { ctx } = this;
86
89
  const { canvas } = this;
87
- const y = this.yScale(solid.depth);
88
- ctx.save();
89
- ctx.strokeStyle = solid.color;
90
- this.setCtxLineStyle(ctx, solid);
91
- this.setCtxLineWidth(ctx, solid);
92
- ctx.beginPath();
93
- ctx.moveTo(0, y);
94
- ctx.lineTo(canvas.width, y);
95
- ctx.stroke();
96
- ctx.restore();
97
- if (solid.text) {
98
- this.drawText(ctx, solid, ctx.canvas.width, y);
90
+ const y = this.yScale!(solid.depth);
91
+ if (ctx != null && canvas != null) {
92
+ ctx.save();
93
+ ctx.strokeStyle = solid.color;
94
+ this.setCtxLineStyle(ctx, solid);
95
+ this.setCtxLineWidth(ctx, solid);
96
+ ctx.beginPath();
97
+ ctx.moveTo(0, y);
98
+ ctx.lineTo(canvas.width, y);
99
+ ctx.stroke();
100
+ ctx.restore();
101
+ if (solid.text) {
102
+ this.drawText(ctx, solid, ctx.canvas.width, y);
103
+ }
99
104
  }
100
105
  }
101
106
 
@@ -103,25 +108,27 @@ export class ReferenceLineLayer extends CanvasLayer<ReferenceLine[]> {
103
108
  const factor = 4;
104
109
  const min = 2.5;
105
110
  const max = 500;
106
- const { ctx } = this;
107
- const { canvas } = this;
108
- const waveHeight = calcSize(factor, min, max, this.yScale);
109
- const wavePeriod = waveHeight * 2;
110
- const y = this.yScale(wavy.depth) - waveHeight;
111
- const steps = Math.ceil(canvas.width / wavePeriod) + 1;
112
- const xOffset = this.xScale(0) % wavePeriod;
113
- ctx.save();
114
- ctx.strokeStyle = wavy.color;
115
- this.setCtxLineStyle(ctx, wavy);
116
- this.setCtxLineWidth(ctx, wavy);
117
- for (let i = -1; i < steps; i++) {
118
- ctx.beginPath();
119
- ctx.arc(i * wavePeriod + xOffset + waveHeight, y, waveHeight, 0, Math.PI);
120
- ctx.stroke();
121
- }
122
- ctx.restore();
123
- if (wavy.text) {
124
- this.drawText(ctx, wavy, ctx.canvas.width, y);
111
+ const { ctx, canvas } = this;
112
+
113
+ if (this.xScale != null && this.yScale != null && canvas != null && ctx != null) {
114
+ const waveHeight = calcSize(factor, min, max, this.yScale);
115
+ const wavePeriod = waveHeight * 2;
116
+ const y = this.yScale(wavy.depth) - waveHeight;
117
+ const steps = Math.ceil(canvas.width / wavePeriod) + 1;
118
+ const xOffset = this.xScale(0) % wavePeriod;
119
+ ctx.save();
120
+ ctx.strokeStyle = wavy.color;
121
+ this.setCtxLineStyle(ctx, wavy);
122
+ this.setCtxLineWidth(ctx, wavy);
123
+ for (let i = -1; i < steps; i++) {
124
+ ctx.beginPath();
125
+ ctx.arc(i * wavePeriod + xOffset + waveHeight, y, waveHeight, 0, Math.PI);
126
+ ctx.stroke();
127
+ }
128
+ ctx.restore();
129
+ if (wavy.text) {
130
+ this.drawText(ctx, wavy, ctx.canvas.width, y);
131
+ }
125
132
  }
126
133
  }
127
134
 
@@ -129,12 +136,13 @@ export class ReferenceLineLayer extends CanvasLayer<ReferenceLine[]> {
129
136
  const textColor = refLine.textColor || '#000';
130
137
  const fontSize = refLine.fontSize || '10px sans-serif';
131
138
  const textOffsetX = 10;
139
+
132
140
  ctx.save();
133
141
  ctx.strokeStyle = textColor;
134
142
  ctx.font = fontSize;
135
143
  ctx.textAlign = 'end';
136
144
  ctx.textBaseline = 'bottom';
137
- ctx.fillText(refLine.text, x - textOffsetX, y);
145
+ ctx.fillText(refLine.text ?? '', x - textOffsetX, y);
138
146
  ctx.restore();
139
147
  }
140
148
 
@@ -153,13 +153,13 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
153
153
  perforationLayerId: true,
154
154
  };
155
155
 
156
- private cementTextureCache: Texture;
157
- private cementSqueezeTextureCache: Texture;
158
- private cementPlugTextureCache: Texture;
159
- private holeTextureCache: Texture;
160
- private screenTextureCache: Texture;
161
- private tubingTextureCache: Texture;
162
- private textureSymbolCacheArray: { [key: string]: Texture };
156
+ private cementTextureCache: Texture | null = null;
157
+ private cementSqueezeTextureCache: Texture | null = null;
158
+ private cementPlugTextureCache: Texture | null = null;
159
+ private holeTextureCache: Texture | null = null;
160
+ private screenTextureCache: Texture | null = null;
161
+ private tubingTextureCache: Texture | null = null;
162
+ private textureSymbolCacheArray: { [key: string]: Texture } | null = null;
163
163
 
164
164
  protected scalingFactors: ScalingFactors = {
165
165
  height: 600,
@@ -178,14 +178,12 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
178
178
 
179
179
  public override onUnmount(event?: OnUnmountEvent): void {
180
180
  super.onUnmount(event);
181
- this.scalingFactors = null;
182
181
  this.cementTextureCache = null;
183
182
  this.cementSqueezeTextureCache = null;
184
183
  this.holeTextureCache = null;
185
184
  this.screenTextureCache = null;
186
185
  this.tubingTextureCache = null;
187
186
  this.textureSymbolCacheArray = null;
188
- this.internalLayerVisibility = null;
189
187
  }
190
188
 
191
189
  public override onUpdate(event: OnUpdateEvent<T>): void {
@@ -220,8 +218,10 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
220
218
  }
221
219
 
222
220
  const { internalLayerOptions } = this.options as SchematicLayerOptions<T>;
221
+ const entries = internalLayerOptions ? Object.entries(internalLayerOptions) : [];
222
+ const entryFound = entries.find(([_key, id]: [string, string]) => id === layerId);
223
+ const keyFound = entryFound?.[0];
223
224
 
224
- const [keyFound] = Object.entries(internalLayerOptions).find(([_key, id]: [string, string]) => id === layerId);
225
225
  if (keyFound) {
226
226
  this.internalLayerVisibility[keyFound as keyof InternalLayerVisibility] = isVisible;
227
227
  this.clearLayer();
@@ -232,7 +232,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
232
232
 
233
233
  public override getInternalLayerIds(): string[] {
234
234
  const { internalLayerOptions } = this.options as SchematicLayerOptions<T>;
235
- return Object.values(internalLayerOptions);
235
+ return internalLayerOptions ? Object.values(internalLayerOptions) : [];
236
236
  }
237
237
 
238
238
  /**
@@ -240,18 +240,18 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
240
240
  * TODO consider to move this into ZoomPanHandler
241
241
  */
242
242
  protected yRatio(): number {
243
- const domain = this.scalingFactors.yScale.domain();
243
+ const domain = this.scalingFactors.yScale.domain() as [number, number];
244
244
  const ySpan = domain[1] - domain[0];
245
245
  const baseYSpan = ySpan * this.scalingFactors.zFactor;
246
- const baseDomain = [domain[0], domain[0] + baseYSpan];
246
+ const baseDomain: [number, number] = [domain[0], domain[0] + baseYSpan];
247
247
  return Math.abs(this.scalingFactors.height / (baseDomain[1] - baseDomain[0]));
248
248
  }
249
249
 
250
250
  protected getZFactorScaledPathForPoints = (start: number, end: number): Point[] => {
251
251
  const y = (y: number): number => y * this.scalingFactors.zFactor;
252
252
 
253
- const path = this.referenceSystem.getCurtainPath(start, end, true);
254
- return path.map((p) => new Point(p.point[0], y(p.point[1])));
253
+ const path = this.referenceSystem?.getCurtainPath(start, end, true) ?? [];
254
+ return path.map((p) => new Point(p.point[0], y(p.point[1]!)));
255
255
  };
256
256
 
257
257
  protected drawBigPolygon = (coords: IPoint[], color = 0x000000) => {
@@ -265,13 +265,11 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
265
265
 
266
266
  protected drawRope(path: Point[], texture: Texture, tint?: number): void {
267
267
  if (path.length === 0) {
268
- return null;
268
+ return undefined;
269
269
  }
270
270
 
271
271
  const rope: SimpleRope = new SimpleRope(texture, path, 1);
272
-
273
272
  rope.tint = tint || rope.tint;
274
-
275
273
  this.addChild(rope);
276
274
  }
277
275
 
@@ -294,8 +292,8 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
294
292
  ): void {
295
293
  const leftPathReverse = leftPath.map<Point>((d) => d.clone()).reverse();
296
294
 
297
- const startPointRight = rightPath[0];
298
- const startPointLeft = leftPathReverse[0];
295
+ const startPointRight = rightPath[0]!;
296
+ const startPointLeft = leftPathReverse[0]!;
299
297
 
300
298
  const line = new Graphics();
301
299
  line.lineStyle(lineWidth, lineColor, undefined, lineAlignment);
@@ -333,7 +331,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
333
331
  const graphics = new Graphics();
334
332
  graphics.lineStyle(lineWidth, convertColor(lineColor), undefined, solidAlignment);
335
333
 
336
- const startPointLinePath = linePath[0];
334
+ const startPointLinePath = linePath[0]!;
337
335
  graphics.moveTo(startPointLinePath.x, startPointLinePath.y);
338
336
  linePath.forEach((p: Point) => graphics.lineTo(p.x, p.y));
339
337
 
@@ -344,7 +342,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
344
342
  alignment: dashedAlignment,
345
343
  });
346
344
 
347
- const startPointDashedPath = dashedPath[0];
345
+ const startPointDashedPath = dashedPath[0]!;
348
346
  dashedLine.moveTo(startPointDashedPath.x, startPointDashedPath.y);
349
347
  dashedPath.forEach((currentPoint: Point) => {
350
348
  dashedLine.lineTo(currentPoint.x, currentPoint.y);
@@ -360,13 +358,14 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
360
358
  return;
361
359
  }
362
360
 
363
- const { exaggerationFactor } = this.options as SchematicLayerOptions<T>;
361
+ const { exaggerationFactor = 1 } = this.options as SchematicLayerOptions<T>;
364
362
  const { holeSizes, casings, cements, completion, symbols, pAndA, perforations } = this.data;
365
363
 
366
364
  this.updateSymbolCache(symbols);
367
365
 
368
366
  holeSizes.sort((a: HoleSize, b: HoleSize) => b.diameter - a.diameter);
369
- const maxHoleDiameter = holeSizes.length > 0 ? max(holeSizes, (d) => d.diameter) * exaggerationFactor : EXAGGERATED_DIAMETER * exaggerationFactor;
367
+ const maxHoleDiameter =
368
+ holeSizes.length > 0 ? (max(holeSizes, (d) => d.diameter) ?? 0) * exaggerationFactor : EXAGGERATED_DIAMETER * exaggerationFactor;
370
369
  if (this.internalLayerVisibility.holeLayerId) {
371
370
  holeSizes.forEach((hole: HoleSize) => this.drawHoleSize(maxHoleDiameter, hole));
372
371
  }
@@ -407,12 +406,14 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
407
406
  },
408
407
  (cementRO: CementRenderObject) => {
409
408
  if (this.internalLayerVisibility.cementLayerId) {
410
- this.drawComplexRope(cementRO.segments, this.getCementTexture());
409
+ const texture = this.getCementTexture();
410
+ texture && this.drawComplexRope(cementRO.segments, texture);
411
411
  }
412
412
  },
413
413
  (cementSqueezesRO: CementSqueezeRenderObject) => {
414
414
  if (this.internalLayerVisibility.pAndALayerId) {
415
- this.drawComplexRope(cementSqueezesRO.segments, this.getCementSqueezeTexture());
415
+ const texture = this.getCementSqueezeTexture();
416
+ texture && this.drawComplexRope(cementSqueezesRO.segments, texture);
416
417
  }
417
418
  },
418
419
  ),
@@ -440,15 +441,15 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
440
441
  if (!dict[ps.diameter]) {
441
442
  dict[ps.diameter] = [];
442
443
  }
443
- dict[ps.diameter] = [...dict[ps.diameter], ps];
444
+ dict[ps.diameter] = [...(dict[ps.diameter] ?? []), ps];
444
445
  return dict;
445
446
  },
446
447
  {},
447
448
  );
448
449
  Object.values(perfShapesByDiameter).forEach((perfShapesWithSameDiameter) => {
449
- const texture = createPerforationPackingTexture(perforation, perfShapesWithSameDiameter[0], perforationOptions);
450
+ const texture = createPerforationPackingTexture(perforation, perfShapesWithSameDiameter[0]!, perforationOptions!);
450
451
  const rope = this.drawComplexRope(perfShapesWithSameDiameter, texture);
451
- this.perforationRopeAndTextureReferences.push({ rope, texture });
452
+ rope && this.perforationRopeAndTextureReferences.push({ rope, texture });
452
453
  });
453
454
  });
454
455
 
@@ -460,16 +461,16 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
460
461
  if (!dict[ps.diameter]) {
461
462
  dict[ps.diameter] = [];
462
463
  }
463
- dict[ps.diameter] = [...dict[ps.diameter], ps];
464
+ dict[ps.diameter] = [...(dict[ps.diameter] ?? []), ps];
464
465
  return dict;
465
466
  },
466
467
  {},
467
468
  );
468
469
  Object.values(perfShapesByDiameter).forEach((perfShapesWithSameDiameter) => {
469
470
  perfShapesWithSameDiameter.forEach((perfShape) => {
470
- const texture = createPerforationSpikeTexture(perforation, perforations, perfShape, perforationOptions);
471
+ const texture = createPerforationSpikeTexture(perforation, perforations, perfShape, perforationOptions!);
471
472
  const rope = this.drawComplexRope([perfShape], texture);
472
- this.perforationRopeAndTextureReferences.push({ rope, texture });
473
+ rope && this.perforationRopeAndTextureReferences.push({ rope, texture });
473
474
  });
474
475
  });
475
476
  });
@@ -482,16 +483,16 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
482
483
  if (!dict[ps.diameter]) {
483
484
  dict[ps.diameter] = [];
484
485
  }
485
- dict[ps.diameter] = [...dict[ps.diameter], ps];
486
+ dict[ps.diameter] = [...(dict[ps.diameter] ?? []), ps];
486
487
  return dict;
487
488
  },
488
489
  {},
489
490
  );
490
491
  Object.values(perfShapesByDiameter).forEach((perfShapesWithSameDiameter) => {
491
492
  perfShapesWithSameDiameter.forEach((perfShape) => {
492
- const texture = createPerforationFracLineTexture(perforation, perfShape, perforationOptions);
493
+ const texture = createPerforationFracLineTexture(perforation, perfShape, perforationOptions!);
493
494
  const rope = this.drawComplexRope([perfShape], texture);
494
- this.perforationRopeAndTextureReferences.push({ rope, texture });
495
+ rope && this.perforationRopeAndTextureReferences.push({ rope, texture });
495
496
  });
496
497
  });
497
498
  });
@@ -533,14 +534,14 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
533
534
 
534
535
  const existingKeys = Object.keys(this.textureSymbolCacheArray);
535
536
  Object.entries(symbols).forEach(([key, symbol]: [string, string]) => {
536
- if (!existingKeys.includes(key)) {
537
+ if (!existingKeys.includes(key) && this.textureSymbolCacheArray) {
537
538
  this.textureSymbolCacheArray[key] = Texture.from(symbol);
538
539
  }
539
540
  });
540
541
  }
541
542
 
542
543
  private drawCementPlug(cementPlug: CementPlug, casings: Casing[], completion: Completion[], holes: HoleSize[]) {
543
- const { exaggerationFactor, cementPlugOptions } = this.options as SchematicLayerOptions<T>;
544
+ const { exaggerationFactor = 1, cementPlugOptions } = this.options as SchematicLayerOptions<T>;
544
545
 
545
546
  const cementPlugSegments = createComplexRopeSegmentsForCementPlug(
546
547
  cementPlug,
@@ -550,7 +551,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
550
551
  exaggerationFactor,
551
552
  this.getZFactorScaledPathForPoints,
552
553
  );
553
- this.drawComplexRope(cementPlugSegments, this.getCementPlugTexture(cementPlugOptions));
554
+ cementPlugOptions && this.drawComplexRope(cementPlugSegments, this.getCementPlugTexture(cementPlugOptions));
554
555
 
555
556
  const { rightPath, leftPath } = cementPlugSegments.reduce<{ rightPath: Point[]; leftPath: Point[] }>(
556
557
  (acc, current) => {
@@ -568,7 +569,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
568
569
  }
569
570
 
570
571
  private createCasingRenderObject(casing: Casing): CasingRenderObject {
571
- const { exaggerationFactor } = this.options as SchematicLayerOptions<T>;
572
+ const { exaggerationFactor = 1 } = this.options as SchematicLayerOptions<T>;
572
573
  return prepareCasingRenderObject(exaggerationFactor, casing, this.getZFactorScaledPathForPoints);
573
574
  }
574
575
 
@@ -580,7 +581,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
580
581
  }
581
582
 
582
583
  private prepareSymbolRenderObject = (component: CompletionSymbol | PAndASymbol): SymbolRenderObject => {
583
- const { exaggerationFactor } = this.options as SchematicLayerOptions<T>;
584
+ const { exaggerationFactor = 1 } = this.options as SchematicLayerOptions<T>;
584
585
 
585
586
  const exaggeratedDiameter = component.diameter * exaggerationFactor;
586
587
 
@@ -596,12 +597,12 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
596
597
  private drawSymbolComponent = ({ pathPoints, referenceDiameter, symbolKey }: SymbolRenderObject): void => {
597
598
  const texture = this.getSymbolTexture(symbolKey, referenceDiameter);
598
599
  // The rope renders fine in CANVAS/fallback mode
599
- this.drawSVGRope(pathPoints, texture);
600
+ this.drawSVGRope(pathPoints, texture!);
600
601
  };
601
602
 
602
603
  private drawSVGRope(path: Point[], texture: Texture): void {
603
604
  if (path.length === 0) {
604
- return null;
605
+ return undefined;
605
606
  }
606
607
 
607
608
  const rope: UniformTextureStretchRope = new UniformTextureStretchRope(texture, path);
@@ -609,8 +610,9 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
609
610
  this.addChild(rope);
610
611
  }
611
612
 
612
- private getSymbolTexture(symbolKey: string, diameter: number): Texture {
613
- return new Texture(this.textureSymbolCacheArray[symbolKey].baseTexture, null, new Rectangle(0, 0, 0, diameter), null, groupD8.MAIN_DIAGONAL);
613
+ private getSymbolTexture(symbolKey: string, diameter: number): Texture | undefined {
614
+ const baseTexture = this.textureSymbolCacheArray?.[symbolKey]?.baseTexture;
615
+ return baseTexture ? new Texture(baseTexture, undefined, new Rectangle(0, 0, 0, diameter), undefined, groupD8.MAIN_DIAGONAL) : undefined;
614
616
  }
615
617
 
616
618
  private drawHoleSize = (maxHoleDiameter: number, holeObject: HoleSize): void => {
@@ -623,19 +625,19 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
623
625
  return;
624
626
  }
625
627
 
626
- const { exaggerationFactor, holeOptions } = this.options as SchematicLayerOptions<T>;
628
+ const { exaggerationFactor = 1, holeOptions } = this.options as SchematicLayerOptions<T>;
627
629
  const exaggeratedDiameter = holeObject.diameter * exaggerationFactor;
628
630
  const { rightPath, leftPath } = createTubularRenderingObject(exaggeratedDiameter / 2, pathPoints);
629
- const texture = this.getHoleTexture(holeOptions, exaggeratedDiameter, maxHoleDiameter);
631
+ const texture = this.getHoleTexture(holeOptions!, exaggeratedDiameter, maxHoleDiameter);
630
632
 
631
633
  this.drawHoleRope(pathPoints, texture, maxHoleDiameter);
632
634
 
633
- this.drawOutline(leftPath, rightPath, convertColor(holeOptions.lineColor), HOLE_OUTLINE * exaggerationFactor, 'TopAndBottom', 0);
635
+ this.drawOutline(leftPath, rightPath, convertColor(holeOptions!.lineColor), HOLE_OUTLINE * exaggerationFactor, 'TopAndBottom', 0);
634
636
  };
635
637
 
636
638
  private drawHoleRope(path: Point[], texture: Texture, maxHoleDiameter: number): void {
637
639
  if (path.length === 0) {
638
- return null;
640
+ return undefined;
639
641
  }
640
642
 
641
643
  const rope: SimpleRope = new SimpleRope(texture, path, maxHoleDiameter / DEFAULT_TEXTURE_SIZE);
@@ -694,7 +696,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
694
696
  casingRenderObject.zIndex = zIndex++;
695
697
 
696
698
  return {
697
- result: [...acc.result, foundCementShape, casingRenderObject, ...foundCementSqueezes],
699
+ result: [...acc.result, foundCementShape!, casingRenderObject, ...foundCementSqueezes],
698
700
  remainingCement: acc.remainingCement.filter((c) => c !== foundCementShape),
699
701
  remainingCementSqueezes: acc.remainingCementSqueezes.filter((squeeze) => !foundCementSqueezes.includes(squeeze)),
700
702
  };
@@ -702,7 +704,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
702
704
  { result: [], remainingCement: cementRenderObject, remainingCementSqueezes: cementSqueezes },
703
705
  );
704
706
 
705
- return result.filter((item) => item !== undefined).sort((a, b) => a.zIndex - b.zIndex);
707
+ return result.filter((item): item is InterlacedRenderObjects => item != null).sort((a, b) => a.zIndex! - b.zIndex!);
706
708
  }
707
709
 
708
710
  /**
@@ -714,9 +716,9 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
714
716
  * @param getExaggerationFactor
715
717
  * @returns
716
718
  */
717
- private drawComplexRope(intervals: ComplexRopeSegment[], texture: Texture): ComplexRope {
719
+ private drawComplexRope(intervals: ComplexRopeSegment[], texture: Texture): ComplexRope | undefined {
718
720
  if (intervals.length === 0) {
719
- return null;
721
+ return undefined;
720
722
  }
721
723
  const rope = new ComplexRope(texture, intervals);
722
724
 
@@ -741,8 +743,8 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
741
743
 
742
744
  private drawCasing = (casingRenderObject: CasingRenderObject): void => {
743
745
  const { casingOptions } = this.options as SchematicLayerOptions<T>;
744
- const casingSolidColorNumber = convertColor(casingOptions.solidColor);
745
- const casingLineColorNumber = convertColor(casingOptions.lineColor);
746
+ const casingSolidColorNumber = convertColor(casingOptions!.solidColor);
747
+ const casingLineColorNumber = convertColor(casingOptions!.lineColor);
746
748
 
747
749
  casingRenderObject.sections.forEach((section, index, list) => {
748
750
  const outlineClosureType = SchematicLayer.getOutlineClosureType(index, list.length - 1);
@@ -751,7 +753,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
751
753
  this.drawRope(section.pathPoints, texture, casingSolidColorNumber);
752
754
 
753
755
  if (section.kind === 'casing-window') {
754
- this.drawCasingWindowOutline(section.leftPath, section.rightPath, casingOptions, casingRenderObject.casingWallWidth);
756
+ this.drawCasingWindowOutline(section.leftPath, section.rightPath, casingOptions!, casingRenderObject.casingWallWidth);
755
757
  } else {
756
758
  this.drawOutline(section.leftPath, section.rightPath, casingLineColorNumber, casingRenderObject.casingWallWidth, outlineClosureType);
757
759
  }
@@ -760,13 +762,13 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
760
762
 
761
763
  private createCasingTexture(diameter: number): Texture {
762
764
  const textureWidthPO2 = 16;
763
- return new Texture(Texture.WHITE.baseTexture, null, new Rectangle(0, 0, textureWidthPO2, diameter));
765
+ return new Texture(Texture.WHITE.baseTexture, undefined, new Rectangle(0, 0, textureWidthPO2, diameter));
764
766
  }
765
767
 
766
768
  private drawShoe(casingEnd: number, casingRadius: number): void {
767
- const { exaggerationFactor, casingOptions } = this.options as SchematicLayerOptions<T>;
768
- const shoeWidth = casingOptions.shoeSize.width * exaggerationFactor;
769
- const shoeLength = casingOptions.shoeSize.length * exaggerationFactor;
769
+ const { exaggerationFactor = 1, casingOptions } = this.options as SchematicLayerOptions<T>;
770
+ const shoeWidth = casingOptions!.shoeSize.width * exaggerationFactor;
771
+ const shoeLength = casingOptions!.shoeSize.length * exaggerationFactor;
770
772
 
771
773
  const shoeCoords = this.generateShoe(casingEnd, casingRadius, shoeLength, shoeWidth);
772
774
  const shoeCoords2 = this.generateShoe(casingEnd, casingRadius, shoeLength, -shoeWidth);
@@ -783,8 +785,8 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
783
785
  const normal = createNormals(points);
784
786
  const shoeEdge: Point[] = offsetPoints(points, normal, casingRadius * (width < 0 ? -1 : 1));
785
787
 
786
- const shoeTipPoint = points[points.length - 1];
787
- const shoeTipNormal = normal[normal.length - 1];
788
+ const shoeTipPoint = points[points.length - 1]!;
789
+ const shoeTipNormal = normal[normal.length - 1]!;
788
790
  const shoeTip: Point = offsetPoint(shoeTipPoint, shoeTipNormal, width + casingRadius * (width < 0 ? -1 : 1));
789
791
 
790
792
  return [...shoeEdge, shoeTip];
@@ -796,50 +798,51 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
796
798
  completion: Completion[],
797
799
  holes: HoleSize[],
798
800
  ): ComplexRopeSegment[] => {
799
- const { exaggerationFactor } = this.options as SchematicLayerOptions<T>;
801
+ const { exaggerationFactor = 1 } = this.options as SchematicLayerOptions<T>;
800
802
  return createComplexRopeSegmentsForCementSqueeze(squeeze, casings, completion, holes, exaggerationFactor, this.getZFactorScaledPathForPoints);
801
803
  };
802
804
 
803
- private getCementTexture(): Texture {
805
+ private getCementTexture(): Texture | null {
804
806
  if (!this.cementTextureCache) {
805
807
  const { cementOptions } = this.options as SchematicLayerOptions<T>;
806
- this.cementTextureCache = createCementTexture(cementOptions);
808
+ cementOptions && (this.cementTextureCache = createCementTexture(cementOptions));
807
809
  }
808
810
  return this.cementTextureCache;
809
811
  }
810
812
 
811
813
  private createPerforationShape = (perforation: Perforation, casings: Casing[], holes: HoleSize[]): PerforationShape[] => {
812
- const { exaggerationFactor } = this.options as SchematicLayerOptions<T>;
814
+ const { exaggerationFactor = 1 } = this.options as SchematicLayerOptions<T>;
813
815
  return createComplexRopeSegmentsForPerforation(perforation, casings, holes, exaggerationFactor, this.getZFactorScaledPathForPoints);
814
816
  };
815
817
 
816
- private getCementSqueezeTexture(): Texture {
818
+ private getCementSqueezeTexture(): Texture | null {
817
819
  if (!this.cementSqueezeTextureCache) {
818
820
  const { cementSqueezeOptions } = this.options as SchematicLayerOptions<T>;
819
- this.cementSqueezeTextureCache = createCementSqueezeTexture(cementSqueezeOptions);
821
+ cementSqueezeOptions && (this.cementSqueezeTextureCache = createCementSqueezeTexture(cementSqueezeOptions));
820
822
  }
821
823
  return this.cementSqueezeTextureCache;
822
824
  }
823
825
 
824
826
  private drawScreen({ start, end, diameter }: Screen): void {
825
- const { exaggerationFactor, screenOptions } = this.options as SchematicLayerOptions<T>;
827
+ const { exaggerationFactor = 1, screenOptions } = this.options as SchematicLayerOptions<T>;
826
828
  const exaggeratedDiameter = exaggerationFactor * diameter;
827
829
 
828
830
  const pathPoints = this.getZFactorScaledPathForPoints(start, end);
829
831
  const { leftPath, rightPath } = createTubularRenderingObject(exaggeratedDiameter / 2, pathPoints);
830
832
 
831
833
  const texture = this.getScreenTexture();
832
-
833
- this.drawCompletionRope(pathPoints, texture, exaggeratedDiameter);
834
- this.drawOutline(leftPath, rightPath, convertColor(screenOptions.lineColor), SCREEN_OUTLINE * exaggerationFactor, 'TopAndBottom');
834
+ if (texture) {
835
+ this.drawCompletionRope(pathPoints, texture, exaggeratedDiameter);
836
+ this.drawOutline(leftPath, rightPath, convertColor(screenOptions!.lineColor), SCREEN_OUTLINE * exaggerationFactor, 'TopAndBottom');
837
+ }
835
838
  }
836
839
 
837
840
  private drawTubing({ diameter, start, end }: Tubing): void {
838
- const { exaggerationFactor, tubingOptions } = this.options as SchematicLayerOptions<T>;
841
+ const { exaggerationFactor = 1, tubingOptions } = this.options as SchematicLayerOptions<T>;
839
842
  const exaggeratedDiameter = exaggerationFactor * diameter;
840
843
 
841
844
  const pathPoints = this.getZFactorScaledPathForPoints(start, end);
842
- const texture = this.getTubingTexture(tubingOptions);
845
+ const texture = this.getTubingTexture(tubingOptions!);
843
846
 
844
847
  this.drawCompletionRope(pathPoints, texture, exaggeratedDiameter);
845
848
  }
@@ -851,10 +854,10 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
851
854
  return this.tubingTextureCache;
852
855
  }
853
856
 
854
- private getScreenTexture(): Texture {
857
+ private getScreenTexture(): Texture | null {
855
858
  if (!this.screenTextureCache) {
856
859
  const { screenOptions } = this.options as SchematicLayerOptions<T>;
857
- this.screenTextureCache = createScreenTexture(screenOptions);
860
+ screenOptions && (this.screenTextureCache = createScreenTexture(screenOptions));
858
861
  }
859
862
  return this.screenTextureCache;
860
863
  }