@equinor/esv-intersection 3.1.9 → 4.1.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 (97) hide show
  1. package/dist/components/axis.d.ts.map +1 -1
  2. package/dist/control/ExtendedCurveInterpolator.d.ts.map +1 -1
  3. package/dist/control/IntersectionReferenceSystem.d.ts.map +1 -1
  4. package/dist/control/LayerManager.d.ts.map +1 -1
  5. package/dist/control/MainController.d.ts.map +1 -1
  6. package/dist/control/ZoomPanHandler.d.ts.map +1 -1
  7. package/dist/control/overlay.d.ts.map +1 -1
  8. package/dist/datautils/colortable.d.ts.map +1 -1
  9. package/dist/datautils/findsample.d.ts.map +1 -1
  10. package/dist/datautils/picks.d.ts.map +1 -1
  11. package/dist/datautils/schematicShapeGenerator.d.ts +10 -10
  12. package/dist/datautils/schematicShapeGenerator.d.ts.map +1 -1
  13. package/dist/datautils/seismicimage.d.ts.map +1 -1
  14. package/dist/datautils/surfacedata.d.ts.map +1 -1
  15. package/dist/datautils/trajectory.d.ts.map +1 -1
  16. package/dist/index.cjs +2 -2
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.mjs +2533 -1570
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/index.umd.js +2 -2
  21. package/dist/index.umd.js.map +1 -1
  22. package/dist/layers/CalloutCanvasLayer.d.ts.map +1 -1
  23. package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts +2 -3
  24. package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts.map +1 -1
  25. package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts.map +1 -1
  26. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts +3 -4
  27. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts.map +1 -1
  28. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts +4 -4
  29. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts.map +1 -1
  30. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts +3 -4
  31. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts.map +1 -1
  32. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts +4 -4
  33. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts.map +1 -1
  34. package/dist/layers/GeomodelCanvasLayer.d.ts.map +1 -1
  35. package/dist/layers/GeomodelLabelsLayer.d.ts.map +1 -1
  36. package/dist/layers/GeomodelLayerV2.d.ts.map +1 -1
  37. package/dist/layers/GridLayer.d.ts.map +1 -1
  38. package/dist/layers/ImageCanvasLayer.d.ts.map +1 -1
  39. package/dist/layers/ReferenceLineLayer.d.ts.map +1 -1
  40. package/dist/layers/SchematicLayer.d.ts +6 -6
  41. package/dist/layers/SchematicLayer.d.ts.map +1 -1
  42. package/dist/layers/WellborePathLayer.d.ts.map +1 -1
  43. package/dist/layers/base/CanvasLayer.d.ts.map +1 -1
  44. package/dist/layers/base/HTMLLayer.d.ts.map +1 -1
  45. package/dist/layers/base/Layer.d.ts.map +1 -1
  46. package/dist/layers/base/PixiLayer.d.ts +7 -8
  47. package/dist/layers/base/PixiLayer.d.ts.map +1 -1
  48. package/dist/layers/base/SVGLayer.d.ts.map +1 -1
  49. package/dist/layers/schematicInterfaces.d.ts.map +1 -1
  50. package/dist/utils/arc-length.d.ts.map +1 -1
  51. package/dist/utils/root-finder.d.ts.map +1 -1
  52. package/dist/utils/text.d.ts.map +1 -1
  53. package/dist/utils/vectorUtils.d.ts +6 -6
  54. package/dist/utils/vectorUtils.d.ts.map +1 -1
  55. package/dist/vendor/pixi-dashed-line/index.d.ts +13 -13
  56. package/dist/vendor/pixi-dashed-line/index.d.ts.map +1 -1
  57. package/package.json +4 -6
  58. package/src/components/axis.ts +40 -10
  59. package/src/control/ExtendedCurveInterpolator.ts +47 -9
  60. package/src/control/IntersectionReferenceSystem.ts +110 -30
  61. package/src/control/LayerManager.ts +76 -24
  62. package/src/control/MainController.ts +37 -8
  63. package/src/control/ZoomPanHandler.ts +76 -14
  64. package/src/control/overlay.ts +18 -6
  65. package/src/datautils/colortable.ts +7 -2
  66. package/src/datautils/findsample.ts +12 -2
  67. package/src/datautils/picks.ts +66 -18
  68. package/src/datautils/schematicShapeGenerator.ts +591 -165
  69. package/src/datautils/seismicimage.ts +36 -10
  70. package/src/datautils/surfacedata.ts +119 -40
  71. package/src/datautils/trajectory.ts +56 -17
  72. package/src/layers/CalloutCanvasLayer.ts +129 -26
  73. package/src/layers/CustomDisplayObjects/ComplexRope.ts +11 -13
  74. package/src/layers/CustomDisplayObjects/ComplexRopeGeometry.ts +14 -13
  75. package/src/layers/CustomDisplayObjects/FixedWidthSimpleRope.ts +11 -14
  76. package/src/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.ts +13 -12
  77. package/src/layers/CustomDisplayObjects/UniformTextureStretchRope.ts +16 -17
  78. package/src/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.ts +11 -11
  79. package/src/layers/GeomodelCanvasLayer.ts +10 -3
  80. package/src/layers/GeomodelLabelsLayer.ts +212 -87
  81. package/src/layers/GeomodelLayerV2.ts +11 -7
  82. package/src/layers/GridLayer.ts +14 -3
  83. package/src/layers/ImageCanvasLayer.ts +17 -3
  84. package/src/layers/ReferenceLineLayer.ts +31 -9
  85. package/src/layers/SchematicLayer.ts +533 -173
  86. package/src/layers/WellborePathLayer.ts +22 -7
  87. package/src/layers/base/CanvasLayer.ts +18 -4
  88. package/src/layers/base/HTMLLayer.ts +11 -3
  89. package/src/layers/base/Layer.ts +10 -2
  90. package/src/layers/base/PixiLayer.ts +36 -43
  91. package/src/layers/base/SVGLayer.ts +13 -3
  92. package/src/layers/schematicInterfaces.ts +16 -6
  93. package/src/utils/arc-length.ts +31 -5
  94. package/src/utils/root-finder.ts +32 -4
  95. package/src/utils/text.ts +34 -7
  96. package/src/utils/vectorUtils.ts +27 -10
  97. package/src/vendor/pixi-dashed-line/index.ts +93 -39
