@equinor/esv-intersection 3.1.8 → 4.0.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 (41) hide show
  1. package/dist/datautils/schematicShapeGenerator.d.ts +5 -5
  2. package/dist/datautils/schematicShapeGenerator.d.ts.map +1 -1
  3. package/dist/index.cjs +2 -2
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.mjs +1386 -1381
  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/layers/CustomDisplayObjects/ComplexRope.d.ts +2 -3
  10. package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts.map +1 -1
  11. package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts.map +1 -1
  12. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts +3 -4
  13. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts.map +1 -1
  14. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts +4 -4
  15. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts.map +1 -1
  16. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts +3 -4
  17. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts.map +1 -1
  18. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts +4 -4
  19. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts.map +1 -1
  20. package/dist/layers/GeomodelLayerV2.d.ts.map +1 -1
  21. package/dist/layers/SchematicLayer.d.ts +6 -6
  22. package/dist/layers/SchematicLayer.d.ts.map +1 -1
  23. package/dist/layers/base/PixiLayer.d.ts +7 -8
  24. package/dist/layers/base/PixiLayer.d.ts.map +1 -1
  25. package/dist/utils/vectorUtils.d.ts +6 -6
  26. package/dist/utils/vectorUtils.d.ts.map +1 -1
  27. package/dist/vendor/pixi-dashed-line/index.d.ts +13 -13
  28. package/dist/vendor/pixi-dashed-line/index.d.ts.map +1 -1
  29. package/package.json +3 -6
  30. package/src/datautils/schematicShapeGenerator.ts +23 -21
  31. package/src/layers/CustomDisplayObjects/ComplexRope.ts +10 -13
  32. package/src/layers/CustomDisplayObjects/ComplexRopeGeometry.ts +9 -8
  33. package/src/layers/CustomDisplayObjects/FixedWidthSimpleRope.ts +11 -14
  34. package/src/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.ts +13 -12
  35. package/src/layers/CustomDisplayObjects/UniformTextureStretchRope.ts +11 -16
  36. package/src/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.ts +11 -11
  37. package/src/layers/GeomodelLayerV2.ts +4 -5
  38. package/src/layers/SchematicLayer.ts +42 -31
  39. package/src/layers/base/PixiLayer.ts +11 -38
  40. package/src/utils/vectorUtils.ts +6 -6
  41. package/src/vendor/pixi-dashed-line/index.ts +33 -32
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1
2
  // @ts-nocheck
2
3
  // https://github.com/davidfig/pixi-dashed-line
3
4
  //
@@ -18,7 +19,7 @@
18
19
  // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
20
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21
 
21
- import * as PIXI from 'pixi.js';
22
+ import { Graphics, Matrix, Point, Texture, SCALE_MODES } from 'pixi.js';
22
23
 
23
24
  /** Define the dash: [dash length, gap size, dash size, gap size, ...] */
24
25
  export type Dashes = number[];
@@ -31,8 +32,8 @@ export interface DashLineOptions {
31
32
  scale?: number;
32
33
  useTexture?: boolean;
33
34
  useDots?: boolean;
34
- cap?: PIXI.LINE_CAP;
35
- join?: PIXI.LINE_JOIN;
35
+ cap?: LINE_CAP;
36
+ join?: LINE_JOIN;
36
37
  alignment?: number;
37
38
  }
38
39
 
@@ -47,18 +48,18 @@ const dashLineOptionsDefault: Partial<DashLineOptions> = {
47
48
  };
48
49
 
