@cosmos.gl/graph 2.6.2 → 2.7.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +2 -2
- package/dist/graph/utils/error-message.d.ts +1 -1
- package/dist/helper.d.ts +39 -2
- package/dist/index-B1_1MjaX.js +19917 -0
- package/dist/index-B1_1MjaX.js.map +1 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +14 -14658
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1068 -469
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Clusters/index.d.ts +11 -6
- package/dist/modules/ForceCenter/index.d.ts +10 -3
- package/dist/modules/ForceGravity/index.d.ts +5 -1
- package/dist/modules/ForceLink/index.d.ts +8 -5
- package/dist/modules/ForceManyBody/index.d.ts +16 -7
- package/dist/modules/ForceMouse/index.d.ts +5 -1
- package/dist/modules/Lines/index.d.ts +11 -5
- package/dist/modules/Points/index.d.ts +30 -14
- package/dist/modules/Store/index.d.ts +93 -0
- package/dist/modules/core-module.d.ts +3 -3
- package/dist/webgl-device-DzkMihDq.js +3923 -0
- package/dist/webgl-device-DzkMihDq.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-device-DzkMihDq.js","sources":["../node_modules/@probe.gl/env/dist/lib/get-browser.js","../node_modules/@luma.gl/core/dist/utils/promise-utils.js","../node_modules/@luma.gl/core/dist/adapter/canvas-context.js","../node_modules/@luma.gl/core/dist/adapter/resources/framebuffer.js","../node_modules/@luma.gl/core/dist/adapter/resources/render-pass.js","../node_modules/@luma.gl/core/dist/adapter/resources/command-encoder.js","../node_modules/@luma.gl/core/dist/adapter/resources/command-buffer.js","../node_modules/@luma.gl/core/dist/adapter/resources/vertex-array.js","../node_modules/@luma.gl/core/dist/adapter/resources/transform-feedback.js","../node_modules/@luma.gl/core/dist/adapter/resources/query-set.js","../node_modules/@luma.gl/webgl/dist/context/parameters/webgl-parameter-tables.js","../node_modules/@luma.gl/webgl/dist/context/parameters/unified-parameter-api.js","../node_modules/@luma.gl/webgl/dist/context/state-tracker/deep-array-equal.js","../node_modules/@luma.gl/webgl/dist/context/state-tracker/webgl-state-tracker.js","../node_modules/@luma.gl/webgl/dist/context/helpers/create-browser-context.js","../node_modules/@luma.gl/webgl/dist/context/helpers/webgl-extensions.js","../node_modules/@luma.gl/webgl/dist/adapter/device-helpers/webgl-device-info.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-vertex-formats.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-texture-table.js","../node_modules/@luma.gl/webgl/dist/adapter/device-helpers/webgl-device-features.js","../node_modules/@luma.gl/webgl/dist/adapter/device-helpers/webgl-device-limits.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-framebuffer.js","../node_modules/@luma.gl/webgl/dist/adapter/webgl-canvas-context.js","../node_modules/@luma.gl/webgl/dist/utils/uid.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-buffer.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/parse-shader-compiler-log.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-shader.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/device-parameters.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/sampler-parameters.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-sampler.js","../node_modules/@luma.gl/webgl/dist/context/state-tracker/with-parameters.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-texture-view.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-texture.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/webgl-shadertypes.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/get-shader-layout-from-glsl.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/set-uniform.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/webgl-topology-utils.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-render-pipeline.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-command-buffer.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-render-pass.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-command-encoder.js","../node_modules/@luma.gl/webgl/dist/utils/fill-array.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-vertex-array.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-transform-feedback.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-query-set.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/format-utils.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/shader-formats.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/webgl-texture-utils.js","../node_modules/@luma.gl/webgl/dist/adapter/webgl-device.js"],"sourcesContent":["// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n// This function is needed in initialization stages,\n// make sure it can be imported in isolation\nimport { isBrowser } from \"./is-browser.js\";\nimport { isElectron } from \"./is-electron.js\";\nimport { navigator } from \"./globals.js\";\nexport function isMobile() {\n return typeof globalThis.orientation !== 'undefined';\n}\n// Simple browser detection\n// `mockUserAgent` parameter allows user agent to be overridden for testing\n/* eslint-disable complexity */\nexport function getBrowser(mockUserAgent) {\n if (!mockUserAgent && !isBrowser()) {\n return 'Node';\n }\n if (isElectron(mockUserAgent)) {\n return 'Electron';\n }\n const userAgent = mockUserAgent || navigator.userAgent || '';\n // NOTE: Order of tests matter, as many agents list Chrome etc.\n if (userAgent.indexOf('Edge') > -1) {\n return 'Edge';\n }\n if (globalThis.chrome) {\n return 'Chrome';\n }\n if (globalThis.safari) {\n return 'Safari';\n }\n if (globalThis.mozInnerScreenX) {\n return 'Firefox';\n }\n return 'Unknown';\n}\n//# sourceMappingURL=get-browser.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// TODO - replace with Promise.withResolvers once we upgrade TS baseline\nexport function withResolvers() {\n let resolve;\n let reject;\n const promise = new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n // @ts-expect-error - in fact these are no used before initialized\n return { promise, resolve, reject };\n}\n//# sourceMappingURL=promise-utils.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { isBrowser } from '@probe.gl/env';\nimport { uid } from \"../utils/uid.js\";\nimport { withResolvers } from \"../utils/promise-utils.js\";\n/**\n * Manages a canvas. Supports both HTML or offscreen canvas\n * - Creates a new canvas or looks up a canvas from the DOM\n * - Provides check for DOM loaded\n * @todo commit() @see https://github.com/w3ctag/design-reviews/issues/288\n * @todo transferControlToOffscreen: @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen\n */\nexport class CanvasContext {\n static isHTMLCanvas(canvas) {\n return typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement;\n }\n static isOffscreenCanvas(canvas) {\n return typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas;\n }\n static defaultProps = {\n id: undefined,\n canvas: null,\n width: 800,\n height: 600,\n useDevicePixels: true,\n autoResize: true,\n container: null,\n visible: true,\n alphaMode: 'opaque',\n colorSpace: 'srgb',\n trackPosition: false\n };\n id;\n props;\n canvas;\n /** Handle to HTML canvas */\n htmlCanvas;\n /** Handle to wrapped OffScreenCanvas */\n offscreenCanvas;\n type;\n /** Promise that resolved once the resize observer has updated the pixel size */\n initialized;\n isInitialized = false;\n /** Visibility is automatically updated (via an IntersectionObserver) */\n isVisible = true;\n /** Width of canvas in CSS units (tracked by a ResizeObserver) */\n cssWidth;\n /** Height of canvas in CSS units (tracked by a ResizeObserver) */\n cssHeight;\n /** Device pixel ratio. Automatically updated via media queries */\n devicePixelRatio;\n /** Exact width of canvas in physical pixels (tracked by a ResizeObserver) */\n devicePixelWidth;\n /** Exact height of canvas in physical pixels (tracked by a ResizeObserver) */\n devicePixelHeight;\n /** Width of drawing buffer: automatically tracks this.pixelWidth if props.autoResize is true */\n drawingBufferWidth;\n /** Height of drawing buffer: automatically tracks this.pixelHeight if props.autoResize is true */\n drawingBufferHeight;\n _initializedResolvers = withResolvers();\n _resizeObserver;\n _intersectionObserver;\n _position;\n destroyed = false;\n toString() {\n return `${this[Symbol.toStringTag]}(${this.id})`;\n }\n constructor(props) {\n this.props = { ...CanvasContext.defaultProps, ...props };\n props = this.props;\n this.initialized = this._initializedResolvers.promise;\n // Create a canvas element if needed\n if (!isBrowser()) {\n // TODO - does this prevent app from using jsdom style polyfills?\n this.canvas = { width: props.width || 1, height: props.height || 1 };\n }\n else if (!props.canvas) {\n this.canvas = createCanvasElement(props);\n }\n else if (typeof props.canvas === 'string') {\n this.canvas = getCanvasFromDOM(props.canvas);\n }\n else {\n this.canvas = props.canvas;\n }\n if (CanvasContext.isHTMLCanvas(this.canvas)) {\n this.id = props.id || this.canvas.id;\n this.type = 'html-canvas';\n this.htmlCanvas = this.canvas;\n }\n else if (CanvasContext.isOffscreenCanvas(this.canvas)) {\n this.id = props.id || 'offscreen-canvas';\n this.type = 'offscreen-canvas';\n this.offscreenCanvas = this.canvas;\n }\n else {\n // TODO - Node.js support is currently untested (was used for headless-gl in luma v8)\n this.id = props.id || 'node-canvas-context';\n this.type = 'node';\n }\n // Initialize size variables to some sane values (these will be updated by ResizeObserver)\n this.cssWidth = this.htmlCanvas?.clientWidth || this.canvas.width;\n this.cssHeight = this.htmlCanvas?.clientHeight || this.canvas.height;\n this.devicePixelWidth = this.canvas.width;\n this.devicePixelHeight = this.canvas.height;\n this.drawingBufferWidth = this.canvas.width;\n this.drawingBufferHeight = this.canvas.height;\n this.devicePixelRatio = globalThis.devicePixelRatio || 1;\n this._position = [0, 0];\n if (CanvasContext.isHTMLCanvas(this.canvas)) {\n // Track visibility changes\n this._intersectionObserver = new IntersectionObserver(entries => this._handleIntersection(entries));\n this._intersectionObserver.observe(this.canvas);\n // Track size changes\n this._resizeObserver = new ResizeObserver(entries => this._handleResize(entries));\n try {\n this._resizeObserver.observe(this.canvas, { box: 'device-pixel-content-box' });\n }\n catch {\n // Safari fallback\n this._resizeObserver.observe(this.canvas, { box: 'content-box' });\n }\n // Track device pixel ratio changes.\n // Defer call to after construction completes to ensure `this.device` is available.\n setTimeout(() => this._observeDevicePixelRatio(), 0);\n // Track top/left position changes\n if (this.props.trackPosition) {\n this._trackPosition();\n }\n }\n }\n destroy() {\n this.destroyed = true;\n }\n setProps(props) {\n if ('useDevicePixels' in props) {\n this.props.useDevicePixels = props.useDevicePixels || false;\n this._updateDrawingBufferSize();\n }\n return this;\n }\n // SIZE METHODS\n /**\n * Returns the size covered by the canvas in CSS pixels\n * @note This can be different from the actual device pixel size of a canvas due to DPR scaling, and rounding to integer pixels\n * @note This is independent of the canvas' internal drawing buffer size (.width, .height).\n */\n getCSSSize() {\n return [this.cssWidth, this.cssHeight];\n }\n getPosition() {\n return this._position;\n }\n /**\n * Returns the size covered by the canvas in actual device pixels.\n * @note This can be different from the 'CSS' size of a canvas due to DPR scaling, and rounding to integer pixels\n * @note This is independent of the canvas' internal drawing buffer size (.width, .height).\n */\n getDevicePixelSize() {\n return [this.devicePixelWidth, this.devicePixelHeight];\n }\n /** Get the drawing buffer size (number of pixels GPU is rendering into, can be different from CSS size) */\n getDrawingBufferSize() {\n return [this.drawingBufferWidth, this.drawingBufferHeight];\n }\n /** Returns the biggest allowed framebuffer size. @todo Allow the application to limit this? */\n getMaxDrawingBufferSize() {\n const maxTextureDimension = this.device.limits.maxTextureDimension2D;\n return [maxTextureDimension, maxTextureDimension];\n }\n /** Update the canvas drawing buffer size. Called automatically if props.autoResize is true. */\n setDrawingBufferSize(width, height) {\n this.canvas.width = width;\n this.canvas.height = height;\n this.drawingBufferWidth = width;\n this.drawingBufferHeight = height;\n }\n /**\n * Returns the current DPR (number of physical pixels per CSS pixel), if props.useDevicePixels is true\n * @note This can be a fractional (non-integer) number, e.g. when the user zooms in the browser.\n * @note This function handles the non-HTML canvas cases\n */\n getDevicePixelRatio() {\n const dpr = typeof window !== 'undefined' && window.devicePixelRatio;\n return dpr || 1;\n }\n // DEPRECATED METHODS\n /**\n * Maps CSS pixel position to device pixel position\n */\n cssToDevicePixels(cssPixel, yInvert = true) {\n const ratio = this.cssToDeviceRatio();\n const [width, height] = this.getDrawingBufferSize();\n return scalePixels(cssPixel, ratio, width, height, yInvert);\n }\n /** @deprecated - use .getDevicePixelSize() */\n getPixelSize() {\n return this.getDevicePixelSize();\n }\n /** @deprecated - TODO which values should we use for aspect */\n getAspect() {\n const [width, height] = this.getDevicePixelSize();\n return width / height;\n }\n /** @deprecated Returns multiplier need to convert CSS size to Device size */\n cssToDeviceRatio() {\n try {\n const [drawingBufferWidth] = this.getDrawingBufferSize();\n const [cssWidth] = this.getCSSSize();\n return cssWidth ? drawingBufferWidth / cssWidth : 1;\n }\n catch {\n return 1;\n }\n }\n /** @deprecated Use canvasContext.setDrawingBufferSize() */\n resize(size) {\n this.setDrawingBufferSize(size.width, size.height);\n }\n // IMPLEMENTATION\n /**\n * Allows subclass constructor to override the canvas id for auto created canvases.\n * This can really help when debugging DOM in apps that create multiple devices\n */\n _setAutoCreatedCanvasId(id) {\n if (this.htmlCanvas?.id === 'lumagl-auto-created-canvas') {\n this.htmlCanvas.id = id;\n }\n }\n /** reacts to an observed intersection */\n _handleIntersection(entries) {\n const entry = entries.find(entry_ => entry_.target === this.canvas);\n if (!entry) {\n return;\n }\n // TODO - store intersection rectangle?\n const isVisible = entry.isIntersecting;\n if (this.isVisible !== isVisible) {\n this.isVisible = isVisible;\n this.device.props.onVisibilityChange(this);\n }\n }\n /**\n * Reacts to an observed resize by using the most accurate pixel size information the browser can provide\n * @see https://web.dev/articles/device-pixel-content-box\n * @see https://webgpufundamentals.org/webgpu/lessons/webgpu-resizing-the-canvas.html\n */\n _handleResize(entries) {\n const entry = entries.find(entry_ => entry_.target === this.canvas);\n if (!entry) {\n return;\n }\n // Update CSS size using content box size\n this.cssWidth = entry.contentBoxSize[0].inlineSize;\n this.cssHeight = entry.contentBoxSize[0].blockSize;\n // Update our drawing buffer size variables, saving the old values for logging\n const oldPixelSize = this.getDevicePixelSize();\n // Use the most accurate drawing buffer size information the current browser can provide\n // Note: content box sizes are guaranteed to be integers\n // Note: Safari falls back to contentBoxSize\n const devicePixelWidth = entry.devicePixelContentBoxSize?.[0].inlineSize ||\n entry.contentBoxSize[0].inlineSize * devicePixelRatio;\n const devicePixelHeight = entry.devicePixelContentBoxSize?.[0].blockSize ||\n entry.contentBoxSize[0].blockSize * devicePixelRatio;\n // Make sure we don't overflow the maximum supported texture size\n const [maxDevicePixelWidth, maxDevicePixelHeight] = this.getMaxDrawingBufferSize();\n this.devicePixelWidth = Math.max(1, Math.min(devicePixelWidth, maxDevicePixelWidth));\n this.devicePixelHeight = Math.max(1, Math.min(devicePixelHeight, maxDevicePixelHeight));\n this._updateDrawingBufferSize();\n // Inform the device\n this.device.props.onResize(this, { oldPixelSize });\n }\n _updateDrawingBufferSize() {\n // Update the canvas drawing buffer size\n if (this.props.autoResize) {\n if (typeof this.props.useDevicePixels === 'number') {\n const dpr = this.props.useDevicePixels;\n this.setDrawingBufferSize(this.cssWidth * dpr, this.cssHeight * dpr);\n }\n else if (this.props.useDevicePixels) {\n this.setDrawingBufferSize(this.devicePixelWidth, this.devicePixelHeight);\n }\n else {\n this.setDrawingBufferSize(this.cssWidth, this.cssHeight);\n }\n // Inform the subclass\n this._updateDevice();\n }\n // Resolve the initialized promise\n this._initializedResolvers.resolve();\n this.isInitialized = true;\n this.updatePosition();\n }\n /** Monitor DPR changes */\n _observeDevicePixelRatio() {\n const oldRatio = this.devicePixelRatio;\n this.devicePixelRatio = window.devicePixelRatio;\n this.updatePosition();\n // Inform the device\n this.device.props.onDevicePixelRatioChange(this, { oldRatio });\n // Set up a one time query against the current resolution.\n matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener('change', () => this._observeDevicePixelRatio(), { once: true });\n }\n /** Start tracking positions with a timer */\n _trackPosition(intervalMs = 100) {\n const intervalId = setInterval(() => {\n if (this.destroyed) {\n clearInterval(intervalId);\n }\n else {\n this.updatePosition();\n }\n }, intervalMs);\n }\n /**\n * Calculated the absolute position of the canvas\n * @note - getBoundingClientRect() is normally cheap but can be expensive\n * if called before browser has finished a reflow. Should not be the case here.\n */\n updatePosition() {\n const newRect = this.htmlCanvas?.getBoundingClientRect();\n if (newRect) {\n // We only track position since we rely on the more precise ResizeObserver for size\n const position = [newRect.left, newRect.top];\n this._position ??= position;\n const positionChanged = position[0] !== this._position[0] || position[1] !== this._position[1];\n if (positionChanged) {\n const oldPosition = this._position;\n this._position = position;\n this.device.props.onPositionChange?.(this, { oldPosition });\n }\n }\n }\n}\n// HELPER FUNCTIONS\n/** Get a container element from a string or DOM element */\nfunction getContainer(container) {\n if (typeof container === 'string') {\n const element = document.getElementById(container);\n if (!element) {\n throw new Error(`${container} is not an HTML element`);\n }\n return element;\n }\n if (container) {\n return container;\n }\n return document.body;\n}\n/** Get a Canvas element from DOM id */\nfunction getCanvasFromDOM(canvasId) {\n const canvas = document.getElementById(canvasId);\n if (!CanvasContext.isHTMLCanvas(canvas)) {\n throw new Error('Object is not a canvas element');\n }\n return canvas;\n}\n/** Create a new canvas */\nfunction createCanvasElement(props) {\n const { width, height } = props;\n const newCanvas = document.createElement('canvas');\n newCanvas.id = uid('lumagl-auto-created-canvas');\n newCanvas.width = width || 1;\n newCanvas.height = height || 1;\n newCanvas.style.width = Number.isFinite(width) ? `${width}px` : '100%';\n newCanvas.style.height = Number.isFinite(height) ? `${height}px` : '100%';\n if (!props?.visible) {\n newCanvas.style.visibility = 'hidden';\n }\n // Insert the canvas in the DOM\n const container = getContainer(props?.container || null);\n container.insertBefore(newCanvas, container.firstChild);\n return newCanvas;\n}\n/**\n * Scales pixels linearly, handles edge cases\n * @param pixel\n * @param ratio\n * @param width\n * @param height\n * @param yInvert\n * @returns\n */\nfunction scalePixels(pixel, ratio, width, height, yInvert) {\n const point = pixel;\n const x = scaleX(point[0], ratio, width);\n let y = scaleY(point[1], ratio, height, yInvert);\n // Find boundaries of next pixel to provide valid range of device pixel locations\n let t = scaleX(point[0] + 1, ratio, width);\n // If next pixel's position is clamped to boundary, use it as is, otherwise subtract 1 for current pixel boundary\n const xHigh = t === width - 1 ? t : t - 1;\n t = scaleY(point[1] + 1, ratio, height, yInvert);\n let yHigh;\n if (yInvert) {\n // If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range\n t = t === 0 ? t : t + 1;\n // swap y and yHigh\n yHigh = y;\n y = t;\n }\n else {\n // If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range\n yHigh = t === height - 1 ? t : t - 1;\n // y remains same\n }\n return {\n x,\n y,\n // when ratio < 1, current css pixel and next css pixel may point to same device pixel, set width/height to 1 in those cases.\n width: Math.max(xHigh - x + 1, 1),\n height: Math.max(yHigh - y + 1, 1)\n };\n}\nfunction scaleX(x, ratio, width) {\n // since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit\n const r = Math.min(Math.round(x * ratio), width - 1);\n return r;\n}\nfunction scaleY(y, ratio, height, yInvert) {\n // since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit\n return yInvert\n ? Math.max(0, height - 1 - Math.round(y * ratio))\n : Math.min(Math.round(y * ratio), height - 1);\n}\n//# sourceMappingURL=canvas-context.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Resource } from \"./resource.js\";\nimport { Texture } from \"./texture.js\";\nimport { log } from \"../../utils/log.js\";\n/**\n * Create new textures with correct size for all attachments.\n * @note resize() destroys existing textures (if size has changed).\n */\nexport class Framebuffer extends Resource {\n get [Symbol.toStringTag]() {\n return 'Framebuffer';\n }\n /** Width of all attachments in this framebuffer */\n width;\n /** Height of all attachments in this framebuffer */\n height;\n constructor(device, props = {}) {\n super(device, props, Framebuffer.defaultProps);\n this.width = this.props.width;\n this.height = this.props.height;\n }\n /**\n * Create a copy of this framebuffer with new attached textures, with same props but of the specified size.\n * @note Does not copy contents of the attached textures.\n */\n clone(size) {\n const colorAttachments = this.colorAttachments.map(colorAttachment => colorAttachment.texture.clone(size));\n const depthStencilAttachment = this.depthStencilAttachment && this.depthStencilAttachment.texture.clone(size);\n return this.device.createFramebuffer({ ...this.props, colorAttachments, depthStencilAttachment });\n }\n resize(size) {\n let updateSize = !size;\n if (size) {\n const [width, height] = Array.isArray(size) ? size : [size.width, size.height];\n updateSize = updateSize || height !== this.height || width !== this.width;\n this.width = width;\n this.height = height;\n }\n if (updateSize) {\n log.log(2, `Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)();\n this.resizeAttachments(this.width, this.height);\n }\n }\n /** Auto creates any textures */\n autoCreateAttachmentTextures() {\n if (this.props.colorAttachments.length === 0 && !this.props.depthStencilAttachment) {\n throw new Error('Framebuffer has noattachments');\n }\n this.colorAttachments = this.props.colorAttachments.map((attachment, index) => {\n if (typeof attachment === 'string') {\n const texture = this.createColorTexture(attachment, index);\n this.attachResource(texture);\n return texture.view;\n }\n if (attachment instanceof Texture) {\n return attachment.view;\n }\n return attachment;\n });\n const attachment = this.props.depthStencilAttachment;\n if (attachment) {\n if (typeof attachment === 'string') {\n const texture = this.createDepthStencilTexture(attachment);\n this.attachResource(texture);\n this.depthStencilAttachment = texture.view;\n }\n else if (attachment instanceof Texture) {\n this.depthStencilAttachment = attachment.view;\n }\n else {\n this.depthStencilAttachment = attachment;\n }\n }\n }\n /** Create a color texture */\n createColorTexture(format, index) {\n return this.device.createTexture({\n id: `${this.id}-color-attachment-${index}`,\n usage: Texture.RENDER_ATTACHMENT,\n format,\n width: this.width,\n height: this.height,\n // TODO deprecated? - luma.gl v8 compatibility\n sampler: {\n magFilter: 'linear',\n minFilter: 'linear'\n }\n });\n }\n /** Create depth stencil texture */\n createDepthStencilTexture(format) {\n return this.device.createTexture({\n id: `${this.id}-depth-stencil-attachment`,\n usage: Texture.RENDER_ATTACHMENT,\n format,\n width: this.width,\n height: this.height\n });\n }\n /**\n * Default implementation of resize\n * Creates new textures with correct size for all attachments.\n * and destroys existing textures if owned\n */\n resizeAttachments(width, height) {\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n if (this.colorAttachments[i]) {\n const resizedTexture = this.colorAttachments[i].texture.clone({\n width,\n height\n });\n this.destroyAttachedResource(this.colorAttachments[i]);\n this.colorAttachments[i] = resizedTexture.view;\n this.attachResource(resizedTexture.view);\n }\n }\n if (this.depthStencilAttachment) {\n const resizedTexture = this.depthStencilAttachment.texture.clone({\n width,\n height\n });\n this.destroyAttachedResource(this.depthStencilAttachment);\n this.depthStencilAttachment = resizedTexture.view;\n this.attachResource(resizedTexture);\n }\n this.updateAttachments();\n }\n static defaultProps = {\n ...Resource.defaultProps,\n width: 1,\n height: 1,\n colorAttachments: [], // ['rgba8unorm'],\n depthStencilAttachment: null // 'depth24plus-stencil8'\n };\n}\n//# sourceMappingURL=framebuffer.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// import {Binding} from '../types/shader-layout';\nimport { Resource } from \"./resource.js\";\n/**\n * A RenderPass instance is a required parameter to all draw calls.\n *\n * It holds a combination of\n * - render targets (specified via a framebuffer)\n * - clear colors, read/write, discard information for the framebuffer attachments\n * - a couple of mutable parameters ()\n */\nexport class RenderPass extends Resource {\n /** TODO - should be [0, 0, 0, 0], update once deck.gl tests run clean */\n static defaultClearColor = [0, 0, 0, 1];\n /** Depth 1.0 represents the far plance */\n static defaultClearDepth = 1;\n /** Clears all stencil bits */\n static defaultClearStencil = 0;\n get [Symbol.toStringTag]() {\n return 'RenderPass';\n }\n constructor(device, props) {\n props = RenderPass.normalizeProps(device, props);\n super(device, props, RenderPass.defaultProps);\n }\n static normalizeProps(device, props) {\n return props;\n }\n /** Default properties for RenderPass */\n static defaultProps = {\n ...Resource.defaultProps,\n framebuffer: null,\n parameters: undefined,\n clearColor: RenderPass.defaultClearColor,\n clearColors: undefined,\n clearDepth: RenderPass.defaultClearDepth,\n clearStencil: RenderPass.defaultClearStencil,\n depthReadOnly: false,\n stencilReadOnly: false,\n discard: false,\n occlusionQuerySet: undefined,\n timestampQuerySet: undefined,\n beginTimestampIndex: undefined,\n endTimestampIndex: undefined\n };\n}\n// TODO - Can we align WebGL implementation with WebGPU API?\n// In WebGPU the following methods are on the renderpass instead of the renderpipeline\n// luma.gl keeps them on the pipeline for now, but that has some issues.\n// abstract setPipeline(pipeline: RenderPipeline): void {}\n// abstract setIndexBuffer()\n// abstract setVertexBuffer(slot: number, buffer: Buffer, offset: number): void;\n// abstract setBindings(bindings: Record<string, Binding>): void;\n// abstract setParameters(parameters: RenderPassParameters);\n// abstract draw(options: {\n// abstract drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n// abstract drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n//# sourceMappingURL=render-pass.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Resource } from \"./resource.js\";\n/**\n * Encodes commands to queue that can be executed later\n */\nexport class CommandEncoder extends Resource {\n get [Symbol.toStringTag]() {\n return 'CommandEncoder';\n }\n constructor(device, props) {\n super(device, props, CommandEncoder.defaultProps);\n }\n // TODO - luma.gl has these on the device, should we align with WebGPU API?\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n static defaultProps = {\n ...Resource.defaultProps,\n measureExecutionTime: undefined\n };\n}\n//# sourceMappingURL=command-encoder.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Resource } from \"./resource.js\";\n/**\n * Encodes commands to queue that can be executed later\n */\nexport class CommandBuffer extends Resource {\n get [Symbol.toStringTag]() {\n return 'CommandBuffer';\n }\n constructor(device, props) {\n super(device, props, CommandBuffer.defaultProps);\n }\n static defaultProps = {\n ...Resource.defaultProps\n };\n}\n//# sourceMappingURL=command-buffer.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { getAttributeInfosByLocation } from \"../../adapter-utils/get-attribute-from-layouts.js\";\nimport { Resource } from \"./resource.js\";\n/**\n * Stores attribute bindings.\n * Makes it easy to share a render pipeline and use separate vertex arrays.\n * @note On WebGL, VertexArray allows non-constant bindings to be performed in advance\n * reducing the number of WebGL calls per draw call.\n * @note On WebGPU this is just a convenience class that collects the bindings.\n */\nexport class VertexArray extends Resource {\n static defaultProps = {\n ...Resource.defaultProps,\n shaderLayout: undefined,\n bufferLayout: []\n };\n get [Symbol.toStringTag]() {\n return 'VertexArray';\n }\n /** Max number of vertex attributes */\n maxVertexAttributes;\n /** Attribute infos indexed by location - TODO only needed by webgl module? */\n attributeInfos;\n /** Index buffer */\n indexBuffer = null;\n /** Attributes indexed by buffer slot */\n attributes;\n constructor(device, props) {\n super(device, props, VertexArray.defaultProps);\n this.maxVertexAttributes = device.limits.maxVertexAttributes;\n this.attributes = new Array(this.maxVertexAttributes).fill(null);\n this.attributeInfos = getAttributeInfosByLocation(props.shaderLayout, props.bufferLayout, this.maxVertexAttributes);\n }\n // DEPRECATED METHODS\n /** @deprecated Set constant attributes (WebGL only) */\n setConstantWebGL(location, value) {\n this.device.reportError(new Error('constant attributes not supported'), this)();\n }\n}\n//# sourceMappingURL=vertex-array.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Resource } from \"./resource.js\";\n/** Holds a set of output buffers for pipeline (WebGL only) */\nexport class TransformFeedback extends Resource {\n static defaultProps = {\n ...Resource.defaultProps,\n layout: undefined,\n buffers: {}\n };\n get [Symbol.toStringTag]() {\n return 'TransformFeedback';\n }\n constructor(device, props) {\n super(device, props, TransformFeedback.defaultProps);\n }\n}\n//# sourceMappingURL=transform-feedback.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Resource } from \"./resource.js\";\n/** Immutable QuerySet object */\nexport class QuerySet extends Resource {\n get [Symbol.toStringTag]() {\n return 'QuerySet';\n }\n constructor(device, props) {\n super(device, props, QuerySet.defaultProps);\n }\n static defaultProps = {\n ...Resource.defaultProps,\n type: undefined,\n count: undefined\n };\n}\n//# sourceMappingURL=query-set.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// @ts-nocheck TODO fix\n// Tables describing WebGL parameters\nimport { GL } from '@luma.gl/constants';\n// DEFAULT SETTINGS - FOR FAST CACHE INITIALIZATION AND CONTEXT RESETS\n/* eslint-disable no-shadow */\nexport const GL_PARAMETER_DEFAULTS = {\n [3042]: false,\n [32773]: new Float32Array([0, 0, 0, 0]),\n [32777]: 32774,\n [34877]: 32774,\n [32969]: 1,\n [32968]: 0,\n [32971]: 1,\n [32970]: 0,\n [3106]: new Float32Array([0, 0, 0, 0]), // TBD\n [3107]: [true, true, true, true],\n [2884]: false,\n [2885]: 1029,\n [2929]: false,\n [2931]: 1,\n [2932]: 513,\n [2928]: new Float32Array([0, 1]), // TBD\n [2930]: true,\n [3024]: true,\n [35725]: null,\n // FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.\n [36006]: null,\n [36007]: null,\n [34229]: null,\n [34964]: null,\n [2886]: 2305,\n [33170]: 4352,\n [2849]: 1,\n [32823]: false,\n [32824]: 0,\n [10752]: 0,\n [32926]: false,\n [32928]: false,\n [32938]: 1.0,\n [32939]: false,\n [3089]: false,\n // Note: Dynamic value. If scissor test enabled we expect users to set correct scissor box\n [3088]: new Int32Array([0, 0, 1024, 1024]),\n [2960]: false,\n [2961]: 0,\n [2968]: 0xffffffff,\n [36005]: 0xffffffff,\n [2962]: 519,\n [2967]: 0,\n [2963]: 0xffffffff,\n [34816]: 519,\n [36003]: 0,\n [36004]: 0xffffffff,\n [2964]: 7680,\n [2965]: 7680,\n [2966]: 7680,\n [34817]: 7680,\n [34818]: 7680,\n [34819]: 7680,\n // Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame.\n [2978]: [0, 0, 1024, 1024],\n [36389]: null,\n [36662]: null,\n [36663]: null,\n [35053]: null,\n [35055]: null,\n [35723]: 4352,\n [36010]: null,\n [35977]: false,\n [3333]: 4,\n [3317]: 4,\n [37440]: false,\n [37441]: false,\n [37443]: 37444,\n [3330]: 0,\n [3332]: 0,\n [3331]: 0,\n [3314]: 0,\n [32878]: 0,\n [3316]: 0,\n [3315]: 0,\n [32877]: 0\n};\n// SETTER TABLES - ENABLES SETTING ANY PARAMETER WITH A COMMON API\nconst enable = (gl, value, key) => value ? gl.enable(key) : gl.disable(key);\nconst hint = (gl, value, key) => gl.hint(key, value);\nconst pixelStorei = (gl, value, key) => gl.pixelStorei(key, value);\nconst bindFramebuffer = (gl, value, key) => {\n const target = key === 36006 ? 36009 : 36008;\n return gl.bindFramebuffer(target, value);\n};\nconst bindBuffer = (gl, value, key) => {\n const bindingMap = {\n [34964]: 34962,\n [36662]: 36662,\n [36663]: 36663,\n [35053]: 35051,\n [35055]: 35052\n };\n const glTarget = bindingMap[key];\n gl.bindBuffer(glTarget, value);\n};\n// Utility\nfunction isArray(array) {\n return Array.isArray(array) || (ArrayBuffer.isView(array) && !(array instanceof DataView));\n}\n// Map from WebGL parameter names to corresponding WebGL setter functions\n// WegGL constants are read by parameter names, but set by function names\n// NOTE: When value type is a string, it will be handled by 'GL_COMPOSITE_PARAMETER_SETTERS'\nexport const GL_PARAMETER_SETTERS = {\n [3042]: enable,\n [32773]: (gl, value) => gl.blendColor(...value),\n [32777]: 'blendEquation',\n [34877]: 'blendEquation',\n [32969]: 'blendFunc',\n [32968]: 'blendFunc',\n [32971]: 'blendFunc',\n [32970]: 'blendFunc',\n [3106]: (gl, value) => gl.clearColor(...value),\n [3107]: (gl, value) => gl.colorMask(...value),\n [2884]: enable,\n [2885]: (gl, value) => gl.cullFace(value),\n [2929]: enable,\n [2931]: (gl, value) => gl.clearDepth(value),\n [2932]: (gl, value) => gl.depthFunc(value),\n [2928]: (gl, value) => gl.depthRange(...value),\n [2930]: (gl, value) => gl.depthMask(value),\n [3024]: enable,\n [35723]: hint,\n [35725]: (gl, value) => gl.useProgram(value),\n [36007]: (gl, value) => gl.bindRenderbuffer(36161, value),\n [36389]: (gl, value) => gl.bindTransformFeedback?.(36386, value),\n [34229]: (gl, value) => gl.bindVertexArray(value),\n // NOTE: FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.\n [36006]: bindFramebuffer,\n [36010]: bindFramebuffer,\n // Buffers\n [34964]: bindBuffer,\n [36662]: bindBuffer,\n [36663]: bindBuffer,\n [35053]: bindBuffer,\n [35055]: bindBuffer,\n [2886]: (gl, value) => gl.frontFace(value),\n [33170]: hint,\n [2849]: (gl, value) => gl.lineWidth(value),\n [32823]: enable,\n [32824]: 'polygonOffset',\n [10752]: 'polygonOffset',\n [35977]: enable,\n [32926]: enable,\n [32928]: enable,\n [32938]: 'sampleCoverage',\n [32939]: 'sampleCoverage',\n [3089]: enable,\n [3088]: (gl, value) => gl.scissor(...value),\n [2960]: enable,\n [2961]: (gl, value) => gl.clearStencil(value),\n [2968]: (gl, value) => gl.stencilMaskSeparate(1028, value),\n [36005]: (gl, value) => gl.stencilMaskSeparate(1029, value),\n [2962]: 'stencilFuncFront',\n [2967]: 'stencilFuncFront',\n [2963]: 'stencilFuncFront',\n [34816]: 'stencilFuncBack',\n [36003]: 'stencilFuncBack',\n [36004]: 'stencilFuncBack',\n [2964]: 'stencilOpFront',\n [2965]: 'stencilOpFront',\n [2966]: 'stencilOpFront',\n [34817]: 'stencilOpBack',\n [34818]: 'stencilOpBack',\n [34819]: 'stencilOpBack',\n [2978]: (gl, value) => gl.viewport(...value),\n // WEBGL2 EXTENSIONS\n // EXT_depth_clamp https://registry.khronos.org/webgl/extensions/EXT_depth_clamp/\n [34383]: enable,\n // WEBGL_provoking_vertex https://registry.khronos.org/webgl/extensions/WEBGL_provoking_vertex/\n // [GL.PROVOKING_VERTEX_WEBL]: TODO - extension function needed\n // WEBGL_polygon_mode https://registry.khronos.org/webgl/extensions/WEBGL_polygon_mode/\n // POLYGON_MODE_WEBGL TODO - extension function needed\n [10754]: enable,\n // WEBGL_clip_cull_distance https://registry.khronos.org/webgl/extensions/WEBGL_clip_cull_distance/\n [12288]: enable,\n [12289]: enable,\n [12290]: enable,\n [12291]: enable,\n [12292]: enable,\n [12293]: enable,\n [12294]: enable,\n [12295]: enable,\n // PIXEL PACK/UNPACK MODES\n [3333]: pixelStorei,\n [3317]: pixelStorei,\n [37440]: pixelStorei,\n [37441]: pixelStorei,\n [37443]: pixelStorei,\n [3330]: pixelStorei,\n [3332]: pixelStorei,\n [3331]: pixelStorei,\n [3314]: pixelStorei,\n [32878]: pixelStorei,\n [3316]: pixelStorei,\n [3315]: pixelStorei,\n [32877]: pixelStorei,\n // Function-style setters\n framebuffer: (gl, framebuffer) => {\n // accepts 1) a WebGLFramebuffer 2) null (default framebuffer), or 3) luma.gl Framebuffer class\n // framebuffer is null when restoring to default framebuffer, otherwise use the WebGL handle.\n const handle = framebuffer && 'handle' in framebuffer ? framebuffer.handle : framebuffer;\n return gl.bindFramebuffer(36160, handle);\n },\n blend: (gl, value) => value ? gl.enable(3042) : gl.disable(3042),\n blendColor: (gl, value) => gl.blendColor(...value),\n blendEquation: (gl, args) => {\n const separateModes = typeof args === 'number' ? [args, args] : args;\n gl.blendEquationSeparate(...separateModes);\n },\n blendFunc: (gl, args) => {\n const separateFuncs = args?.length === 2 ? [...args, ...args] : args;\n gl.blendFuncSeparate(...separateFuncs);\n },\n clearColor: (gl, value) => gl.clearColor(...value),\n clearDepth: (gl, value) => gl.clearDepth(value),\n clearStencil: (gl, value) => gl.clearStencil(value),\n colorMask: (gl, value) => gl.colorMask(...value),\n cull: (gl, value) => value ? gl.enable(2884) : gl.disable(2884),\n cullFace: (gl, value) => gl.cullFace(value),\n depthTest: (gl, value) => value ? gl.enable(2929) : gl.disable(2929),\n depthFunc: (gl, value) => gl.depthFunc(value),\n depthMask: (gl, value) => gl.depthMask(value),\n depthRange: (gl, value) => gl.depthRange(...value),\n dither: (gl, value) => value ? gl.enable(3024) : gl.disable(3024),\n derivativeHint: (gl, value) => {\n // gl1: 'OES_standard_derivatives'\n gl.hint(35723, value);\n },\n frontFace: (gl, value) => gl.frontFace(value),\n mipmapHint: (gl, value) => gl.hint(33170, value),\n lineWidth: (gl, value) => gl.lineWidth(value),\n polygonOffsetFill: (gl, value) => value ? gl.enable(32823) : gl.disable(32823),\n polygonOffset: (gl, value) => gl.polygonOffset(...value),\n sampleCoverage: (gl, value) => gl.sampleCoverage(value[0], value[1] || false),\n scissorTest: (gl, value) => value ? gl.enable(3089) : gl.disable(3089),\n scissor: (gl, value) => gl.scissor(...value),\n stencilTest: (gl, value) => value ? gl.enable(2960) : gl.disable(2960),\n stencilMask: (gl, value) => {\n value = isArray(value) ? value : [value, value];\n const [mask, backMask] = value;\n gl.stencilMaskSeparate(1028, mask);\n gl.stencilMaskSeparate(1029, backMask);\n },\n stencilFunc: (gl, args) => {\n args = isArray(args) && args.length === 3 ? [...args, ...args] : args;\n const [func, ref, mask, backFunc, backRef, backMask] = args;\n gl.stencilFuncSeparate(1028, func, ref, mask);\n gl.stencilFuncSeparate(1029, backFunc, backRef, backMask);\n },\n stencilOp: (gl, args) => {\n args = isArray(args) && args.length === 3 ? [...args, ...args] : args;\n const [sfail, dpfail, dppass, backSfail, backDpfail, backDppass] = args;\n gl.stencilOpSeparate(1028, sfail, dpfail, dppass);\n gl.stencilOpSeparate(1029, backSfail, backDpfail, backDppass);\n },\n viewport: (gl, value) => gl.viewport(...value)\n};\nfunction getValue(glEnum, values, cache) {\n return values[glEnum] !== undefined ? values[glEnum] : cache[glEnum];\n}\n// COMPOSITE_WEBGL_PARAMETER_\nexport const GL_COMPOSITE_PARAMETER_SETTERS = {\n blendEquation: (gl, values, cache) => gl.blendEquationSeparate(getValue(32777, values, cache), getValue(34877, values, cache)),\n blendFunc: (gl, values, cache) => gl.blendFuncSeparate(getValue(32969, values, cache), getValue(32968, values, cache), getValue(32971, values, cache), getValue(32970, values, cache)),\n polygonOffset: (gl, values, cache) => gl.polygonOffset(getValue(32824, values, cache), getValue(10752, values, cache)),\n sampleCoverage: (gl, values, cache) => gl.sampleCoverage(getValue(32938, values, cache), getValue(32939, values, cache)),\n stencilFuncFront: (gl, values, cache) => gl.stencilFuncSeparate(1028, getValue(2962, values, cache), getValue(2967, values, cache), getValue(2963, values, cache)),\n stencilFuncBack: (gl, values, cache) => gl.stencilFuncSeparate(1029, getValue(34816, values, cache), getValue(36003, values, cache), getValue(36004, values, cache)),\n stencilOpFront: (gl, values, cache) => gl.stencilOpSeparate(1028, getValue(2964, values, cache), getValue(2965, values, cache), getValue(2966, values, cache)),\n stencilOpBack: (gl, values, cache) => gl.stencilOpSeparate(1029, getValue(34817, values, cache), getValue(34818, values, cache), getValue(34819, values, cache))\n};\n// Setter functions intercepted for cache updates\nexport const GL_HOOKED_SETTERS = {\n // GENERIC SETTERS\n enable: (update, capability) => update({\n [capability]: true\n }),\n disable: (update, capability) => update({\n [capability]: false\n }),\n pixelStorei: (update, pname, value) => update({\n [pname]: value\n }),\n hint: (update, pname, value) => update({\n [pname]: value\n }),\n // SPECIFIC SETTERS\n useProgram: (update, value) => update({\n [35725]: value\n }),\n bindRenderbuffer: (update, target, value) => update({\n [36007]: value\n }),\n bindTransformFeedback: (update, target, value) => update({\n [36389]: value\n }),\n bindVertexArray: (update, value) => update({\n [34229]: value\n }),\n bindFramebuffer: (update, target, framebuffer) => {\n switch (target) {\n case 36160:\n return update({\n [36006]: framebuffer,\n [36010]: framebuffer\n });\n case 36009:\n return update({ [36006]: framebuffer });\n case 36008:\n return update({ [36010]: framebuffer });\n default:\n return null;\n }\n },\n bindBuffer: (update, target, buffer) => {\n const pname = {\n [34962]: [34964],\n [36662]: [36662],\n [36663]: [36663],\n [35051]: [35053],\n [35052]: [35055]\n }[target];\n if (pname) {\n return update({ [pname]: buffer });\n }\n // targets that should not be cached\n return { valueChanged: true };\n },\n blendColor: (update, r, g, b, a) => update({\n [32773]: new Float32Array([r, g, b, a])\n }),\n blendEquation: (update, mode) => update({\n [32777]: mode,\n [34877]: mode\n }),\n blendEquationSeparate: (update, modeRGB, modeAlpha) => update({\n [32777]: modeRGB,\n [34877]: modeAlpha\n }),\n blendFunc: (update, src, dst) => update({\n [32969]: src,\n [32968]: dst,\n [32971]: src,\n [32970]: dst\n }),\n blendFuncSeparate: (update, srcRGB, dstRGB, srcAlpha, dstAlpha) => update({\n [32969]: srcRGB,\n [32968]: dstRGB,\n [32971]: srcAlpha,\n [32970]: dstAlpha\n }),\n clearColor: (update, r, g, b, a) => update({\n [3106]: new Float32Array([r, g, b, a])\n }),\n clearDepth: (update, depth) => update({\n [2931]: depth\n }),\n clearStencil: (update, s) => update({\n [2961]: s\n }),\n colorMask: (update, r, g, b, a) => update({\n [3107]: [r, g, b, a]\n }),\n cullFace: (update, mode) => update({\n [2885]: mode\n }),\n depthFunc: (update, func) => update({\n [2932]: func\n }),\n depthRange: (update, zNear, zFar) => update({\n [2928]: new Float32Array([zNear, zFar])\n }),\n depthMask: (update, mask) => update({\n [2930]: mask\n }),\n frontFace: (update, face) => update({\n [2886]: face\n }),\n lineWidth: (update, width) => update({\n [2849]: width\n }),\n polygonOffset: (update, factor, units) => update({\n [32824]: factor,\n [10752]: units\n }),\n sampleCoverage: (update, value, invert) => update({\n [32938]: value,\n [32939]: invert\n }),\n scissor: (update, x, y, width, height) => update({\n [3088]: new Int32Array([x, y, width, height])\n }),\n stencilMask: (update, mask) => update({\n [2968]: mask,\n [36005]: mask\n }),\n stencilMaskSeparate: (update, face, mask) => update({\n [face === 1028 ? 2968 : 36005]: mask\n }),\n stencilFunc: (update, func, ref, mask) => update({\n [2962]: func,\n [2967]: ref,\n [2963]: mask,\n [34816]: func,\n [36003]: ref,\n [36004]: mask\n }),\n stencilFuncSeparate: (update, face, func, ref, mask) => update({\n [face === 1028 ? 2962 : 34816]: func,\n [face === 1028 ? 2967 : 36003]: ref,\n [face === 1028 ? 2963 : 36004]: mask\n }),\n stencilOp: (update, fail, zfail, zpass) => update({\n [2964]: fail,\n [2965]: zfail,\n [2966]: zpass,\n [34817]: fail,\n [34818]: zfail,\n [34819]: zpass\n }),\n stencilOpSeparate: (update, face, fail, zfail, zpass) => update({\n [face === 1028 ? 2964 : 34817]: fail,\n [face === 1028 ? 2965 : 34818]: zfail,\n [face === 1028 ? 2966 : 34819]: zpass\n }),\n viewport: (update, x, y, width, height) => update({\n [2978]: [x, y, width, height]\n })\n};\n// GETTER TABLE - FOR READING OUT AN ENTIRE CONTEXT\nconst isEnabled = (gl, key) => gl.isEnabled(key);\n// Exceptions for any keys that cannot be queried by gl.getParameters\nexport const GL_PARAMETER_GETTERS = {\n [3042]: isEnabled,\n [2884]: isEnabled,\n [2929]: isEnabled,\n [3024]: isEnabled,\n [32823]: isEnabled,\n [32926]: isEnabled,\n [32928]: isEnabled,\n [3089]: isEnabled,\n [2960]: isEnabled,\n [35977]: isEnabled\n};\nexport const NON_CACHE_PARAMETERS = new Set([\n 34016,\n 36388,\n 36387,\n 35983,\n 35368,\n 34965,\n 35739,\n 35738,\n 3074,\n 34853,\n 34854,\n 34855,\n 34856,\n 34857,\n 34858,\n 34859,\n 34860,\n 34861,\n 34862,\n 34863,\n 34864,\n 34865,\n 34866,\n 34867,\n 34868,\n 35097,\n 32873,\n 35869,\n 32874,\n 34068\n]);\n//# sourceMappingURL=webgl-parameter-tables.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { GL_PARAMETER_DEFAULTS, GL_PARAMETER_SETTERS, GL_COMPOSITE_PARAMETER_SETTERS, GL_PARAMETER_GETTERS } from \"./webgl-parameter-tables.js\";\n/**\n * Sets any GL parameter regardless of function (gl.blendMode, ...)\n *\n * @note requires a `cache` object to be set on the context (gl.state.cache)\n * This object is used to fill in any missing values for composite setter functions\n */\nexport function setGLParameters(gl, parameters) {\n if (isObjectEmpty(parameters)) {\n return;\n }\n const compositeSetters = {};\n // HANDLE PRIMITIVE SETTERS (and make note of any composite setters)\n for (const key in parameters) {\n const glConstant = Number(key);\n // @ts-ignore TODO\n const setter = GL_PARAMETER_SETTERS[key];\n if (setter) {\n // Composite setters should only be called once, so save them\n if (typeof setter === 'string') {\n // @ts-ignore TODO\n compositeSetters[setter] = true;\n }\n else {\n // if (gl[glConstant] !== undefined) {\n // TODO - added above check since this is being called on WebGL2 parameters in WebGL1...\n // TODO - deep equal on values? only call setter if value has changed?\n // NOTE - the setter will automatically update this.state\n // @ts-ignore TODO\n setter(gl, parameters[key], glConstant);\n }\n }\n }\n // HANDLE COMPOSITE SETTERS\n // NOTE: any non-provided values needed by composite setters are filled in from state cache\n // The cache parameter is automatically retrieved from the context\n // This depends on `trackContextState`, which is technically a \"circular\" dependency.\n // But it is too inconvenient to always require a cache parameter here.\n // This is the ONLY external dependency in this module/\n // @ts-expect-error\n const cache = gl.state && gl.state.cache;\n if (cache) {\n for (const key in compositeSetters) {\n // TODO - avoid calling composite setters if values have not changed.\n // @ts-ignore TODO\n const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];\n // Note - if `trackContextState` has been called,\n // the setter will automatically update this.state.cache\n compositeSetter(gl, parameters, cache);\n }\n }\n // Add a log for the else case?\n}\n/**\n * Reads the entire WebGL state from a context\n\n // default to querying all parameters\n\n * @returns - a newly created map, with values keyed by GL parameters\n *\n * @note Copies the state from a context (gl.getParameter should not be overriden)\n * Reads the entire WebGL state from a context\n *\n * @note This can generates a huge amount of synchronous driver roundtrips and should be\n * considered a very slow operation, to be used only if/when a context already manipulated\n * by external code needs to be synchronized for the first time\n */\nexport function getGLParameters(gl, parameters = GL_PARAMETER_DEFAULTS) {\n // support both arrays of parameters and objects (keys represent parameters)\n if (typeof parameters === 'number') {\n // single GL enum\n const key = parameters;\n // @ts-ignore TODO\n const getter = GL_PARAMETER_GETTERS[key];\n return getter ? getter(gl, key) : gl.getParameter(key);\n }\n const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);\n const state = {};\n for (const key of parameterKeys) {\n // @ts-ignore TODO\n const getter = GL_PARAMETER_GETTERS[key];\n // @ts-ignore TODO\n state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));\n }\n return state;\n}\n/**\n * Reset all parameters to a (almost) pure context state\n * @note viewport and scissor will be set to the values in GL_PARAMETER_DEFAULTS,\n * NOT the canvas size dimensions, so they will have to be properly set after\n * calling this function.\n */\nexport function resetGLParameters(gl) {\n setGLParameters(gl, GL_PARAMETER_DEFAULTS);\n}\n// Helpers\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(object) {\n // @ts-ignore dummy key variable\n for (const key in object) {\n return false;\n }\n return true;\n}\n//# sourceMappingURL=unified-parameter-api.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/** deeply compare two arrays */\nexport function deepArrayEqual(x, y) {\n if (x === y) {\n return true;\n }\n if (isArray(x) && isArray(y) && x.length === y.length) {\n for (let i = 0; i < x.length; ++i) {\n if (x[i] !== y[i]) {\n return false;\n }\n }\n return true;\n }\n return false;\n}\nfunction isArray(x) {\n return Array.isArray(x) || ArrayBuffer.isView(x);\n}\n//# sourceMappingURL=deep-array-equal.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// @ts-nocheck TODO - fix\nimport { setGLParameters, getGLParameters } from \"../parameters/unified-parameter-api.js\";\nimport { deepArrayEqual } from \"./deep-array-equal.js\";\nimport { GL_PARAMETER_DEFAULTS, GL_HOOKED_SETTERS, NON_CACHE_PARAMETERS } from \"../parameters/webgl-parameter-tables.js\";\n// HELPER CLASS - WebGLStateTracker\n/**\n * Support for listening to context state changes and intercepting state queries\n * NOTE: this system does not handle buffer bindings\n */\nexport class WebGLStateTracker {\n static get(gl) {\n // @ts-expect-error\n return gl.state;\n }\n gl;\n program = null;\n stateStack = [];\n enable = true;\n cache = null;\n log;\n initialized = false;\n constructor(gl, props) {\n this.gl = gl;\n this.log = props?.log || (() => { });\n this._updateCache = this._updateCache.bind(this);\n Object.seal(this);\n }\n push(values = {}) {\n this.stateStack.push({});\n }\n pop() {\n // assert(this.stateStack.length > 0);\n // Use the saved values in the state stack to restore parameters\n const oldValues = this.stateStack[this.stateStack.length - 1];\n setGLParameters(this.gl, oldValues);\n // Don't pop until we have reset parameters (to make sure other \"stack frames\" are not affected)\n this.stateStack.pop();\n }\n /**\n * Initialize WebGL state caching on a context\n * can be called multiple times to enable/disable\n *\n * @note After calling this function, context state will be cached\n * .push() and .pop() will be available for saving,\n * temporarily modifying, and then restoring state.\n */\n trackState(gl, options) {\n this.cache = options?.copyState\n ? getGLParameters(gl)\n : Object.assign({}, GL_PARAMETER_DEFAULTS);\n if (this.initialized) {\n throw new Error('WebGLStateTracker');\n }\n this.initialized = true;\n // @ts-expect-error\n this.gl.state = this;\n installProgramSpy(gl);\n // intercept all setter functions in the table\n for (const key in GL_HOOKED_SETTERS) {\n const setter = GL_HOOKED_SETTERS[key];\n installSetterSpy(gl, key, setter);\n }\n // intercept all getter functions in the table\n installGetterOverride(gl, 'getParameter');\n installGetterOverride(gl, 'isEnabled');\n }\n /**\n // interceptor for context set functions - update our cache and our stack\n // values (Object) - the key values for this setter\n * @param values\n * @returns\n */\n _updateCache(values) {\n let valueChanged = false;\n let oldValue; // = undefined\n const oldValues = this.stateStack.length > 0 ? this.stateStack[this.stateStack.length - 1] : null;\n for (const key in values) {\n // assert(key !== undefined);\n const value = values[key];\n const cached = this.cache[key];\n // Check that value hasn't already been shadowed\n if (!deepArrayEqual(value, cached)) {\n valueChanged = true;\n oldValue = cached;\n // First, save current value being shadowed\n // If a state stack frame is active, save the current parameter values for pop\n // but first check that value hasn't already been shadowed and saved\n if (oldValues && !(key in oldValues)) {\n oldValues[key] = cached;\n }\n // Save current value being shadowed\n this.cache[key] = value;\n }\n }\n return { valueChanged, oldValue };\n }\n}\n// HELPER FUNCTIONS - INSTALL GET/SET INTERCEPTORS (SPYS) ON THE CONTEXT\n/**\n// Overrides a WebGL2RenderingContext state \"getter\" function\n// to return values directly from cache\n * @param gl\n * @param functionName\n */\nfunction installGetterOverride(gl, functionName) {\n // Get the original function from the WebGL2RenderingContext\n const originalGetterFunc = gl[functionName].bind(gl);\n // Wrap it with a spy so that we can update our state cache when it gets called\n gl[functionName] = function get(pname) {\n if (pname === undefined || NON_CACHE_PARAMETERS.has(pname)) {\n // Invalid or blacklisted parameter, do not cache\n return originalGetterFunc(pname);\n }\n const glState = WebGLStateTracker.get(gl);\n if (!(pname in glState.cache)) {\n // WebGL limits are not prepopulated in the cache, call the original getter when first queried.\n glState.cache[pname] = originalGetterFunc(pname);\n }\n // Optionally call the original function to do a \"hard\" query from the WebGL2RenderingContext\n return glState.enable\n ? // Call the getter the params so that it can e.g. serve from a cache\n glState.cache[pname]\n : // Optionally call the original function to do a \"hard\" query from the WebGL2RenderingContext\n originalGetterFunc(pname);\n };\n // Set the name of this anonymous function to help in debugging and profiling\n Object.defineProperty(gl[functionName], 'name', {\n value: `${functionName}-from-cache`,\n configurable: false\n });\n}\n/**\n// Overrides a WebGL2RenderingContext state \"setter\" function\n// to call a setter spy before the actual setter. Allows us to keep a cache\n// updated with a copy of the WebGL context state.\n * @param gl\n * @param functionName\n * @param setter\n * @returns\n */\nfunction installSetterSpy(gl, functionName, setter) {\n // Get the original function from the WebGL2RenderingContext\n if (!gl[functionName]) {\n // TODO - remove?\n // This could happen if we try to intercept WebGL2 method on a WebGL1 context\n return;\n }\n const originalSetterFunc = gl[functionName].bind(gl);\n // Wrap it with a spy so that we can update our state cache when it gets called\n gl[functionName] = function set(...params) {\n // Update the value\n // Call the setter with the state cache and the params so that it can store the parameters\n const glState = WebGLStateTracker.get(gl);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { valueChanged, oldValue } = setter(glState._updateCache, ...params);\n // Call the original WebGL2RenderingContext func to make sure the context actually gets updated\n if (valueChanged) {\n originalSetterFunc(...params);\n }\n // Note: if the original function fails to set the value, our state cache will be bad\n // No solution for this at the moment, but assuming that this is unlikely to be a real problem\n // We could call the setter after the originalSetterFunc. Concern is that this would\n // cause different behavior in debug mode, where originalSetterFunc can throw exceptions\n return oldValue;\n };\n // Set the name of this anonymous function to help in debugging and profiling\n Object.defineProperty(gl[functionName], 'name', {\n value: `${functionName}-to-cache`,\n configurable: false\n });\n}\nfunction installProgramSpy(gl) {\n const originalUseProgram = gl.useProgram.bind(gl);\n gl.useProgram = function useProgramLuma(handle) {\n const glState = WebGLStateTracker.get(gl);\n if (glState.program !== handle) {\n originalUseProgram(handle);\n glState.program = handle;\n }\n };\n}\n//# sourceMappingURL=webgl-state-tracker.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n * @param canvas A canvas element or offscreen canvas\n */\nexport function createBrowserContext(canvas, props, webglContextAttributes) {\n // Try to extract any extra information about why context creation failed\n let errorMessage = '';\n // const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);\n // Avoid multiple listeners?\n // canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n // canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n const webglProps = {\n preserveDrawingBuffer: true,\n // failIfMajorPerformanceCaveat: true,\n ...webglContextAttributes\n };\n // Create the desired context\n let gl = null;\n // Create a webgl2 context\n gl ||= canvas.getContext('webgl2', webglProps);\n if (webglProps.failIfMajorPerformanceCaveat) {\n errorMessage ||=\n 'Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.';\n }\n // Creation failed with failIfMajorPerformanceCaveat - Try a Software GPU\n if (!gl && !webglContextAttributes.failIfMajorPerformanceCaveat) {\n webglProps.failIfMajorPerformanceCaveat = false;\n gl = canvas.getContext('webgl2', webglProps);\n // @ts-expect-error\n gl.luma ||= {};\n // @ts-expect-error\n gl.luma.softwareRenderer = true;\n }\n if (!gl) {\n gl = canvas.getContext('webgl', {});\n if (gl) {\n gl = null;\n errorMessage ||= 'Your browser only supports WebGL1';\n }\n }\n if (!gl) {\n errorMessage ||= 'Your browser does not support WebGL';\n throw new Error(`Failed to create WebGL context: ${errorMessage}`);\n }\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const { onContextLost, onContextRestored } = props;\n canvas.addEventListener('webglcontextlost', (event) => onContextLost(event), false);\n canvas.addEventListener('webglcontextrestored', (event) => onContextRestored(event), false);\n // @ts-expect-error\n gl.luma ||= {};\n return gl;\n}\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGL2RenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n//# sourceMappingURL=create-browser-context.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/** Ensure extensions are only requested once */\nexport function getWebGLExtension(gl, name, extensions) {\n // @ts-ignore TODO\n if (extensions[name] === undefined) {\n // @ts-ignore TODO\n extensions[name] = gl.getExtension(name) || null;\n }\n // @ts-ignore TODO\n return extensions[name];\n}\n//# sourceMappingURL=webgl-extensions.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { GL } from '@luma.gl/constants';\nimport { getWebGLExtension } from \"../../context/helpers/webgl-extensions.js\";\n/** @returns strings identifying the GPU vendor and driver. */\nexport function getDeviceInfo(gl, extensions) {\n // \"Masked\" info is always available, but don't contain much useful information\n const vendorMasked = gl.getParameter(7936);\n const rendererMasked = gl.getParameter(7937);\n // If we are lucky, unmasked info is available\n // https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/\n getWebGLExtension(gl, 'WEBGL_debug_renderer_info', extensions);\n const ext = extensions.WEBGL_debug_renderer_info;\n const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : 7936);\n const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : 7937);\n const vendor = vendorUnmasked || vendorMasked;\n const renderer = rendererUnmasked || rendererMasked;\n // Driver version\n const version = gl.getParameter(7938);\n // \"Sniff\" the GPU type and backend from the info. This works best if unmasked info is available.\n const gpu = identifyGPUVendor(vendor, renderer);\n const gpuBackend = identifyGPUBackend(vendor, renderer);\n const gpuType = identifyGPUType(vendor, renderer);\n // Determine GLSL version\n // For now, skip parsing of the long version string, just use context type below to deduce version\n // const version = gl.getParameter(GL.SHADING_LANGUAGE_VERSION) as string;\n // const shadingLanguageVersion = parseGLSLVersion(version);\n const shadingLanguage = 'glsl';\n const shadingLanguageVersion = 300;\n return {\n type: 'webgl',\n gpu,\n gpuType,\n gpuBackend,\n vendor,\n renderer,\n version,\n shadingLanguage,\n shadingLanguageVersion\n };\n}\n/** \"Sniff\" the GPU type from the info. This works best if unmasked info is available. */\nfunction identifyGPUVendor(vendor, renderer) {\n if (/NVIDIA/i.exec(vendor) || /NVIDIA/i.exec(renderer)) {\n return 'nvidia';\n }\n if (/INTEL/i.exec(vendor) || /INTEL/i.exec(renderer)) {\n return 'intel';\n }\n if (/Apple/i.exec(vendor) || /Apple/i.exec(renderer)) {\n return 'apple';\n }\n if (/AMD/i.exec(vendor) ||\n /AMD/i.exec(renderer) ||\n /ATI/i.exec(vendor) ||\n /ATI/i.exec(renderer)) {\n return 'amd';\n }\n if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {\n return 'software';\n }\n return 'unknown';\n}\n/** \"Sniff\" the GPU backend from the info. This works best if unmasked info is available. */\nfunction identifyGPUBackend(vendor, renderer) {\n if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {\n return 'metal';\n }\n if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {\n return 'opengl';\n }\n return 'unknown';\n}\nfunction identifyGPUType(vendor, renderer) {\n if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {\n return 'cpu';\n }\n const gpuVendor = identifyGPUVendor(vendor, renderer);\n switch (gpuVendor) {\n case 'intel':\n return 'integrated';\n case 'software':\n return 'cpu';\n case 'unknown':\n return 'unknown';\n default:\n return 'discrete';\n }\n}\n//# sourceMappingURL=webgl-device-info.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { GL } from '@luma.gl/constants';\n/** Get vertex format from GL constants */\nexport function getVertexFormatFromGL(type, components) {\n const base = getVertexTypeFromGL(type);\n // prettier-ignore\n switch (components) {\n case 1: return base;\n case 2: return `${base}x2`;\n // @ts-expect-error TODO deal with lack of \"unaligned\" formats\n case 3: return `${base}x3`;\n case 4: return `${base}x4`;\n }\n // @ts-ignore unreachable\n throw new Error(String(components));\n}\n/** Get data type from GL constants */\nexport function getVertexTypeFromGL(type, normalized = false) {\n // prettier-ignore\n switch (type) {\n // WebGPU does not support normalized 32 bit integer attributes\n case 5124: return normalized ? 'sint32' : 'sint32';\n case 5125: return normalized ? 'uint32' : 'uint32';\n case 5122: return normalized ? 'sint16' : 'unorm16';\n case 5123: return normalized ? 'uint16' : 'unorm16';\n case 5120: return normalized ? 'sint8' : 'snorm16';\n case 5121: return normalized ? 'uint8' : 'unorm8';\n case 5126: return 'float32';\n case 5131: return 'float16';\n }\n // @ts-ignore unreachable\n throw new Error(String(type));\n}\nexport function getGLFromVertexType(dataType) {\n // prettier-ignore\n switch (dataType) {\n case 'uint8': return 5121;\n case 'sint8': return 5120;\n case 'unorm8': return 5121;\n case 'snorm8': return 5120;\n case 'uint16': return 5123;\n case 'sint16': return 5122;\n case 'unorm16': return 5123;\n case 'snorm16': return 5122;\n case 'uint32': return 5125;\n case 'sint32': return 5124;\n // WebGPU does not support normalized 32 bit integer attributes\n // case 'unorm32': return GL.UNSIGNED_INT;\n // case 'snorm32': return GL.INT;\n case 'float16': return 5131;\n case 'float32': return 5126;\n }\n // @ts-ignore unreachable\n throw new Error(String(dataType));\n}\n//# sourceMappingURL=webgl-vertex-formats.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { textureFormatDecoder } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { getWebGLExtension } from \"../../context/helpers/webgl-extensions.js\";\nimport { getGLFromVertexType } from \"./webgl-vertex-formats.js\";\n/* eslint-disable camelcase */\n// TEXTURE FEATURES\n// Define local webgl extension strings to optimize minification\nconst X_S3TC = 'WEBGL_compressed_texture_s3tc'; // BC1, BC2, BC3\nconst X_S3TC_SRGB = 'WEBGL_compressed_texture_s3tc_srgb'; // BC1, BC2, BC3\nconst X_RGTC = 'EXT_texture_compression_rgtc'; // BC4, BC5\nconst X_BPTC = 'EXT_texture_compression_bptc'; // BC6, BC7\nconst X_ETC2 = 'WEBGL_compressed_texture_etc'; // Renamed from 'WEBGL_compressed_texture_es3'\nconst X_ASTC = 'WEBGL_compressed_texture_astc';\nconst X_ETC1 = 'WEBGL_compressed_texture_etc1';\nconst X_PVRTC = 'WEBGL_compressed_texture_pvrtc';\nconst X_ATC = 'WEBGL_compressed_texture_atc';\n// Define local webgl extension strings to optimize minification\nconst EXT_texture_norm16 = 'EXT_texture_norm16';\nconst EXT_render_snorm = 'EXT_render_snorm';\nconst EXT_color_buffer_float = 'EXT_color_buffer_float';\n// prettier-ignore\nexport const TEXTURE_FEATURES = {\n 'float32-renderable-webgl': ['EXT_color_buffer_float'],\n 'float16-renderable-webgl': ['EXT_color_buffer_half_float'],\n 'rgb9e5ufloat-renderable-webgl': ['WEBGL_render_shared_exponent'],\n 'snorm8-renderable-webgl': [EXT_render_snorm],\n 'norm16-renderable-webgl': [EXT_texture_norm16],\n 'snorm16-renderable-webgl': [EXT_texture_norm16, EXT_render_snorm],\n 'float32-filterable': ['OES_texture_float_linear'],\n 'float16-filterable-webgl': ['OES_texture_half_float_linear'],\n 'texture-filterable-anisotropic-webgl': ['EXT_texture_filter_anisotropic'],\n 'texture-blend-float-webgl': ['EXT_float_blend'],\n 'texture-compression-bc': [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],\n // 'texture-compression-bc3-srgb-webgl': [X_S3TC_SRGB],\n // 'texture-compression-bc3-webgl': [X_S3TC],\n 'texture-compression-bc5-webgl': [X_RGTC],\n 'texture-compression-bc7-webgl': [X_BPTC],\n 'texture-compression-etc2': [X_ETC2],\n 'texture-compression-astc': [X_ASTC],\n 'texture-compression-etc1-webgl': [X_ETC1],\n 'texture-compression-pvrtc-webgl': [X_PVRTC],\n 'texture-compression-atc-webgl': [X_ATC]\n};\nexport function isTextureFeature(feature) {\n return feature in TEXTURE_FEATURES;\n}\n/** Checks a texture feature (for Device.features). Mainly compressed texture support */\nexport function checkTextureFeature(gl, feature, extensions) {\n const textureExtensions = TEXTURE_FEATURES[feature] || [];\n return textureExtensions.every(extension => getWebGLExtension(gl, extension, extensions));\n}\n// TABLES\n/**\n * Texture format data -\n * Exported but can change without notice\n */\n// prettier-ignore\nexport const WEBGL_TEXTURE_FORMATS = {\n // 8-bit formats\n 'r8unorm': { gl: 33321, rb: true },\n 'r8snorm': { gl: 36756 },\n 'r8uint': { gl: 33330, rb: true },\n 'r8sint': { gl: 33329, rb: true },\n // 16-bit formats\n 'rg8unorm': { gl: 33323, rb: true },\n 'rg8snorm': { gl: 36757 },\n 'rg8uint': { gl: 33336, rb: true },\n 'rg8sint': { gl: 33335, rb: true },\n 'r16uint': { gl: 33332, rb: true },\n 'r16sint': { gl: 33331, rb: true },\n 'r16float': { gl: 33325, rb: true },\n 'r16unorm': { gl: 33322, rb: true },\n 'r16snorm': { gl: 36760 },\n // Packed 16-bit formats\n 'rgba4unorm-webgl': { gl: 32854, rb: true },\n 'rgb565unorm-webgl': { gl: 36194, rb: true },\n 'rgb5a1unorm-webgl': { gl: 32855, rb: true },\n // 24-bit formats\n 'rgb8unorm-webgl': { gl: 32849 },\n 'rgb8snorm-webgl': { gl: 36758 },\n // 32-bit formats\n 'rgba8unorm': { gl: 32856 },\n 'rgba8unorm-srgb': { gl: 35907 },\n 'rgba8snorm': { gl: 36759 },\n 'rgba8uint': { gl: 36220 },\n 'rgba8sint': { gl: 36238 },\n // reverse colors, webgpu only\n 'bgra8unorm': {},\n 'bgra8unorm-srgb': {},\n 'rg16uint': { gl: 33338 },\n 'rg16sint': { gl: 33337 },\n 'rg16float': { gl: 33327, rb: true },\n 'rg16unorm': { gl: 33324 },\n 'rg16snorm': { gl: 36761 },\n 'r32uint': { gl: 33334, rb: true },\n 'r32sint': { gl: 33333, rb: true },\n 'r32float': { gl: 33326 },\n // Packed 32-bit formats\n 'rgb9e5ufloat': { gl: 35901 }, // , filter: true},\n 'rg11b10ufloat': { gl: 35898, rb: true },\n 'rgb10a2unorm': { gl: 32857, rb: true },\n 'rgb10a2uint': { gl: 36975, rb: true },\n // 48-bit formats\n 'rgb16unorm-webgl': { gl: 32852 }, // rgb not renderable\n 'rgb16snorm-webgl': { gl: 36762 }, // rgb not renderable\n // 64-bit formats\n 'rg32uint': { gl: 33340, rb: true },\n 'rg32sint': { gl: 33339, rb: true },\n 'rg32float': { gl: 33328, rb: true },\n 'rgba16uint': { gl: 36214, rb: true },\n 'rgba16sint': { gl: 36232, rb: true },\n 'rgba16float': { gl: 34842 },\n 'rgba16unorm': { gl: 32859, rb: true },\n 'rgba16snorm': { gl: 36763 },\n // 96-bit formats (deprecated!)\n 'rgb32float-webgl': { gl: 34837, x: EXT_color_buffer_float, dataFormat: 6407, types: [5126] },\n // 128-bit formats\n 'rgba32uint': { gl: 36208, rb: true },\n 'rgba32sint': { gl: 36226, rb: true },\n 'rgba32float': { gl: 34836, rb: true },\n // Depth and stencil formats\n 'stencil8': { gl: 36168, rb: true }, // 8 stencil bits\n 'depth16unorm': { gl: 33189, dataFormat: 6402, types: [5123], rb: true }, // 16 depth bits\n 'depth24plus': { gl: 33190, dataFormat: 6402, types: [5125] },\n 'depth32float': { gl: 36012, dataFormat: 6402, types: [5126], rb: true },\n // The depth component of the \"depth24plus\" and \"depth24plus-stencil8\" formats may be implemented as either a 24-bit depth value or a \"depth32float\" value.\n 'depth24plus-stencil8': { gl: 35056, rb: true, depthTexture: true, dataFormat: 34041, types: [34042] },\n // \"depth32float-stencil8\" feature - TODO below is render buffer only?\n 'depth32float-stencil8': { gl: 36013, dataFormat: 34041, types: [36269], rb: true },\n // BC compressed formats: check device.features.has(\"texture-compression-bc\");\n 'bc1-rgb-unorm-webgl': { gl: 33776, x: X_S3TC },\n 'bc1-rgb-unorm-srgb-webgl': { gl: 35916, x: X_S3TC_SRGB },\n 'bc1-rgba-unorm': { gl: 33777, x: X_S3TC },\n 'bc1-rgba-unorm-srgb': { gl: 35916, x: X_S3TC_SRGB },\n 'bc2-rgba-unorm': { gl: 33778, x: X_S3TC },\n 'bc2-rgba-unorm-srgb': { gl: 35918, x: X_S3TC_SRGB },\n 'bc3-rgba-unorm': { gl: 33779, x: X_S3TC },\n 'bc3-rgba-unorm-srgb': { gl: 35919, x: X_S3TC_SRGB },\n 'bc4-r-unorm': { gl: 36283, x: X_RGTC },\n 'bc4-r-snorm': { gl: 36284, x: X_RGTC },\n 'bc5-rg-unorm': { gl: 36285, x: X_RGTC },\n 'bc5-rg-snorm': { gl: 36286, x: X_RGTC },\n 'bc6h-rgb-ufloat': { gl: 36495, x: X_BPTC },\n 'bc6h-rgb-float': { gl: 36494, x: X_BPTC },\n 'bc7-rgba-unorm': { gl: 36492, x: X_BPTC },\n 'bc7-rgba-unorm-srgb': { gl: 36493, x: X_BPTC },\n // WEBGL_compressed_texture_etc: device.features.has(\"texture-compression-etc2\")\n // Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression\n 'etc2-rgb8unorm': { gl: 37492 },\n 'etc2-rgb8unorm-srgb': { gl: 37494 },\n 'etc2-rgb8a1unorm': { gl: 37496 },\n 'etc2-rgb8a1unorm-srgb': { gl: 37497 },\n 'etc2-rgba8unorm': { gl: 37493 },\n 'etc2-rgba8unorm-srgb': { gl: 37495 },\n 'eac-r11unorm': { gl: 37488 },\n 'eac-r11snorm': { gl: 37489 },\n 'eac-rg11unorm': { gl: 37490 },\n 'eac-rg11snorm': { gl: 37491 },\n // X_ASTC compressed formats: device.features.has(\"texture-compression-astc\")\n 'astc-4x4-unorm': { gl: 37808 },\n 'astc-4x4-unorm-srgb': { gl: 37840 },\n 'astc-5x4-unorm': { gl: 37809 },\n 'astc-5x4-unorm-srgb': { gl: 37841 },\n 'astc-5x5-unorm': { gl: 37810 },\n 'astc-5x5-unorm-srgb': { gl: 37842 },\n 'astc-6x5-unorm': { gl: 37811 },\n 'astc-6x5-unorm-srgb': { gl: 37843 },\n 'astc-6x6-unorm': { gl: 37812 },\n 'astc-6x6-unorm-srgb': { gl: 37844 },\n 'astc-8x5-unorm': { gl: 37813 },\n 'astc-8x5-unorm-srgb': { gl: 37845 },\n 'astc-8x6-unorm': { gl: 37814 },\n 'astc-8x6-unorm-srgb': { gl: 37846 },\n 'astc-8x8-unorm': { gl: 37815 },\n 'astc-8x8-unorm-srgb': { gl: 37847 },\n 'astc-10x5-unorm': { gl: 37819 },\n 'astc-10x5-unorm-srgb': { gl: 37851 },\n 'astc-10x6-unorm': { gl: 37817 },\n 'astc-10x6-unorm-srgb': { gl: 37849 },\n 'astc-10x8-unorm': { gl: 37818 },\n 'astc-10x8-unorm-srgb': { gl: 37850 },\n 'astc-10x10-unorm': { gl: 37819 },\n 'astc-10x10-unorm-srgb': { gl: 37851 },\n 'astc-12x10-unorm': { gl: 37820 },\n 'astc-12x10-unorm-srgb': { gl: 37852 },\n 'astc-12x12-unorm': { gl: 37821 },\n 'astc-12x12-unorm-srgb': { gl: 37853 },\n // WEBGL_compressed_texture_pvrtc\n 'pvrtc-rgb4unorm-webgl': { gl: 35840 },\n 'pvrtc-rgba4unorm-webgl': { gl: 35842 },\n 'pvrtc-rbg2unorm-webgl': { gl: 35841 },\n 'pvrtc-rgba2unorm-webgl': { gl: 35843 },\n // WEBGL_compressed_texture_etc1\n 'etc1-rbg-unorm-webgl': { gl: 36196 },\n // WEBGL_compressed_texture_atc\n 'atc-rgb-unorm-webgl': { gl: 35986 },\n 'atc-rgba-unorm-webgl': { gl: 35986 },\n 'atc-rgbai-unorm-webgl': { gl: 34798 }\n};\n// FUNCTIONS\n/** Checks if a texture format is supported */\nexport function isWebGLTextureFormatCapabilitiesed(gl, format, extensions) {\n const webglTextureInfo = WEBGL_TEXTURE_FORMATS[format];\n // Check that we have a GL constant\n if (!webglTextureInfo?.gl) {\n return false;\n }\n // Check extensions\n const extension = webglTextureInfo.x;\n if (extension) {\n return Boolean(getWebGLExtension(gl, extension, extensions));\n }\n return true;\n}\n/** Checks if a texture format is supported, renderable, filterable etc */\nexport function getTextureFormatCapabilitiesWebGL(gl, formatSupport, extensions) {\n let supported = formatSupport.create;\n const webglFormatInfo = WEBGL_TEXTURE_FORMATS[formatSupport.format];\n // Support Check that we have a GL constant\n if (webglFormatInfo?.gl === undefined) {\n supported = false;\n }\n if (webglFormatInfo?.x) {\n supported = supported && Boolean(getWebGLExtension(gl, webglFormatInfo.x, extensions));\n }\n return {\n format: formatSupport.format,\n // @ts-ignore\n create: supported && formatSupport.create,\n // @ts-ignore\n render: supported && formatSupport.render,\n // @ts-ignore\n filter: supported && formatSupport.filter,\n // @ts-ignore\n blend: supported && formatSupport.blend,\n // @ts-ignore\n store: supported && formatSupport.store\n };\n}\n/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */\nexport function getTextureFormatWebGL(format) {\n const formatData = WEBGL_TEXTURE_FORMATS[format];\n const webglFormat = convertTextureFormatToGL(format);\n const decoded = textureFormatDecoder.getInfo(format);\n if (decoded.compressed) {\n // TODO: Unclear whether this is always valid, this may be why ETC2 RGBA8 fails.\n formatData.dataFormat = webglFormat;\n }\n return {\n internalFormat: webglFormat,\n format: formatData?.dataFormat ||\n getWebGLPixelDataFormat(decoded.channels, decoded.integer, decoded.normalized, webglFormat),\n // depth formats don't have a type\n type: decoded.dataType\n ? getGLFromVertexType(decoded.dataType)\n : formatData?.types?.[0] || 5121,\n compressed: decoded.compressed || false\n };\n}\nexport function getDepthStencilAttachmentWebGL(format) {\n const formatInfo = textureFormatDecoder.getInfo(format);\n switch (formatInfo.attachment) {\n case 'depth':\n return 36096;\n case 'stencil':\n return 36128;\n case 'depth-stencil':\n return 33306;\n default:\n throw new Error(`Not a depth stencil format: ${format}`);\n }\n}\n/** TODO - VERY roundabout legacy way of calculating bytes per pixel */\nexport function getTextureFormatBytesPerPixel(format) {\n const formatInfo = textureFormatDecoder.getInfo(format);\n return formatInfo.bytesPerPixel;\n}\n// DATA TYPE HELPERS\nexport function getWebGLPixelDataFormat(channels, integer, normalized, format) {\n // WebGL1 formats use same internalFormat\n if (format === 6408 || format === 6407) {\n return format;\n }\n // prettier-ignore\n switch (channels) {\n case 'r': return integer && !normalized ? 36244 : 6403;\n case 'rg': return integer && !normalized ? 33320 : 33319;\n case 'rgb': return integer && !normalized ? 36248 : 6407;\n case 'rgba': return integer && !normalized ? 36249 : 6408;\n case 'bgra': throw new Error('bgra pixels not supported by WebGL');\n default: return 6408;\n }\n}\n/**\n * Map WebGPU style texture format strings to GL constants\n */\nfunction convertTextureFormatToGL(format) {\n const formatInfo = WEBGL_TEXTURE_FORMATS[format];\n const webglFormat = formatInfo?.gl;\n if (webglFormat === undefined) {\n throw new Error(`Unsupported texture format ${format}`);\n }\n return webglFormat;\n}\n//# sourceMappingURL=webgl-texture-table.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Feature detection for WebGL\n// Provides a function that enables simple checking of which WebGL features are\nimport { DeviceFeatures } from '@luma.gl/core';\nimport { getWebGLExtension } from \"../../context/helpers/webgl-extensions.js\";\nimport { isTextureFeature, checkTextureFeature, TEXTURE_FEATURES } from \"../converters/webgl-texture-table.js\";\n/**\n * Defines luma.gl \"feature\" names and semantics\n * when value is 'string' it is the name of the extension that enables this feature\n */\nconst WEBGL_FEATURES = {\n // optional WebGPU features\n 'depth-clip-control': 'EXT_depth_clamp', // TODO these seem subtly different\n // 'timestamp-query' // GPUQueryType \"timestamp-query\"\n // \"indirect-first-instance\"\n // Textures are handled by getTextureFeatures()\n // 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'\n // optional WebGL features\n 'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',\n 'compilation-status-async-webgl': 'KHR_parallel_shader_compile',\n 'polygon-mode-webgl': 'WEBGL_polygon_mode',\n 'provoking-vertex-webgl': 'WEBGL_provoking_vertex',\n 'shader-clip-cull-distance-webgl': 'WEBGL_clip_cull_distance',\n 'shader-noperspective-interpolation-webgl': 'NV_shader_noperspective_interpolation',\n 'shader-conservative-depth-webgl': 'EXT_conservative_depth'\n // Textures are handled by getTextureFeatures()\n};\n/**\n * WebGL extensions exposed as luma.gl features\n * To minimize GL log noise and improve performance, this class ensures that\n * - WebGL extensions are not queried until the corresponding feature is checked.\n * - WebGL extensions are only queried once.\n */\nexport class WebGLDeviceFeatures extends DeviceFeatures {\n gl;\n extensions;\n testedFeatures = new Set();\n constructor(gl, extensions, disabledFeatures) {\n super([], disabledFeatures);\n this.gl = gl;\n this.extensions = extensions;\n // TODO - is this really needed?\n // Enable EXT_float_blend first: https://developer.mozilla.org/en-US/docs/Web/API/EXT_float_blend\n getWebGLExtension(gl, 'EXT_color_buffer_float', extensions);\n }\n *[Symbol.iterator]() {\n const features = this.getFeatures();\n for (const feature of features) {\n if (this.has(feature)) {\n yield feature;\n }\n }\n return [];\n }\n has(feature) {\n if (this.disabledFeatures?.[feature]) {\n return false;\n }\n // We have already tested this feature\n if (!this.testedFeatures.has(feature)) {\n this.testedFeatures.add(feature);\n // Check the feature once\n if (isTextureFeature(feature) && checkTextureFeature(this.gl, feature, this.extensions)) {\n this.features.add(feature);\n }\n if (this.getWebGLFeature(feature)) {\n this.features.add(feature);\n }\n }\n return this.features.has(feature);\n }\n // FOR DEVICE\n initializeFeatures() {\n // Initialize all features by checking them.\n // Except WEBGL_polygon_mode since Chrome logs ugly console warnings\n const features = this.getFeatures().filter(feature => feature !== 'polygon-mode-webgl');\n for (const feature of features) {\n this.has(feature);\n }\n }\n // IMPLEMENTATION\n getFeatures() {\n return [...Object.keys(WEBGL_FEATURES), ...Object.keys(TEXTURE_FEATURES)];\n }\n /** Extract all WebGL features */\n getWebGLFeature(feature) {\n const featureInfo = WEBGL_FEATURES[feature];\n // string value requires checking the corresponding WebGL extension\n const isSupported = typeof featureInfo === 'string'\n ? Boolean(getWebGLExtension(this.gl, featureInfo, this.extensions))\n : Boolean(featureInfo);\n return isSupported;\n }\n}\n//# sourceMappingURL=webgl-device-features.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { DeviceLimits } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\n// prettier-ignore\nexport class WebGLDeviceLimits extends DeviceLimits {\n get maxTextureDimension1D() { return 0; } // WebGL does not support 1D textures\n get maxTextureDimension2D() { return this.getParameter(3379); }\n get maxTextureDimension3D() { return this.getParameter(32883); }\n get maxTextureArrayLayers() { return this.getParameter(35071); }\n get maxBindGroups() { return 0; }\n get maxDynamicUniformBuffersPerPipelineLayout() { return 0; } // TBD\n get maxDynamicStorageBuffersPerPipelineLayout() { return 0; } // TBD\n get maxSampledTexturesPerShaderStage() { return this.getParameter(35660); } // ) TBD\n get maxSamplersPerShaderStage() { return this.getParameter(35661); }\n get maxStorageBuffersPerShaderStage() { return 0; } // TBD\n get maxStorageTexturesPerShaderStage() { return 0; } // TBD\n get maxUniformBuffersPerShaderStage() { return this.getParameter(35375); }\n get maxUniformBufferBindingSize() { return this.getParameter(35376); }\n get maxStorageBufferBindingSize() { return 0; }\n get minUniformBufferOffsetAlignment() { return this.getParameter(35380); }\n get minStorageBufferOffsetAlignment() { return 0; }\n get maxVertexBuffers() { return 16; } // WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284\n get maxVertexAttributes() { return this.getParameter(34921); }\n get maxVertexBufferArrayStride() { return 2048; } // TBD, this is just the default value from WebGPU\n get maxInterStageShaderVariables() { return this.getParameter(35659); }\n get maxComputeWorkgroupStorageSize() { return 0; } // WebGL does not support compute shaders\n get maxComputeInvocationsPerWorkgroup() { return 0; } // WebGL does not support compute shaders\n get maxComputeWorkgroupSizeX() { return 0; } // WebGL does not support compute shaders\n get maxComputeWorkgroupSizeY() { return 0; } // WebGL does not support compute shaders\n get maxComputeWorkgroupSizeZ() { return 0; } // WebGL does not support compute shaders\n get maxComputeWorkgroupsPerDimension() { return 0; } // WebGL does not support compute shaders\n // PRIVATE\n gl;\n limits = {};\n constructor(gl) {\n super();\n this.gl = gl;\n }\n getParameter(parameter) {\n if (this.limits[parameter] === undefined) {\n this.limits[parameter] = this.gl.getParameter(parameter);\n }\n return this.limits[parameter] || 0;\n }\n}\n//# sourceMappingURL=webgl-device-limits.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Framebuffer } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { getDepthStencilAttachmentWebGL } from \"../converters/webgl-texture-table.js\";\n/** luma.gl Framebuffer, WebGL implementation */\nexport class WEBGLFramebuffer extends Framebuffer {\n device;\n gl;\n handle;\n colorAttachments = [];\n depthStencilAttachment = null;\n constructor(device, props) {\n super(device, props);\n // WebGL default framebuffer handle is null\n const isDefaultFramebuffer = props.handle === null;\n this.device = device;\n this.gl = device.gl;\n this.handle =\n this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();\n if (!isDefaultFramebuffer) {\n // default framebuffer handle is null, so we can't set debug metadata...\n device._setWebGLDebugMetadata(this.handle, this, { spector: this.props });\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n this.updateAttachments();\n }\n }\n /** destroys any auto created resources etc. */\n destroy() {\n super.destroy(); // destroys owned resources etc.\n if (!this.destroyed && this.handle !== null) {\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n }\n }\n updateAttachments() {\n /** Attach from a map of attachments */\n // @ts-expect-error native bindFramebuffer is overridden by our state tracker\n const prevHandle = this.gl.bindFramebuffer(36160, this.handle);\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n if (attachment) {\n const attachmentPoint = 36064 + i;\n this._attachTextureView(attachmentPoint, attachment);\n }\n }\n if (this.depthStencilAttachment) {\n const attachmentPoint = getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format);\n this._attachTextureView(attachmentPoint, this.depthStencilAttachment);\n }\n /** Check the status */\n if (this.device.props.debug) {\n const status = this.gl.checkFramebufferStatus(36160);\n if (status !== 36053) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n this.gl.bindFramebuffer(36160, prevHandle);\n }\n // PRIVATE\n /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */\n // protected override createDepthStencilTexture(format: TextureFormat): Texture {\n // // return new WEBGLRenderbuffer(this.device, {\n // return new WEBGLTexture(this.device, {\n // id: `${this.id}-depth-stencil`,\n // format,\n // width: this.width,\n // height: this.height,\n // mipmaps: false\n // });\n // }\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel\n */\n _attachTextureView(attachment, textureView) {\n const { gl } = this.device;\n const { texture } = textureView;\n const level = textureView.props.baseMipLevel;\n const layer = textureView.props.baseArrayLayer;\n gl.bindTexture(texture.glTarget, texture.handle);\n switch (texture.glTarget) {\n case 35866:\n case 32879:\n gl.framebufferTextureLayer(36160, attachment, texture.handle, level, layer);\n break;\n case 34067:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(36160, attachment, face, texture.handle, level);\n break;\n case 3553:\n gl.framebufferTexture2D(36160, attachment, 3553, texture.handle, level);\n break;\n default:\n throw new Error('Illegal texture type');\n }\n gl.bindTexture(texture.glTarget, null);\n }\n}\n// Helper functions\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer) {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < 34069\n ? layer + 34069\n : layer;\n}\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status) {\n switch (status) {\n case 36053:\n return 'success';\n case 36054:\n return 'Mismatched attachments';\n case 36055:\n return 'No attachments';\n case 36057:\n return 'Height/width mismatch';\n case 36061:\n return 'Unsupported or split attachments';\n // WebGL2\n case 36182:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n/**\n * Attachment resize is expected to be a noop if size is same\n *\nprotected override resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n // TODO Not clear that this is better than default destroy/create implementation\n\n for (const colorAttachment of this.colorAttachments) {\n colorAttachment.texture.clone({width, height});\n }\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.texture.resize({width, height});\n }\n return this;\n}\n*/\n//# sourceMappingURL=webgl-framebuffer.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { CanvasContext } from '@luma.gl/core';\nimport { WEBGLFramebuffer } from \"./resources/webgl-framebuffer.js\";\n/**\n * A WebGL Canvas Context which manages the canvas and handles drawing buffer resizing etc\n */\nexport class WebGLCanvasContext extends CanvasContext {\n device;\n handle = null;\n _framebuffer = null;\n get [Symbol.toStringTag]() {\n return 'WebGLCanvasContext';\n }\n constructor(device, props) {\n // Note: Base class creates / looks up the canvas (unless under Node.js)\n super(props);\n this.device = device;\n // Base class constructor cannot access derived methods/fields, so we need to call these functions in the subclass constructor\n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n this._updateDevice();\n }\n getCurrentFramebuffer() {\n // Setting handle to null returns a reference to the default framebuffer\n this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, { handle: null });\n return this._framebuffer;\n }\n // IMPLEMENTATION OF ABSTRACT METHODS\n _updateDevice() { }\n}\n//# sourceMappingURL=webgl-canvas-context.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nconst uidCounters = {};\n/**\n * Returns a UID.\n * @param id= - Identifier base name\n * @return uid\n **/\nexport function uid(id = 'id') {\n uidCounters[id] = uidCounters[id] || 1;\n const count = uidCounters[id]++;\n return `${id}-${count}`;\n}\n//# sourceMappingURL=uid.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Buffer } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\n/** WebGL Buffer interface */\nexport class WEBGLBuffer extends Buffer {\n device;\n gl;\n handle;\n /** Target in OpenGL defines the type of buffer */\n glTarget;\n /** Usage is a hint on how frequently the buffer will be updates */\n glUsage;\n /** Index type is needed when issuing draw calls, so we pre-compute it */\n glIndexType = 5123;\n /** Number of bytes allocated on the GPU for this buffer */\n byteLength = 0;\n /** Number of bytes used */\n bytesUsed = 0;\n constructor(device, props = {}) {\n super(device, props);\n this.device = device;\n this.gl = this.device.gl;\n const handle = typeof props === 'object' ? props.handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n device._setWebGLDebugMetadata(this.handle, this, {\n spector: { ...this.props, data: typeof this.props.data }\n });\n // - In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // - In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n this.glTarget = getWebGLTarget(this.props.usage);\n this.glUsage = getWebGLUsage(this.props.usage);\n this.glIndexType = this.props.indexType === 'uint32' ? 5125 : 5123;\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n }\n else {\n this._initWithByteLength(props.byteLength || 0);\n }\n }\n destroy() {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // @ts-expect-error\n this.handle = null;\n }\n }\n /** Allocate a new buffer and initialize to contents of typed array */\n _initWithData(data, byteOffset = 0, byteLength = data.byteLength + byteOffset) {\n // const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n const glTarget = this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, byteLength, this.glUsage);\n this.gl.bufferSubData(glTarget, byteOffset, data);\n this.gl.bindBuffer(glTarget, null);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this._setDebugData(data, byteOffset, byteLength);\n this.trackAllocatedMemory(byteLength);\n }\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength) {\n // assert(byteLength >= 0);\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n // const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n const glTarget = this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, data, this.glUsage);\n this.gl.bindBuffer(glTarget, null);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this._setDebugData(null, 0, byteLength);\n this.trackAllocatedMemory(byteLength);\n return this;\n }\n write(data, byteOffset = 0) {\n const dataView = ArrayBuffer.isView(data) ? data : new Uint8Array(data);\n const srcOffset = 0;\n const byteLength = undefined; // data.byteLength;\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const glTarget = 36663;\n this.gl.bindBuffer(glTarget, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.gl.bufferSubData(glTarget, byteOffset, dataView, srcOffset, byteLength);\n }\n else {\n this.gl.bufferSubData(glTarget, byteOffset, dataView);\n }\n this.gl.bindBuffer(glTarget, null);\n this._setDebugData(data, byteOffset, data.byteLength);\n }\n async mapAndWriteAsync(callback, byteOffset = 0, byteLength = this.byteLength - byteOffset) {\n const arrayBuffer = new ArrayBuffer(byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n await callback(arrayBuffer, 'copied');\n this.write(arrayBuffer, byteOffset);\n }\n async readAsync(byteOffset = 0, byteLength) {\n return this.readSyncWebGL(byteOffset, byteLength);\n }\n async mapAndReadAsync(callback, byteOffset = 0, byteLength) {\n const data = await this.readAsync(byteOffset, byteLength);\n // eslint-disable-next-line @typescript-eslint/await-thenable\n return await callback(data.buffer, 'copied');\n }\n readSyncWebGL(byteOffset = 0, byteLength) {\n byteLength = byteLength ?? this.byteLength - byteOffset;\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(36662, this.handle);\n this.gl.getBufferSubData(36662, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(36662, null);\n // Update local `data` if offsets are 0\n this._setDebugData(data, byteOffset, byteLength);\n return data;\n }\n}\n/**\n * Returns a WebGL buffer target\n *\n * @param usage\n * static MAP_READ = 0x01;\n * static MAP_WRITE = 0x02;\n * static COPY_SRC = 0x0004;\n * static COPY_DST = 0x0008;\n * static INDEX = 0x0010;\n * static VERTEX = 0x0020;\n * static UNIFORM = 0x0040;\n * static STORAGE = 0x0080;\n * static INDIRECT = 0x0100;\n * static QUERY_RESOLVE = 0x0200;\n *\n * @returns WebGL buffer targe\n *\n * Buffer bind points in WebGL2\n * gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n * gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n * gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n * gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n * gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n */\nfunction getWebGLTarget(usage) {\n if (usage & Buffer.INDEX) {\n return 34963;\n }\n if (usage & Buffer.VERTEX) {\n return 34962;\n }\n if (usage & Buffer.UNIFORM) {\n return 35345;\n }\n // Binding a buffer for the first time locks the type\n // In WebGL2, we can use GL.COPY_WRITE_BUFFER to avoid locking the type\n return 34962;\n}\n/** @todo usage is not passed correctly */\nfunction getWebGLUsage(usage) {\n if (usage & Buffer.INDEX) {\n return 35044;\n }\n if (usage & Buffer.VERTEX) {\n return 35044;\n }\n if (usage & Buffer.UNIFORM) {\n return 35048;\n }\n return 35044;\n}\n//# sourceMappingURL=webgl-buffer.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * Parse a WebGL-format GLSL compilation log into an array of WebGPU style message records.\n * This follows documented WebGL conventions for compilation logs.\n * Based on https://github.com/wwwtyro/gl-format-compiler-error (public domain)\n */\nexport function parseShaderCompilerLog(errLog) {\n // Parse the error - note: browser and driver dependent\n const lines = errLog.split(/\\r?\\n/);\n const messages = [];\n for (const line of lines) {\n if (line.length <= 1) {\n continue; // eslint-disable-line no-continue\n }\n const segments = line.split(':');\n // Check for messages with no line information `ERROR: unsupported shader version`\n if (segments.length === 2) {\n const [messageType, message] = segments;\n messages.push({\n message: message.trim(),\n type: getMessageType(messageType),\n lineNum: 0,\n linePos: 0\n });\n continue; // eslint-disable-line no-continue\n }\n const [messageType, linePosition, lineNumber, ...rest] = segments;\n let lineNum = parseInt(lineNumber, 10);\n if (isNaN(lineNum)) {\n lineNum = 0;\n }\n let linePos = parseInt(linePosition, 10);\n if (isNaN(linePos)) {\n linePos = 0;\n }\n messages.push({\n message: rest.join(':').trim(),\n type: getMessageType(messageType),\n lineNum,\n linePos // TODO\n });\n }\n return messages;\n}\n/** Ensure supported type */\nfunction getMessageType(messageType) {\n const MESSAGE_TYPES = ['warning', 'error', 'info'];\n const lowerCaseType = messageType.toLowerCase();\n return (MESSAGE_TYPES.includes(lowerCaseType) ? lowerCaseType : 'info');\n}\n//# sourceMappingURL=parse-shader-compiler-log.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Shader, log } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { parseShaderCompilerLog } from \"../helpers/parse-shader-compiler-log.js\";\n/**\n * An immutable compiled shader program that execute portions of the GPU Pipeline\n */\nexport class WEBGLShader extends Shader {\n device;\n handle;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n switch (this.props.stage) {\n case 'vertex':\n this.handle = this.props.handle || this.device.gl.createShader(35633);\n break;\n case 'fragment':\n this.handle = this.props.handle || this.device.gl.createShader(35632);\n break;\n default:\n throw new Error(this.props.stage);\n }\n // default framebuffer handle is null, so we can't set spector metadata...\n device._setWebGLDebugMetadata(this.handle, this, { spector: this.props });\n this._compile(this.source);\n }\n destroy() {\n if (this.handle) {\n this.removeStats();\n this.device.gl.deleteShader(this.handle);\n this.destroyed = true;\n // @ts-expect-error\n this.handle.destroyed = true;\n // this.handle = null;\n }\n }\n get asyncCompilationStatus() {\n return this._waitForCompilationComplete().then(() => {\n this._getCompilationStatus();\n return this.compilationStatus;\n });\n }\n async getCompilationInfo() {\n await this._waitForCompilationComplete();\n return this.getCompilationInfoSync();\n }\n getCompilationInfoSync() {\n const shaderLog = this.device.gl.getShaderInfoLog(this.handle);\n return shaderLog ? parseShaderCompilerLog(shaderLog) : [];\n }\n getTranslatedSource() {\n const extensions = this.device.getExtension('WEBGL_debug_shaders');\n const ext = extensions.WEBGL_debug_shaders;\n return ext?.getTranslatedShaderSource(this.handle) || null;\n }\n // PRIVATE METHODS\n /** Compile a shader and get compilation status */\n async _compile(source) {\n source = source.startsWith('#version ') ? source : `#version 300 es\\n${source}`;\n const { gl } = this.device;\n gl.shaderSource(this.handle, source);\n gl.compileShader(this.handle);\n // For performance reasons, avoid checking shader compilation errors on production\n if (!this.device.props.debug) {\n this.compilationStatus = 'pending';\n return;\n }\n // Sync case - slower, but advantage is that it throws in the constructor, making break on error more useful\n if (!this.device.features.has('compilation-status-async-webgl')) {\n this._getCompilationStatus();\n // The `Shader` base class will determine if debug window should be opened based on this.compilationStatus\n this.debugShader();\n if (this.compilationStatus === 'error') {\n throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);\n }\n return;\n }\n // async case\n log.once(1, 'Shader compilation is asynchronous')();\n await this._waitForCompilationComplete();\n log.info(2, `Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)();\n this._getCompilationStatus();\n // The `Shader` base class will determine if debug window should be opened based on this.compilationStatus\n this.debugShader();\n }\n /** Use KHR_parallel_shader_compile extension if available */\n async _waitForCompilationComplete() {\n const waitMs = async (ms) => await new Promise(resolve => setTimeout(resolve, ms));\n const DELAY_MS = 10; // Shader compilation is typically quite fast (with some exceptions)\n // If status polling is not available, we can't wait for completion. Just wait a little to minimize blocking\n if (!this.device.features.has('compilation-status-async-webgl')) {\n await waitMs(DELAY_MS);\n return;\n }\n const { gl } = this.device;\n for (;;) {\n const complete = gl.getShaderParameter(this.handle, 37297);\n if (complete) {\n return;\n }\n await waitMs(DELAY_MS);\n }\n }\n /**\n * Get the shader compilation status\n * TODO - Load log even when no error reported, to catch warnings?\n * https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings\n */\n _getCompilationStatus() {\n this.compilationStatus = this.device.gl.getShaderParameter(this.handle, 35713)\n ? 'success'\n : 'error';\n }\n}\n// TODO - Original code from luma.gl v8 - keep until new debug functionality has matured\n// if (!compilationSuccess) {\n// const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];\n// const messages = parsedLog.filter(message => message.type === 'error');\n// const formattedLog = formatCompilerLog(messages, source, {showSourceCode: 'all', html: true});\n// const shaderDescription = `${this.stage} shader ${shaderName}`;\n// log.error(`GLSL compilation errors in ${shaderDescription}\\n${formattedLog}`)();\n// displayShaderLog(parsedLog, source, shaderName);\n// }\n//# sourceMappingURL=webgl-shader.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { log } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { setGLParameters } from \"../../context/parameters/unified-parameter-api.js\";\n/* eslint-disable no-unused-expressions */ // For expression ? gl.enable() : gl.disable()\n/**\n * Execute a function with a set of temporary WebGL parameter overrides\n * - Saves current \"global\" WebGL context settings\n * - Sets the supplies WebGL context parameters,\n * - Executes supplied function\n * - Restores parameters\n * - Returns the return value of the supplied function\n */\nexport function withDeviceAndGLParameters(device, parameters, glParameters, func) {\n if (isObjectEmpty(parameters)) {\n // Avoid setting state if no parameters provided. Just call and return\n return func(device);\n }\n // Wrap in a try-catch to ensure that parameters are restored on exceptions\n const webglDevice = device;\n webglDevice.pushState();\n try {\n setDeviceParameters(device, parameters);\n setGLParameters(webglDevice.gl, glParameters);\n return func(device);\n }\n finally {\n webglDevice.popState();\n }\n}\n/**\n * Execute a function with a set of temporary WebGL parameter overrides\n * - Saves current \"global\" WebGL context settings\n * - Sets the supplies WebGL context parameters,\n * - Executes supplied function\n * - Restores parameters\n * - Returns the return value of the supplied function\n * @deprecated use withDeviceParameters instead\n */\nexport function withGLParameters(device, parameters, func) {\n if (isObjectEmpty(parameters)) {\n // Avoid setting state if no parameters provided. Just call and return\n return func(device);\n }\n // Wrap in a try-catch to ensure that parameters are restored on exceptions\n const webglDevice = device;\n webglDevice.pushState();\n try {\n setGLParameters(webglDevice.gl, parameters);\n return func(device);\n }\n finally {\n webglDevice.popState();\n }\n}\n/**\n * Execute a function with a set of temporary WebGL parameter overrides\n * - Saves current \"global\" WebGL context settings\n * - Sets the supplies WebGL context parameters,\n * - Executes supplied function\n * - Restores parameters\n * - Returns the return value of the supplied function\n */\nexport function withDeviceParameters(device, parameters, func) {\n if (isObjectEmpty(parameters)) {\n // Avoid setting state if no parameters provided. Just call and return\n return func(device);\n }\n // Wrap in a try-catch to ensure that parameters are restored on exceptions'\n const webglDevice = device;\n webglDevice.pushState();\n try {\n setDeviceParameters(device, parameters);\n return func(device);\n }\n finally {\n webglDevice.popState();\n }\n}\n/** Set WebGPU Style Parameters */\nexport function setDeviceParameters(device, parameters) {\n const webglDevice = device;\n const { gl } = webglDevice;\n // RASTERIZATION SETTINGS\n if (parameters.cullMode) {\n switch (parameters.cullMode) {\n case 'none':\n gl.disable(2884);\n break;\n case 'front':\n gl.enable(2884);\n gl.cullFace(1028);\n break;\n case 'back':\n gl.enable(2884);\n gl.cullFace(1029);\n break;\n }\n }\n if (parameters.frontFace) {\n gl.frontFace(map('frontFace', parameters.frontFace, {\n ccw: 2305,\n cw: 2304\n }));\n }\n if (parameters.unclippedDepth) {\n if (device.features.has('depth-clip-control')) {\n // EXT_depth_clamp\n gl.enable(34383);\n }\n }\n if (parameters.depthBias !== undefined) {\n gl.enable(32823);\n gl.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);\n }\n // depthBiasSlopeScale: {\n // // Handled by depthBias\n // },\n // WEBGL EXTENSIONS\n if (parameters.provokingVertex) {\n if (device.features.has('provoking-vertex-webgl')) {\n const extensions = webglDevice.getExtension('WEBGL_provoking_vertex');\n const ext = extensions.WEBGL_provoking_vertex;\n const vertex = map('provokingVertex', parameters.provokingVertex, {\n first: 36429,\n last: 36430\n });\n ext?.provokingVertexWEBGL(vertex);\n }\n }\n if (parameters.polygonMode || parameters.polygonOffsetLine) {\n if (device.features.has('polygon-mode-webgl')) {\n if (parameters.polygonMode) {\n const extensions = webglDevice.getExtension('WEBGL_polygon_mode');\n const ext = extensions.WEBGL_polygon_mode;\n const mode = map('polygonMode', parameters.polygonMode, {\n fill: 6914,\n line: 6913\n });\n ext?.polygonModeWEBGL(1028, mode);\n ext?.polygonModeWEBGL(1029, mode);\n }\n if (parameters.polygonOffsetLine) {\n gl.enable(10754);\n }\n }\n }\n if (device.features.has('shader-clip-cull-distance-webgl')) {\n if (parameters.clipDistance0) {\n gl.enable(12288);\n }\n if (parameters.clipDistance1) {\n gl.enable(12289);\n }\n if (parameters.clipDistance2) {\n gl.enable(12290);\n }\n if (parameters.clipDistance3) {\n gl.enable(12291);\n }\n if (parameters.clipDistance4) {\n gl.enable(12292);\n }\n if (parameters.clipDistance5) {\n gl.enable(12293);\n }\n if (parameters.clipDistance6) {\n gl.enable(12294);\n }\n if (parameters.clipDistance7) {\n gl.enable(12295);\n }\n }\n // DEPTH STENCIL\n if (parameters.depthWriteEnabled !== undefined) {\n gl.depthMask(mapBoolean('depthWriteEnabled', parameters.depthWriteEnabled));\n }\n if (parameters.depthCompare) {\n parameters.depthCompare !== 'always' ? gl.enable(2929) : gl.disable(2929);\n gl.depthFunc(convertCompareFunction('depthCompare', parameters.depthCompare));\n }\n if (parameters.stencilWriteMask) {\n const mask = parameters.stencilWriteMask;\n gl.stencilMaskSeparate(1028, mask);\n gl.stencilMaskSeparate(1029, mask);\n }\n if (parameters.stencilReadMask) {\n // stencilReadMask is handle inside stencil***Compare.\n log.warn('stencilReadMask not supported under WebGL');\n }\n if (parameters.stencilCompare) {\n const mask = parameters.stencilReadMask || 0xffffffff;\n const glValue = convertCompareFunction('depthCompare', parameters.stencilCompare);\n // TODO - ensure back doesn't overwrite\n parameters.stencilCompare !== 'always'\n ? gl.enable(2960)\n : gl.disable(2960);\n gl.stencilFuncSeparate(1028, glValue, 0, mask);\n gl.stencilFuncSeparate(1029, glValue, 0, mask);\n }\n if (parameters.stencilPassOperation &&\n parameters.stencilFailOperation &&\n parameters.stencilDepthFailOperation) {\n const dppass = convertStencilOperation('stencilPassOperation', parameters.stencilPassOperation);\n const sfail = convertStencilOperation('stencilFailOperation', parameters.stencilFailOperation);\n const dpfail = convertStencilOperation('stencilDepthFailOperation', parameters.stencilDepthFailOperation);\n gl.stencilOpSeparate(1028, sfail, dpfail, dppass);\n gl.stencilOpSeparate(1029, sfail, dpfail, dppass);\n }\n // stencilDepthFailOperation() {\n // // handled by stencilPassOperation\n // },\n // stencilFailOperation() {\n // // handled by stencilPassOperation\n // },\n // COLOR STATE\n switch (parameters.blend) {\n case true:\n gl.enable(3042);\n break;\n case false:\n gl.disable(3042);\n break;\n default:\n // leave WebGL blend state unchanged if `parameters.blend` is not set\n }\n if (parameters.blendColorOperation || parameters.blendAlphaOperation) {\n const colorEquation = convertBlendOperationToEquation('blendColorOperation', parameters.blendColorOperation || 'add');\n const alphaEquation = convertBlendOperationToEquation('blendAlphaOperation', parameters.blendAlphaOperation || 'add');\n gl.blendEquationSeparate(colorEquation, alphaEquation);\n const colorSrcFactor = convertBlendFactorToFunction('blendColorSrcFactor', parameters.blendColorSrcFactor || 'one');\n const colorDstFactor = convertBlendFactorToFunction('blendColorDstFactor', parameters.blendColorDstFactor || 'zero');\n const alphaSrcFactor = convertBlendFactorToFunction('blendAlphaSrcFactor', parameters.blendAlphaSrcFactor || 'one');\n const alphaDstFactor = convertBlendFactorToFunction('blendAlphaDstFactor', parameters.blendAlphaDstFactor || 'zero');\n gl.blendFuncSeparate(colorSrcFactor, colorDstFactor, alphaSrcFactor, alphaDstFactor);\n }\n}\n/*\n rasterizationState: {\n cullMode: \"back\",\n },\n\n depthStencilState: {\n depthWriteEnabled: true,\n depthCompare: \"less\",\n format: \"depth24plus-stencil8\",\n },\n\n colorStates: [\n {\n format: \"bgra8unorm\",\n // colorBlend.srcFactor = wgpu::BlendFactor::SrcAlpha;\n // colorBlend.dstFactor = wgpu::BlendFactor::OneMinusSrcAlpha;\n // alphaBlend.srcFactor = wgpu::BlendFactor::SrcAlpha;\n // alphaBlend.dstFactor = wgpu::BlendFactor::OneMinusSrcAlpha;\n },\n ],\n });\n*/\nexport function convertCompareFunction(parameter, value) {\n return map(parameter, value, {\n never: 512,\n less: 513,\n equal: 514,\n 'less-equal': 515,\n greater: 516,\n 'not-equal': 517,\n 'greater-equal': 518,\n always: 519\n });\n}\nexport function convertToCompareFunction(parameter, value) {\n return map(parameter, value, {\n [512]: 'never',\n [513]: 'less',\n [514]: 'equal',\n [515]: 'less-equal',\n [516]: 'greater',\n [517]: 'not-equal',\n [518]: 'greater-equal',\n [519]: 'always'\n });\n}\nfunction convertStencilOperation(parameter, value) {\n return map(parameter, value, {\n keep: 7680,\n zero: 0,\n replace: 7681,\n invert: 5386,\n 'increment-clamp': 7682,\n 'decrement-clamp': 7683,\n 'increment-wrap': 34055,\n 'decrement-wrap': 34056\n });\n}\nfunction convertBlendOperationToEquation(parameter, value) {\n return map(parameter, value, {\n add: 32774,\n subtract: 32778,\n 'reverse-subtract': 32779,\n min: 32775,\n max: 32776\n });\n}\nfunction convertBlendFactorToFunction(parameter, value, type = 'color') {\n return map(parameter, value, {\n one: 1,\n zero: 0,\n src: 768,\n 'one-minus-src': 769,\n dst: 774,\n 'one-minus-dst': 775,\n 'src-alpha': 770,\n 'one-minus-src-alpha': 771,\n 'dst-alpha': 772,\n 'one-minus-dst-alpha': 773,\n 'src-alpha-saturated': 776,\n constant: type === 'color' ? 32769 : 32771,\n 'one-minus-constant': type === 'color' ? 32770 : 32772,\n // 'constant-alpha': GL.CONSTANT_ALPHA,\n // 'one-minus-constant-alpha': GL.ONE_MINUS_CONSTANT_ALPHA,\n // TODO not supported in WebGL2\n src1: 768,\n 'one-minus-src1': 769,\n 'src1-alpha': 770,\n 'one-minus-src1-alpha': 771\n });\n}\nfunction message(parameter, value) {\n return `Illegal parameter ${value} for ${parameter}`;\n}\nfunction map(parameter, value, valueMap) {\n if (!(value in valueMap)) {\n throw new Error(message(parameter, value));\n }\n return valueMap[value];\n}\nfunction mapBoolean(parameter, value) {\n return value;\n}\n/** Returns true if given object is empty, false otherwise. */\nfunction isObjectEmpty(obj) {\n let isEmpty = true;\n // @ts-ignore key is unused\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n for (const key in obj) {\n isEmpty = false;\n break;\n }\n return isEmpty;\n}\n//# sourceMappingURL=device-parameters.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { GL } from '@luma.gl/constants';\nimport { convertCompareFunction } from \"./device-parameters.js\";\n/**\n * Convert WebGPU-style sampler props to WebGL\n * @param props\n * @returns\n */\nexport function convertSamplerParametersToWebGL(props) {\n const params = {};\n if (props.addressModeU) {\n params[10242] = convertAddressMode(props.addressModeU);\n }\n if (props.addressModeV) {\n params[10243] = convertAddressMode(props.addressModeV);\n }\n if (props.addressModeW) {\n params[32882] = convertAddressMode(props.addressModeW);\n }\n if (props.magFilter) {\n params[10240] = convertMaxFilterMode(props.magFilter);\n }\n if (props.minFilter || props.mipmapFilter) {\n // TODO - arbitrary choice of linear?\n params[10241] = convertMinFilterMode(props.minFilter || 'linear', props.mipmapFilter);\n }\n if (props.lodMinClamp !== undefined) {\n params[33082] = props.lodMinClamp;\n }\n if (props.lodMaxClamp !== undefined) {\n params[33083] = props.lodMaxClamp;\n }\n if (props.type === 'comparison-sampler') {\n // Setting prop.compare turns this into a comparison sampler\n params[34892] = 34894;\n }\n if (props.compare) {\n params[34893] = convertCompareFunction('compare', props.compare);\n }\n // Note depends on WebGL extension\n if (props.maxAnisotropy) {\n params[34046] = props.maxAnisotropy;\n }\n return params;\n}\n// HELPERS\n/** Convert address more */\nfunction convertAddressMode(addressMode) {\n switch (addressMode) {\n case 'clamp-to-edge':\n return 33071;\n case 'repeat':\n return 10497;\n case 'mirror-repeat':\n return 33648;\n }\n}\nfunction convertMaxFilterMode(maxFilter) {\n switch (maxFilter) {\n case 'nearest':\n return 9728;\n case 'linear':\n return 9729;\n }\n}\n/**\n * WebGPU has separate min filter and mipmap filter,\n * WebGL is combined and effectively offers 6 options\n */\nfunction convertMinFilterMode(minFilter, mipmapFilter = 'none') {\n if (!mipmapFilter) {\n return convertMaxFilterMode(minFilter);\n }\n switch (mipmapFilter) {\n case 'none':\n return convertMaxFilterMode(minFilter);\n case 'nearest':\n switch (minFilter) {\n case 'nearest':\n return 9984;\n case 'linear':\n return 9985;\n }\n break;\n case 'linear':\n switch (minFilter) {\n case 'nearest':\n return 9986;\n case 'linear':\n return 9987;\n }\n }\n}\n//# sourceMappingURL=sampler-parameters.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Sampler } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { convertSamplerParametersToWebGL } from \"../converters/sampler-parameters.js\";\n/**\n * Sampler object -\n * so that they can be set directly on the texture\n * https://github.com/WebGLSamples/WebGL2Samples/blob/master/samples/sampler_object.html\n */\nexport class WEBGLSampler extends Sampler {\n device;\n handle;\n parameters;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.parameters = convertSamplerParametersToWebGL(props);\n this.handle = props.handle || this.device.gl.createSampler();\n this._setSamplerParameters(this.parameters);\n }\n destroy() {\n if (this.handle) {\n this.device.gl.deleteSampler(this.handle);\n // @ts-expect-error read-only/undefined\n this.handle = undefined;\n }\n }\n toString() {\n return `Sampler(${this.id},${JSON.stringify(this.props)})`;\n }\n /** Set sampler parameters on the sampler */\n _setSamplerParameters(parameters) {\n for (const [pname, value] of Object.entries(parameters)) {\n // Apparently there are integer/float conversion issues requires two parameter setting functions in JavaScript.\n // For now, pick the float version for parameters specified as GLfloat.\n const param = Number(pname);\n switch (param) {\n case 33082:\n case 33083:\n this.device.gl.samplerParameterf(this.handle, param, value);\n break;\n default:\n this.device.gl.samplerParameteri(this.handle, param, value);\n break;\n }\n }\n }\n}\n//# sourceMappingURL=webgl-sampler.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { setGLParameters } from \"../parameters/unified-parameter-api.js\";\nimport { WebGLStateTracker } from \"./webgl-state-tracker.js\";\n/**\n * Execute a function with a set of temporary WebGL parameter overrides\n * - Saves current \"global\" WebGL context settings\n * - Sets the supplies WebGL context parameters,\n * - Executes supplied function\n * - Restores parameters\n * - Returns the return value of the supplied function\n */\nexport function withGLParameters(gl, parameters, func) {\n if (isObjectEmpty(parameters)) {\n // Avoid setting state if no parameters provided. Just call and return\n return func(gl);\n }\n const { nocatch = true } = parameters;\n const webglState = WebGLStateTracker.get(gl);\n webglState.push();\n setGLParameters(gl, parameters);\n // Setup is done, call the function\n let value;\n if (nocatch) {\n // Avoid try catch to minimize stack size impact for safe execution paths\n value = func(gl);\n webglState.pop();\n }\n else {\n // Wrap in a try-catch to ensure that parameters are restored on exceptions\n try {\n value = func(gl);\n }\n finally {\n webglState.pop();\n }\n }\n return value;\n}\n// Helpers\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(object) {\n // @ts-ignore - dummy key variable\n for (const key in object) {\n return false;\n }\n return true;\n}\n//# sourceMappingURL=with-parameters.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// import {getTextureFormatInfo} from '@luma.gl/core';\nimport { TextureView, Texture } from '@luma.gl/core';\nexport class WEBGLTextureView extends TextureView {\n device;\n gl;\n handle; // Does not have a WebGL representation\n texture;\n constructor(device, props) {\n super(device, { ...Texture.defaultProps, ...props });\n this.device = device;\n this.gl = this.device.gl;\n this.handle = null;\n this.texture = props.texture;\n }\n}\n//# sourceMappingURL=webgl-texture-view.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Texture, log } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { getTextureFormatWebGL } from \"../converters/webgl-texture-table.js\";\nimport { convertSamplerParametersToWebGL } from \"../converters/sampler-parameters.js\";\nimport { withGLParameters } from \"../../context/state-tracker/with-parameters.js\";\nimport { WEBGLTextureView } from \"./webgl-texture-view.js\";\n/**\n * WebGL... the texture API from hell... hopefully made simpler\n */\nexport class WEBGLTexture extends Texture {\n // readonly MAX_ATTRIBUTES: number;\n device;\n gl;\n handle;\n // @ts-ignore TODO - currently unused in WebGL. Create dummy sampler?\n sampler = undefined;\n view;\n /**\n * The WebGL target corresponding to the texture type\n * @note `target` cannot be modified by bind:\n * textures are special because when you first bind them to a target,\n * When you first bind a texture as a GL_TEXTURE_2D, you are saying that this texture is a 2D texture.\n * And it will always be a 2D texture; this state cannot be changed ever.\n * A texture that was first bound as a GL_TEXTURE_2D, must always be bound as a GL_TEXTURE_2D;\n * attempting to bind it as GL_TEXTURE_3D will give rise to a run-time error\n */\n glTarget;\n /** The WebGL format - essentially channel structure */\n glFormat;\n /** The WebGL data format - the type of each channel */\n glType;\n /** The WebGL constant corresponding to the WebGPU style constant in format */\n glInternalFormat;\n /** Whether the internal format is compressed */\n compressed;\n // state\n /** Texture binding slot - TODO - move to texture view? */\n _textureUnit = 0;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.gl = this.device.gl;\n const formatInfo = getTextureFormatWebGL(this.props.format);\n // Note: In WebGL the texture target defines the type of texture on first bind.\n this.glTarget = getWebGLTextureTarget(this.props.dimension);\n this.glInternalFormat = formatInfo.internalFormat;\n this.glFormat = formatInfo.format;\n this.glType = formatInfo.type;\n this.compressed = formatInfo.compressed;\n this.handle = this.props.handle || this.gl.createTexture();\n this.device._setWebGLDebugMetadata(this.handle, this, { spector: this.props });\n /**\n * Use WebGL immutable texture storage to allocate and clear texture memory.\n * - texStorage2D should be considered a preferred alternative to texImage2D. It may have lower memory costs than texImage2D in some implementations.\n * - Once texStorage*D has been called, the texture is immutable and can only be updated with texSubImage*(), not texImage()\n * @see https://registry.khronos.org/webgl/specs/latest/2.0/ WebGL 2 spec section 3.7.6\n */\n this.gl.bindTexture(this.glTarget, this.handle);\n const { dimension, width, height, depth, mipLevels, glTarget, glInternalFormat } = this;\n switch (dimension) {\n case '2d':\n case 'cube':\n this.gl.texStorage2D(glTarget, mipLevels, glInternalFormat, width, height);\n break;\n case '2d-array':\n case '3d':\n this.gl.texStorage3D(glTarget, mipLevels, glInternalFormat, width, height, depth);\n break;\n default:\n throw new Error(dimension);\n }\n this.gl.bindTexture(this.glTarget, null);\n // Set data\n this._initializeData(props.data);\n // Set texture sampler parameters\n this.setSampler(this.props.sampler);\n // @ts-ignore TODO - fix types\n this.view = new WEBGLTextureView(this.device, { ...this.props, texture: this });\n Object.seal(this);\n }\n destroy() {\n if (this.handle) {\n this.gl.deleteTexture(this.handle);\n this.removeStats();\n this.trackDeallocatedMemory('Texture');\n // this.handle = null;\n this.destroyed = true;\n }\n }\n createView(props) {\n return new WEBGLTextureView(this.device, { ...props, texture: this });\n }\n setSampler(sampler = {}) {\n super.setSampler(sampler);\n // Apply sampler parameters to texture\n const parameters = convertSamplerParametersToWebGL(this.sampler.props);\n this._setSamplerParameters(parameters);\n }\n copyImageData(options_) {\n const options = this._normalizeCopyImageDataOptions(options_);\n const typedArray = options.data;\n const { width, height, depth } = this;\n const { mipLevel = 0, byteOffset = 0, x = 0, y = 0, z = 0 } = options;\n const { glFormat, glType, compressed } = this;\n const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, depth);\n // WebGL automatically ignores these for compressed textures, but we are careful\n const glParameters = !this.compressed\n ? {\n [3314]: options.bytesPerRow,\n [32878]: options.rowsPerImage\n }\n : {};\n this.gl.bindTexture(glTarget, this.handle);\n withGLParameters(this.gl, glParameters, () => {\n switch (this.dimension) {\n case '2d':\n case 'cube':\n if (compressed) {\n // prettier-ignore\n this.gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, typedArray, byteOffset); // , byteLength\n }\n else {\n // prettier-ignore\n this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, typedArray, byteOffset); // , byteLength\n }\n break;\n case '2d-array':\n case '3d':\n if (compressed) {\n // prettier-ignore\n this.gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, typedArray, byteOffset); // , byteLength\n }\n else {\n // prettier-ignore\n this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, typedArray, byteOffset); // , byteLength\n }\n break;\n default:\n // Can never happen in WebGL\n }\n });\n this.gl.bindTexture(glTarget, null);\n }\n copyExternalImage(options_) {\n const options = this._normalizeCopyExternalImageOptions(options_);\n if (options.sourceX || options.sourceY) {\n // requires copyTexSubImage2D from a framebuffer'\n throw new Error('WebGL does not support sourceX/sourceY)');\n }\n const { glFormat, glType } = this;\n const { image, depth, mipLevel, x, y, z, width, height } = options;\n // WebGL cube maps specify faces by overriding target instead of using the depth parameter\n const glTarget = getWebGLCubeFaceTarget(this.glTarget, this.dimension, depth);\n const glParameters = options.flipY ? { [37440]: true } : {};\n this.gl.bindTexture(this.glTarget, this.handle);\n withGLParameters(this.gl, glParameters, () => {\n switch (this.dimension) {\n case '2d':\n case 'cube':\n // prettier-ignore\n this.gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);\n break;\n case '2d-array':\n case '3d':\n // prettier-ignore\n this.gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);\n break;\n default:\n // Can never happen in WebGL\n }\n });\n this.gl.bindTexture(this.glTarget, null);\n return { width: options.width, height: options.height };\n }\n // WEBGL SPECIFIC\n generateMipmapsWebGL(options) {\n const isFilterableAndRenderable = this.device.isTextureFormatRenderable(this.props.format) &&\n this.device.isTextureFormatFilterable(this.props.format);\n if (!isFilterableAndRenderable) {\n log.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)();\n if (!options?.force) {\n return;\n }\n }\n try {\n this.gl.bindTexture(this.glTarget, this.handle);\n this.gl.generateMipmap(this.glTarget);\n }\n catch (error) {\n log.warn(`Error generating mipmap for ${this}: ${error.message}`)();\n }\n finally {\n this.gl.bindTexture(this.glTarget, null);\n }\n }\n // INTERNAL\n /**\n * Sets sampler parameters on texture\n */\n _setSamplerParameters(parameters) {\n log.log(2, `${this.id} sampler parameters`, this.device.getGLKeys(parameters))();\n this.gl.bindTexture(this.glTarget, this.handle);\n for (const [pname, pvalue] of Object.entries(parameters)) {\n const param = Number(pname);\n const value = pvalue;\n // Apparently integer/float issues require two different texture parameter setting functions in JavaScript.\n // For now, pick the float version for parameters specified as GLfloat.\n switch (param) {\n case 33082:\n case 33083:\n this.gl.texParameterf(this.glTarget, param, value);\n break;\n case 10240:\n case 10241:\n this.gl.texParameteri(this.glTarget, param, value);\n break;\n case 10242:\n case 10243:\n case 32882:\n this.gl.texParameteri(this.glTarget, param, value);\n break;\n case 34046:\n // We have to query feature before using it\n if (this.device.features.has('texture-filterable-anisotropic-webgl')) {\n this.gl.texParameteri(this.glTarget, param, value);\n }\n break;\n case 34892:\n case 34893:\n this.gl.texParameteri(this.glTarget, param, value);\n break;\n }\n }\n this.gl.bindTexture(this.glTarget, null);\n }\n _getActiveUnit() {\n return this.gl.getParameter(34016) - 33984;\n }\n _bind(_textureUnit) {\n const { gl } = this;\n if (_textureUnit !== undefined) {\n this._textureUnit = _textureUnit;\n gl.activeTexture(33984 + _textureUnit);\n }\n gl.bindTexture(this.glTarget, this.handle);\n // @ts-ignore TODO fix types\n return _textureUnit;\n }\n _unbind(_textureUnit) {\n const { gl } = this;\n if (_textureUnit !== undefined) {\n this._textureUnit = _textureUnit;\n gl.activeTexture(33984 + _textureUnit);\n }\n gl.bindTexture(this.glTarget, null);\n return _textureUnit;\n }\n}\n// INTERNAL HELPERS\n/** Convert a WebGPU style texture constant to a WebGL style texture constant */\nexport function getWebGLTextureTarget(dimension) {\n // prettier-ignore\n switch (dimension) {\n case '1d': break; // not supported in any WebGL version\n case '2d': return 3553; // supported in WebGL1\n case '3d': return 32879; // supported in WebGL2\n case 'cube': return 34067; // supported in WebGL1\n case '2d-array': return 35866; // supported in WebGL2\n case 'cube-array': break; // not supported in any WebGL version\n }\n throw new Error(dimension);\n}\n/**\n * In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.\n * @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.\n * @returns glTarget unchanged, if dimension !== 'cube'.\n */\nexport function getWebGLCubeFaceTarget(glTarget, dimension, level) {\n return dimension === 'cube' ? 34069 + level : glTarget;\n}\n//# sourceMappingURL=webgl-texture.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { GL } from '@luma.gl/constants';\n/** Converts to a luma shadertype to a GL data type (GL.BYTE, GL.FLOAT32 etc) */\nexport function convertDataTypeToGLDataType(normalizedType) {\n return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];\n}\n/** Converts to a luma shadertype to a GL data type (GL.BYTE, GL.FLOAT32 etc) */\nexport function convertShaderVariableTypeToGLDataType(normalizedType) {\n // @ts-ignore TODO\n return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];\n}\n/** Convert a WebGL \"compisite type (e.g. GL.VEC3) into the corresponding luma shader uniform type */\nexport function convertGLUniformTypeToShaderVariableType(glUniformType) {\n return WEBGL_SHADER_TYPES[glUniformType];\n}\n/** Check if a WebGL \"uniform:\" is a texture binding */\nexport function isGLSamplerType(type) {\n // @ts-ignore TODO\n return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);\n}\n/* Get luma texture binding info (viewDimension and sampleType) from a WebGL \"sampler\" binding */\nexport function getTextureBindingFromGLSamplerType(glSamplerType) {\n return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];\n}\n/** Get vertex format from GL constants */\nexport function getVertexFormatFromGL(type, components) {\n const base = getVertexTypeFromGL(type);\n // prettier-ignore\n switch (components) {\n case 1: return base;\n case 2: return `${base}x2`;\n // @ts-expect-error - deal with lack of \"unaligned\" formats\n case 3: return `${base}x3`;\n case 4: return `${base}x4`;\n }\n // @ts-ignore unreachable\n throw new Error(String(components));\n}\n/** Get data type from GL constants */\nexport function getVertexTypeFromGL(glType, normalized = false) {\n const index = normalized ? 1 : 0;\n return WEBGL_TO_NORMALIZED_DATA_TYPE[glType][index];\n}\n// Composite types table\n// @ts-ignore TODO - fix the type confusion here\nconst WEBGL_SHADER_TYPES = {\n [5126]: 'f32',\n [35664]: 'vec2<f32>',\n [35665]: 'vec3<f32>',\n [35666]: 'vec4<f32>',\n [5124]: 'i32',\n [35667]: 'vec2<i32>',\n [35668]: 'vec3<i32>',\n [35669]: 'vec4<i32>',\n [5125]: 'u32',\n [36294]: 'vec2<u32>',\n [36295]: 'vec3<u32>',\n [36296]: 'vec4<u32>',\n [35670]: 'f32',\n [35671]: 'vec2<f32>',\n [35672]: 'vec3<f32>',\n [35673]: 'vec4<f32>',\n // TODO - are sizes/components below correct?\n [35674]: 'mat2x2<f32>',\n [35685]: 'mat2x3<f32>',\n [35686]: 'mat2x4<f32>',\n [35687]: 'mat3x2<f32>',\n [35675]: 'mat3x3<f32>',\n [35688]: 'mat3x4<f32>',\n [35689]: 'mat4x2<f32>',\n [35690]: 'mat4x3<f32>',\n [35676]: 'mat4x4<f32>'\n};\nconst WEBGL_SAMPLER_TO_TEXTURE_BINDINGS = {\n [35678]: { viewDimension: '2d', sampleType: 'float' },\n [35680]: { viewDimension: 'cube', sampleType: 'float' },\n [35679]: { viewDimension: '3d', sampleType: 'float' },\n [35682]: { viewDimension: '3d', sampleType: 'depth' },\n [36289]: { viewDimension: '2d-array', sampleType: 'float' },\n [36292]: { viewDimension: '2d-array', sampleType: 'depth' },\n [36293]: { viewDimension: 'cube', sampleType: 'float' },\n [36298]: { viewDimension: '2d', sampleType: 'sint' },\n [36299]: { viewDimension: '3d', sampleType: 'sint' },\n [36300]: { viewDimension: 'cube', sampleType: 'sint' },\n [36303]: { viewDimension: '2d-array', sampleType: 'uint' },\n [36306]: { viewDimension: '2d', sampleType: 'uint' },\n [36307]: { viewDimension: '3d', sampleType: 'uint' },\n [36308]: { viewDimension: 'cube', sampleType: 'uint' },\n [36311]: { viewDimension: '2d-array', sampleType: 'uint' }\n};\n/** Map from WebGL normalized types to WebGL */\nconst NORMALIZED_SHADER_TYPE_TO_WEBGL = {\n uint8: 5121,\n sint8: 5120,\n unorm8: 5121,\n snorm8: 5120,\n uint16: 5123,\n sint16: 5122,\n unorm16: 5123,\n snorm16: 5122,\n uint32: 5125,\n sint32: 5124,\n // WebGPU does not support normalized 32 bit integer attributes\n // 'unorm32': GL.UNSIGNED_INT,\n // 'snorm32': GL.INT,\n float16: 5131,\n float32: 5126\n};\n/* Map from WebGL types to webgpu normalized types */\nconst WEBGL_TO_NORMALIZED_DATA_TYPE = {\n [5120]: ['sint8', 'snorm16'],\n [5121]: ['uint8', 'unorm8'],\n [5122]: ['sint16', 'unorm16'],\n [5123]: ['uint16', 'unorm16'],\n [5124]: ['sint32', 'sint32'],\n [5125]: ['uint32', 'uint32'],\n [5126]: ['float32', 'float32'],\n [5131]: ['float16', 'float16']\n};\n//# sourceMappingURL=webgl-shadertypes.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { getVariableShaderTypeInfo } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { isGLSamplerType, getTextureBindingFromGLSamplerType, convertGLUniformTypeToShaderVariableType } from \"../converters/webgl-shadertypes.js\";\n/**\n * Extract metadata describing binding information for a program's shaders\n * Note: `linkProgram()` needs to have been called\n * (although linking does not need to have been successful).\n */\nexport function getShaderLayoutFromGLSL(gl, program) {\n const shaderLayout = {\n attributes: [],\n bindings: []\n };\n shaderLayout.attributes = readAttributeDeclarations(gl, program);\n // Uniform blocks\n const uniformBlocks = readUniformBlocks(gl, program);\n for (const uniformBlock of uniformBlocks) {\n const uniforms = uniformBlock.uniforms.map(uniform => ({\n name: uniform.name,\n format: uniform.format,\n byteOffset: uniform.byteOffset,\n byteStride: uniform.byteStride,\n arrayLength: uniform.arrayLength\n }));\n shaderLayout.bindings.push({\n type: 'uniform',\n name: uniformBlock.name,\n group: 0,\n location: uniformBlock.location,\n visibility: (uniformBlock.vertex ? 0x1 : 0) & (uniformBlock.fragment ? 0x2 : 0),\n minBindingSize: uniformBlock.byteLength,\n uniforms\n });\n }\n const uniforms = readUniformBindings(gl, program);\n let textureUnit = 0;\n for (const uniform of uniforms) {\n if (isGLSamplerType(uniform.type)) {\n const { viewDimension, sampleType } = getTextureBindingFromGLSamplerType(uniform.type);\n shaderLayout.bindings.push({\n type: 'texture',\n name: uniform.name,\n group: 0,\n location: textureUnit,\n viewDimension,\n sampleType\n });\n // @ts-expect-error\n uniform.textureUnit = textureUnit;\n textureUnit += 1;\n }\n }\n if (uniforms.length) {\n shaderLayout.uniforms = uniforms;\n }\n // Varyings\n const varyings = readVaryings(gl, program);\n // Note - samplers are always in unform bindings, even if uniform blocks are used\n if (varyings?.length) {\n shaderLayout.varyings = varyings;\n }\n return shaderLayout;\n}\n// HELPERS\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readAttributeDeclarations(gl, program) {\n const attributes = [];\n const count = gl.getProgramParameter(program, 35721);\n for (let index = 0; index < count; index++) {\n const activeInfo = gl.getActiveAttrib(program, index);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const { name, type: compositeType /* , size*/ } = activeInfo;\n const location = gl.getAttribLocation(program, name);\n // Add only user provided attributes, for built-in attributes like `gl_InstanceID` location will be < 0\n if (location >= 0) {\n const attributeType = convertGLUniformTypeToShaderVariableType(compositeType);\n // Whether an attribute is instanced is essentially fixed by the structure of the shader code,\n // so it is arguably a static property of the shader.\n // There is no hint in the shader declarations\n // Heuristic: Any attribute name containing the word \"instance\" will be assumed to be instanced\n const stepMode = /instance/i.test(name) ? 'instance' : 'vertex';\n attributes.push({\n name,\n location,\n stepMode,\n type: attributeType\n // size - for arrays, size is the number of elements in the array\n });\n }\n }\n // Sort by declaration order\n attributes.sort((a, b) => a.location - b.location);\n return attributes;\n}\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readVaryings(gl, program) {\n const varyings = [];\n const count = gl.getProgramParameter(program, 35971);\n for (let location = 0; location < count; location++) {\n const activeInfo = gl.getTransformFeedbackVarying(program, location);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const { name, type: glUniformType, size } = activeInfo;\n const uniformType = convertGLUniformTypeToShaderVariableType(glUniformType);\n const { type, components } = getVariableShaderTypeInfo(uniformType);\n varyings.push({ location, name, type, size: size * components });\n }\n varyings.sort((a, b) => a.location - b.location);\n return varyings;\n}\n/**\n * Extract info about all uniforms\n *\n * Query uniform locations and build name to setter map.\n */\nfunction readUniformBindings(gl, program) {\n const uniforms = [];\n const uniformCount = gl.getProgramParameter(program, 35718);\n for (let i = 0; i < uniformCount; i++) {\n const activeInfo = gl.getActiveUniform(program, i);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const { name: rawName, size, type } = activeInfo;\n const { name, isArray } = parseUniformName(rawName);\n let webglLocation = gl.getUniformLocation(program, name);\n const uniformInfo = {\n // WebGL locations are uniquely typed but just numbers\n location: webglLocation,\n name,\n size,\n type,\n isArray\n };\n uniforms.push(uniformInfo);\n // Array (e.g. matrix) uniforms can occupy several 4x4 byte banks\n if (uniformInfo.size > 1) {\n for (let j = 0; j < uniformInfo.size; j++) {\n const elementName = `${name}[${j}]`;\n webglLocation = gl.getUniformLocation(program, elementName);\n const arrayElementUniformInfo = {\n ...uniformInfo,\n name: elementName,\n location: webglLocation\n };\n uniforms.push(arrayElementUniformInfo);\n }\n }\n }\n return uniforms;\n}\n/**\n * Extract info about all \"active\" uniform blocks\n * @note In WebGL, \"active\" just means that unused (inactive) blocks may have been optimized away during linking)\n */\nfunction readUniformBlocks(gl, program) {\n const getBlockParameter = (blockIndex, pname) => gl.getActiveUniformBlockParameter(program, blockIndex, pname);\n const uniformBlocks = [];\n const blockCount = gl.getProgramParameter(program, 35382);\n for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {\n const blockInfo = {\n name: gl.getActiveUniformBlockName(program, blockIndex) || '',\n location: getBlockParameter(blockIndex, 35391),\n byteLength: getBlockParameter(blockIndex, 35392),\n vertex: getBlockParameter(blockIndex, 35396),\n fragment: getBlockParameter(blockIndex, 35398),\n uniformCount: getBlockParameter(blockIndex, 35394),\n uniforms: []\n };\n const uniformIndices = getBlockParameter(blockIndex, 35395) || [];\n const uniformType = gl.getActiveUniforms(program, uniformIndices, 35383); // Array of GLenum indicating the types of the uniforms.\n const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, 35384); // Array of GLuint indicating the sizes of the uniforms.\n // const uniformBlockIndex = gl.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_BLOCK_INDEX\n // ); // Array of GLint indicating the block indices of the uniforms.\n const uniformOffset = gl.getActiveUniforms(program, uniformIndices, 35387); // Array of GLint indicating the uniform buffer offsets.\n const uniformStride = gl.getActiveUniforms(program, uniformIndices, 35388); // Array of GLint indicating the strides between the elements.\n // const uniformMatrixStride = gl.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_MATRIX_STRIDE\n // ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.\n // const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);\n for (let i = 0; i < blockInfo.uniformCount; ++i) {\n const activeInfo = gl.getActiveUniform(program, uniformIndices[i]);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const format = convertGLUniformTypeToShaderVariableType(uniformType[i]);\n blockInfo.uniforms.push({\n name: activeInfo.name,\n format,\n type: uniformType[i],\n arrayLength: uniformArrayLength[i],\n byteOffset: uniformOffset[i],\n byteStride: uniformStride[i]\n // matrixStride: uniformStride[i],\n // rowMajor: uniformRowMajor[i]\n });\n }\n uniformBlocks.push(blockInfo);\n }\n uniformBlocks.sort((a, b) => a.location - b.location);\n return uniformBlocks;\n}\n/**\n * TOOD - compare with a above, confirm copy, then delete\n const bindings: Binding[] = [];\n const count = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < count; blockIndex++) {\n const vertex = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n const fragment = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n const visibility = (vertex) + (fragment);\n const binding: BufferBinding = {\n location: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_BINDING),\n // name: gl.getActiveUniformBlockName(program, blockIndex),\n type: 'uniform',\n visibility,\n minBindingSize: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_DATA_SIZE),\n // uniformCount: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n // uniformIndices: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),\n }\n bindings.push(binding);\n }\n*/\n// HELPERS\nfunction parseUniformName(name) {\n // Shortcut to avoid redundant or bad matches\n if (name[name.length - 1] !== ']') {\n return {\n name,\n length: 1,\n isArray: false\n };\n }\n // if array name then clean the array brackets\n const UNIFORM_NAME_REGEXP = /([^[]*)(\\[[0-9]+\\])?/;\n const matches = UNIFORM_NAME_REGEXP.exec(name);\n if (!matches || matches.length < 2) {\n throw new Error(`Failed to parse GLSL uniform name ${name}`);\n }\n return {\n name: matches[1],\n length: matches[2] ? 1 : 0,\n isArray: Boolean(matches[2])\n };\n}\n//# sourceMappingURL=get-shader-layout-from-glsl.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { GL } from '@luma.gl/constants';\n/** Set a raw uniform (without type conversion and caching) */\n/* eslint-disable max-len */\nexport function setUniform(gl, location, type, value) {\n const gl2 = gl;\n // Prepare the value for WebGL setters\n let uniformValue = value;\n if (uniformValue === true) {\n uniformValue = 1;\n }\n if (uniformValue === false) {\n uniformValue = 0;\n }\n const arrayValue = typeof uniformValue === 'number' ? [uniformValue] : uniformValue;\n // prettier-ignore\n switch (type) {\n case 35678:\n case 35680:\n case 35679:\n case 35682:\n case 36289:\n case 36292:\n case 36293:\n case 36298:\n case 36299:\n case 36300:\n case 36303:\n case 36306:\n case 36307:\n case 36308:\n case 36311:\n if (typeof value !== 'number') {\n throw new Error('samplers must be set to integers');\n }\n return gl.uniform1i(location, value);\n case 5126: return gl.uniform1fv(location, arrayValue);\n case 35664: return gl.uniform2fv(location, arrayValue);\n case 35665: return gl.uniform3fv(location, arrayValue);\n case 35666: return gl.uniform4fv(location, arrayValue);\n case 5124: return gl.uniform1iv(location, arrayValue);\n case 35667: return gl.uniform2iv(location, arrayValue);\n case 35668: return gl.uniform3iv(location, arrayValue);\n case 35669: return gl.uniform4iv(location, arrayValue);\n case 35670: return gl.uniform1iv(location, arrayValue);\n case 35671: return gl.uniform2iv(location, arrayValue);\n case 35672: return gl.uniform3iv(location, arrayValue);\n case 35673: return gl.uniform4iv(location, arrayValue);\n // WEBGL2 - unsigned integers\n case 5125: return gl2.uniform1uiv(location, arrayValue, 1);\n case 36294: return gl2.uniform2uiv(location, arrayValue, 2);\n case 36295: return gl2.uniform3uiv(location, arrayValue, 3);\n case 36296: return gl2.uniform4uiv(location, arrayValue, 4);\n // WebGL2 - quadratic matrices\n // false: don't transpose the matrix\n case 35674: return gl.uniformMatrix2fv(location, false, arrayValue);\n case 35675: return gl.uniformMatrix3fv(location, false, arrayValue);\n case 35676: return gl.uniformMatrix4fv(location, false, arrayValue);\n // WebGL2 - rectangular matrices\n case 35685: return gl2.uniformMatrix2x3fv(location, false, arrayValue);\n case 35686: return gl2.uniformMatrix2x4fv(location, false, arrayValue);\n case 35687: return gl2.uniformMatrix3x2fv(location, false, arrayValue);\n case 35688: return gl2.uniformMatrix3x4fv(location, false, arrayValue);\n case 35689: return gl2.uniformMatrix4x2fv(location, false, arrayValue);\n case 35690: return gl2.uniformMatrix4x3fv(location, false, arrayValue);\n }\n throw new Error('Illegal uniform');\n}\n//# sourceMappingURL=set-uniform.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { GL } from '@luma.gl/constants';\n// Counts the number of complete primitives given a number of vertices and a drawMode\nexport function getPrimitiveDrawMode(drawMode) {\n switch (drawMode) {\n case 0:\n return 0;\n case 1:\n return 1;\n case 3:\n return 1;\n case 2:\n return 1;\n case 4:\n return 4;\n case 5:\n return 4;\n case 6:\n return 4;\n default:\n throw new Error('drawMode');\n }\n}\n// Counts the number of complete \"primitives\" given a number of vertices and a drawMode\nexport function getPrimitiveCount(options) {\n const { drawMode, vertexCount } = options;\n switch (drawMode) {\n case 0:\n case 2:\n return vertexCount;\n case 1:\n return vertexCount / 2;\n case 3:\n return vertexCount - 1;\n case 4:\n return vertexCount / 3;\n case 5:\n case 6:\n return vertexCount - 2;\n default:\n throw new Error('drawMode');\n }\n}\n// Counts the number of vertices after splitting the vertex stream into separate \"primitives\"\nexport function getVertexCount(options) {\n const { drawMode, vertexCount } = options;\n const primitiveCount = getPrimitiveCount({ drawMode, vertexCount });\n switch (getPrimitiveDrawMode(drawMode)) {\n case 0:\n return primitiveCount;\n case 1:\n return primitiveCount * 2;\n case 4:\n return primitiveCount * 3;\n default:\n throw new Error('drawMode');\n }\n}\n/** Get the primitive type for draw */\nexport function getGLDrawMode(topology) {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return 0;\n case 'line-list': return 1;\n case 'line-strip': return 3;\n case 'triangle-list': return 4;\n case 'triangle-strip': return 5;\n default: throw new Error(topology);\n }\n}\n/** Get the primitive type for transform feedback */\nexport function getGLPrimitive(topology) {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return 0;\n case 'line-list': return 1;\n case 'line-strip': return 1;\n case 'triangle-list': return 4;\n case 'triangle-strip': return 4;\n default: throw new Error(topology);\n }\n}\n//# sourceMappingURL=webgl-topology-utils.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { RenderPipeline, log } from '@luma.gl/core';\n// import {getAttributeInfosFromLayouts} from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { getShaderLayoutFromGLSL } from \"../helpers/get-shader-layout-from-glsl.js\";\nimport { withDeviceAndGLParameters } from \"../converters/device-parameters.js\";\nimport { setUniform } from \"../helpers/set-uniform.js\";\nimport { WEBGLBuffer } from \"./webgl-buffer.js\";\nimport { WEBGLFramebuffer } from \"./webgl-framebuffer.js\";\nimport { WEBGLTexture } from \"./webgl-texture.js\";\nimport { WEBGLTextureView } from \"./webgl-texture-view.js\";\nimport { getGLDrawMode } from \"../helpers/webgl-topology-utils.js\";\nconst LOG_PROGRAM_PERF_PRIORITY = 4;\n/** Creates a new render pipeline */\nexport class WEBGLRenderPipeline extends RenderPipeline {\n /** The WebGL device that created this render pipeline */\n device;\n /** Handle to underlying WebGL program */\n handle;\n /** vertex shader */\n vs;\n /** fragment shader */\n fs;\n /** The layout extracted from shader by WebGL introspection APIs */\n introspectedLayout;\n /** Uniforms set on this model */\n uniforms = {};\n /** Bindings set on this model */\n bindings = {};\n /** WebGL varyings */\n varyings = null;\n _uniformCount = 0;\n _uniformSetters = {}; // TODO are these used?\n get [Symbol.toStringTag]() {\n return 'WEBGLRenderPipeline';\n }\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.gl.createProgram();\n this.device._setWebGLDebugMetadata(this.handle, this, { spector: { id: this.props.id } });\n // Create shaders if needed\n this.vs = props.vs;\n this.fs = props.fs;\n // assert(this.vs.stage === 'vertex');\n // assert(this.fs.stage === 'fragment');\n // Setup varyings if supplied\n // @ts-expect-error WebGL only\n const { varyings, bufferMode = 35981 } = props;\n if (varyings && varyings.length > 0) {\n this.varyings = varyings;\n this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);\n }\n this._linkShaders();\n log.time(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();\n this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);\n log.timeEnd(3, `RenderPipeline ${this.id} - shaderLayout introspection`)();\n // Merge provided layout with introspected layout\n this.shaderLayout = props.shaderLayout\n ? mergeShaderLayout(this.introspectedLayout, props.shaderLayout)\n : this.introspectedLayout;\n }\n destroy() {\n if (this.handle) {\n // log.error(`Deleting program ${this.id}`)();\n this.device.gl.useProgram(null);\n this.device.gl.deleteProgram(this.handle);\n this.destroyed = true;\n // @ts-expect-error\n this.handle.destroyed = true;\n // @ts-ignore\n this.handle = null;\n }\n }\n /**\n * Bindings include: textures, samplers and uniform buffers\n * @todo needed for portable model\n */\n setBindings(bindings, options) {\n // if (log.priority >= 2) {\n // checkUniformValues(uniforms, this.id, this._uniformSetters);\n // }\n for (const [name, value] of Object.entries(bindings)) {\n // Accept both `xyz` and `xyzUniforms` as valid names for `xyzUniforms` uniform block\n // This convention allows shaders to name uniform blocks as `uniform appUniforms {} app;`\n // and reference them as `app` from both GLSL and JS.\n // TODO - this is rather hacky - we could also remap the name directly in the shader layout.\n const binding = this.shaderLayout.bindings.find(binding_ => binding_.name === name) ||\n this.shaderLayout.bindings.find(binding_ => binding_.name === `${name}Uniforms`);\n if (!binding) {\n const validBindings = this.shaderLayout.bindings\n .map(binding_ => `\"${binding_.name}\"`)\n .join(', ');\n if (!options?.disableWarnings) {\n log.warn(`No binding \"${name}\" in render pipeline \"${this.id}\", expected one of ${validBindings}`, value)();\n }\n continue; // eslint-disable-line no-continue\n }\n if (!value) {\n log.warn(`Unsetting binding \"${name}\" in render pipeline \"${this.id}\"`)();\n }\n switch (binding.type) {\n case 'uniform':\n // @ts-expect-error\n if (!(value instanceof WEBGLBuffer) && !(value.buffer instanceof WEBGLBuffer)) {\n throw new Error('buffer value');\n }\n break;\n case 'texture':\n if (!(value instanceof WEBGLTextureView ||\n value instanceof WEBGLTexture ||\n value instanceof WEBGLFramebuffer)) {\n throw new Error(`${this} Bad texture binding for ${name}`);\n }\n break;\n case 'sampler':\n log.warn(`Ignoring sampler ${name}`)();\n break;\n default:\n throw new Error(binding.type);\n }\n this.bindings[name] = value;\n }\n }\n /** @todo needed for portable model\n * @note The WebGL API is offers many ways to draw things\n * This function unifies those ways into a single call using common parameters with sane defaults\n */\n draw(options) {\n const { renderPass, parameters = this.props.parameters, topology = this.props.topology, vertexArray, vertexCount, \n // indexCount,\n instanceCount, isInstanced = false, firstVertex = 0, \n // firstIndex,\n // firstInstance,\n // baseVertex,\n transformFeedback } = options;\n const glDrawMode = getGLDrawMode(topology);\n const isIndexed = Boolean(vertexArray.indexBuffer);\n const glIndexType = vertexArray.indexBuffer?.glIndexType;\n // Note that we sometimes get called with 0 instances\n // If we are using async linking, we need to wait until linking completes\n if (this.linkStatus !== 'success') {\n log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();\n return false;\n }\n // Avoid WebGL draw call when not rendering any data or values are incomplete\n // Note: async textures set as uniforms might still be loading.\n // Now that all uniforms have been updated, check if any texture\n // in the uniforms is not yet initialized, then we don't draw\n if (!this._areTexturesRenderable()) {\n log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();\n // Note: false means that the app needs to redraw the pipeline again.\n return false;\n }\n // (isInstanced && instanceCount === 0)\n // if (vertexCount === 0) {\n // log.info(2, `RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)();\n // Note: false means that the app needs to redraw the pipeline again.\n // return true;\n // }\n this.device.gl.useProgram(this.handle);\n // Note: Rebinds constant attributes before each draw call\n vertexArray.bindBeforeRender(renderPass);\n if (transformFeedback) {\n transformFeedback.begin(this.props.topology);\n }\n // We have to apply bindings before every draw call since other draw calls will overwrite\n this._applyBindings();\n this._applyUniforms();\n const webglRenderPass = renderPass;\n withDeviceAndGLParameters(this.device, parameters, webglRenderPass.glParameters, () => {\n if (isIndexed && isInstanced) {\n this.device.gl.drawElementsInstanced(glDrawMode, vertexCount || 0, // indexCount?\n glIndexType, firstVertex, instanceCount || 0);\n // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {\n // this.device.gldrawRangeElements(glDrawMode, start, end, vertexCount, glIndexType, offset);\n }\n else if (isIndexed) {\n this.device.gl.drawElements(glDrawMode, vertexCount || 0, glIndexType, firstVertex); // indexCount?\n }\n else if (isInstanced) {\n this.device.gl.drawArraysInstanced(glDrawMode, firstVertex, vertexCount || 0, instanceCount || 0);\n }\n else {\n this.device.gl.drawArrays(glDrawMode, firstVertex, vertexCount || 0);\n }\n if (transformFeedback) {\n transformFeedback.end();\n }\n });\n vertexArray.unbindAfterRender(renderPass);\n return true;\n }\n // PRIVATE METHODS\n // setAttributes(attributes: Record<string, Buffer>): void {}\n // setBindings(bindings: Record<string, Binding>): void {}\n async _linkShaders() {\n const { gl } = this.device;\n gl.attachShader(this.handle, this.vs.handle);\n gl.attachShader(this.handle, this.fs.handle);\n log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n gl.linkProgram(this.handle);\n log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n // TODO Avoid checking program linking error in production\n if (log.level === 0) {\n // return;\n }\n if (!this.device.features.has('compilation-status-async-webgl')) {\n const status = this._getLinkStatus();\n this._reportLinkStatus(status);\n return;\n }\n // async case\n log.once(1, 'RenderPipeline linking is asynchronous')();\n await this._waitForLinkComplete();\n log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();\n const status = this._getLinkStatus();\n this._reportLinkStatus(status);\n }\n /** Report link status. First, check for shader compilation failures if linking fails */\n async _reportLinkStatus(status) {\n switch (status) {\n case 'success':\n return;\n default:\n const errorType = status === 'link-error' ? 'Link error' : 'Validation error';\n // First check for shader compilation failures if linking fails\n switch (this.vs.compilationStatus) {\n case 'error':\n this.vs.debugShader();\n throw new Error(`${this} ${errorType} during compilation of ${this.vs}`);\n case 'pending':\n await this.vs.asyncCompilationStatus;\n this.vs.debugShader();\n break;\n case 'success':\n break;\n }\n switch (this.fs?.compilationStatus) {\n case 'error':\n this.fs.debugShader();\n throw new Error(`${this} ${errorType} during compilation of ${this.fs}`);\n case 'pending':\n await this.fs.asyncCompilationStatus;\n this.fs.debugShader();\n break;\n case 'success':\n break;\n }\n const linkErrorLog = this.device.gl.getProgramInfoLog(this.handle);\n this.device.reportError(new Error(`${errorType} during ${status}: ${linkErrorLog}`), this)();\n this.device.debug();\n }\n }\n /**\n * Get the shader compilation status\n * TODO - Load log even when no error reported, to catch warnings?\n * https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings\n */\n _getLinkStatus() {\n const { gl } = this.device;\n const linked = gl.getProgramParameter(this.handle, 35714);\n if (!linked) {\n this.linkStatus = 'error';\n return 'link-error';\n }\n gl.validateProgram(this.handle);\n const validated = gl.getProgramParameter(this.handle, 35715);\n if (!validated) {\n this.linkStatus = 'error';\n return 'validation-error';\n }\n this.linkStatus = 'success';\n return 'success';\n }\n /** Use KHR_parallel_shader_compile extension if available */\n async _waitForLinkComplete() {\n const waitMs = async (ms) => await new Promise(resolve => setTimeout(resolve, ms));\n const DELAY_MS = 10; // Shader compilation is typically quite fast (with some exceptions)\n // If status polling is not available, we can't wait for completion. Just wait a little to minimize blocking\n if (!this.device.features.has('compilation-status-async-webgl')) {\n await waitMs(DELAY_MS);\n return;\n }\n const { gl } = this.device;\n for (;;) {\n const complete = gl.getProgramParameter(this.handle, 37297);\n if (complete) {\n return;\n }\n await waitMs(DELAY_MS);\n }\n }\n /**\n * Checks if all texture-values uniforms are renderable (i.e. loaded)\n * Update a texture if needed (e.g. from video)\n * Note: This is currently done before every draw call\n */\n _areTexturesRenderable() {\n let texturesRenderable = true;\n for (const bindingInfo of this.shaderLayout.bindings) {\n if (!this.bindings[bindingInfo.name] &&\n !this.bindings[bindingInfo.name.replace(/Uniforms$/, '')]) {\n log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();\n texturesRenderable = false;\n }\n }\n // TODO - remove this should be handled by ExternalTexture\n // for (const [, texture] of Object.entries(this.bindings)) {\n // if (texture instanceof WEBGLTexture) {\n // texture.update();\n // }\n // }\n return texturesRenderable;\n }\n /** Apply any bindings (before each draw call) */\n _applyBindings() {\n // If we are using async linking, we need to wait until linking completes\n if (this.linkStatus !== 'success') {\n return;\n }\n const { gl } = this.device;\n gl.useProgram(this.handle);\n let textureUnit = 0;\n let uniformBufferIndex = 0;\n for (const binding of this.shaderLayout.bindings) {\n // Accept both `xyz` and `xyzUniforms` as valid names for `xyzUniforms` uniform block\n const value = this.bindings[binding.name] || this.bindings[binding.name.replace(/Uniforms$/, '')];\n if (!value) {\n throw new Error(`No value for binding ${binding.name} in ${this.id}`);\n }\n switch (binding.type) {\n case 'uniform':\n // Set buffer\n const { name } = binding;\n const location = gl.getUniformBlockIndex(this.handle, name);\n if (location === 4294967295) {\n throw new Error(`Invalid uniform block name ${name}`);\n }\n gl.uniformBlockBinding(this.handle, uniformBufferIndex, location);\n // console.debug(binding, location);\n if (value instanceof WEBGLBuffer) {\n gl.bindBufferBase(35345, uniformBufferIndex, value.handle);\n }\n else {\n gl.bindBufferRange(35345, uniformBufferIndex, \n // @ts-expect-error\n value.buffer.handle, \n // @ts-expect-error\n value.offset || 0, \n // @ts-expect-error\n value.size || value.buffer.byteLength - value.offset);\n }\n uniformBufferIndex += 1;\n break;\n case 'texture':\n if (!(value instanceof WEBGLTextureView ||\n value instanceof WEBGLTexture ||\n value instanceof WEBGLFramebuffer)) {\n throw new Error('texture');\n }\n let texture;\n if (value instanceof WEBGLTextureView) {\n texture = value.texture;\n }\n else if (value instanceof WEBGLTexture) {\n texture = value;\n }\n else if (value instanceof WEBGLFramebuffer &&\n value.colorAttachments[0] instanceof WEBGLTextureView) {\n log.warn('Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead')();\n texture = value.colorAttachments[0].texture;\n }\n else {\n throw new Error('No texture');\n }\n gl.activeTexture(33984 + textureUnit);\n gl.bindTexture(texture.glTarget, texture.handle);\n // gl.bindSampler(textureUnit, sampler.handle);\n textureUnit += 1;\n break;\n case 'sampler':\n // ignore\n break;\n case 'storage':\n case 'read-only-storage':\n throw new Error(`binding type '${binding.type}' not supported in WebGL`);\n }\n }\n }\n /**\n * Due to program sharing, uniforms need to be reset before every draw call\n * (though caching will avoid redundant WebGL calls)\n */\n _applyUniforms() {\n for (const uniformLayout of this.shaderLayout.uniforms || []) {\n const { name, location, type, textureUnit } = uniformLayout;\n const value = this.uniforms[name] ?? textureUnit;\n if (value !== undefined) {\n setUniform(this.device.gl, location, type, value);\n }\n }\n }\n}\n/**\n * Merges an provided shader layout into a base shader layout\n * In WebGL, this allows the auto generated shader layout to be overridden by the application\n * Typically to change the format of the vertex attributes (from float32x4 to uint8x4 etc).\n * @todo Drop this? Aren't all use cases covered by mergeBufferLayout()?\n */\nfunction mergeShaderLayout(baseLayout, overrideLayout) {\n // Deep clone the base layout\n const mergedLayout = {\n ...baseLayout,\n attributes: baseLayout.attributes.map(attribute => ({ ...attribute }))\n };\n // Merge the attributes\n for (const attribute of overrideLayout?.attributes || []) {\n const baseAttribute = mergedLayout.attributes.find(attr => attr.name === attribute.name);\n if (!baseAttribute) {\n log.warn(`shader layout attribute ${attribute.name} not present in shader`);\n }\n else {\n baseAttribute.type = attribute.type || baseAttribute.type;\n baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;\n }\n }\n return mergedLayout;\n}\n//# sourceMappingURL=webgl-render-pipeline.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { CommandBuffer, Texture } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { WEBGLTexture } from \"./webgl-texture.js\";\nimport { getTextureFormatWebGL } from \"../converters/webgl-texture-table.js\";\nexport class WEBGLCommandBuffer extends CommandBuffer {\n device;\n handle = null;\n commands = [];\n constructor(device) {\n super(device, {});\n this.device = device;\n }\n _executeCommands(commands = this.commands) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(this.device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(this.device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(this.device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(this.device, command.options);\n break;\n // case 'clear-texture':\n // _clearTexture(this.device, command.options);\n // break;\n default:\n throw new Error(command.name);\n }\n }\n }\n}\nfunction _copyBufferToBuffer(device, options) {\n const source = options.sourceBuffer;\n const destination = options.destinationBuffer;\n // {In WebGL2 we can p}erform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n device.gl.bindBuffer(36662, source.handle);\n device.gl.bindBuffer(36663, destination.handle);\n device.gl.copyBufferSubData(36662, 36663, options.sourceOffset ?? 0, options.destinationOffset ?? 0, options.size);\n device.gl.bindBuffer(36662, null);\n device.gl.bindBuffer(36663, null);\n}\n/**\n * Copies data from a Buffer object into a Texture object\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyBufferToTexture(device, options) {\n throw new Error('Not implemented');\n}\n/**\n * Copies data from a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyTextureToBuffer(device, options) {\n const { \n /** Texture to copy to/from. */\n sourceTexture, \n /** Mip-map level of the texture to copy to/from. (Default 0) */\n mipLevel = 0, \n /** Defines which aspects of the texture to copy to/from. */\n aspect = 'all', \n /** Width to copy */\n width = options.sourceTexture.width, \n /** Height to copy */\n height = options.sourceTexture.height, depthOrArrayLayers = 0, \n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0], \n /** Destination buffer */\n destinationBuffer, \n /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */\n byteOffset = 0, \n /**\n * The stride, in bytes, between the beginning of each block row and the subsequent block row.\n * Required if there are multiple block rows (i.e. the copy height or depth is more than one block).\n */\n bytesPerRow, \n /**\n * Number of block rows per single image of the texture.\n * rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.\n * Required if there are multiple images (i.e. the copy depth is more than one).\n */\n rowsPerImage } = options;\n // TODO - Not possible to read just stencil or depth part in WebGL?\n if (aspect !== 'all') {\n throw new Error('aspect not supported in WebGL');\n }\n // TODO - mipLevels are set when attaching texture to framebuffer\n if (mipLevel !== 0 || depthOrArrayLayers !== 0 || bytesPerRow || rowsPerImage) {\n throw new Error('not implemented');\n }\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const { framebuffer, destroyFramebuffer } = getFramebuffer(sourceTexture);\n let prevHandle;\n try {\n const webglBuffer = destinationBuffer;\n const sourceWidth = width || framebuffer.width;\n const sourceHeight = height || framebuffer.height;\n const sourceParams = getTextureFormatWebGL(framebuffer.colorAttachments[0].texture.props.format);\n const sourceFormat = sourceParams.format;\n const sourceType = sourceParams.type;\n // if (!target) {\n // // Create new buffer with enough size\n // const components = glFormatToComponents(sourceFormat);\n // const byteCount = glTypeToBytes(sourceType);\n // const byteLength = byteOffset + sourceWidth * sourceHeight * components * byteCount;\n // target = device.createBuffer({byteLength});\n // }\n device.gl.bindBuffer(35051, webglBuffer.handle);\n // @ts-expect-error native bindFramebuffer is overridden by our state tracker\n prevHandle = device.gl.bindFramebuffer(36160, framebuffer.handle);\n device.gl.readPixels(origin[0], origin[1], sourceWidth, sourceHeight, sourceFormat, sourceType, byteOffset);\n }\n finally {\n device.gl.bindBuffer(35051, null);\n // prevHandle may be unassigned if the try block failed before binding\n if (prevHandle !== undefined) {\n device.gl.bindFramebuffer(36160, prevHandle);\n }\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n }\n}\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transfer.\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer\n */\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n */\n// eslint-disable-next-line complexity, max-statements\nfunction _copyTextureToTexture(device, options) {\n const { \n /** Texture to copy to/from. */\n sourceTexture, \n /** Mip-map level of the texture to copy to (Default 0) */\n destinationMipLevel = 0, \n /** Defines which aspects of the texture to copy to/from. */\n // aspect = 'all',\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy from. */\n origin = [0, 0], \n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */\n destinationOrigin = [0, 0], \n /** Texture to copy to/from. */\n destinationTexture\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // destinationMipLevel = options.mipLevel,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n // destinationOrigin = [0, 0],\n /** Defines which aspects of the texture to copy to/from. */\n // destinationAspect = options.aspect,\n } = options;\n let { width = options.destinationTexture.width, height = options.destinationTexture.height\n // depthOrArrayLayers = 0\n } = options;\n const { framebuffer, destroyFramebuffer } = getFramebuffer(sourceTexture);\n const [sourceX, sourceY] = origin;\n const [destinationX, destinationY, destinationZ] = destinationOrigin;\n // @ts-expect-error native bindFramebuffer is overridden by our state tracker\n const prevHandle = device.gl.bindFramebuffer(36160, framebuffer.handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n let texture;\n let textureTarget;\n if (destinationTexture instanceof WEBGLTexture) {\n texture = destinationTexture;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture._bind(0);\n textureTarget = texture.glTarget;\n }\n else {\n throw new Error('invalid destination');\n }\n switch (textureTarget) {\n case 3553:\n case 34067:\n device.gl.copyTexSubImage2D(textureTarget, destinationMipLevel, destinationX, destinationY, sourceX, sourceY, width, height);\n break;\n case 35866:\n case 32879:\n device.gl.copyTexSubImage3D(textureTarget, destinationMipLevel, destinationX, destinationY, destinationZ, sourceX, sourceY, width, height);\n break;\n default:\n }\n if (texture) {\n texture._unbind();\n }\n device.gl.bindFramebuffer(36160, prevHandle);\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n}\n/** Clear one mip level of a texture *\nfunction _clearTexture(device: WebGLDevice, options: ClearTextureOptions) {\n const BORDER = 0;\n const {dimension, width, height, depth = 0, mipLevel = 0} = options;\n const {glInternalFormat, glFormat, glType, compressed} = options;\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n\n switch (dimension) {\n case '2d-array':\n case '3d':\n if (compressed) {\n // prettier-ignore\n device.gl.compressedTexImage3D(glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, null);\n } else {\n // prettier-ignore\n device.gl.texImage3D( glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);\n }\n break;\n\n case '2d':\n case 'cube':\n if (compressed) {\n // prettier-ignore\n device.gl.compressedTexImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, null);\n } else {\n // prettier-ignore\n device.gl.texImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, glFormat, glType, null);\n }\n break;\n\n default:\n throw new Error(dimension);\n }\n}\n */\n// function _readTexture(device: WebGLDevice, options: CopyTextureToBufferOptions) {}\n// HELPERS\n/**\n * In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.\n * @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.\n * @returns glTarget unchanged, if dimension !== 'cube'.\n */\nexport function getWebGLCubeFaceTarget(glTarget, dimension, level) {\n return dimension === 'cube' ? 34069 + level : glTarget;\n}\n/** Wrap a texture in a framebuffer so that we can use WebGL APIs that work on framebuffers */\nfunction getFramebuffer(source) {\n if (source instanceof Texture) {\n const { width, height, id } = source;\n const framebuffer = source.device.createFramebuffer({\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [source]\n });\n return { framebuffer, destroyFramebuffer: true };\n }\n return { framebuffer: source, destroyFramebuffer: false };\n}\n/**\n * Returns number of components in a specific readPixels WebGL format\n * @todo use shadertypes utils instead?\n */\nexport function glFormatToComponents(format) {\n switch (format) {\n case 6406:\n case 33326:\n case 6403:\n return 1;\n case 33328:\n case 33319:\n return 2;\n case 6407:\n case 34837:\n return 3;\n case 6408:\n case 34836:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n throw new Error('GLFormat');\n }\n}\n/**\n * Return byte count for given readPixels WebGL type\n * @todo use shadertypes utils instead?\n */\nexport function glTypeToBytes(type) {\n switch (type) {\n case 5121:\n return 1;\n case 33635:\n case 32819:\n case 32820:\n return 2;\n case 5126:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n throw new Error('GLType');\n }\n}\n//# sourceMappingURL=webgl-command-buffer.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { RenderPass } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { withGLParameters } from \"../../context/state-tracker/with-parameters.js\";\nimport { setGLParameters } from \"../../context/parameters/unified-parameter-api.js\";\nconst COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPUColorWrite RED, GREEN, BLUE, ALPHA\nexport class WEBGLRenderPass extends RenderPass {\n device;\n handle = null;\n /** Parameters that should be applied before each draw call */\n glParameters = {};\n constructor(device, props) {\n super(device, props);\n this.device = device;\n // If no viewport is provided, apply reasonably defaults\n let viewport;\n if (!props?.parameters?.viewport) {\n if (props?.framebuffer) {\n // Set the viewport to the size of the framebuffer\n const { width, height } = props.framebuffer;\n viewport = [0, 0, width, height];\n }\n else {\n // Instead of using our own book-keeping, we can just read the values from the WebGL context\n const [width, height] = device.getDefaultCanvasContext().getDrawingBufferSize();\n viewport = [0, 0, width, height];\n }\n }\n // TODO - do parameters (scissorRect) affect the clear operation?\n this.device.pushState();\n this.setParameters({ viewport, ...this.props.parameters });\n // Specify mapping of draw buffer locations to color attachments\n const webglFramebuffer = this.props.framebuffer;\n // Default framebuffers can only be set to GL.BACK or GL.NONE\n if (this.props.framebuffer && webglFramebuffer?.handle) {\n const drawBuffers = this.props.framebuffer.colorAttachments.map((_, i) => 36064 + i);\n this.device.gl.drawBuffers(drawBuffers);\n }\n else {\n this.device.gl.drawBuffers([1029]);\n }\n // Hack - for now WebGL draws in \"immediate mode\" (instead of queueing the operations)...\n this.clear();\n }\n end() {\n this.device.popState();\n // should add commands to CommandEncoder.\n }\n pushDebugGroup(groupLabel) { }\n popDebugGroup() { }\n insertDebugMarker(markerLabel) { }\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n /**\n * Maps RenderPass parameters to GL parameters\n */\n setParameters(parameters = {}) {\n const glParameters = { ...this.glParameters };\n // Framebuffers are specified using parameters in WebGL\n glParameters.framebuffer = this.props.framebuffer || null;\n if (this.props.depthReadOnly) {\n glParameters.depthMask = !this.props.depthReadOnly;\n }\n glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;\n glParameters[35977] = this.props.discard;\n // Map the four renderpass parameters to WebGL parameters\n if (parameters.viewport) {\n // WebGPU viewports are 6 coordinates (X, Y, Z)\n if (parameters.viewport.length >= 6) {\n glParameters.viewport = parameters.viewport.slice(0, 4);\n glParameters.depthRange = [\n parameters.viewport[4],\n parameters.viewport[5]\n ];\n }\n else {\n // WebGL viewports are 4 coordinates (X, Y)\n glParameters.viewport = parameters.viewport;\n }\n }\n if (parameters.scissorRect) {\n glParameters.scissorTest = true;\n glParameters.scissor = parameters.scissorRect;\n }\n if (parameters.blendConstant) {\n glParameters.blendColor = parameters.blendConstant;\n }\n if (parameters.stencilReference) {\n // eslint-disable-next-line no-console\n console.warn('RenderPassParameters.stencilReference not yet implemented in WebGL');\n // parameters.stencilFunc = [func, ref, mask];\n // Does this work?\n glParameters[2967] = parameters.stencilReference;\n }\n if ('colorMask' in parameters) {\n glParameters.colorMask = COLOR_CHANNELS.map(channel => Boolean(channel & parameters.colorMask));\n }\n this.glParameters = glParameters;\n setGLParameters(this.device.gl, glParameters);\n }\n beginOcclusionQuery(queryIndex) {\n const webglQuerySet = this.props.occlusionQuerySet;\n webglQuerySet?.beginOcclusionQuery();\n }\n endOcclusionQuery() {\n const webglQuerySet = this.props.occlusionQuerySet;\n webglQuerySet?.endOcclusionQuery();\n }\n // PRIVATE\n /**\n * Optionally clears depth, color and stencil buffers based on parameters\n */\n clear() {\n const glParameters = { ...this.glParameters };\n let clearMask = 0;\n if (this.props.clearColors) {\n this.props.clearColors.forEach((color, drawBufferIndex) => {\n if (color) {\n this.clearColorBuffer(drawBufferIndex, color);\n }\n });\n }\n if (this.props.clearColor !== false && this.props.clearColors === undefined) {\n clearMask |= 16384;\n glParameters.clearColor = this.props.clearColor;\n }\n if (this.props.clearDepth !== false) {\n clearMask |= 256;\n glParameters.clearDepth = this.props.clearDepth;\n }\n if (this.props.clearStencil !== false) {\n clearMask |= 1024;\n glParameters.clearStencil = this.props.clearStencil;\n }\n if (clearMask !== 0) {\n // Temporarily set any clear \"colors\" and call clear\n withGLParameters(this.device.gl, glParameters, () => {\n this.device.gl.clear(clearMask);\n });\n }\n }\n /**\n * WebGL2 - clear a specific color buffer\n */\n clearColorBuffer(drawBuffer = 0, value = [0, 0, 0, 0]) {\n withGLParameters(this.device.gl, { framebuffer: this.props.framebuffer }, () => {\n // Method selection per OpenGL ES 3 docs\n switch (value.constructor) {\n case Int8Array:\n case Int16Array:\n case Int32Array:\n this.device.gl.clearBufferiv(6144, drawBuffer, value);\n break;\n case Uint8Array:\n case Uint8ClampedArray:\n case Uint16Array:\n case Uint32Array:\n this.device.gl.clearBufferuiv(6144, drawBuffer, value);\n break;\n case Float32Array:\n this.device.gl.clearBufferfv(6144, drawBuffer, value);\n break;\n default:\n throw new Error('clearColorBuffer: color must be typed array');\n }\n });\n }\n}\n//# sourceMappingURL=webgl-render-pass.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { CommandEncoder } from '@luma.gl/core';\nimport { WEBGLCommandBuffer } from \"./webgl-command-buffer.js\";\nimport { WEBGLRenderPass } from \"./webgl-render-pass.js\";\nexport class WEBGLCommandEncoder extends CommandEncoder {\n device;\n handle = null;\n commandBuffer;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.commandBuffer = new WEBGLCommandBuffer(device);\n }\n destroy() { }\n finish() {\n return this.commandBuffer;\n }\n beginRenderPass(props) {\n return new WEBGLRenderPass(this.device, props);\n }\n beginComputePass(props) {\n throw new Error('ComputePass not supported in WebGL');\n }\n copyBufferToBuffer(options) {\n this.commandBuffer.commands.push({ name: 'copy-buffer-to-buffer', options });\n }\n copyBufferToTexture(options) {\n this.commandBuffer.commands.push({ name: 'copy-buffer-to-texture', options });\n }\n copyTextureToBuffer(options) {\n this.commandBuffer.commands.push({ name: 'copy-texture-to-buffer', options });\n }\n copyTextureToTexture(options) {\n this.commandBuffer.commands.push({ name: 'copy-texture-to-texture', options });\n }\n // clearTexture(options: ClearTextureOptions): void {\n // this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n // }\n pushDebugGroup(groupLabel) { }\n popDebugGroup() { }\n insertDebugMarker(markerLabel) { }\n resolveQuerySet(querySet, destination, options) { }\n}\n//# sourceMappingURL=webgl-command-encoder.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Uses copyWithin to significantly speed up typed array value filling\nexport function fillArray(options) {\n const { target, source, start = 0, count = 1 } = options;\n const length = source.length;\n const total = count * length;\n let copied = 0;\n for (let i = start; copied < length; copied++) {\n target[i++] = source[copied];\n }\n while (copied < total) {\n // If we have copied less than half, copy everything we got\n // else copy remaining in one operation\n if (copied < total - copied) {\n target.copyWithin(start + copied, start, start + copied);\n copied *= 2;\n }\n else {\n target.copyWithin(start + copied, start, start + total - copied);\n copied = total;\n }\n }\n return options.target;\n}\n//# sourceMappingURL=fill-array.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { VertexArray, getScratchArray } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { getBrowser } from '@probe.gl/env';\nimport { getGLFromVertexType } from \"../converters/webgl-vertex-formats.js\";\nimport { fillArray } from \"../../utils/fill-array.js\";\n/** VertexArrayObject wrapper */\nexport class WEBGLVertexArray extends VertexArray {\n get [Symbol.toStringTag]() {\n return 'VertexArray';\n }\n device;\n handle;\n /** Attribute 0 buffer constant */\n buffer = null;\n bufferValue = null;\n /** * Attribute 0 can not be disable on most desktop OpenGL based browsers */\n static isConstantAttributeZeroSupported(device) {\n return getBrowser() === 'Chrome';\n }\n // Create a VertexArray\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.handle = this.device.gl.createVertexArray();\n }\n destroy() {\n super.destroy();\n if (this.buffer) {\n this.buffer?.destroy();\n }\n if (this.handle) {\n this.device.gl.deleteVertexArray(this.handle);\n // @ts-expect-error read-only/undefined\n this.handle = undefined;\n }\n // Auto-delete elements?\n // return [this.elements];\n }\n /**\n // Set (bind/unbind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER or null. Constants not supported\n *\n * @param elementBuffer\n */\n setIndexBuffer(indexBuffer) {\n const buffer = indexBuffer;\n // Explicitly allow `null` to support clearing the index buffer\n if (buffer && buffer.glTarget !== 34963) {\n throw new Error('Use .setBuffer()');\n }\n // In WebGL The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject\n this.device.gl.bindVertexArray(this.handle);\n this.device.gl.bindBuffer(34963, buffer ? buffer.handle : null);\n this.indexBuffer = buffer;\n // Unbind to prevent unintended changes to the VAO.\n this.device.gl.bindVertexArray(null);\n }\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location, attributeBuffer) {\n const buffer = attributeBuffer;\n // Sanity check target\n if (buffer.glTarget === 34963) {\n throw new Error('Use .setIndexBuffer()');\n }\n const { size, type, stride, offset, normalized, integer, divisor } = this._getAccessor(location);\n this.device.gl.bindVertexArray(this.handle);\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n this.device.gl.bindBuffer(34962, buffer.handle);\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n this.device.gl.vertexAttribIPointer(location, size, type, stride, offset);\n }\n else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n this.device.gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n // Clear binding - keeping it may cause [.WebGL-0x12804417100]\n // GL_INVALID_OPERATION: A transform feedback buffer that would be written to is also bound to a non-transform-feedback target\n this.device.gl.bindBuffer(34962, null);\n // Mark as non-constant\n this.device.gl.enableVertexAttribArray(location);\n // Set the step mode 0=vertex, 1=instance\n this.device.gl.vertexAttribDivisor(location, divisor || 0);\n this.attributes[location] = buffer;\n // Unbind to prevent unintended changes to the VAO.\n this.device.gl.bindVertexArray(null);\n }\n /** Set a location in vertex attributes array to a constant value, disables the location */\n setConstantWebGL(location, value) {\n this._enable(location, false);\n this.attributes[location] = value;\n }\n bindBeforeRender() {\n this.device.gl.bindVertexArray(this.handle);\n this._applyConstantAttributes();\n }\n unbindAfterRender() {\n // Unbind to prevent unintended changes to the VAO.\n this.device.gl.bindVertexArray(null);\n }\n // Internal methods\n /**\n * Constant attributes need to be reset before every draw call\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @note Constant attributes are only supported in WebGL, not in WebGPU\n */\n _applyConstantAttributes() {\n for (let location = 0; location < this.maxVertexAttributes; ++location) {\n const constant = this.attributes[location];\n // A typed array means this is a constant\n if (ArrayBuffer.isView(constant)) {\n this.device.setConstantAttributeWebGL(location, constant);\n }\n }\n }\n /**\n * Set a location in vertex attributes array to a buffer, enables the location, sets divisor\n * @note requires vertex array to be bound\n */\n // protected _setAttributeLayout(location: number): void {\n // const {size, type, stride, offset, normalized, integer, divisor} = this._getAccessor(location);\n // // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n // if (integer) {\n // this.device.gl.vertexAttribIPointer(location, size, type, stride, offset);\n // } else {\n // // Attaches ARRAY_BUFFER with specified buffer format to location\n // this.device.gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n // }\n // this.device.gl.vertexAttribDivisor(location, divisor || 0);\n // }\n /** Get an accessor from the */\n _getAccessor(location) {\n const attributeInfo = this.attributeInfos[location];\n if (!attributeInfo) {\n throw new Error(`Unknown attribute location ${location}`);\n }\n const glType = getGLFromVertexType(attributeInfo.bufferDataType);\n return {\n size: attributeInfo.bufferComponents,\n type: glType,\n stride: attributeInfo.byteStride,\n offset: attributeInfo.byteOffset,\n normalized: attributeInfo.normalized,\n // it is the shader attribute declaration, not the vertex memory format,\n // that determines if the data in the buffer will be treated as integers.\n //\n // Also note that WebGL supports assigning non-normalized integer data to floating point attributes,\n // but as far as we can tell, WebGPU does not.\n integer: attributeInfo.integer,\n divisor: attributeInfo.stepMode === 'instance' ? 1 : 0\n };\n }\n /**\n * Enabling an attribute location makes it reference the currently bound buffer\n * Disabling an attribute location makes it reference the global constant value\n * TODO - handle single values for size 1 attributes?\n * TODO - convert classic arrays based on known type?\n */\n _enable(location, enable = true) {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers...\n const canDisableAttributeZero = WEBGLVertexArray.isConstantAttributeZeroSupported(this.device);\n const canDisableAttribute = canDisableAttributeZero || location !== 0;\n if (enable || canDisableAttribute) {\n location = Number(location);\n this.device.gl.bindVertexArray(this.handle);\n if (enable) {\n this.device.gl.enableVertexAttribArray(location);\n }\n else {\n this.device.gl.disableVertexAttribArray(location);\n }\n this.device.gl.bindVertexArray(null);\n }\n }\n /**\n * Provide a means to create a buffer that is equivalent to a constant.\n * NOTE: Desktop OpenGL cannot disable attribute 0.\n * https://stackoverflow.com/questions/20305231/webgl-warning-attribute-0-is-disabled-\n * this-has-significant-performance-penalty\n */\n getConstantBuffer(elementCount, value) {\n // Create buffer only when needed, and reuse it (avoids inflating buffer creation statistics)\n const constantValue = normalizeConstantArrayValue(value);\n const byteLength = constantValue.byteLength * elementCount;\n const length = constantValue.length * elementCount;\n if (this.buffer && byteLength !== this.buffer.byteLength) {\n throw new Error(`Buffer size is immutable, byte length ${byteLength} !== ${this.buffer.byteLength}.`);\n }\n let updateNeeded = !this.buffer;\n this.buffer = this.buffer || this.device.createBuffer({ byteLength });\n // Reallocate and update contents if needed\n // @ts-ignore TODO fix types\n updateNeeded ||= !compareConstantArrayValues(constantValue, this.bufferValue);\n if (updateNeeded) {\n // Create a typed array that is big enough, and fill it with the required data\n const typedArray = getScratchArray(value.constructor, length);\n fillArray({ target: typedArray, source: constantValue, start: 0, count: length });\n this.buffer.write(typedArray);\n this.bufferValue = value;\n }\n return this.buffer;\n }\n}\n// HELPER FUNCTIONS\n/**\n * TODO - convert Arrays based on known type? (read type from accessor, don't assume Float32Array)\n * TODO - handle single values for size 1 attributes?\n */\nfunction normalizeConstantArrayValue(arrayValue) {\n if (Array.isArray(arrayValue)) {\n return new Float32Array(arrayValue);\n }\n return arrayValue;\n}\n/**\n *\n */\nfunction compareConstantArrayValues(v1, v2) {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=webgl-vertex-array.js.map","import { log, TransformFeedback } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { WEBGLBuffer } from \"../../index.js\";\nimport { getGLPrimitive } from \"../helpers/webgl-topology-utils.js\";\nexport class WEBGLTransformFeedback extends TransformFeedback {\n device;\n gl;\n handle;\n /**\n * NOTE: The Model already has this information while drawing, but\n * TransformFeedback currently needs it internally, to look up\n * varying information outside of a draw() call.\n */\n layout;\n buffers = {};\n unusedBuffers = {};\n /**\n * Allows us to avoid a Chrome bug where a buffer that is already bound to a\n * different target cannot be bound to 'TRANSFORM_FEEDBACK_BUFFER' target.\n * This a major workaround, see: https://github.com/KhronosGroup/WebGL/issues/2346\n */\n bindOnUse = true;\n _bound = false;\n constructor(device, props) {\n super(device, props);\n this.device = device;\n this.gl = device.gl;\n this.handle = this.props.handle || this.gl.createTransformFeedback();\n this.layout = this.props.layout;\n if (props.buffers) {\n this.setBuffers(props.buffers);\n }\n Object.seal(this);\n }\n destroy() {\n this.gl.deleteTransformFeedback(this.handle);\n super.destroy();\n }\n begin(topology = 'point-list') {\n this.gl.bindTransformFeedback(36386, this.handle);\n if (this.bindOnUse) {\n this._bindBuffers();\n }\n this.gl.beginTransformFeedback(getGLPrimitive(topology));\n }\n end() {\n this.gl.endTransformFeedback();\n if (this.bindOnUse) {\n this._unbindBuffers();\n }\n this.gl.bindTransformFeedback(36386, null);\n }\n // SUBCLASS\n setBuffers(buffers) {\n this.buffers = {};\n this.unusedBuffers = {};\n this.bind(() => {\n for (const bufferName in buffers) {\n this.setBuffer(bufferName, buffers[bufferName]);\n }\n });\n }\n setBuffer(locationOrName, bufferOrRange) {\n const location = this._getVaryingIndex(locationOrName);\n const { buffer, byteLength, byteOffset } = this._getBufferRange(bufferOrRange);\n if (location < 0) {\n this.unusedBuffers[locationOrName] = buffer;\n log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();\n return;\n }\n this.buffers[location] = { buffer, byteLength, byteOffset };\n // Need to avoid chrome bug where buffer that is already bound to a different target\n // cannot be bound to 'TRANSFORM_FEEDBACK_BUFFER' target.\n if (!this.bindOnUse) {\n this._bindBuffer(location, buffer, byteOffset, byteLength);\n }\n }\n getBuffer(locationOrName) {\n if (isIndex(locationOrName)) {\n return this.buffers[locationOrName] || null;\n }\n const location = this._getVaryingIndex(locationOrName);\n return location >= 0 ? this.buffers[location] : null;\n }\n bind(funcOrHandle = this.handle) {\n if (typeof funcOrHandle !== 'function') {\n this.gl.bindTransformFeedback(36386, funcOrHandle);\n return this;\n }\n let value;\n if (!this._bound) {\n this.gl.bindTransformFeedback(36386, this.handle);\n this._bound = true;\n value = funcOrHandle();\n this._bound = false;\n this.gl.bindTransformFeedback(36386, null);\n }\n else {\n value = funcOrHandle();\n }\n return value;\n }\n unbind() {\n this.bind(null);\n }\n // PRIVATE METHODS\n /** Extract offsets for bindBufferRange */\n _getBufferRange(bufferOrRange) {\n if (bufferOrRange instanceof WEBGLBuffer) {\n return { buffer: bufferOrRange, byteOffset: 0, byteLength: bufferOrRange.byteLength };\n }\n // To use bindBufferRange either offset or size must be specified.\n // @ts-expect-error Must be a BufferRange.\n const { buffer, byteOffset = 0, byteLength = bufferOrRange.buffer.byteLength } = bufferOrRange;\n return { buffer, byteOffset, byteLength };\n }\n _getVaryingIndex(locationOrName) {\n if (isIndex(locationOrName)) {\n return Number(locationOrName);\n }\n for (const varying of this.layout.varyings || []) {\n if (locationOrName === varying.name) {\n return varying.location;\n }\n }\n return -1;\n }\n /**\n * Need to avoid chrome bug where buffer that is already bound to a different target\n * cannot be bound to 'TRANSFORM_FEEDBACK_BUFFER' target.\n */\n _bindBuffers() {\n for (const bufferIndex in this.buffers) {\n const { buffer, byteLength, byteOffset } = this._getBufferRange(this.buffers[bufferIndex]);\n this._bindBuffer(Number(bufferIndex), buffer, byteOffset, byteLength);\n }\n }\n _unbindBuffers() {\n for (const bufferIndex in this.buffers) {\n this.gl.bindBufferBase(35982, Number(bufferIndex), null);\n }\n }\n _bindBuffer(index, buffer, byteOffset = 0, byteLength) {\n const handle = buffer && buffer.handle;\n if (!handle || byteLength === undefined) {\n this.gl.bindBufferBase(35982, index, handle);\n }\n else {\n this.gl.bindBufferRange(35982, index, handle, byteOffset, byteLength);\n }\n }\n}\n/**\n * Returns true if the given value is an integer, or a string that\n * trivially converts to an integer (only numeric characters).\n */\nfunction isIndex(value) {\n if (typeof value === 'number') {\n return Number.isInteger(value);\n }\n return /^\\d+$/.test(value);\n}\n//# sourceMappingURL=webgl-transform-feedback.js.map","// WebGL2 Query (also handles disjoint timer extensions)\nimport { QuerySet } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\n/**\n * Asynchronous queries for different kinds of information\n */\nexport class WEBGLQuerySet extends QuerySet {\n device;\n handle;\n target = null;\n _queryPending = false;\n _pollingPromise = null;\n get [Symbol.toStringTag]() {\n return 'Query';\n }\n // Create a query class\n constructor(device, props) {\n super(device, props);\n this.device = device;\n if (props.count > 1) {\n throw new Error('WebGL QuerySet can only have one value');\n }\n const handle = this.device.gl.createQuery();\n if (!handle) {\n throw new Error('WebGL query not supported');\n }\n this.handle = handle;\n Object.seal(this);\n }\n destroy() {\n this.device.gl.deleteQuery(this.handle);\n }\n // FOR RENDER PASS AND COMMAND ENCODER\n /**\n * Shortcut for timer query (dependent on extension in both WebGL1 and 2)\n * Measures GPU time delta between this call and a matching `end` call in the\n * GPU instruction stream.\n */\n beginTimestampQuery() {\n return this._begin(35007);\n }\n endTimestampQuery() {\n this._end();\n }\n // Shortcut for occlusion queries\n beginOcclusionQuery(options) {\n return this._begin(options?.conservative ? 36202 : 35887);\n }\n endOcclusionQuery() {\n this._end();\n }\n // Shortcut for transformFeedbackQuery\n beginTransformFeedbackQuery() {\n return this._begin(35976);\n }\n endTransformFeedbackQuery() {\n this._end();\n }\n async resolveQuery() {\n const value = await this.pollQuery();\n return [value];\n }\n // PRIVATE METHODS\n /**\n * Due to OpenGL API limitations, after calling `begin()` on one Query\n * instance, `end()` must be called on that same instance before\n * calling `begin()` on another query. While there can be multiple\n * outstanding queries representing disjoint `begin()`/`end()` intervals.\n * It is not possible to interleave or overlap `begin` and `end` calls.\n */\n _begin(target) {\n // Don't start a new query if one is already active.\n if (this._queryPending) {\n return;\n }\n this.target = target;\n this.device.gl.beginQuery(this.target, this.handle);\n return;\n }\n // ends the current query\n _end() {\n // Can't end a new query if the last one hasn't been resolved.\n if (this._queryPending) {\n return;\n }\n if (this.target) {\n this.device.gl.endQuery(this.target);\n this.target = null;\n this._queryPending = true;\n }\n return;\n }\n // Returns true if the query result is available\n isResultAvailable() {\n if (!this._queryPending) {\n return false;\n }\n const resultAvailable = this.device.gl.getQueryParameter(this.handle, 34919);\n if (resultAvailable) {\n this._queryPending = false;\n }\n return resultAvailable;\n }\n // Timing query is disjoint, i.e. results are invalid\n isTimerDisjoint() {\n return this.device.gl.getParameter(36795);\n }\n // Returns query result.\n getResult() {\n return this.device.gl.getQueryParameter(this.handle, 34918);\n }\n // Returns the query result, converted to milliseconds to match JavaScript conventions.\n getTimerMilliseconds() {\n return this.getResult() / 1e6;\n }\n // Polls the query\n pollQuery(limit = Number.POSITIVE_INFINITY) {\n if (this._pollingPromise) {\n return this._pollingPromise;\n }\n let counter = 0;\n this._pollingPromise = new Promise((resolve, reject) => {\n const poll = () => {\n if (this.isResultAvailable()) {\n resolve(this.getResult());\n this._pollingPromise = null;\n }\n else if (counter++ > limit) {\n reject('Timed out');\n this._pollingPromise = null;\n }\n else {\n requestAnimationFrame(poll);\n }\n };\n requestAnimationFrame(poll);\n });\n return this._pollingPromise;\n }\n}\n//# sourceMappingURL=webgl-query-set.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { GL } from '@luma.gl/constants';\n// Returns number of components in a specific readPixels WebGL format\nexport function glFormatToComponents(format) {\n switch (format) {\n case 6406:\n case 33326:\n case 6403:\n case 36244:\n return 1;\n case 33339:\n case 33340:\n case 33328:\n case 33320:\n case 33319:\n return 2;\n case 6407:\n case 36248:\n case 34837:\n return 3;\n case 6408:\n case 36249:\n case 34836:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n return 0;\n }\n}\n// Return byte count for given readPixels WebGL type\nexport function glTypeToBytes(type) {\n switch (type) {\n case 5121:\n return 1;\n case 33635:\n case 32819:\n case 32820:\n return 2;\n case 5126:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n return 0;\n }\n}\n//# sourceMappingURL=format-utils.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { GL } from '@luma.gl/constants';\n/** Get shadertypes data type from GL constants */\nexport function convertGLDataTypeToDataType(type) {\n return GL_DATA_TYPE_MAP[type];\n}\nconst GL_DATA_TYPE_MAP = {\n [5124]: 'sint32',\n [5125]: 'uint32',\n [5122]: 'sint16',\n [5123]: 'uint16',\n [5120]: 'sint8',\n [5121]: 'uint8',\n [5126]: 'float32',\n [5131]: 'float16',\n [33635]: 'uint16',\n [32819]: 'uint16',\n [32820]: 'uint16',\n [33640]: 'uint32',\n [35899]: 'uint32',\n [35902]: 'uint32',\n [34042]: 'uint32',\n [36269]: 'uint32'\n};\n/** Get shader data type from GL constants *\nexport function getPrimitiveTypeFromGL(type: GL): PrimitiveDataType {\n switch (type) {\n case GL.INT:\n return 'i32';\n case GL.UNSIGNED_INT:\n return 'u32';\n case GL.SHORT:\n return 'i32';\n case GL.UNSIGNED_SHORT:\n return 'u32';\n case GL.BYTE:\n return 'i32';\n case GL.UNSIGNED_BYTE:\n return 'u32';\n case GL.FLOAT:\n return 'f32';\n case GL.HALF_FLOAT:\n return 'f16';\n default:\n throw new Error(String(type));\n }\n}\n\n/** Get shader attribute type from GL constants *\nexport function getShaderAttributeTypeFromGL(\n type: GL,\n components: 1 | 2 | 3 | 4\n): AttributeShaderType {\n const dataType = getPrimitiveTypeFromGL(type);\n switch (components) {\n case 1:\n return dataType;\n case 2:\n return `vec2<${dataType}>`;\n case 3:\n return `vec2<${dataType}>`;\n case 4:\n return `vec2<${dataType}>`;\n default:\n throw new Error(String(components));\n }\n}\n*/\n/** GetGL constant from shader data type\nexport function getGLFromShaderDataType(\n type: PrimitiveDataType\n): GL.INT | GL.UNSIGNED_INT | GL.FLOAT | GL.HALF_FLOAT {\n switch (type) {\n // TODO\n case 'i32':\n return GL.INT;\n case 'u32':\n return GL.UNSIGNED_INT;\n case 'f32':\n return GL.FLOAT;\n case 'f16':\n return GL.HALF_FLOAT;\n default:\n throw new Error(String(type));\n }\n}\n*/\n//# sourceMappingURL=shader-formats.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Framebuffer, getTypedArrayConstructor, getDataType } from '@luma.gl/core';\nimport { GL } from '@luma.gl/constants';\nimport { convertDataTypeToGLDataType } from \"../converters/webgl-shadertypes.js\";\nimport { glFormatToComponents, glTypeToBytes } from \"./format-utils.js\";\nimport { WEBGLTexture } from \"../resources/webgl-texture.js\";\nimport { convertGLDataTypeToDataType } from \"../converters/shader-formats.js\";\n/** A \"border\" parameter is required in many WebGL texture APIs, but must always be 0... */\nconst BORDER = 0;\n/**\n * Copy a region of compressed data from a GPU memory buffer into this texture.\n */\nexport function copyGPUBufferToMipLevel(gl, webglBuffer, byteLength, options) {\n const { dimension, width, height, depth = 0, mipLevel = 0, byteOffset = 0 } = options;\n const { x = 0, y = 0, z = 0 } = options;\n const { glFormat, glType, compressed } = options;\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n gl.bindBuffer(35052, webglBuffer);\n switch (dimension) {\n case '2d-array':\n case '3d':\n // 3 dimensional textures requires 3D texture functions\n if (compressed) {\n // TODO enable extension?\n // prettier-ignore\n gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, byteLength, byteOffset);\n }\n else {\n // prettier-ignore\n gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, byteOffset);\n }\n break;\n case '2d':\n case 'cube':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, byteLength, byteOffset);\n }\n else {\n // prettier-ignore\n gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, BORDER, glFormat, byteOffset);\n }\n break;\n default:\n throw new Error(dimension);\n }\n}\n// INTERNAL HELPERS\n/** Convert a WebGPU style texture constant to a WebGL style texture constant */\nexport function getWebGLTextureTarget(dimension) {\n // prettier-ignore\n switch (dimension) {\n case '1d': break; // not supported in any WebGL version\n case '2d': return 3553; // supported in WebGL1\n case '3d': return 32879; // supported in WebGL2\n case 'cube': return 34067; // supported in WebGL1\n case '2d-array': return 35866; // supported in WebGL2\n case 'cube-array': break; // not supported in any WebGL version\n }\n throw new Error(dimension);\n}\n/**\n * In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.\n * @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.\n * @returns glTarget unchanged, if dimension !== 'cube'.\n */\nexport function getWebGLCubeFaceTarget(glTarget, dimension, level) {\n return dimension === 'cube' ? 34069 + level : glTarget;\n}\n/**\n * Copies data from a type or a Texture object into ArrayBuffer object.\n * App can provide targetPixelArray or have it auto allocated by this method\n * newly allocated by this method unless provided by app.\n * @deprecated Use CommandEncoder.copyTextureToBuffer and Buffer.read\n * @note Slow requires roundtrip to GPU\n *\n * @param source\n * @param options\n * @returns pixel array,\n */\nexport function readPixelsToArray(source, options) {\n const { sourceX = 0, sourceY = 0, sourceAttachment = 0 // TODO - support gl.readBuffer\n } = options || {};\n let { target = null, \n // following parameters are auto deduced if not provided\n sourceWidth, sourceHeight, sourceDepth, sourceFormat, sourceType } = options || {};\n const { framebuffer, deleteFramebuffer } = getFramebuffer(source);\n // assert(framebuffer);\n const { gl, handle } = framebuffer;\n sourceWidth ||= framebuffer.width;\n sourceHeight ||= framebuffer.height;\n const texture = framebuffer.colorAttachments[sourceAttachment]?.texture;\n if (!texture) {\n throw new Error(`Invalid framebuffer attachment ${sourceAttachment}`);\n }\n sourceDepth = texture?.depth || 1;\n sourceFormat ||= texture?.glFormat || 6408;\n // Deduce the type from color attachment if not provided.\n sourceType ||= texture?.glType || 5121;\n // Deduce type and allocated pixelArray if needed\n target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);\n // Pixel array available, if necessary, deduce type from it.\n const signedType = getDataType(target);\n sourceType = sourceType || convertDataTypeToGLDataType(signedType);\n // Note: luma.gl overrides bindFramebuffer so that we can reliably restore the previous framebuffer (this is the only function for which we do that)\n const prevHandle = gl.bindFramebuffer(36160, handle);\n // Select the color attachment to read from\n gl.readBuffer(36064 + sourceAttachment);\n // There is a lot of hedging in the WebGL2 spec about what formats are guaranteed to be readable\n // (It should always be possible to read RGBA/UNSIGNED_BYTE, but most other combinations are not guaranteed)\n // Querying is possible but expensive:\n // const {device} = framebuffer;\n // texture.glReadFormat ||= gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT);\n // texture.glReadType ||= gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE);\n // console.log('params', device.getGLKey(texture.glReadFormat), device.getGLKey(texture.glReadType));\n gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);\n gl.readBuffer(36064);\n gl.bindFramebuffer(36160, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return target;\n}\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.\n * @deprecated Use CommandEncoder\n * @param source\n * @param options\n */\nexport function readPixelsToBuffer(source, options) {\n const { target, sourceX = 0, sourceY = 0, sourceFormat = 6408, targetByteOffset = 0 } = options || {};\n // following parameters are auto deduced if not provided\n let { sourceWidth, sourceHeight, sourceType } = options || {};\n const { framebuffer, deleteFramebuffer } = getFramebuffer(source);\n // assert(framebuffer);\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const webglFramebuffer = framebuffer;\n // deduce type if not available.\n sourceType = sourceType || 5121;\n let webglBufferTarget = target;\n if (!webglBufferTarget) {\n // Create new buffer with enough size\n const components = glFormatToComponents(sourceFormat);\n const byteCount = glTypeToBytes(sourceType);\n const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;\n webglBufferTarget = webglFramebuffer.device.createBuffer({ byteLength });\n }\n // TODO(donmccurdy): Do we have tests to confirm this is working?\n const commandEncoder = source.device.createCommandEncoder();\n commandEncoder.copyTextureToBuffer({\n sourceTexture: source,\n width: sourceWidth,\n height: sourceHeight,\n origin: [sourceX, sourceY],\n destinationBuffer: webglBufferTarget,\n byteOffset: targetByteOffset\n });\n commandEncoder.destroy();\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return webglBufferTarget;\n}\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n * @deprecated Use CommandEncoder\n */\n// eslint-disable-next-line complexity, max-statements\nexport function copyToTexture(sourceTexture, destinationTexture, options) {\n const { sourceX = 0, sourceY = 0, \n // attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer\n targetMipmaplevel = 0, targetInternalFormat = 6408 } = options || {};\n let { targetX, targetY, targetZ, width, // defaults to target width\n height // defaults to target height\n } = options || {};\n const { framebuffer, deleteFramebuffer } = getFramebuffer(sourceTexture);\n // assert(framebuffer);\n const webglFramebuffer = framebuffer;\n const { device, handle } = webglFramebuffer;\n const isSubCopy = typeof targetX !== 'undefined' ||\n typeof targetY !== 'undefined' ||\n typeof targetZ !== 'undefined';\n targetX = targetX || 0;\n targetY = targetY || 0;\n targetZ = targetZ || 0;\n const prevHandle = device.gl.bindFramebuffer(36160, handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n // assert(target);\n let texture = null;\n let textureTarget;\n if (destinationTexture instanceof WEBGLTexture) {\n texture = destinationTexture;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture?._bind(0);\n // @ts-ignore\n textureTarget = texture.target;\n }\n else {\n // @ts-ignore\n textureTarget = target;\n }\n if (!isSubCopy) {\n device.gl.copyTexImage2D(textureTarget, targetMipmaplevel, targetInternalFormat, sourceX, sourceY, width, height, 0 /* border must be 0 */);\n }\n else {\n switch (textureTarget) {\n case 3553:\n case 34067:\n device.gl.copyTexSubImage2D(textureTarget, targetMipmaplevel, targetX, targetY, sourceX, sourceY, width, height);\n break;\n case 35866:\n case 32879:\n device.gl.copyTexSubImage3D(textureTarget, targetMipmaplevel, targetX, targetY, targetZ, sourceX, sourceY, width, height);\n break;\n default:\n }\n }\n if (texture) {\n texture._unbind();\n }\n // @ts-expect-error\n device.gl.bindFramebuffer(36160, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\nfunction getFramebuffer(source) {\n if (!(source instanceof Framebuffer)) {\n return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };\n }\n return { framebuffer: source, deleteFramebuffer: false };\n}\n/**\n * Wraps a given texture into a framebuffer object, that can be further used\n * to read data from the texture object.\n */\nexport function toFramebuffer(texture, props) {\n const { device, width, height, id } = texture;\n const framebuffer = device.createFramebuffer({\n ...props,\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [texture]\n });\n return framebuffer;\n}\n// eslint-disable-next-line max-params\nfunction getPixelArray(pixelArray, glType, glFormat, width, height, depth) {\n if (pixelArray) {\n return pixelArray;\n }\n // const formatInfo = getTextureFormatInfo(format);\n // Allocate pixel array if not already available, using supplied type\n glType ||= 5121;\n const shaderType = convertGLDataTypeToDataType(glType);\n const ArrayType = getTypedArrayConstructor(shaderType);\n const components = glFormatToComponents(glFormat);\n // TODO - check for composite type (components = 1).\n return new ArrayType(width * height * components);\n}\n//# sourceMappingURL=webgl-texture-utils.js.map","// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Device, log } from '@luma.gl/core';\nimport { WebGLStateTracker } from \"../context/state-tracker/webgl-state-tracker.js\";\nimport { createBrowserContext } from \"../context/helpers/create-browser-context.js\";\nimport { getDeviceInfo } from \"./device-helpers/webgl-device-info.js\";\nimport { WebGLDeviceFeatures } from \"./device-helpers/webgl-device-features.js\";\nimport { WebGLDeviceLimits } from \"./device-helpers/webgl-device-limits.js\";\nimport { WebGLCanvasContext } from \"./webgl-canvas-context.js\";\nimport { initializeSpectorJS } from \"../context/debug/spector.js\";\nimport { makeDebugContext } from \"../context/debug/webgl-developer-tools.js\";\nimport { getTextureFormatCapabilitiesWebGL } from \"./converters/webgl-texture-table.js\";\nimport { uid } from \"../utils/uid.js\";\nimport { WEBGLBuffer } from \"./resources/webgl-buffer.js\";\nimport { WEBGLShader } from \"./resources/webgl-shader.js\";\nimport { WEBGLSampler } from \"./resources/webgl-sampler.js\";\nimport { WEBGLTexture } from \"./resources/webgl-texture.js\";\nimport { WEBGLFramebuffer } from \"./resources/webgl-framebuffer.js\";\nimport { WEBGLRenderPipeline } from \"./resources/webgl-render-pipeline.js\";\nimport { WEBGLCommandEncoder } from \"./resources/webgl-command-encoder.js\";\nimport { WEBGLVertexArray } from \"./resources/webgl-vertex-array.js\";\nimport { WEBGLTransformFeedback } from \"./resources/webgl-transform-feedback.js\";\nimport { WEBGLQuerySet } from \"./resources/webgl-query-set.js\";\nimport { readPixelsToArray, readPixelsToBuffer } from \"./helpers/webgl-texture-utils.js\";\nimport { setGLParameters, getGLParameters, resetGLParameters } from \"../context/parameters/unified-parameter-api.js\";\nimport { withGLParameters } from \"../context/state-tracker/with-parameters.js\";\nimport { getWebGLExtension } from \"../context/helpers/webgl-extensions.js\";\n/** WebGPU style Device API for a WebGL context */\nexport class WebGLDevice extends Device {\n // Public `Device` API\n /** type of this device */\n type = 'webgl';\n // Use the ! assertion to handle the case where _reuseDevices causes the constructor to return early\n /** The underlying WebGL context */\n handle;\n features;\n limits;\n info;\n canvasContext;\n preferredColorFormat = 'rgba8unorm';\n preferredDepthFormat = 'depth24plus';\n commandEncoder;\n lost;\n _resolveContextLost;\n /** WebGL2 context. */\n gl;\n /** Store constants */\n // @ts-ignore TODO fix\n _constants;\n /** State used by luma.gl classes - TODO - not used? */\n _extensions = {};\n _polyfilled = false;\n /** Instance of Spector.js (if initialized) */\n spectorJS;\n //\n // Public API\n //\n get [Symbol.toStringTag]() {\n return 'WebGLDevice';\n }\n toString() {\n return `${this[Symbol.toStringTag]}(${this.id})`;\n }\n isVertexFormatSupported(format) {\n switch (format) {\n case 'unorm8x4-bgra':\n return false;\n default:\n return true;\n }\n }\n constructor(props) {\n super({ ...props, id: props.id || uid('webgl-device') });\n const canvasContextProps = Device._getCanvasContextProps(props);\n // WebGL requires a canvas to be created before creating the context\n if (!canvasContextProps) {\n throw new Error('WebGLDevice requires props.createCanvasContext to be set');\n }\n // Check if the WebGL context is already associated with a device\n // Note that this can be avoided in webgl2adapter.create() if\n // DeviceProps._reuseDevices is set.\n // @ts-expect-error device is attached to context\n let device = canvasContextProps.canvas?.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, canvasContextProps);\n this.lost = new Promise(resolve => {\n this._resolveContextLost = resolve;\n });\n const webglContextAttributes = { ...props.webgl };\n // Copy props from CanvasContextProps\n if (canvasContextProps.alphaMode === 'premultiplied') {\n webglContextAttributes.premultipliedAlpha = true;\n }\n if (props.powerPreference !== undefined) {\n webglContextAttributes.powerPreference = props.powerPreference;\n }\n // Check if we should attach to an externally created context or create a new context\n const externalGLContext = this.props._handle;\n const gl = externalGLContext ||\n createBrowserContext(this.canvasContext.canvas, {\n onContextLost: (event) => this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'\n }),\n // eslint-disable-next-line no-console\n onContextRestored: (event) => console.log('WebGL context restored')\n }, webglContextAttributes);\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n // Note that the browser will only create one WebGL context per canvas.\n // This means that a newly created gl context may already have a device attached to it.\n // @ts-expect-error luma.gl stores a device reference on the context.\n device = gl.device;\n if (device) {\n if (props._reuseDevices) {\n log.log(1, `Not creating a new Device, instead returning a reference to Device ${device.id} already attached to WebGL context`, device)();\n device._reused = true;\n return device;\n }\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n this.handle = gl;\n this.gl = gl;\n // Add spector debug instrumentation to context\n // We need to trust spector integration to decide if spector should be initialized\n // We also run spector instrumentation first, otherwise spector can clobber luma instrumentation.\n this.spectorJS = initializeSpectorJS({ ...this.props, gl: this.handle });\n // Instrument context\n this.gl.device = this; // Update GL context: Link webgl context back to device\n // TODO - remove, this is only used to detect debug contexts.\n this.gl._version = 2; // Update GL context: Store WebGL version field on gl context (HACK to identify debug contexts)\n // initialize luma Device fields\n this.info = getDeviceInfo(this.gl, this._extensions);\n this.limits = new WebGLDeviceLimits(this.gl);\n this.features = new WebGLDeviceFeatures(this.gl, this._extensions, this.props._disabledFeatures);\n if (this.props._initializeFeatures) {\n this.features.initializeFeatures();\n }\n // Install context state tracking\n const glState = new WebGLStateTracker(this.gl, {\n log: (...args) => log.log(1, ...args)()\n });\n glState.trackState(this.gl, { copyState: false });\n // DEBUG contexts: Add luma debug instrumentation to the context, force log level to at least 1\n const debugWebGL = props.debugWebGL || props.debug;\n const traceWebGL = props.debugWebGL;\n if (debugWebGL) {\n this.gl = makeDebugContext(this.gl, { debugWebGL, traceWebGL });\n log.warn('WebGL debug mode activated. Performance reduced.')();\n if (props.debugWebGL) {\n log.level = Math.max(log.level, 1);\n }\n }\n this.commandEncoder = new WEBGLCommandEncoder(this, { id: `${this}-command-encoder` });\n }\n /**\n * Destroys the device\n *\n * @note \"Detaches\" from the WebGL context unless _reuseDevices is true.\n *\n * @note The underlying WebGL context is not immediately destroyed,\n * but may be destroyed later through normal JavaScript garbage collection.\n * This is a fundamental limitation since WebGL does not offer any\n * browser API for destroying WebGL contexts.\n */\n destroy() {\n // Note that deck.gl (especially in React strict mode) depends on being able\n // to asynchronously create a Device against the same canvas (i.e. WebGL context)\n // multiple times and getting the same device back. Since deck.gl is not aware\n // of this sharing, it might call destroy() multiple times on the same device.\n // Therefore we must do nothing in destroy() if props._reuseDevices is true\n if (!this.props._reuseDevices && !this._reused) {\n // Delete the reference to the device that we store on the WebGL context\n delete this.gl.device;\n }\n }\n get isLost() {\n return this.gl.isContextLost();\n }\n // IMPLEMENTATION OF ABSTRACT DEVICE\n getTextureByteAlignment() {\n return 4;\n }\n createCanvasContext(props) {\n throw new Error('WebGL only supports a single canvas');\n }\n createBuffer(props) {\n const newProps = this._normalizeBufferProps(props);\n return new WEBGLBuffer(this, newProps);\n }\n createTexture(props) {\n return new WEBGLTexture(this, props);\n }\n createExternalTexture(props) {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n createSampler(props) {\n return new WEBGLSampler(this, props);\n }\n createShader(props) {\n return new WEBGLShader(this, props);\n }\n createFramebuffer(props) {\n return new WEBGLFramebuffer(this, props);\n }\n createVertexArray(props) {\n return new WEBGLVertexArray(this, props);\n }\n createTransformFeedback(props) {\n return new WEBGLTransformFeedback(this, props);\n }\n createQuerySet(props) {\n return new WEBGLQuerySet(this, props);\n }\n createRenderPipeline(props) {\n return new WEBGLRenderPipeline(this, props);\n }\n createComputePipeline(props) {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n createCommandEncoder(props = {}) {\n return new WEBGLCommandEncoder(this, props);\n }\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(commandBuffer) {\n if (!commandBuffer) {\n commandBuffer = this.commandEncoder.finish();\n this.commandEncoder.destroy();\n this.commandEncoder = this.createCommandEncoder({ id: `${this.id}-default-encoder` });\n }\n commandBuffer._executeCommands();\n }\n //\n // TEMPORARY HACKS - will be removed in v9.1\n //\n /** @deprecated - should use command encoder */\n readPixelsToArrayWebGL(source, options) {\n return readPixelsToArray(source, options);\n }\n /** @deprecated - should use command encoder */\n readPixelsToBufferWebGL(source, options) {\n return readPixelsToBuffer(source, options);\n }\n setParametersWebGL(parameters) {\n setGLParameters(this.gl, parameters);\n }\n getParametersWebGL(parameters) {\n return getGLParameters(this.gl, parameters);\n }\n withParametersWebGL(parameters, func) {\n return withGLParameters(this.gl, parameters, func);\n }\n resetWebGL() {\n log.warn('WebGLDevice.resetWebGL is deprecated, use only for debugging')();\n resetGLParameters(this.gl);\n }\n _getDeviceSpecificTextureFormatCapabilities(capabilities) {\n return getTextureFormatCapabilitiesWebGL(this.gl, capabilities, this._extensions);\n }\n //\n // WebGL-only API (not part of `Device` API)\n //\n /**\n * Triggers device (or WebGL context) loss.\n * @note primarily intended for testing how application reacts to device loss\n */\n loseDevice() {\n let deviceLossTriggered = false;\n const extensions = this.getExtension('WEBGL_lose_context');\n const ext = extensions.WEBGL_lose_context;\n if (ext) {\n deviceLossTriggered = true;\n ext.loseContext();\n // ext.loseContext should trigger context loss callback but the platform may not do this, so do it explicitly\n }\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n return deviceLossTriggered;\n }\n /** Save current WebGL context state onto an internal stack */\n pushState() {\n const webglState = WebGLStateTracker.get(this.gl);\n webglState.push();\n }\n /** Restores previously saved context state */\n popState() {\n const webglState = WebGLStateTracker.get(this.gl);\n webglState.pop();\n }\n /**\n * Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant\n * Be aware that there are some duplicates especially for constants that are 0,\n * so this isn't guaranteed to return the right key in all cases.\n */\n getGLKey(value, options) {\n const number = Number(value);\n for (const key in this.gl) {\n // @ts-ignore expect-error depends on settings\n if (this.gl[key] === number) {\n return `GL.${key}`;\n }\n }\n // No constant found. Stringify the value and return it.\n return options?.emptyIfUnknown ? '' : String(value);\n }\n /**\n * Returns a map with any GL.<KEY> constants mapped to strings, both for keys and values\n */\n getGLKeys(glParameters) {\n const opts = { emptyIfUnknown: true };\n return Object.entries(glParameters).reduce((keys, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n keys[`${key}:${this.getGLKey(key, opts)}`] = `${value}:${this.getGLKey(value, opts)}`;\n return keys;\n }, {});\n }\n /**\n * Set a constant value for a location. Disabled attributes at that location will read from this value\n * @note WebGL constants are stored globally on the WebGL context, not the VertexArray\n * so they need to be updated before every render\n * @todo - remember/cache values to avoid setting them unnecessarily?\n */\n setConstantAttributeWebGL(location, constant) {\n const maxVertexAttributes = this.limits.maxVertexAttributes;\n this._constants = this._constants || new Array(maxVertexAttributes).fill(null);\n const currentConstant = this._constants[location];\n if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {\n log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)();\n }\n this._constants[location] = constant;\n switch (constant.constructor) {\n case Float32Array:\n setConstantFloatArray(this, location, constant);\n break;\n case Int32Array:\n setConstantIntArray(this, location, constant);\n break;\n case Uint32Array:\n setConstantUintArray(this, location, constant);\n break;\n default:\n throw new Error('constant');\n }\n }\n /** Ensure extensions are only requested once */\n getExtension(name) {\n getWebGLExtension(this.gl, name, this._extensions);\n return this._extensions;\n }\n // INTERNAL SUPPORT METHODS FOR WEBGL RESOURCES\n /**\n * Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension\n * luma.gl ids and props can be inspected\n */\n _setWebGLDebugMetadata(handle, resource, options) {\n // @ts-expect-error\n handle.luma = resource;\n const spectorMetadata = { props: options.spector, id: options.spector['id'] };\n // @ts-expect-error\n // eslint-disable-next-line camelcase\n handle.__SPECTOR_Metadata = spectorMetadata;\n }\n}\n/** Set constant float array attribute */\nfunction setConstantFloatArray(device, location, array) {\n switch (array.length) {\n case 1:\n device.gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n device.gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n device.gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n device.gl.vertexAttrib4fv(location, array);\n break;\n default:\n // assert(false);\n }\n}\n/** Set constant signed int array attribute */\nfunction setConstantIntArray(device, location, array) {\n device.gl.vertexAttribI4iv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1iv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2iv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3iv(location, array);\n // break;\n // case 4:\n // break;\n // default:\n // assert(false);\n // }\n}\n/** Set constant unsigned int array attribute */\nfunction setConstantUintArray(device, location, array) {\n device.gl.vertexAttribI4uiv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1uiv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2uiv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3uiv(location, array);\n // break;\n // case 4:\n // gl.vertexAttribI4uiv(location, array);\n // break;\n // default:\n // assert(false);\n // }\n}\n/**\n * Compares contents of two typed arrays\n * @todo max length?\n */\nfunction compareConstantArrayValues(v1, v2) {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=webgl-device.js.map"],"names":["getBrowser","mockUserAgent","isBrowser","isElectron","navigator","withResolvers","resolve","reject","_resolve","_reject","_CanvasContext","props","__publicField","getCanvasFromDOM","createCanvasElement","_a","_b","entries","canvas","maxTextureDimension","width","height","cssPixel","yInvert","ratio","scalePixels","drawingBufferWidth","cssWidth","size","id","entry","entry_","isVisible","oldPixelSize","devicePixelWidth","devicePixelHeight","maxDevicePixelWidth","maxDevicePixelHeight","dpr","oldRatio","intervalMs","intervalId","newRect","position","oldPosition","_c","CanvasContext","getContainer","container","element","canvasId","newCanvas","uid","pixel","point","x","scaleX","y","scaleY","t","xHigh","yHigh","_Framebuffer","Resource","device","colorAttachments","colorAttachment","depthStencilAttachment","updateSize","log","attachment","index","texture","Texture","format","i","resizedTexture","Framebuffer","_RenderPass","RenderPass","_CommandEncoder","CommandEncoder","_CommandBuffer","CommandBuffer","_VertexArray","getAttributeInfosByLocation","location","value","VertexArray","_TransformFeedback","TransformFeedback","_QuerySet","QuerySet","GL_PARAMETER_DEFAULTS","enable","gl","key","hint","pixelStorei","bindFramebuffer","target","bindBuffer","glTarget","isArray","array","GL_PARAMETER_SETTERS","framebuffer","handle","args","separateModes","separateFuncs","mask","backMask","func","ref","backFunc","backRef","sfail","dpfail","dppass","backSfail","backDpfail","backDppass","getValue","glEnum","values","cache","GL_COMPOSITE_PARAMETER_SETTERS","GL_HOOKED_SETTERS","update","capability","pname","buffer","r","g","b","a","mode","modeRGB","modeAlpha","src","dst","srcRGB","dstRGB","srcAlpha","dstAlpha","depth","s","zNear","zFar","face","factor","units","invert","fail","zfail","zpass","isEnabled","GL_PARAMETER_GETTERS","NON_CACHE_PARAMETERS","setGLParameters","parameters","isObjectEmpty","compositeSetters","glConstant","setter","compositeSetter","getGLParameters","getter","parameterKeys","state","resetGLParameters","object","deepArrayEqual","WebGLStateTracker","oldValues","options","installProgramSpy","installSetterSpy","installGetterOverride","valueChanged","oldValue","cached","functionName","originalGetterFunc","glState","originalSetterFunc","params","originalUseProgram","createBrowserContext","webglContextAttributes","errorMessage","webglProps","onContextLost","onContextRestored","event","getWebGLExtension","name","extensions","getDeviceInfo","vendorMasked","rendererMasked","ext","vendorUnmasked","rendererUnmasked","vendor","renderer","version","gpu","identifyGPUVendor","gpuBackend","identifyGPUBackend","gpuType","identifyGPUType","getGLFromVertexType","dataType","X_S3TC","X_S3TC_SRGB","X_RGTC","X_BPTC","X_ETC2","X_ASTC","X_ETC1","X_PVRTC","X_ATC","EXT_texture_norm16","EXT_render_snorm","EXT_color_buffer_float","TEXTURE_FEATURES","isTextureFeature","feature","checkTextureFeature","extension","WEBGL_TEXTURE_FORMATS","getTextureFormatCapabilitiesWebGL","formatSupport","supported","webglFormatInfo","getTextureFormatWebGL","formatData","webglFormat","convertTextureFormatToGL","decoded","textureFormatDecoder","getWebGLPixelDataFormat","getDepthStencilAttachmentWebGL","channels","integer","normalized","formatInfo","WEBGL_FEATURES","WebGLDeviceFeatures","DeviceFeatures","disabledFeatures","features","featureInfo","WebGLDeviceLimits","DeviceLimits","parameter","WEBGLFramebuffer","isDefaultFramebuffer","prevHandle","attachmentPoint","status","_getFrameBufferStatus","textureView","level","layer","mapIndexToCubeMapFace","WebGLCanvasContext","uidCounters","count","WEBGLBuffer","Buffer","getWebGLTarget","getWebGLUsage","data","byteOffset","byteLength","dataView","callback","arrayBuffer","dstOffset","usage","parseShaderCompilerLog","errLog","lines","messages","line","segments","messageType","message","getMessageType","linePosition","lineNumber","rest","lineNum","linePos","MESSAGE_TYPES","lowerCaseType","WEBGLShader","Shader","shaderLog","source","waitMs","ms","withDeviceAndGLParameters","glParameters","webglDevice","setDeviceParameters","map","vertex","mapBoolean","convertCompareFunction","glValue","convertStencilOperation","colorEquation","convertBlendOperationToEquation","alphaEquation","colorSrcFactor","convertBlendFactorToFunction","colorDstFactor","alphaSrcFactor","alphaDstFactor","type","valueMap","obj","isEmpty","convertSamplerParametersToWebGL","convertAddressMode","convertMaxFilterMode","convertMinFilterMode","addressMode","maxFilter","minFilter","mipmapFilter","WEBGLSampler","Sampler","param","withGLParameters","nocatch","webglState","WEBGLTextureView","TextureView","WEBGLTexture","getWebGLTextureTarget","dimension","mipLevels","glInternalFormat","sampler","options_","typedArray","mipLevel","z","glFormat","glType","compressed","getWebGLCubeFaceTarget","image","error","pvalue","_textureUnit","convertDataTypeToGLDataType","normalizedType","NORMALIZED_SHADER_TYPE_TO_WEBGL","convertGLUniformTypeToShaderVariableType","glUniformType","WEBGL_SHADER_TYPES","isGLSamplerType","WEBGL_SAMPLER_TO_TEXTURE_BINDINGS","getTextureBindingFromGLSamplerType","glSamplerType","getShaderLayoutFromGLSL","program","shaderLayout","readAttributeDeclarations","uniformBlocks","readUniformBlocks","uniformBlock","uniforms","uniform","readUniformBindings","textureUnit","viewDimension","sampleType","varyings","readVaryings","attributes","activeInfo","compositeType","attributeType","stepMode","uniformType","components","getVariableShaderTypeInfo","uniformCount","rawName","parseUniformName","webglLocation","uniformInfo","j","elementName","arrayElementUniformInfo","getBlockParameter","blockIndex","blockCount","blockInfo","uniformIndices","uniformArrayLength","uniformOffset","uniformStride","matches","setUniform","gl2","uniformValue","arrayValue","getGLDrawMode","topology","getGLPrimitive","LOG_PROGRAM_PERF_PRIORITY","WEBGLRenderPipeline","RenderPipeline","bufferMode","mergeShaderLayout","bindings","binding","binding_","validBindings","renderPass","vertexArray","vertexCount","instanceCount","isInstanced","firstVertex","transformFeedback","glDrawMode","isIndexed","glIndexType","webglRenderPass","errorType","linkErrorLog","texturesRenderable","bindingInfo","uniformBufferIndex","uniformLayout","baseLayout","overrideLayout","mergedLayout","attribute","baseAttribute","attr","WEBGLCommandBuffer","commands","command","_copyBufferToBuffer","_copyBufferToTexture","_copyTextureToBuffer","_copyTextureToTexture","destination","sourceTexture","aspect","depthOrArrayLayers","origin","destinationBuffer","bytesPerRow","rowsPerImage","destroyFramebuffer","getFramebuffer","webglBuffer","sourceWidth","sourceHeight","sourceParams","sourceFormat","sourceType","destinationMipLevel","destinationOrigin","destinationTexture","sourceX","sourceY","destinationX","destinationY","destinationZ","textureTarget","COLOR_CHANNELS","WEBGLRenderPass","viewport","webglFramebuffer","drawBuffers","_","groupLabel","markerLabel","channel","queryIndex","webglQuerySet","clearMask","color","drawBufferIndex","drawBuffer","WEBGLCommandEncoder","querySet","fillArray","start","length","total","copied","WEBGLVertexArray","indexBuffer","attributeBuffer","stride","offset","divisor","constant","attributeInfo","canDisableAttribute","elementCount","constantValue","normalizeConstantArrayValue","updateNeeded","compareConstantArrayValues","getScratchArray","v1","v2","WEBGLTransformFeedback","buffers","bufferName","locationOrName","bufferOrRange","isIndex","funcOrHandle","varying","bufferIndex","WEBGLQuerySet","resultAvailable","limit","counter","poll","glFormatToComponents","glTypeToBytes","convertGLDataTypeToDataType","GL_DATA_TYPE_MAP","readPixelsToArray","sourceAttachment","sourceDepth","deleteFramebuffer","getPixelArray","signedType","getDataType","readPixelsToBuffer","targetByteOffset","webglBufferTarget","byteCount","commandEncoder","toFramebuffer","pixelArray","shaderType","ArrayType","getTypedArrayConstructor","WebGLDevice","Device","canvasContextProps","initializeSpectorJS","debugWebGL","traceWebGL","makeDebugContext","newProps","commandBuffer","capabilities","deviceLossTriggered","number","opts","keys","maxVertexAttributes","currentConstant","setConstantFloatArray","setConstantIntArray","setConstantUintArray","resource","spectorMetadata"],"mappings":";;;;AA8BO,SAASA,GAAWC,GAAe;AACtC,SAAuBC,GAAS,IAG5BC,GAAwB,IACjB,cAEwBC,GAAU,aAAa,IAE5C,QAAQ,MAAM,IAAI,KACrB,SAEP,WAAW,SACJ,WAEP,WAAW,SACJ,WAEP,WAAW,kBACJ,YAEJ,YAnBI;AAoBf;AChDO,SAASC,KAAgB;AAC5B,MAAIC,GACAC;AAMJ,SAAO,EAAE,SALO,IAAI,QAAQ,CAACC,GAAUC,MAAY;AAC/C,IAAAH,IAAUE,GACVD,IAASE;AAAA,EACjB,CAAK,GAEiB,SA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