123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715 |
- import {
- E,
- a as a3,
- u as u2
- } from "./chunk-H2VOWDMO.js";
- import {
- A,
- B,
- C,
- D,
- F,
- G,
- L,
- M,
- P,
- U,
- V,
- Y,
- c,
- f,
- n,
- t as t2,
- u
- } from "./chunk-3OFVLRSL.js";
- import {
- r as r2
- } from "./chunk-RWQH5X3O.js";
- import {
- s2
- } from "./chunk-E5O6P5I2.js";
- import {
- a as a2,
- i2 as i,
- s2 as s
- } from "./chunk-2TIUKVZN.js";
- import {
- a,
- d,
- r,
- t
- } from "./chunk-YXWMMD76.js";
- // 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 / o(e.layout[r3]);
- }
- function o(e) {
- return e[0].stride;
- }
- function R(e, r3, t3, s4, a5 = 0) {
- const c3 = e.gl, i3 = e.capabilities.instancing;
- e.bindBuffer(t3);
- for (const n3 of s4) {
- const e2 = r3.get(n3.name);
- void 0 === e2 && console.error(`There is no location for vertex attribute '${n3.name}' defined.`);
- const t4 = a5 * n3.stride;
- if (n3.count <= 4)
- c3.vertexAttribPointer(e2, n3.count, n3.type, n3.normalized, n3.stride, n3.offset + t4), c3.enableVertexAttribArray(e2), n3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2, n3.divisor);
- else if (9 === n3.count)
- for (let r4 = 0; r4 < 3; r4++)
- c3.vertexAttribPointer(e2 + r4, 3, n3.type, n3.normalized, n3.stride, n3.offset + 12 * r4 + t4), c3.enableVertexAttribArray(e2 + r4), n3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2 + r4, n3.divisor);
- else if (16 === n3.count)
- for (let r4 = 0; r4 < 4; r4++)
- c3.vertexAttribPointer(e2 + r4, 4, n3.type, n3.normalized, n3.stride, n3.offset + 16 * r4 + t4), c3.enableVertexAttribArray(e2 + r4), n3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2 + r4, n3.divisor);
- else
- console.error("Unsupported vertex attribute element count: " + n3.count);
- }
- }
- function E2(e, t3, s4, a5) {
- const c3 = e.gl, i3 = e.capabilities.instancing;
- e.bindBuffer(s4);
- for (const r3 of a5) {
- const e2 = t3.get(r3.name);
- if (r3.count <= 4)
- c3.disableVertexAttribArray(e2), r3.divisor && r3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2, 0);
- else if (9 === r3.count)
- for (let t4 = 0; t4 < 3; t4++)
- c3.disableVertexAttribArray(e2 + t4), r3.divisor && r3.divisor > 0 && i3 && i3.vertexAttribDivisor(e2 + t4, 0);
- else if (16 === r3.count)
- for (let t4 = 0; t4 < 4; t4++)
- c3.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 _(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 u3(r3) {
- if (t(r3))
- return 0;
- if ("descriptor" in r3)
- return r3.glName ? u3(r3.descriptor) : 0;
- const t3 = r3.internalFormat || "pixelFormat" in r3 && r3.pixelFormat;
- if (!t3)
- return 0;
- const s4 = "hasMipmap" in r3 && r3.hasMipmap ? 1.3 : 1, a5 = r3.width * r3.height;
- return _(t3) * a5 * s4;
- }
- // node_modules/@arcgis/core/views/webgl/VertexArrayObject.js
- var f2 = s2.getLogger("esri.views.webgl.VertexArrayObject");
- var a4 = class {
- constructor(t3, e, i3, r3, n3 = null) {
- this._context = t3, this._locations = e, this._layout = i3, this._buffers = r3, 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) {
- var _a2, _b, _c;
- if (!this._context)
- return void ((this._glName || t3 && Object.getOwnPropertyNames(this._buffers).length > 0) && f2.warn("Leaked WebGL VAO"));
- if (this._glName) {
- const t4 = (_b = (_a2 = this._context) == null ? void 0 : _a2.capabilities) == null ? void 0 : _b.vao;
- t4 ? (t4.deleteVertexArray(this._glName), this._glName = null) : f2.warn("Leaked WebGL VAO");
- }
- if (this._context.getBoundVAO() === this && this._context.bindVAO(null), t3) {
- for (const t4 in this._buffers)
- (_c = this._buffers[t4]) == null ? void 0 : _c.dispose(), delete this._buffers[t4];
- this._indexBuffer = a(this._indexBuffer);
- }
- this._context.instanceCounter.decrement(t2.VertexArrayObject, this), this._context = d(this._context);
- }
- 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 || f2.error("Vertex buffer dictionary is empty!");
- const s4 = this._context.gl;
- for (const e in t3) {
- const r4 = t3[e];
- r4 || f2.error("Vertex buffer is uninitialized!");
- const s5 = i3[e];
- s5 || f2.error("Vertex element descriptor is empty!"), R(this._context, this._locations, r4, s5);
- }
- if (r(r3)) {
- !!this._context.capabilities.vao ? s4.bindBuffer(s4.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 || f2.error("Vertex buffer dictionary is empty!");
- for (const e in t3) {
- const r3 = t3[e];
- r3 || f2.error("Vertex buffer is uninitialized!");
- const s4 = i3[e];
- E2(this._context, this._locations, r3, s4);
- }
- r(this._indexBuffer) && this._context.unbindBuffer(this._indexBuffer.bufferType);
- }
- };
- // node_modules/@arcgis/core/views/webgl/BufferObject.js
- var c2 = s2.getLogger("esri.views.webgl.BufferObject");
- function b(t3) {
- return a2(t3);
- }
- var E3 = 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(), u2(this._context.gl), i3 && this.setData(i3);
- }
- static createIndex(e, t3, r3) {
- return new E3(e, A.ELEMENT_ARRAY_BUFFER, t3, r3);
- }
- static createVertex(e, t3, r3) {
- return new E3(e, A.ARRAY_BUFFER, t3, r3);
- }
- static createUniform(e, t3, r3) {
- if (e.type !== r2.WEBGL2)
- throw new Error("Uniform buffers are supported in WebGL2 only!");
- return new E3(e, A.UNIFORM_BUFFER, t3, r3);
- }
- static createPixelPack(e, t3 = F.STREAM_READ, r3) {
- if (e.type !== r2.WEBGL2)
- throw new Error("Pixel pack buffers are supported in WebGL2 only!");
- const i3 = new E3(e, A.PIXEL_PACK_BUFFER, t3);
- return r3 && i3.setSize(r3), i3;
- }
- static createPixelUnpack(e, t3 = F.STREAM_DRAW, r3) {
- if (e.type !== r2.WEBGL2)
- throw new Error("Pixel unpack buffers are supported in WebGL2 only!");
- return new E3(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() {
- var _a;
- if ((_a = this._context) == null ? void 0 : _a.gl) {
- if (this._glName) {
- this._context.gl.deleteBuffer(this._glName), this._glName = null;
- }
- this._context.instanceCounter.decrement(t2.BufferObject, this), this._context = d(this._context);
- } else
- this._glName && c2.warn("Leaked WebGL buffer object");
- }
- setSize(e, t3 = null) {
- if (e <= 0 && c2.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), s(e) && (t3 /= 4, this._indexType = C.UNSIGNED_INT)), this._setBufferData(t3, e);
- }
- _setBufferData(e, t3 = null) {
- this._size = e;
- const r3 = this._context.getBoundVAO();
- this._isVAOAware && this._context.bindVAO(null), this._context.bindBuffer(this);
- const s4 = this._context.gl;
- r(t3) ? s4.bufferData(this.bufferType, t3, this.usage) : s4.bufferData(this.bufferType, e, this.usage), u2(s4), this._isVAOAware && this._context.bindVAO(r3);
- }
- setSubData(e, t3, r3, i3) {
- if (!e)
- return;
- (t3 < 0 || t3 >= this._size) && c2.error("offset is out of range!"), r3 >= i3 && c2.error("end must be bigger than start!"), t3 + (i3 - r3) > this._size && c2.error("An attempt to write beyond the end of the buffer!");
- const s4 = this._context.getBoundVAO();
- this._isVAOAware && this._context.bindVAO(null), this._context.bindBuffer(this);
- const n3 = this._context.gl;
- if (this._context.type === r2.WEBGL2)
- n3.bufferSubData(this.bufferType, t3 * e.BYTES_PER_ELEMENT, e, r3, i3 - r3);
- else {
- const s5 = 0 === r3 && i3 === e.length ? e : e.subarray(r3, i3);
- n3.bufferSubData(this.bufferType, t3 * e.BYTES_PER_ELEMENT, s5);
- }
- u2(n3), this._isVAOAware && this._context.bindVAO(s4);
- }
- getSubData(e, t3 = 0, r3, i3) {
- if (this._context.type !== r2.WEBGL2)
- return void c2.error("Get buffer subdata is supported in WebGL2 only!");
- if (r3 < 0 || i3 < 0)
- return void c2.error("Problem getting subdata: offset and length were less than zero!");
- const s4 = b(e) ? e.BYTES_PER_ELEMENT : 1;
- if (s4 * ((r3 != null ? r3 : 0) + (i3 != null ? i3 : 0)) > e.byteLength)
- return void c2.error("Problem getting subdata: offset and length exceeded destination size!");
- t3 + s4 * (i3 != null ? i3 : 0) > this.byteSize && c2.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 === r2.WEBGL2 ? (await this._context.clientWaitAsync(), this.getSubData(e, t3, r3, i3)) : c2.error("Get buffer subdata is supported in WebGL2 only!");
- }
- };
- // node_modules/@arcgis/core/views/webgl/Renderbuffer.js
- var s3 = class {
- constructor(e, s4) {
- this._context = e, this._desc = s4, 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: o2, internalFormat: h, multisampled: c3 } = s4;
- if (c3) {
- if (this._context.type !== r2.WEBGL2)
- throw new Error("Multisampled renderbuffers are not supported in WebGL1!");
- i3.renderbufferStorageMultisample(i3.RENDERBUFFER, this.samples, h, n3, o2);
- } else
- i3.renderbufferStorage(i3.RENDERBUFFER, h, n3, o2);
- }
- 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 s4 = this._context.gl;
- if (this._context.bindRenderbuffer(this), r3.multisampled) {
- s4.renderbufferStorageMultisample(s4.RENDERBUFFER, this.samples, r3.internalFormat, r3.width, r3.height);
- } else
- s4.renderbufferStorage(s4.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 = d(this._context));
- }
- };
- // node_modules/@arcgis/core/views/webgl/FramebufferObject.js
- var x = class {
- constructor(t3, i3, r3 = null, h = null) {
- var _a;
- if (this._context = t3, this._glName = null, this._depthAttachment = null, this._stencilAttachment = null, this._colorAttachments = /* @__PURE__ */ new Map(), this._depthStencilTexture = null, 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 h2;
- C2(e) ? (b2(e) ? (h2 = e.descriptor, this._colorAttachments.set(i4, e)) : (h2 = e, this._colorAttachments.set(i4, new E(this._context, h2))), U2(h2, this._desc)) : (D2(e) ? (h2 = e.descriptor, this._colorAttachments.set(i4, e)) : (h2 = e, this._colorAttachments.set(i4, new s3(this._context, h2))), H(h2, this._desc)), this._validateColorAttachmentPoint(i4);
- }
- }
- if (r(h)) {
- let t4, e;
- if (C2(h))
- this._context.capabilities.depthTexture || console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"), b2(h) ? (e = h.descriptor, this._depthStencilTexture = h) : (e = h, this._depthStencilTexture = new E(this._context, e)), U2(e, this._desc);
- else {
- D2(h) ? (e = h.descriptor, t4 = h) : (e = h, t4 = new s3(this._context, e));
- const i4 = (_a = this._desc.depthStencilTarget) != null ? _a : 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'), this._desc.depthStencilTarget = i4, H(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 && b2(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() {
- var _a;
- return (_a = this._desc.width) != null ? _a : 0;
- }
- get height() {
- var _a;
- return (_a = this._desc.height) != null ? _a : 0;
- }
- get gpuMemoryUsage() {
- return [...this._colorAttachments].reduce((t3, [e, i3]) => t3 + u3(i3), 0) + u3(this.depthStencilAttachment);
- }
- getColorTexture(t3) {
- const e = this._colorAttachments.get(t3);
- return e && b2(e) ? e : null;
- }
- attachColorTexture(t3, e = f.COLOR_ATTACHMENT0) {
- if (!t3)
- return;
- this._validateColorAttachmentPoint(e);
- U2(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 (b2(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);
- b2(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!"), U2(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"), H(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, h, s4, n3) {
- (t3 < 0 || e < 0 || h < 0 || s4 < 0) && console.error("Offsets cannot be negative!"), (i3 <= 0 || r3 <= 0) && console.error("Copy width and height must be greater than zero!");
- const c3 = this._desc, o2 = n3.descriptor;
- n3.descriptor.target !== M.TEXTURE_2D && console.error("Texture target must be TEXTURE_2D!"), (null == (c3 == null ? void 0 : c3.width) || null == (c3 == null ? void 0 : c3.height) || null == (o2 == null ? void 0 : o2.width) || null == (o2 == null ? void 0 : o2.height) || t3 + i3 > c3.width || e + r3 > c3.height || h + i3 > o2.width || s4 + r3 > o2.height) && console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");
- const _2 = this._context, a5 = _2.bindTexture(n3, E.TEXTURE_UNIT_FOR_UPDATES);
- _2.setActiveTexture(E.TEXTURE_UNIT_FOR_UPDATES), _2.bindFramebuffer(this), _2.gl.copyTexSubImage2D(M.TEXTURE_2D, 0, h, s4, t3, e, i3, r3), _2.bindTexture(a5, E.TEXTURE_UNIT_FOR_UPDATES);
- }
- readPixels(t3, e, i3, r3, h, s4, 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, h, s4, n3);
- }
- async readPixelsAsync(t3, e, i3, n3, c3, o2, _2) {
- if (this._context.type !== r2.WEBGL2)
- return a3() && console.warn("Attempting to read pixels using pixel buffer object without WebGL2"), void this.readPixels(t3, e, i3, n3, c3, o2, _2);
- const a5 = this._context.gl, l = E3.createPixelPack(this._context, F.STREAM_READ, _2.byteLength);
- this._context.bindBuffer(l), this._context.bindFramebuffer(this), a5.readPixels(t3, e, i3, n3, c3, o2, 0), this._context.unbindBuffer(A.PIXEL_PACK_BUFFER), await l.getSubDataAsync(_2), 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);
- }), null != this._depthStencilTexture ? 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) {
- var _a, _b, _c, _d;
- 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(), s4 = this._desc, n3 = (_a = s4.colorTarget) != null ? _a : Y.RENDER_BUFFER, l = (_b = s4.width) != null ? _b : 1, u4 = (_c = s4.height) != null ? _c : 1;
- if (e.bindFramebuffer(t3, r3), 0 === this._colorAttachments.size)
- if (n3 === Y.TEXTURE || n3 === Y.CUBEMAP)
- this._colorAttachments.set(f.COLOR_ATTACHMENT0, S(i3, s4, this.descriptor.colorTarget === Y.CUBEMAP ? M.TEXTURE_CUBE_MAP : M.TEXTURE_2D));
- else {
- const t4 = new s3(i3, { internalFormat: U.RGBA4, width: l, height: u4 });
- this._colorAttachments.set(f.COLOR_ATTACHMENT0, t4);
- }
- this._colorAttachments.forEach((i4, r4) => {
- i4 && (b2(i4) ? this._framebufferTexture2D(i4.glName, r4, P2(i4), t3) : e.framebufferRenderbuffer(t3, r4, e.RENDERBUFFER, i4.glName));
- });
- const f3 = (_d = s4.depthStencilTarget) != null ? _d : V.NONE;
- switch (f3) {
- case V.DEPTH_RENDER_BUFFER:
- case V.DEPTH_STENCIL_RENDER_BUFFER: {
- this._depthAttachment || (this._depthAttachment = new s3(i3, { internalFormat: s4.depthStencilTarget === V.DEPTH_RENDER_BUFFER ? B.DEPTH_COMPONENT16 : B.DEPTH_STENCIL, width: l, height: u4 }));
- 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 s3(i3, { internalFormat: B.STENCIL_INDEX8, width: l, height: u4 })), 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: l, height: u4 };
- this._depthStencilTexture = new E(i3, t4);
- }
- this._framebufferTexture2D(this._depthStencilTexture.glName, e.DEPTH_STENCIL_ATTACHMENT, P2(this._depthStencilTexture), t3);
- }
- if (a3()) {
- 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, h = 0) {
- this._context.gl.framebufferTexture2D(r3, e, i3, t3, h);
- }
- _detachColorAttachment(t3) {
- a3() && 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 b2(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(e) {
- if (-1 === x._MAX_COLOR_ATTACHMENTS) {
- const t3 = this._context.capabilities.drawBuffers;
- if (t3) {
- const e2 = this._context.gl;
- x._MAX_COLOR_ATTACHMENTS = e2.getParameter(t3.MAX_COLOR_ATTACHMENTS);
- } else
- x._MAX_COLOR_ATTACHMENTS = 1;
- }
- const i3 = e - f.COLOR_ATTACHMENT0;
- i3 + 1 > x._MAX_COLOR_ATTACHMENTS && s2.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject", `illegal attachment point for color attachment: ${i3 + 1}. Implementation supports up to ${x._MAX_COLOR_ATTACHMENTS} color attachments`);
- }
- };
- function b2(t3) {
- return null != t3 && "type" in t3 && "texture" === t3.type;
- }
- function D2(t3) {
- return null != t3 && "type" in t3 && "renderbuffer" === t3.type;
- }
- function C2(t3) {
- return b2(t3) || null != t3 && "pixelFormat" in t3;
- }
- function S(t3, e, i3) {
- return new E(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 U2(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!"), void 0 !== e.width && e.width >= 0 && void 0 !== e.height && 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 H(t3, e) {
- void 0 !== e.width && e.width >= 0 && void 0 !== e.height && 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 P2(t3) {
- return t3.descriptor.target === M.TEXTURE_CUBE_MAP ? M.TEXTURE_CUBE_MAP_POSITIVE_X : M.TEXTURE_2D;
- }
- x._MAX_COLOR_ATTACHMENTS = -1;
- export {
- i2 as i,
- n2 as n,
- _,
- a4 as a,
- E3 as E,
- s3 as s,
- x
- };
- //# sourceMappingURL=chunk-WBWQJQK4.js.map
|