loadGLTFMesh-WBYY2AJJ.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. import {
  2. d as d2,
  3. e as e4,
  4. f as f2,
  5. f2 as f3,
  6. i as i2,
  7. m as m2,
  8. n as n2,
  9. n2 as n3,
  10. n3 as n4,
  11. o as o3,
  12. o2 as o4,
  13. o3 as o5,
  14. o4 as o6,
  15. r as r6,
  16. r2 as r7,
  17. t as t4
  18. } from "./chunk-ORLXOWB6.js";
  19. import {
  20. g as g2,
  21. p
  22. } from "./chunk-SFI4OJO6.js";
  23. import {
  24. c as c2,
  25. m
  26. } from "./chunk-UE4KC4K5.js";
  27. import "./chunk-X6GHUY4U.js";
  28. import {
  29. D,
  30. E as E2
  31. } from "./chunk-3OFVLRSL.js";
  32. import {
  33. _
  34. } from "./chunk-BXBBOCLV.js";
  35. import {
  36. e2 as e3,
  37. f,
  38. n,
  39. o as o2,
  40. r as r5,
  41. t as t2,
  42. t2 as t3
  43. } from "./chunk-IRQMHCT3.js";
  44. import "./chunk-W3XAGTM6.js";
  45. import "./chunk-44FMXGSC.js";
  46. import "./chunk-XFDO4CMR.js";
  47. import {
  48. e as e2
  49. } from "./chunk-GHN7C53L.js";
  50. import {
  51. E,
  52. L,
  53. O,
  54. T,
  55. c,
  56. i,
  57. u,
  58. x
  59. } from "./chunk-HIELTLML.js";
  60. import "./chunk-6FXLJAMI.js";
  61. import {
  62. g
  63. } from "./chunk-O3JQY77G.js";
  64. import "./chunk-E3G7BRZB.js";
  65. import "./chunk-P24XEEHY.js";
  66. import "./chunk-SAJAEMIJ.js";
  67. import "./chunk-GGGVIS2U.js";
  68. import {
  69. r as r4
  70. } from "./chunk-C7742RNZ.js";
  71. import "./chunk-4ONPMX2F.js";
  72. import "./chunk-VGWC3IKZ.js";
  73. import "./chunk-2H5MD622.js";
  74. import "./chunk-3RSFVUKZ.js";
  75. import "./chunk-O6VYMEIX.js";
  76. import {
  77. l
  78. } from "./chunk-X4SA4ELJ.js";
  79. import "./chunk-2ZSOO377.js";
  80. import "./chunk-ZLNEXZAN.js";
  81. import "./chunk-ZYRIJWLX.js";
  82. import {
  83. d
  84. } from "./chunk-RYY6632W.js";
  85. import "./chunk-DW42UVIT.js";
  86. import "./chunk-YAEIHDJH.js";
  87. import {
  88. r as r3
  89. } from "./chunk-TJNOJH33.js";
  90. import "./chunk-OSHI574D.js";
  91. import "./chunk-VCH45Q2I.js";
  92. import "./chunk-GSSTTHIT.js";
  93. import "./chunk-HZRKBTHJ.js";
  94. import {
  95. U
  96. } from "./chunk-DVUG3KID.js";
  97. import "./chunk-FWSQEIAR.js";
  98. import "./chunk-VEGAOVMY.js";
  99. import "./chunk-6T6G6LCQ.js";
  100. import "./chunk-YEJL5NEF.js";
  101. import "./chunk-PQFTYGF5.js";
  102. import "./chunk-2Z2TG5CU.js";
  103. import "./chunk-6KZ2LTDA.js";
  104. import "./chunk-U2XHEJM7.js";
  105. import {
  106. r as r2
  107. } from "./chunk-SQOPWYIT.js";
  108. import "./chunk-V6P2MAQQ.js";
  109. import "./chunk-E5O6P5I2.js";
  110. import "./chunk-SPWQ3AWG.js";
  111. import "./chunk-2TIUKVZN.js";
  112. import {
  113. e,
  114. o,
  115. r,
  116. t
  117. } from "./chunk-YXWMMD76.js";
  118. import "./chunk-S5KM4IGW.js";
  119. // node_modules/@arcgis/core/geometry/support/meshUtils/loadGLTFMesh.js
  120. async function W(e5, t5, r8) {
  121. const o7 = new n4(X(r8)), s = (await m2(o7, t5, r8, true)).model, i3 = s.lods.shift(), a = /* @__PURE__ */ new Map(), c3 = /* @__PURE__ */ new Map();
  122. s.textures.forEach((e6, t6) => a.set(t6, te(e6))), s.materials.forEach((e6, t6) => c3.set(t6, re(e6, a)));
  123. const u2 = ee(i3);
  124. for (const n5 of u2.parts)
  125. oe(u2, n5, c3);
  126. const { position: l2, normal: f4, tangent: m3, color: p2, texCoord0: d3 } = u2.vertexAttributes, x2 = { position: l2.typedBuffer, normal: r(f4) ? f4.typedBuffer : null, tangent: r(m3) ? m3.typedBuffer : null, uv: r(d3) ? d3.typedBuffer : null, color: r(p2) ? p2.typedBuffer : null }, T2 = _(x2, e5, r8);
  127. return { transform: T2.transform, components: u2.components, spatialReference: e5.spatialReference, vertexAttributes: new p({ position: T2.vertexAttributes.position, normal: T2.vertexAttributes.normal, tangent: T2.vertexAttributes.tangent, color: x2.color, uv: x2.uv }) };
  128. }
  129. function X(e5) {
  130. const r8 = e5 == null ? void 0 : e5.resolveFile;
  131. return r8 ? { busy: false, request: async (e6, o7, s) => {
  132. const i3 = r8(e6), a = "image" === o7 ? "image" : "binary" === o7 ? "array-buffer" : "json";
  133. return (await U(i3, { responseType: a, signal: r(s) ? s.signal : null })).data;
  134. } } : null;
  135. }
  136. function Y(e5, t5) {
  137. if (t(e5))
  138. return "-";
  139. const o7 = e5.typedBuffer;
  140. return `${r2(t5, o7.buffer, () => t5.size)}/${o7.byteOffset}/${o7.byteLength}`;
  141. }
  142. function Z(e5) {
  143. return r(e5) ? e5.toString() : "-";
  144. }
  145. function ee(e5) {
  146. let t5 = 0;
  147. const has = { color: false, tangent: false, normal: false, texCoord0: false }, o7 = /* @__PURE__ */ new Map(), n5 = /* @__PURE__ */ new Map(), s = [];
  148. for (const i3 of e5.parts) {
  149. const { attributes: { position: e6, normal: a, color: c3, tangent: u2, texCoord0: l2 } } = i3, f4 = `
  150. ${Y(e6, o7)}/
  151. ${Y(a, o7)}/
  152. ${Y(c3, o7)}/
  153. ${Y(u2, o7)}/
  154. ${Y(l2, o7)}/
  155. ${Z(i3.transform)}
  156. `;
  157. let m3 = false;
  158. const p2 = r2(n5, f4, () => (m3 = true, { start: t5, length: e6.count }));
  159. m3 && (t5 += e6.count), a && (has.normal = true), c3 && (has.color = true), u2 && (has.tangent = true), l2 && (has.texCoord0 = true), s.push({ gltf: i3, writeVertices: m3, region: p2 });
  160. }
  161. return { vertexAttributes: { position: r7(T, t5), normal: has.normal ? r7(i, t5) : null, tangent: has.tangent ? r7(c, t5) : null, color: has.color ? r7(x, t5) : null, texCoord0: has.texCoord0 ? r7(u, t5) : null }, parts: s, components: [] };
  162. }
  163. function te(e5) {
  164. return new m({ data: e5.data, wrap: ae(e5.parameters.wrap) });
  165. }
  166. function re(t5, r8) {
  167. const o7 = new l(le(t5.color, t5.opacity)), n5 = t5.emissiveFactor ? new l(fe(t5.emissiveFactor)) : null;
  168. return new c2({ color: o7, colorTexture: e(o(t5.textureColor, (e5) => r8.get(e5))), normalTexture: e(o(t5.textureNormal, (e5) => r8.get(e5))), emissiveColor: n5, emissiveTexture: e(o(t5.textureEmissive, (e5) => r8.get(e5))), occlusionTexture: e(o(t5.textureOcclusion, (e5) => r8.get(e5))), alphaMode: ie(t5.alphaMode), alphaCutoff: t5.alphaCutoff, doubleSided: t5.doubleSided, metallic: t5.metallicFactor, roughness: t5.roughnessFactor, metallicRoughnessTexture: e(o(t5.textureMetallicRoughness, (e5) => r8.get(e5))), colorTextureTransform: t5.colorTextureTransform, normalTextureTransform: t5.normalTextureTransform, occlusionTextureTransform: t5.occlusionTextureTransform, emissiveTextureTransform: t5.emissiveTextureTransform, metallicRoughnessTextureTransform: t5.metallicRoughnessTextureTransform });
  169. }
  170. function oe(e5, t5, r8) {
  171. t5.writeVertices && ne(e5, t5);
  172. const o7 = t5.gltf, n5 = se(o7.indices || o7.attributes.position.count, o7.primitiveType), s = t5.region.start;
  173. if (s)
  174. for (let i3 = 0; i3 < n5.length; i3++)
  175. n5[i3] += s;
  176. e5.components.push(new g2({ faces: n5, material: r8.get(o7.material), trustSourceNormals: true }));
  177. }
  178. function ne(e5, t5) {
  179. const { position: r8, normal: s, tangent: i3, color: a, texCoord0: l2 } = e5.vertexAttributes, f4 = t5.region.start, { attributes: m3, transform: p2 } = t5.gltf, d3 = m3.position.count;
  180. if (t2(r8.slice(f4, d3), m3.position, p2), r(m3.normal) && r(s)) {
  181. const e6 = g(e2(), p2), t6 = s.slice(f4, d3);
  182. r5(t6, m3.normal, e6), d(e6) && o2(t6, t6);
  183. } else
  184. r(s) && t3(s, 0, 0, 1, { dstIndex: f4, count: d3 });
  185. if (r(m3.tangent) && r(i3)) {
  186. const e6 = g(e2(), p2), t6 = i3.slice(f4, d3);
  187. r6(t6, m3.tangent, e6), d(e6) && f2(t6, t6);
  188. } else
  189. r(i3) && t4(i3, 0, 0, 1, 1, { dstIndex: f4, count: d3 });
  190. if (r(m3.texCoord0) && r(l2) ? n3(l2.slice(f4, d3), m3.texCoord0) : r(l2) && d2(l2, 0, 0, { dstIndex: f4, count: d3 }), r(m3.color) && r(a)) {
  191. const e6 = m3.color, t6 = a.slice(f4, d3);
  192. if (4 === e6.elementCount)
  193. e6 instanceof c ? o3(t6, e6, 255) : e6 instanceof x ? e4(t6, e6) : e6 instanceof L && n2(t6, e6, 8);
  194. else {
  195. t4(t6, 255, 255, 255, 255);
  196. const r9 = O.fromTypedArray(t6.typedBuffer, t6.typedBufferStride);
  197. e6 instanceof i ? f(r9, e6, 255) : e6 instanceof O ? e3(r9, e6) : e6 instanceof E && n(r9, e6, 8);
  198. }
  199. } else
  200. r(a) && t4(a.slice(f4, d3), 255, 255, 255, 255);
  201. }
  202. function se(e5, t5) {
  203. switch (t5) {
  204. case E2.TRIANGLES:
  205. return o5(e5, o4);
  206. case E2.TRIANGLE_STRIP:
  207. return f3(e5);
  208. case E2.TRIANGLE_FAN:
  209. return i2(e5);
  210. }
  211. }
  212. function ie(e5) {
  213. switch (e5) {
  214. case "OPAQUE":
  215. return "opaque";
  216. case "MASK":
  217. return "mask";
  218. case "BLEND":
  219. return "blend";
  220. }
  221. }
  222. function ae(e5) {
  223. return { horizontal: ce(e5.s), vertical: ce(e5.t) };
  224. }
  225. function ce(e5) {
  226. switch (e5) {
  227. case D.CLAMP_TO_EDGE:
  228. return "clamp";
  229. case D.MIRRORED_REPEAT:
  230. return "mirror";
  231. case D.REPEAT:
  232. return "repeat";
  233. }
  234. }
  235. function ue(e5) {
  236. return e5 ** (1 / o6) * 255;
  237. }
  238. function le(e5, t5) {
  239. return r4(ue(e5[0]), ue(e5[1]), ue(e5[2]), t5);
  240. }
  241. function fe(e5) {
  242. return r3(ue(e5[0]), ue(e5[1]), ue(e5[2]));
  243. }
  244. export {
  245. W as loadGLTFMesh
  246. };
  247. //# sourceMappingURL=loadGLTFMesh-WBYY2AJJ.js.map