@@ -1,7 +1,12 @@
1
1
  import { ScaleLinear } from 'd3-scale';
2
2
 
3
3
  import { CanvasLayer } from './base/CanvasLayer';
4
- import { OnUpdateEvent, Annotation, OnRescaleEvent, BoundingBox } from '../interfaces';
4
+ import {
5
+ OnUpdateEvent,
6
+ Annotation,
7
+ OnRescaleEvent,
8
+ BoundingBox,
9
+ } from '../interfaces';
5
10
  import { calcSize, isOverlapping, getOverlapOffset } from '../utils';
6
11
  import { LayerOptions } from './base/Layer';
7
12
 
@@ -46,7 +51,9 @@ export type Callout = {
46
51
  dy: number;
47
52
  };
48
53
 
49
- export interface CalloutOptions<T extends Annotation[]> extends LayerOptions<T> {
54
+ export interface CalloutOptions<
55
+ T extends Annotation[],
56
+ > extends LayerOptions<T> {
50
57
  minFontSize?: number;
51
58
  maxFontSize?: number;
52
59
  fontSizeFactor?: number;
@@ -98,8 +105,12 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
98
105
  this.backgroundColor = DEFAULT_BACKGROUND_COLOR;
99
106
  }
100
107
 
101
- this.backgroundPadding = options?.backgroundPadding || DEFAULT_BACKGROUND_PADDING;
102
- this.backgroundBorderRadius = getValueOrDefault(options?.backgroundBorderRadius, DEFAULT_BACKGROUND_BORDER_RADIUS);
108
+ this.backgroundPadding =
109
+ options?.backgroundPadding || DEFAULT_BACKGROUND_PADDING;
110
+ this.backgroundBorderRadius = getValueOrDefault(
111
+ options?.backgroundBorderRadius,
112
+ DEFAULT_BACKGROUND_BORDER_RADIUS,
113
+ );
103
114
  }
104
115
 
