@luma.gl/effects 9.1.0-beta.8 → 9.1.0
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/dist.dev.js +115 -210
- package/dist/dist.min.js +6 -6
- package/package.json +2 -2
package/dist/dist.dev.js
CHANGED
|
@@ -1074,7 +1074,7 @@ var __exports__ = (() => {
|
|
|
1074
1074
|
// , filter: true},
|
|
1075
1075
|
"rg11b10ufloat": { channels: "rgb", bitsPerChannel: [11, 11, 10, 0], packed: true, p: 1, render: float32_renderable },
|
|
1076
1076
|
"rgb10a2unorm": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1 },
|
|
1077
|
-
"rgb10a2uint": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1 },
|
|
1077
|
+
"rgb10a2uint-webgl": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1, wgpu: false },
|
|
1078
1078
|
// 48-bit formats
|
|
1079
1079
|
"rgb16unorm-webgl": { f: norm16_renderable },
|
|
1080
1080
|
// rgb not renderable
|
|
@@ -1459,7 +1459,7 @@ var __exports__ = (() => {
|
|
|
1459
1459
|
} else if (props.data instanceof Uint16Array) {
|
|
1460
1460
|
newProps.indexType = "uint16";
|
|
1461
1461
|
} else {
|
|
1462
|
-
log.warn("indices buffer content must be of type
|
|
1462
|
+
log.warn("indices buffer content must be of integer type")();
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
1465
1465
|
return newProps;
|
|
@@ -1471,37 +1471,25 @@ var __exports__ = (() => {
|
|
|
1471
1471
|
powerPreference: "high-performance",
|
|
1472
1472
|
failIfMajorPerformanceCaveat: false,
|
|
1473
1473
|
createCanvasContext: void 0,
|
|
1474
|
-
// WebGL specific
|
|
1475
|
-
webgl: {},
|
|
1476
1474
|
// Callbacks
|
|
1477
1475
|
onError: (error) => log.error(error.message)(),
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1476
|
+
_requestMaxLimits: true,
|
|
1477
|
+
_factoryDestroyPolicy: "unused",
|
|
1478
|
+
// TODO - Change these after confirming things work as expected
|
|
1479
|
+
_initializeFeatures: true,
|
|
1480
|
+
_disabledFeatures: {
|
|
1481
|
+
"compilation-status-async-webgl": true
|
|
1482
1482
|
},
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1483
|
+
_resourceDefaults: {},
|
|
1484
|
+
// WebGL specific
|
|
1485
|
+
webgl: {},
|
|
1486
1486
|
debug: log.get("debug") || void 0,
|
|
1487
1487
|
debugShaders: log.get("debug-shaders") || void 0,
|
|
1488
1488
|
debugFramebuffers: Boolean(log.get("debug-framebuffers")),
|
|
1489
|
-
debugFactories: Boolean(log.get("debug-factories")),
|
|
1490
1489
|
debugWebGL: Boolean(log.get("debug-webgl")),
|
|
1491
1490
|
debugSpectorJS: void 0,
|
|
1492
1491
|
// Note: log setting is queried by the spector.js code
|
|
1493
1492
|
debugSpectorJSUrl: void 0,
|
|
1494
|
-
// Experimental
|
|
1495
|
-
_requestMaxLimits: true,
|
|
1496
|
-
_cacheShaders: false,
|
|
1497
|
-
_cachePipelines: false,
|
|
1498
|
-
_cacheDestroyPolicy: "unused",
|
|
1499
|
-
// TODO - Change these after confirming things work as expected
|
|
1500
|
-
_initializeFeatures: true,
|
|
1501
|
-
_disabledFeatures: {
|
|
1502
|
-
"compilation-status-async-webgl": true
|
|
1503
|
-
},
|
|
1504
|
-
_resourceDefaults: {},
|
|
1505
1493
|
// INTERNAL
|
|
1506
1494
|
_handle: void 0
|
|
1507
1495
|
});
|
|
@@ -1676,25 +1664,10 @@ var __exports__ = (() => {
|
|
|
1676
1664
|
htmlCanvas;
|
|
1677
1665
|
offscreenCanvas;
|
|
1678
1666
|
type;
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
/** Visibility is automatically updated (via an IntersectionObserver) */
|
|
1684
|
-
isVisible = true;
|
|
1685
|
-
/** Device pixel ratio. Automatically updated via media queries */
|
|
1686
|
-
devicePixelRatio;
|
|
1687
|
-
/** Exact width of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
1688
|
-
pixelWidth;
|
|
1689
|
-
/** Exact height of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
1690
|
-
pixelHeight;
|
|
1691
|
-
/** Width of drawing buffer: automatically updated if props.autoResize is true */
|
|
1692
|
-
drawingBufferWidth;
|
|
1693
|
-
/** Height of drawing buffer: automatically updated if props.autoResize is true */
|
|
1694
|
-
drawingBufferHeight;
|
|
1695
|
-
_resizeObserver;
|
|
1696
|
-
_intersectionObserver;
|
|
1697
|
-
/** State used by luma.gl classes: TODO - remove */
|
|
1667
|
+
width = 1;
|
|
1668
|
+
height = 1;
|
|
1669
|
+
resizeObserver;
|
|
1670
|
+
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
1698
1671
|
_canvasSizeInfo = { clientWidth: 0, clientHeight: 0, devicePixelRatio: 1 };
|
|
1699
1672
|
toString() {
|
|
1700
1673
|
return `${this[Symbol.toStringTag]}(${this.id})`;
|
|
@@ -1702,92 +1675,50 @@ var __exports__ = (() => {
|
|
|
1702
1675
|
constructor(props) {
|
|
1703
1676
|
this.props = { ..._CanvasContext.defaultProps, ...props };
|
|
1704
1677
|
props = this.props;
|
|
1705
|
-
this.initialized = this._initializedResolvers.promise;
|
|
1706
1678
|
if (!isBrowser()) {
|
|
1707
|
-
this.
|
|
1708
|
-
|
|
1709
|
-
this.
|
|
1679
|
+
this.id = "node-canvas-context";
|
|
1680
|
+
this.type = "node";
|
|
1681
|
+
this.width = this.props.width;
|
|
1682
|
+
this.height = this.props.height;
|
|
1683
|
+
this.canvas = null;
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
if (!props.canvas) {
|
|
1687
|
+
const canvas = createCanvas(props);
|
|
1688
|
+
const container = getContainer(props?.container || null);
|
|
1689
|
+
container.insertBefore(canvas, container.firstChild);
|
|
1690
|
+
this.canvas = canvas;
|
|
1691
|
+
if (!props?.visible) {
|
|
1692
|
+
this.canvas.style.visibility = "hidden";
|
|
1693
|
+
}
|
|
1710
1694
|
} else if (typeof props.canvas === "string") {
|
|
1711
1695
|
this.canvas = getCanvasFromDOM(props.canvas);
|
|
1712
1696
|
} else {
|
|
1713
1697
|
this.canvas = props.canvas;
|
|
1714
1698
|
}
|
|
1715
|
-
if (
|
|
1716
|
-
this.id =
|
|
1699
|
+
if (this.canvas instanceof HTMLCanvasElement) {
|
|
1700
|
+
this.id = this.canvas.id;
|
|
1717
1701
|
this.type = "html-canvas";
|
|
1718
1702
|
this.htmlCanvas = this.canvas;
|
|
1719
|
-
} else
|
|
1720
|
-
this.id =
|
|
1703
|
+
} else {
|
|
1704
|
+
this.id = "offscreen-canvas";
|
|
1721
1705
|
this.type = "offscreen-canvas";
|
|
1722
1706
|
this.offscreenCanvas = this.canvas;
|
|
1723
|
-
} else {
|
|
1724
|
-
this.id = props.id || "node-canvas-context";
|
|
1725
|
-
this.type = "node";
|
|
1726
|
-
}
|
|
1727
|
-
this.pixelWidth = this.canvas.width;
|
|
1728
|
-
this.pixelHeight = this.canvas.height;
|
|
1729
|
-
this.drawingBufferWidth = this.canvas.width;
|
|
1730
|
-
this.drawingBufferHeight = this.canvas.height;
|
|
1731
|
-
this.devicePixelRatio = globalThis.devicePixelRatio || 1;
|
|
1732
|
-
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) {
|
|
1733
|
-
this._intersectionObserver = new IntersectionObserver(
|
|
1734
|
-
(entries) => this._handleIntersection(entries)
|
|
1735
|
-
);
|
|
1736
|
-
this._intersectionObserver.observe(this.canvas);
|
|
1737
|
-
this._resizeObserver = new ResizeObserver((entries) => this._handleResize(entries));
|
|
1738
|
-
try {
|
|
1739
|
-
this._resizeObserver.observe(this.canvas, { box: "device-pixel-content-box" });
|
|
1740
|
-
} catch {
|
|
1741
|
-
this._resizeObserver.observe(this.canvas, { box: "content-box" });
|
|
1742
|
-
}
|
|
1743
|
-
setTimeout(() => this._observeDevicePixelRatio(), 0);
|
|
1744
1707
|
}
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
return [this.canvas.clientWidth, this.canvas.clientHeight];
|
|
1708
|
+
if (this.canvas instanceof HTMLCanvasElement && props.autoResize) {
|
|
1709
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
1710
|
+
for (const entry of entries) {
|
|
1711
|
+
if (entry.target === this.canvas) {
|
|
1712
|
+
this.update();
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
1716
|
+
this.resizeObserver.observe(this.canvas);
|
|
1755
1717
|
}
|
|
1756
|
-
return [this.pixelWidth, this.pixelHeight];
|
|
1757
|
-
}
|
|
1758
|
-
/**
|
|
1759
|
-
* Returns the size covered by the canvas in actual device pixels.
|
|
1760
|
-
* @note This can be different from the 'CSS' size of a canvas due to DPR scaling, and rounding to integer pixels
|
|
1761
|
-
* @note This is independent of the canvas' internal drawing buffer size (.width, .height).
|
|
1762
|
-
*/
|
|
1763
|
-
getPixelSize() {
|
|
1764
|
-
return [this.pixelWidth, this.pixelHeight];
|
|
1765
|
-
}
|
|
1766
|
-
/** Get the drawing buffer size (number of pixels GPU is rendering into, can be different from CSS size) */
|
|
1767
|
-
getDrawingBufferSize() {
|
|
1768
|
-
return [this.drawingBufferWidth, this.drawingBufferHeight];
|
|
1769
|
-
}
|
|
1770
|
-
/** Returns the biggest allowed framebuffer size. @todo Allow the application to limit this? */
|
|
1771
|
-
getMaxDrawingBufferSize() {
|
|
1772
|
-
const maxTextureDimension = this.device.limits.maxTextureDimension2D;
|
|
1773
|
-
return [maxTextureDimension, maxTextureDimension];
|
|
1774
|
-
}
|
|
1775
|
-
/** Update the canvas drawing buffer size. Called automatically if props.autoResize is true. */
|
|
1776
|
-
setDrawingBufferSize(width, height) {
|
|
1777
|
-
this.canvas.width = width;
|
|
1778
|
-
this.canvas.height = height;
|
|
1779
|
-
this.drawingBufferWidth = width;
|
|
1780
|
-
this.drawingBufferHeight = height;
|
|
1781
|
-
}
|
|
1782
|
-
/** @deprecated - TODO which values should we use for aspect */
|
|
1783
|
-
getAspect() {
|
|
1784
|
-
const [width, height] = this.getPixelSize();
|
|
1785
|
-
return width / height;
|
|
1786
1718
|
}
|
|
1787
1719
|
/**
|
|
1788
|
-
* Returns the current DPR
|
|
1789
|
-
*
|
|
1790
|
-
* @note This function handles the non-HTML canvas cases
|
|
1720
|
+
* Returns the current DPR, if props.useDevicePixels is true
|
|
1721
|
+
* Device refers to physical
|
|
1791
1722
|
*/
|
|
1792
1723
|
getDevicePixelRatio(useDevicePixels) {
|
|
1793
1724
|
if (typeof OffscreenCanvas !== "undefined" && this.canvas instanceof OffscreenCanvas) {
|
|
@@ -1803,13 +1734,37 @@ var __exports__ = (() => {
|
|
|
1803
1734
|
}
|
|
1804
1735
|
return useDevicePixels;
|
|
1805
1736
|
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Returns the size of drawing buffer in device pixels.
|
|
1739
|
+
* @note This can be different from the 'CSS' size of a canvas, and also from the
|
|
1740
|
+
* canvas' internal drawing buffer size (.width, .height).
|
|
1741
|
+
* This is the size required to cover the canvas, adjusted for DPR
|
|
1742
|
+
*/
|
|
1743
|
+
getPixelSize() {
|
|
1744
|
+
switch (this.type) {
|
|
1745
|
+
case "node":
|
|
1746
|
+
return [this.width, this.height];
|
|
1747
|
+
case "offscreen-canvas":
|
|
1748
|
+
return [this.canvas.width, this.canvas.height];
|
|
1749
|
+
case "html-canvas":
|
|
1750
|
+
const dpr = this.getDevicePixelRatio();
|
|
1751
|
+
const canvas = this.canvas;
|
|
1752
|
+
return canvas.parentElement ? [canvas.clientWidth * dpr, canvas.clientHeight * dpr] : [this.canvas.width, this.canvas.height];
|
|
1753
|
+
default:
|
|
1754
|
+
throw new Error(this.type);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
getAspect() {
|
|
1758
|
+
const [width, height] = this.getPixelSize();
|
|
1759
|
+
return width / height;
|
|
1760
|
+
}
|
|
1806
1761
|
/**
|
|
1807
1762
|
* Returns multiplier need to convert CSS size to Device size
|
|
1808
1763
|
*/
|
|
1809
1764
|
cssToDeviceRatio() {
|
|
1810
1765
|
try {
|
|
1811
1766
|
const [drawingBufferWidth] = this.getDrawingBufferSize();
|
|
1812
|
-
const
|
|
1767
|
+
const clientWidth = this._canvasSizeInfo.clientWidth || this.htmlCanvas?.clientWidth;
|
|
1813
1768
|
return clientWidth ? drawingBufferWidth / clientWidth : 1;
|
|
1814
1769
|
} catch {
|
|
1815
1770
|
return 1;
|
|
@@ -1823,68 +1778,11 @@ var __exports__ = (() => {
|
|
|
1823
1778
|
const [width, height] = this.getDrawingBufferSize();
|
|
1824
1779
|
return scalePixels(cssPixel, ratio, width, height, yInvert);
|
|
1825
1780
|
}
|
|
1826
|
-
// IMPLEMENTATION
|
|
1827
1781
|
/**
|
|
1828
|
-
*
|
|
1829
|
-
* This can really help when debugging DOM in apps that create multiple devices
|
|
1830
|
-
*/
|
|
1831
|
-
_setAutoCreatedCanvasId(id) {
|
|
1832
|
-
if (this.htmlCanvas?.id === "lumagl-auto-created-canvas") {
|
|
1833
|
-
this.htmlCanvas.id = id;
|
|
1834
|
-
}
|
|
1835
|
-
}
|
|
1836
|
-
/** reacts to our intersection observer */
|
|
1837
|
-
_handleIntersection(entries) {
|
|
1838
|
-
const entry = entries.find((entry_) => entry_.target === this.canvas);
|
|
1839
|
-
if (!entry) {
|
|
1840
|
-
return;
|
|
1841
|
-
}
|
|
1842
|
-
const isVisible = entry.isIntersecting;
|
|
1843
|
-
if (this.isVisible !== isVisible) {
|
|
1844
|
-
this.isVisible = isVisible;
|
|
1845
|
-
this.device.props.onVisibilityChange(this);
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
/**
|
|
1849
|
-
* Reacts to an observed resize by using the most accurate pixel size information the browser can provide
|
|
1850
|
-
* @see https://web.dev/articles/device-pixel-content-box
|
|
1851
|
-
* @see https://webgpufundamentals.org/webgpu/lessons/webgpu-resizing-the-canvas.html
|
|
1852
|
-
*/
|
|
1853
|
-
_handleResize(entries) {
|
|
1854
|
-
const entry = entries.find((entry_) => entry_.target === this.canvas);
|
|
1855
|
-
if (!entry) {
|
|
1856
|
-
return;
|
|
1857
|
-
}
|
|
1858
|
-
const boxWidth = entry.devicePixelContentBoxSize?.[0].inlineSize || entry.contentBoxSize[0].inlineSize * devicePixelRatio;
|
|
1859
|
-
const boxHeight = entry.devicePixelContentBoxSize?.[0].blockSize || entry.contentBoxSize[0].blockSize * devicePixelRatio;
|
|
1860
|
-
const oldPixelSize = this.getPixelSize();
|
|
1861
|
-
const [maxPixelWidth, maxPixelHeight] = this.getMaxDrawingBufferSize();
|
|
1862
|
-
this.pixelWidth = Math.max(1, Math.min(boxWidth, maxPixelWidth));
|
|
1863
|
-
this.pixelHeight = Math.max(1, Math.min(boxHeight, maxPixelHeight));
|
|
1864
|
-
if (this.props.autoResize) {
|
|
1865
|
-
this.setDrawingBufferSize(this.pixelWidth, this.pixelHeight);
|
|
1866
|
-
this.updateSize(this.getDrawingBufferSize());
|
|
1867
|
-
}
|
|
1868
|
-
this._initializedResolvers.resolve();
|
|
1869
|
-
this.isInitialized = true;
|
|
1870
|
-
this.device.props.onResize(this, { oldPixelSize });
|
|
1871
|
-
}
|
|
1872
|
-
/** Monitor DPR changes */
|
|
1873
|
-
_observeDevicePixelRatio() {
|
|
1874
|
-
const oldRatio = this.devicePixelRatio;
|
|
1875
|
-
this.devicePixelRatio = window.devicePixelRatio;
|
|
1876
|
-
this.device.props.onDevicePixelRatioChange(this, { oldRatio });
|
|
1877
|
-
matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener(
|
|
1878
|
-
"change",
|
|
1879
|
-
() => this._observeDevicePixelRatio(),
|
|
1880
|
-
{ once: true }
|
|
1881
|
-
);
|
|
1882
|
-
}
|
|
1883
|
-
/**
|
|
1884
|
-
* @deprecated Use devicePixelRatio to set canvas width and height
|
|
1782
|
+
* Use devicePixelRatio to set canvas width and height
|
|
1885
1783
|
* @note this is a raw port of luma.gl v8 code. Might be worth a review
|
|
1886
1784
|
*/
|
|
1887
|
-
|
|
1785
|
+
setDevicePixelRatio(devicePixelRatio, options = {}) {
|
|
1888
1786
|
if (!this.htmlCanvas) {
|
|
1889
1787
|
return;
|
|
1890
1788
|
}
|
|
@@ -1892,13 +1790,13 @@ var __exports__ = (() => {
|
|
|
1892
1790
|
let clientHeight = "height" in options ? options.height : this.htmlCanvas.clientHeight;
|
|
1893
1791
|
if (!clientWidth || !clientHeight) {
|
|
1894
1792
|
log.log(1, "Canvas clientWidth/clientHeight is 0")();
|
|
1895
|
-
|
|
1793
|
+
devicePixelRatio = 1;
|
|
1896
1794
|
clientWidth = this.htmlCanvas.width || 1;
|
|
1897
1795
|
clientHeight = this.htmlCanvas.height || 1;
|
|
1898
1796
|
}
|
|
1899
1797
|
const cachedSize = this._canvasSizeInfo;
|
|
1900
|
-
if (cachedSize.clientWidth !== clientWidth || cachedSize.clientHeight !== clientHeight || cachedSize.devicePixelRatio !==
|
|
1901
|
-
let clampedPixelRatio =
|
|
1798
|
+
if (cachedSize.clientWidth !== clientWidth || cachedSize.clientHeight !== clientHeight || cachedSize.devicePixelRatio !== devicePixelRatio) {
|
|
1799
|
+
let clampedPixelRatio = devicePixelRatio;
|
|
1902
1800
|
const canvasWidth = Math.floor(clientWidth * clampedPixelRatio);
|
|
1903
1801
|
const canvasHeight = Math.floor(clientHeight * clampedPixelRatio);
|
|
1904
1802
|
this.htmlCanvas.width = canvasWidth;
|
|
@@ -1917,16 +1815,34 @@ var __exports__ = (() => {
|
|
|
1917
1815
|
}
|
|
1918
1816
|
this._canvasSizeInfo.clientWidth = clientWidth;
|
|
1919
1817
|
this._canvasSizeInfo.clientHeight = clientHeight;
|
|
1920
|
-
this._canvasSizeInfo.devicePixelRatio =
|
|
1818
|
+
this._canvasSizeInfo.devicePixelRatio = devicePixelRatio;
|
|
1921
1819
|
}
|
|
1922
1820
|
}
|
|
1923
1821
|
}
|
|
1822
|
+
// PRIVATE
|
|
1823
|
+
/** @todo Major hack done to port the CSS methods above, base canvas context should not depend on WebGL */
|
|
1824
|
+
getDrawingBufferSize() {
|
|
1825
|
+
const gl = this.device.gl;
|
|
1826
|
+
if (!gl) {
|
|
1827
|
+
throw new Error("canvas size");
|
|
1828
|
+
}
|
|
1829
|
+
return [gl.drawingBufferWidth, gl.drawingBufferHeight];
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Allows subclass constructor to override the canvas id for auto created canvases.
|
|
1833
|
+
* This can really help when debugging DOM in apps that create multiple devices
|
|
1834
|
+
*/
|
|
1835
|
+
_setAutoCreatedCanvasId(id) {
|
|
1836
|
+
if (this.htmlCanvas?.id === "lumagl-auto-created-canvas") {
|
|
1837
|
+
this.htmlCanvas.id = id;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1924
1840
|
};
|
|
1925
1841
|
var CanvasContext = _CanvasContext;
|
|
1926
1842
|
__publicField(CanvasContext, "defaultProps", {
|
|
1927
|
-
id: void 0,
|
|
1928
1843
|
canvas: null,
|
|
1929
1844
|
width: 800,
|
|
1845
|
+
// width are height are only used by headless gl
|
|
1930
1846
|
height: 600,
|
|
1931
1847
|
useDevicePixels: true,
|
|
1932
1848
|
autoResize: true,
|
|
@@ -1942,33 +1858,27 @@ var __exports__ = (() => {
|
|
|
1942
1858
|
throw new Error(`${container} is not an HTML element`);
|
|
1943
1859
|
}
|
|
1944
1860
|
return element;
|
|
1945
|
-
}
|
|
1946
|
-
if (container) {
|
|
1861
|
+
} else if (container) {
|
|
1947
1862
|
return container;
|
|
1948
1863
|
}
|
|
1949
1864
|
return document.body;
|
|
1950
1865
|
}
|
|
1951
1866
|
function getCanvasFromDOM(canvasId) {
|
|
1952
1867
|
const canvas = document.getElementById(canvasId);
|
|
1953
|
-
if (
|
|
1868
|
+
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
1954
1869
|
throw new Error("Object is not a canvas element");
|
|
1955
1870
|
}
|
|
1956
1871
|
return canvas;
|
|
1957
1872
|
}
|
|
1958
|
-
function
|
|
1873
|
+
function createCanvas(props) {
|
|
1959
1874
|
const { width, height } = props;
|
|
1960
|
-
const
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
newCanvas.style.visibility = "hidden";
|
|
1968
|
-
}
|
|
1969
|
-
const container = getContainer(props?.container || null);
|
|
1970
|
-
container.insertBefore(newCanvas, container.firstChild);
|
|
1971
|
-
return newCanvas;
|
|
1875
|
+
const targetCanvas = document.createElement("canvas");
|
|
1876
|
+
targetCanvas.id = uid("lumagl-auto-created-canvas");
|
|
1877
|
+
targetCanvas.width = width || 1;
|
|
1878
|
+
targetCanvas.height = height || 1;
|
|
1879
|
+
targetCanvas.style.width = Number.isFinite(width) ? `${width}px` : "100%";
|
|
1880
|
+
targetCanvas.style.height = Number.isFinite(height) ? `${height}px` : "100%";
|
|
1881
|
+
return targetCanvas;
|
|
1972
1882
|
}
|
|
1973
1883
|
function scalePixels(pixel, ratio, width, height, yInvert) {
|
|
1974
1884
|
const point = pixel;
|
|
@@ -2000,15 +1910,6 @@ var __exports__ = (() => {
|
|
|
2000
1910
|
function scaleY(y, ratio, height, yInvert) {
|
|
2001
1911
|
return yInvert ? Math.max(0, height - 1 - Math.round(y * ratio)) : Math.min(Math.round(y * ratio), height - 1);
|
|
2002
1912
|
}
|
|
2003
|
-
function withResolvers() {
|
|
2004
|
-
let resolve;
|
|
2005
|
-
let reject;
|
|
2006
|
-
const promise = new Promise((_resolve, _reject) => {
|
|
2007
|
-
resolve = _resolve;
|
|
2008
|
-
reject = _reject;
|
|
2009
|
-
});
|
|
2010
|
-
return { promise, resolve, reject };
|
|
2011
|
-
}
|
|
2012
1913
|
|
|
2013
1914
|
// ../core/src/adapter/resources/texture.ts
|
|
2014
1915
|
var _Texture = class extends Resource {
|
|
@@ -2626,9 +2527,10 @@ ${htmlLog}
|
|
|
2626
2527
|
shaderLayout: null,
|
|
2627
2528
|
bufferLayout: [],
|
|
2628
2529
|
topology: "triangle-list",
|
|
2629
|
-
colorAttachmentFormats: void 0,
|
|
2630
|
-
depthStencilAttachmentFormat: void 0,
|
|
2631
2530
|
parameters: {},
|
|
2531
|
+
// isInstanced: false,
|
|
2532
|
+
// instanceCount: 0,
|
|
2533
|
+
// vertexCount: 0,
|
|
2632
2534
|
bindings: {},
|
|
2633
2535
|
uniforms: {}
|
|
2634
2536
|
});
|
|
@@ -2966,9 +2868,13 @@ ${htmlLog}
|
|
|
2966
2868
|
super(device, props, _VertexArray.defaultProps);
|
|
2967
2869
|
this.maxVertexAttributes = device.limits.maxVertexAttributes;
|
|
2968
2870
|
this.attributes = new Array(this.maxVertexAttributes).fill(null);
|
|
2871
|
+
const { shaderLayout, bufferLayout } = props.renderPipeline || {};
|
|
2872
|
+
if (!shaderLayout || !bufferLayout) {
|
|
2873
|
+
throw new Error("VertexArray");
|
|
2874
|
+
}
|
|
2969
2875
|
this.attributeInfos = getAttributeInfosByLocation(
|
|
2970
|
-
|
|
2971
|
-
|
|
2876
|
+
shaderLayout,
|
|
2877
|
+
bufferLayout,
|
|
2972
2878
|
this.maxVertexAttributes
|
|
2973
2879
|
);
|
|
2974
2880
|
}
|
|
@@ -2981,8 +2887,7 @@ ${htmlLog}
|
|
|
2981
2887
|
var VertexArray = _VertexArray;
|
|
2982
2888
|
__publicField(VertexArray, "defaultProps", {
|
|
2983
2889
|
...Resource.defaultProps,
|
|
2984
|
-
|
|
2985
|
-
bufferLayout: []
|
|
2890
|
+
renderPipeline: null
|
|
2986
2891
|
});
|
|
2987
2892
|
|
|
2988
2893
|
// ../core/src/adapter/resources/transform-feedback.ts
|
package/dist/dist.min.js
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var Mt=Object.create;var z=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var It=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var $t=(r,e,t)=>e in r?z(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var zt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ht=(r,e)=>{for(var t in e)z(r,t,{get:e[t],enumerable:!0})},se=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Dt(e))!Ft.call(r,i)&&i!==t&&z(r,i,{get:()=>e[i],enumerable:!(n=Rt(e,i))||n.enumerable});return r},oe=(r,e,t)=>(se(r,e,"default"),t&&se(t,e,"default")),Nt=(r,e,t)=>(t=r!=null?Mt(It(r)):{},se(e||!r||!r.__esModule?z(t,"default",{value:r,enumerable:!0}):t,r)),Ut=r=>se(z({},"__esModule",{value:!0}),r);var a=(r,e,t)=>($t(r,typeof e!="symbol"?e+"":e,t),t);var Lt=zt((oo,_t)=>{_t.exports=globalThis.luma});var ie={};Ht(ie,{Adapter:()=>we,Buffer:()=>h,CanvasContext:()=>G,CommandBuffer:()=>Q,CommandEncoder:()=>J,ComputePass:()=>K,ComputePipeline:()=>q,Device:()=>C,DeviceFeatures:()=>xe,DeviceLimits:()=>ye,ExternalTexture:()=>O,Framebuffer:()=>X,QuerySet:()=>ne,RenderPass:()=>A,RenderPipeline:()=>Z,Resource:()=>c,Sampler:()=>Y,Shader:()=>j,Texture:()=>m,TextureView:()=>V,TransformFeedback:()=>re,UniformBlock:()=>$,UniformBufferLayout:()=>F,UniformStore:()=>Ee,VertexArray:()=>te,_BufferLayoutHelper:()=>Pe,_getTextureFormatDefinition:()=>R,_getTextureFormatTable:()=>lt,decodeShaderAttributeType:()=>Se,decodeShaderUniformType:()=>ve,decodeTextureFormat:()=>ge,decodeVertexFormat:()=>ee,getAttributeInfosFromLayouts:()=>je,getDataTypeFromTypedArray:()=>Ke,getScratchArray:()=>St,getTextureFormatCapabilities:()=>be,getTypedArrayFromDataType:()=>Pt,getVertexFormatFromAttribute:()=>Ct,log:()=>l,luma:()=>ht});var ae=globalThis,kt=globalThis.document||{},ce=globalThis.process||{},Wt=globalThis.console,Lr=globalThis.navigator||{};function Je(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=r||e;return Boolean(t&&t.indexOf("Electron")>=0)}function y(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Je()}var Ce="4.0.7";function H(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var E=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=H(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(H()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var L=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:n}=e,i=this.stats[t];return i||(e instanceof E?i=e:i=new E(t,n),this.stats[t]=i),i}};var _e=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new L({id:e})),this.stats.get(e)}},ue=new _e;function Vt(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var le=class{constructor(e,t,n="sessionStorage"){this.storage=Vt(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}};function Qe(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function et(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var fe;(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(fe||(fe={}));var Ot=10;function tt(r){return typeof r!="string"?r:(r=r.toUpperCase(),fe[r]||fe.WHITE)}function rt(r,e,t){return!y&&typeof r=="string"&&(e&&(r=`\x1B[${tt(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${tt(t)+Ot}m${r}\x1B[49m`)),r}function nt(r,e=["constructor"]){let t=Object.getPrototypeOf(r),n=Object.getOwnPropertyNames(t),i=r;for(let s of n){let o=i[s];typeof o=="function"&&(e.find(u=>s===u)||(i[s]=o.bind(r)))}}function N(r,e){if(!r)throw new Error(e||"Assertion failed")}function P(){let r;if(y()&&ae.performance)r=ae?.performance?.now?.();else if("hrtime"in ce){let e=ce?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var B={debug:y()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},jt={enabled:!0,level:0};function M(){}var it={},st={once:!0},S=class{constructor({id:e}={id:""}){this.VERSION=Ce,this._startTs=P(),this._deltaTs=P(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new le(`__probe-${this.id}__`,jt),this.timeStamp(`${this.id} started`),nt(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((P()-this._startTs).toPrecision(10))}getDelta(){return Number((P()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,B.warn,arguments,st)}error(e){return this._getLogFunction(0,e,B.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,B.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,B.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,B.debug||B.info,arguments,st)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||M,n&&[n],{tag:Xt(t)}):M}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||M)}group(e,t,n={collapsed:!1}){let i=ot({logLevel:e,message:t,opts:n}),{collapsed:s}=n;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||M)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=at(e)}_getLogFunction(e,t,n,i,s){if(this._shouldLog(e)){s=ot({logLevel:e,message:t,args:i,opts:s}),n=n||s.method,N(n),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=P();let o=s.tag||s.message;if(s.once&&o)if(!it[o])it[o]=P();else return M;return t=Yt(this.id,s.message,s),n.bind(console,t,...s.args)}return M}};S.VERSION=Ce;function at(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return N(Number.isFinite(e)&&e>=0),e}function ot(r){let{logLevel:e,message:t}=r;r.logLevel=at(e);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let i=typeof r.message;return N(i==="string"||i==="object"),Object.assign(r,{args:n},r.opts)}function Yt(r,e,t){if(typeof e=="string"){let n=t.time?et(Qe(t.total)):"";e=t.time?`${r}: ${n} ${e}`:`${r}: ${e}`,e=rt(e,t.color,t.background)}return e}function Xt(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}globalThis.probe={};var dn=new S({id:"@probe.gl/log"});var l=new S({id:"luma.gl"});var Le={};function v(r="id"){Le[r]=Le[r]||1;let e=Le[r]++;return`${r}-${e}`}var c=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,t,n){if(!e)throw new Error("no device");this._device=e,this.props=Zt(t,n);let i=this.props.id!=="undefined"?this.props.id:v(this[Symbol.toStringTag]);this.props.id=i,this.id=i,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}};a(c,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Zt(r,e){let t={...e};for(let n in r)r[n]!==void 0&&(t[n]=r[n]);return t}var U=class extends c{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let n={...t};(t.usage||0)&U.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array&&(n.indexType="uint16")),delete n.data,super(e,n,U.defaultProps),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}readSyncWebGL(e,t){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(e,t,n){let i=ArrayBuffer.isView(e)?e.buffer:e,s=Math.min(e?e.byteLength:n,U.DEBUG_DATA_MAX_LENGTH);i===null?this.debugData=new ArrayBuffer(s):t===0&&n===i.byteLength?this.debugData=i.slice(0,s):this.debugData=i.slice(t,t+s)}},h=U;a(h,"defaultProps",{...c.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),a(h,"MAP_READ",1),a(h,"MAP_WRITE",2),a(h,"COPY_SRC",4),a(h,"COPY_DST",8),a(h,"INDEX",16),a(h,"VERTEX",32),a(h,"UNIFORM",64),a(h,"STORAGE",128),a(h,"INDIRECT",256),a(h,"QUERY_RESOLVE",512),a(h,"DEBUG_DATA_MAX_LENGTH",32);function de(r){let e=ct[r],t=qt(e),n=r.includes("norm"),i=!n&&!r.startsWith("float"),s=r.startsWith("s");return{dataType:ct[r],byteLength:t,integer:i,signed:s,normalized:n}}function qt(r){return Kt[r]}var ct={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Kt={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var p="texture-compression-bc",d="texture-compression-astc",w="texture-compression-etc2",Jt="texture-compression-etc1-webgl",he="texture-compression-pvrtc-webgl",Be="texture-compression-atc-webgl",me="float32-renderable-webgl",Me="float16-renderable-webgl",Qt="rgb9e5ufloat-renderable-webgl",Re="snorm8-renderable-webgl",k="norm16-renderable-webgl",De="snorm16-renderable-webgl",pe="float32-filterable",ut="float16-filterable-webgl";function R(r){let e=ft[r];if(!e)throw new Error(`Unsupported texture format ${r}`);return e}function lt(){return ft}var ft={r8unorm:{},r8snorm:{render:Re},r8uint:{},r8sint:{},rg8unorm:{},rg8snorm:{render:Re},rg8uint:{},rg8sint:{},r16uint:{},r16sint:{},r16float:{render:Me,filter:"float16-filterable-webgl"},"r16unorm-webgl":{f:k},"r16snorm-webgl":{f:De},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},"rgb8unorm-webgl":{},"rgb8snorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},rgba8snorm:{render:Re},rgba8uint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{},rg16sint:{},rg16float:{render:Me,filter:ut},"rg16unorm-webgl":{render:k},"rg16snorm-webgl":{render:De},r32uint:{},r32sint:{},r32float:{render:me,filter:pe},rgb9e5ufloat:{channels:"rgb",packed:!0,render:Qt},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:me},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},"rgb16unorm-webgl":{f:k},"rgb16snorm-webgl":{f:k},rg32uint:{},rg32sint:{},rg32float:{render:!1,filter:pe},rgba16uint:{},rgba16sint:{},rgba16float:{render:Me,filter:ut},"rgba16unorm-webgl":{render:k},"rgba16snorm-webgl":{render:De},"rgb32float-webgl":{render:me,filter:pe},rgba32uint:{},rgba32sint:{},rgba32float:{render:me,filter:pe},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0},"bc1-rgb-unorm-webgl":{f:p},"bc1-rgb-unorm-srgb-webgl":{f:p},"bc1-rgba-unorm":{f:p},"bc1-rgba-unorm-srgb":{f:p},"bc2-rgba-unorm":{f:p},"bc2-rgba-unorm-srgb":{f:p},"bc3-rgba-unorm":{f:p},"bc3-rgba-unorm-srgb":{f:p},"bc4-r-unorm":{f:p},"bc4-r-snorm":{f:p},"bc5-rg-unorm":{f:p},"bc5-rg-snorm":{f:p},"bc6h-rgb-ufloat":{f:p},"bc6h-rgb-float":{f:p},"bc7-rgba-unorm":{f:p},"bc7-rgba-unorm-srgb":{f:p},"etc2-rgb8unorm":{f:w},"etc2-rgb8unorm-srgb":{f:w},"etc2-rgb8a1unorm":{f:w},"etc2-rgb8a1unorm-srgb":{f:w},"etc2-rgba8unorm":{f:w},"etc2-rgba8unorm-srgb":{f:w},"eac-r11unorm":{f:w},"eac-r11snorm":{f:w},"eac-rg11unorm":{f:w},"eac-rg11snorm":{f:w},"astc-4x4-unorm":{f:d},"astc-4x4-unorm-srgb":{f:d},"astc-5x4-unorm":{f:d},"astc-5x4-unorm-srgb":{f:d},"astc-5x5-unorm":{f:d},"astc-5x5-unorm-srgb":{f:d},"astc-6x5-unorm":{f:d},"astc-6x5-unorm-srgb":{f:d},"astc-6x6-unorm":{f:d},"astc-6x6-unorm-srgb":{f:d},"astc-8x5-unorm":{f:d},"astc-8x5-unorm-srgb":{f:d},"astc-8x6-unorm":{f:d},"astc-8x6-unorm-srgb":{f:d},"astc-8x8-unorm":{f:d},"astc-8x8-unorm-srgb":{f:d},"astc-10x5-unorm":{f:d},"astc-10x5-unorm-srgb":{f:d},"astc-10x6-unorm":{f:d},"astc-10x6-unorm-srgb":{f:d},"astc-10x8-unorm":{f:d},"astc-10x8-unorm-srgb":{f:d},"astc-10x10-unorm":{f:d},"astc-10x10-unorm-srgb":{f:d},"astc-12x10-unorm":{f:d},"astc-12x10-unorm-srgb":{f:d},"astc-12x12-unorm":{f:d},"astc-12x12-unorm-srgb":{f:d},"pvrtc-rgb4unorm-webgl":{f:he},"pvrtc-rgba4unorm-webgl":{f:he},"pvrtc-rbg2unorm-webgl":{f:he},"pvrtc-rgba2unorm-webgl":{f:he},"etc1-rbg-unorm-webgl":{f:Jt},"atc-rgb-unorm-webgl":{f:Be},"atc-rgba-unorm-webgl":{f:Be},"atc-rgbai-unorm-webgl":{f:Be}};var er=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],tr=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;function Ie(r){return er.some(e=>r.startsWith(e))}function ge(r){let e=rr(r);if(Ie(r)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;let n=nr(r);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}let t=tr.exec(r);if(t){let[,n,i,s,o,u]=t,f=`${s}${i}`,b=de(f),g=b.byteLength*8,x=n.length,Bt=[g,x>=2?g:0,x>=3?g:0,x>=4?g:0];e={format:r,attachment:e.attachment,dataType:b.dataType,components:x,channels:n,integer:b.integer,signed:b.signed,normalized:b.normalized,bitsPerChannel:Bt,bytesPerPixel:b.byteLength*n.length,packed:e.packed,srgb:e.srgb},u==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return r.endsWith("-webgl")&&(e.webgl=!0),r.endsWith("-srgb")&&(e.srgb=!0),e}function rr(r){let e=R(r),t=e.bytesPerPixel||1,n=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:r,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:n,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function nr(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,n,i]=t;return{blockWidth:Number(n),blockHeight:Number(i)}}return null}function be(r){let e=R(r),t={format:r,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},n=ge(r),i=r.startsWith("depth")||r.startsWith("stencil"),s=n?.signed,o=n?.integer,u=n?.webgl;return t.render&&=!s,t.filter&&=!i&&!s&&!o&&!u,t}var ye=class{},xe=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},Fe=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...Fe.defaultProps,...e},this.id=this.props.id||v(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=ue;timestamp=0;_lumaData={};getTextureFormatCapabilities(e){let t=be(e),n=o=>(typeof o=="string"?this.features.has(o):o)??!0,i=n(t.create),s={format:e,create:i,render:i&&n(t.render),filter:i&&n(t.filter),blend:i&&n(t.blend),store:i&&n(t.store)};return this._getDeviceSpecificTextureFormatCapabilities(s)}isTextureFormatSupported(e,t){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Ie(e)}loseDevice(){return!1}reportError(e){this.props.onError(e)}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createCommandEncoder(e={}){throw new Error("not implemented")}incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};return(e.usage||0)&h.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":l.warn("indices buffer content must be of type uint16 or uint32")()),t}},C=Fe;a(C,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:e=>l.error(e.message)(),onResize:(e,t)=>{let[n,i]=e.getPixelSize(),[s,o]=t.oldPixelSize;l.log(1,`${e} Resized ${s}x${o} => ${n}x${i}px`)()},onVisibilityChange:e=>l.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>l.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:l.get("debug")||void 0,debugShaders:l.get("debug-shaders")||void 0,debugFramebuffers:Boolean(l.get("debug-framebuffers")),debugFactories:Boolean(l.get("debug-factories")),debugWebGL:Boolean(l.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_resourceDefaults:{},_handle:void 0});var ir=y()&&typeof document<"u",sr=()=>ir&&document.readyState==="complete",or="set luma.log.level=1 (or higher) to trace rendering",dt="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",D=class{stats=ue;log=l;VERSION="9.1.0-beta.8";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw l.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),l.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");l.error("This version of luma.gl has already been initialized")()}l.log(1,`${this.VERSION} - ${or}`)(),globalThis.luma=this}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this.getAdapterMap(e);return Array.from(t).map(([,n])=>n).filter(n=>n.isSupported?.()).map(n=>n.type)}getBestAvailableAdapter(e=[]){let t=this.getAdapterMap(e);return t.get("webgpu")?.isSupported?.()?"webgpu":t.get("webgl")?.isSupported?.()?"webgl":null}setDefaultDeviceProps(e){Object.assign(D.defaultProps,e)}async createDevice(e={}){e={...D.defaultProps,...e},e.waitForPageLoad&&await D.pageLoaded;let t=this.getAdapterMap(e.adapters),n=e.type||"";n==="best-available"&&(n=this.getBestAvailableAdapter(e.adapters)||n);let o=await(this.getAdapterMap(e.adapters)||t).get(n)?.create?.(e);if(o)return o;throw new Error(dt)}async attachDevice(e){let t=this.getAdapterMap(e.adapters),n="";e.handle instanceof WebGL2RenderingContext&&(n="webgl"),e.createCanvasContext&&await D.pageLoaded,e.handle===null&&(n="unknown");let s=await t.get(n)?.attach?.(null);if(s)return s;throw new Error(dt)}enforceWebGL2(e=!0,t=[]){let i=this.getAdapterMap(t).get("webgl");i||l.warn("enforceWebGL2: webgl adapter not found")(),i?.enforceWebGL2?.(e)}getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let n of e)t.set(n.type,n);return t}registerDevices(e){l.warn("luma.registerDevices() is deprecated, use luma.registerAdapters() instead");for(let t of e){let n=t.adapter;n&&this.preregisteredAdapters.set(n.type,n)}}},W=D;a(W,"defaultProps",{...C.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0}),a(W,"pageLoaded",ar().then(()=>{l.probe(2,"DOM is loaded")()}));var ht=new W;function ar(){return sr()||typeof window>"u"?Promise.resolve():new Promise(r=>{window.addEventListener("load",()=>r())})}var we=class{};var $e=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;_initializedResolvers=dr();initialized;isInitialized=!1;isVisible=!0;devicePixelRatio;pixelWidth;pixelHeight;drawingBufferWidth;drawingBufferHeight;_resizeObserver;_intersectionObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){if(this.props={...$e.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,y()?e.canvas?typeof e.canvas=="string"?this.canvas=ur(e.canvas):this.canvas=e.canvas:this.canvas=lr(e):this.canvas={width:e.width||1,height:e.height||1},typeof HTMLCanvasElement<"u"&&this.canvas instanceof HTMLCanvasElement?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.pixelWidth=this.canvas.width,this.pixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,typeof HTMLCanvasElement<"u"&&this.canvas instanceof HTMLCanvasElement){this._intersectionObserver=new IntersectionObserver(t=>this._handleIntersection(t)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(t=>this._handleResize(t));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0)}}getCSSSize(){return typeof HTMLCanvasElement<"u"&&this.canvas instanceof HTMLCanvasElement?[this.canvas.clientWidth,this.canvas.clientHeight]:[this.pixelWidth,this.pixelHeight]}getPixelSize(){return[this.pixelWidth,this.pixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getAspect(){let[e,t]=this.getPixelSize();return e/t}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:t}=this._canvasSizeInfo;return t?e/t:1}catch{return 1}}cssToDevicePixels(e,t=!0){let n=this.cssToDeviceRatio(),[i,s]=this.getDrawingBufferSize();return fr(e,n,i,s,t)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_handleIntersection(e){let t=e.find(i=>i.target===this.canvas);if(!t)return;let n=t.isIntersecting;this.isVisible!==n&&(this.isVisible=n,this.device.props.onVisibilityChange(this))}_handleResize(e){let t=e.find(f=>f.target===this.canvas);if(!t)return;let n=t.devicePixelContentBoxSize?.[0].inlineSize||t.contentBoxSize[0].inlineSize*devicePixelRatio,i=t.devicePixelContentBoxSize?.[0].blockSize||t.contentBoxSize[0].blockSize*devicePixelRatio,s=this.getPixelSize(),[o,u]=this.getMaxDrawingBufferSize();this.pixelWidth=Math.max(1,Math.min(n,o)),this.pixelHeight=Math.max(1,Math.min(i,u)),this.props.autoResize&&(this.setDrawingBufferSize(this.pixelWidth,this.pixelHeight),this.updateSize(this.getDrawingBufferSize())),this._initializedResolvers.resolve(),this.isInitialized=!0,this.device.props.onResize(this,{oldPixelSize:s})}_observeDevicePixelRatio(){let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let n="width"in t?t.width:this.htmlCanvas.clientWidth,i="height"in t?t.height:this.htmlCanvas.clientHeight;(!n||!i)&&(l.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,n=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==n||s.clientHeight!==i||s.devicePixelRatio!==e){let o=e,u=Math.floor(n*o),f=Math.floor(i*o);if(this.htmlCanvas.width=u,this.htmlCanvas.height=f,this.device.gl){let[g,x]=this.getDrawingBufferSize();(g!==u||x!==f)&&(o=Math.min(g/n,x/i),this.htmlCanvas.width=Math.floor(n*o),this.htmlCanvas.height=Math.floor(i*o),l.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=n,this._canvasSizeInfo.clientHeight=i,this._canvasSizeInfo.devicePixelRatio=e}}}},G=$e;a(G,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb"});function cr(r){if(typeof r=="string"){let e=document.getElementById(r);if(!e)throw new Error(`${r} is not an HTML element`);return e}return r||document.body}function ur(r){let e=document.getElementById(r);if(typeof e<"u"&&typeof HTMLCanvasElement<"u"&&!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function lr(r){let{width:e,height:t}=r,n=document.createElement("canvas");n.id=v("lumagl-auto-created-canvas"),n.width=e||1,n.height=t||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(t)?`${t}px`:"100%",r?.visible||(n.style.visibility="hidden");let i=cr(r?.container||null);return i.insertBefore(n,i.firstChild),n}function fr(r,e,t,n,i){let s=r,o=mt(s[0],e,t),u=pt(s[1],e,n,i),f=mt(s[0]+1,e,t),b=f===t-1?f:f-1;f=pt(s[1]+1,e,n,i);let g;return i?(f=f===0?f:f+1,g=u,u=f):g=f===n-1?f:f-1,{x:o,y:u,width:Math.max(b-o+1,1),height:Math.max(g-u+1,1)}}function mt(r,e,t){return Math.min(Math.round(r*e),t-1)}function pt(r,e,t,n){return n?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}function dr(){let r,e;return{promise:new Promise((n,i)=>{r=n,e=i}),resolve:r,reject:e}}var T=class extends c{get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}dimension;format;width;height;depth;mipLevels;updateTimestamp;constructor(e,t){if(t=T.normalizeProps(e,t),super(e,t,T.defaultProps),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.props.width===void 0||this.props.height===void 0){let n=T.getTextureDataSize(this.props.data);this.width=n?.width||1,this.height=n?.height||1}this.props.mipmaps&&this.props.mipLevels===void 0&&(this.props.mipLevels="pyramid"),this.mipLevels=this.props.mipLevels==="pyramid"?T.getMipLevelCount(this.width,this.height):this.props.mipLevels||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}static isExternalImage(e){return typeof ImageData<"u"&&e instanceof ImageData||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof VideoFrame<"u"&&e instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}static getExternalImageSize(e){if(typeof ImageData<"u"&&e instanceof ImageData||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if(typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if(typeof VideoFrame<"u"&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw new Error("Unknown image type")}static isTextureLevelData(e){let t=e?.data;return ArrayBuffer.isView(t)}static getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return T.getTextureDataSize(e[0]);if(T.isExternalImage(e))return T.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){let n=Object.values(e)[0];return{width:n.width,height:n.height}}throw new Error("texture size deduction failed")}static normalizeTextureData(e,t){let n;return ArrayBuffer.isView(e)?n=[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?n=e:n=[e],n}static getMipLevelCount(e,t){return Math.floor(Math.log2(Math.max(e,t)))+1}static getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}static normalizeProps(e,t){let n={...t},i=e?.props?._resourceDefaults?.texture||{};Object.assign(n,i);let{width:s,height:o}=n;return typeof s=="number"&&(n.width=Math.max(1,Math.ceil(s))),typeof o=="number"&&(n.height=Math.max(1,Math.ceil(o))),n}},m=T;a(m,"COPY_SRC",1),a(m,"COPY_DST",2),a(m,"TEXTURE",4),a(m,"STORAGE",8),a(m,"RENDER_ATTACHMENT",16),a(m,"CubeFaces",["+X","-X","+Y","-Y","+Z","-Z"]),a(m,"defaultProps",{...c.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!1,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,sampler:{},view:void 0,flipY:void 0}),a(m,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1});var ze=class extends c{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,ze.defaultProps)}},V=ze;a(V,"defaultProps",{...c.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var He=class extends c{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,He.defaultProps)}},O=He;a(O,"defaultProps",{...c.defaultProps,source:void 0,colorSpace:"srgb"});function bt(r,e,t){let n="",i=e.split(/\r?\n/),s=r.slice().sort((o,u)=>o.lineNum-u.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let u=1;u<=i.length;u++)for(n+=yt(i[u-1],u,t);s.length>o&&s[o].lineNum===u;){let f=s[o++];n+=gt(f,i,f.lineNum,{...t,inlineSource:!1})}return n;case"issues":case"no":for(let u of r)n+=gt(u,i,u.lineNum,{inlineSource:t?.showSourceCode!=="no"});return n}}function gt(r,e,t,n){if(n?.inlineSource){let s=hr(e,t),o=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^
|
|
7
|
+
"use strict";var __exports__=(()=>{var Bt=Object.create;var N=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Ft=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty;var $t=(r,e,t)=>e in r?N(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Nt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ut=(r,e)=>{for(var t in e)N(r,t,{get:e[t],enumerable:!0})},oe=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Rt(e))!Dt.call(r,s)&&s!==t&&N(r,s,{get:()=>e[s],enumerable:!(n=It(e,s))||n.enumerable});return r},ie=(r,e,t)=>(oe(r,e,"default"),t&&oe(t,e,"default")),Ht=(r,e,t)=>(t=r!=null?Bt(Ft(r)):{},oe(e||!r||!r.__esModule?N(t,"default",{value:r,enumerable:!0}):t,r)),zt=r=>oe(N({},"__esModule",{value:!0}),r);var a=(r,e,t)=>($t(r,typeof e!="symbol"?e+"":e,t),t);var Lt=Nt((ii,Pt)=>{Pt.exports=globalThis.luma});var se={};Ut(se,{Adapter:()=>we,Buffer:()=>m,CanvasContext:()=>W,CommandBuffer:()=>Q,CommandEncoder:()=>J,ComputePass:()=>K,ComputePipeline:()=>q,Device:()=>_,DeviceFeatures:()=>xe,DeviceLimits:()=>ye,ExternalTexture:()=>O,Framebuffer:()=>X,QuerySet:()=>ne,RenderPass:()=>A,RenderPipeline:()=>Z,Resource:()=>u,Sampler:()=>Y,Shader:()=>j,Texture:()=>h,TextureView:()=>V,TransformFeedback:()=>re,UniformBlock:()=>$,UniformBufferLayout:()=>D,UniformStore:()=>Ee,VertexArray:()=>te,_BufferLayoutHelper:()=>Ce,_getTextureFormatDefinition:()=>I,_getTextureFormatTable:()=>ft,decodeShaderAttributeType:()=>Se,decodeShaderUniformType:()=>ve,decodeTextureFormat:()=>ge,decodeVertexFormat:()=>ee,getAttributeInfosFromLayouts:()=>je,getDataTypeFromTypedArray:()=>Ke,getScratchArray:()=>St,getTextureFormatCapabilities:()=>be,getTypedArrayFromDataType:()=>Ct,getVertexFormatFromAttribute:()=>_t,log:()=>f,luma:()=>mt});var ae=globalThis,kt=globalThis.document||{},ue=globalThis.process||{},Gt=globalThis.console,Pr=globalThis.navigator||{};function Je(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=r||e;return Boolean(t&&t.indexOf("Electron")>=0)}function y(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Je()}var _e="4.0.7";function U(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var E=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=U(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(U()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var L=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:n}=e,s=this.stats[t];return s||(e instanceof E?s=e:s=new E(t,n),this.stats[t]=s),s}};var Pe=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new L({id:e})),this.stats.get(e)}},ce=new Pe;function Vt(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var fe=class{constructor(e,t,n="sessionStorage"){this.storage=Vt(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}};function Qe(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function et(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var le;(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(le||(le={}));var Ot=10;function tt(r){return typeof r!="string"?r:(r=r.toUpperCase(),le[r]||le.WHITE)}function rt(r,e,t){return!y&&typeof r=="string"&&(e&&(r=`\x1B[${tt(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${tt(t)+Ot}m${r}\x1B[49m`)),r}function nt(r,e=["constructor"]){let t=Object.getPrototypeOf(r),n=Object.getOwnPropertyNames(t),s=r;for(let o of n){let i=s[o];typeof i=="function"&&(e.find(c=>o===c)||(s[o]=i.bind(r)))}}function H(r,e){if(!r)throw new Error(e||"Assertion failed")}function C(){let r;if(y()&&ae.performance)r=ae?.performance?.now?.();else if("hrtime"in ue){let e=ue?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var M={debug:y()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},jt={enabled:!0,level:0};function B(){}var st={},ot={once:!0},S=class{constructor({id:e}={id:""}){this.VERSION=_e,this._startTs=C(),this._deltaTs=C(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new fe(`__probe-${this.id}__`,jt),this.timeStamp(`${this.id} started`),nt(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((C()-this._startTs).toPrecision(10))}getDelta(){return Number((C()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,M.warn,arguments,ot)}error(e){return this._getLogFunction(0,e,M.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,M.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,M.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,M.debug||M.info,arguments,ot)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||B,n&&[n],{tag:Xt(t)}):B}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||B)}group(e,t,n={collapsed:!1}){let s=it({logLevel:e,message:t,opts:n}),{collapsed:o}=n;return s.method=(o?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||B)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=at(e)}_getLogFunction(e,t,n,s,o){if(this._shouldLog(e)){o=it({logLevel:e,message:t,args:s,opts:o}),n=n||o.method,H(n),o.total=this.getTotal(),o.delta=this.getDelta(),this._deltaTs=C();let i=o.tag||o.message;if(o.once&&i)if(!st[i])st[i]=C();else return B;return t=Yt(this.id,o.message,o),n.bind(console,t,...o.args)}return B}};S.VERSION=_e;function at(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return H(Number.isFinite(e)&&e>=0),e}function it(r){let{logLevel:e,message:t}=r;r.logLevel=at(e);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let s=typeof r.message;return H(s==="string"||s==="object"),Object.assign(r,{args:n},r.opts)}function Yt(r,e,t){if(typeof e=="string"){let n=t.time?et(Qe(t.total)):"";e=t.time?`${r}: ${n} ${e}`:`${r}: ${e}`,e=rt(e,t.color,t.background)}return e}function Xt(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}globalThis.probe={};var ln=new S({id:"@probe.gl/log"});var f=new S({id:"luma.gl"});var Le={};function v(r="id"){Le[r]=Le[r]||1;let e=Le[r]++;return`${r}-${e}`}var u=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,t,n){if(!e)throw new Error("no device");this._device=e,this.props=Zt(t,n);let s=this.props.id!=="undefined"?this.props.id:v(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}};a(u,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Zt(r,e){let t={...e};for(let n in r)r[n]!==void 0&&(t[n]=r[n]);return t}var z=class extends u{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let n={...t};(t.usage||0)&z.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array&&(n.indexType="uint16")),delete n.data,super(e,n,z.defaultProps),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}readSyncWebGL(e,t){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(e,t,n){let s=ArrayBuffer.isView(e)?e.buffer:e,o=Math.min(e?e.byteLength:n,z.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(o):t===0&&n===s.byteLength?this.debugData=s.slice(0,o):this.debugData=s.slice(t,t+o)}},m=z;a(m,"defaultProps",{...u.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),a(m,"MAP_READ",1),a(m,"MAP_WRITE",2),a(m,"COPY_SRC",4),a(m,"COPY_DST",8),a(m,"INDEX",16),a(m,"VERTEX",32),a(m,"UNIFORM",64),a(m,"STORAGE",128),a(m,"INDIRECT",256),a(m,"QUERY_RESOLVE",512),a(m,"DEBUG_DATA_MAX_LENGTH",32);function de(r){let e=ut[r],t=qt(e),n=r.includes("norm"),s=!n&&!r.startsWith("float"),o=r.startsWith("s");return{dataType:ut[r],byteLength:t,integer:s,signed:o,normalized:n}}function qt(r){return Kt[r]}var ut={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Kt={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var p="texture-compression-bc",d="texture-compression-astc",w="texture-compression-etc2",Jt="texture-compression-etc1-webgl",me="texture-compression-pvrtc-webgl",Me="texture-compression-atc-webgl",he="float32-renderable-webgl",Be="float16-renderable-webgl",Qt="rgb9e5ufloat-renderable-webgl",Ie="snorm8-renderable-webgl",k="norm16-renderable-webgl",Re="snorm16-renderable-webgl",pe="float32-filterable",ct="float16-filterable-webgl";function I(r){let e=lt[r];if(!e)throw new Error(`Unsupported texture format ${r}`);return e}function ft(){return lt}var lt={r8unorm:{},r8snorm:{render:Ie},r8uint:{},r8sint:{},rg8unorm:{},rg8snorm:{render:Ie},rg8uint:{},rg8sint:{},r16uint:{},r16sint:{},r16float:{render:Be,filter:"float16-filterable-webgl"},"r16unorm-webgl":{f:k},"r16snorm-webgl":{f:Re},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},"rgb8unorm-webgl":{},"rgb8snorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},rgba8snorm:{render:Ie},rgba8uint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{},rg16sint:{},rg16float:{render:Be,filter:ct},"rg16unorm-webgl":{render:k},"rg16snorm-webgl":{render:Re},r32uint:{},r32sint:{},r32float:{render:he,filter:pe},rgb9e5ufloat:{channels:"rgb",packed:!0,render:Qt},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:he},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},"rgb10a2uint-webgl":{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,wgpu:!1},"rgb16unorm-webgl":{f:k},"rgb16snorm-webgl":{f:k},rg32uint:{},rg32sint:{},rg32float:{render:!1,filter:pe},rgba16uint:{},rgba16sint:{},rgba16float:{render:Be,filter:ct},"rgba16unorm-webgl":{render:k},"rgba16snorm-webgl":{render:Re},"rgb32float-webgl":{render:he,filter:pe},rgba32uint:{},rgba32sint:{},rgba32float:{render:he,filter:pe},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0},"bc1-rgb-unorm-webgl":{f:p},"bc1-rgb-unorm-srgb-webgl":{f:p},"bc1-rgba-unorm":{f:p},"bc1-rgba-unorm-srgb":{f:p},"bc2-rgba-unorm":{f:p},"bc2-rgba-unorm-srgb":{f:p},"bc3-rgba-unorm":{f:p},"bc3-rgba-unorm-srgb":{f:p},"bc4-r-unorm":{f:p},"bc4-r-snorm":{f:p},"bc5-rg-unorm":{f:p},"bc5-rg-snorm":{f:p},"bc6h-rgb-ufloat":{f:p},"bc6h-rgb-float":{f:p},"bc7-rgba-unorm":{f:p},"bc7-rgba-unorm-srgb":{f:p},"etc2-rgb8unorm":{f:w},"etc2-rgb8unorm-srgb":{f:w},"etc2-rgb8a1unorm":{f:w},"etc2-rgb8a1unorm-srgb":{f:w},"etc2-rgba8unorm":{f:w},"etc2-rgba8unorm-srgb":{f:w},"eac-r11unorm":{f:w},"eac-r11snorm":{f:w},"eac-rg11unorm":{f:w},"eac-rg11snorm":{f:w},"astc-4x4-unorm":{f:d},"astc-4x4-unorm-srgb":{f:d},"astc-5x4-unorm":{f:d},"astc-5x4-unorm-srgb":{f:d},"astc-5x5-unorm":{f:d},"astc-5x5-unorm-srgb":{f:d},"astc-6x5-unorm":{f:d},"astc-6x5-unorm-srgb":{f:d},"astc-6x6-unorm":{f:d},"astc-6x6-unorm-srgb":{f:d},"astc-8x5-unorm":{f:d},"astc-8x5-unorm-srgb":{f:d},"astc-8x6-unorm":{f:d},"astc-8x6-unorm-srgb":{f:d},"astc-8x8-unorm":{f:d},"astc-8x8-unorm-srgb":{f:d},"astc-10x5-unorm":{f:d},"astc-10x5-unorm-srgb":{f:d},"astc-10x6-unorm":{f:d},"astc-10x6-unorm-srgb":{f:d},"astc-10x8-unorm":{f:d},"astc-10x8-unorm-srgb":{f:d},"astc-10x10-unorm":{f:d},"astc-10x10-unorm-srgb":{f:d},"astc-12x10-unorm":{f:d},"astc-12x10-unorm-srgb":{f:d},"astc-12x12-unorm":{f:d},"astc-12x12-unorm-srgb":{f:d},"pvrtc-rgb4unorm-webgl":{f:me},"pvrtc-rgba4unorm-webgl":{f:me},"pvrtc-rbg2unorm-webgl":{f:me},"pvrtc-rgba2unorm-webgl":{f:me},"etc1-rbg-unorm-webgl":{f:Jt},"atc-rgb-unorm-webgl":{f:Me},"atc-rgba-unorm-webgl":{f:Me},"atc-rgbai-unorm-webgl":{f:Me}};var er=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],tr=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;function Fe(r){return er.some(e=>r.startsWith(e))}function ge(r){let e=rr(r);if(Fe(r)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;let n=nr(r);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}let t=tr.exec(r);if(t){let[,n,s,o,i,c]=t,l=`${o}${s}`,b=de(l),g=b.byteLength*8,x=n.length,Mt=[g,x>=2?g:0,x>=3?g:0,x>=4?g:0];e={format:r,attachment:e.attachment,dataType:b.dataType,components:x,channels:n,integer:b.integer,signed:b.signed,normalized:b.normalized,bitsPerChannel:Mt,bytesPerPixel:b.byteLength*n.length,packed:e.packed,srgb:e.srgb},c==="-webgl"&&(e.webgl=!0),i==="-srgb"&&(e.srgb=!0)}return r.endsWith("-webgl")&&(e.webgl=!0),r.endsWith("-srgb")&&(e.srgb=!0),e}function rr(r){let e=I(r),t=e.bytesPerPixel||1,n=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:r,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:n,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function nr(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,n,s]=t;return{blockWidth:Number(n),blockHeight:Number(s)}}return null}function be(r){let e=I(r),t={format:r,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},n=ge(r),s=r.startsWith("depth")||r.startsWith("stencil"),o=n?.signed,i=n?.integer,c=n?.webgl;return t.render&&=!o,t.filter&&=!s&&!o&&!i&&!c,t}var ye=class{},xe=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},De=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...De.defaultProps,...e},this.id=this.props.id||v(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=ce;timestamp=0;_lumaData={};getTextureFormatCapabilities(e){let t=be(e),n=i=>(typeof i=="string"?this.features.has(i):i)??!0,s=n(t.create),o={format:e,create:s,render:s&&n(t.render),filter:s&&n(t.filter),blend:s&&n(t.blend),store:s&&n(t.store)};return this._getDeviceSpecificTextureFormatCapabilities(o)}isTextureFormatSupported(e,t){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Fe(e)}loseDevice(){return!1}reportError(e){this.props.onError(e)}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createCommandEncoder(e={}){throw new Error("not implemented")}incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};return(e.usage||0)&m.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":f.warn("indices buffer content must be of integer type")()),t}},_=De;a(_,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,onError:e=>f.error(e.message)(),_requestMaxLimits:!0,_factoryDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_resourceDefaults:{},webgl:{},debug:f.get("debug")||void 0,debugShaders:f.get("debug-shaders")||void 0,debugFramebuffers:Boolean(f.get("debug-framebuffers")),debugWebGL:Boolean(f.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_handle:void 0});var sr=y()&&typeof document<"u",or=()=>sr&&document.readyState==="complete",ir="set luma.log.level=1 (or higher) to trace rendering",dt="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",R=class{stats=ce;log=f;VERSION="9.1.0";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw f.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),f.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");f.error("This version of luma.gl has already been initialized")()}f.log(1,`${this.VERSION} - ${ir}`)(),globalThis.luma=this}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this.getAdapterMap(e);return Array.from(t).map(([,n])=>n).filter(n=>n.isSupported?.()).map(n=>n.type)}getBestAvailableAdapter(e=[]){let t=this.getAdapterMap(e);return t.get("webgpu")?.isSupported?.()?"webgpu":t.get("webgl")?.isSupported?.()?"webgl":null}setDefaultDeviceProps(e){Object.assign(R.defaultProps,e)}async createDevice(e={}){e={...R.defaultProps,...e},e.waitForPageLoad&&await R.pageLoaded;let t=this.getAdapterMap(e.adapters),n=e.type||"";n==="best-available"&&(n=this.getBestAvailableAdapter(e.adapters)||n);let i=await(this.getAdapterMap(e.adapters)||t).get(n)?.create?.(e);if(i)return i;throw new Error(dt)}async attachDevice(e){let t=this.getAdapterMap(e.adapters),n="";e.handle instanceof WebGL2RenderingContext&&(n="webgl"),e.createCanvasContext&&await R.pageLoaded,e.handle===null&&(n="unknown");let o=await t.get(n)?.attach?.(null);if(o)return o;throw new Error(dt)}enforceWebGL2(e=!0,t=[]){let s=this.getAdapterMap(t).get("webgl");s||f.warn("enforceWebGL2: webgl adapter not found")(),s?.enforceWebGL2?.(e)}getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let n of e)t.set(n.type,n);return t}registerDevices(e){f.warn("luma.registerDevices() is deprecated, use luma.registerAdapters() instead");for(let t of e){let n=t.adapter;n&&this.preregisteredAdapters.set(n.type,n)}}},G=R;a(G,"defaultProps",{..._.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0}),a(G,"pageLoaded",ar().then(()=>{f.probe(2,"DOM is loaded")()}));var mt=new G;function ar(){return or()||typeof window>"u"?Promise.resolve():new Promise(r=>{window.addEventListener("load",()=>r())})}var we=class{};var $e=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){if(this.props={...$e.defaultProps,...e},e=this.props,!y()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=cr(e.canvas):this.canvas=e.canvas;else{let t=fr(e),n=ur(e?.container||null);n.insertBefore(t,n.firstChild),this.canvas=t,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(t=>{for(let n of t)n.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),t=this.canvas;return t.parentElement?[t.clientWidth*e,t.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,t]=this.getPixelSize();return e/t}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),t=this._canvasSizeInfo.clientWidth||this.htmlCanvas?.clientWidth;return t?e/t:1}catch{return 1}}cssToDevicePixels(e,t=!0){let n=this.cssToDeviceRatio(),[s,o]=this.getDrawingBufferSize();return lr(e,n,s,o,t)}setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let n="width"in t?t.width:this.htmlCanvas.clientWidth,s="height"in t?t.height:this.htmlCanvas.clientHeight;(!n||!s)&&(f.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,n=this.htmlCanvas.width||1,s=this.htmlCanvas.height||1);let o=this._canvasSizeInfo;if(o.clientWidth!==n||o.clientHeight!==s||o.devicePixelRatio!==e){let i=e,c=Math.floor(n*i),l=Math.floor(s*i);if(this.htmlCanvas.width=c,this.htmlCanvas.height=l,this.device.gl){let[g,x]=this.getDrawingBufferSize();(g!==c||x!==l)&&(i=Math.min(g/n,x/s),this.htmlCanvas.width=Math.floor(n*i),this.htmlCanvas.height=Math.floor(s*i),f.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=n,this._canvasSizeInfo.clientHeight=s,this._canvasSizeInfo.devicePixelRatio=e}}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}},W=$e;a(W,"defaultProps",{canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb"});function ur(r){if(typeof r=="string"){let e=document.getElementById(r);if(!e)throw new Error(`${r} is not an HTML element`);return e}else if(r)return r;return document.body}function cr(r){let e=document.getElementById(r);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function fr(r){let{width:e,height:t}=r,n=document.createElement("canvas");return n.id=v("lumagl-auto-created-canvas"),n.width=e||1,n.height=t||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(t)?`${t}px`:"100%",n}function lr(r,e,t,n,s){let o=r,i=ht(o[0],e,t),c=pt(o[1],e,n,s),l=ht(o[0]+1,e,t),b=l===t-1?l:l-1;l=pt(o[1]+1,e,n,s);let g;return s?(l=l===0?l:l+1,g=c,c=l):g=l===n-1?l:l-1,{x:i,y:c,width:Math.max(b-i+1,1),height:Math.max(g-c+1,1)}}function ht(r,e,t){return Math.min(Math.round(r*e),t-1)}function pt(r,e,t,n){return n?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var T=class extends u{get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}dimension;format;width;height;depth;mipLevels;updateTimestamp;constructor(e,t){if(t=T.normalizeProps(e,t),super(e,t,T.defaultProps),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.props.width===void 0||this.props.height===void 0){let n=T.getTextureDataSize(this.props.data);this.width=n?.width||1,this.height=n?.height||1}this.props.mipmaps&&this.props.mipLevels===void 0&&(this.props.mipLevels="pyramid"),this.mipLevels=this.props.mipLevels==="pyramid"?T.getMipLevelCount(this.width,this.height):this.props.mipLevels||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}static isExternalImage(e){return typeof ImageData<"u"&&e instanceof ImageData||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof VideoFrame<"u"&&e instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}static getExternalImageSize(e){if(typeof ImageData<"u"&&e instanceof ImageData||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if(typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if(typeof VideoFrame<"u"&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw new Error("Unknown image type")}static isTextureLevelData(e){let t=e?.data;return ArrayBuffer.isView(t)}static getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return T.getTextureDataSize(e[0]);if(T.isExternalImage(e))return T.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){let n=Object.values(e)[0];return{width:n.width,height:n.height}}throw new Error("texture size deduction failed")}static normalizeTextureData(e,t){let n;return ArrayBuffer.isView(e)?n=[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?n=e:n=[e],n}static getMipLevelCount(e,t){return Math.floor(Math.log2(Math.max(e,t)))+1}static getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}static normalizeProps(e,t){let n={...t},s=e?.props?._resourceDefaults?.texture||{};Object.assign(n,s);let{width:o,height:i}=n;return typeof o=="number"&&(n.width=Math.max(1,Math.ceil(o))),typeof i=="number"&&(n.height=Math.max(1,Math.ceil(i))),n}},h=T;a(h,"COPY_SRC",1),a(h,"COPY_DST",2),a(h,"TEXTURE",4),a(h,"STORAGE",8),a(h,"RENDER_ATTACHMENT",16),a(h,"CubeFaces",["+X","-X","+Y","-Y","+Z","-Z"]),a(h,"defaultProps",{...u.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!1,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,sampler:{},view:void 0,flipY:void 0}),a(h,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1});var Ne=class extends u{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,Ne.defaultProps)}},V=Ne;a(V,"defaultProps",{...u.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var Ue=class extends u{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,Ue.defaultProps)}},O=Ue;a(O,"defaultProps",{...u.defaultProps,source:void 0,colorSpace:"srgb"});function bt(r,e,t){let n="",s=e.split(/\r?\n/),o=r.slice().sort((i,c)=>i.lineNum-c.lineNum);switch(t?.showSourceCode||"no"){case"all":let i=0;for(let c=1;c<=s.length;c++)for(n+=yt(s[c-1],c,t);o.length>i&&o[i].lineNum===c;){let l=o[i++];n+=gt(l,s,l.lineNum,{...t,inlineSource:!1})}return n;case"issues":case"no":for(let c of r)n+=gt(c,s,c.lineNum,{inlineSource:t?.showSourceCode!=="no"});return n}}function gt(r,e,t,n){if(n?.inlineSource){let o=dr(e,t),i=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^
|
|
8
8
|
`:"";return`
|
|
9
|
-
${
|
|
9
|
+
${o}${i}${r.type.toUpperCase()}: ${r.message}
|
|
10
10
|
|
|
11
|
-
`}let
|
|
12
|
-
`}`}function mr(r,e){let t="";for(let n=r.length;n<e;++n)t+=" ";return t+r}function
|
|
11
|
+
`}let s=r.type==="error"?"red":"#8B4000";return n?.html?`<div class='luma-compiler-log-error' style="color:${s};"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function dr(r,e,t){let n="";for(let s=e-2;s<=e;s++){let o=r[s-1];o!==void 0&&(n+=yt(o,e,t))}return n}function yt(r,e,t){let n=t?.html?hr(r):r;return`${mr(String(e),4)}: ${n}${t?.html?"<br/>":`
|
|
12
|
+
`}`}function mr(r,e){let t="";for(let n=r.length;n<e;++n)t+=" ";return t+r}function hr(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var He=class extends u{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:pr(t),...t},He.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let t=await this.getCompilationInfo();e==="warnings"&&t?.length===0||this._displayShaderLog(t)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let t=xt(this.source),n=`${this.stage} ${t}`,s=bt(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource();o&&(s+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${o}</pre></code>`);let i=document.createElement("Button");i.innerHTML=`
|
|
13
13
|
<h1>Shader Compilation Error in ${n}</h1><br /><br />
|
|
14
14
|
<code style="user-select:text;"><pre>
|
|
15
|
-
${
|
|
16
|
-
</pre></code>`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),o.onclick=()=>{let f=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(f)}}},j=Ne;a(j,"defaultProps",{...c.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});function gr(r){return xt(r.source)||r.id||v(`unnamed ${r.stage}-shader`)}function xt(r,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return n?n[1]:e}var Te=class extends c{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=Te.normalizeProps(e,t),super(e,t,Te.defaultProps)}static normalizeProps(e,t){let n=e?.props?._resourceDefaults?.sampler||{};return{...t,...n}}},Y=Te;a(Y,"defaultProps",{...c.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var Ue=class extends c{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,Ue.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(i=>i.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){let[n,i]=Array.isArray(e)?e:[e.width,e.height];t=t||i!==this.height||n!==this.width,this.width=n,this.height=i}t&&(l.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,n)=>{if(typeof t=="string"){let i=this.createColorTexture(t,n);return this.attachResource(i),i.view}return t instanceof m?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof m?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:m.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:m.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,mipmaps:!1})}resizeAttachments(e,t){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let i=this.colorAttachments[n].texture.clone({width:e,height:t});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=i.view,this.attachResource(i.view)}if(this.depthStencilAttachment){let n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}},X=Ue;a(X,"defaultProps",{...c.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var ke=class extends c{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,t){super(e,t,ke.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(e){throw new Error("Use uniform blocks")}},Z=ke;a(Z,"defaultProps",{...c.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});var _=class extends c{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=_.normalizeProps(e,t),super(e,t,_.defaultProps)}static normalizeProps(e,t){return{...e.props._resourceDefaults?.renderPass,...t}}},A=_;a(A,"defaultClearColor",[0,0,0,1]),a(A,"defaultClearDepth",1),a(A,"defaultClearStencil",0),a(A,"defaultProps",{...c.defaultProps,framebuffer:null,parameters:void 0,clearColor:_.defaultClearColor,clearColors:void 0,clearDepth:_.defaultClearDepth,clearStencil:_.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var We=class extends c{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,We.defaultProps),this.shaderLayout=t.shaderLayout}},q=We;a(q,"defaultProps",{...c.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var Ge=class extends c{get[Symbol.toStringTag](){return"ComputePass"}constructor(e,t){super(e,t,Ge.defaultProps)}},K=Ge;a(K,"defaultProps",{...c.defaultProps,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Ve=class extends c{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Ve.defaultProps)}},J=Ve;a(J,"defaultProps",{...c.defaultProps,measureExecutionTime:void 0});var Oe=class extends c{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,Oe.defaultProps)}},Q=Oe;a(Q,"defaultProps",{...c.defaultProps});function Se(r){let[e,t]=yr[r],n=e==="i32"||e==="u32",i=e!=="u32",s=xr[e]*t,o=br(e,t);return{dataType:e,components:t,defaultVertexFormat:o,byteLength:s,integer:n,signed:i}}function br(r,e){let t;switch(r){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?t:`${t}x${e}`}var yr={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},xr={f32:4,f16:2,i32:4,u32:4};function ee(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,n]=r.split("x"),i=t,s=n?parseInt(n):1,o=de(i),u={type:i,components:s,byteLength:o.byteLength*s,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(u.webglOnly=!0),u}function je(r,e){let t={};for(let n of r.attributes){let i=wr(r,e,n.name);i&&(t[n.name]=i)}return t}function wt(r,e,t=16){let n=je(r,e),i=new Array(t).fill(null);for(let s of Object.values(n))i[s.location]=s;return i}function wr(r,e,t){let n=Tr(r,t),i=Sr(e,t);if(!n)return null;let s=Se(n.type),o=i?.vertexFormat||s.defaultVertexFormat,u=ee(o);return{attributeName:i?.attributeName||n.name,bufferName:i?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:s.dataType,shaderComponents:s.components,vertexFormat:o,bufferDataType:u.type,bufferComponents:u.components,normalized:u.normalized,integer:s.integer,stepMode:i?.stepMode||n.stepMode||"vertex",byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function Tr(r,e){let t=r.attributes.find(n=>n.name===e);return t||l.warn(`shader layout attribute "${e}" not present in shader`),t||null}function Sr(r,e){vr(r);let t=Ar(r,e);return t||(t=Er(r,e),t)?t:(l.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function vr(r){for(let e of r)(e.attributes&&e.format||!e.attributes&&!e.format)&&l.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Ar(r,e){for(let t of r)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function Er(r,e){for(let t of r){let n=t.byteStride;if(typeof t.byteStride!="number")for(let s of t.attributes||[]){let o=ee(s.format);n+=o.byteLength}let i=t.attributes?.find(s=>s.attribute===e);if(i)return{attributeName:i.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:n}}return null}var Ye=class extends c{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,Ye.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=wt(t.shaderLayout,t.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){throw new Error("constant attributes not supported")}},te=Ye;a(te,"defaultProps",{...c.defaultProps,shaderLayout:void 0,bufferLayout:[]});var Xe=class extends c{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Xe.defaultProps)}},re=Xe;a(re,"defaultProps",{...c.defaultProps,layout:void 0,buffers:{}});var Ze=class extends c{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Ze.defaultProps)}},ne=Ze;a(ne,"defaultProps",{...c.defaultProps,type:void 0,count:void 0});var Pr={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16}};function ve(r){return Pr[r]}function Tt(r,e){switch(e){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}var Ae;function qe(r){return(!Ae||Ae.byteLength<r)&&(Ae=new ArrayBuffer(r)),Ae}function St(r,e){let t=qe(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}function Cr(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function I(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":Cr(r)}var vt=1024,F=class{layout={};byteLength;constructor(e){let t=0;for(let[i,s]of Object.entries(e)){let o=ve(s),{type:u,components:f}=o;t=Tt(t,f);let b=t;t+=f,this.layout[i]={type:u,size:f,offset:b}}t+=(4-t%4)%4;let n=t*4;this.byteLength=Math.max(n,vt)}getData(e){let t=Math.max(this.byteLength,vt),n=qe(t),i={i32:new Int32Array(n),u32:new Uint32Array(n),f32:new Float32Array(n),f16:new Uint16Array(n)};for(let[s,o]of Object.entries(e)){let u=this.layout[s];if(!u){l.warn(`Supplied uniform value ${s} not present in uniform block layout`)();continue}let{type:f,size:b,offset:g}=u,x=i[f];if(b===1){if(typeof o!="number"&&typeof o!="boolean"){l.warn(`Supplied value for single component uniform ${s} is not a number: ${o}`)();continue}x[g]=Number(o)}else{if(!I(o)){l.warn(`Supplied value for multi component / array uniform ${s} is not a numeric array: ${o}`)();continue}x.set(o,g)}}return new Uint8Array(n)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}};function At(r,e,t=16){if(r!==e)return!1;let n=r,i=e;if(!I(n))return!1;if(I(i)&&n.length===i.length){for(let s=0;s<n.length;++s)if(i[s]!==n[s])return!1}return!0}function Et(r){return I(r)?r.slice():r}var $=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(i=>i.type==="uniform"&&i.name===e?.name);if(!t)throw new Error(e?.name);let n=t;for(let i of n.uniforms||[])this.bindingLayout[i.name]=i}}setUniforms(e){for(let[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){At(this.uniforms[e],t)||(this.uniforms[e]=Et(t),this.modifiedUniforms[e]=!0,this.modified=!0)}};var Ee=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[t,n]of Object.entries(e)){let i=t,s=new F(n.uniformTypes||{});this.uniformBufferLayouts.set(i,s);let o=new $({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(i,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,n]of Object.entries(e))this.uniformBlocks.get(t)?.setUniforms(n);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e)?.byteLength||0}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.uniformBufferLayouts.get(e)?.getData(t)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);let i=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:h.UNIFORM|h.COPY_DST,byteLength:i}),o=this.getUniformBufferData(t);return s.write(o),s}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){let n=this.getUniformBufferByteLength(t),i=e.createBuffer({usage:h.UNIFORM|h.COPY_DST,byteLength:n});this.uniformBuffers.set(t,i)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(t);e||=n}return e&&l.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),n=this.uniformBuffers.get(e),i=!1;if(n&&t?.needsRedraw){i||=t.needsRedraw;let s=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(s);let o=this.uniformBlocks.get(e)?.getAllUniforms();l.log(4,`Writing to uniform buffer ${String(e)}`,s,o)()}return i}};function Ke(r){let e=ArrayBuffer.isView(r)?r.constructor:r;switch(e){case Float32Array:return"float32";case Uint16Array:return"uint16";case Uint32Array:return"uint32";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int8Array:return"sint8";case Int16Array:return"sint16";case Int32Array:return"sint32";default:throw new Error(e.constructor.name)}}function Pt(r){switch(r){case"float32":return Float32Array;case"uint32":return Uint32Array;case"sint32":return Int32Array;case"uint16":case"unorm16":return Uint16Array;case"sint16":case"snorm16":return Int16Array;case"uint8":case"unorm8":return Uint8Array;case"sint8":case"snorm8":return Int8Array;default:throw new Error(r)}}function Ct(r,e,t){if(!e||e>4)throw new Error(`size ${e}`);let n=e,i=Ke(r);if(i==="uint8"&&t&&n===1)return"unorm8-webgl";if(i==="uint8"&&t&&n===3)return"unorm8x3-webgl";if(i==="uint8"||i==="sint8"){if(n===1||n===3)throw new Error(`size: ${e}`);return t&&(i=i.replace("int","norm")),`${i}x${n}`}if(i==="uint16"||i==="sint16"){if(n===1||n===3)throw new Error(`size: ${e}`);return t&&(i=i.replace("int","norm")),`${i}x${n}`}return n===1?i:`${i}x${n}`}var Pe=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(t=>t.attribute):[e.name]}mergeBufferLayouts(e,t){let n=[...e];for(let i of t){let s=n.findIndex(o=>o.name===i.name);s<0?n.push(i):n[s]=i}return n}};oe(ie,Nt(Lt(),1));return Ut(ie);})();
|
|
15
|
+
${s}
|
|
16
|
+
</pre></code>`,i.style.top="10px",i.style.left="10px",i.style.position="absolute",i.style.zIndex="9999",i.style.width="100%",i.style.textAlign="left",document.body.appendChild(i),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),i.onclick=()=>{let l=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(l)}}},j=He;a(j,"defaultProps",{...u.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});function pr(r){return xt(r.source)||r.id||v(`unnamed ${r.stage}-shader`)}function xt(r,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return n?n[1]:e}var Te=class extends u{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=Te.normalizeProps(e,t),super(e,t,Te.defaultProps)}static normalizeProps(e,t){let n=e?.props?._resourceDefaults?.sampler||{};return{...t,...n}}},Y=Te;a(Y,"defaultProps",{...u.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var ze=class extends u{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,ze.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(s=>s.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){let[n,s]=Array.isArray(e)?e:[e.width,e.height];t=t||s!==this.height||n!==this.width,this.width=n,this.height=s}t&&(f.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,n)=>{if(typeof t=="string"){let s=this.createColorTexture(t,n);return this.attachResource(s),s.view}return t instanceof h?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof h?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:h.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:h.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,mipmaps:!1})}resizeAttachments(e,t){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let s=this.colorAttachments[n].texture.clone({width:e,height:t});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=s.view,this.attachResource(s.view)}if(this.depthStencilAttachment){let n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}},X=ze;a(X,"defaultProps",{...u.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var ke=class extends u{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,t){super(e,t,ke.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(e){throw new Error("Use uniform blocks")}},Z=ke;a(Z,"defaultProps",{...u.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},bindings:{},uniforms:{}});var P=class extends u{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=P.normalizeProps(e,t),super(e,t,P.defaultProps)}static normalizeProps(e,t){return{...e.props._resourceDefaults?.renderPass,...t}}},A=P;a(A,"defaultClearColor",[0,0,0,1]),a(A,"defaultClearDepth",1),a(A,"defaultClearStencil",0),a(A,"defaultProps",{...u.defaultProps,framebuffer:null,parameters:void 0,clearColor:P.defaultClearColor,clearColors:void 0,clearDepth:P.defaultClearDepth,clearStencil:P.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Ge=class extends u{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,Ge.defaultProps),this.shaderLayout=t.shaderLayout}},q=Ge;a(q,"defaultProps",{...u.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var We=class extends u{get[Symbol.toStringTag](){return"ComputePass"}constructor(e,t){super(e,t,We.defaultProps)}},K=We;a(K,"defaultProps",{...u.defaultProps,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Ve=class extends u{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Ve.defaultProps)}},J=Ve;a(J,"defaultProps",{...u.defaultProps,measureExecutionTime:void 0});var Oe=class extends u{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,Oe.defaultProps)}},Q=Oe;a(Q,"defaultProps",{...u.defaultProps});function Se(r){let[e,t]=br[r],n=e==="i32"||e==="u32",s=e!=="u32",o=yr[e]*t,i=gr(e,t);return{dataType:e,components:t,defaultVertexFormat:i,byteLength:o,integer:n,signed:s}}function gr(r,e){let t;switch(r){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?t:`${t}x${e}`}var br={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},yr={f32:4,f16:2,i32:4,u32:4};function ee(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,n]=r.split("x"),s=t,o=n?parseInt(n):1,i=de(s),c={type:s,components:o,byteLength:i.byteLength*o,integer:i.integer,signed:i.signed,normalized:i.normalized};return e&&(c.webglOnly=!0),c}function je(r,e){let t={};for(let n of r.attributes){let s=xr(r,e,n.name);s&&(t[n.name]=s)}return t}function wt(r,e,t=16){let n=je(r,e),s=new Array(t).fill(null);for(let o of Object.values(n))s[o.location]=o;return s}function xr(r,e,t){let n=wr(r,t),s=Tr(e,t);if(!n)return null;let o=Se(n.type),i=s?.vertexFormat||o.defaultVertexFormat,c=ee(i);return{attributeName:s?.attributeName||n.name,bufferName:s?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:i,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:o.integer,stepMode:s?.stepMode||n.stepMode||"vertex",byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function wr(r,e){let t=r.attributes.find(n=>n.name===e);return t||f.warn(`shader layout attribute "${e}" not present in shader`),t||null}function Tr(r,e){Sr(r);let t=vr(r,e);return t||(t=Ar(r,e),t)?t:(f.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function Sr(r){for(let e of r)(e.attributes&&e.format||!e.attributes&&!e.format)&&f.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function vr(r,e){for(let t of r)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function Ar(r,e){for(let t of r){let n=t.byteStride;if(typeof t.byteStride!="number")for(let o of t.attributes||[]){let i=ee(o.format);n+=i.byteLength}let s=t.attributes?.find(o=>o.attribute===e);if(s)return{attributeName:s.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:n}}return null}var Ye=class extends u{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,Ye.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null);let{shaderLayout:n,bufferLayout:s}=t.renderPipeline||{};if(!n||!s)throw new Error("VertexArray");this.attributeInfos=wt(n,s,this.maxVertexAttributes)}setConstantWebGL(e,t){throw new Error("constant attributes not supported")}},te=Ye;a(te,"defaultProps",{...u.defaultProps,renderPipeline:null});var Xe=class extends u{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Xe.defaultProps)}},re=Xe;a(re,"defaultProps",{...u.defaultProps,layout:void 0,buffers:{}});var Ze=class extends u{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Ze.defaultProps)}},ne=Ze;a(ne,"defaultProps",{...u.defaultProps,type:void 0,count:void 0});var Er={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16}};function ve(r){return Er[r]}function Tt(r,e){switch(e){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}var Ae;function qe(r){return(!Ae||Ae.byteLength<r)&&(Ae=new ArrayBuffer(r)),Ae}function St(r,e){let t=qe(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}function Cr(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function F(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":Cr(r)}var vt=1024,D=class{layout={};byteLength;constructor(e){let t=0;for(let[s,o]of Object.entries(e)){let i=ve(o),{type:c,components:l}=i;t=Tt(t,l);let b=t;t+=l,this.layout[s]={type:c,size:l,offset:b}}t+=(4-t%4)%4;let n=t*4;this.byteLength=Math.max(n,vt)}getData(e){let t=Math.max(this.byteLength,vt),n=qe(t),s={i32:new Int32Array(n),u32:new Uint32Array(n),f32:new Float32Array(n),f16:new Uint16Array(n)};for(let[o,i]of Object.entries(e)){let c=this.layout[o];if(!c){f.warn(`Supplied uniform value ${o} not present in uniform block layout`)();continue}let{type:l,size:b,offset:g}=c,x=s[l];if(b===1){if(typeof i!="number"&&typeof i!="boolean"){f.warn(`Supplied value for single component uniform ${o} is not a number: ${i}`)();continue}x[g]=Number(i)}else{if(!F(i)){f.warn(`Supplied value for multi component / array uniform ${o} is not a numeric array: ${i}`)();continue}x.set(i,g)}}return new Uint8Array(n)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}};function At(r,e,t=16){if(r!==e)return!1;let n=r,s=e;if(!F(n))return!1;if(F(s)&&n.length===s.length){for(let o=0;o<n.length;++o)if(s[o]!==n[o])return!1}return!0}function Et(r){return F(r)?r.slice():r}var $=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(s=>s.type==="uniform"&&s.name===e?.name);if(!t)throw new Error(e?.name);let n=t;for(let s of n.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(let[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){At(this.uniforms[e],t)||(this.uniforms[e]=Et(t),this.modifiedUniforms[e]=!0,this.modified=!0)}};var Ee=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[t,n]of Object.entries(e)){let s=t,o=new D(n.uniformTypes||{});this.uniformBufferLayouts.set(s,o);let i=new $({name:t});i.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,i)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,n]of Object.entries(e))this.uniformBlocks.get(t)?.setUniforms(n);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e)?.byteLength||0}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.uniformBufferLayouts.get(e)?.getData(t)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);let s=this.getUniformBufferByteLength(t),o=e.createBuffer({usage:m.UNIFORM|m.COPY_DST,byteLength:s}),i=this.getUniformBufferData(t);return o.write(i),o}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){let n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:m.UNIFORM|m.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(t);e||=n}return e&&f.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),n=this.uniformBuffers.get(e),s=!1;if(n&&t?.needsRedraw){s||=t.needsRedraw;let o=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(o);let i=this.uniformBlocks.get(e)?.getAllUniforms();f.log(4,`Writing to uniform buffer ${String(e)}`,o,i)()}return s}};function Ke(r){let e=ArrayBuffer.isView(r)?r.constructor:r;switch(e){case Float32Array:return"float32";case Uint16Array:return"uint16";case Uint32Array:return"uint32";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int8Array:return"sint8";case Int16Array:return"sint16";case Int32Array:return"sint32";default:throw new Error(e.constructor.name)}}function Ct(r){switch(r){case"float32":return Float32Array;case"uint32":return Uint32Array;case"sint32":return Int32Array;case"uint16":case"unorm16":return Uint16Array;case"sint16":case"snorm16":return Int16Array;case"uint8":case"unorm8":return Uint8Array;case"sint8":case"snorm8":return Int8Array;default:throw new Error(r)}}function _t(r,e,t){if(!e||e>4)throw new Error(`size ${e}`);let n=e,s=Ke(r);if(s==="uint8"&&t&&n===1)return"unorm8-webgl";if(s==="uint8"&&t&&n===3)return"unorm8x3-webgl";if(s==="uint8"||s==="sint8"){if(n===1||n===3)throw new Error(`size: ${e}`);return t&&(s=s.replace("int","norm")),`${s}x${n}`}if(s==="uint16"||s==="sint16"){if(n===1||n===3)throw new Error(`size: ${e}`);return t&&(s=s.replace("int","norm")),`${s}x${n}`}return n===1?s:`${s}x${n}`}var Ce=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(t=>t.attribute):[e.name]}mergeBufferLayouts(e,t){let n=[...e];for(let s of t){let o=n.findIndex(i=>i.name===s.name);o<0?n.push(s):n[o]=s}return n}};ie(se,Ht(Lt(),1));return zt(se);})();
|
|
17
17
|
return __exports__;
|
|
18
18
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/effects",
|
|
3
|
-
"version": "9.1.0
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "Post-processing effects for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"@math.gl/types": "^4.1.0",
|
|
54
54
|
"wgsl_reflect": "^1.0.1"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e5cb5a93674bc7cc571c26dee4d2aef841fdff7f"
|
|
57
57
|
}
|