import { u as u3 } from "./chunk-546QCRS4.js"; import { c as c2, s as s4, u as u2 } from "./chunk-QXZVBSBH.js"; import { A, B, C, D, F, G, L, M, P, U, V, Y, c, f, n, t as t2, u } from "./chunk-MI7HWWFL.js"; import { o } from "./chunk-LGW7TID4.js"; import { s as s3 } from "./chunk-EMJ4ZSM2.js"; import { a3 as a, i3 as i, r, s, s3 as s2, t } from "./chunk-GZT4BVFP.js"; // node_modules/@arcgis/core/views/webgl/BufferObject.js var _ = s3.getLogger("esri.views.webgl.BufferObject"); function b(t3) { return a(t3); } var c3 = class { constructor(e, t3, r3, i3) { this._context = e, this.bufferType = t3, this.usage = r3, this._glName = null, this._size = -1, this._indexType = void 0, e.instanceCounter.increment(t2.BufferObject, this), this._glName = this._context.gl.createBuffer(), s4(this._context.gl), i3 && this.setData(i3); } static createIndex(e, t3, r3) { return new c3(e, A.ELEMENT_ARRAY_BUFFER, t3, r3); } static createVertex(e, t3, r3) { return new c3(e, A.ARRAY_BUFFER, t3, r3); } static createUniform(e, t3, r3) { if (e.type !== o.WEBGL2) throw new Error("Uniform buffers are supported in WebGL2 only!"); return new c3(e, A.UNIFORM_BUFFER, t3, r3); } static createPixelPack(e, t3 = F.STREAM_READ, r3) { if (e.type !== o.WEBGL2) throw new Error("Pixel pack buffers are supported in WebGL2 only!"); const i3 = new c3(e, A.PIXEL_PACK_BUFFER, t3); return r3 && i3.setSize(r3), i3; } static createPixelUnpack(e, t3 = F.STREAM_DRAW, r3) { if (e.type !== o.WEBGL2) throw new Error("Pixel unpack buffers are supported in WebGL2 only!"); return new c3(e, A.PIXEL_UNPACK_BUFFER, t3, r3); } get glName() { return this._glName; } get size() { return this._size; } get indexType() { return this._indexType; } get byteSize() { return this.bufferType === A.ELEMENT_ARRAY_BUFFER ? this._indexType === C.UNSIGNED_INT ? 4 * this._size : 2 * this._size : this._size; } get _isVAOAware() { return this.bufferType === A.ELEMENT_ARRAY_BUFFER || this.bufferType === A.ARRAY_BUFFER; } dispose() { if (this._context?.gl) { if (this._glName) { this._context.gl.deleteBuffer(this._glName), this._glName = null; } this._context.instanceCounter.decrement(t2.BufferObject, this), this._context = null; } else this._glName && _.warn("Leaked WebGL buffer object"); } setSize(e, t3 = null) { if (e <= 0 && _.error("Buffer size needs to be positive!"), this.bufferType === A.ELEMENT_ARRAY_BUFFER && r(t3)) switch (this._indexType = t3, t3) { case C.UNSIGNED_SHORT: e *= 2; break; case C.UNSIGNED_INT: e *= 4; } this._setBufferData(e); } setData(e) { if (!e) return; let t3 = e.byteLength; this.bufferType === A.ELEMENT_ARRAY_BUFFER && (i(e) && (t3 /= 2, this._indexType = C.UNSIGNED_SHORT), s2(e) && (t3 /= 4, this._indexType = C.UNSIGNED_INT)), this._setBufferData(t3, e); } _setBufferData(e, t3 = null) { this._size = e; const i3 = this._context.getBoundVAO(); this._isVAOAware && this._context.bindVAO(null), this._context.bindBuffer(this); const s5 = this._context.gl; r(t3) ? s5.bufferData(this.bufferType, t3, this.usage) : s5.bufferData(this.bufferType, e, this.usage), s4(s5), this._isVAOAware && this._context.bindVAO(i3); } setSubData(e, t3 = 0, r3 = 0, o4 = e.byteLength) { if (!e) return; (t3 < 0 || t3 >= this._size) && _.error("offset is out of range!"); let a2 = t3, u5 = r3, h = o4, b3 = e.byteLength; this.bufferType === A.ELEMENT_ARRAY_BUFFER && (i(e) ? (b3 /= 2, a2 *= 2, u5 *= 2, h *= 2) : s2(e) && (b3 /= 4, a2 *= 4, u5 *= 4, h *= 4)), o4 === void 0 && (o4 = b3 - 1), r3 >= o4 && _.error("end must be bigger than start!"), t3 + r3 - o4 > this._size && _.error("An attempt to write beyond the end of the buffer!"); const c4 = this._context.getBoundVAO(); this._isVAOAware && this._context.bindVAO(null), this._context.bindBuffer(this); const E2 = this._context.gl, l = ArrayBuffer.isView(e) ? e.buffer : e, d = u5 === 0 && h === e.byteLength ? l : l.slice(u5, h); E2.bufferSubData(this.bufferType, a2, d), s4(E2), this._isVAOAware && this._context.bindVAO(c4); } setSubDataFromView(e, t3, r3, i3) { if (!e) return; (t3 < 0 || t3 >= this._size) && _.error("offset is out of range!"), r3 >= i3 && _.error("end must be bigger than start!"), t3 + r3 - i3 > this._size && _.error("An attempt to write beyond the end of the buffer!"); const s5 = this._context.getBoundVAO(); this._isVAOAware && this._context.bindVAO(null), this._context.bindBuffer(this); const f3 = this._context.gl; if (this._context.type === o.WEBGL2) f3.bufferSubData(this.bufferType, t3 * e.BYTES_PER_ELEMENT, e, r3, i3 - r3); else { const s6 = r3 === 0 && i3 === e.length ? e : e.subarray(r3, i3); f3.bufferSubData(this.bufferType, t3 * e.BYTES_PER_ELEMENT, s6); } s4(f3), this._isVAOAware && this._context.bindVAO(s5); } getSubData(e, t3 = 0, r3, i3) { if (this._context.type !== o.WEBGL2) return void _.error("Get buffer subdata is supported in WebGL2 only!"); if (r3 < 0 || i3 < 0) return void _.error("Problem getting subdata: offset and length were less than zero!"); const s5 = b(e) ? e.BYTES_PER_ELEMENT : 1; if (s5 * ((r3 ?? 0) + (i3 ?? 0)) > e.byteLength) return void _.error("Problem getting subdata: offset and length exceeded destination size!"); t3 + s5 * (i3 ?? 0) > this.byteSize && _.warn("Potential problem getting subdata: requested data exceeds buffer size!"); const n3 = this._context.gl; this._context.bindBuffer(this, A.COPY_READ_BUFFER), n3.getBufferSubData(A.COPY_READ_BUFFER, t3, e, r3, i3), this._context.unbindBuffer(A.COPY_READ_BUFFER); } async getSubDataAsync(e, t3 = 0, r3, i3) { this._context.type === o.WEBGL2 ? (await this._context.clientWaitAsync(), this.getSubData(e, t3, r3, i3)) : _.error("Get buffer subdata is supported in WebGL2 only!"); } }; // node_modules/@arcgis/core/views/webgl/Util.js function i2(e) { const r3 = e.gl; switch (r3.getError()) { case r3.NO_ERROR: return null; case r3.INVALID_ENUM: return "An unacceptable value has been specified for an enumerated argument"; case r3.INVALID_VALUE: return "A numeric argument is out of range"; case r3.INVALID_OPERATION: return "The specified command is not allowed for the current state"; case r3.INVALID_FRAMEBUFFER_OPERATION: return "The currently bound framebuffer is not framebuffer complete"; case r3.OUT_OF_MEMORY: return "Not enough memory is left to execute the command"; case r3.CONTEXT_LOST_WEBGL: return "WebGL context is lost"; } return "Unknown error"; } function n2(e, r3) { return e.vertexBuffers[r3].size / o2(e.layout[r3]); } function o2(e) { return e[0].stride; } function R(e, r3, t3, s5, a2 = 0) { const c4 = e.gl, i3 = e.capabilities.instancing; e.bindBuffer(t3); for (const n3 of s5) { const e2 = r3.get(n3.name); e2 === void 0 && console.error(`There is no location for vertex attribute '${n3.name}' defined.`); const t4 = a2 * n3.stride; if (n3.count <= 4) c4.vertexAttribPointer(e2, n3.count, n3.type, n3.normalized, n3.stride, n3.offset + t4), c4.enableVertexAttribArray(e2), n3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2, n3.divisor); else if (n3.count === 9) for (let r4 = 0; r4 < 3; r4++) c4.vertexAttribPointer(e2 + r4, 3, n3.type, n3.normalized, n3.stride, n3.offset + 12 * r4 + t4), c4.enableVertexAttribArray(e2 + r4), n3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2 + r4, n3.divisor); else if (n3.count === 16) for (let r4 = 0; r4 < 4; r4++) c4.vertexAttribPointer(e2 + r4, 4, n3.type, n3.normalized, n3.stride, n3.offset + 16 * r4 + t4), c4.enableVertexAttribArray(e2 + r4), n3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2 + r4, n3.divisor); else console.error("Unsupported vertex attribute element count: " + n3.count); } } function E(e, t3, s5, a2) { const c4 = e.gl, i3 = e.capabilities.instancing; e.bindBuffer(s5); for (const r3 of a2) { const e2 = t3.get(r3.name); if (r3.count <= 4) c4.disableVertexAttribArray(e2), r3.divisor && r3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2, 0); else if (r3.count === 9) for (let t4 = 0; t4 < 3; t4++) c4.disableVertexAttribArray(e2 + t4), r3.divisor && r3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2 + t4, 0); else if (r3.count === 16) for (let t4 = 0; t4 < 4; t4++) c4.disableVertexAttribArray(e2 + t4), r3.divisor && r3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2 + t4, 0); else console.error("Unsupported vertex attribute element count: " + r3.count); } e.unbindBuffer(A.ARRAY_BUFFER); } function _2(e) { switch (e) { case P.ALPHA: case P.LUMINANCE: case P.RED: case P.RED_INTEGER: case U.R8: case U.R8I: case U.R8UI: case U.R8_SNORM: case B.STENCIL_INDEX8: return 1; case P.LUMINANCE_ALPHA: case P.RG: case P.RG_INTEGER: case U.RGBA4: case U.R16F: case U.R16I: case U.R16UI: case U.RG8: case U.RG8I: case U.RG8UI: case U.RG8_SNORM: case U.RGB565: case U.RGB5_A1: case B.DEPTH_COMPONENT16: return 2; case P.DEPTH_COMPONENT: case P.RGB: case P.RGB_INTEGER: case U.RGB8: case U.RGB8I: case U.RGB8UI: case U.RGB8_SNORM: case U.SRGB8: case B.DEPTH_COMPONENT24: return 3; case P.DEPTH_STENCIL: case P.RGBA: case P.RGBA_INTEGER: case U.RGBA8: case U.R32F: case U.R11F_G11F_B10F: case U.RG16F: case U.R32I: case U.R32UI: case U.RG16I: case U.RG16UI: case U.RGBA8I: case U.RGBA8UI: case U.RGBA8_SNORM: case U.SRGB8_ALPHA8: case U.RGB9_E5: case U.RGB10_A2UI: case U.RGB10_A2: case B.DEPTH_STENCIL: case B.DEPTH_COMPONENT32F: case B.DEPTH24_STENCIL8: return 4; case B.DEPTH32F_STENCIL8: return 5; case U.RGB16F: case U.RGB16I: case U.RGB16UI: return 6; case U.RG32F: case U.RG32I: case U.RG32UI: case U.RGBA16F: case U.RGBA16I: case U.RGBA16UI: return 8; case U.RGB32F: case U.RGB32I: case U.RGB32UI: return 12; case U.RGBA32F: case U.RGBA32I: case U.RGBA32UI: return 16; case u.COMPRESSED_RGB_S3TC_DXT1_EXT: case u.COMPRESSED_RGBA_S3TC_DXT1_EXT: return 0.5; case u.COMPRESSED_RGBA_S3TC_DXT3_EXT: case u.COMPRESSED_RGBA_S3TC_DXT5_EXT: return 1; case u.COMPRESSED_R11_EAC: case u.COMPRESSED_SIGNED_R11_EAC: case u.COMPRESSED_RGB8_ETC2: case u.COMPRESSED_SRGB8_ETC2: case u.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: case u.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return 0.5; case u.COMPRESSED_RG11_EAC: case u.COMPRESSED_SIGNED_RG11_EAC: case u.COMPRESSED_RGBA8_ETC2_EAC: case u.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: return 1; } return 0; } function u4(r3) { if (t(r3)) return 0; if ("descriptor" in r3) return r3.glName ? u4(r3.descriptor) : 0; const t3 = r3.internalFormat || "pixelFormat" in r3 && r3.pixelFormat; if (!t3) return 0; const s5 = "hasMipmap" in r3 && r3.hasMipmap ? 1.3 : 1, a2 = r3.width * r3.height; return _2(t3) * a2 * s5; } // node_modules/@arcgis/core/views/webgl/VertexArrayObject.js var o3 = s3.getLogger("esri.views.webgl.VertexArrayObject"); var f2 = class { constructor(t3, e, i3, s5, n3 = null) { this._context = t3, this._locations = e, this._layout = i3, this._buffers = s5, this._indexBuffer = n3, this._glName = null, this._initialized = false, t3.instanceCounter.increment(t2.VertexArrayObject, this); } get glName() { return this._glName; } get context() { return this._context; } get vertexBuffers() { return this._buffers; } get indexBuffer() { return this._indexBuffer; } get size() { return Object.keys(this._buffers).reduce((t3, e) => t3 + this._buffers[e].size, r(this._indexBuffer) ? this._indexBuffer.size : 0); } get layout() { return this._layout; } get locations() { return this._locations; } dispose(t3 = true) { if (!this._context) return void ((this._glName || t3 && Object.getOwnPropertyNames(this._buffers).length > 0) && o3.warn("Leaked WebGL VAO")); if (this._glName) { const t4 = this._context?.capabilities?.vao; t4 ? (t4.deleteVertexArray(this._glName), this._glName = null) : o3.warn("Leaked WebGL VAO"); } if (this._context.getBoundVAO() === this && this._context.bindVAO(null), t3) { for (const t4 in this._buffers) this._buffers[t4].dispose(), delete this._buffers[t4]; this._indexBuffer = s(this._indexBuffer); } this._context.instanceCounter.decrement(t2.VertexArrayObject, this), this._context = null; } initialize() { if (this._initialized) return; const t3 = this._context.capabilities.vao; if (t3) { const e = t3.createVertexArray(); t3.bindVertexArray(e), this._bindLayout(), t3.bindVertexArray(null), this._glName = e; } this._initialized = true; } bind() { this.initialize(); const t3 = this._context.capabilities.vao; t3 ? t3.bindVertexArray(this.glName) : (this._context.bindVAO(null), this._bindLayout()); } _bindLayout() { const { _buffers: t3, _layout: i3, _indexBuffer: r3 } = this; t3 || o3.error("Vertex buffer dictionary is empty!"); const n3 = this._context.gl; for (const e in t3) { const r4 = t3[e]; r4 || o3.error("Vertex buffer is uninitialized!"); const n4 = i3[e]; n4 || o3.error("Vertex element descriptor is empty!"), R(this._context, this._locations, r4, n4); } if (r(r3)) { !!this._context.capabilities.vao ? n3.bindBuffer(n3.ELEMENT_ARRAY_BUFFER, r3.glName) : this._context.bindBuffer(r3); } } unbind() { this.initialize(); const t3 = this._context.capabilities.vao; t3 ? t3.bindVertexArray(null) : this._unbindLayout(); } _unbindLayout() { const { _buffers: t3, _layout: i3 } = this; t3 || o3.error("Vertex buffer dictionary is empty!"); for (const e in t3) { const r3 = t3[e]; r3 || o3.error("Vertex buffer is uninitialized!"); const s5 = i3[e]; E(this._context, this._locations, r3, s5); } r(this._indexBuffer) && this._context.unbindBuffer(this._indexBuffer.bufferType); } }; // node_modules/@arcgis/core/views/webgl/Renderbuffer.js var r2 = class { constructor(r3, s5) { this._context = r3, this._desc = s5, this.type = "renderbuffer", this._context.instanceCounter.increment(t2.Renderbuffer, this); const i3 = this._context.gl; this.glName = i3.createRenderbuffer(), this._context.bindRenderbuffer(this); const { width: n3, height: h, internalFormat: o4, multisampled: a2 } = s5; if (a2) { if (this._context.type !== o.WEBGL2) throw new Error("Multisampled renderbuffers are not supported in WebGL1!"); i3.renderbufferStorageMultisample(i3.RENDERBUFFER, this.samples, o4, n3, h); } else i3.renderbufferStorage(i3.RENDERBUFFER, o4, n3, h); } get descriptor() { return this._desc; } get samples() { const e = this._desc.samples, t3 = this._context.parameters.maxSamples; return e ? Math.min(e, t3) : t3; } resize(e, t3) { const r3 = this._desc; if (r3.width === e && r3.height === t3) return; r3.width = e, r3.height = t3; const s5 = this._context.gl; if (this._context.bindRenderbuffer(this), r3.multisampled) { s5.renderbufferStorageMultisample(s5.RENDERBUFFER, this.samples, r3.internalFormat, r3.width, r3.height); } else s5.renderbufferStorage(s5.RENDERBUFFER, r3.internalFormat, r3.width, r3.height); } dispose() { this._context && (this._context.gl.deleteRenderbuffer(this.glName), this._context.instanceCounter.decrement(t2.Renderbuffer, this), this._context = null); } }; // node_modules/@arcgis/core/views/webgl/FramebufferObject.js var b2 = s3.getLogger("esri.views.webgl.FrameBufferObject"); var D2 = class { constructor(t3, i3, r3 = null, s5 = null) { if (this._context = t3, this._glName = null, this._depthAttachment = null, this._stencilAttachment = null, this._colorAttachments = new Map(), this._initialized = false, this._desc = { ...i3 }, t3.instanceCounter.increment(t2.FramebufferObject, this), r(r3)) { Array.isArray(r3) || (r3 = [r3]); for (let t4 = 0; t4 < r3.length; ++t4) { const e = r3[t4], i4 = f.COLOR_ATTACHMENT0 + t4; let s6; U2(e) ? (C2(e) ? (s6 = e.descriptor, this._colorAttachments.set(i4, e)) : (s6 = e, this._colorAttachments.set(i4, new u3(this._context, s6))), P2(s6, this._desc)) : (S(e) ? (s6 = e.descriptor, this._colorAttachments.set(i4, e)) : (s6 = e, this._colorAttachments.set(i4, new r2(this._context, s6))), B2(s6, this._desc)), this._validateColorAttachmentPoint(i4); } } if (r(s5)) { let t4, e; if (U2(s5)) this._context.capabilities.depthTexture || console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"), C2(s5) ? (e = s5.descriptor, this._depthStencilTexture = s5) : (e = s5, this._depthStencilTexture = new u3(this._context, e)), P2(e, this._desc); else { S(s5) ? (e = s5.descriptor, t4 = s5) : (e = s5, t4 = new r2(this._context, e)); const i4 = this._desc.depthStencilTarget ?? V.DEPTH_STENCIL_RENDER_BUFFER; i4 === V.STENCIL_RENDER_BUFFER ? this._stencilAttachment = t4 : i4 === V.DEPTH_RENDER_BUFFER || i4 === V.DEPTH_STENCIL_RENDER_BUFFER ? this._depthAttachment = t4 : console.error('If a Renderbuffer is provided, "depthStencilTarget" must be one of STENCIL_RENDER_BUFFER, DEPTH_RENDER_BUFFER or DEPTH_STENCIL_RENDER_BUFFER'), B2(e, this._desc); } } } dispose() { if (!this._desc) return; const t3 = this._context.getBoundFramebufferObject(); if (this._disposeColorAttachments(), this._disposeDepthStencilAttachments(), this._glName) { this._context.gl.deleteFramebuffer(this._glName), this._glName = null; } this._context.bindFramebuffer(t3), this._context.instanceCounter.decrement(t2.FramebufferObject, this), this._desc = null; } get glName() { return this._glName; } get descriptor() { return this._desc; } get colorTexture() { const t3 = this._colorAttachments.get(f.COLOR_ATTACHMENT0); return t3 && C2(t3) ? t3 : null; } get colorAttachment() { return this._colorAttachments.get(f.COLOR_ATTACHMENT0); } get depthStencilAttachment() { return this._depthStencilTexture || this._depthAttachment || this._stencilAttachment; } get depthStencilTexture() { return this._depthStencilTexture; } get width() { return this._desc.width; } get height() { return this._desc.height; } get gpuMemoryUsage() { return [...this._colorAttachments].reduce((t3, [e, i3]) => t3 + u4(i3), 0) + u4(this.depthStencilAttachment); } getColorTexture(t3) { const e = this._colorAttachments.get(t3); return e && C2(e) ? e : null; } attachColorTexture(t3, e = f.COLOR_ATTACHMENT0) { if (!t3) return; this._validateColorAttachmentPoint(e); P2(t3.descriptor, this._desc), this._disposeColorAttachments(), this._initialized && (this._context.bindFramebuffer(this), this._framebufferTexture2D(t3.glName, e)), this._colorAttachments.set(e, t3); } detachColorTexture(t3 = f.COLOR_ATTACHMENT0) { const e = this._colorAttachments.get(t3); if (C2(e)) { const i3 = e; return this._initialized && (this._context.bindFramebuffer(this), this._framebufferTexture2D(null, t3)), this._colorAttachments.delete(t3), i3; } } setColorTextureTarget(t3, e = f.COLOR_ATTACHMENT0) { const i3 = this._colorAttachments.get(e); C2(i3) && this._framebufferTexture2D(i3.glName, e, t3); } attachDepthStencilTexture(t3) { if (t(t3)) return; const e = t3.descriptor; e.pixelFormat !== P.DEPTH_STENCIL && console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"), e.dataType !== G.UNSIGNED_INT_24_8 && console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"), this._context.capabilities.depthTexture || console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"), P2(e, this._desc), this._desc.depthStencilTarget && this._desc.depthStencilTarget !== V.DEPTH_STENCIL_TEXTURE && (this._desc.depthStencilTarget = V.DEPTH_STENCIL_TEXTURE), this._disposeDepthStencilAttachments(), this._initialized && (this._context.bindFramebuffer(this), this._framebufferTexture2D(t3.glName, c)), this._depthStencilTexture = t3; } detachDepthStencilTexture() { const t3 = this._depthStencilTexture; return t3 && this._initialized && (this._context.bindFramebuffer(this), this._framebufferTexture2D(null, c)), this._depthStencilTexture = null, t3; } attachDepthStencilBuffer(t3) { if (t(t3)) return; const e = t3.descriptor; if (e.internalFormat !== B.DEPTH_STENCIL && e.internalFormat !== B.DEPTH_COMPONENT16 && console.error("Depth/Stencil buffer must have correct internalFormat"), B2(e, this._desc), this._disposeDepthStencilAttachments(), this._desc.depthStencilTarget = e.internalFormat === B.DEPTH_STENCIL ? V.DEPTH_STENCIL_RENDER_BUFFER : V.DEPTH_RENDER_BUFFER, this._initialized) { this._context.bindFramebuffer(this); const e2 = this._context.gl, i3 = this._desc.depthStencilTarget === V.DEPTH_RENDER_BUFFER ? e2.DEPTH_ATTACHMENT : e2.DEPTH_STENCIL_ATTACHMENT; e2.framebufferRenderbuffer(n.FRAMEBUFFER, i3, e2.RENDERBUFFER, t3.glName); } this._depthAttachment = t3; } detachDepthStencilBuffer() { const t3 = this._context.gl, e = this._depthAttachment; if (e && this._initialized) { this._context.bindFramebuffer(this); const e2 = this._desc.depthStencilTarget === V.DEPTH_RENDER_BUFFER ? t3.DEPTH_ATTACHMENT : t3.DEPTH_STENCIL_ATTACHMENT; t3.framebufferRenderbuffer(n.FRAMEBUFFER, e2, t3.RENDERBUFFER, null); } return this._depthAttachment = null, e; } detachAll() { this._colorAttachments.forEach((t3, e) => this._detachColorAttachment(e)), this.detachDepthStencilBuffer(), this.detachDepthStencilTexture(); } copyToTexture(t3, e, i3, r3, s5, h, n3) { (t3 < 0 || e < 0 || s5 < 0 || h < 0) && console.error("Offsets cannot be negative!"), (i3 <= 0 || r3 <= 0) && console.error("Copy width and height must be greater than zero!"); const c4 = this._desc, o4 = n3.descriptor; n3.descriptor.target !== M.TEXTURE_2D && console.error("Texture target must be TEXTURE_2D!"), (t3 + i3 > c4.width || e + r3 > c4.height || s5 + i3 > o4.width || h + r3 > o4.height) && console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!"); const _3 = this._context, a2 = _3.bindTexture(n3, u3.TEXTURE_UNIT_FOR_UPDATES); _3.setActiveTexture(u3.TEXTURE_UNIT_FOR_UPDATES), _3.bindFramebuffer(this), _3.gl.copyTexSubImage2D(M.TEXTURE_2D, 0, s5, h, t3, e, i3, r3), _3.bindTexture(a2, u3.TEXTURE_UNIT_FOR_UPDATES); } readPixels(t3, e, i3, r3, s5, h, n3) { (i3 <= 0 || r3 <= 0) && console.error("Copy width and height must be greater than zero!"), n3 || console.error("Target memory is not initialized!"), this._context.bindFramebuffer(this); this._context.gl.readPixels(t3, e, i3, r3, s5, h, n3); } async readPixelsAsync(t3, e, i3, h, c4, o4, _3) { if (this._context.type !== o.WEBGL2) return u2() && console.warn("Attempting to read pixels using pixel buffer object without WebGL2"), void this.readPixels(t3, e, i3, h, c4, o4, _3); const a2 = this._context.gl, l = c3.createPixelPack(this._context, F.STREAM_READ, _3.byteLength); this._context.bindBuffer(l), this._context.bindFramebuffer(this), a2.readPixels(t3, e, i3, h, c4, o4, 0), this._context.unbindBuffer(A.PIXEL_PACK_BUFFER), await l.getSubDataAsync(_3), l.dispose(); } resize(t3, e) { const i3 = this._desc; if (i3.width !== t3 || i3.height !== e) { if (!this._initialized) return i3.width = t3, i3.height = e, this._colorAttachments.forEach((i4) => { i4 && i4.resize(t3, e); }), void (this._depthStencilTexture && this._depthStencilTexture.resize(t3, e)); i3.width = t3, i3.height = e, this._colorAttachments.forEach((i4) => { i4 && i4.resize(t3, e); }), this._depthStencilTexture != null ? this._depthStencilTexture.resize(t3, e) : (this._depthAttachment || this._stencilAttachment) && (this._depthAttachment && this._depthAttachment.resize(t3, e), this._stencilAttachment && this._stencilAttachment.resize(t3, e)), this._context.getBoundFramebufferObject() === this && this._context.bindFramebuffer(null), this._initialized = false; } } initializeAndBind(t3 = n.FRAMEBUFFER) { const e = this._context.gl; if (this._initialized) return void e.bindFramebuffer(t3, this.glName); this._glName && e.deleteFramebuffer(this._glName); const i3 = this._context, r3 = e.createFramebuffer(), s5 = this._desc, n3 = s5.colorTarget ?? Y.RENDER_BUFFER, c4 = s5.width ?? 1, T = s5.height ?? 1; if (e.bindFramebuffer(t3, r3), this._colorAttachments.size === 0) if (n3 === Y.TEXTURE || n3 === Y.CUBEMAP) this._colorAttachments.set(f.COLOR_ATTACHMENT0, H(i3, s5, this.descriptor.colorTarget === Y.CUBEMAP ? M.TEXTURE_CUBE_MAP : M.TEXTURE_2D)); else { const t4 = new r2(i3, { internalFormat: U.RGBA4, width: c4, height: T }); this._colorAttachments.set(f.COLOR_ATTACHMENT0, t4); } this._colorAttachments.forEach((i4, r4) => { i4 && (C2(i4) ? this._framebufferTexture2D(i4.glName, r4, M2(i4), t3) : e.framebufferRenderbuffer(t3, r4, e.RENDERBUFFER, i4.glName)); }); const f3 = s5.depthStencilTarget ?? V.NONE; switch (f3) { case V.DEPTH_RENDER_BUFFER: case V.DEPTH_STENCIL_RENDER_BUFFER: { this._depthAttachment || (this._depthAttachment = new r2(i3, { internalFormat: s5.depthStencilTarget === V.DEPTH_RENDER_BUFFER ? B.DEPTH_COMPONENT16 : B.DEPTH_STENCIL, width: c4, height: T })); const r4 = f3 === V.DEPTH_RENDER_BUFFER ? e.DEPTH_ATTACHMENT : e.DEPTH_STENCIL_ATTACHMENT; e.framebufferRenderbuffer(t3, r4, e.RENDERBUFFER, this._depthAttachment.glName); break; } case V.STENCIL_RENDER_BUFFER: this._stencilAttachment || (this._stencilAttachment = new r2(i3, { internalFormat: B.STENCIL_INDEX8, width: c4, height: T })), e.framebufferRenderbuffer(t3, e.STENCIL_ATTACHMENT, e.RENDERBUFFER, this._stencilAttachment.glName); break; case V.DEPTH_STENCIL_TEXTURE: if (!this._depthStencilTexture) { i3.capabilities.depthTexture || console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture as an attachment!"); const t4 = { target: M.TEXTURE_2D, pixelFormat: P.DEPTH_STENCIL, dataType: G.UNSIGNED_INT_24_8, samplingMode: L.NEAREST, wrapMode: D.CLAMP_TO_EDGE, width: c4, height: T }; this._depthStencilTexture = new u3(i3, t4); } this._framebufferTexture2D(this._depthStencilTexture.glName, e.DEPTH_STENCIL_ATTACHMENT, M2(this._depthStencilTexture), t3); } if (c2()) { e.checkFramebufferStatus(t3) !== e.FRAMEBUFFER_COMPLETE && console.error("Framebuffer is incomplete!"); } this._glName = r3, this._initialized = true; } _framebufferTexture2D(t3, e = f.COLOR_ATTACHMENT0, i3 = M.TEXTURE_2D, r3 = n.FRAMEBUFFER, s5 = 0) { this._context.gl.framebufferTexture2D(r3, e, i3, t3, s5); } _detachColorAttachment(t3) { u2() && console.warn("Detaching an FBO attachment can be a slow due to invalidating framebuffer completeness!"); const e = this._context.gl, i3 = this._colorAttachments.get(t3); return C2(i3) ? this._initialized && (this._context.bindFramebuffer(this), this._framebufferTexture2D(null, t3)) : this._initialized && (this._context.bindFramebuffer(this), e.framebufferRenderbuffer(n.FRAMEBUFFER, t3, e.RENDERBUFFER, null)), this._colorAttachments.delete(t3), i3; } _disposeColorAttachments() { this._colorAttachments.forEach((t3, e) => { this._detachColorAttachment(e), t3.dispose(); }), this._colorAttachments.clear(); } _disposeDepthStencilAttachments() { const t3 = this._context.gl; if (this._depthAttachment) { if (this._initialized) { this._context.bindFramebuffer(this); const e = this._desc.depthStencilTarget === V.DEPTH_RENDER_BUFFER ? t3.DEPTH_ATTACHMENT : t3.DEPTH_STENCIL_ATTACHMENT; t3.framebufferRenderbuffer(n.FRAMEBUFFER, e, t3.RENDERBUFFER, null); } this._depthAttachment.dispose(), this._depthAttachment = null; } this._stencilAttachment && (this._initialized && (this._context.bindFramebuffer(this), t3.framebufferRenderbuffer(n.FRAMEBUFFER, t3.STENCIL_ATTACHMENT, t3.RENDERBUFFER, null)), this._stencilAttachment.dispose(), this._stencilAttachment = null), this._depthStencilTexture && (this._initialized && (this._context.bindFramebuffer(this), this._framebufferTexture2D(null, t3.DEPTH_STENCIL_ATTACHMENT)), this._depthStencilTexture.dispose(), this._depthStencilTexture = null); } _validateColorAttachmentPoint(t3) { if (D2._MAX_COLOR_ATTACHMENTS === -1) { const t4 = this._context.capabilities.drawBuffers; if (t4) { const e2 = this._context.gl; D2._MAX_COLOR_ATTACHMENTS = e2.getParameter(t4.MAX_COLOR_ATTACHMENTS); } else D2._MAX_COLOR_ATTACHMENTS = 1; } const e = t3 - f.COLOR_ATTACHMENT0; e + 1 > D2._MAX_COLOR_ATTACHMENTS && b2.error("esri.FrameBufferObject", `illegal attachment point for color attachment: ${e + 1}. Implementation supports up to ${D2._MAX_COLOR_ATTACHMENTS} color attachments`); } }; function C2(t3) { return "type" in t3 && t3.type === "texture"; } function S(t3) { return "type" in t3 && t3.type === "renderbuffer"; } function U2(t3) { return C2(t3) || "pixelFormat" in t3; } function H(t3, e, i3) { return new u3(t3, { target: i3, pixelFormat: P.RGBA, dataType: G.UNSIGNED_BYTE, samplingMode: L.NEAREST, wrapMode: D.CLAMP_TO_EDGE, width: e.width, height: e.height }); } function P2(t3, e) { t3.target !== M.TEXTURE_2D && t3.target !== M.TEXTURE_CUBE_MAP && console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"), e.width !== void 0 && e.width >= 0 && e.height !== void 0 && e.height >= 0 ? e.width === t3.width && e.height === t3.height || console.error("Color attachment texture must match the framebuffer's!") : (e.width = t3.width, e.height = t3.height); } function B2(t3, e) { e.width !== void 0 && e.width >= 0 && e.height !== void 0 && e.height >= 0 ? e.width === t3.width && e.height === t3.height || console.error("Renderbuffer dimensions must match the framebuffer's!") : (e.width = t3.width, e.height = t3.height); } function M2(t3) { return t3.descriptor.target === M.TEXTURE_CUBE_MAP ? M.TEXTURE_CUBE_MAP_POSITIVE_X : M.TEXTURE_2D; } D2._MAX_COLOR_ATTACHMENTS = -1; export { i2 as i, n2 as n, _2 as _, c3 as c, f2 as f, r2 as r, D2 as D }; //# sourceMappingURL=chunk-GDB2KX4Y.js.map