@cearth/tools 2.2.0 → 2.3.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/math/transform.d.ts +34 -8
- package/dist/math/transform.d.ts.map +1 -1
- package/dist/tools.iife.js +7 -7
- package/dist/tools.js +58 -58
- package/dist/tools.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WebGLConstants as R, Cartesian3 as l, HeadingPitchRoll as B, Quaternion as w, Matrix3 as g, Matrix4 as a, TranslationRotationScale as P, Plane as et, Transforms as
|
|
1
|
+
import { WebGLConstants as R, Cartesian3 as l, HeadingPitchRoll as B, Quaternion as w, Matrix3 as g, Matrix4 as a, TranslationRotationScale as P, Plane as et, Transforms as E, BoundingSphere as C, JulianDate as h, Cartesian2 as x, ComponentDatatype as X, Cartographic as D, Cartesian4 as b, Rectangle as v, Matrix2 as F } from "cesium";
|
|
2
2
|
import { mat4_decompose as it, getMatrixOfQuantizedMeshTerrainData as rt, Geometry as at, workerApi as st, GeometricRelation as z, computeSignAreaOfPolygon3 as Z, computeRelationAreaOfPolygon2Terrain as ct } from "@web-3d/tools";
|
|
3
3
|
function Jt(t) {
|
|
4
4
|
return k(t) || J(t) || lt(t);
|
|
@@ -55,7 +55,7 @@ const ut = {
|
|
|
55
55
|
*/
|
|
56
56
|
[R.DOUBLE]: Float64Array
|
|
57
57
|
};
|
|
58
|
-
var ft = /* @__PURE__ */ ((t) => (t[t.x = 0] = "x", t[t.y = 1] = "y", t[t.z = 2] = "z", t))(ft || {}),
|
|
58
|
+
var ft = /* @__PURE__ */ ((t) => (t[t.x = 0] = "x", t[t.y = 1] = "y", t[t.z = 2] = "z", t))(ft || {}), O = /* @__PURE__ */ ((t) => (t.x = "roll", t.y = "pitch", t.z = "heading", t))(O || {});
|
|
59
59
|
((t) => {
|
|
60
60
|
function o(i) {
|
|
61
61
|
for (let [r, s] of Object.entries(t))
|
|
@@ -71,7 +71,7 @@ var ft = /* @__PURE__ */ ((t) => (t[t.x = 0] = "x", t[t.y = 1] = "y", t[t.z = 2]
|
|
|
71
71
|
return new B(-i[o("heading")], -i[o("pitch")], i[o("roll")]);
|
|
72
72
|
}
|
|
73
73
|
t.toHeadingPitchRoll = e;
|
|
74
|
-
})(
|
|
74
|
+
})(O || (O = {}));
|
|
75
75
|
var mt = /* @__PURE__ */ ((t) => (t[t.heading = 0] = "heading", t[t.pitch = 1] = "pitch", t[t.roll = 2] = "roll", t))(mt || {});
|
|
76
76
|
function K(t) {
|
|
77
77
|
const o = t?.world, { translation: n, rotation: e, scale: i } = o && typeof o == "object" ? o : { translation: o, rotation: o, scale: o };
|
|
@@ -82,7 +82,7 @@ function G(t) {
|
|
|
82
82
|
const { axis: n, angle: e } = t;
|
|
83
83
|
return w.fromAxisAngle(n, e);
|
|
84
84
|
}
|
|
85
|
-
const o =
|
|
85
|
+
const o = O.toHeadingPitchRoll(t);
|
|
86
86
|
return w.fromHeadingPitchRoll(o);
|
|
87
87
|
}
|
|
88
88
|
function qt(t, o, n) {
|
|
@@ -226,11 +226,11 @@ function xt(t) {
|
|
|
226
226
|
function i(r, s) {
|
|
227
227
|
return a.multiply(o, r, n), gt(n, s);
|
|
228
228
|
}
|
|
229
|
-
return { compose: e, decompose: i };
|
|
229
|
+
return { compose: e, decompose: i, referInverse: o };
|
|
230
230
|
}
|
|
231
231
|
function on(t, o) {
|
|
232
|
-
const n =
|
|
233
|
-
return xt(n);
|
|
232
|
+
const n = E.eastNorthUpToFixedFrame(t, o ?? void 0);
|
|
233
|
+
return { ...xt(n), refer: n };
|
|
234
234
|
}
|
|
235
235
|
function en(t) {
|
|
236
236
|
let o = t.boundingSphere;
|
|
@@ -240,10 +240,10 @@ function en(t) {
|
|
|
240
240
|
if (n) {
|
|
241
241
|
n = Array.isArray(n) ? n : [n];
|
|
242
242
|
const i = n.map((r) => r.geometry.boundingSphere);
|
|
243
|
-
return
|
|
243
|
+
return C.fromBoundingSpheres(i);
|
|
244
244
|
}
|
|
245
245
|
const e = t.positions;
|
|
246
|
-
return e?.length > 0 ?
|
|
246
|
+
return e?.length > 0 ? C.fromPoints(e) : null;
|
|
247
247
|
}
|
|
248
248
|
function rn(t, o) {
|
|
249
249
|
o = o ?? new l();
|
|
@@ -254,7 +254,7 @@ function rn(t, o) {
|
|
|
254
254
|
if (e)
|
|
255
255
|
return a.getTranslation(e, o);
|
|
256
256
|
const i = t.positions;
|
|
257
|
-
return i?.length > 0 ?
|
|
257
|
+
return i?.length > 0 ? C.fromPoints(i).center : null;
|
|
258
258
|
}
|
|
259
259
|
function an(t, o, n) {
|
|
260
260
|
let { translation: e, rotation: i, scale: r } = q(o, n);
|
|
@@ -285,10 +285,10 @@ function Tt(t, o) {
|
|
|
285
285
|
return !1;
|
|
286
286
|
}
|
|
287
287
|
function sn(t, o, n) {
|
|
288
|
-
const e =
|
|
289
|
-
return
|
|
288
|
+
const e = At(t), i = yt(o, { ...n, defaultMatrix: e });
|
|
289
|
+
return vt(t, i);
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function vt(t, o) {
|
|
292
292
|
if (k(t))
|
|
293
293
|
return t.modelMatrix = o, !0;
|
|
294
294
|
const n = a.getTranslation(o, new l());
|
|
@@ -301,7 +301,7 @@ function At(t, o) {
|
|
|
301
301
|
}
|
|
302
302
|
const e = t.positions;
|
|
303
303
|
if (e?.length > 0) {
|
|
304
|
-
const i =
|
|
304
|
+
const i = C.fromPoints(e);
|
|
305
305
|
l.subtract(n, i.center, n);
|
|
306
306
|
for (const r of e)
|
|
307
307
|
l.add(r, n, r);
|
|
@@ -309,7 +309,7 @@ function At(t, o) {
|
|
|
309
309
|
}
|
|
310
310
|
return !1;
|
|
311
311
|
}
|
|
312
|
-
function
|
|
312
|
+
function At(t) {
|
|
313
313
|
if (k(t))
|
|
314
314
|
return t.modelMatrix;
|
|
315
315
|
if (J(t)) {
|
|
@@ -318,7 +318,7 @@ function vt(t) {
|
|
|
318
318
|
}
|
|
319
319
|
const o = t.positions;
|
|
320
320
|
if (o?.length > 0) {
|
|
321
|
-
const n =
|
|
321
|
+
const n = C.fromPoints(o);
|
|
322
322
|
return a.fromTranslation(n.center);
|
|
323
323
|
}
|
|
324
324
|
return null;
|
|
@@ -327,27 +327,27 @@ function cn(t, o) {
|
|
|
327
327
|
let { translation: n, rotation: e, scale: i } = q(o, o);
|
|
328
328
|
const { reset: r, referFrame: s } = o, c = h.now(), u = !r;
|
|
329
329
|
if (e) {
|
|
330
|
-
let
|
|
330
|
+
let A = e;
|
|
331
331
|
if (u) {
|
|
332
332
|
const T = t.orientation?.getValue(c);
|
|
333
|
-
T && (
|
|
333
|
+
T && (A = w.multiply(e, T, T));
|
|
334
334
|
}
|
|
335
|
-
t.orientation =
|
|
335
|
+
t.orientation = A;
|
|
336
336
|
}
|
|
337
337
|
if (n) {
|
|
338
|
-
let
|
|
338
|
+
let A = n;
|
|
339
339
|
if (u) {
|
|
340
340
|
const T = t.position?.getValue(c);
|
|
341
|
-
T && (
|
|
341
|
+
T && (A = l.add(T, n, T));
|
|
342
342
|
}
|
|
343
|
-
t.position =
|
|
343
|
+
t.position = A;
|
|
344
344
|
}
|
|
345
345
|
if (!s) return;
|
|
346
346
|
const { translation: f, rotation: m, scale: p } = dt(o, o), d = new P(f ?? void 0, m ?? void 0, p ?? void 0);
|
|
347
347
|
let y = a.fromTranslationRotationScale(d);
|
|
348
348
|
if (y = H(y, s, y), p) {
|
|
349
|
-
const
|
|
350
|
-
|
|
349
|
+
const A = t.box;
|
|
350
|
+
A && Rt(A, p);
|
|
351
351
|
const T = t.cylinder;
|
|
352
352
|
T && Pt(T, p);
|
|
353
353
|
const U = t.ellipse;
|
|
@@ -366,9 +366,9 @@ function cn(t, o) {
|
|
|
366
366
|
const S = t.polyline;
|
|
367
367
|
S && bt(S, y, p);
|
|
368
368
|
const I = t.polylineVolume;
|
|
369
|
-
I &&
|
|
369
|
+
I && Ct(I, y, p);
|
|
370
370
|
const N = t.wall;
|
|
371
|
-
N &&
|
|
371
|
+
N && Ot(N, y, p);
|
|
372
372
|
}
|
|
373
373
|
function Rt(t, o) {
|
|
374
374
|
const n = h.now(), e = t.dimensions?.getValue(n);
|
|
@@ -448,7 +448,7 @@ function bt(t, o, n) {
|
|
|
448
448
|
const s = n ?? a.getScale(o, i), c = Math.max(s.x, s.y);
|
|
449
449
|
t.width?.getValue(e) != null && (t.width = c * scale);
|
|
450
450
|
}
|
|
451
|
-
function
|
|
451
|
+
function Ct(t, o, n) {
|
|
452
452
|
const e = h.now(), i = new l(), r = t.positions?.getValue(e);
|
|
453
453
|
if (r?.length > 0) {
|
|
454
454
|
for (const f of r)
|
|
@@ -462,7 +462,7 @@ function Ot(t, o, n) {
|
|
|
462
462
|
t.shape = u;
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
|
-
function
|
|
465
|
+
function Ot(t, o, n) {
|
|
466
466
|
const e = h.now(), i = new l(), r = t.positions?.getValue(e);
|
|
467
467
|
if (r?.length > 0) {
|
|
468
468
|
for (const m of r)
|
|
@@ -481,7 +481,7 @@ function ln(t, o, n) {
|
|
|
481
481
|
let d;
|
|
482
482
|
if (r) {
|
|
483
483
|
const V = g.fromQuaternion(r), S = a.fromRotation(V), I = a.multiply(f, S, S), N = $(I);
|
|
484
|
-
d =
|
|
484
|
+
d = O.toCartesian3(N), p.rotation = d;
|
|
485
485
|
}
|
|
486
486
|
const y = new P(m ?? void 0, d ? G(d) : void 0, c ?? void 0);
|
|
487
487
|
let M = a.fromTranslationRotationScale(y);
|
|
@@ -501,17 +501,17 @@ function mn(t) {
|
|
|
501
501
|
return n.getBufferData(c, 0, 0, i), c;
|
|
502
502
|
}
|
|
503
503
|
new x(), new l(), new b();
|
|
504
|
-
const
|
|
504
|
+
const Q = [new x(), new x(), new x(), new x()], _ = [new l(), new l(), new l(), new l()];
|
|
505
505
|
new b(), new b(), new b(), new b();
|
|
506
506
|
const Nt = [new D(), new D(), new D(), new D()];
|
|
507
|
-
new
|
|
507
|
+
new v(), new v(), new v(), new v();
|
|
508
508
|
new F(), new F(), new F(), new F();
|
|
509
509
|
new g(), new g(), new g(), new g();
|
|
510
510
|
new a(), new a(), new a(), new a();
|
|
511
511
|
new w(), new w(), new w(), new w();
|
|
512
512
|
new B(), new B(), new B(), new B();
|
|
513
513
|
function pn(t, o = []) {
|
|
514
|
-
const { stride: n, vertexArray: e } = t, i = e.length / n, r =
|
|
514
|
+
const { stride: n, vertexArray: e } = t, i = e.length / n, r = _[0];
|
|
515
515
|
for (let s = 0; s < i; s++)
|
|
516
516
|
t.encoding.decodePosition(e, s, r), l.pack(r, o, o.length);
|
|
517
517
|
return o;
|
|
@@ -520,7 +520,7 @@ function dn(t, o, n) {
|
|
|
520
520
|
return t.encoding.decodePosition(t.vertexArray, o, n);
|
|
521
521
|
}
|
|
522
522
|
function Ft(t) {
|
|
523
|
-
const { stride: o, vertices: n, indices: e, encoding: i } = t, r = n.length / o, s =
|
|
523
|
+
const { stride: o, vertices: n, indices: e, encoding: i } = t, r = n.length / o, s = _[0], c = new Float32Array(r * 3), u = Q[0], f = new Float32Array(r * 2), m = new Float32Array(r);
|
|
524
524
|
for (let p = 0; p < r; p++) {
|
|
525
525
|
i.decodePosition(n, p, s), l.pack(s, c, p * 3);
|
|
526
526
|
const d = i.decodeHeight(n, p);
|
|
@@ -537,10 +537,10 @@ function Ft(t) {
|
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
539
|
function nt(t, o) {
|
|
540
|
-
const n = t._surface._tilesToRender, e = [], i = new
|
|
540
|
+
const n = t._surface._tilesToRender, e = [], i = new v();
|
|
541
541
|
for (const r of n) {
|
|
542
542
|
const { rectangle: s } = r;
|
|
543
|
-
|
|
543
|
+
v.intersection(o, s, i) && e.push(r);
|
|
544
544
|
}
|
|
545
545
|
return e;
|
|
546
546
|
}
|
|
@@ -568,9 +568,9 @@ function wn(t) {
|
|
|
568
568
|
function Gt(t, o, n) {
|
|
569
569
|
const { east: e, north: i, south: r, west: s } = o, c = Nt[0];
|
|
570
570
|
c.longitude = s, c.latitude = r;
|
|
571
|
-
const u = t.positionToTileXY(c, n,
|
|
571
|
+
const u = t.positionToTileXY(c, n, Q[0]);
|
|
572
572
|
c.longitude = e, c.latitude = i;
|
|
573
|
-
const f = t.positionToTileXY(c, n,
|
|
573
|
+
const f = t.positionToTileXY(c, n, Q[1]), [m, p] = u.x < f.x ? [u.x, f.x] : [f.x, u.x], [d, y] = u.y < f.y ? [u.y, f.y] : [f.y, u.y];
|
|
574
574
|
return { min: [m, d], max: [p, y] };
|
|
575
575
|
}
|
|
576
576
|
const Ht = 32767;
|
|
@@ -585,7 +585,7 @@ function hn(t, o, n) {
|
|
|
585
585
|
const e = Math.PI / 180;
|
|
586
586
|
return x.multiplyByScalar(n, e, n);
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function _t(t) {
|
|
589
589
|
const { _quantizedVertices: o, _indices: n } = t, e = o.length / 3, i = {
|
|
590
590
|
type: "Float32Array",
|
|
591
591
|
start: 0,
|
|
@@ -609,14 +609,14 @@ function Qt(t) {
|
|
|
609
609
|
async function xn(t, o, n, e) {
|
|
610
610
|
const i = await t.requestTileGeometry(o, n, e);
|
|
611
611
|
if (!i) return null;
|
|
612
|
-
const r =
|
|
612
|
+
const r = _t(i), s = [data._minimumHeight, data._maximumHeight], c = t.tilingScheme.tileXYToRectangle(o, n, e), u = rt(c, s), f = a.fromArray(u, void 0), m = ["u", "v", "height"], p = new at({ ...r, positionNames: m }), d = new l();
|
|
613
613
|
return p.mapForAggregate(m, (y, M) => (l.fromArray(y, 0, d), a.multiplyByPoint(f, d, d), new D(d.x, d.y, d.z)));
|
|
614
614
|
}
|
|
615
615
|
async function Tn(t, o, n) {
|
|
616
616
|
const { min: e, max: i } = Gt(t.tilingScheme, o, n), r = [], s = [];
|
|
617
617
|
for (let u = e[0]; u <= i[0]; u++)
|
|
618
618
|
for (let f = e[1]; f <= i[1]; f++) {
|
|
619
|
-
const m =
|
|
619
|
+
const m = Qt(t, u, f, n);
|
|
620
620
|
m && (r.push(m), s.push({ x: u, y: f }));
|
|
621
621
|
}
|
|
622
622
|
return (await Promise.all(r)).map(function(u, f) {
|
|
@@ -624,14 +624,14 @@ async function Tn(t, o, n) {
|
|
|
624
624
|
return { x: m, y: p, level: n, data: u };
|
|
625
625
|
});
|
|
626
626
|
}
|
|
627
|
-
async function
|
|
627
|
+
async function Qt(t, o, n, e) {
|
|
628
628
|
return t.getTileDataAvailable(o, n, e) ? (await t.loadTileDataAvailability(o, n, e), t.requestTileGeometry(o, n, e)) : Promise.reject("不可用");
|
|
629
629
|
}
|
|
630
|
-
async function
|
|
631
|
-
const n =
|
|
630
|
+
async function vn(t, o) {
|
|
631
|
+
const n = v.fromCartesianArray(o), e = D.toCartesian(v.center(n)), i = L(t.ellipsoid, e), r = [i.x, i.y, 1], s = nt(t, n), c = ot(s), u = E.eastNorthUpToFixedFrame(e);
|
|
632
632
|
a.inverseTransformation(u, u);
|
|
633
633
|
const f = o.map((d) => {
|
|
634
|
-
const y = a.multiplyByPoint(u, d,
|
|
634
|
+
const y = a.multiplyByPoint(u, d, _[2]);
|
|
635
635
|
return [y.x, y.y];
|
|
636
636
|
});
|
|
637
637
|
let m = 0;
|
|
@@ -658,11 +658,11 @@ async function An(t, o) {
|
|
|
658
658
|
}
|
|
659
659
|
return m;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
662
|
-
const n =
|
|
661
|
+
function An(t, o) {
|
|
662
|
+
const n = v.fromCartesianArray(o), e = D.toCartesian(v.center(n)), i = L(t.ellipsoid, e), r = [i.x, i.y, 1], s = nt(t, n), c = ot(s), u = E.eastNorthUpToFixedFrame(e);
|
|
663
663
|
a.inverseTransformation(u, u);
|
|
664
664
|
const f = o.map((p) => {
|
|
665
|
-
const d = a.multiplyByPoint(u, p,
|
|
665
|
+
const d = a.multiplyByPoint(u, p, _[2]);
|
|
666
666
|
return [d.x, d.y];
|
|
667
667
|
});
|
|
668
668
|
let m = 0;
|
|
@@ -689,15 +689,15 @@ function vn(t, o) {
|
|
|
689
689
|
export {
|
|
690
690
|
ft as CartesianAxis,
|
|
691
691
|
mt as HeadingPitchRollComponent,
|
|
692
|
-
|
|
692
|
+
O as Xyz_Hpr,
|
|
693
693
|
Xt as applyMatrixReferFrame,
|
|
694
694
|
Tt as applyTransformInPrimitive,
|
|
695
695
|
an as applyTransformInfoPrimitive,
|
|
696
696
|
ut as componentDatatypeTypedArrayMap,
|
|
697
697
|
fn as computeAttributeSizeInBytes,
|
|
698
698
|
wt as computeNormalOfCoplanars,
|
|
699
|
-
|
|
700
|
-
|
|
699
|
+
An as computeTerrainAreaOfPolygon,
|
|
700
|
+
vn as computeTerrainAreaOfPolygon_worker,
|
|
701
701
|
un as computeVertexNumOfAttribute,
|
|
702
702
|
jt as createPlaneOfCoplanars,
|
|
703
703
|
K as flatTransformInfoOptions,
|
|
@@ -705,7 +705,7 @@ export {
|
|
|
705
705
|
en as getBoundingSphere,
|
|
706
706
|
pn as getDecodePositionsOfTerrainMesh,
|
|
707
707
|
ln as getEntityInfo,
|
|
708
|
-
|
|
708
|
+
_t as getGeometryDataOfQuantizedMeshTerrainData,
|
|
709
709
|
Ft as getGeometryDataOfTerrainMesh,
|
|
710
710
|
zt as getLevelRangeOfQuadtreeTiles,
|
|
711
711
|
L as getLocalCurvatureRadius,
|
|
@@ -718,12 +718,12 @@ export {
|
|
|
718
718
|
nt as getRenderedQuadtreeTilesOfIntersectRectangle,
|
|
719
719
|
yn as getRenderedTileLevelRange,
|
|
720
720
|
gn as getScaleOfTerrainDataByOrientedBoundingBox,
|
|
721
|
-
|
|
721
|
+
Qt as getTerrainData,
|
|
722
722
|
wn as getTerrainDataOfQuadtreeTile,
|
|
723
723
|
Tn as getTerrainDatasOfIntersectRectangle,
|
|
724
724
|
ot as getTerrainDatasOfQuadtreeTiles,
|
|
725
725
|
Gt as getTileRangeOfIntersectRectangle,
|
|
726
|
-
|
|
726
|
+
At as getTransform,
|
|
727
727
|
xn as getWorldDataOfQuantizedMeshTerrainData,
|
|
728
728
|
yt as getWorldMatrix,
|
|
729
729
|
q as getWorldTransformInfo,
|
|
@@ -732,14 +732,14 @@ export {
|
|
|
732
732
|
J as isPositionPrimitive,
|
|
733
733
|
Jt as isPrimitiveObject,
|
|
734
734
|
pt as localQuaternionToWorld,
|
|
735
|
-
xt as
|
|
736
|
-
on as
|
|
735
|
+
xt as localTRS_WorldMatrix4_Convert,
|
|
736
|
+
on as localTRS_WorldMatrix4_ENU_Convert,
|
|
737
737
|
H as makeMatrixReferFrame,
|
|
738
738
|
ht as mat4_compose,
|
|
739
739
|
gt as mat4_decompose,
|
|
740
740
|
$ as matrix4ToHeadingPitchRoll,
|
|
741
741
|
qt as quaternionToHeadingPitchRoll,
|
|
742
|
-
|
|
742
|
+
vt as resetTransformInPrimitive,
|
|
743
743
|
sn as resetTransformInfoPrimitive,
|
|
744
744
|
Kt as rotateMatrixReferFrame,
|
|
745
745
|
G as rotationInfoToQuaternion,
|
|
@@ -757,8 +757,8 @@ export {
|
|
|
757
757
|
Bt as transformPolygonGraphics,
|
|
758
758
|
tt as transformPolygonHierarchy,
|
|
759
759
|
bt as transformPolylineGraphics,
|
|
760
|
-
|
|
761
|
-
|
|
760
|
+
Ct as transformPolylineVolumeGraphics,
|
|
761
|
+
Ot as transformWallGraphics,
|
|
762
762
|
Zt as translationMatrixReferFrame,
|
|
763
763
|
Lt as worldMatrixToLocal,
|
|
764
764
|
Ut as worldQuaternionToLocal
|
package/dist/tools.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("cesium"),require("@web-3d/tools")):typeof define=="function"&&define.amd?define(["exports","cesium","@web-3d/tools"],t):(l=typeof globalThis<"u"?globalThis:l||self,t(l.Tools={},l.cesium,l.tools))})(this,function(l,t,M){"use strict";function wt(n){return A(n)||m(n)||z(n)}function A(n){return"modelMatrix"in n}function m(n){return"position"in n}function z(n){return"positions"in n}const N={[t.WebGLConstants.BYTE]:Int8Array,[t.WebGLConstants.UNSIGNED_BYTE]:Uint8Array,[t.WebGLConstants.SHORT]:Int16Array,[t.WebGLConstants.UNSIGNED_SHORT]:Uint16Array,[t.WebGLConstants.INT]:Int32Array,[t.WebGLConstants.UNSIGNED_INT]:Uint32Array,[t.WebGLConstants.FLOAT]:Float32Array,[t.WebGLConstants.DOUBLE]:Float64Array};var F=(n=>(n[n.x=0]="x",n[n.y=1]="y",n[n.z=2]="z",n))(F||{});l.Xyz_Hpr=(n=>(n.x="roll",n.y="pitch",n.z="heading",n))(l.Xyz_Hpr||{}),(n=>{function o(r){for(let[i,s]of Object.entries(n))if(r===s)return i}n.toKey=o;function a(r){return new t.Cartesian3(r.roll,-r.pitch,-r.heading)}n.toCartesian3=a;function e(r){return new t.HeadingPitchRoll(-r[o("heading")],-r[o("pitch")],r[o("roll")])}n.toHeadingPitchRoll=e})(l.Xyz_Hpr||(l.Xyz_Hpr={}));var L=(n=>(n[n.heading=0]="heading",n[n.pitch=1]="pitch",n[n.roll=2]="roll",n))(L||{});function V(n){const o=n?.world,{translation:a,rotation:e,scale:r}=o&&typeof o=="object"?o:{translation:o,rotation:o,scale:o};return{...n,worldTranslation:a,worldRotation:e,worldScale:r}}function P(n){if(n.axis){const{axis:a,angle:e}=n;return t.Quaternion.fromAxisAngle(a,e)}const o=l.Xyz_Hpr.toHeadingPitchRoll(n);return t.Quaternion.fromHeadingPitchRoll(o)}function ht(n,o,a){const e=t.Matrix3.fromQuaternion(n),r=t.Matrix4.fromRotation(e),i=t.Matrix4.inverseTransformation(o,new t.Matrix4),s=t.Matrix4.multiply(i,r,r);return B(s)}function B(n,o){const a=t.Matrix4.getMatrix3(n,new t.Matrix3),e=t.Quaternion.fromRotationMatrix(a);return t.HeadingPitchRoll.fromQuaternion(e,o)}function xt(n,o,a){a=a??new t.Matrix4;const e=t.Matrix4.inverse(o,new t.Matrix4);return t.Matrix4.multiply(e,n,a)}function J(n,o,a){let e=t.Quaternion.computeAxis(n,new t.Cartesian3);if(e.equals(t.Cartesian3.ZERO))return null;const r=t.Quaternion.computeAngle(n);return e=t.Matrix4.multiplyByPointAsVector(o,e,e),t.Quaternion.fromAxisAngle(e,r)}function Tt(n,o,a){let e=t.Quaternion.computeAxis(n,new t.Cartesian3);if(e.equals(t.Cartesian3.ZERO))return null;const r=t.Quaternion.computeAngle(n),i=t.Matrix4.inverse(o,new t.Matrix4);return e=t.Matrix4.multiplyByPointAsVector(i,e,e),t.Quaternion.fromAxisAngle(e,r)}function D(n,o){let{translation:a,rotation:e,scale:r}=n;const{referFrame:i,worldTranslation:s,worldRotation:f,worldScale:c}=V(o);let d=null;return a&&(s||(a=t.Matrix4.multiplyByPointAsVector(i,a,new t.Cartesian3))),e&&(d=P(e),f||(d=J(d,i))),r&&(c||(r=t.Matrix4.multiplyByPointAsVector(i,r,new t.Cartesian3))),{translation:a,rotation:d,scale:r}}function _(n,o){let{translation:a,rotation:e,scale:r}=n;const{referFrame:i,worldTranslation:s,worldRotation:f,worldScale:c}=V(o),d=i?t.Matrix4.inverse(i,new t.Matrix4):null;let y=null;if(a&&s&&(a=t.Matrix4.multiplyByPointAsVector(d,a,new t.Cartesian3)),e&&(y=P(e),f)){let u=t.Quaternion.computeAxis(y,new t.Cartesian3);if(!u.equals(t.Cartesian3.ZERO)){const g=t.Quaternion.computeAngle(y);u=t.Matrix4.multiplyByPointAsVector(d,u,u),y=t.Quaternion.fromAxisAngle(u,g)}}return r&&c&&(r=t.Matrix4.multiplyByPointAsVector(d,r,new t.Cartesian3)),{translation:a,rotation:y,scale:r}}function W(n,o){const a=o?.defaultMatrix;let{translation:e,rotation:r,scale:i}=D(n,o);if(a){if(e||(e=t.Matrix4.getTranslation(a,new t.Cartesian3)),!r){const f=t.Matrix4.getMatrix3(a,new t.Matrix3);r=t.Quaternion.fromRotationMatrix(f)}i||(i=t.Matrix4.getScale(a,new t.Cartesian3))}const s=new t.TranslationRotationScale(e??void 0,r??void 0,i??void 0);return t.Matrix4.fromTranslationRotationScale(s)}function Ct(n){const{translation:o,rotation:a,scale:e}=n,r=a?P(a):void 0,i=new t.TranslationRotationScale(o??void 0,r,e??void 0);return t.Matrix4.fromTranslationRotationScale(i)}function E(n,o,a){const e=t.Cartesian3.subtract(o,n,new t.Cartesian3),r=t.Cartesian3.subtract(a,n,new t.Cartesian3),i=t.Cartesian3.cross(e,r,e);return t.Cartesian3.normalize(i,e)}function Rt(n,o,a){const e=E(n,o,a);return t.Plane.fromPointNormal(e,n)}function*Pt(n,o=!0,a,e){const r=n.length,i=o?r:r-1,s=a||e?t.Cartesian3.prototype.equalsEpsilon:t.Cartesian3.prototype.equals;for(let f=0;f<i;f++){const c=n[f];let d=(f+1)%r,y=n[d],u=f;for(;s.call(c,y,a,e);){if(d=(++u+1)%r,d===f)return;y=n[d]}f=u,yield[c,y]}}function v(n,o,a){a=a??new t.Matrix4;const e=t.Matrix4.inverse(o,new t.Matrix4),r=t.Matrix4.multiply(n,e,e);return t.Matrix4.multiply(o,r,a)}function vt(n,o,a,e){e=e??new t.Matrix4;const r=t.Matrix4.inverse(a,new t.Matrix4);let i=t.Matrix4.multiply(r,n,r);return i=t.Matrix4.multiply(o,i,i),t.Matrix4.multiply(a,i,e)}function At(n,o,a){const e=t.Matrix4.fromTranslation(n);return v(e,o,a)}function mt(n,o,a,e){const r=t.Quaternion.fromAxisAngle(n,o),i=t.Matrix3.fromQuaternion(r),s=t.Matrix4.fromRotation(i);return v(s,a,e)}function Dt(n,o,a){const e=t.Matrix4.fromScale(n);return v(e,o,a)}function St(n,o,a){const e=t.Matrix3.fromScale(o);if(a)for(const r of n)t.Cartesian3.subtract(r,a,r),t.Matrix3.multiplyByVector(e,r,r),t.Cartesian3.add(r,a,r);else{const r=t.Matrix3.fromScale(o);for(const i of n)t.Matrix3.multiplyByVector(r,i,i)}return n}function Ot(n,o){const{translation:a,rotation:e,scale:r}=n;let i;if(e){const{axis:f,angle:c}=e;i=t.Quaternion.fromAxisAngle(f,c)}const s=new t.TranslationRotationScale(a??void 0,i,r??void 0);return t.Matrix4.fromTranslationRotationScale(s,o??void 0)}function k(n,o){o??=new t.TranslationRotationScale;const a=t.Matrix4.pack(n,[]),e=[],r=[],i=[];return M.mat4_decompose(e,r,i,a),t.Cartesian3.unpack(e,0,o.translation),t.Cartesian3.unpack(r,0,o.scale),t.Quaternion.unpack(i,0,o.rotation),o}const q=t.Matrix4.fromTranslationRotationScale;function U(n){const o=t.Matrix4.inverse(n,new t.Matrix4),a=new t.Matrix4;function e(i,s){return s=q(i,s),t.Matrix4.multiply(n,s,s)}function r(i,s){return t.Matrix4.multiply(o,i,a),k(a,s)}return{compose:e,decompose:r}}function It(n,o){const a=t.Transforms.eastNorthUpToFixedFrame(n,o??void 0);return U(a)}function Vt(n){let o=n.boundingSphere;if(o)return o;let a=n.geometryInstances;if(a){a=Array.isArray(a)?a:[a];const r=a.map(i=>i.geometry.boundingSphere);return t.BoundingSphere.fromBoundingSpheres(r)}const e=n.positions;return e?.length>0?t.BoundingSphere.fromPoints(e):null}function Bt(n,o){o=o??new t.Cartesian3;const a=n.position;if(a)return a instanceof t.Cartesian3?a:a.getValue(t.JulianDate.now(),o);const e=n.modelMatrix;if(e)return t.Matrix4.getTranslation(e,o);const r=n.positions;return r?.length>0?t.BoundingSphere.fromPoints(r).center:null}function bt(n,o,a){let{translation:e,rotation:r,scale:i}=D(o,a);const s=new t.TranslationRotationScale(e??void 0,r??void 0,i??void 0),f=t.Matrix4.fromTranslationRotationScale(s);return j(n,f)}function j(n,o){const a=n.modelMatrix;if(a)return t.Matrix4.multiply(o,a,a),n.modelMatrix=a,!0;const e=n.position;if(e){if("scale"in n){const i=t.Matrix4.getTranslation(o,new t.Cartesian3);t.Cartesian3.add(e,i,e);const s=n.scale??1,f=t.Matrix4.getScale(o,new t.Cartesian3);n.scale=t.Cartesian3.maximumComponent(f)*s}else t.Matrix4.multiplyByPoint(o,e,e);return n.position=e,!0}const r=n.positions;if(r?.length>0){for(const i of r)t.Matrix4.multiplyByPoint(o,i,i);return n.positions=r,!0}return!1}function Qt(n,o,a){const e=X(n),r=W(o,{...a,defaultMatrix:e});return Y(n,r)}function Y(n,o){if(A(n))return n.modelMatrix=o,!0;const a=t.Matrix4.getTranslation(o,new t.Cartesian3);if(m(n)){if(n.position=a,"scale"in n){const r=t.Matrix4.getScale(o,new t.Cartesian3);n.scale=t.Cartesian3.maximumComponent(r)}return!0}const e=n.positions;if(e?.length>0){const r=t.BoundingSphere.fromPoints(e);t.Cartesian3.subtract(a,r.center,a);for(const i of e)t.Cartesian3.add(i,a,i);return n.positions=e,!0}return!1}function X(n){if(A(n))return n.modelMatrix;if(m(n)){const a=n.position,e=n.scale??1,r=new t.TranslationRotationScale(a,void 0,new t.Cartesian3(e,e,e));return t.Matrix4.fromTranslationRotationScale(r)}const o=n.positions;if(o?.length>0){const a=t.BoundingSphere.fromPoints(o);return t.Matrix4.fromTranslation(a.center)}return null}function Gt(n,o){let{translation:a,rotation:e,scale:r}=D(o,o);const{reset:i,referFrame:s}=o,f=t.JulianDate.now(),c=!i;if(e){let h=e;if(c){const w=n.orientation?.getValue(f);w&&(h=t.Quaternion.multiply(e,w,w))}n.orientation=h}if(a){let h=a;if(c){const w=n.position?.getValue(f);w&&(h=t.Cartesian3.add(w,a,w))}n.position=h}if(!s)return;const{translation:d,rotation:y,scale:u}=_(o,o),g=new t.TranslationRotationScale(d??void 0,y??void 0,u??void 0);let p=t.Matrix4.fromTranslationRotationScale(g);if(p=v(p,s,p),u){const h=n.box;h&&Z(h,u);const w=n.cylinder;w&&K(w,u);const ut=n.ellipse;ut&&$(ut,u);const gt=n.ellipsoid;gt&&tt(gt,u);const pt=n.model;pt&&nt(pt,u,i);const Mt=n.plane;Mt&&at(Mt,u)}const x=n.corridor;x&&ot(x,p,u);const C=n.polygon;C&&et(C,p,u);const T=n.polyline;T&&rt(T,p,u);const R=n.polylineVolume;R&&it(R,p,u);const I=n.wall;I&<(I,p,u)}function Z(n,o){const a=t.JulianDate.now(),e=n.dimensions?.getValue(a);e&&(n.dimensions=t.Cartesian3.multiplyComponents(e,o,e))}function K(n,o){const a=t.JulianDate.now(),e=n.length?.getValue(a);e!=null&&(n.length=e*o.z);const r=Math.max(o.x,o.y),i=n.topRadius?.getValue(a);i!=null&&(n.topRadius=i*r);const s=o.z,f=n.bottomRadius?.getValue(a);f!=null&&(n.bottomRadius=f*s)}function $(n,o){const a=t.JulianDate.now(),e=Math.max(o.x,o.y),r=o.z,i=n.semiMajorAxis?.getValue(a);i!=null&&(n.semiMajorAxis=i*e);const s=n.semiMinorAxis?.getValue(a);s!=null&&(n.semiMinorAxis=s*e);const f=n.height?.getValue(a);f!=null&&(n.height=f*r);const c=n.extrudedHeight?.getValue(a);c!=null&&(n.extrudedHeight=c*r)}function tt(n,o){const a=t.JulianDate.now(),e=n.radii?.getValue(a);e!=null&&(n.radii=t.Cartesian3.multiplyComponents(e,o,e));const r=n.innerRadii?.getValue(a);r!=null&&(n.innerRadii=t.Cartesian3.multiplyComponents(r,o,r))}function nt(n,o,a){let e=t.Cartesian3.maximumComponent(o);if(!a){const r=t.JulianDate.now(),i=n.scale?.getValue(r)??1;e*=i}n.scale=e}function at(n,o){const a=t.JulianDate.now(),e=t.Cartesian2.fromCartesian3(o),r=n.dimensions?.getValue(a);r&&(n.dimensions=t.Cartesian2.multiplyComponents(r,e,r))}function ot(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const u of i)t.Matrix4.multiplyByPoint(o,u,u);n.dimensions=i}const s=a??t.Matrix4.getScale(o,r),f=Math.max(s.x,s.y);n.width?.getValue(e)!=null&&(n.width=f*scale);const d=n.height?.getValue(e),y=s.z;d!=null&&(n.height=d*y)}function et(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.hierarchy?.getValue(e);i&&(b(i,o),n.hierarchy=i);const f=(a??t.Matrix4.getScale(o,r)).z,c=n.height?.getValue(e);c!=null&&(n.height=c*f);const d=n.extrudedHeight?.getValue(e);d!=null&&(n.extrudedHeight=d*f)}function b(n,o){const{positions:a,holes:e}=n;for(const r of a)t.Matrix4.multiplyByPoint(o,r,r);n.positions=a;for(const r of e)b(r,o)}function rt(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const d of i)t.Matrix4.multiplyByPoint(o,d,d);n.positions=i}const s=a??t.Matrix4.getScale(o,r),f=Math.max(s.x,s.y);n.width?.getValue(e)!=null&&(n.width=f*scale)}function it(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const d of i)t.Matrix4.multiplyByPoint(o,d,d);n.positions=i}const s=a??t.Matrix4.getScale(o,r),f=t.Cartesian2.fromCartesian3(s),c=n.shape?.getValue(e);if(c!=null){for(const d of c)t.Cartesian2.multiplyComponents(d,f,d);n.shape=c}}function lt(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const y of i)t.Matrix4.multiplyByPoint(o,y,y);n.positions=i}const f=(a??t.Matrix4.getScale(o,r)).z,c=n.minimumHeights?.getValue(e);c!=null&&(graphicsgraphics.minimumHeights=c.map(y=>y*f));const d=n.maximumHeights?.getValue(e);d!=null&&(graphicsgraphics.maximumHeights=d.map(y=>y*f))}function Ht(n,o,a){const e=t.JulianDate.now(),r=n.position?.getValue(e);if(!r)return null;const i=n.orientation?.getValue(e),s=n.model?.scale?.getValue(e)??1,f=new t.Cartesian3(s,s,s),c=o(r,a),d=t.Matrix4.inverse(c,new t.Matrix4),y=t.Matrix4.multiplyByPoint(d,r,new t.Cartesian3),u={translation:y,position:r,scale:f,rotation:new t.Cartesian3};let g;if(i){const C=t.Matrix3.fromQuaternion(i),T=t.Matrix4.fromRotation(C),R=t.Matrix4.multiply(d,T,T),I=B(R);g=l.Xyz_Hpr.toCartesian3(I),u.rotation=g}const p=new t.TranslationRotationScale(y??void 0,g?P(g):void 0,f??void 0);let x=t.Matrix4.fromTranslationRotationScale(p);return u.matrix=x,u}function zt(n){return n.values.length/n.componentsPerAttribute}function Nt(n){return t.ComponentDatatype.getSizeInBytes(n.componentDatatype)*n.componentsPerAttribute}function Ft(n){const{componentDatatype:o,vertexBuffer:a}=n,e=N[o];if(!e)throw new Error("不支持的数据类型");const r=a.sizeInBytes,i=t.ComponentDatatype.getSizeInBytes(o),s=r/i;let f=new e(s);return a.getBufferData(f,0,0,r),f}new t.Cartesian2,new t.Cartesian3,new t.Cartesian4;const Q=[new t.Cartesian2,new t.Cartesian2,new t.Cartesian2,new t.Cartesian2],S=[new t.Cartesian3,new t.Cartesian3,new t.Cartesian3,new t.Cartesian3];new t.Cartesian4,new t.Cartesian4,new t.Cartesian4,new t.Cartesian4;const Lt=[new t.Cartographic,new t.Cartographic,new t.Cartographic,new t.Cartographic];new t.Rectangle,new t.Rectangle,new t.Rectangle,new t.Rectangle,new t.Matrix2,new t.Matrix2,new t.Matrix2,new t.Matrix2,new t.Matrix3,new t.Matrix3,new t.Matrix3,new t.Matrix3,new t.Matrix4,new t.Matrix4,new t.Matrix4,new t.Matrix4,new t.Quaternion,new t.Quaternion,new t.Quaternion,new t.Quaternion,new t.HeadingPitchRoll,new t.HeadingPitchRoll,new t.HeadingPitchRoll,new t.HeadingPitchRoll;function Jt(n,o=[]){const{stride:a,vertexArray:e}=n,r=e.length/a,i=S[0];for(let s=0;s<r;s++)n.encoding.decodePosition(e,s,i),t.Cartesian3.pack(i,o,o.length);return o}function _t(n,o,a){return n.encoding.decodePosition(n.vertexArray,o,a)}function st(n){const{stride:o,vertices:a,indices:e,encoding:r}=n,i=a.length/o,s=S[0],f=new Float32Array(i*3),c=Q[0],d=new Float32Array(i*2),y=new Float32Array(i);for(let u=0;u<i;u++){r.decodePosition(a,u,s),t.Cartesian3.pack(s,f,u*3);const g=r.decodeHeight(a,u);y[u]=g,r.decodeTextureCoordinates(a,u,c),t.Cartesian2.pack(c,d,u*2)}return{attributes:{position:{array:f,vectorSize:3},uv:{array:d,vectorSize:2},height:{array:y,vectorSize:1}},indices:e.slice(),count:i}}function G(n,o){const a=n._surface._tilesToRender,e=[],r=new t.Rectangle;for(const i of a){const{rectangle:s}=i;t.Rectangle.intersection(o,s,r)&&e.push(i)}return e}function Wt(n){const o=n._surface._tilesToRender;return ft(o)}function ft(n){const o=new Set;for(const i of n)o.add(i.level);const a=[...o],e=Math.min.apply(Math,a),r=Math.max.apply(Math,a);return{min:e,max:r}}function H(n){return n.map(o=>{const{mesh:a,terrainData:e}=o.data,r=st(a),{x:i,y:s,level:f}=o,c=[e._minimumHeight,e._maximumHeight];return{data:r,encoding:a.encoding,rectangle:o.rectangle,heightRange:c,x:i,y:s,level:f}})}function Et(n){const{x:o,y:a,level:e}=n;return n.data.terrainData.upsample(n.tilingScheme,o,a,e,o,a,e)}function ct(n,o,a){const{east:e,north:r,south:i,west:s}=o,f=Lt[0];f.longitude=s,f.latitude=i;const c=n.positionToTileXY(f,a,Q[0]);f.longitude=e,f.latitude=r;const d=n.positionToTileXY(f,a,Q[1]),[y,u]=c.x<d.x?[c.x,d.x]:[d.x,c.x],[g,p]=c.y<d.y?[c.y,d.y]:[d.y,c.y];return{min:[y,g],max:[u,p]}}const kt=32767;function qt(n,o=new t.Cartesian3){return t.Matrix3.getScale(n.halfAxes,o),t.Cartesian3.multiplyByScalar(o,2*kt,o),o}function O(n,o,a){return a=n.getLocalCurvature(o,a),a.x=1/a.x,a.y=1/a.y,a}function Ut(n,o,a){a=O(n,o,a);const e=Math.PI/180;return t.Cartesian2.multiplyByScalar(a,e,a)}function dt(n){const{_quantizedVertices:o,_indices:a}=n,e=o.length/3,r={type:"Float32Array",start:0,vectorSize:1},i={type:"Float32Array",start:e,vectorSize:1},s={type:"Float32Array",start:e*2,vectorSize:1};return{array:new Float32Array(o),attributes:{u:r,v:i,height:s},count:e,indices:a}}async function jt(n,o,a,e){const r=await n.requestTileGeometry(o,a,e);if(!r)return null;const i=dt(r),s=[data._minimumHeight,data._maximumHeight],f=n.tilingScheme.tileXYToRectangle(o,a,e),c=M.getMatrixOfQuantizedMeshTerrainData(f,s),d=t.Matrix4.fromArray(c,void 0),y=["u","v","height"],u=new M.Geometry({...i,positionNames:y}),g=new t.Cartesian3;return u.mapForAggregate(y,(p,x)=>(t.Cartesian3.fromArray(p,0,g),t.Matrix4.multiplyByPoint(d,g,g),new t.Cartographic(g.x,g.y,g.z)))}async function Yt(n,o,a){const{min:e,max:r}=ct(n.tilingScheme,o,a),i=[],s=[];for(let c=e[0];c<=r[0];c++)for(let d=e[1];d<=r[1];d++){const y=yt(n,c,d,a);y&&(i.push(y),s.push({x:c,y:d}))}return(await Promise.all(i)).map(function(c,d){const{x:y,y:u}=s[d];return{x:y,y:u,level:a,data:c}})}async function yt(n,o,a,e){return n.getTileDataAvailable(o,a,e)?(await n.loadTileDataAvailability(o,a,e),n.requestTileGeometry(o,a,e)):Promise.reject("不可用")}async function Xt(n,o){const a=t.Rectangle.fromCartesianArray(o),e=t.Cartographic.toCartesian(t.Rectangle.center(a)),r=O(n.ellipsoid,e),i=[r.x,r.y,1],s=G(n,a),f=H(s),c=t.Transforms.eastNorthUpToFixedFrame(e);t.Matrix4.inverseTransformation(c,c);const d=o.map(g=>{const p=t.Matrix4.multiplyByPoint(c,g,S[2]);return[p.x,p.y]});let y=0;const u=f.map(async g=>{const{data:p,...x}=g,{position:C,uv:T,height:R}=p.attributes;y+=await M.workerApi.computeRelationAreaOfPolygon2Terrain({args:[{...p,...x,positionNames:["position"],region:d,matrix:t.Matrix4.pack(c,[]),relation:M.GeometricRelation.Contain|M.GeometricRelation.Intersect,scale:i}],transfer:[C.array.buffer,T.array.buffer,R.array.buffer,p.indices.buffer]})});if(await Promise.all(u),y===0||isNaN(y)){console.warn("贴地面积计算异常,已回退到椭球面投影面积",y);const g=o.map(p=>t.Cartesian3.pack(p,[]));return y=M.computeSignAreaOfPolygon3(g),Math.abs(y)}return y}function Zt(n,o){const a=t.Rectangle.fromCartesianArray(o),e=t.Cartographic.toCartesian(t.Rectangle.center(a)),r=O(n.ellipsoid,e),i=[r.x,r.y,1],s=G(n,a),f=H(s),c=t.Transforms.eastNorthUpToFixedFrame(e);t.Matrix4.inverseTransformation(c,c);const d=o.map(u=>{const g=t.Matrix4.multiplyByPoint(c,u,S[2]);return[g.x,g.y]});let y=0;for(const u of f){const{data:g,...p}=u;y+=M.computeRelationAreaOfPolygon2Terrain({...g,...p,positionNames:["position"],region:d,matrix:t.Matrix4.pack(c,[]),relation:M.GeometricRelation.Contain|M.GeometricRelation.Intersect,scale:i})}if(y===0||isNaN(y)){console.warn("贴地面积计算异常,已回退到椭球面投影面积",y);const u=o.map(g=>t.Cartesian3.pack(g,[]));return y=M.computeSignAreaOfPolygon3(u),Math.abs(y)}return y}l.CartesianAxis=F,l.HeadingPitchRollComponent=L,l.applyMatrixReferFrame=vt,l.applyTransformInPrimitive=j,l.applyTransformInfoPrimitive=bt,l.componentDatatypeTypedArrayMap=N,l.computeAttributeSizeInBytes=Nt,l.computeNormalOfCoplanars=E,l.computeTerrainAreaOfPolygon=Zt,l.computeTerrainAreaOfPolygon_worker=Xt,l.computeVertexNumOfAttribute=zt,l.createPlaneOfCoplanars=Rt,l.flatTransformInfoOptions=V,l.getAttributeData=Ft,l.getBoundingSphere=Vt,l.getDecodePositionsOfTerrainMesh=Jt,l.getEntityInfo=Ht,l.getGeometryDataOfQuantizedMeshTerrainData=dt,l.getGeometryDataOfTerrainMesh=st,l.getLevelRangeOfQuadtreeTiles=ft,l.getLocalCurvatureRadius=O,l.getLocalSizePerDegrees=Ut,l.getLocalTransformInfo=_,l.getMatrix4OfTransformInfo=Ot,l.getNeighborPairs=Pt,l.getPosition=Bt,l.getPositionOfTerrainMesh=_t,l.getRenderedQuadtreeTilesOfIntersectRectangle=G,l.getRenderedTileLevelRange=Wt,l.getScaleOfTerrainDataByOrientedBoundingBox=qt,l.getTerrainData=yt,l.getTerrainDataOfQuadtreeTile=Et,l.getTerrainDatasOfIntersectRectangle=Yt,l.getTerrainDatasOfQuadtreeTiles=H,l.getTileRangeOfIntersectRectangle=ct,l.getTransform=X,l.getWorldDataOfQuantizedMeshTerrainData=jt,l.getWorldMatrix=W,l.getWorldTransformInfo=D,l.isMatrixPrimitive=A,l.isPositionListPrimitive=z,l.isPositionPrimitive=m,l.isPrimitiveObject=wt,l.localQuaternionToWorld=J,l.localTRS_WorldMatrix4=U,l.localTRS_WorldMatrix4_ENU=It,l.makeMatrixReferFrame=v,l.mat4_compose=q,l.mat4_decompose=k,l.matrix4ToHeadingPitchRoll=B,l.quaternionToHeadingPitchRoll=ht,l.resetTransformInPrimitive=Y,l.resetTransformInfoPrimitive=Qt,l.rotateMatrixReferFrame=mt,l.rotationInfoToQuaternion=P,l.scaleBoxGraphics=Z,l.scaleCylinderGraphics=K,l.scaleEllipseGraphics=$,l.scaleEllipsoidGraphics=tt,l.scaleMatrixReferFrame=Dt,l.scaleModelGraphics=nt,l.scalePlaneGraphics=at,l.scalePoints=St,l.transformCorridorGraphics=ot,l.transformEntity=Gt,l.transformInfoToMatrix=Ct,l.transformPolygonGraphics=et,l.transformPolygonHierarchy=b,l.transformPolylineGraphics=rt,l.transformPolylineVolumeGraphics=it,l.transformWallGraphics=lt,l.translationMatrixReferFrame=At,l.worldMatrixToLocal=xt,l.worldQuaternionToLocal=Tt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(l,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("cesium"),require("@web-3d/tools")):typeof define=="function"&&define.amd?define(["exports","cesium","@web-3d/tools"],t):(l=typeof globalThis<"u"?globalThis:l||self,t(l.Tools={},l.cesium,l.tools))})(this,function(l,t,M){"use strict";function wt(n){return A(n)||m(n)||z(n)}function A(n){return"modelMatrix"in n}function m(n){return"position"in n}function z(n){return"positions"in n}const N={[t.WebGLConstants.BYTE]:Int8Array,[t.WebGLConstants.UNSIGNED_BYTE]:Uint8Array,[t.WebGLConstants.SHORT]:Int16Array,[t.WebGLConstants.UNSIGNED_SHORT]:Uint16Array,[t.WebGLConstants.INT]:Int32Array,[t.WebGLConstants.UNSIGNED_INT]:Uint32Array,[t.WebGLConstants.FLOAT]:Float32Array,[t.WebGLConstants.DOUBLE]:Float64Array};var _=(n=>(n[n.x=0]="x",n[n.y=1]="y",n[n.z=2]="z",n))(_||{});l.Xyz_Hpr=(n=>(n.x="roll",n.y="pitch",n.z="heading",n))(l.Xyz_Hpr||{}),(n=>{function o(r){for(let[i,s]of Object.entries(n))if(r===s)return i}n.toKey=o;function a(r){return new t.Cartesian3(r.roll,-r.pitch,-r.heading)}n.toCartesian3=a;function e(r){return new t.HeadingPitchRoll(-r[o("heading")],-r[o("pitch")],r[o("roll")])}n.toHeadingPitchRoll=e})(l.Xyz_Hpr||(l.Xyz_Hpr={}));var F=(n=>(n[n.heading=0]="heading",n[n.pitch=1]="pitch",n[n.roll=2]="roll",n))(F||{});function V(n){const o=n?.world,{translation:a,rotation:e,scale:r}=o&&typeof o=="object"?o:{translation:o,rotation:o,scale:o};return{...n,worldTranslation:a,worldRotation:e,worldScale:r}}function P(n){if(n.axis){const{axis:a,angle:e}=n;return t.Quaternion.fromAxisAngle(a,e)}const o=l.Xyz_Hpr.toHeadingPitchRoll(n);return t.Quaternion.fromHeadingPitchRoll(o)}function ht(n,o,a){const e=t.Matrix3.fromQuaternion(n),r=t.Matrix4.fromRotation(e),i=t.Matrix4.inverseTransformation(o,new t.Matrix4),s=t.Matrix4.multiply(i,r,r);return B(s)}function B(n,o){const a=t.Matrix4.getMatrix3(n,new t.Matrix3),e=t.Quaternion.fromRotationMatrix(a);return t.HeadingPitchRoll.fromQuaternion(e,o)}function xt(n,o,a){a=a??new t.Matrix4;const e=t.Matrix4.inverse(o,new t.Matrix4);return t.Matrix4.multiply(e,n,a)}function L(n,o,a){let e=t.Quaternion.computeAxis(n,new t.Cartesian3);if(e.equals(t.Cartesian3.ZERO))return null;const r=t.Quaternion.computeAngle(n);return e=t.Matrix4.multiplyByPointAsVector(o,e,e),t.Quaternion.fromAxisAngle(e,r)}function Tt(n,o,a){let e=t.Quaternion.computeAxis(n,new t.Cartesian3);if(e.equals(t.Cartesian3.ZERO))return null;const r=t.Quaternion.computeAngle(n),i=t.Matrix4.inverse(o,new t.Matrix4);return e=t.Matrix4.multiplyByPointAsVector(i,e,e),t.Quaternion.fromAxisAngle(e,r)}function D(n,o){let{translation:a,rotation:e,scale:r}=n;const{referFrame:i,worldTranslation:s,worldRotation:f,worldScale:c}=V(o);let d=null;return a&&(s||(a=t.Matrix4.multiplyByPointAsVector(i,a,new t.Cartesian3))),e&&(d=P(e),f||(d=L(d,i))),r&&(c||(r=t.Matrix4.multiplyByPointAsVector(i,r,new t.Cartesian3))),{translation:a,rotation:d,scale:r}}function J(n,o){let{translation:a,rotation:e,scale:r}=n;const{referFrame:i,worldTranslation:s,worldRotation:f,worldScale:c}=V(o),d=i?t.Matrix4.inverse(i,new t.Matrix4):null;let y=null;if(a&&s&&(a=t.Matrix4.multiplyByPointAsVector(d,a,new t.Cartesian3)),e&&(y=P(e),f)){let u=t.Quaternion.computeAxis(y,new t.Cartesian3);if(!u.equals(t.Cartesian3.ZERO)){const g=t.Quaternion.computeAngle(y);u=t.Matrix4.multiplyByPointAsVector(d,u,u),y=t.Quaternion.fromAxisAngle(u,g)}}return r&&c&&(r=t.Matrix4.multiplyByPointAsVector(d,r,new t.Cartesian3)),{translation:a,rotation:y,scale:r}}function W(n,o){const a=o?.defaultMatrix;let{translation:e,rotation:r,scale:i}=D(n,o);if(a){if(e||(e=t.Matrix4.getTranslation(a,new t.Cartesian3)),!r){const f=t.Matrix4.getMatrix3(a,new t.Matrix3);r=t.Quaternion.fromRotationMatrix(f)}i||(i=t.Matrix4.getScale(a,new t.Cartesian3))}const s=new t.TranslationRotationScale(e??void 0,r??void 0,i??void 0);return t.Matrix4.fromTranslationRotationScale(s)}function Ct(n){const{translation:o,rotation:a,scale:e}=n,r=a?P(a):void 0,i=new t.TranslationRotationScale(o??void 0,r,e??void 0);return t.Matrix4.fromTranslationRotationScale(i)}function E(n,o,a){const e=t.Cartesian3.subtract(o,n,new t.Cartesian3),r=t.Cartesian3.subtract(a,n,new t.Cartesian3),i=t.Cartesian3.cross(e,r,e);return t.Cartesian3.normalize(i,e)}function Rt(n,o,a){const e=E(n,o,a);return t.Plane.fromPointNormal(e,n)}function*Pt(n,o=!0,a,e){const r=n.length,i=o?r:r-1,s=a||e?t.Cartesian3.prototype.equalsEpsilon:t.Cartesian3.prototype.equals;for(let f=0;f<i;f++){const c=n[f];let d=(f+1)%r,y=n[d],u=f;for(;s.call(c,y,a,e);){if(d=(++u+1)%r,d===f)return;y=n[d]}f=u,yield[c,y]}}function v(n,o,a){a=a??new t.Matrix4;const e=t.Matrix4.inverse(o,new t.Matrix4),r=t.Matrix4.multiply(n,e,e);return t.Matrix4.multiply(o,r,a)}function vt(n,o,a,e){e=e??new t.Matrix4;const r=t.Matrix4.inverse(a,new t.Matrix4);let i=t.Matrix4.multiply(r,n,r);return i=t.Matrix4.multiply(o,i,i),t.Matrix4.multiply(a,i,e)}function At(n,o,a){const e=t.Matrix4.fromTranslation(n);return v(e,o,a)}function mt(n,o,a,e){const r=t.Quaternion.fromAxisAngle(n,o),i=t.Matrix3.fromQuaternion(r),s=t.Matrix4.fromRotation(i);return v(s,a,e)}function Dt(n,o,a){const e=t.Matrix4.fromScale(n);return v(e,o,a)}function St(n,o,a){const e=t.Matrix3.fromScale(o);if(a)for(const r of n)t.Cartesian3.subtract(r,a,r),t.Matrix3.multiplyByVector(e,r,r),t.Cartesian3.add(r,a,r);else{const r=t.Matrix3.fromScale(o);for(const i of n)t.Matrix3.multiplyByVector(r,i,i)}return n}function Ot(n,o){const{translation:a,rotation:e,scale:r}=n;let i;if(e){const{axis:f,angle:c}=e;i=t.Quaternion.fromAxisAngle(f,c)}const s=new t.TranslationRotationScale(a??void 0,i,r??void 0);return t.Matrix4.fromTranslationRotationScale(s,o??void 0)}function k(n,o){o??=new t.TranslationRotationScale;const a=t.Matrix4.pack(n,[]),e=[],r=[],i=[];return M.mat4_decompose(e,r,i,a),t.Cartesian3.unpack(e,0,o.translation),t.Cartesian3.unpack(r,0,o.scale),t.Quaternion.unpack(i,0,o.rotation),o}const q=t.Matrix4.fromTranslationRotationScale;function U(n){const o=t.Matrix4.inverse(n,new t.Matrix4),a=new t.Matrix4;function e(i,s){return s=q(i,s),t.Matrix4.multiply(n,s,s)}function r(i,s){return t.Matrix4.multiply(o,i,a),k(a,s)}return{compose:e,decompose:r,referInverse:o}}function It(n,o){const a=t.Transforms.eastNorthUpToFixedFrame(n,o??void 0);return{...U(a),refer:a}}function Vt(n){let o=n.boundingSphere;if(o)return o;let a=n.geometryInstances;if(a){a=Array.isArray(a)?a:[a];const r=a.map(i=>i.geometry.boundingSphere);return t.BoundingSphere.fromBoundingSpheres(r)}const e=n.positions;return e?.length>0?t.BoundingSphere.fromPoints(e):null}function Bt(n,o){o=o??new t.Cartesian3;const a=n.position;if(a)return a instanceof t.Cartesian3?a:a.getValue(t.JulianDate.now(),o);const e=n.modelMatrix;if(e)return t.Matrix4.getTranslation(e,o);const r=n.positions;return r?.length>0?t.BoundingSphere.fromPoints(r).center:null}function bt(n,o,a){let{translation:e,rotation:r,scale:i}=D(o,a);const s=new t.TranslationRotationScale(e??void 0,r??void 0,i??void 0),f=t.Matrix4.fromTranslationRotationScale(s);return j(n,f)}function j(n,o){const a=n.modelMatrix;if(a)return t.Matrix4.multiply(o,a,a),n.modelMatrix=a,!0;const e=n.position;if(e){if("scale"in n){const i=t.Matrix4.getTranslation(o,new t.Cartesian3);t.Cartesian3.add(e,i,e);const s=n.scale??1,f=t.Matrix4.getScale(o,new t.Cartesian3);n.scale=t.Cartesian3.maximumComponent(f)*s}else t.Matrix4.multiplyByPoint(o,e,e);return n.position=e,!0}const r=n.positions;if(r?.length>0){for(const i of r)t.Matrix4.multiplyByPoint(o,i,i);return n.positions=r,!0}return!1}function Qt(n,o,a){const e=X(n),r=W(o,{...a,defaultMatrix:e});return Y(n,r)}function Y(n,o){if(A(n))return n.modelMatrix=o,!0;const a=t.Matrix4.getTranslation(o,new t.Cartesian3);if(m(n)){if(n.position=a,"scale"in n){const r=t.Matrix4.getScale(o,new t.Cartesian3);n.scale=t.Cartesian3.maximumComponent(r)}return!0}const e=n.positions;if(e?.length>0){const r=t.BoundingSphere.fromPoints(e);t.Cartesian3.subtract(a,r.center,a);for(const i of e)t.Cartesian3.add(i,a,i);return n.positions=e,!0}return!1}function X(n){if(A(n))return n.modelMatrix;if(m(n)){const a=n.position,e=n.scale??1,r=new t.TranslationRotationScale(a,void 0,new t.Cartesian3(e,e,e));return t.Matrix4.fromTranslationRotationScale(r)}const o=n.positions;if(o?.length>0){const a=t.BoundingSphere.fromPoints(o);return t.Matrix4.fromTranslation(a.center)}return null}function Gt(n,o){let{translation:a,rotation:e,scale:r}=D(o,o);const{reset:i,referFrame:s}=o,f=t.JulianDate.now(),c=!i;if(e){let h=e;if(c){const w=n.orientation?.getValue(f);w&&(h=t.Quaternion.multiply(e,w,w))}n.orientation=h}if(a){let h=a;if(c){const w=n.position?.getValue(f);w&&(h=t.Cartesian3.add(w,a,w))}n.position=h}if(!s)return;const{translation:d,rotation:y,scale:u}=J(o,o),g=new t.TranslationRotationScale(d??void 0,y??void 0,u??void 0);let p=t.Matrix4.fromTranslationRotationScale(g);if(p=v(p,s,p),u){const h=n.box;h&&Z(h,u);const w=n.cylinder;w&&K(w,u);const ut=n.ellipse;ut&&$(ut,u);const gt=n.ellipsoid;gt&&tt(gt,u);const pt=n.model;pt&&nt(pt,u,i);const Mt=n.plane;Mt&&at(Mt,u)}const x=n.corridor;x&&ot(x,p,u);const C=n.polygon;C&&et(C,p,u);const T=n.polyline;T&&rt(T,p,u);const R=n.polylineVolume;R&&it(R,p,u);const I=n.wall;I&<(I,p,u)}function Z(n,o){const a=t.JulianDate.now(),e=n.dimensions?.getValue(a);e&&(n.dimensions=t.Cartesian3.multiplyComponents(e,o,e))}function K(n,o){const a=t.JulianDate.now(),e=n.length?.getValue(a);e!=null&&(n.length=e*o.z);const r=Math.max(o.x,o.y),i=n.topRadius?.getValue(a);i!=null&&(n.topRadius=i*r);const s=o.z,f=n.bottomRadius?.getValue(a);f!=null&&(n.bottomRadius=f*s)}function $(n,o){const a=t.JulianDate.now(),e=Math.max(o.x,o.y),r=o.z,i=n.semiMajorAxis?.getValue(a);i!=null&&(n.semiMajorAxis=i*e);const s=n.semiMinorAxis?.getValue(a);s!=null&&(n.semiMinorAxis=s*e);const f=n.height?.getValue(a);f!=null&&(n.height=f*r);const c=n.extrudedHeight?.getValue(a);c!=null&&(n.extrudedHeight=c*r)}function tt(n,o){const a=t.JulianDate.now(),e=n.radii?.getValue(a);e!=null&&(n.radii=t.Cartesian3.multiplyComponents(e,o,e));const r=n.innerRadii?.getValue(a);r!=null&&(n.innerRadii=t.Cartesian3.multiplyComponents(r,o,r))}function nt(n,o,a){let e=t.Cartesian3.maximumComponent(o);if(!a){const r=t.JulianDate.now(),i=n.scale?.getValue(r)??1;e*=i}n.scale=e}function at(n,o){const a=t.JulianDate.now(),e=t.Cartesian2.fromCartesian3(o),r=n.dimensions?.getValue(a);r&&(n.dimensions=t.Cartesian2.multiplyComponents(r,e,r))}function ot(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const u of i)t.Matrix4.multiplyByPoint(o,u,u);n.dimensions=i}const s=a??t.Matrix4.getScale(o,r),f=Math.max(s.x,s.y);n.width?.getValue(e)!=null&&(n.width=f*scale);const d=n.height?.getValue(e),y=s.z;d!=null&&(n.height=d*y)}function et(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.hierarchy?.getValue(e);i&&(b(i,o),n.hierarchy=i);const f=(a??t.Matrix4.getScale(o,r)).z,c=n.height?.getValue(e);c!=null&&(n.height=c*f);const d=n.extrudedHeight?.getValue(e);d!=null&&(n.extrudedHeight=d*f)}function b(n,o){const{positions:a,holes:e}=n;for(const r of a)t.Matrix4.multiplyByPoint(o,r,r);n.positions=a;for(const r of e)b(r,o)}function rt(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const d of i)t.Matrix4.multiplyByPoint(o,d,d);n.positions=i}const s=a??t.Matrix4.getScale(o,r),f=Math.max(s.x,s.y);n.width?.getValue(e)!=null&&(n.width=f*scale)}function it(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const d of i)t.Matrix4.multiplyByPoint(o,d,d);n.positions=i}const s=a??t.Matrix4.getScale(o,r),f=t.Cartesian2.fromCartesian3(s),c=n.shape?.getValue(e);if(c!=null){for(const d of c)t.Cartesian2.multiplyComponents(d,f,d);n.shape=c}}function lt(n,o,a){const e=t.JulianDate.now(),r=new t.Cartesian3,i=n.positions?.getValue(e);if(i?.length>0){for(const y of i)t.Matrix4.multiplyByPoint(o,y,y);n.positions=i}const f=(a??t.Matrix4.getScale(o,r)).z,c=n.minimumHeights?.getValue(e);c!=null&&(graphicsgraphics.minimumHeights=c.map(y=>y*f));const d=n.maximumHeights?.getValue(e);d!=null&&(graphicsgraphics.maximumHeights=d.map(y=>y*f))}function Ht(n,o,a){const e=t.JulianDate.now(),r=n.position?.getValue(e);if(!r)return null;const i=n.orientation?.getValue(e),s=n.model?.scale?.getValue(e)??1,f=new t.Cartesian3(s,s,s),c=o(r,a),d=t.Matrix4.inverse(c,new t.Matrix4),y=t.Matrix4.multiplyByPoint(d,r,new t.Cartesian3),u={translation:y,position:r,scale:f,rotation:new t.Cartesian3};let g;if(i){const C=t.Matrix3.fromQuaternion(i),T=t.Matrix4.fromRotation(C),R=t.Matrix4.multiply(d,T,T),I=B(R);g=l.Xyz_Hpr.toCartesian3(I),u.rotation=g}const p=new t.TranslationRotationScale(y??void 0,g?P(g):void 0,f??void 0);let x=t.Matrix4.fromTranslationRotationScale(p);return u.matrix=x,u}function zt(n){return n.values.length/n.componentsPerAttribute}function Nt(n){return t.ComponentDatatype.getSizeInBytes(n.componentDatatype)*n.componentsPerAttribute}function _t(n){const{componentDatatype:o,vertexBuffer:a}=n,e=N[o];if(!e)throw new Error("不支持的数据类型");const r=a.sizeInBytes,i=t.ComponentDatatype.getSizeInBytes(o),s=r/i;let f=new e(s);return a.getBufferData(f,0,0,r),f}new t.Cartesian2,new t.Cartesian3,new t.Cartesian4;const Q=[new t.Cartesian2,new t.Cartesian2,new t.Cartesian2,new t.Cartesian2],S=[new t.Cartesian3,new t.Cartesian3,new t.Cartesian3,new t.Cartesian3];new t.Cartesian4,new t.Cartesian4,new t.Cartesian4,new t.Cartesian4;const Ft=[new t.Cartographic,new t.Cartographic,new t.Cartographic,new t.Cartographic];new t.Rectangle,new t.Rectangle,new t.Rectangle,new t.Rectangle,new t.Matrix2,new t.Matrix2,new t.Matrix2,new t.Matrix2,new t.Matrix3,new t.Matrix3,new t.Matrix3,new t.Matrix3,new t.Matrix4,new t.Matrix4,new t.Matrix4,new t.Matrix4,new t.Quaternion,new t.Quaternion,new t.Quaternion,new t.Quaternion,new t.HeadingPitchRoll,new t.HeadingPitchRoll,new t.HeadingPitchRoll,new t.HeadingPitchRoll;function Lt(n,o=[]){const{stride:a,vertexArray:e}=n,r=e.length/a,i=S[0];for(let s=0;s<r;s++)n.encoding.decodePosition(e,s,i),t.Cartesian3.pack(i,o,o.length);return o}function Jt(n,o,a){return n.encoding.decodePosition(n.vertexArray,o,a)}function st(n){const{stride:o,vertices:a,indices:e,encoding:r}=n,i=a.length/o,s=S[0],f=new Float32Array(i*3),c=Q[0],d=new Float32Array(i*2),y=new Float32Array(i);for(let u=0;u<i;u++){r.decodePosition(a,u,s),t.Cartesian3.pack(s,f,u*3);const g=r.decodeHeight(a,u);y[u]=g,r.decodeTextureCoordinates(a,u,c),t.Cartesian2.pack(c,d,u*2)}return{attributes:{position:{array:f,vectorSize:3},uv:{array:d,vectorSize:2},height:{array:y,vectorSize:1}},indices:e.slice(),count:i}}function G(n,o){const a=n._surface._tilesToRender,e=[],r=new t.Rectangle;for(const i of a){const{rectangle:s}=i;t.Rectangle.intersection(o,s,r)&&e.push(i)}return e}function Wt(n){const o=n._surface._tilesToRender;return ft(o)}function ft(n){const o=new Set;for(const i of n)o.add(i.level);const a=[...o],e=Math.min.apply(Math,a),r=Math.max.apply(Math,a);return{min:e,max:r}}function H(n){return n.map(o=>{const{mesh:a,terrainData:e}=o.data,r=st(a),{x:i,y:s,level:f}=o,c=[e._minimumHeight,e._maximumHeight];return{data:r,encoding:a.encoding,rectangle:o.rectangle,heightRange:c,x:i,y:s,level:f}})}function Et(n){const{x:o,y:a,level:e}=n;return n.data.terrainData.upsample(n.tilingScheme,o,a,e,o,a,e)}function ct(n,o,a){const{east:e,north:r,south:i,west:s}=o,f=Ft[0];f.longitude=s,f.latitude=i;const c=n.positionToTileXY(f,a,Q[0]);f.longitude=e,f.latitude=r;const d=n.positionToTileXY(f,a,Q[1]),[y,u]=c.x<d.x?[c.x,d.x]:[d.x,c.x],[g,p]=c.y<d.y?[c.y,d.y]:[d.y,c.y];return{min:[y,g],max:[u,p]}}const kt=32767;function qt(n,o=new t.Cartesian3){return t.Matrix3.getScale(n.halfAxes,o),t.Cartesian3.multiplyByScalar(o,2*kt,o),o}function O(n,o,a){return a=n.getLocalCurvature(o,a),a.x=1/a.x,a.y=1/a.y,a}function Ut(n,o,a){a=O(n,o,a);const e=Math.PI/180;return t.Cartesian2.multiplyByScalar(a,e,a)}function dt(n){const{_quantizedVertices:o,_indices:a}=n,e=o.length/3,r={type:"Float32Array",start:0,vectorSize:1},i={type:"Float32Array",start:e,vectorSize:1},s={type:"Float32Array",start:e*2,vectorSize:1};return{array:new Float32Array(o),attributes:{u:r,v:i,height:s},count:e,indices:a}}async function jt(n,o,a,e){const r=await n.requestTileGeometry(o,a,e);if(!r)return null;const i=dt(r),s=[data._minimumHeight,data._maximumHeight],f=n.tilingScheme.tileXYToRectangle(o,a,e),c=M.getMatrixOfQuantizedMeshTerrainData(f,s),d=t.Matrix4.fromArray(c,void 0),y=["u","v","height"],u=new M.Geometry({...i,positionNames:y}),g=new t.Cartesian3;return u.mapForAggregate(y,(p,x)=>(t.Cartesian3.fromArray(p,0,g),t.Matrix4.multiplyByPoint(d,g,g),new t.Cartographic(g.x,g.y,g.z)))}async function Yt(n,o,a){const{min:e,max:r}=ct(n.tilingScheme,o,a),i=[],s=[];for(let c=e[0];c<=r[0];c++)for(let d=e[1];d<=r[1];d++){const y=yt(n,c,d,a);y&&(i.push(y),s.push({x:c,y:d}))}return(await Promise.all(i)).map(function(c,d){const{x:y,y:u}=s[d];return{x:y,y:u,level:a,data:c}})}async function yt(n,o,a,e){return n.getTileDataAvailable(o,a,e)?(await n.loadTileDataAvailability(o,a,e),n.requestTileGeometry(o,a,e)):Promise.reject("不可用")}async function Xt(n,o){const a=t.Rectangle.fromCartesianArray(o),e=t.Cartographic.toCartesian(t.Rectangle.center(a)),r=O(n.ellipsoid,e),i=[r.x,r.y,1],s=G(n,a),f=H(s),c=t.Transforms.eastNorthUpToFixedFrame(e);t.Matrix4.inverseTransformation(c,c);const d=o.map(g=>{const p=t.Matrix4.multiplyByPoint(c,g,S[2]);return[p.x,p.y]});let y=0;const u=f.map(async g=>{const{data:p,...x}=g,{position:C,uv:T,height:R}=p.attributes;y+=await M.workerApi.computeRelationAreaOfPolygon2Terrain({args:[{...p,...x,positionNames:["position"],region:d,matrix:t.Matrix4.pack(c,[]),relation:M.GeometricRelation.Contain|M.GeometricRelation.Intersect,scale:i}],transfer:[C.array.buffer,T.array.buffer,R.array.buffer,p.indices.buffer]})});if(await Promise.all(u),y===0||isNaN(y)){console.warn("贴地面积计算异常,已回退到椭球面投影面积",y);const g=o.map(p=>t.Cartesian3.pack(p,[]));return y=M.computeSignAreaOfPolygon3(g),Math.abs(y)}return y}function Zt(n,o){const a=t.Rectangle.fromCartesianArray(o),e=t.Cartographic.toCartesian(t.Rectangle.center(a)),r=O(n.ellipsoid,e),i=[r.x,r.y,1],s=G(n,a),f=H(s),c=t.Transforms.eastNorthUpToFixedFrame(e);t.Matrix4.inverseTransformation(c,c);const d=o.map(u=>{const g=t.Matrix4.multiplyByPoint(c,u,S[2]);return[g.x,g.y]});let y=0;for(const u of f){const{data:g,...p}=u;y+=M.computeRelationAreaOfPolygon2Terrain({...g,...p,positionNames:["position"],region:d,matrix:t.Matrix4.pack(c,[]),relation:M.GeometricRelation.Contain|M.GeometricRelation.Intersect,scale:i})}if(y===0||isNaN(y)){console.warn("贴地面积计算异常,已回退到椭球面投影面积",y);const u=o.map(g=>t.Cartesian3.pack(g,[]));return y=M.computeSignAreaOfPolygon3(u),Math.abs(y)}return y}l.CartesianAxis=_,l.HeadingPitchRollComponent=F,l.applyMatrixReferFrame=vt,l.applyTransformInPrimitive=j,l.applyTransformInfoPrimitive=bt,l.componentDatatypeTypedArrayMap=N,l.computeAttributeSizeInBytes=Nt,l.computeNormalOfCoplanars=E,l.computeTerrainAreaOfPolygon=Zt,l.computeTerrainAreaOfPolygon_worker=Xt,l.computeVertexNumOfAttribute=zt,l.createPlaneOfCoplanars=Rt,l.flatTransformInfoOptions=V,l.getAttributeData=_t,l.getBoundingSphere=Vt,l.getDecodePositionsOfTerrainMesh=Lt,l.getEntityInfo=Ht,l.getGeometryDataOfQuantizedMeshTerrainData=dt,l.getGeometryDataOfTerrainMesh=st,l.getLevelRangeOfQuadtreeTiles=ft,l.getLocalCurvatureRadius=O,l.getLocalSizePerDegrees=Ut,l.getLocalTransformInfo=J,l.getMatrix4OfTransformInfo=Ot,l.getNeighborPairs=Pt,l.getPosition=Bt,l.getPositionOfTerrainMesh=Jt,l.getRenderedQuadtreeTilesOfIntersectRectangle=G,l.getRenderedTileLevelRange=Wt,l.getScaleOfTerrainDataByOrientedBoundingBox=qt,l.getTerrainData=yt,l.getTerrainDataOfQuadtreeTile=Et,l.getTerrainDatasOfIntersectRectangle=Yt,l.getTerrainDatasOfQuadtreeTiles=H,l.getTileRangeOfIntersectRectangle=ct,l.getTransform=X,l.getWorldDataOfQuantizedMeshTerrainData=jt,l.getWorldMatrix=W,l.getWorldTransformInfo=D,l.isMatrixPrimitive=A,l.isPositionListPrimitive=z,l.isPositionPrimitive=m,l.isPrimitiveObject=wt,l.localQuaternionToWorld=L,l.localTRS_WorldMatrix4_Convert=U,l.localTRS_WorldMatrix4_ENU_Convert=It,l.makeMatrixReferFrame=v,l.mat4_compose=q,l.mat4_decompose=k,l.matrix4ToHeadingPitchRoll=B,l.quaternionToHeadingPitchRoll=ht,l.resetTransformInPrimitive=Y,l.resetTransformInfoPrimitive=Qt,l.rotateMatrixReferFrame=mt,l.rotationInfoToQuaternion=P,l.scaleBoxGraphics=Z,l.scaleCylinderGraphics=K,l.scaleEllipseGraphics=$,l.scaleEllipsoidGraphics=tt,l.scaleMatrixReferFrame=Dt,l.scaleModelGraphics=nt,l.scalePlaneGraphics=at,l.scalePoints=St,l.transformCorridorGraphics=ot,l.transformEntity=Gt,l.transformInfoToMatrix=Ct,l.transformPolygonGraphics=et,l.transformPolygonHierarchy=b,l.transformPolylineGraphics=rt,l.transformPolylineVolumeGraphics=it,l.transformWallGraphics=lt,l.translationMatrixReferFrame=At,l.worldMatrixToLocal=xt,l.worldQuaternionToLocal=Tt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|