@margoengine/points 0.0.0-stage → 1.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.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +876 -2
- package/dist/attributes-DNc-1pdr.js +256 -0
- package/dist/attributes.d.ts +48 -0
- package/dist/clip.d.ts +55 -0
- package/dist/clip.js +122 -0
- package/dist/cloud-B4O_G-Df.js +545 -0
- package/dist/cloud.d.ts +155 -0
- package/dist/color.d.ts +1 -0
- package/dist/copc-write.d.ts +95 -0
- package/dist/copc-write.js +318 -0
- package/dist/copc.d.ts +55 -0
- package/dist/copc.js +127 -0
- package/dist/depth-video.d.ts +98 -0
- package/dist/depth-video.js +164 -0
- package/dist/e57.d.ts +163 -0
- package/dist/e57.js +624 -0
- package/dist/frame.d.ts +14 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1246 -0
- package/dist/las.d.ts +213 -0
- package/dist/las.js +500 -0
- package/dist/laz-encode-CHXgHra_.js +446 -0
- package/dist/laz-encode.d.ts +14 -0
- package/dist/laz-model-DCphHLqH.js +385 -0
- package/dist/laz-model.d.ts +47 -0
- package/dist/laz-write.d.ts +46 -0
- package/dist/laz-write.js +75 -0
- package/dist/laz.d.ts +50 -0
- package/dist/laz.js +645 -0
- package/dist/material.d.ts +167 -0
- package/dist/math.d.ts +103 -0
- package/dist/octree.d.ts +182 -0
- package/dist/octree.js +360 -0
- package/dist/pick.d.ts +76 -0
- package/dist/pick.js +192 -0
- package/dist/plugin.d.ts +235 -0
- package/dist/potree-las-RC8sjbYU.js +1 -0
- package/dist/potree-las.d.ts +1 -0
- package/dist/potree.d.ts +70 -0
- package/dist/potree.js +451 -0
- package/dist/range-BQuJAjUM.js +23 -0
- package/dist/range.d.ts +4 -0
- package/dist/screen-door-CALlYs39.js +7 -0
- package/dist/shaders-DCnbvb0-.js +282 -0
- package/dist/shaders.d.ts +52 -0
- package/dist/shared/fog.d.ts +33 -0
- package/dist/shared/pass.d.ts +53 -0
- package/dist/shared/selection-mask.d.ts +52 -0
- package/dist/shared/style-expression.d.ts +18 -0
- package/dist/sprites.d.ts +78 -0
- package/dist/storage-limit.d.ts +6 -0
- package/dist/style.d.ts +124 -0
- package/dist/style.js +709 -0
- package/dist/surfels.d.ts +95 -0
- package/dist/surfels.js +538 -0
- package/dist/survey-DToZwkJv.js +46 -0
- package/dist/survey.d.ts +10 -0
- package/dist/tier-BcFbLPVT.js +91 -0
- package/dist/tier.d.ts +6 -0
- package/package.json +102 -4
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
//#region src/attributes.ts
|
|
2
|
+
var e = {
|
|
3
|
+
0: "Created, never classified",
|
|
4
|
+
1: "Unclassified",
|
|
5
|
+
2: "Ground",
|
|
6
|
+
3: "Low vegetation",
|
|
7
|
+
4: "Medium vegetation",
|
|
8
|
+
5: "High vegetation",
|
|
9
|
+
6: "Building",
|
|
10
|
+
7: "Low point (noise)",
|
|
11
|
+
8: "Model key-point",
|
|
12
|
+
9: "Water",
|
|
13
|
+
10: "Rail",
|
|
14
|
+
11: "Road surface",
|
|
15
|
+
12: "Overlap",
|
|
16
|
+
13: "Wire guard (shield)",
|
|
17
|
+
14: "Wire conductor (phase)",
|
|
18
|
+
15: "Transmission tower",
|
|
19
|
+
16: "Wire-structure connector (insulator)",
|
|
20
|
+
17: "Bridge deck",
|
|
21
|
+
18: "High noise",
|
|
22
|
+
19: "Overhead structure",
|
|
23
|
+
20: "Ignored ground",
|
|
24
|
+
21: "Snow",
|
|
25
|
+
22: "Temporal exclusion"
|
|
26
|
+
}, t = {
|
|
27
|
+
0: [
|
|
28
|
+
160,
|
|
29
|
+
160,
|
|
30
|
+
160
|
|
31
|
+
],
|
|
32
|
+
1: [
|
|
33
|
+
200,
|
|
34
|
+
200,
|
|
35
|
+
200
|
|
36
|
+
],
|
|
37
|
+
2: [
|
|
38
|
+
166,
|
|
39
|
+
118,
|
|
40
|
+
64
|
|
41
|
+
],
|
|
42
|
+
3: [
|
|
43
|
+
140,
|
|
44
|
+
210,
|
|
45
|
+
90
|
|
46
|
+
],
|
|
47
|
+
4: [
|
|
48
|
+
70,
|
|
49
|
+
170,
|
|
50
|
+
60
|
|
51
|
+
],
|
|
52
|
+
5: [
|
|
53
|
+
20,
|
|
54
|
+
110,
|
|
55
|
+
40
|
|
56
|
+
],
|
|
57
|
+
6: [
|
|
58
|
+
220,
|
|
59
|
+
80,
|
|
60
|
+
60
|
|
61
|
+
],
|
|
62
|
+
7: [
|
|
63
|
+
255,
|
|
64
|
+
0,
|
|
65
|
+
255
|
|
66
|
+
],
|
|
67
|
+
8: [
|
|
68
|
+
255,
|
|
69
|
+
220,
|
|
70
|
+
0
|
|
71
|
+
],
|
|
72
|
+
9: [
|
|
73
|
+
50,
|
|
74
|
+
120,
|
|
75
|
+
230
|
|
76
|
+
],
|
|
77
|
+
10: [
|
|
78
|
+
120,
|
|
79
|
+
80,
|
|
80
|
+
150
|
|
81
|
+
],
|
|
82
|
+
11: [
|
|
83
|
+
90,
|
|
84
|
+
90,
|
|
85
|
+
100
|
|
86
|
+
],
|
|
87
|
+
12: [
|
|
88
|
+
255,
|
|
89
|
+
160,
|
|
90
|
+
0
|
|
91
|
+
],
|
|
92
|
+
13: [
|
|
93
|
+
240,
|
|
94
|
+
240,
|
|
95
|
+
120
|
|
96
|
+
],
|
|
97
|
+
14: [
|
|
98
|
+
250,
|
|
99
|
+
250,
|
|
100
|
+
60
|
|
101
|
+
],
|
|
102
|
+
15: [
|
|
103
|
+
180,
|
|
104
|
+
180,
|
|
105
|
+
240
|
|
106
|
+
],
|
|
107
|
+
16: [
|
|
108
|
+
120,
|
|
109
|
+
220,
|
|
110
|
+
220
|
|
111
|
+
],
|
|
112
|
+
17: [
|
|
113
|
+
150,
|
|
114
|
+
100,
|
|
115
|
+
70
|
|
116
|
+
],
|
|
117
|
+
18: [
|
|
118
|
+
255,
|
|
119
|
+
40,
|
|
120
|
+
160
|
|
121
|
+
],
|
|
122
|
+
19: [
|
|
123
|
+
200,
|
|
124
|
+
140,
|
|
125
|
+
220
|
|
126
|
+
],
|
|
127
|
+
20: [
|
|
128
|
+
130,
|
|
129
|
+
100,
|
|
130
|
+
70
|
|
131
|
+
],
|
|
132
|
+
21: [
|
|
133
|
+
235,
|
|
134
|
+
245,
|
|
135
|
+
255
|
|
136
|
+
],
|
|
137
|
+
22: [
|
|
138
|
+
110,
|
|
139
|
+
110,
|
|
140
|
+
140
|
|
141
|
+
]
|
|
142
|
+
};
|
|
143
|
+
function n(e, n = {}) {
|
|
144
|
+
let r = {
|
|
145
|
+
...t,
|
|
146
|
+
...n.palette
|
|
147
|
+
}, i = new Set(n.hidden ?? []), a = new Uint8Array(e.length * 4);
|
|
148
|
+
for (let t = 0; t < e.length; t++) {
|
|
149
|
+
let n = r[e[t]] ?? [
|
|
150
|
+
128,
|
|
151
|
+
128,
|
|
152
|
+
128
|
|
153
|
+
];
|
|
154
|
+
a[t * 4] = n[0], a[t * 4 + 1] = n[1], a[t * 4 + 2] = n[2], a[t * 4 + 3] = i.has(e[t]) ? 0 : 255;
|
|
155
|
+
}
|
|
156
|
+
return a;
|
|
157
|
+
}
|
|
158
|
+
function r(e, t) {
|
|
159
|
+
let n = e.length;
|
|
160
|
+
if (!n) return 0;
|
|
161
|
+
let r = Math.max(1, Math.floor(n / 65536)), i = [];
|
|
162
|
+
for (let t = 0; t < n; t += r) Number.isFinite(e[t]) && i.push(e[t]);
|
|
163
|
+
return i.sort((e, t) => e - t), i.length ? i[Math.min(i.length - 1, Math.floor(t * (i.length - 1)))] : 0;
|
|
164
|
+
}
|
|
165
|
+
function i(e, t = {}) {
|
|
166
|
+
let n = t.min ?? r(e, .01), i = t.max ?? r(e, .99), a = t.gamma ?? 1, o = t.stops ?? [[
|
|
167
|
+
0,
|
|
168
|
+
0,
|
|
169
|
+
0
|
|
170
|
+
], [
|
|
171
|
+
255,
|
|
172
|
+
255,
|
|
173
|
+
255
|
|
174
|
+
]];
|
|
175
|
+
if (!(a > 0)) throw RangeError("Invalid gamma; pass a number above 0");
|
|
176
|
+
if (o.length < 2) throw RangeError("A ramp needs at least two stops");
|
|
177
|
+
let s = i - n || 1, c = new Uint8Array(e.length * 4), l = o.length - 1;
|
|
178
|
+
for (let t = 0; t < e.length; t++) {
|
|
179
|
+
let r = e[t], i = Number.isFinite(r) ? Math.min(1, Math.max(0, (r - n) / s)) : 0;
|
|
180
|
+
i **= a;
|
|
181
|
+
let u = i * l, d = Math.min(l - 1, Math.floor(u)), f = u - d, p = o[d], m = o[d + 1];
|
|
182
|
+
c[t * 4] = Math.round(p[0] + (m[0] - p[0]) * f), c[t * 4 + 1] = Math.round(p[1] + (m[1] - p[1]) * f), c[t * 4 + 2] = Math.round(p[2] + (m[2] - p[2]) * f), c[t * 4 + 3] = Number.isFinite(r) ? 255 : 0;
|
|
183
|
+
}
|
|
184
|
+
return c;
|
|
185
|
+
}
|
|
186
|
+
var a = [
|
|
187
|
+
[
|
|
188
|
+
40,
|
|
189
|
+
60,
|
|
190
|
+
200
|
|
191
|
+
],
|
|
192
|
+
[
|
|
193
|
+
40,
|
|
194
|
+
200,
|
|
195
|
+
220
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
60,
|
|
199
|
+
200,
|
|
200
|
+
80
|
|
201
|
+
],
|
|
202
|
+
[
|
|
203
|
+
240,
|
|
204
|
+
220,
|
|
205
|
+
60
|
|
206
|
+
],
|
|
207
|
+
[
|
|
208
|
+
220,
|
|
209
|
+
50,
|
|
210
|
+
40
|
|
211
|
+
]
|
|
212
|
+
];
|
|
213
|
+
function o(e) {
|
|
214
|
+
let t = 0;
|
|
215
|
+
for (let n = 0; n < e.length; n++) e[n] > t && (t = e[n]);
|
|
216
|
+
let n = t > 255 ? 8 : 0, r = e.length / 3, i = new Uint8Array(r * 4);
|
|
217
|
+
for (let t = 0; t < r; t++) i[t * 4] = e[t * 3] >> n, i[t * 4 + 1] = e[t * 3 + 1] >> n, i[t * 4 + 2] = e[t * 3 + 2] >> n, i[t * 4 + 3] = 255;
|
|
218
|
+
return i;
|
|
219
|
+
}
|
|
220
|
+
var s = (e, t) => [
|
|
221
|
+
e[0] - t[0],
|
|
222
|
+
e[1] - t[1],
|
|
223
|
+
e[2] - t[2]
|
|
224
|
+
];
|
|
225
|
+
function c(e, t) {
|
|
226
|
+
return Math.hypot(e[0] - t[0], e[1] - t[1], e[2] - t[2]);
|
|
227
|
+
}
|
|
228
|
+
function l(e, t = !1) {
|
|
229
|
+
let n = 0;
|
|
230
|
+
for (let t = 1; t < e.length; t++) n += c(e[t - 1], e[t]);
|
|
231
|
+
return t && e.length > 2 && (n += c(e[e.length - 1], e[0])), n;
|
|
232
|
+
}
|
|
233
|
+
function u(e) {
|
|
234
|
+
let t = 0, n = 0, r = 0;
|
|
235
|
+
for (let i = 0; i < e.length; i++) {
|
|
236
|
+
let a = e[i], o = e[(i + 1) % e.length];
|
|
237
|
+
t += (a[1] - o[1]) * (a[2] + o[2]), n += (a[2] - o[2]) * (a[0] + o[0]), r += (a[0] - o[0]) * (a[1] + o[1]);
|
|
238
|
+
}
|
|
239
|
+
return Math.hypot(t, n, r) / 2;
|
|
240
|
+
}
|
|
241
|
+
function d(e, t, n = [
|
|
242
|
+
0,
|
|
243
|
+
1,
|
|
244
|
+
0
|
|
245
|
+
]) {
|
|
246
|
+
let r = s(t, e), i = Math.hypot(n[0], n[1], n[2]) || 1;
|
|
247
|
+
return (r[0] * n[0] + r[1] * n[1] + r[2] * n[2]) / i;
|
|
248
|
+
}
|
|
249
|
+
function f(e, t, n) {
|
|
250
|
+
let r = s(e, t), i = s(n, t), a = Math.hypot(r[0], r[1], r[2]), o = Math.hypot(i[0], i[1], i[2]);
|
|
251
|
+
if (!a || !o) return 0;
|
|
252
|
+
let c = (r[0] * i[0] + r[1] * i[1] + r[2] * i[2]) / (a * o);
|
|
253
|
+
return Math.acos(Math.min(1, Math.max(-1, c))) * 180 / Math.PI;
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
export { f as a, l as c, o as d, n as i, c as l, t as n, u as o, a as r, d as s, e as t, i as u };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ASPRS standard point classes, by class number: LAS 1.4 R15 table 17 (point formats 6 to 10), which adds 19 to 22,
|
|
3
|
+
* with 8 and 12 named as table 9 (formats 0 to 5) names them; formats 6 to 10 reserve those two and flag overlap apart.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ASPRS_CLASSES: Readonly<Record<number, string>>;
|
|
6
|
+
/** Default classification colours (sRGB), by class; classes without one are grey. */
|
|
7
|
+
export declare const CLASSIFICATION_COLORS: Readonly<Record<number, readonly [number, number, number]>>;
|
|
8
|
+
/** Options of `classificationColors`. */
|
|
9
|
+
export interface ClassificationColorOptions {
|
|
10
|
+
/** Colours per class (sRGB 0..255), merged over `CLASSIFICATION_COLORS`. */
|
|
11
|
+
palette?: Readonly<Record<number, readonly [number, number, number]>>;
|
|
12
|
+
/** Classes drawn with alpha 0 (pair with `alphaTest` on the material to hide them). Default none. */
|
|
13
|
+
hidden?: readonly number[];
|
|
14
|
+
}
|
|
15
|
+
/** RGBA bytes per point from ASPRS classes. */
|
|
16
|
+
export declare function classificationColors(classes: ArrayLike<number>, options?: ClassificationColorOptions): Uint8Array;
|
|
17
|
+
/** Options of `rampColors` (intensity, elevation or any scalar). */
|
|
18
|
+
export interface RampOptions {
|
|
19
|
+
/** Value mapped to the start of the ramp. Default: the 1st percentile. */
|
|
20
|
+
min?: number;
|
|
21
|
+
/** Value mapped to the end. Default: the 99th percentile. */
|
|
22
|
+
max?: number;
|
|
23
|
+
/** Exponent on the normalised value (below 1 brightens dark scans). Default 1. */
|
|
24
|
+
gamma?: number;
|
|
25
|
+
/** Colour stops (sRGB 0..255) spread evenly. Default black to white. */
|
|
26
|
+
stops?: readonly (readonly [number, number, number])[];
|
|
27
|
+
}
|
|
28
|
+
/** RGBA bytes per point from a scalar (intensity, height, an extra-bytes attribute) through a colour ramp. */
|
|
29
|
+
export declare function rampColors(values: ArrayLike<number>, options?: RampOptions): Uint8Array;
|
|
30
|
+
/** A blue-cyan-green-yellow-red ramp for elevation. */
|
|
31
|
+
export declare const ELEVATION_STOPS: readonly (readonly [number, number, number])[];
|
|
32
|
+
/**
|
|
33
|
+
* RGBA bytes from 16-bit RGB (LAS, E57). Files that store 8-bit values in 16-bit fields (every value 255 or less) are
|
|
34
|
+
* detected and kept as they are; otherwise the high byte is used.
|
|
35
|
+
*/
|
|
36
|
+
export declare function rgb16ToRgba8(rgb: ArrayLike<number>): Uint8Array;
|
|
37
|
+
type P = ArrayLike<number>;
|
|
38
|
+
/** Straight-line distance between two points. */
|
|
39
|
+
export declare function measurePointDistance(a: P, b: P): number;
|
|
40
|
+
/** Length of a path through the points in order (closed adds the last-to-first leg). */
|
|
41
|
+
export declare function measurePath(points: readonly P[], closed?: boolean): number;
|
|
42
|
+
/** Area of a planar polygon through the points (Newell's normal; for a non-planar loop, its projected vector area). */
|
|
43
|
+
export declare function measureArea(points: readonly P[]): number;
|
|
44
|
+
/** Height of b above a along `up` (default +y, the engine's up). */
|
|
45
|
+
export declare function measureHeight(a: P, b: P, up?: P): number;
|
|
46
|
+
/** Angle at b between the legs to a and c, in degrees. */
|
|
47
|
+
export declare function measureAngle(a: P, b: P, c: P): number;
|
|
48
|
+
export {};
|
package/dist/clip.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PointCloud } from './cloud.js';
|
|
2
|
+
import { type SurveyPoints } from './survey.js';
|
|
3
|
+
/** A closed volume in world space. Point centres on its boundary belong to the volume. */
|
|
4
|
+
export interface PointClipVolume {
|
|
5
|
+
contains(x: number, y: number, z: number): boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Settings for combining volumes. Defaults: union, keep inside. An empty list keeps all finite points. */
|
|
8
|
+
export interface PointClipOptions {
|
|
9
|
+
volumes: readonly PointClipVolume[];
|
|
10
|
+
operation?: 'union' | 'intersection';
|
|
11
|
+
keep?: 'inside' | 'outside';
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
/** Axis-aligned or oriented box; worldToLocal defaults to identity. Bounds are copied. */
|
|
15
|
+
export declare function boxClipVolume(min: readonly number[], max: readonly number[], worldToLocal?: ArrayLike<number>): PointClipVolume;
|
|
16
|
+
/** Polygon extruded along local z; arbitrary concave rings use even-odd fill. */
|
|
17
|
+
export interface PolygonClipOptions {
|
|
18
|
+
/** Local z interval, inclusive. Default unbounded. */
|
|
19
|
+
depth?: readonly [number, number];
|
|
20
|
+
/** World-to-volume matrix; may be a view-projection matrix for screen-space polygons. Default identity. */
|
|
21
|
+
worldToLocal?: ArrayLike<number>;
|
|
22
|
+
/** Reject points with homogeneous w <= 0 (behind a perspective camera). Default false. */
|
|
23
|
+
positiveW?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Create an extruded polygon volume. Vertices are local xy pairs and are copied. */
|
|
26
|
+
export declare function polygonClipVolume(vertices: readonly (readonly [number, number])[], options?: PolygonClipOptions): PointClipVolume;
|
|
27
|
+
/** Select point indices without modifying data. Non-finite positions are always excluded. */
|
|
28
|
+
export declare function clipPoints(data: SurveyPoints, options: PointClipOptions): Uint32Array;
|
|
29
|
+
/** Create a renderable clipped cloud plus indices into the source. Re-run after changing data or volumes. */
|
|
30
|
+
export declare function createClippedCloud(source: PointCloud, options: PointClipOptions, worldMatrix?: ArrayLike<number>): {
|
|
31
|
+
cloud: PointCloud;
|
|
32
|
+
indices: Uint32Array;
|
|
33
|
+
};
|
|
34
|
+
/** A polyline corridor, horizontal in the plane perpendicular to upAxis (default y). */
|
|
35
|
+
export interface ElevationProfileOptions {
|
|
36
|
+
path: readonly (readonly [number, number, number])[];
|
|
37
|
+
/** Full corridor width in world units, including its boundary. */
|
|
38
|
+
width: number;
|
|
39
|
+
upAxis?: 0 | 1 | 2;
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
}
|
|
42
|
+
/** Profile records sorted by horizontal distance along the path, then source index. */
|
|
43
|
+
export interface ElevationProfile {
|
|
44
|
+
indices: Uint32Array;
|
|
45
|
+
positions: Float64Array;
|
|
46
|
+
distance: Float64Array;
|
|
47
|
+
elevation: Float64Array;
|
|
48
|
+
/** Signed lateral distance from the chosen path segment. */
|
|
49
|
+
offset: Float64Array;
|
|
50
|
+
segment: Uint32Array;
|
|
51
|
+
length: number;
|
|
52
|
+
}
|
|
53
|
+
/** Extract every point in a finite-width polyline corridor, once at the closest segment; square end caps. */
|
|
54
|
+
export declare function elevationProfile(data: SurveyPoints, options: ElevationProfileOptions): ElevationProfile;
|
|
55
|
+
export type { SurveyPoints } from './survey.js';
|
package/dist/clip.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { n as e, r as t, t as n } from "./survey-DToZwkJv.js";
|
|
2
|
+
//#region src/clip.ts
|
|
3
|
+
function r(e, t, n) {
|
|
4
|
+
if (e.length !== n || t.length !== n || Array.from(e).some((e, n) => !Number.isFinite(e) || !Number.isFinite(t[n]) || e > t[n])) throw RangeError("Pass finite min/max bounds in ascending order");
|
|
5
|
+
}
|
|
6
|
+
function i(e) {
|
|
7
|
+
if (e) {
|
|
8
|
+
if (e.length !== 16 || !Array.from(e).every(Number.isFinite)) throw TypeError("Pass a finite column-major world-to-volume matrix of 16 numbers");
|
|
9
|
+
return Array.from(e);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function a(e, n, a) {
|
|
13
|
+
r(e, n, 3);
|
|
14
|
+
let o = [...e], s = [...n], c = i(a);
|
|
15
|
+
return { contains(e, n, r) {
|
|
16
|
+
return t([
|
|
17
|
+
e,
|
|
18
|
+
n,
|
|
19
|
+
r
|
|
20
|
+
], 0, c).every((e, t) => e >= o[t] && e <= s[t]);
|
|
21
|
+
} };
|
|
22
|
+
}
|
|
23
|
+
function o(e, n = {}) {
|
|
24
|
+
if (e.length < 3 || e.some((e) => e.length !== 2 || !e.every(Number.isFinite))) throw TypeError("Pass at least three finite xy polygon vertices");
|
|
25
|
+
let r = e.map((e) => [...e]), a = i(n.worldToLocal), o = n.depth ?? [-Infinity, Infinity];
|
|
26
|
+
if (o.length !== 2 || Number.isNaN(o[0]) || Number.isNaN(o[1]) || o[0] > o[1]) throw RangeError("Pass an ascending polygon depth interval");
|
|
27
|
+
let s = o[0], c = o[1];
|
|
28
|
+
return { contains(e, i, o) {
|
|
29
|
+
if (n.positiveW && a && a[3] * e + a[7] * i + a[11] * o + a[15] <= 0) return !1;
|
|
30
|
+
let [l, u, d] = t([
|
|
31
|
+
e,
|
|
32
|
+
i,
|
|
33
|
+
o
|
|
34
|
+
], 0, a);
|
|
35
|
+
if (!Number.isFinite(l) || !Number.isFinite(u) || d < s || d > c || !Number.isFinite(d)) return !1;
|
|
36
|
+
let f = !1;
|
|
37
|
+
for (let e = 0, t = r.length - 1; e < r.length; t = e++) {
|
|
38
|
+
let [n, i] = r[t], [a, o] = r[e];
|
|
39
|
+
if ((l - n) * (o - i) - (u - i) * (a - n) === 0 && l >= Math.min(n, a) && l <= Math.max(n, a) && u >= Math.min(i, o) && u <= Math.max(i, o)) return !0;
|
|
40
|
+
i > u != o > u && l < n + (u - i) * (a - n) / (o - i) && (f = !f);
|
|
41
|
+
}
|
|
42
|
+
return f;
|
|
43
|
+
} };
|
|
44
|
+
}
|
|
45
|
+
function s(e, r) {
|
|
46
|
+
if (n(e), !["union", "intersection"].includes(r.operation ?? "union") || !["inside", "outside"].includes(r.keep ?? "inside")) throw RangeError("Use operation union/intersection and keep inside/outside");
|
|
47
|
+
let i = [];
|
|
48
|
+
for (let n = 0; n < e.positions.length / 3; n++) {
|
|
49
|
+
n % 4096 || r.signal?.throwIfAborted();
|
|
50
|
+
let a = t(e.positions, n, e.matrix);
|
|
51
|
+
if (!a.every(Number.isFinite)) continue;
|
|
52
|
+
let o = r.operation === "intersection" ? r.volumes.every((e) => e.contains(...a)) : r.volumes.some((e) => e.contains(...a));
|
|
53
|
+
(!r.volumes.length || o === (r.keep !== "outside")) && i.push(n);
|
|
54
|
+
}
|
|
55
|
+
return Uint32Array.from(i);
|
|
56
|
+
}
|
|
57
|
+
function c(t, n, r) {
|
|
58
|
+
let i = s(r ? {
|
|
59
|
+
positions: t.positions,
|
|
60
|
+
matrix: r
|
|
61
|
+
} : t, n);
|
|
62
|
+
return {
|
|
63
|
+
cloud: e(t, i),
|
|
64
|
+
indices: i
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function l(e, r) {
|
|
68
|
+
n(e);
|
|
69
|
+
let { path: i, width: a } = r, o = r.upAxis ?? 1;
|
|
70
|
+
if (!Number.isFinite(a) || a < 0 || ![
|
|
71
|
+
0,
|
|
72
|
+
1,
|
|
73
|
+
2
|
|
74
|
+
].includes(o) || i.length < 2 || i.some((e) => e.length !== 3 || !e.every(Number.isFinite))) throw RangeError("Pass at least two finite xyz path vertices, nonnegative width and upAxis 0, 1 or 2");
|
|
75
|
+
let s = [
|
|
76
|
+
0,
|
|
77
|
+
1,
|
|
78
|
+
2
|
|
79
|
+
].filter((e) => e !== o), c = s[0], l = s[1], u = [], d = 0;
|
|
80
|
+
for (let e = 0; e < i.length - 1; e++) {
|
|
81
|
+
let t = i[e + 1][c] - i[e][c], n = i[e + 1][l] - i[e][l], r = Math.hypot(t, n);
|
|
82
|
+
r && (u.push({
|
|
83
|
+
x: i[e][c],
|
|
84
|
+
y: i[e][l],
|
|
85
|
+
dx: t / r,
|
|
86
|
+
dy: n / r,
|
|
87
|
+
length: r,
|
|
88
|
+
start: d,
|
|
89
|
+
index: e
|
|
90
|
+
}), d += r);
|
|
91
|
+
}
|
|
92
|
+
if (!u.length) throw RangeError("Pass a path with nonzero horizontal length");
|
|
93
|
+
let f = [];
|
|
94
|
+
for (let n = 0; n < e.positions.length / 3; n++) {
|
|
95
|
+
n % 4096 || r.signal?.throwIfAborted();
|
|
96
|
+
let i = t(e.positions, n, e.matrix);
|
|
97
|
+
if (!i.every(Number.isFinite)) continue;
|
|
98
|
+
let o = Infinity, s;
|
|
99
|
+
for (let e of u) {
|
|
100
|
+
let t = i[c] - e.x, r = i[l] - e.y, u = t * e.dx + r * e.dy, d = e.dx * r - e.dy * t;
|
|
101
|
+
u < 0 || u > e.length || Math.abs(d) > a / 2 || Math.abs(d) >= o || (o = Math.abs(d), s = {
|
|
102
|
+
i: n,
|
|
103
|
+
p: i,
|
|
104
|
+
distance: e.start + u,
|
|
105
|
+
offset: d,
|
|
106
|
+
segment: e.index
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
s && f.push(s);
|
|
110
|
+
}
|
|
111
|
+
return f.sort((e, t) => e.distance - t.distance || e.i - t.i), {
|
|
112
|
+
indices: Uint32Array.from(f, (e) => e.i),
|
|
113
|
+
positions: Float64Array.from(f.flatMap((e) => e.p)),
|
|
114
|
+
distance: Float64Array.from(f, (e) => e.distance),
|
|
115
|
+
elevation: Float64Array.from(f, (e) => e.p[o]),
|
|
116
|
+
offset: Float64Array.from(f, (e) => e.offset),
|
|
117
|
+
segment: Uint32Array.from(f, (e) => e.segment),
|
|
118
|
+
length: d
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { a as boxClipVolume, s as clipPoints, c as createClippedCloud, l as elevationProfile, o as polygonClipVolume };
|