105
116
  setGroupFilter(filter: string[]): void {
@@ -116,7 +127,8 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
116
127
 
117
128
  override onRescale(event: OnRescaleEvent): void {
118
129
  super.onRescale(event);
119
- const isPanning = this.rescaleEvent && this.rescaleEvent.xRatio === event.xRatio;
130
+ const isPanning =
131
+ this.rescaleEvent && this.rescaleEvent.xRatio === event.xRatio;
120
132
  this.rescaleEvent = event;
121
133
 
122
134
  this.render(isPanning);
@@ -132,21 +144,45 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
132
144
 
133
145
  const { xScale, yScale, xBounds } = this.rescaleEvent;
134
146
 
135
- const fontSize = calcSize(this.fontSizeFactor, this.minFontSize, this.maxFontSize, xScale);
147
+ const fontSize = calcSize(
148
+ this.fontSizeFactor,
149
+ this.minFontSize,
150
+ this.maxFontSize,
151
+ xScale,
152
+ );
136
153
 
137
154
  if (!isPanning || this.callouts.length <= 0) {
138
155
  const { data, ctx, groupFilter } = this;
139
- const { calculateDisplacementFromBottom } = this.referenceSystem.options;
140
- const isLeftToRight = calculateDisplacementFromBottom ? xBounds[0] < xBounds[1] : xBounds[0] > xBounds[1];
156
+ const { calculateDisplacementFromBottom } =
157
+ this.referenceSystem.options;
158
+ const isLeftToRight = calculateDisplacementFromBottom
159
+ ? xBounds[0] < xBounds[1]
160
+ : xBounds[0] > xBounds[1];
141
161
  const scale = 0;
142
162
 
143
163
  ctx != null && (ctx.font = `bold ${fontSize}px arial`);
144
- const filtered = data.filter((d: Annotation) => groupFilter.length <= 0 || groupFilter.includes(d.group));
145
- const offset = calcSize(this.offsetFactor, this.offsetMin, this.offsetMax, xScale);
146
- this.callouts = this.positionCallouts(filtered, isLeftToRight, xScale, yScale, scale, fontSize, offset);
164
+ const filtered = data.filter(
165
+ (d: Annotation) =>
166
+ groupFilter.length <= 0 || groupFilter.includes(d.group),
167
+ );
168
+ const offset = calcSize(
169
+ this.offsetFactor,
170
+ this.offsetMin,
171
+ this.offsetMax,
172
+ xScale,
173
+ );
174
+ this.callouts = this.positionCallouts(
175
+ filtered,
176
+ isLeftToRight,
177
+ xScale,
178
+ yScale,
179
+ scale,
180
+ fontSize,
181
+ offset,
182
+ );
147
183
  }
148
184
 
149
- this.callouts.forEach((callout) => {
185
+ this.callouts.forEach(callout => {
150
186
  const { pos, title, color } = callout;
151
187
  const x = xScale(pos.x);
152
188
  const y = yScale(pos.y);
@@ -160,12 +196,24 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
160
196
  offsetY: callout.dy,
161
197
  };
162
198
 
163
- this.renderCallout(title, callout.label, calloutBB, color, callout.alignment);
199
+ this.renderCallout(
200
+ title,
201
+ callout.label,
202
+ calloutBB,
203
+ color,
204
+ callout.alignment,
205
+ );
164
206
  });
165
207
  });
166
208
  }
167
209
 
