@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.
- package/dist/components/axis.d.ts.map +1 -1
- package/dist/control/ExtendedCurveInterpolator.d.ts.map +1 -1
- package/dist/control/IntersectionReferenceSystem.d.ts.map +1 -1
- package/dist/control/LayerManager.d.ts.map +1 -1
- package/dist/control/MainController.d.ts.map +1 -1
- package/dist/control/ZoomPanHandler.d.ts.map +1 -1
- package/dist/control/overlay.d.ts.map +1 -1
- package/dist/datautils/colortable.d.ts.map +1 -1
- package/dist/datautils/findsample.d.ts.map +1 -1
- package/dist/datautils/picks.d.ts.map +1 -1
- package/dist/datautils/schematicShapeGenerator.d.ts +10 -10
- package/dist/datautils/schematicShapeGenerator.d.ts.map +1 -1
- package/dist/datautils/seismicimage.d.ts.map +1 -1
- package/dist/datautils/surfacedata.d.ts.map +1 -1
- package/dist/datautils/trajectory.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2533 -1570
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/layers/CalloutCanvasLayer.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts +2 -3
- package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts +3 -4
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts +4 -4
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts +3 -4
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts +4 -4
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts.map +1 -1
- package/dist/layers/GeomodelCanvasLayer.d.ts.map +1 -1
- package/dist/layers/GeomodelLabelsLayer.d.ts.map +1 -1
- package/dist/layers/GeomodelLayerV2.d.ts.map +1 -1
- package/dist/layers/GridLayer.d.ts.map +1 -1
- package/dist/layers/ImageCanvasLayer.d.ts.map +1 -1
- package/dist/layers/ReferenceLineLayer.d.ts.map +1 -1
- package/dist/layers/SchematicLayer.d.ts +6 -6
- package/dist/layers/SchematicLayer.d.ts.map +1 -1
- package/dist/layers/WellborePathLayer.d.ts.map +1 -1
- package/dist/layers/base/CanvasLayer.d.ts.map +1 -1
- package/dist/layers/base/HTMLLayer.d.ts.map +1 -1
- package/dist/layers/base/Layer.d.ts.map +1 -1
- package/dist/layers/base/PixiLayer.d.ts +7 -8
- package/dist/layers/base/PixiLayer.d.ts.map +1 -1
- package/dist/layers/base/SVGLayer.d.ts.map +1 -1
- package/dist/layers/schematicInterfaces.d.ts.map +1 -1
- package/dist/utils/arc-length.d.ts.map +1 -1
- package/dist/utils/root-finder.d.ts.map +1 -1
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/vectorUtils.d.ts +6 -6
- package/dist/utils/vectorUtils.d.ts.map +1 -1
- package/dist/vendor/pixi-dashed-line/index.d.ts +13 -13
- package/dist/vendor/pixi-dashed-line/index.d.ts.map +1 -1
- package/package.json +4 -6
- package/src/components/axis.ts +40 -10
- package/src/control/ExtendedCurveInterpolator.ts +47 -9
- package/src/control/IntersectionReferenceSystem.ts +110 -30
- package/src/control/LayerManager.ts +76 -24
- package/src/control/MainController.ts +37 -8
- package/src/control/ZoomPanHandler.ts +76 -14
- package/src/control/overlay.ts +18 -6
- package/src/datautils/colortable.ts +7 -2
- package/src/datautils/findsample.ts +12 -2
- package/src/datautils/picks.ts +66 -18
- package/src/datautils/schematicShapeGenerator.ts +591 -165
- package/src/datautils/seismicimage.ts +36 -10
- package/src/datautils/surfacedata.ts +119 -40
- package/src/datautils/trajectory.ts +56 -17
- package/src/layers/CalloutCanvasLayer.ts +129 -26
- package/src/layers/CustomDisplayObjects/ComplexRope.ts +11 -13
- package/src/layers/CustomDisplayObjects/ComplexRopeGeometry.ts +14 -13
- package/src/layers/CustomDisplayObjects/FixedWidthSimpleRope.ts +11 -14
- package/src/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.ts +13 -12
- package/src/layers/CustomDisplayObjects/UniformTextureStretchRope.ts +16 -17
- package/src/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.ts +11 -11
- package/src/layers/GeomodelCanvasLayer.ts +10 -3
- package/src/layers/GeomodelLabelsLayer.ts +212 -87
- package/src/layers/GeomodelLayerV2.ts +11 -7
- package/src/layers/GridLayer.ts +14 -3
- package/src/layers/ImageCanvasLayer.ts +17 -3
- package/src/layers/ReferenceLineLayer.ts +31 -9
- package/src/layers/SchematicLayer.ts +533 -173
- package/src/layers/WellborePathLayer.ts +22 -7
- package/src/layers/base/CanvasLayer.ts +18 -4
- package/src/layers/base/HTMLLayer.ts +11 -3
- package/src/layers/base/Layer.ts +10 -2
- package/src/layers/base/PixiLayer.ts +36 -43
- package/src/layers/base/SVGLayer.ts +13 -3
- package/src/layers/schematicInterfaces.ts +16 -6
- package/src/utils/arc-length.ts +31 -5
- package/src/utils/root-finder.ts +32 -4
- package/src/utils/text.ts +34 -7
- package/src/utils/vectorUtils.ts +27 -10
- 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 {
|
|
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<
|
|
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 =
|
|
102
|
-
|
|
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 =
|
|
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(
|
|
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 } =
|
|
140
|
-
|
|
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(
|
|
145
|
-
|
|
146
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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 = (
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
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 = (
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
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(
|
|
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(
|
|
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,
|
|
1
|
+
import { Mesh, Point, Texture } from 'pixi.js';
|
|
2
2
|
import { ComplexRopeGeometry } from './ComplexRopeGeometry';
|
|
3
3
|
|
|
4
4
|
export type ComplexRopeSegment = {
|
|
5
|
-
points:
|
|
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.
|
|
27
|
+
texture.source.addressMode = 'repeat';
|
|
29
28
|
|
|
30
|
-
super(ropeGeometry,
|
|
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
|
-
|
|
39
|
-
geometry
|
|
40
|
-
|
|
33
|
+
this.onRender = () => {
|
|
34
|
+
const geometry: ComplexRopeGeometry = this
|
|
35
|
+
.geometry as ComplexRopeGeometry;
|
|
41
36
|
|
|
42
|
-
|
|
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,
|
|
16
|
+
const pointCount = sum(segments, segment => segment.points.length);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
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,
|
|
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('
|
|
43
|
-
const uvBuffer = this.getBuffer('
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
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 {
|
|
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
|
|
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:
|
|
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.
|
|
24
|
+
texture.source.addressMode = 'repeat';
|
|
26
25
|
|
|
27
|
-
super(ropeGeometry,
|
|
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
|
-
|
|
36
|
-
geometry.
|
|
37
|
-
}
|
|
30
|
+
this.onRender = () => {
|
|
31
|
+
const geometry: RopeGeometry = this.geometry as RopeGeometry;
|
|
38
32
|
|
|
39
|
-
|
|
33
|
+
if (this.autoUpdate) {
|
|
34
|
+
geometry.update();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
40
37
|
}
|
|
41
38
|
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Point, MeshGeometry } from 'pixi.js';
|
|
2
2
|
|
|
3
3
|
export class FixedWidthSimpleRopeGeometry extends MeshGeometry {
|
|
4
|
-
public points:
|
|
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 {
|
|
8
|
+
* @param {Point[]} [points] - An array of Point objects to construct this rope.
|
|
9
9
|
*/
|
|
10
|
-
constructor(points:
|
|
11
|
-
|
|
12
|
-
|
|
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 {
|
|
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('
|
|
49
|
-
const uvBuffer = this.getBuffer('
|
|
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 {
|
|
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
|
|
16
|
+
* @param points - An array of {@link Point} objects to construct this rope.
|
|
17
17
|
*/
|
|
18
|
-
constructor(texture: Texture, points:
|
|
19
|
-
const ropeGeometry = new UniformTextureStretchRopeGeometry(
|
|
20
|
-
|
|
18
|
+
constructor(texture: Texture, points: Point[]) {
|
|
19
|
+
const ropeGeometry = new UniformTextureStretchRopeGeometry(
|
|
20
|
+
points,
|
|
21
|
+
texture.height,
|
|
22
|
+
);
|
|
21
23
|
|
|
22
|
-
super(ropeGeometry,
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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 {
|
|
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:
|
|
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
|
|
19
|
+
* @param points - An array of Point objects to construct this rope.
|
|
20
20
|
*/
|
|
21
|
-
constructor(points:
|
|
22
|
-
|
|
23
|
-
|
|
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('
|
|
40
|
-
const uvBuffer = this.getBuffer('
|
|
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) =>
|
|
63
|
-
|
|
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) => ({
|
|
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
|
}, []) ?? [];
|