loadGLTFMesh-VTQIH4TD.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. import {
  2. a,
  3. c as c3,
  4. d,
  5. e as e4,
  6. f as f3,
  7. i as i2,
  8. n as n2,
  9. n2 as n3,
  10. n3 as n4,
  11. n4 as n5,
  12. o as o3,
  13. o2 as o4,
  14. o3 as o5,
  15. r as r6,
  16. r2 as r7,
  17. t as t4
  18. } from "./chunk-NBRP7CWO.js";
  19. import "./chunk-GXVMJ7RN.js";
  20. import "./chunk-6BRTRIDE.js";
  21. import {
  22. f as f2,
  23. p
  24. } from "./chunk-T47XOAZJ.js";
  25. import {
  26. c as c2,
  27. m
  28. } from "./chunk-7NPG47AN.js";
  29. import "./chunk-2QVXRTVA.js";
  30. import {
  31. D,
  32. E as E2
  33. } from "./chunk-MI7HWWFL.js";
  34. import {
  35. k3 as k
  36. } from "./chunk-2ADIR7NB.js";
  37. import {
  38. e2 as e3,
  39. f,
  40. n,
  41. o as o2,
  42. r as r5,
  43. t as t2,
  44. t2 as t3
  45. } from "./chunk-4KFEVYXL.js";
  46. import "./chunk-5W6F4NR5.js";
  47. import "./chunk-YZUP3MAF.js";
  48. import "./chunk-E3HOL2XO.js";
  49. import {
  50. e as e2
  51. } from "./chunk-SCXOTZ6Q.js";
  52. import {
  53. E,
  54. L,
  55. O,
  56. T,
  57. c,
  58. i,
  59. u,
  60. x
  61. } from "./chunk-H4JLO5B2.js";
  62. import "./chunk-G5AI6ZNE.js";
  63. import "./chunk-5JK4DCPE.js";
  64. import {
  65. j
  66. } from "./chunk-CRGVDJI6.js";
  67. import "./chunk-DH2OBAUC.js";
  68. import "./chunk-TNLRDNTC.js";
  69. import "./chunk-6P6NA7JB.js";
  70. import "./chunk-LPQPD3EP.js";
  71. import "./chunk-WR32EHFC.js";
  72. import {
  73. r as r4
  74. } from "./chunk-NTUXR253.js";
  75. import "./chunk-H2KDMZTR.js";
  76. import {
  77. l
  78. } from "./chunk-7XXXCK2A.js";
  79. import "./chunk-65BYCSII.js";
  80. import "./chunk-TERAW6FT.js";
  81. import "./chunk-N2663GRX.js";
  82. import "./chunk-O4FY3ITT.js";
  83. import "./chunk-JXW4QTJA.js";
  84. import {
  85. w
  86. } from "./chunk-XNLG7T2T.js";
  87. import {
  88. r as r3
  89. } from "./chunk-IR4PV7VK.js";
  90. import "./chunk-OWVBLVP3.js";
  91. import "./chunk-WJ3OEUD3.js";
  92. import "./chunk-MXB2XLKV.js";
  93. import "./chunk-HNOZUNJ4.js";
  94. import {
  95. U
  96. } from "./chunk-VNFRAYHO.js";
  97. import "./chunk-R5IG2D6H.js";
  98. import "./chunk-VBRY5KJM.js";
  99. import "./chunk-PDKDCAAD.js";
  100. import "./chunk-ECW2QABR.js";
  101. import "./chunk-GCDJLKH4.js";
  102. import "./chunk-MRJEICT6.js";
  103. import "./chunk-Y3WMVFTW.js";
  104. import "./chunk-SAS7RONY.js";
  105. import "./chunk-WSRBH7BF.js";
  106. import {
  107. r as r2
  108. } from "./chunk-IHXECKQQ.js";
  109. import "./chunk-ULGDPLM2.js";
  110. import "./chunk-EMJ4ZSM2.js";
  111. import "./chunk-IKP3YN53.js";
  112. import {
  113. e,
  114. o,
  115. r,
  116. t
  117. } from "./chunk-GZT4BVFP.js";
  118. import "./chunk-A5ICIBVI.js";
  119. // node_modules/@arcgis/core/geometry/support/meshUtils/loadGLTFMesh.js
  120. async function W(t5, e5, r8) {
  121. const o6 = new n4(X(r8)), n6 = (await c3(o6, e5, r8, true)).model, s = n6.lods.shift(), a2 = new Map(), c4 = new Map();
  122. n6.textures.forEach((t6, e6) => a2.set(e6, et(t6))), n6.materials.forEach((t6, e6) => c4.set(e6, rt(t6, a2)));
  123. const l2 = tt(s);
  124. for (const i3 of l2.parts)
  125. ot(l2, i3, c4);
  126. 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);
  127. 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 }) };
  128. }
  129. function X(t5) {
  130. return t5?.resolveFile ? { busy: false, request: async (r8, o6, n6) => {
  131. const s = t5.resolveFile(r8), a2 = o6 === "image" ? "image" : o6 === "binary" ? "array-buffer" : "json";
  132. return (await U(s, { responseType: a2, signal: r(n6) ? n6.signal : null })).data;
  133. } } : null;
  134. }
  135. function Y(t5, e5) {
  136. if (t(t5))
  137. return "-";
  138. const o6 = t5.typedBuffer;
  139. return `${r2(e5, o6.buffer, () => e5.size)}/${o6.byteOffset}/${o6.byteLength}`;
  140. }
  141. function Z(t5) {
  142. return r(t5) ? t5.toString() : "-";
  143. }
  144. function tt(t5) {
  145. let e5 = 0;
  146. const o6 = { color: false, tangent: false, normal: false, texCoord0: false }, n6 = new Map(), s = new Map(), i3 = [];
  147. for (const a2 of t5.parts) {
  148. const { attributes: { position: t6, normal: c4, color: l2, tangent: u2, texCoord0: f4 } } = a2, m2 = `
  149. ${Y(t6, n6)}/
  150. ${Y(c4, n6)}/
  151. ${Y(l2, n6)}/
  152. ${Y(u2, n6)}/
  153. ${Y(f4, n6)}/
  154. ${Z(a2.transform)}
  155. `;
  156. let p2 = false;
  157. const d2 = r2(s, m2, () => (p2 = true, { start: e5, length: t6.count }));
  158. 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 });
  159. }
  160. 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: [] };
  161. }
  162. function et(t5) {
  163. return new m({ data: t5.data, wrap: at(t5.parameters.wrap) });
  164. }
  165. function rt(e5, r8) {
  166. const o6 = new l(ut(e5.color, e5.opacity)), i3 = e5.emissiveFactor ? new l(ft(e5.emissiveFactor)) : null;
  167. 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))) });
  168. }
  169. function ot(t5, e5, r8) {
  170. e5.writeVertices && nt(t5, e5);
  171. const o6 = e5.gltf, n6 = st(o6.indices || o6.attributes.position.count, o6.primitiveType), s = e5.region.start;
  172. if (s)
  173. for (let i3 = 0; i3 < n6.length; i3++)
  174. n6[i3] += s;
  175. t5.components.push(new f2({ faces: n6, material: r8.get(o6.material), trustSourceNormals: true }));
  176. }
  177. function nt(t5, e5) {
  178. 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;
  179. if (t2(r8.slice(f4, d2), m2.position, p2), r(m2.normal) && r(n6)) {
  180. const t6 = j(e2(), p2), e6 = n6.slice(f4, d2);
  181. r5(e6, m2.normal, t6), w(t6) && o2(e6, e6);
  182. } else
  183. r(n6) && t3(n6, 0, 0, 1, { dstIndex: f4, count: d2 });
  184. if (r(m2.tangent) && r(s)) {
  185. const t6 = j(e2(), p2), e6 = s.slice(f4, d2);
  186. r6(e6, m2.tangent, t6), w(t6) && f3(e6, e6);
  187. } else
  188. r(s) && t4(s, 0, 0, 1, 1, { dstIndex: f4, count: d2 });
  189. 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)) {
  190. const t6 = m2.color, e6 = a2.slice(f4, d2);
  191. if (t6.elementCount === 4)
  192. t6 instanceof c ? o3(e6, t6, 255) : t6 instanceof x ? e4(e6, t6) : t6 instanceof L && n2(e6, t6, 8);
  193. else {
  194. t4(e6, 255, 255, 255, 255);
  195. const r9 = O.fromTypedArray(e6.typedBuffer, e6.typedBufferStride);
  196. t6 instanceof i ? f(r9, t6, 255) : t6 instanceof O ? e3(r9, t6) : t6 instanceof E && n(r9, t6, 8);
  197. }
  198. } else
  199. r(a2) && t4(a2.slice(f4, d2), 255, 255, 255, 255);
  200. }
  201. function st(t5, e5) {
  202. switch (e5) {
  203. case E2.TRIANGLES:
  204. return n5(t5, a);
  205. case E2.TRIANGLE_STRIP:
  206. return o4(t5);
  207. case E2.TRIANGLE_FAN:
  208. return i2(t5);
  209. }
  210. }
  211. function it(t5) {
  212. switch (t5) {
  213. case "OPAQUE":
  214. return "opaque";
  215. case "MASK":
  216. return "mask";
  217. case "BLEND":
  218. return "blend";
  219. }
  220. }
  221. function at(t5) {
  222. return { horizontal: ct(t5.s), vertical: ct(t5.t) };
  223. }
  224. function ct(t5) {
  225. switch (t5) {
  226. case D.CLAMP_TO_EDGE:
  227. return "clamp";
  228. case D.MIRRORED_REPEAT:
  229. return "mirror";
  230. case D.REPEAT:
  231. return "repeat";
  232. }
  233. }
  234. function lt(t5) {
  235. return t5 ** (1 / o5) * 255;
  236. }
  237. function ut(t5, e5) {
  238. return r4(lt(t5[0]), lt(t5[1]), lt(t5[2]), e5);
  239. }
  240. function ft(t5) {
  241. return r3(lt(t5[0]), lt(t5[1]), lt(t5[2]));
  242. }
  243. export {
  244. W as loadGLTFMesh
  245. };
  246. //# sourceMappingURL=loadGLTFMesh-VTQIH4TD.js.map