168
- private renderBackground(title: string, label: string, x: number, y: number, fontSize: number): void {
210
+ private renderBackground(
211
+ title: string,
212
+ label: string,
213
+ x: number,
214
+ y: number,
215
+ fontSize: number,
216
+ ): void {
169
217
  const { ctx } = this;
170
218
 
171
219
  if (ctx == null) {
@@ -209,12 +257,27 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
209
257
  }
210
258
  }
211
259
 
212
- private renderAnnotation = (title: string, label: string, x: number, y: number, fontSize: number, color: string): void => {
260
+ private renderAnnotation = (
261
+ title: string,
262
+ label: string,
263
+ x: number,
264
+ y: number,
265
+ fontSize: number,
266
+ color: string,
267
+ ): void => {
213
268
  this.renderText(title, x, y - fontSize, fontSize, color, 'arial', 'bold');
214
269
  this.renderText(label, x, y, fontSize, color);
215
270
  };
216
271
 
217
- private renderText(title: string, x: number, y: number, fontSize: number, color: string, font = 'arial', fontStyle = 'normal'): void {
272
+ private renderText(
273
+ title: string,
274
+ x: number,
275
+ y: number,
276
+ fontSize: number,
277
+ color: string,
278
+ font = 'arial',
279
+ fontStyle = 'normal',
280
+ ): void {
218
281
  const { ctx } = this;
219
282
  if (ctx != null) {
220
283
  ctx.font = `${fontStyle} ${fontSize}px ${font}`;
@@ -223,7 +286,12 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
223
286
  }
224
287
  }
225
288
 
226
- private measureTextWidth(title: string, fontSize: number, font = 'arial', fontStyle = 'normal'): number {
289
+ private measureTextWidth(
290
+ title: string,
291
+ fontSize: number,
292
+ font = 'arial',
293
+ fontStyle = 'normal',
294
+ ): number {
227
295
  const { ctx } = this;
228
296
 
229
297
  if (ctx == null) {
@@ -246,12 +314,19 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
246
314
  }
247
315
  }
248
316
 
249
- private renderCallout(title: string, label: string, boundingBox: BoundingBox, color: string, location: string): void {
317
+ private renderCallout(
318
+ title: string,
319
+ label: string,
320
+ boundingBox: BoundingBox,
321
+ color: string,
322
+ location: string,
323
+ ): void {
250
324
  const pos = this.getPosition(boundingBox, location);
251
325
  const { x, y } = pos;
252
326
  const { height, width, x: dotX, y: dotY } = boundingBox;
253
327
 
254
- const placeLeft = location === Location.topright || location === Location.bottomright;
328
+ const placeLeft =
329
+ location === Location.topright || location === Location.bottomright;
255
330
 
256
331
  if (this.backgroundActive) {
257
332
  this.renderBackground(title, label, x, y, height);
@@ -262,7 +337,15 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
262
337
  this.renderLine(x, y, width, dotX, dotY, color, placeLeft);
263
338
  }
264
339
 
265
- private renderLine = (x: number, y: number, width: number, dotX: number, dotY: number, color: string, placeLeft = true): void => {
340
+ private renderLine = (
341
+ x: number,
342
+ y: number,
343
+ width: number,
344
+ dotX: number,
345
+ dotY: number,
346
+ color: string,
347
+ placeLeft = true,
348
+ ): void => {
266
349
  const { ctx } = this;
267
350
  const textX = placeLeft ? x : x + width;
268
351
  const inverseTextX = placeLeft ? x + width : x;
@@ -327,7 +410,7 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
327
410
  }
328
411
  const alignment = isLeftToRight ? Location.topleft : Location.topright;
329
412
 
330
- const nodes = annotations.map((a) => {
413
+ const nodes = annotations.map(a => {
331
414
  const pos = a.pos ? a.pos : this.referenceSystem?.project(a.md!)!;
332
415
  return {
333
416
  title: a.title,
@@ -336,7 +419,14 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
336
419
  pos: { x: pos?.[0]!, y: pos?.[1]! },
337
420
  group: a.group,
338
421
  alignment,
339
- boundingBox: this.getAnnotationBoundingBox(a.title, a.label, pos, xScale, yScale, fontSize),
422
+ boundingBox: this.getAnnotationBoundingBox(
423
+ a.title,
424
+ a.label,
425
+ pos,
426
+ xScale,
427
+ yScale,
428
+ fontSize,
429
+ ),
340
430
  dx: offset,
341
431
  dy: offset,
342
432
  };
@@ -382,14 +472,21 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
382
472
  return bbox;
383
473
  }
384
474
 
385
- chooseTopOrBottomPosition(nodes: Callout[], bottom: Callout[], top: Callout[]): void {
475
+ chooseTopOrBottomPosition(
476
+ nodes: Callout[],
477
+ bottom: Callout[],
478
+ top: Callout[],
479
+ ): void {
386
480
  for (let i = nodes.length - 2; i >= 0; --i) {
387
481
  const node = nodes[i]!;
388
482
  const prevNode = top[0]!;
389
483
 
390
484
  const overlap = isOverlapping(node.boundingBox, prevNode.boundingBox);
391
485
  if (overlap) {
392
- node.alignment = node.alignment === Location.topleft ? Location.bottomright : Location.bottomleft;
486
+ node.alignment =
487
+ node.alignment === Location.topleft
488
+ ? Location.bottomright
489
+ : Location.bottomleft;
393
490
  bottom.push(node);
394
491
  if (i > 0) {
395
492
  top.unshift(nodes[--i]!);
@@ -405,7 +502,10 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
405
502
  const currentNode = top[i]!;
406
503
  for (let j = top.length - 1; j > i; --j) {
407
504
  const prevNode = top[j]!;
408
- const overlap = getOverlapOffset(currentNode.boundingBox, prevNode.boundingBox);
505
+ const overlap = getOverlapOffset(
506
+ currentNode.boundingBox,
507
+ prevNode.boundingBox,
508
+ );
409
509
  if (overlap) {
410
510
  currentNode.dy += overlap.dy;
411
511
  currentNode.boundingBox.y -= overlap.dy;
@@ -419,7 +519,10 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
419
519
  const currentNode = bottom[i]!;
420
520
  for (let j = bottom.length - 1; j > i; --j) {
421
521
  const prevNode = bottom[j]!;
422
- const overlap = getOverlapOffset(prevNode.boundingBox, currentNode.boundingBox);
522
+ const overlap = getOverlapOffset(
523
+ prevNode.boundingBox,
524
+ currentNode.boundingBox,
525
+ );
423
526
  if (overlap) {
424
527
  currentNode.dy += overlap.dy;
425
528
  currentNode.boundingBox.y += overlap.dy;
@@ -1,8 +1,8 @@
1
- import { Mesh, MeshMaterial, IPoint, Renderer, Texture, WRAP_MODES } from 'pixi.js';
1
+ import { Mesh, Point, Texture } from 'pixi.js';
2
2
  import { ComplexRopeGeometry } from './ComplexRopeGeometry';
3
3
 
4
4
  export type ComplexRopeSegment = {
5
- points: IPoint[];
5
+ points: Point[];
6
6
  diameter: number;
7
7
  };
8
8
 
@@ -22,23 +22,21 @@ export class ComplexRope extends Mesh {
22
22
  */
23
23
  constructor(texture: Texture, segments: ComplexRopeSegment[]) {
24
24
  const ropeGeometry = new ComplexRopeGeometry(segments);
25
- const meshMaterial = new MeshMaterial(texture);
26
25
 
27
26
  // attempt to set UV wrapping, will fail on non-power of two textures
28
- texture.baseTexture.wrapMode = WRAP_MODES.REPEAT;
27
+ texture.source.addressMode = 'repeat';
29
28
 
30
- super(ropeGeometry, meshMaterial);
29
+ super({ geometry: ropeGeometry, texture });
31
30
 
32
31
  this.autoUpdate = true;
33
- }
34
-
35
- override _render(renderer: Renderer): void {
36
- const geometry: ComplexRopeGeometry = this.geometry as ComplexRopeGeometry;
37
32
 
38
- if (this.autoUpdate) {
39
- geometry.update();
40
- }
33
+ this.onRender = () => {
34
+ const geometry: ComplexRopeGeometry = this
35
+ .geometry as ComplexRopeGeometry;
41
36
 
42
- super._render(renderer);
37
+ if (this.autoUpdate) {
38
+ geometry.update();
39
+ }
40
+ };
43
41
  }
44
42
  }
@@ -13,10 +13,14 @@ export class ComplexRopeGeometry extends MeshGeometry {
13
13
  * @param segments - An array of segments with points and diameter to construct this rope.
14
14
  */
15
15
  constructor(segments: ComplexRopeSegment[]) {
16
- const pointCount = sum(segments, (segment) => segment.points.length);
16
+ const pointCount = sum(segments, segment => segment.points.length);
17
17
 
18
- // @ts-expect-error Temporary fix until pixi.js is updated
19
- super(new Float32Array(pointCount * 4), new Float32Array(pointCount * 4), new Uint16Array((pointCount - 1) * 6));
18
+ super({
19
+ positions: new Float32Array(pointCount * 4),
20
+ uvs: new Float32Array(pointCount * 4),
21
+ indices: new Uint32Array((pointCount - 1) * 6),
22
+ shrinkBuffersToFit: true,
23
+ });
20
24
 
21
25
  this.segments = segments;
22
26
 
@@ -28,7 +32,7 @@ export class ComplexRopeGeometry extends MeshGeometry {
28
32
  * @readonly
29
33
  */
30
34
  get width(): number {
31
- return max(this.segments, (segment) => segment.diameter)!;
35
+ return max(this.segments, segment => segment.diameter)!;
32
36
  }
33
37
 
34
38
  /** Refreshes Rope indices and uvs */
@@ -39,11 +43,11 @@ export class ComplexRopeGeometry extends MeshGeometry {
39
43
  return;
40
44
  }
41
45
 
42
- const vertexBuffer = this.getBuffer('aVertexPosition');
43
- const uvBuffer = this.getBuffer('aTextureCoord');
46
+ const vertexBuffer = this.getBuffer('aPosition');
47
+ const uvBuffer = this.getBuffer('aUV');
44
48
  const indexBuffer = this.getIndex();
45
49
 
46
- const pointCount = sum(segments, (segment) => segment.points.length);
50
+ const pointCount = sum(segments, segment => segment.points.length);
47
51
 
48
52
  // if too few points, or texture hasn't got UVs set yet just move on.
49
53
  if (pointCount < 1) {
@@ -52,11 +56,8 @@ export class ComplexRopeGeometry extends MeshGeometry {
52
56
 
53
57
  // if the number of points has changed we will need to recreate the arraybuffers
54
58
  if (vertexBuffer.data.length / 4 !== pointCount) {
55
- // @ts-expect-error Temporary fix until pixi.js is updated
56
59
  vertexBuffer.data = new Float32Array(pointCount * 4);
57
- // @ts-expect-error Temporary fix until pixi.js is updated
58
60
  uvBuffer.data = new Float32Array(pointCount * 4);
59
- // @ts-expect-error Temporary fix until pixi.js is updated
60
61
  indexBuffer.data = new Uint16Array((pointCount - 1) * 6);
61
62
  }
62
63
 
@@ -69,7 +70,7 @@ export class ComplexRopeGeometry extends MeshGeometry {
69
70
  uvs[3] = 1;
70
71
 
71
72
  const segmentCount = segments.length;
72
- const maxDiameter = max(segments, (segment) => segment.diameter)!;
73
+ const maxDiameter = max(segments, segment => segment.diameter)!;
73
74
 
74
75
  let amount = 0;
75
76
  let uvIndex = 0;
@@ -125,7 +126,7 @@ export class ComplexRopeGeometry extends MeshGeometry {
125
126
  /** refreshes vertices of Rope mesh */
126
127
  public updateVertices(): void {
127
128
  const segments = this.segments;
128
- const pointCount = sum(segments, (segment) => segment.points.length);
129
+ const pointCount = sum(segments, segment => segment.points.length);
129
130
 
130
131
  if (pointCount < 1) {
131
132
  return;
@@ -182,7 +183,7 @@ export class ComplexRopeGeometry extends MeshGeometry {
182
183
  public update(): void {
183
184
  // TODO: Possible optimiztion to be had here
184
185
  // Figure out if/when it is enough to only update verticies with this.updateVertices()
185
- // See PIXI.SimpleRope.update() for ideas
186
+ // See MeshRope.update() for ideas
186
187
 
187
188
  // build() sets indicies and uvs and then calls this.updateVertices()
188
189
  this.build();
@@ -1,4 +1,4 @@
1
- import { IPoint, Mesh, MeshMaterial, Renderer, RopeGeometry, Texture, WRAP_MODES } from 'pixi.js';
1
+ import { Point, Mesh, RopeGeometry, Texture } from 'pixi.js';
2
2
  import { FixedWidthSimpleRopeGeometry } from './FixedWidthSimpleRopeGeometry';
3
3
 
4
4
  /**
@@ -15,27 +15,24 @@ export class FixedWidthSimpleRope extends Mesh {
15
15
  /**
16
16
  * Note: The wrap mode of the texture is set to REPEAT if `textureScale` is positive.
17
17
  * @param texture - The texture to use on the rope. (attempt to set UV wrapping, will fail on non-power of two textures)
18
- * @param points - An array of {@link PIXI.Point} objects to construct this rope.
18
+ * @param points - An array of {@link Point} objects to construct this rope.
19
19
  * @param width - Width of rope
20
20
  */
21
- constructor(texture: Texture, points: IPoint[], width: number) {
21
+ constructor(texture: Texture, points: Point[], width: number) {
22
22
  const ropeGeometry = new FixedWidthSimpleRopeGeometry(points, width);
23
- const meshMaterial = new MeshMaterial(texture);
24
23
 
25
- texture.baseTexture.wrapMode = WRAP_MODES.REPEAT;
24
+ texture.source.addressMode = 'repeat';
26
25
 
27
- super(ropeGeometry, meshMaterial);
26
+ super({ geometry: ropeGeometry, texture });
28
27
 
29
28
  this.autoUpdate = true;
30
- }
31
-
32
- override _render(renderer: Renderer): void {
33
- const geometry: RopeGeometry = this.geometry as RopeGeometry;
34
29
 
35
- if (this.autoUpdate) {
36
- geometry.update();
37
- }
30
+ this.onRender = () => {
31
+ const geometry: RopeGeometry = this.geometry as RopeGeometry;
38
32
 
39
- super._render(renderer);
33
+ if (this.autoUpdate) {
34
+ geometry.update();
35
+ }
36
+ };
40
37
  }
41
38
  }
@@ -1,18 +1,21 @@
1
- import { IPoint, MeshGeometry } from 'pixi.js';
1
+ import { Point, MeshGeometry } from 'pixi.js';
2
2
 
3
3
  export class FixedWidthSimpleRopeGeometry extends MeshGeometry {
4
- public points: IPoint[];
4
+ public points: Point[];
5
5
  _width: number;
6
6
  /**
7
7
  * @param {number} [width=200] - The width (i.e., thickness) of the rope.
8
- * @param {PIXI.Point[]} [points] - An array of PIXI.Point objects to construct this rope.
8
+ * @param {Point[]} [points] - An array of Point objects to construct this rope.
9
9
  */
10
- constructor(points: IPoint[], width = 200) {
11
- // @ts-expect-error Temporary fix until pixi.js is updated
12
- super(new Float32Array(points.length * 4), new Float32Array(points.length * 4), new Uint16Array((points.length - 1) * 6));
10
+ constructor(points: Point[], width = 200) {
11
+ super({
12
+ positions: new Float32Array(points.length * 4),
13
+ uvs: new Float32Array(points.length * 4),
14
+ indices: new Uint32Array((points.length - 1) * 6),
15
+ });
13
16
  /**
14
17
  * An array of points that determine the rope
15
- * @member {PIXI.Point[]}
18
+ * @member {Point[]}
16
19
  */
17
20
  this.points = points;
18
21
  /**
@@ -45,20 +48,18 @@ export class FixedWidthSimpleRopeGeometry extends MeshGeometry {
45
48
  if (!points) {
46
49
  return;
47
50
  }
48
- const vertexBuffer = this.getBuffer('aVertexPosition');
49
- const uvBuffer = this.getBuffer('aTextureCoord');
51
+ const vertexBuffer = this.getBuffer('aPosition');
52
+ const uvBuffer = this.getBuffer('aUV');
50
53
  const indexBuffer = this.getIndex();
54
+
51
55
  // if too little points, or texture hasn't got UVs set yet just move on.
52
56
  if (points.length < 1) {
53
57
  return;
54
58
  }
55
59
  // if the number of points has changed we will need to recreate the arraybuffers
56
60
  if (vertexBuffer.data.length / 4 !== points.length) {
57
- // @ts-expect-error Temporary fix until pixi.js is updated
58
61
  vertexBuffer.data = new Float32Array(points.length * 4);
59
- // @ts-expect-error Temporary fix until pixi.js is updated
60
62
  uvBuffer.data = new Float32Array(points.length * 4);
61
- // @ts-expect-error Temporary fix until pixi.js is updated
62
63
  indexBuffer.data = new Uint16Array((points.length - 1) * 6);
63
64
  }
64
65
  const uvs = uvBuffer.data;
@@ -1,4 +1,4 @@
1
- import { IPoint, Mesh, MeshMaterial, Renderer, Texture } from 'pixi.js';
1
+ import { Point, Mesh, Texture } from 'pixi.js';
2
2
  import { UniformTextureStretchRopeGeometry } from './UniformTextureStretchRopeGeometry';
3
3
 
4
4
  /**
@@ -13,27 +13,26 @@ export class UniformTextureStretchRope extends Mesh {
13
13
 
14
14
  /**
15
15
  * @param texture - The texture to use on the rope.
16
- * @param points - An array of {@link PIXI.Point} objects to construct this rope.
16
+ * @param points - An array of {@link Point} objects to construct this rope.
17
17
  */
18
- constructor(texture: Texture, points: IPoint[]) {
19
- const ropeGeometry = new UniformTextureStretchRopeGeometry(points, texture.height);
20
- const meshMaterial = new MeshMaterial(texture);
18
+ constructor(texture: Texture, points: Point[]) {
19
+ const ropeGeometry = new UniformTextureStretchRopeGeometry(
20
+ points,
21
+ texture.height,
22
+ );
21
23
 
22
- super(ropeGeometry, meshMaterial);
24
+ super({ geometry: ropeGeometry, texture });
23
25
 
24
26
  this.autoUpdate = true;
25
- }
26
-
27
- override _render(renderer: Renderer): void {
28
- const geometry: UniformTextureStretchRopeGeometry = this.geometry as UniformTextureStretchRopeGeometry;
29
27
 
30
- // TODO: Possible optimiztion here
31
- // Find correct check for when to update geometry
32
- if (this.autoUpdate || geometry._width !== this.shader.texture.height) {
33
- geometry._width = this.shader.texture.height;
34
- geometry.update();
35
- }
28
+ this.onRender = () => {
29
+ const geometry: UniformTextureStretchRopeGeometry = this
30
+ .geometry as UniformTextureStretchRopeGeometry;
36
31
 
37
- super._render(renderer);
32
+ if (this.autoUpdate || geometry._width !== this.shader?.texture.height) {
33
+ geometry._width = this.shader?.texture.height ?? 0;
34
+ geometry.update();
35
+ }
36
+ };
38
37
  }
39
38
  }
@@ -1,12 +1,12 @@
1
1
  import { MeshGeometry } from 'pixi.js';
2
- import type { IPoint } from 'pixi.js';
2
+ import type { Point } from 'pixi.js';
3
3
 
4
4
  /**
5
5
  * UniformTextureStretchRopeGeometry allows you to draw a geometry across several points and then manipulate these points.
6
6
  */
7
7
  export class UniformTextureStretchRopeGeometry extends MeshGeometry {
8
8
  /** An array of points that determine the rope. */
9
- public points: IPoint[];
9
+ public points: Point[];
10
10
 
11
11
  /**
12
12
  * The width (i.e., thickness) of the rope.
@@ -16,11 +16,14 @@ export class UniformTextureStretchRopeGeometry extends MeshGeometry {
16
16
 
17
17
  /**
18
18
  * @param width - The width (i.e., thickness) of the rope.
19
- * @param points - An array of PIXI.Point objects to construct this rope.
19
+ * @param points - An array of Point objects to construct this rope.
20
20
  */
21
- constructor(points: IPoint[], width = 200) {
22
- // @ts-expect-error Temporary fix until pixi.js is updated
23
- super(new Float32Array(points.length * 4), new Float32Array(points.length * 4), new Uint16Array((points.length - 1) * 6));
21
+ constructor(points: Point[], width = 200) {
22
+ super({
23
+ positions: new Float32Array(points.length * 4),
24
+ uvs: new Float32Array(points.length * 4),
25
+ indices: new Uint32Array((points.length - 1) * 6),
26
+ });
24
27
 
25
28
  this.points = points;
26
29
  this._width = width;
@@ -36,8 +39,8 @@ export class UniformTextureStretchRopeGeometry extends MeshGeometry {
36
39
  return;
37
40
  }
38
41
 
39
- const vertexBuffer = this.getBuffer('aVertexPosition');
40
- const uvBuffer = this.getBuffer('aTextureCoord');
42
+ const vertexBuffer = this.getBuffer('aPosition');
43
+ const uvBuffer = this.getBuffer('aUV');
41
44
  const indexBuffer = this.getIndex();
42
45
 
43
46
  // if too few points, or texture hasn't got UVs set yet just move on.
@@ -47,11 +50,8 @@ export class UniformTextureStretchRopeGeometry extends MeshGeometry {
47
50
 
48
51
  // if the number of points has changed we will need to recreate the arraybuffers
49
52
  if (vertexBuffer.data.length / 4 !== points.length) {
50
- // @ts-expect-error Temporary fix until pixi.js is updated
51
53
  vertexBuffer.data = new Float32Array(points.length * 4);
52
- // @ts-expect-error Temporary fix until pixi.js is updated
53
54
  uvBuffer.data = new Float32Array(points.length * 4);
54
- // @ts-expect-error Temporary fix until pixi.js is updated
55
55
  indexBuffer.data = new Uint16Array((points.length - 1) * 6);
56
56
  }
57
57
 
@@ -59,8 +59,12 @@ export class GeomodelCanvasLayer<T extends SurfaceData> extends CanvasLayer<T> {
59
59
 
60
60
  requestAnimationFrame(() => {
61
61
  this.clearCanvas();
62
- this.surfaceAreasPaths.forEach((p: SurfacePaths) => this.drawPolygonPath(p.color, p.path));
63
- this.surfaceLinesPaths.forEach((l: SurfacePaths) => this.drawLinePath(l.color, l.path));
62
+ this.surfaceAreasPaths.forEach((p: SurfacePaths) =>
63
+ this.drawPolygonPath(p.color, p.path),
64
+ );
65
+ this.surfaceLinesPaths.forEach((l: SurfacePaths) =>
66
+ this.drawLinePath(l.color, l.path),
67
+ );
64
68
  });
65
69
  }
66
70
 
@@ -85,7 +89,10 @@ export class GeomodelCanvasLayer<T extends SurfaceData> extends CanvasLayer<T> {
85
89
  this.surfaceLinesPaths =
86
90
  this.data?.lines.reduce((acc: SurfacePaths[], l: SurfaceLine) => {
87
91
  const lines = this.generateLinePaths(l);
88
- const mapped: SurfacePaths[] = lines.map((path: Path2D) => ({ color: this.colorToCSSColor(l.color), path }));
92
+ const mapped: SurfacePaths[] = lines.map((path: Path2D) => ({
93
+ color: this.colorToCSSColor(l.color),
94
+ path,
95
+ }));
89
96
  acc.push(...mapped);
90
97
  return acc;
91
98
  }, []) ?? [];