49
50
  export class DashLine {
50
- graphics: PIXI.Graphics;
51
+ graphics: Graphics;
51
52
 
52
53
  /** current length of the line */
53
54
  lineLength: number;
54
55
 
55
56
  /** cursor location */
56
- cursor = new PIXI.Point();
57
+ cursor = new Point();
57
58
 
58
59
  /** desired scale of line */
59
60
  scale = 1;
60
61
 
61
- private start: PIXI.Point;
62
+ private start: Point;
62
63
 
63
64
  private dashSize: number;
64
65
  private dash: number[];
@@ -66,8 +67,8 @@ export class DashLine {
66
67
  private useTexture: boolean;
67
68
  private options: DashLineOptions;
68
69
 
69
- // cache of PIXI.Textures for dashed lines
70
- static dashTextureCache: Record<string, PIXI.Texture> = {};
70
+ // cache of Textures for dashed lines
71
+ static dashTextureCache: Record<string, Texture> = {};
71
72
 
72
73
  /**
73
74
  * Create a DashLine
@@ -78,11 +79,11 @@ export class DashLine {
78
79
  * @param [options.width=1] - width of the dashed line
79
80
  * @param [options.alpha=1] - alpha of the dashed line
80
81
  * @param [options.color=0xffffff] - color of the dashed line
81
- * @param [options.cap] - add a PIXI.LINE_CAP style to dashed lines (only works for useTexture: false)
82
- * @param [options.join] - add a PIXI.LINE_JOIN style to the dashed lines (only works for useTexture: false)
82
+ * @param [options.cap] - add a LINE_CAP style to dashed lines (only works for useTexture: false)
83
+ * @param [options.join] - add a LINE_JOIN style to the dashed lines (only works for useTexture: false)
83
84
  * @param [options.alignment] - The alignment of any lines drawn (0.5 = middle, 1 = outer, 0 = inner)
84
85
  */
85
- constructor(graphics: PIXI.Graphics, options: DashLineOptions = {}) {
86
+ constructor(graphics: Graphics, options: DashLineOptions = {}) {
86
87
  this.graphics = graphics;
87
88
  options = { ...dashLineOptionsDefault, ...options };
88
89
  this.dash = options.dash;
@@ -105,7 +106,7 @@ export class DashLine {
105
106
  alignment: options.alignment,
106
107
  });
107
108
  } else {
108
- this.graphics.lineStyle({
109
+ this.graphics.setStrokeStyle({
109
110
  width: options.width * options.scale,
110
111
  color: options.color,
111
112
  alpha: options.alpha,
@@ -124,7 +125,7 @@ export class DashLine {
124
125
  moveTo(x: number, y: number): this {
125
126
  this.lineLength = 0;
126
127
  this.cursor.set(x, y);
127
- this.start = new PIXI.Point(x, y);
128
+ this.start = new Point(x, y);
128
129
  this.graphics.moveTo(this.cursor.x, this.cursor.y);
129
130
  return this;
130
131
  }
@@ -212,18 +213,18 @@ export class DashLine {
212
213
  this.lineTo(this.start.x, this.start.y, true);
213
214
  }
214
215
 
215
- drawCircle(x: number, y: number, radius: number, points = 80, matrix?: PIXI.Matrix): this {
216
+ drawCircle(x: number, y: number, radius: number, points = 80, matrix?: Matrix): this {
216
217
  const interval = (Math.PI * 2) / points;
217
218
  let angle = 0,
218
- first: PIXI.Point;
219
+ first: Point;
219
220
  if (matrix) {
220
- first = new PIXI.Point(x + Math.cos(angle) * radius, y + Math.sin(angle) * radius);
221
+ first = new Point(x + Math.cos(angle) * radius, y + Math.sin(angle) * radius);
221
222
  matrix.apply(first, first);
222
223
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
223
224
  // @ts-ignore
224
225
  this.moveTo(first[0], first[1]);
225
226
  } else {
226
- first = new PIXI.Point(x + Math.cos(angle) * radius, y + Math.sin(angle) * radius);
227
+ first = new Point(x + Math.cos(angle) * radius, y + Math.sin(angle) * radius);
227
228
  this.moveTo(first.x, first.y);
228
229
  }
229
230
  angle += interval;
@@ -237,10 +238,10 @@ export class DashLine {
237
238
  return this;
238
239
  }
239
240
 
240
- drawEllipse(x: number, y: number, radiusX: number, radiusY: number, points = 80, matrix?: PIXI.Matrix): this {
241
+ drawEllipse(x: number, y: number, radiusX: number, radiusY: number, points = 80, matrix?: Matrix): this {
241
242
  const interval = (Math.PI * 2) / points;
242
243
  let first: { x: number; y: number };
243
- const point = new PIXI.Point();
244
+ const point = new Point();
244
245
  for (let i = 0; i < Math.PI * 2; i += interval) {
245
246
  let x0 = x - radiusX * Math.sin(i);
246
247
  let y0 = y - radiusY * Math.cos(i);
@@ -261,8 +262,8 @@ export class DashLine {
261
262
  return this;
262
263
  }
263
264
 
264
- drawPolygon(points: PIXI.Point[] | number[], matrix?: PIXI.Matrix): this {
265
- const p = new PIXI.Point();
265
+ drawPolygon(points: Point[] | number[], matrix?: Matrix): this {
266
+ const p = new Point();
266
267
  if (typeof points[0] === 'number') {
267
268
  if (matrix) {
268
269
  p.set(points[0] as number, points[1] as number);
@@ -281,21 +282,21 @@ export class DashLine {
281
282
  }
282
283
  } else {
283
284
  if (matrix) {
284
- const point = points[0] as PIXI.Point;
285
+ const point = points[0] as Point;
285
286
  p.copyFrom(point);
286
287
  matrix.apply(p, p);
287
288
  this.moveTo(p.x, p.y);
288
289
  for (let i = 1; i < points.length; i++) {
289
- const point = points[i] as PIXI.Point;
290
+ const point = points[i] as Point;
290
291
  p.copyFrom(point);
291
292
  matrix.apply(p, p);
292
293
  this.lineTo(p.x, p.y, i === points.length - 1);
293
294
  }
294
295
  } else {
295
- const point = points[0] as PIXI.Point;
296
+ const point = points[0] as Point;
296
297
  this.moveTo(point.x, point.y);
297
298
  for (let i = 1; i < points.length; i++) {
298
- const point = points[i] as PIXI.Point;
299
+ const point = points[i] as Point;
299
300
  this.lineTo(point.x, point.y, i === points.length - 1);
300
301
  }
301
302
  }
@@ -303,9 +304,9 @@ export class DashLine {
303
304
  return this;
304
305
  }
305
306
 
306
- drawRect(x: number, y: number, width: number, height: number, matrix?: PIXI.Matrix): this {
307
+ drawRect(x: number, y: number, width: number, height: number, matrix?: Matrix): this {
307
308
  if (matrix) {
308
- const p = new PIXI.Point();
309
+ const p = new Point();
309
310
 
310
311
  // moveTo(x, y)
311
312
  p.set(x, y);
@@ -344,7 +345,7 @@ export class DashLine {
344
345
  // adjust the matrix for the dashed texture
345
346
  private adjustLineStyle(angle: number) {
346
347
  const lineStyle = this.graphics.line;
347
- lineStyle.matrix = new PIXI.Matrix();
348
+ lineStyle.matrix = new Matrix();
348
349
  if (angle) {
349
350
  lineStyle.matrix.rotate(angle);
350
351
  }
@@ -357,7 +358,7 @@ export class DashLine {
357
358
  }
358
359
 
359
360
  // creates or uses cached texture
360
- private static getTexture(options: DashLineOptions, dashSize: number): PIXI.Texture | undefined {
361
+ private static getTexture(options: DashLineOptions, dashSize: number): Texture | undefined {
361
362
  const key = options.dash.toString();
362
363
  if (DashLine.dashTextureCache[key]) {
363
364
  return DashLine.dashTextureCache[key];
@@ -370,7 +371,6 @@ export class DashLine {
370
371
  console.warn('Did not get context from canvas');
371
372
  return undefined;
372
373
  }
373
- context.strokeStyle = 'white';
374
374
  context.globalAlpha = options.alpha;
375
375
  context.lineWidth = options.width;
376
376
  let x = 0;
@@ -384,9 +384,10 @@ export class DashLine {
384
384
  context.moveTo(x, y);
385
385
  }
386
386
  }
387
+ context.strokeStyle = 'white';
387
388
  context.stroke();
388
- const texture = (DashLine.dashTextureCache[key] = PIXI.Texture.from(canvas));
389
- texture.baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST;
389
+ const texture = (DashLine.dashTextureCache[key] = Texture.from(canvas));
390
+ texture.baseTexture.scaleMode = SCALE_MODES.NEAREST;
390
391
  return texture;
391
392
  }
392
393
  }