chunk-H2VOWDMO.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. import {
  2. D,
  3. G,
  4. L,
  5. M,
  6. P,
  7. U,
  8. t,
  9. u
  10. } from "./chunk-3OFVLRSL.js";
  11. import {
  12. r as r2
  13. } from "./chunk-RWQH5X3O.js";
  14. import {
  15. c
  16. } from "./chunk-RYY6632W.js";
  17. import {
  18. s2 as s,
  19. s3 as s2
  20. } from "./chunk-E5O6P5I2.js";
  21. import {
  22. has
  23. } from "./chunk-SPWQ3AWG.js";
  24. import {
  25. e,
  26. r
  27. } from "./chunk-YXWMMD76.js";
  28. // node_modules/@arcgis/core/views/webgl/checkWebGLError.js
  29. var o = s.getLogger("esri.views.webgl.checkWebGLError");
  30. function t2(e2, r3) {
  31. switch (r3) {
  32. case e2.INVALID_ENUM:
  33. return "Invalid Enum. An unacceptable value has been specified for an enumerated argument.";
  34. case e2.INVALID_VALUE:
  35. return "Invalid Value. A numeric argument is out of range.";
  36. case e2.INVALID_OPERATION:
  37. return "Invalid Operation. The specified command is not allowed for the current state.";
  38. case e2.INVALID_FRAMEBUFFER_OPERATION:
  39. return "Invalid Framebuffer operation. The currently bound framebuffer is not framebuffer complete when trying to render to or to read from it.";
  40. case e2.OUT_OF_MEMORY:
  41. return "Out of memory. Not enough memory is left to execute the command.";
  42. case e2.CONTEXT_LOST_WEBGL:
  43. return "WebGL context has been lost";
  44. default:
  45. return "Unknown error";
  46. }
  47. }
  48. var n = !!has("enable-feature:webgl-debug");
  49. function a() {
  50. return n;
  51. }
  52. function c2() {
  53. return n;
  54. }
  55. function u2(r3) {
  56. if (a()) {
  57. const n3 = r3.getError();
  58. if (n3) {
  59. const a2 = t2(r3, n3), c4 = new Error().stack;
  60. o.error(new s2("webgl-error", "WebGL error occured", { message: a2, stack: c4 }));
  61. }
  62. }
  63. }
  64. // node_modules/@arcgis/core/views/webgl/capabilities/isWebGL2Context.js
  65. function n2(n3) {
  66. return window.WebGL2RenderingContext && n3 instanceof window.WebGL2RenderingContext;
  67. }
  68. // node_modules/@arcgis/core/views/webgl/Texture.js
  69. var u3 = { target: M.TEXTURE_2D, samplingMode: L.LINEAR, wrapMode: D.REPEAT, flipped: false, hasMipmap: false, isOpaque: false, unpackAlignment: 4, preMultiplyAlpha: false, isImmutable: false };
  70. var c3 = 4;
  71. var E = class {
  72. constructor(t3, e2, i = null) {
  73. this._context = t3, this.type = "texture", this._glName = null, this._samplingModeDirty = false, this._wrapModeDirty = false, this._wasImmutablyAllocated = false, t3.instanceCounter.increment(t.Texture, this), this._descriptor = { ...u3, ...e2 };
  74. for (const r3 in u3) {
  75. void 0 === this._descriptor[r3] && (this._descriptor[r3] = u3[r3]);
  76. }
  77. if (t3.type !== r2.WEBGL2 && (this._descriptor.isImmutable && (this._descriptor.isImmutable = false), A(this._descriptor.target)))
  78. throw new Error("3D and array textures are not supported in WebGL1");
  79. this._descriptor.target === M.TEXTURE_CUBE_MAP ? this._setDataCubeMap(i) : this.setData(i);
  80. }
  81. get glName() {
  82. return this._glName;
  83. }
  84. get descriptor() {
  85. return this._descriptor;
  86. }
  87. get isDirty() {
  88. return this._samplingModeDirty || this._wrapModeDirty;
  89. }
  90. dispose() {
  91. this._context.gl && this._glName && (this._context.unbindTexture(this), this._context.gl.deleteTexture(this._glName), this._glName = null, this._context.instanceCounter.decrement(t.Texture, this));
  92. }
  93. release() {
  94. this.dispose();
  95. }
  96. resize(t3, e2) {
  97. const i = this._descriptor;
  98. if (i.width !== t3 || i.height !== e2) {
  99. if (this._wasImmutablyAllocated)
  100. throw new Error("Immutable textures can't be resized!");
  101. i.width = t3, i.height = e2, this._descriptor.target === M.TEXTURE_CUBE_MAP ? this._setDataCubeMap(null) : this.setData(null);
  102. }
  103. }
  104. _setDataCubeMap(t3 = null) {
  105. for (let e2 = M.TEXTURE_CUBE_MAP_POSITIVE_X; e2 <= M.TEXTURE_CUBE_MAP_NEGATIVE_Z; e2++)
  106. this._setData(t3, e2);
  107. }
  108. setData(t3) {
  109. this._setData(t3);
  110. }
  111. _setData(t3, i) {
  112. var _a, _b;
  113. if (!this._context || !this._context.gl)
  114. return;
  115. const o2 = this._context.gl;
  116. this._glName || (this._glName = o2.createTexture()), void 0 === t3 && (t3 = null);
  117. const s3 = this._descriptor, a2 = i != null ? i : s3.target, n3 = A(a2);
  118. null === t3 && (s3.width = s3.width || c3, s3.height = s3.height || c3, n3 && (s3.depth = (_a = s3.depth) != null ? _a : 1));
  119. const l = this._context.bindTexture(this, E.TEXTURE_UNIT_FOR_UPDATES);
  120. this._context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES), E._validateTexture(this._context, s3), this._configurePixelStorage(), u2(o2);
  121. const h = s3.pixelFormat;
  122. let p = (_b = s3.internalFormat) != null ? _b : this._deriveInternalFormat(h, s3.dataType);
  123. if (f(t3)) {
  124. let e2 = t3.width, i2 = t3.height;
  125. const l2 = 1;
  126. t3 instanceof HTMLVideoElement && (e2 = t3.videoWidth, i2 = t3.videoHeight), s3.width && s3.height, n3 && s3.depth, s3.isImmutable && !this._wasImmutablyAllocated && this._texStorage(a2, p, s3.hasMipmap, e2, i2, l2), this._texImage(a2, 0, p, e2, i2, l2, t3), u2(o2), s3.hasMipmap && this.generateMipmap(), void 0 === s3.width && (s3.width = e2), void 0 === s3.height && (s3.height = i2), n3 && void 0 === s3.depth && (s3.depth = l2);
  127. } else {
  128. const { width: i2, height: l2, depth: h2 } = s3;
  129. if (null == i2 || null == l2)
  130. throw new Error("Width and height must be specified!");
  131. if (n3 && null == h2)
  132. throw new Error("Depth must be specified!");
  133. if (s3.isImmutable && !this._wasImmutablyAllocated && this._texStorage(a2, p, s3.hasMipmap, i2, l2, h2), o2.DEPTH24_STENCIL8 && p === o2.DEPTH_STENCIL && (p = o2.DEPTH24_STENCIL8), x(t3)) {
  134. const e2 = t3.levels, r3 = w(a2, i2, l2, h2), n4 = Math.min(r3 - 1, e2.length - 1);
  135. n2(o2) ? o2.texParameteri(s3.target, o2.TEXTURE_MAX_LEVEL, n4) : s3.hasMipmap = s3.hasMipmap && r3 === e2.length;
  136. const _ = p;
  137. if (!g(_))
  138. throw new Error("Attempting to use compressed data with an umcompressed format!");
  139. this._forEachMipmapLevel((t4, i3, r4, o3) => {
  140. const s4 = e2[Math.min(t4, e2.length - 1)];
  141. this._compressedTexImage(a2, t4, _, i3, r4, o3, s4);
  142. }, n4);
  143. } else
  144. r(t3) ? (this._texImage(a2, 0, p, i2, l2, h2, t3), u2(o2), s3.hasMipmap && this.generateMipmap()) : this._forEachMipmapLevel((t4, e2, i3, s4) => {
  145. this._texImage(a2, t4, p, e2, i3, s4, null), u2(o2);
  146. });
  147. }
  148. E._applySamplingMode(o2, this._descriptor), E._applyWrapMode(o2, this._descriptor), E._applyAnisotropicFilteringParameters(this._context, this._descriptor), u2(o2), this._context.bindTexture(l, E.TEXTURE_UNIT_FOR_UPDATES);
  149. }
  150. updateData(t3, e2, i, r3, o2, s3, a2 = 0) {
  151. var _a;
  152. s3 || console.error("An attempt to use uninitialized data!"), this._glName || console.error("An attempt to update uninitialized texture!");
  153. const n3 = this._context.gl, l = this._descriptor, { pixelFormat: h, dataType: p, target: _, isImmutable: m } = l, u4 = (_a = l.internalFormat) != null ? _a : this._deriveInternalFormat(h, p);
  154. if (m && !this._wasImmutablyAllocated)
  155. throw new Error("Cannot update immutable texture before allocation!");
  156. const c4 = this._context.bindTexture(this, E.TEXTURE_UNIT_FOR_UPDATES, true);
  157. if ((e2 < 0 || i < 0 || r3 > l.width || o2 > l.height || e2 + r3 > l.width || i + o2 > l.height) && console.error("An attempt to update out of bounds of the texture!"), this._configurePixelStorage(), a2) {
  158. if (!n2(n3))
  159. return void console.error("Webgl2 must be enabled to use dataRowOffset!");
  160. n3.pixelStorei(n3.UNPACK_SKIP_ROWS, a2);
  161. }
  162. if (f(s3) ? n2(n3) ? n3.texSubImage2D(_, t3, e2, i, r3, o2, h, p, s3) : n3.texSubImage2D(_, t3, e2, i, h, p, s3) : x(s3) ? n3.compressedTexSubImage2D(_, t3, e2, i, r3, o2, u4, s3.levels[t3]) : n3.texSubImage2D(_, t3, e2, i, r3, o2, h, p, s3), a2) {
  163. if (!n2(n3))
  164. return void console.error("Webgl2 must be enabled to use dataRowOffset!");
  165. n3.pixelStorei(n3.UNPACK_SKIP_ROWS, 0);
  166. }
  167. this._context.bindTexture(c4, E.TEXTURE_UNIT_FOR_UPDATES);
  168. }
  169. updateData3D(t3, e2, i, r3, o2, s3, a2, n3) {
  170. var _a;
  171. n3 || console.error("An attempt to use uninitialized data!"), this._glName || console.error("An attempt to update uninitialized texture!");
  172. const l = this._context.gl;
  173. if (!n2(l))
  174. throw new Error("3D textures are not supported in WebGL1");
  175. const h = this._descriptor, { pixelFormat: p, dataType: _, isImmutable: m, target: u4 } = h, c4 = (_a = h.internalFormat) != null ? _a : this._deriveInternalFormat(p, _);
  176. if (m && !this._wasImmutablyAllocated)
  177. throw new Error("Cannot update immutable texture before allocation!");
  178. A(u4) || console.warn("Attempting to set 3D texture data on a non-3D texture");
  179. const T2 = this._context.bindTexture(this, E.TEXTURE_UNIT_FOR_UPDATES);
  180. if (this._context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES), (e2 < 0 || i < 0 || r3 < 0 || o2 > h.width || s3 > h.height || a2 > h.depth || e2 + o2 > h.width || i + s3 > h.height || r3 + a2 > h.depth) && console.error("An attempt to update out of bounds of the texture!"), this._configurePixelStorage(), x(n3))
  181. n3 = n3.levels[t3], l.compressedTexSubImage3D(u4, t3, e2, i, r3, o2, s3, a2, c4, n3);
  182. else {
  183. const h2 = n3;
  184. l.texSubImage3D(u4, t3, e2, i, r3, o2, s3, a2, p, _, h2);
  185. }
  186. this._context.bindTexture(T2, E.TEXTURE_UNIT_FOR_UPDATES);
  187. }
  188. generateMipmap() {
  189. const t3 = this._descriptor;
  190. if (!t3.hasMipmap) {
  191. if (this._wasImmutablyAllocated)
  192. throw new Error("Cannot add mipmaps to immutable texture after allocation");
  193. t3.hasMipmap = true, this._samplingModeDirty = true, E._validateTexture(this._context, t3);
  194. }
  195. t3.samplingMode === L.LINEAR ? (this._samplingModeDirty = true, t3.samplingMode = L.LINEAR_MIPMAP_NEAREST) : t3.samplingMode === L.NEAREST && (this._samplingModeDirty = true, t3.samplingMode = L.NEAREST_MIPMAP_NEAREST);
  196. const e2 = this._context.bindTexture(this, E.TEXTURE_UNIT_FOR_UPDATES);
  197. this._context.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES);
  198. this._context.gl.generateMipmap(t3.target), this._context.bindTexture(e2, E.TEXTURE_UNIT_FOR_UPDATES);
  199. }
  200. setSamplingMode(t3) {
  201. t3 !== this._descriptor.samplingMode && (this._descriptor.samplingMode = t3, this._samplingModeDirty = true);
  202. }
  203. setWrapMode(t3) {
  204. t3 !== this._descriptor.wrapMode && (this._descriptor.wrapMode = t3, E._validateTexture(this._context, this._descriptor), this._wrapModeDirty = true);
  205. }
  206. applyChanges() {
  207. const t3 = this._context.gl, e2 = this._descriptor;
  208. this._samplingModeDirty && (E._applySamplingMode(t3, e2), this._samplingModeDirty = false), this._wrapModeDirty && (E._applyWrapMode(t3, e2), this._wrapModeDirty = false);
  209. }
  210. _deriveInternalFormat(t3, e2) {
  211. if (this._context.type === r2.WEBGL1)
  212. return t3;
  213. switch (e2) {
  214. case G.FLOAT:
  215. switch (t3) {
  216. case P.RGBA:
  217. return U.RGBA32F;
  218. case P.RGB:
  219. return U.RGB32F;
  220. default:
  221. throw new Error("Unable to derive format");
  222. }
  223. case G.UNSIGNED_BYTE:
  224. switch (t3) {
  225. case P.RGBA:
  226. return U.RGBA8;
  227. case P.RGB:
  228. return U.RGB8;
  229. }
  230. default:
  231. return t3;
  232. }
  233. }
  234. _configurePixelStorage() {
  235. const t3 = this._context.gl, { unpackAlignment: e2, flipped: i, preMultiplyAlpha: r3 } = this._descriptor;
  236. t3.pixelStorei(t3.UNPACK_ALIGNMENT, e2), t3.pixelStorei(t3.UNPACK_FLIP_Y_WEBGL, i ? 1 : 0), t3.pixelStorei(t3.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r3 ? 1 : 0);
  237. }
  238. _texStorage(t3, e2, i, r3, o2, s3) {
  239. const a2 = this._context.gl;
  240. if (!n2(a2))
  241. throw new Error("Immutable textures are not supported in WebGL1");
  242. if (!T(e2))
  243. throw new Error("Immutable textures must have a sized internal format");
  244. if (!this._descriptor.isImmutable)
  245. return;
  246. const n3 = i ? w(t3, r3, o2, s3) : 1;
  247. if (A(t3)) {
  248. if (null == s3)
  249. throw new Error("Missing depth dimension for 3D texture upload");
  250. a2.texStorage3D(t3, n3, e2, r3, o2, s3);
  251. } else
  252. a2.texStorage2D(t3, n3, e2, r3, o2);
  253. this._wasImmutablyAllocated = true;
  254. }
  255. _texImage(t3, r3, s3, a2, n3, l, h) {
  256. const p = this._context.gl;
  257. let _ = null;
  258. const m = this._context.type === r2.WEBGL2, d = A(t3), { isImmutable: u4, pixelFormat: c4, dataType: E2 } = this._descriptor;
  259. if (m && (_ = p), m || !f(h))
  260. if (u4) {
  261. if (r(h)) {
  262. const e2 = h;
  263. if (d) {
  264. if (null == l)
  265. throw new Error("Missing depth dimension for 3D texture upload");
  266. _.texSubImage3D(t3, r3, 0, 0, 0, a2, n3, l, c4, E2, e2);
  267. } else
  268. p.texSubImage2D(t3, r3, 0, 0, a2, n3, c4, E2, e2);
  269. }
  270. } else {
  271. const e2 = e(h);
  272. if (d) {
  273. if (null == l)
  274. throw new Error("Missing depth dimension for 3D texture upload");
  275. _.texImage3D(t3, r3, s3, a2, n3, l, 0, c4, E2, e2);
  276. } else
  277. p.texImage2D(t3, r3, s3, a2, n3, 0, c4, E2, e2);
  278. }
  279. else
  280. p.texImage2D(t3, 0, s3, c4, E2, h);
  281. }
  282. _compressedTexImage(t3, i, r3, s3, a2, n3, l) {
  283. const h = this._context.gl;
  284. let p = null;
  285. const _ = A(t3), m = this._descriptor.isImmutable;
  286. if (_) {
  287. if (this._context.type !== r2.WEBGL2)
  288. throw new Error("3D textures are not supported in WebGL1");
  289. p = h;
  290. }
  291. if (m) {
  292. if (r(l))
  293. if (_) {
  294. if (null == n3)
  295. throw new Error("Missing depth dimension for 3D texture upload");
  296. p.compressedTexSubImage3D(t3, i, 0, 0, 0, s3, a2, n3, r3, l);
  297. } else
  298. h.compressedTexSubImage2D(t3, i, 0, 0, s3, a2, r3, l);
  299. } else if (_) {
  300. if (null == n3)
  301. throw new Error("Missing depth dimension for 3D texture upload");
  302. p.compressedTexImage3D(t3, i, r3, s3, a2, n3, 0, l);
  303. } else
  304. h.compressedTexImage2D(t3, i, r3, s3, a2, 0, l);
  305. }
  306. _forEachMipmapLevel(t3, e2 = 1 / 0) {
  307. let { width: i, height: r3, depth: o2, hasMipmap: a2, target: n3 } = this._descriptor;
  308. const l = n3 === M.TEXTURE_3D;
  309. if (null == i || null == r3 || l && null == o2)
  310. throw new Error("Missing texture dimensions for mipmap calculation");
  311. for (let s3 = 0; t3(s3, i, r3, o2), a2 && (1 !== i || 1 !== r3 || l && 1 !== o2) && !(s3 >= e2); ++s3)
  312. i = Math.max(1, i >> 1), r3 = Math.max(1, r3 >> 1), l && (o2 = Math.max(1, o2 >> 1));
  313. }
  314. static _validateTexture(e2, i) {
  315. (null != i.width && i.width < 0 || null != i.height && i.height < 0 || null != i.depth && i.depth < 0) && console.error("Negative dimension parameters are not allowed!");
  316. const r3 = n2(e2.gl), o2 = null != i.width && c(i.width) && null != i.height && c(i.height);
  317. r3 || !i.isImmutable && !A(i.target) || console.error("Immutable and 3D-like textures are not supported in WebGL1!"), r3 || o2 || ("number" == typeof i.wrapMode ? i.wrapMode !== D.CLAMP_TO_EDGE && console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!") : i.wrapMode.s === D.CLAMP_TO_EDGE && i.wrapMode.t === D.CLAMP_TO_EDGE || console.error("Non-power-of-two textures must have a wrap mode of CLAMP_TO_EDGE!"), i.hasMipmap && console.error("Mipmapping requires power-of-two textures!"));
  318. }
  319. static _applySamplingMode(t3, e2) {
  320. let i = e2.samplingMode, r3 = e2.samplingMode;
  321. i === L.LINEAR_MIPMAP_NEAREST || i === L.LINEAR_MIPMAP_LINEAR ? (i = L.LINEAR, e2.hasMipmap || (r3 = L.LINEAR)) : i !== L.NEAREST_MIPMAP_NEAREST && i !== L.NEAREST_MIPMAP_LINEAR || (i = L.NEAREST, e2.hasMipmap || (r3 = L.NEAREST)), t3.texParameteri(e2.target, t3.TEXTURE_MAG_FILTER, i), t3.texParameteri(e2.target, t3.TEXTURE_MIN_FILTER, r3);
  322. }
  323. static _applyWrapMode(t3, e2) {
  324. "number" == typeof e2.wrapMode ? (t3.texParameteri(e2.target, t3.TEXTURE_WRAP_S, e2.wrapMode), t3.texParameteri(e2.target, t3.TEXTURE_WRAP_T, e2.wrapMode)) : (t3.texParameteri(e2.target, t3.TEXTURE_WRAP_S, e2.wrapMode.s), t3.texParameteri(e2.target, t3.TEXTURE_WRAP_T, e2.wrapMode.t));
  325. }
  326. static _applyAnisotropicFilteringParameters(t3, e2) {
  327. var _a;
  328. const i = t3.capabilities.textureFilterAnisotropic;
  329. if (!i)
  330. return;
  331. t3.gl.texParameterf(e2.target, i.TEXTURE_MAX_ANISOTROPY, (_a = e2.maxAnisotropy) != null ? _a : 1);
  332. }
  333. };
  334. function T(t3) {
  335. return t3 in U;
  336. }
  337. function g(t3) {
  338. return t3 in u;
  339. }
  340. function x(t3) {
  341. return r(t3) && "type" in t3 && "compressed" === t3.type;
  342. }
  343. function M2(t3) {
  344. return r(t3) && "byteLength" in t3;
  345. }
  346. function f(t3) {
  347. return r(t3) && !x(t3) && !M2(t3);
  348. }
  349. function A(t3) {
  350. return t3 === M.TEXTURE_3D || t3 === M.TEXTURE_2D_ARRAY;
  351. }
  352. function w(t3, e2, i, r3 = 1) {
  353. let o2 = Math.max(e2, i);
  354. return t3 === M.TEXTURE_3D && (o2 = Math.max(o2, r3)), Math.round(Math.log(o2) / Math.LN2) + 1;
  355. }
  356. E.TEXTURE_UNIT_FOR_UPDATES = 0;
  357. export {
  358. a,
  359. c2 as c,
  360. u2 as u,
  361. n2 as n,
  362. E
  363. };
  364. //# sourceMappingURL=chunk-H2VOWDMO.js.map