123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- import {
- a,
- c as c3,
- d,
- e as e4,
- f as f3,
- i as i2,
- n as n2,
- n2 as n3,
- n3 as n4,
- n4 as n5,
- o as o3,
- o2 as o4,
- o3 as o5,
- r as r6,
- r2 as r7,
- t as t4
- } from "./chunk-NBRP7CWO.js";
- import "./chunk-GXVMJ7RN.js";
- import "./chunk-6BRTRIDE.js";
- import {
- f as f2,
- p
- } from "./chunk-T47XOAZJ.js";
- import {
- c as c2,
- m
- } from "./chunk-7NPG47AN.js";
- import "./chunk-2QVXRTVA.js";
- import {
- D,
- E as E2
- } from "./chunk-MI7HWWFL.js";
- import {
- k3 as k
- } from "./chunk-2ADIR7NB.js";
- import {
- e2 as e3,
- f,
- n,
- o as o2,
- r as r5,
- t as t2,
- t2 as t3
- } from "./chunk-4KFEVYXL.js";
- import "./chunk-5W6F4NR5.js";
- import "./chunk-YZUP3MAF.js";
- import "./chunk-E3HOL2XO.js";
- import {
- e as e2
- } from "./chunk-SCXOTZ6Q.js";
- import {
- E,
- L,
- O,
- T,
- c,
- i,
- u,
- x
- } from "./chunk-H4JLO5B2.js";
- import "./chunk-G5AI6ZNE.js";
- import "./chunk-5JK4DCPE.js";
- import {
- j
- } from "./chunk-CRGVDJI6.js";
- import "./chunk-DH2OBAUC.js";
- import "./chunk-TNLRDNTC.js";
- import "./chunk-6P6NA7JB.js";
- import "./chunk-LPQPD3EP.js";
- import "./chunk-WR32EHFC.js";
- import {
- r as r4
- } from "./chunk-NTUXR253.js";
- import "./chunk-H2KDMZTR.js";
- import {
- l
- } from "./chunk-7XXXCK2A.js";
- import "./chunk-65BYCSII.js";
- import "./chunk-TERAW6FT.js";
- import "./chunk-N2663GRX.js";
- import "./chunk-O4FY3ITT.js";
- import "./chunk-JXW4QTJA.js";
- import {
- w
- } from "./chunk-XNLG7T2T.js";
- import {
- r as r3
- } from "./chunk-IR4PV7VK.js";
- import "./chunk-OWVBLVP3.js";
- import "./chunk-WJ3OEUD3.js";
- import "./chunk-MXB2XLKV.js";
- import "./chunk-HNOZUNJ4.js";
- import {
- U
- } from "./chunk-VNFRAYHO.js";
- import "./chunk-R5IG2D6H.js";
- import "./chunk-VBRY5KJM.js";
- import "./chunk-PDKDCAAD.js";
- import "./chunk-ECW2QABR.js";
- import "./chunk-GCDJLKH4.js";
- import "./chunk-MRJEICT6.js";
- import "./chunk-Y3WMVFTW.js";
- import "./chunk-SAS7RONY.js";
- import "./chunk-WSRBH7BF.js";
- import {
- r as r2
- } from "./chunk-IHXECKQQ.js";
- import "./chunk-ULGDPLM2.js";
- import "./chunk-EMJ4ZSM2.js";
- import "./chunk-IKP3YN53.js";
- import {
- e,
- o,
- r,
- t
- } from "./chunk-GZT4BVFP.js";
- import "./chunk-A5ICIBVI.js";
- // node_modules/@arcgis/core/geometry/support/meshUtils/loadGLTFMesh.js
- async function W(t5, e5, r8) {
- const o6 = new n4(X(r8)), n6 = (await c3(o6, e5, r8, true)).model, s = n6.lods.shift(), a2 = new Map(), c4 = new Map();
- n6.textures.forEach((t6, e6) => a2.set(e6, et(t6))), n6.materials.forEach((t6, e6) => c4.set(e6, rt(t6, a2)));
- const l2 = tt(s);
- for (const i3 of l2.parts)
- ot(l2, i3, c4);
- const { position: u2, normal: f4, tangent: m2, color: p2, texCoord0: d2 } = l2.vertexAttributes, h = { position: u2.typedBuffer, normal: r(f4) ? f4.typedBuffer : null, tangent: r(m2) ? m2.typedBuffer : null, uv: r(d2) ? d2.typedBuffer : null, color: r(p2) ? p2.typedBuffer : null }, x2 = k(h, t5, r8);
- return { transform: x2.transform, components: l2.components, spatialReference: t5.spatialReference, vertexAttributes: new p({ position: x2.vertexAttributes.position, normal: x2.vertexAttributes.normal, tangent: x2.vertexAttributes.tangent, color: h.color, uv: h.uv }) };
- }
- function X(t5) {
- return t5?.resolveFile ? { busy: false, request: async (r8, o6, n6) => {
- const s = t5.resolveFile(r8), a2 = o6 === "image" ? "image" : o6 === "binary" ? "array-buffer" : "json";
- return (await U(s, { responseType: a2, signal: r(n6) ? n6.signal : null })).data;
- } } : null;
- }
- function Y(t5, e5) {
- if (t(t5))
- return "-";
- const o6 = t5.typedBuffer;
- return `${r2(e5, o6.buffer, () => e5.size)}/${o6.byteOffset}/${o6.byteLength}`;
- }
- function Z(t5) {
- return r(t5) ? t5.toString() : "-";
- }
- function tt(t5) {
- let e5 = 0;
- const o6 = { color: false, tangent: false, normal: false, texCoord0: false }, n6 = new Map(), s = new Map(), i3 = [];
- for (const a2 of t5.parts) {
- const { attributes: { position: t6, normal: c4, color: l2, tangent: u2, texCoord0: f4 } } = a2, m2 = `
- ${Y(t6, n6)}/
- ${Y(c4, n6)}/
- ${Y(l2, n6)}/
- ${Y(u2, n6)}/
- ${Y(f4, n6)}/
- ${Z(a2.transform)}
- `;
- let p2 = false;
- const d2 = r2(s, m2, () => (p2 = true, { start: e5, length: t6.count }));
- p2 && (e5 += t6.count), c4 && (o6.normal = true), l2 && (o6.color = true), u2 && (o6.tangent = true), f4 && (o6.texCoord0 = true), i3.push({ gltf: a2, writeVertices: p2, region: d2 });
- }
- return { vertexAttributes: { position: r7(T, e5), normal: o6.normal ? r7(i, e5) : null, tangent: o6.tangent ? r7(c, e5) : null, color: o6.color ? r7(x, e5) : null, texCoord0: o6.texCoord0 ? r7(u, e5) : null }, parts: i3, components: [] };
- }
- function et(t5) {
- return new m({ data: t5.data, wrap: at(t5.parameters.wrap) });
- }
- function rt(e5, r8) {
- const o6 = new l(ut(e5.color, e5.opacity)), i3 = e5.emissiveFactor ? new l(ft(e5.emissiveFactor)) : null;
- return new c2({ color: o6, colorTexture: e(o(e5.textureColor, (t5) => r8.get(t5))), normalTexture: e(o(e5.textureNormal, (t5) => r8.get(t5))), emissiveColor: i3, emissiveTexture: e(o(e5.textureEmissive, (t5) => r8.get(t5))), occlusionTexture: e(o(e5.textureOcclusion, (t5) => r8.get(t5))), alphaMode: it(e5.alphaMode), alphaCutoff: e5.alphaCutoff, doubleSided: e5.doubleSided, metallic: e5.metallicFactor, roughness: e5.roughnessFactor, metallicRoughnessTexture: e(o(e5.textureMetallicRoughness, (t5) => r8.get(t5))) });
- }
- function ot(t5, e5, r8) {
- e5.writeVertices && nt(t5, e5);
- const o6 = e5.gltf, n6 = st(o6.indices || o6.attributes.position.count, o6.primitiveType), s = e5.region.start;
- if (s)
- for (let i3 = 0; i3 < n6.length; i3++)
- n6[i3] += s;
- t5.components.push(new f2({ faces: n6, material: r8.get(o6.material), trustSourceNormals: true }));
- }
- function nt(t5, e5) {
- const { position: r8, normal: n6, tangent: s, color: a2, texCoord0: u2 } = t5.vertexAttributes, f4 = e5.region.start, { attributes: m2, transform: p2 } = e5.gltf, d2 = m2.position.count;
- if (t2(r8.slice(f4, d2), m2.position, p2), r(m2.normal) && r(n6)) {
- const t6 = j(e2(), p2), e6 = n6.slice(f4, d2);
- r5(e6, m2.normal, t6), w(t6) && o2(e6, e6);
- } else
- r(n6) && t3(n6, 0, 0, 1, { dstIndex: f4, count: d2 });
- if (r(m2.tangent) && r(s)) {
- const t6 = j(e2(), p2), e6 = s.slice(f4, d2);
- r6(e6, m2.tangent, t6), w(t6) && f3(e6, e6);
- } else
- r(s) && t4(s, 0, 0, 1, 1, { dstIndex: f4, count: d2 });
- if (r(m2.texCoord0) && r(u2) ? n3(u2.slice(f4, d2), m2.texCoord0) : r(u2) && d(u2, 0, 0, { dstIndex: f4, count: d2 }), r(m2.color) && r(a2)) {
- const t6 = m2.color, e6 = a2.slice(f4, d2);
- if (t6.elementCount === 4)
- t6 instanceof c ? o3(e6, t6, 255) : t6 instanceof x ? e4(e6, t6) : t6 instanceof L && n2(e6, t6, 8);
- else {
- t4(e6, 255, 255, 255, 255);
- const r9 = O.fromTypedArray(e6.typedBuffer, e6.typedBufferStride);
- t6 instanceof i ? f(r9, t6, 255) : t6 instanceof O ? e3(r9, t6) : t6 instanceof E && n(r9, t6, 8);
- }
- } else
- r(a2) && t4(a2.slice(f4, d2), 255, 255, 255, 255);
- }
- function st(t5, e5) {
- switch (e5) {
- case E2.TRIANGLES:
- return n5(t5, a);
- case E2.TRIANGLE_STRIP:
- return o4(t5);
- case E2.TRIANGLE_FAN:
- return i2(t5);
- }
- }
- function it(t5) {
- switch (t5) {
- case "OPAQUE":
- return "opaque";
- case "MASK":
- return "mask";
- case "BLEND":
- return "blend";
- }
- }
- function at(t5) {
- return { horizontal: ct(t5.s), vertical: ct(t5.t) };
- }
- function ct(t5) {
- switch (t5) {
- case D.CLAMP_TO_EDGE:
- return "clamp";
- case D.MIRRORED_REPEAT:
- return "mirror";
- case D.REPEAT:
- return "repeat";
- }
- }
- function lt(t5) {
- return t5 ** (1 / o5) * 255;
- }
- function ut(t5, e5) {
- return r4(lt(t5[0]), lt(t5[1]), lt(t5[2]), e5);
- }
- function ft(t5) {
- return r3(lt(t5[0]), lt(t5[1]), lt(t5[2]));
- }
- export {
- W as loadGLTFMesh
- };
- //# sourceMappingURL=loadGLTFMesh-VTQIH4TD.js.map
|