@cearth/tools
Version:
CEarth 的 工具库
811 lines (810 loc) • 26.1 kB
JavaScript
import { WebGLConstants as M, Cartesian3 as u, HeadingPitchRoll as I, Quaternion as w, Matrix3 as g, Matrix4 as s, TranslationRotationScale as R, Plane as an, Transforms as E, BoundingSphere as C, JulianDate as h, Cartesian2 as x, ComponentDatatype as Z, Cartographic as D, Cartesian4 as O, Rectangle as v, Matrix2 as N } from "cesium";
import { MatrixComposeOrder as F, mat4_decompose_quat as cn, mat4_compose_quat as ln, getMatrixOfQuantizedMeshTerrainData as un, Geometry as fn, workerApi as mn, GeometricRelation as z, computeSignAreaOfPolygon3 as K, computeRelationAreaOfPolygon2Terrain as pn } from "@web-3d/tools";
function Yn(n) {
return q(n) || J(n) || dn(n);
}
function q(n) {
return "modelMatrix" in n;
}
function J(n) {
return "position" in n;
}
function dn(n) {
return "positions" in n;
}
const yn = {
/**
* 8-bit signed byte corresponding to <code>gl.BYTE</code> and the type
* of an element in <code>Int8Array</code>.
*/
[M.BYTE]: Int8Array,
/**
* 8-bit unsigned byte corresponding to <code>UNSIGNED_BYTE</code> and the type
* of an element in <code>Uint8Array</code>.
*/
[M.UNSIGNED_BYTE]: Uint8Array,
/**
* 16-bit signed short corresponding to <code>SHORT</code> and the type
* of an element in <code>Int16Array</code>.
*/
[M.SHORT]: Int16Array,
/**
* 16-bit unsigned short corresponding to <code>UNSIGNED_SHORT</code> and the type
* of an element in <code>Uint16Array</code>.
*/
[M.UNSIGNED_SHORT]: Uint16Array,
/**
* 32-bit signed int corresponding to <code>INT</code> and the type
* of an element in <code>Int32Array</code>.
*/
[M.INT]: Int32Array,
/**
* 32-bit unsigned int corresponding to <code>UNSIGNED_INT</code> and the type
* of an element in <code>Uint32Array</code>.
*/
[M.UNSIGNED_INT]: Uint32Array,
/**
* 32-bit floating-point corresponding to <code>FLOAT</code> and the type
* of an element in <code>Float32Array</code>.
*/
[M.FLOAT]: Float32Array,
/**
* 64-bit floating-point corresponding to <code>gl.DOUBLE</code> (in Desktop OpenGL;
* this is not supported in WebGL, and is emulated in Cesium via {@link GeometryPipeline.encodeAttribute})
* and the type of an element in <code>Float64Array</code>.
*/
[M.DOUBLE]: Float64Array
};
var wn = /* @__PURE__ */ ((n) => (n[n.x = 0] = "x", n[n.y = 1] = "y", n[n.z = 2] = "z", n))(wn || {}), b = /* @__PURE__ */ ((n) => (n.x = "roll", n.y = "pitch", n.z = "heading", n))(b || {});
((n) => {
function o(i) {
for (let [r, a] of Object.entries(n))
if (i === a)
return r;
}
n.toKey = o;
function t(i) {
return new u(i.roll, -i.pitch, -i.heading);
}
n.toCartesian3 = t;
function e(i) {
return new I(-i[o("heading")], -i[o("pitch")], i[o("roll")]);
}
n.toHeadingPitchRoll = e;
})(b || (b = {}));
var gn = /* @__PURE__ */ ((n) => (n[n.heading = 0] = "heading", n[n.pitch = 1] = "pitch", n[n.roll = 2] = "roll", n))(gn || {});
function $(n) {
const o = n?.world, { translation: t, rotation: e, scale: i } = o && typeof o == "object" ? o : { translation: o, rotation: o, scale: o };
return { ...n, worldTranslation: t, worldRotation: e, worldScale: i };
}
function G(n) {
if (n.axis) {
const { axis: t, angle: e } = n;
return w.fromAxisAngle(t, e);
}
const o = b.toHeadingPitchRoll(n);
return w.fromHeadingPitchRoll(o);
}
function jn(n, o, t) {
const e = g.fromQuaternion(n), i = s.fromRotation(e), r = s.inverseTransformation(o, new s()), a = s.multiply(r, i, i);
return nn(a);
}
function nn(n, o) {
const t = s.getMatrix3(n, new g()), e = w.fromRotationMatrix(t);
return I.fromQuaternion(e, o);
}
function Wn(n, o, t) {
t = t ?? new s();
const e = s.inverse(o, new s());
return s.multiply(e, n, t);
}
function hn(n, o, t) {
let e = w.computeAxis(n, new u());
if (e.equals(u.ZERO)) return null;
const i = w.computeAngle(n);
return e = s.multiplyByPointAsVector(o, e, e), w.fromAxisAngle(e, i);
}
function Xn(n, o, t) {
let e = w.computeAxis(n, new u());
if (e.equals(u.ZERO)) return null;
const i = w.computeAngle(n), r = s.inverse(o, new s());
return e = s.multiplyByPointAsVector(r, e, e), w.fromAxisAngle(e, i);
}
function L(n, o) {
let { translation: t, rotation: e, scale: i } = n;
const { referFrame: r, worldTranslation: a, worldRotation: c, worldScale: f } = $(o);
let l = null;
return t && (a || (t = s.multiplyByPointAsVector(r, t, new u()))), e && (l = G(e), c || (l = hn(l, r))), i && (f || (i = s.multiplyByPointAsVector(r, i, new u()))), { translation: t, rotation: l, scale: i };
}
function xn(n, o) {
let { translation: t, rotation: e, scale: i } = n;
const { referFrame: r, worldTranslation: a, worldRotation: c, worldScale: f } = $(o), l = r ? s.inverse(r, new s()) : null;
let m = null;
if (t && a && (t = s.multiplyByPointAsVector(l, t, new u())), e && (m = G(e), c)) {
let p = w.computeAxis(m, new u());
if (!p.equals(u.ZERO)) {
const d = w.computeAngle(m);
p = s.multiplyByPointAsVector(l, p, p), m = w.fromAxisAngle(p, d);
}
}
return i && f && (i = s.multiplyByPointAsVector(l, i, new u())), { translation: t, rotation: m, scale: i };
}
function Tn(n, o) {
const t = o?.defaultMatrix;
let { translation: e, rotation: i, scale: r } = L(n, o);
if (t) {
if (e || (e = s.getTranslation(t, new u())), !i) {
const c = s.getMatrix3(t, new g());
i = w.fromRotationMatrix(c);
}
r || (r = s.getScale(t, new u()));
}
const a = new R(e ?? void 0, i ?? void 0, r ?? void 0);
return s.fromTranslationRotationScale(a);
}
function Zn(n) {
const { translation: o, rotation: t, scale: e } = n, i = t ? G(t) : void 0, r = new R(o ?? void 0, i, e ?? void 0);
return s.fromTranslationRotationScale(r);
}
function vn(n, o, t) {
const e = u.subtract(o, n, new u()), i = u.subtract(t, n, new u()), r = u.cross(e, i, e);
return u.normalize(r, e);
}
function Kn(n, o, t) {
const e = vn(n, o, t);
return an.fromPointNormal(e, n);
}
function* $n(n, o = !0, t, e) {
const i = n.length, r = o ? i : i - 1, a = t || e ? u.prototype.equalsEpsilon : u.prototype.equals;
for (let c = 0; c < r; c++) {
const f = n[c];
let l = (c + 1) % i, m = n[l], p = c;
for (; a.call(f, m, t, e); ) {
if (l = (++p + 1) % i, l === c)
return;
m = n[l];
}
c = p, yield [f, m];
}
}
function H(n, o, t) {
t = t ?? new s();
const e = s.inverse(o, new s()), i = s.multiply(n, e, e);
return s.multiply(o, i, t);
}
function nt(n, o, t, e) {
e = e ?? new s();
const i = s.inverse(t, new s());
let r = s.multiply(i, n, i);
return r = s.multiply(o, r, r), s.multiply(t, r, e);
}
function tt(n, o, t) {
const e = s.fromTranslation(n);
return H(e, o, t);
}
function ot(n, o, t, e) {
const i = w.fromAxisAngle(n, o), r = g.fromQuaternion(i), a = s.fromRotation(r);
return H(a, t, e);
}
function et(n, o, t) {
const e = s.fromScale(n);
return H(e, o, t);
}
function it(n, o, t) {
const e = g.fromScale(o);
if (t)
for (const i of n)
u.subtract(i, t, i), g.multiplyByVector(e, i, i), u.add(i, t, i);
else {
const i = g.fromScale(o);
for (const r of n)
g.multiplyByVector(i, r, r);
}
return n;
}
function rt(n, o) {
const { translation: t, rotation: e, scale: i } = n;
let r;
if (e) {
const { axis: c, angle: f } = e;
r = w.fromAxisAngle(c, f);
}
const a = new R(t ?? void 0, r, i ?? void 0);
return s.fromTranslationRotationScale(a, o ?? void 0);
}
function tn(n, o, t) {
t ??= new R();
const e = s.pack(n, []), i = [], r = [], a = [], c = o ? F[o] : F.trs;
return cn(i, a, r, e, c), u.unpack(i, 0, t.translation), u.unpack(r, 0, t.scale), w.unpack(a, 0, t.rotation), t;
}
function st(n, o) {
return tn(n, null, o);
}
function An(n, o, t) {
const e = u.pack(n.translation, []), i = u.pack(n.scale, []), r = w.pack(n.rotation, []), a = o ? F[o] : F.trs, c = ln([], e, r, i, a);
return s.unpack(c, 0, t);
}
const at = s.fromTranslationRotationScale;
function Mn(n, o) {
const t = s.inverse(n, new s()), e = new s();
function i(a, c) {
return c = An(a, o, c), s.multiply(n, c, c);
}
function r(a, c) {
return s.multiply(t, a, e), tn(e, o, c);
}
return { compose: i, decompose: r, referInverse: t };
}
function on(n, o, t) {
const e = E.eastNorthUpToFixedFrame(n, t ?? void 0);
return { ...Mn(e, o), refer: e };
}
function ct(n) {
let o = n.boundingSphere;
if (o)
return o;
let t = n.geometryInstances;
if (t) {
t = Array.isArray(t) ? t : [t];
const i = t.map((r) => r.geometry.boundingSphere);
return C.fromBoundingSpheres(i);
}
const e = n.positions;
return e?.length > 0 ? C.fromPoints(e) : null;
}
function lt(n, o) {
o = o ?? new u();
const t = n.position;
if (t)
return t instanceof u ? t : t.getValue(h.now(), o);
const e = n.modelMatrix;
if (e)
return s.getTranslation(e, o);
const i = n.positions;
return i?.length > 0 ? C.fromPoints(i).center : null;
}
function ut(n, o, t) {
let { translation: e, rotation: i, scale: r } = L(o, t);
const a = new R(e ?? void 0, i ?? void 0, r ?? void 0), c = s.fromTranslationRotationScale(a);
return Rn(n, c);
}
function Rn(n, o) {
const t = n.modelMatrix;
if (t)
return s.multiply(o, t, t), n.modelMatrix = t, !0;
const e = n.position;
if (e) {
if ("scale" in n) {
const r = s.getTranslation(o, new u());
u.add(e, r, e);
const a = n.scale ?? 1, c = s.getScale(o, new u());
n.scale = u.maximumComponent(c) * a;
} else
s.multiplyByPoint(o, e, e);
return n.position = e, !0;
}
const i = n.positions;
if (i?.length > 0) {
for (const r of i)
s.multiplyByPoint(o, r, r);
return n.positions = i, !0;
}
return !1;
}
function ft(n, o, t) {
const e = Sn(n), i = Tn(o, { ...t, defaultMatrix: e });
return Pn(n, i);
}
function Pn(n, o) {
if (q(n))
return n.modelMatrix = o, !0;
const t = s.getTranslation(o, new u());
if (J(n)) {
if (n.position = t, "scale" in n) {
const i = s.getScale(o, new u());
n.scale = u.maximumComponent(i);
}
return !0;
}
const e = n.positions;
if (e?.length > 0) {
const i = C.fromPoints(e);
u.subtract(t, i.center, t);
for (const r of e)
u.add(r, t, r);
return n.positions = e, !0;
}
return !1;
}
function Sn(n) {
if (q(n))
return n.modelMatrix;
if (J(n)) {
const t = n.position, e = n.scale ?? 1, i = new R(t, void 0, new u(e, e, e));
return s.fromTranslationRotationScale(i);
}
const o = n.positions;
if (o?.length > 0) {
const t = C.fromPoints(o);
return s.fromTranslation(t.center);
}
return null;
}
function mt(n, o) {
let { translation: t, rotation: e, scale: i } = L(o, o);
const { reset: r, referFrame: a } = o, c = h.now(), f = !r;
if (e) {
let A = e;
if (f) {
const T = n.orientation?.getValue(c);
T && (A = w.multiply(e, T, T));
}
n.orientation = A;
}
if (t) {
let A = t;
if (f) {
const T = n.position?.getValue(c);
T && (A = u.add(T, t, T));
}
n.position = A;
}
if (!a) return;
const { translation: l, rotation: m, scale: p } = xn(o, o), d = new R(l ?? void 0, m ?? void 0, p ?? void 0);
let y = s.fromTranslationRotationScale(d);
if (y = H(y, a, y), p) {
const A = n.box;
A && Dn(A, p);
const T = n.cylinder;
T && Vn(T, p);
const Y = n.ellipse;
Y && Bn(Y, p);
const j = n.ellipsoid;
j && In(j, p);
const W = n.model;
W && On(W, p, r);
const X = n.plane;
X && Cn(X, p);
}
const P = n.corridor;
P && bn(P, y, p);
const V = n.polygon;
V && _n(V, y, p);
const S = n.polyline;
S && Nn(S, y, p);
const B = n.polylineVolume;
B && Fn(B, y, p);
const _ = n.wall;
_ && zn(_, y, p);
}
function Dn(n, o) {
const t = h.now(), e = n.dimensions?.getValue(t);
e && (n.dimensions = u.multiplyComponents(e, o, e));
}
function Vn(n, o) {
const t = h.now(), e = n.length?.getValue(t);
e != null && (n.length = e * o.z);
const i = Math.max(o.x, o.y), r = n.topRadius?.getValue(t);
r != null && (n.topRadius = r * i);
const a = o.z, c = n.bottomRadius?.getValue(t);
c != null && (n.bottomRadius = c * a);
}
function Bn(n, o) {
const t = h.now(), e = Math.max(o.x, o.y), i = o.z, r = n.semiMajorAxis?.getValue(t);
r != null && (n.semiMajorAxis = r * e);
const a = n.semiMinorAxis?.getValue(t);
a != null && (n.semiMinorAxis = a * e);
const c = n.height?.getValue(t);
c != null && (n.height = c * i);
const f = n.extrudedHeight?.getValue(t);
f != null && (n.extrudedHeight = f * i);
}
function In(n, o) {
const t = h.now(), e = n.radii?.getValue(t);
e != null && (n.radii = u.multiplyComponents(e, o, e));
const i = n.innerRadii?.getValue(t);
i != null && (n.innerRadii = u.multiplyComponents(i, o, i));
}
function On(n, o, t) {
let e = u.maximumComponent(o);
if (!t) {
const i = h.now(), r = n.scale?.getValue(i) ?? 1;
e *= r;
}
n.scale = e;
}
function Cn(n, o) {
const t = h.now(), e = x.fromCartesian3(o), i = n.dimensions?.getValue(t);
i && (n.dimensions = x.multiplyComponents(i, e, i));
}
function bn(n, o, t) {
const e = h.now(), i = new u(), r = n.positions?.getValue(e);
if (r?.length > 0) {
for (const p of r)
s.multiplyByPoint(o, p, p);
n.dimensions = r;
}
const a = t ?? s.getScale(o, i), c = Math.max(a.x, a.y);
n.width?.getValue(e) != null && (n.width = c * scale);
const l = n.height?.getValue(e), m = a.z;
l != null && (n.height = l * m);
}
function _n(n, o, t) {
const e = h.now(), i = new u(), r = n.hierarchy?.getValue(e);
r && (en(r, o), n.hierarchy = r);
const c = (t ?? s.getScale(o, i)).z, f = n.height?.getValue(e);
f != null && (n.height = f * c);
const l = n.extrudedHeight?.getValue(e);
l != null && (n.extrudedHeight = l * c);
}
function en(n, o) {
const { positions: t, holes: e } = n;
for (const i of t)
s.multiplyByPoint(o, i, i);
n.positions = t;
for (const i of e)
en(i, o);
}
function Nn(n, o, t) {
const e = h.now(), i = new u(), r = n.positions?.getValue(e);
if (r?.length > 0) {
for (const l of r)
s.multiplyByPoint(o, l, l);
n.positions = r;
}
const a = t ?? s.getScale(o, i), c = Math.max(a.x, a.y);
n.width?.getValue(e) != null && (n.width = c * scale);
}
function Fn(n, o, t) {
const e = h.now(), i = new u(), r = n.positions?.getValue(e);
if (r?.length > 0) {
for (const l of r)
s.multiplyByPoint(o, l, l);
n.positions = r;
}
const a = t ?? s.getScale(o, i), c = x.fromCartesian3(a), f = n.shape?.getValue(e);
if (f != null) {
for (const l of f)
x.multiplyComponents(l, c, l);
n.shape = f;
}
}
function zn(n, o, t) {
const e = h.now(), i = new u(), r = n.positions?.getValue(e);
if (r?.length > 0) {
for (const m of r)
s.multiplyByPoint(o, m, m);
n.positions = r;
}
const c = (t ?? s.getScale(o, i)).z, f = n.minimumHeights?.getValue(e);
f != null && (graphicsgraphics.minimumHeights = f.map((m) => m * c));
const l = n.maximumHeights?.getValue(e);
l != null && (graphicsgraphics.maximumHeights = l.map((m) => m * c));
}
function pt(n, o, t) {
const e = h.now(), i = n.position?.getValue(e);
if (!i) return null;
const r = n.orientation?.getValue(e), a = n.model?.scale?.getValue(e) ?? 1, c = new u(a, a, a), f = o(i, t), l = s.inverse(f, new s()), m = s.multiplyByPoint(l, i, new u()), p = { translation: m, position: i, scale: c, rotation: new u() };
let d;
if (r) {
const V = g.fromQuaternion(r), S = s.fromRotation(V), B = s.multiply(l, S, S), _ = nn(B);
d = b.toCartesian3(_), p.rotation = d;
}
const y = new R(m ?? void 0, d ? G(d) : void 0, c ?? void 0);
let P = s.fromTranslationRotationScale(y);
return p.matrix = P, p;
}
function dt(n) {
return n.values.length / n.componentsPerAttribute;
}
function yt(n) {
return Z.getSizeInBytes(n.componentDatatype) * n.componentsPerAttribute;
}
function wt(n) {
const { componentDatatype: o, vertexBuffer: t } = n, e = yn[o];
if (!e) throw new Error("不支持的数据类型");
const i = t.sizeInBytes, r = Z.getSizeInBytes(o), a = i / r;
let c = new e(a);
return t.getBufferData(c, 0, 0, i), c;
}
new x(), new u(), new O();
const Q = [new x(), new x(), new x(), new x()], k = [new u(), new u(), new u(), new u()];
new O(), new O(), new O(), new O();
const Gn = [new D(), new D(), new D(), new D()];
new v(), new v(), new v(), new v();
new N(), new N(), new N(), new N();
new g(), new g(), new g(), new g();
new s(), new s(), new s(), new s();
new w(), new w(), new w(), new w();
new I(), new I(), new I(), new I();
function gt(n, o = []) {
const { stride: t, vertexArray: e } = n, i = e.length / t, r = k[0];
for (let a = 0; a < i; a++)
n.encoding.decodePosition(e, a, r), u.pack(r, o, o.length);
return o;
}
function ht(n, o, t) {
return n.encoding.decodePosition(n.vertexArray, o, t);
}
function Hn(n) {
const { stride: o, vertices: t, indices: e, encoding: i } = n, r = t.length / o, a = k[0], c = new Float32Array(r * 3), f = Q[0], l = new Float32Array(r * 2), m = new Float32Array(r);
for (let p = 0; p < r; p++) {
i.decodePosition(t, p, a), u.pack(a, c, p * 3);
const d = i.decodeHeight(t, p);
m[p] = d, i.decodeTextureCoordinates(t, p, f), x.pack(f, l, p * 2);
}
return {
attributes: {
position: { array: c, vectorSize: 3 },
uv: { array: l, vectorSize: 2 },
height: { array: m, vectorSize: 1 }
},
indices: e.slice(),
count: r
};
}
function rn(n, o) {
const t = n._surface._tilesToRender, e = [], i = new v();
for (const r of t) {
const { rectangle: a } = r;
v.intersection(o, a, i) && e.push(r);
}
return e;
}
function xt(n) {
const o = n._surface._tilesToRender;
return kn(o);
}
function kn(n) {
const o = /* @__PURE__ */ new Set();
for (const r of n)
o.add(r.level);
const t = [...o], e = Math.min.apply(Math, t), i = Math.max.apply(Math, t);
return { min: e, max: i };
}
function sn(n) {
return n.map((o) => {
const { mesh: t, terrainData: e } = o.data, i = Hn(t), { x: r, y: a, level: c } = o, f = [e._minimumHeight, e._maximumHeight];
return { data: i, encoding: t.encoding, rectangle: o.rectangle, heightRange: f, x: r, y: a, level: c };
});
}
function Tt(n) {
const { x: o, y: t, level: e } = n;
return n.data.terrainData.upsample(n.tilingScheme, o, t, e, o, t, e);
}
function Qn(n, o, t) {
const { east: e, north: i, south: r, west: a } = o, c = Gn[0];
c.longitude = a, c.latitude = r;
const f = n.positionToTileXY(c, t, Q[0]);
c.longitude = e, c.latitude = i;
const l = n.positionToTileXY(c, t, Q[1]), [m, p] = f.x < l.x ? [f.x, l.x] : [l.x, f.x], [d, y] = f.y < l.y ? [f.y, l.y] : [l.y, f.y];
return { min: [m, d], max: [p, y] };
}
const En = 32767;
function vt(n, o = new u()) {
return g.getScale(n.halfAxes, o), u.multiplyByScalar(o, 2 * En, o), o;
}
function U(n, o, t) {
return t = n.getLocalCurvature(o, t), t.x = 1 / t.x, t.y = 1 / t.y, t;
}
function At(n, o, t) {
t = U(n, o, t);
const e = Math.PI / 180;
return x.multiplyByScalar(t, e, t);
}
function qn(n) {
const { _quantizedVertices: o, _indices: t } = n, e = o.length / 3, i = {
type: "Float32Array",
start: 0,
vectorSize: 1
}, r = {
type: "Float32Array",
start: e,
vectorSize: 1
}, a = {
type: "Float32Array",
start: e * 2,
vectorSize: 1
};
return {
array: new Float32Array(o),
attributes: { u: i, v: r, height: a },
count: e,
indices: t
};
}
async function Mt(n, o, t, e) {
const i = await n.requestTileGeometry(o, t, e);
if (!i) return null;
const r = qn(i), a = [data._minimumHeight, data._maximumHeight], c = n.tilingScheme.tileXYToRectangle(o, t, e), f = un(c, a), l = s.fromArray(f, void 0), m = ["u", "v", "height"], p = new fn({ ...r, positionNames: m }), d = new u();
return p.mapForAggregate(m, (y, P) => (u.fromArray(y, 0, d), s.multiplyByPoint(l, d, d), new D(d.x, d.y, d.z)));
}
async function Rt(n, o, t) {
const { min: e, max: i } = Qn(n.tilingScheme, o, t), r = [], a = [];
for (let f = e[0]; f <= i[0]; f++)
for (let l = e[1]; l <= i[1]; l++) {
const m = Jn(n, f, l, t);
m && (r.push(m), a.push({ x: f, y: l }));
}
return (await Promise.all(r)).map(function(f, l) {
const { x: m, y: p } = a[l];
return { x: m, y: p, level: t, data: f };
});
}
async function Jn(n, o, t, e) {
return n.getTileDataAvailable(o, t, e) ? (await n.loadTileDataAvailability(o, t, e), n.requestTileGeometry(o, t, e)) : Promise.reject("不可用");
}
async function Pt(n, o) {
const t = v.fromCartesianArray(o), e = D.toCartesian(v.center(t)), i = U(n.ellipsoid, e), r = [i.x, i.y, 1], a = rn(n, t), c = sn(a), f = E.eastNorthUpToFixedFrame(e);
s.inverseTransformation(f, f);
const l = o.map((d) => {
const y = s.multiplyByPoint(f, d, k[2]);
return [y.x, y.y];
});
let m = 0;
const p = c.map(async (d) => {
const { data: y, ...P } = d, { position: V, uv: S, height: B } = y.attributes;
m += await mn.computeRelationAreaOfPolygon2Terrain({
args: [{
...y,
...P,
positionNames: ["position"],
region: l,
// @ts-ignore
matrix: s.pack(f, []),
relation: z.Contain | z.Intersect,
scale: r
}],
transfer: [V.array.buffer, S.array.buffer, B.array.buffer, y.indices.buffer]
});
});
if (await Promise.all(p), m === 0 || isNaN(m)) {
console.warn("贴地面积计算异常,已回退到椭球面投影面积", m);
const d = o.map((y) => u.pack(y, []));
return m = K(d), Math.abs(m);
}
return m;
}
function St(n, o) {
const t = v.fromCartesianArray(o), e = D.toCartesian(v.center(t)), i = U(n.ellipsoid, e), r = [i.x, i.y, 1], a = rn(n, t), c = sn(a), f = E.eastNorthUpToFixedFrame(e);
s.inverseTransformation(f, f);
const l = o.map((p) => {
const d = s.multiplyByPoint(f, p, k[2]);
return [d.x, d.y];
});
let m = 0;
for (const p of c) {
const { data: d, ...y } = p;
m += pn({
...d,
...y,
positionNames: ["position"],
region: l,
// @ts-ignore
matrix: s.pack(f, []),
relation: z.Contain | z.Intersect,
scale: r
});
}
if (m === 0 || isNaN(m)) {
console.warn("贴地面积计算异常,已回退到椭球面投影面积", m);
const p = o.map((d) => u.pack(d, []));
return m = K(p), Math.abs(m);
}
return m;
}
function Dt(n, o, t) {
const e = n.transform.clone(), i = s.inverse(e, new s()), r = new s(), { compose: a, decompose: c, ...f } = on(n.boundingSphere.center, o, t);
function l(p, d) {
return d = a(p, d), s.multiply(d, i, d);
}
function m(p, d) {
return s.multiply(p, e, r), c(r, d);
}
return { ...f, right: i, compose: l, decompose: m };
}
function Vt(n, o, t) {
const e = s.inverse(n.root.transform, new s()), { compose: i, decompose: r, ...a } = on(n.boundingSphere.center, o, t);
function c(l, m) {
return m = i(l, m), s.multiply(m, e, m);
}
function f(l) {
return r(n.root.computedTransform, l);
}
return { ...a, right: e, compose: c, decompose: f };
}
function Bt(n) {
const o = [n.root];
let t = 0;
do {
const e = o[t];
e.children.length && o.push(...e.children);
} while (++t < o.length);
return o;
}
function It(n) {
return n.content?._model;
}
export {
wn as CartesianAxis,
gn as HeadingPitchRollComponent,
b as Xyz_Hpr,
nt as applyMatrixReferFrame,
Rn as applyTransformInPrimitive,
ut as applyTransformInfoPrimitive,
yn as componentDatatypeTypedArrayMap,
yt as computeAttributeSizeInBytes,
vn as computeNormalOfCoplanars,
St as computeTerrainAreaOfPolygon,
Pt as computeTerrainAreaOfPolygon_worker,
dt as computeVertexNumOfAttribute,
Kn as createPlaneOfCoplanars,
$ as flatTransformInfoOptions,
Bt as getAllTilesOf3DTileset,
wt as getAttributeData,
ct as getBoundingSphere,
gt as getDecodePositionsOfTerrainMesh,
pt as getEntityInfo,
qn as getGeometryDataOfQuantizedMeshTerrainData,
Hn as getGeometryDataOfTerrainMesh,
kn as getLevelRangeOfQuadtreeTiles,
U as getLocalCurvatureRadius,
At as getLocalSizePerDegrees,
xn as getLocalTransformInfo,
rt as getMatrix4OfTransformInfo,
It as getModelOf3DTile,
$n as getNeighborPairs,
lt as getPosition,
ht as getPositionOfTerrainMesh,
rn as getRenderedQuadtreeTilesOfIntersectRectangle,
xt as getRenderedTileLevelRange,
vt as getScaleOfTerrainDataByOrientedBoundingBox,
Jn as getTerrainData,
Tt as getTerrainDataOfQuadtreeTile,
Rt as getTerrainDatasOfIntersectRectangle,
sn as getTerrainDatasOfQuadtreeTiles,
Qn as getTileRangeOfIntersectRectangle,
Sn as getTransform,
Mt as getWorldDataOfQuantizedMeshTerrainData,
Tn as getWorldMatrix,
L as getWorldTransformInfo,
q as isMatrixPrimitive,
dn as isPositionListPrimitive,
J as isPositionPrimitive,
Yn as isPrimitiveObject,
hn as localQuaternionToWorld,
Mn as localTRS_WorldMatrix4_Convert,
on as localTRS_WorldMatrix4_ENU_Convert,
H as makeMatrixReferFrame,
at as mat4_compose,
An as mat4_composeByOrder,
st as mat4_decompose,
tn as mat4_decomposeByOrder,
nn as matrix4ToHeadingPitchRoll,
jn as quaternionToHeadingPitchRoll,
Pn as resetTransformInPrimitive,
ft as resetTransformInfoPrimitive,
ot as rotateMatrixReferFrame,
G as rotationInfoToQuaternion,
Dn as scaleBoxGraphics,
Vn as scaleCylinderGraphics,
Bn as scaleEllipseGraphics,
In as scaleEllipsoidGraphics,
et as scaleMatrixReferFrame,
On as scaleModelGraphics,
Cn as scalePlaneGraphics,
it as scalePoints,
Dt as tile_enuTRS_modelMatrix_Convert,
Vt as tileset_enuTRS_modelMatrix_Convert,
bn as transformCorridorGraphics,
mt as transformEntity,
Zn as transformInfoToMatrix,
_n as transformPolygonGraphics,
en as transformPolygonHierarchy,
Nn as transformPolylineGraphics,
Fn as transformPolylineVolumeGraphics,
zn as transformWallGraphics,
tt as translationMatrixReferFrame,
Wn as worldMatrixToLocal,
Xn as worldQuaternionToLocal
};