@luma.gl/effects 9.2.5 → 9.3.0-alpha.2
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 +382 -105
- package/dist/dist.min.js +6 -6
- package/package.json +4 -5
package/dist/dist.dev.js
CHANGED
|
@@ -64,6 +64,7 @@ var __exports__ = (() => {
|
|
|
64
64
|
DeviceFeatures: () => DeviceFeatures,
|
|
65
65
|
DeviceLimits: () => DeviceLimits,
|
|
66
66
|
ExternalTexture: () => ExternalTexture,
|
|
67
|
+
Fence: () => Fence,
|
|
67
68
|
Framebuffer: () => Framebuffer,
|
|
68
69
|
PipelineLayout: () => PipelineLayout,
|
|
69
70
|
QuerySet: () => QuerySet,
|
|
@@ -86,16 +87,20 @@ var __exports__ = (() => {
|
|
|
86
87
|
getAttributeShaderTypeInfo: () => getAttributeShaderTypeInfo,
|
|
87
88
|
getDataType: () => getDataType,
|
|
88
89
|
getDataTypeInfo: () => getDataTypeInfo,
|
|
90
|
+
getExternalImageSize: () => getExternalImageSize,
|
|
89
91
|
getNormalizedDataType: () => getNormalizedDataType,
|
|
90
92
|
getScratchArray: () => getScratchArray,
|
|
93
|
+
getTextureImageView: () => getTextureImageView,
|
|
91
94
|
getTypedArrayConstructor: () => getTypedArrayConstructor,
|
|
92
95
|
getVariableShaderTypeInfo: () => getVariableShaderTypeInfo,
|
|
93
96
|
getVertexFormatFromAttribute: () => getVertexFormatFromAttribute,
|
|
94
97
|
getVertexFormatInfo: () => getVertexFormatInfo,
|
|
98
|
+
isExternalImage: () => isExternalImage,
|
|
95
99
|
log: () => log,
|
|
96
100
|
luma: () => luma,
|
|
97
101
|
makeVertexFormat: () => makeVertexFormat,
|
|
98
102
|
readPixel: () => readPixel,
|
|
103
|
+
setTextureImageData: () => setTextureImageData,
|
|
99
104
|
textureFormatDecoder: () => textureFormatDecoder,
|
|
100
105
|
writePixel: () => writePixel
|
|
101
106
|
});
|
|
@@ -757,8 +762,11 @@ var __exports__ = (() => {
|
|
|
757
762
|
}
|
|
758
763
|
/** props.id, for debugging. */
|
|
759
764
|
id;
|
|
765
|
+
/** The props that this resource was created with */
|
|
760
766
|
props;
|
|
767
|
+
/** User data object, reserved for the application */
|
|
761
768
|
userData = {};
|
|
769
|
+
/** The device that this resource is associated with - TODO can we remove this dup? */
|
|
762
770
|
_device;
|
|
763
771
|
/** Whether this resource has been destroyed */
|
|
764
772
|
destroyed = false;
|
|
@@ -887,7 +895,7 @@ var __exports__ = (() => {
|
|
|
887
895
|
}
|
|
888
896
|
/** The usage with which this buffer was created */
|
|
889
897
|
usage;
|
|
890
|
-
/** For index buffers, whether indices are 16 or 32 bit */
|
|
898
|
+
/** For index buffers, whether indices are 8, 16 or 32 bit. Note: uint8 indices are automatically converted to uint16 for WebGPU compatibility */
|
|
891
899
|
indexType;
|
|
892
900
|
/** "Time" of last update, can be used to check if redraw is needed */
|
|
893
901
|
updateTimestamp;
|
|
@@ -898,6 +906,8 @@ var __exports__ = (() => {
|
|
|
898
906
|
deducedProps.indexType = "uint32";
|
|
899
907
|
} else if (props.data instanceof Uint16Array) {
|
|
900
908
|
deducedProps.indexType = "uint16";
|
|
909
|
+
} else if (props.data instanceof Uint8Array) {
|
|
910
|
+
deducedProps.indexType = "uint8";
|
|
901
911
|
}
|
|
902
912
|
}
|
|
903
913
|
delete deducedProps.data;
|
|
@@ -963,10 +973,11 @@ var __exports__ = (() => {
|
|
|
963
973
|
|
|
964
974
|
// ../core/src/shadertypes/data-types/decode-data-types.ts
|
|
965
975
|
function getDataTypeInfo(type) {
|
|
966
|
-
const [signedType, primitiveType, byteLength] = NORMALIZED_TYPE_MAP[type];
|
|
967
976
|
const normalized = type.includes("norm");
|
|
968
977
|
const integer = !normalized && !type.startsWith("float");
|
|
969
978
|
const signed = type.startsWith("s");
|
|
979
|
+
const typeInfo = NORMALIZED_TYPE_MAP[type];
|
|
980
|
+
const [signedType, primitiveType, byteLength] = typeInfo || ["uint8 ", "i32", 1];
|
|
970
981
|
return {
|
|
971
982
|
signedType,
|
|
972
983
|
primitiveType,
|
|
@@ -1282,6 +1293,9 @@ var __exports__ = (() => {
|
|
|
1282
1293
|
};
|
|
1283
1294
|
|
|
1284
1295
|
// ../core/src/shadertypes/textures/texture-format-decoder.ts
|
|
1296
|
+
var RGB_FORMAT_REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;
|
|
1297
|
+
var COLOR_FORMAT_PREFIXES = ["rgb", "rgba", "bgra"];
|
|
1298
|
+
var DEPTH_FORMAT_PREFIXES = ["depth", "stencil"];
|
|
1285
1299
|
var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
|
|
1286
1300
|
"bc1",
|
|
1287
1301
|
"bc2",
|
|
@@ -1297,49 +1311,73 @@ var __exports__ = (() => {
|
|
|
1297
1311
|
"astc",
|
|
1298
1312
|
"pvrtc"
|
|
1299
1313
|
];
|
|
1300
|
-
var RGB_FORMAT_REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;
|
|
1301
1314
|
var TextureFormatDecoder = class {
|
|
1302
|
-
/** Returns information about a texture format, e.g. attatchment type, components, byte length and flags (integer, signed, normalized) */
|
|
1303
|
-
getInfo(format) {
|
|
1304
|
-
return getTextureFormatInfo(format);
|
|
1305
|
-
}
|
|
1306
1315
|
/** Checks if a texture format is color */
|
|
1307
1316
|
isColor(format) {
|
|
1308
|
-
return
|
|
1317
|
+
return COLOR_FORMAT_PREFIXES.some((prefix) => format.startsWith(prefix));
|
|
1309
1318
|
}
|
|
1310
1319
|
/** Checks if a texture format is depth or stencil */
|
|
1311
1320
|
isDepthStencil(format) {
|
|
1312
|
-
return
|
|
1321
|
+
return DEPTH_FORMAT_PREFIXES.some((prefix) => format.startsWith(prefix));
|
|
1313
1322
|
}
|
|
1314
1323
|
/** Checks if a texture format is compressed */
|
|
1315
1324
|
isCompressed(format) {
|
|
1316
1325
|
return COMPRESSED_TEXTURE_FORMAT_PREFIXES.some((prefix) => format.startsWith(prefix));
|
|
1317
1326
|
}
|
|
1318
|
-
/**
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1327
|
+
/** Returns information about a texture format, e.g. attachment type, components, byte length and flags (integer, signed, normalized) */
|
|
1328
|
+
getInfo(format) {
|
|
1329
|
+
return getTextureFormatInfo(format);
|
|
1330
|
+
}
|
|
1331
|
+
/** "static" capabilities of a texture format. @note Needs to be adjusted against current device */
|
|
1322
1332
|
getCapabilities(format) {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
filter: info.filter ?? true,
|
|
1329
|
-
blend: info.blend ?? true,
|
|
1330
|
-
store: info.store ?? true
|
|
1331
|
-
};
|
|
1332
|
-
const formatInfo = getTextureFormatInfo(format);
|
|
1333
|
-
const isDepthStencil = format.startsWith("depth") || format.startsWith("stencil");
|
|
1334
|
-
const isSigned = formatInfo?.signed;
|
|
1335
|
-
const isInteger = formatInfo?.integer;
|
|
1336
|
-
const isWebGLSpecific = formatInfo?.webgl;
|
|
1337
|
-
formatCapabilities.render &&= !isSigned;
|
|
1338
|
-
formatCapabilities.filter &&= !isDepthStencil && !isSigned && !isInteger && !isWebGLSpecific;
|
|
1339
|
-
return formatCapabilities;
|
|
1333
|
+
return getTextureFormatCapabilities(format);
|
|
1334
|
+
}
|
|
1335
|
+
/** Computes the memory layout for a texture, in particular including row byte alignment */
|
|
1336
|
+
computeMemoryLayout(opts) {
|
|
1337
|
+
return computeTextureMemoryLayout(opts);
|
|
1340
1338
|
}
|
|
1341
1339
|
};
|
|
1342
1340
|
var textureFormatDecoder = new TextureFormatDecoder();
|
|
1341
|
+
function computeTextureMemoryLayout({
|
|
1342
|
+
format,
|
|
1343
|
+
width,
|
|
1344
|
+
height,
|
|
1345
|
+
depth,
|
|
1346
|
+
byteAlignment
|
|
1347
|
+
}) {
|
|
1348
|
+
const { bytesPerPixel } = textureFormatDecoder.getInfo(format);
|
|
1349
|
+
const unpaddedBytesPerRow = width * bytesPerPixel;
|
|
1350
|
+
const bytesPerRow = Math.ceil(unpaddedBytesPerRow / byteAlignment) * byteAlignment;
|
|
1351
|
+
const rowsPerImage = height;
|
|
1352
|
+
const byteLength = bytesPerRow * rowsPerImage * depth;
|
|
1353
|
+
return {
|
|
1354
|
+
bytesPerPixel,
|
|
1355
|
+
bytesPerRow,
|
|
1356
|
+
rowsPerImage,
|
|
1357
|
+
depthOrArrayLayers: depth,
|
|
1358
|
+
bytesPerImage: bytesPerRow * rowsPerImage,
|
|
1359
|
+
byteLength
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
function getTextureFormatCapabilities(format) {
|
|
1363
|
+
const info = getTextureFormatDefinition(format);
|
|
1364
|
+
const formatCapabilities = {
|
|
1365
|
+
format,
|
|
1366
|
+
create: info.f ?? true,
|
|
1367
|
+
render: info.render ?? true,
|
|
1368
|
+
filter: info.filter ?? true,
|
|
1369
|
+
blend: info.blend ?? true,
|
|
1370
|
+
store: info.store ?? true
|
|
1371
|
+
};
|
|
1372
|
+
const formatInfo = getTextureFormatInfo(format);
|
|
1373
|
+
const isDepthStencil = format.startsWith("depth") || format.startsWith("stencil");
|
|
1374
|
+
const isSigned = formatInfo?.signed;
|
|
1375
|
+
const isInteger = formatInfo?.integer;
|
|
1376
|
+
const isWebGLSpecific = formatInfo?.webgl;
|
|
1377
|
+
formatCapabilities.render &&= !isSigned;
|
|
1378
|
+
formatCapabilities.filter &&= !isDepthStencil && !isSigned && !isInteger && !isWebGLSpecific;
|
|
1379
|
+
return formatCapabilities;
|
|
1380
|
+
}
|
|
1343
1381
|
function getTextureFormatInfo(format) {
|
|
1344
1382
|
let formatInfo = getTextureFormatInfoUsingTable(format);
|
|
1345
1383
|
if (textureFormatDecoder.isCompressed(format)) {
|
|
@@ -1493,7 +1531,7 @@ var __exports__ = (() => {
|
|
|
1493
1531
|
/** True if this device has been reused during device creation (app has multiple references) */
|
|
1494
1532
|
_reused = false;
|
|
1495
1533
|
/** Used by other luma.gl modules to store data on the device */
|
|
1496
|
-
|
|
1534
|
+
_moduleData = {};
|
|
1497
1535
|
_textureCaps = {};
|
|
1498
1536
|
constructor(props) {
|
|
1499
1537
|
this.props = { ..._Device.defaultProps, ...props };
|
|
@@ -1590,7 +1628,13 @@ var __exports__ = (() => {
|
|
|
1590
1628
|
reportError(error, context, ...args) {
|
|
1591
1629
|
const isHandled = this.props.onError(error, context);
|
|
1592
1630
|
if (!isHandled) {
|
|
1593
|
-
return log.error(
|
|
1631
|
+
return log.error(
|
|
1632
|
+
this.type === "webgl" ? "%cWebGL" : "%cWebGPU",
|
|
1633
|
+
"color: white; background: red; padding: 2px 6px; border-radius: 3px;",
|
|
1634
|
+
error.message,
|
|
1635
|
+
context,
|
|
1636
|
+
...args
|
|
1637
|
+
);
|
|
1594
1638
|
}
|
|
1595
1639
|
return () => {
|
|
1596
1640
|
};
|
|
@@ -1612,6 +1656,10 @@ or create a device with the 'debug: true' prop.`;
|
|
|
1612
1656
|
}
|
|
1613
1657
|
return this.canvasContext;
|
|
1614
1658
|
}
|
|
1659
|
+
/** Create a fence sync object */
|
|
1660
|
+
createFence() {
|
|
1661
|
+
throw new Error("createFence() not implemented");
|
|
1662
|
+
}
|
|
1615
1663
|
/** Create a RenderPass using the default CommandEncoder */
|
|
1616
1664
|
beginRenderPass(props) {
|
|
1617
1665
|
return this.commandEncoder.beginRenderPass(props);
|
|
@@ -1655,6 +1703,12 @@ or create a device with the 'debug: true' prop.`;
|
|
|
1655
1703
|
resetWebGL() {
|
|
1656
1704
|
throw new Error("not implemented");
|
|
1657
1705
|
}
|
|
1706
|
+
// INTERNAL LUMA.GL METHODS
|
|
1707
|
+
getModuleData(moduleName) {
|
|
1708
|
+
this._moduleData[moduleName] ||= {};
|
|
1709
|
+
return this._moduleData[moduleName];
|
|
1710
|
+
}
|
|
1711
|
+
// INTERNAL HELPERS
|
|
1658
1712
|
// IMPLEMENTATION
|
|
1659
1713
|
/** Helper to get the canvas context props */
|
|
1660
1714
|
static _getCanvasContextProps(props) {
|
|
@@ -1686,6 +1740,9 @@ or create a device with the 'debug: true' prop.`;
|
|
|
1686
1740
|
newProps.indexType = "uint32";
|
|
1687
1741
|
} else if (props.data instanceof Uint16Array) {
|
|
1688
1742
|
newProps.indexType = "uint16";
|
|
1743
|
+
} else if (props.data instanceof Uint8Array) {
|
|
1744
|
+
newProps.data = new Uint16Array(props.data);
|
|
1745
|
+
newProps.indexType = "uint16";
|
|
1689
1746
|
}
|
|
1690
1747
|
}
|
|
1691
1748
|
if (!newProps.indexType) {
|
|
@@ -1963,11 +2020,18 @@ or create a device with the 'debug: true' prop.`;
|
|
|
1963
2020
|
drawingBufferWidth;
|
|
1964
2021
|
/** Height of drawing buffer: automatically tracks this.pixelHeight if props.autoResize is true */
|
|
1965
2022
|
drawingBufferHeight;
|
|
2023
|
+
/** Resolves when the canvas is initialized, i.e. when the ResizeObserver has updated the pixel size */
|
|
1966
2024
|
_initializedResolvers = withResolvers();
|
|
2025
|
+
/** ResizeObserver to track canvas size changes */
|
|
1967
2026
|
_resizeObserver;
|
|
2027
|
+
/** IntersectionObserver to track canvas visibility changes */
|
|
1968
2028
|
_intersectionObserver;
|
|
1969
|
-
|
|
2029
|
+
/** Position of the canvas in the document, updated by a timer */
|
|
2030
|
+
_position = [0, 0];
|
|
2031
|
+
/** Whether this canvas context has been destroyed */
|
|
1970
2032
|
destroyed = false;
|
|
2033
|
+
/** Whether the drawing buffer size needs to be resized (deferred resizing to avoid flicker) */
|
|
2034
|
+
_needsDrawingBufferResize = true;
|
|
1971
2035
|
toString() {
|
|
1972
2036
|
return `${this[Symbol.toStringTag]}(${this.id})`;
|
|
1973
2037
|
}
|
|
@@ -2031,6 +2095,11 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2031
2095
|
}
|
|
2032
2096
|
return this;
|
|
2033
2097
|
}
|
|
2098
|
+
/** Returns a framebuffer with properly resized current 'swap chain' textures */
|
|
2099
|
+
getCurrentFramebuffer(options) {
|
|
2100
|
+
this._resizeDrawingBufferIfNeeded();
|
|
2101
|
+
return this._getCurrentFramebuffer(options);
|
|
2102
|
+
}
|
|
2034
2103
|
// SIZE METHODS
|
|
2035
2104
|
/**
|
|
2036
2105
|
* Returns the size covered by the canvas in CSS pixels
|
|
@@ -2060,12 +2129,16 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2060
2129
|
const maxTextureDimension = this.device.limits.maxTextureDimension2D;
|
|
2061
2130
|
return [maxTextureDimension, maxTextureDimension];
|
|
2062
2131
|
}
|
|
2063
|
-
/**
|
|
2132
|
+
/**
|
|
2133
|
+
* Update the canvas drawing buffer size.
|
|
2134
|
+
* @note - Called automatically if props.autoResize is true.
|
|
2135
|
+
* @note - Defers update of drawing buffer size until framebuffer is requested to avoid flicker
|
|
2136
|
+
* (resizing clears the drawing buffer)!
|
|
2137
|
+
*/
|
|
2064
2138
|
setDrawingBufferSize(width, height) {
|
|
2065
|
-
this.
|
|
2066
|
-
this.
|
|
2067
|
-
this.
|
|
2068
|
-
this.drawingBufferHeight = height;
|
|
2139
|
+
this.drawingBufferWidth = Math.floor(width);
|
|
2140
|
+
this.drawingBufferHeight = Math.floor(height);
|
|
2141
|
+
this._needsDrawingBufferResize = true;
|
|
2069
2142
|
}
|
|
2070
2143
|
/**
|
|
2071
2144
|
* Returns the current DPR (number of physical pixels per CSS pixel), if props.useDevicePixels is true
|
|
@@ -2151,6 +2224,7 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2151
2224
|
this._updateDrawingBufferSize();
|
|
2152
2225
|
this.device.props.onResize(this, { oldPixelSize });
|
|
2153
2226
|
}
|
|
2227
|
+
/** Initiate a deferred update for the canvas drawing buffer size */
|
|
2154
2228
|
_updateDrawingBufferSize() {
|
|
2155
2229
|
if (this.props.autoResize) {
|
|
2156
2230
|
if (typeof this.props.useDevicePixels === "number") {
|
|
@@ -2161,12 +2235,23 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2161
2235
|
} else {
|
|
2162
2236
|
this.setDrawingBufferSize(this.cssWidth, this.cssHeight);
|
|
2163
2237
|
}
|
|
2164
|
-
this._updateDevice();
|
|
2165
2238
|
}
|
|
2166
2239
|
this._initializedResolvers.resolve();
|
|
2167
2240
|
this.isInitialized = true;
|
|
2168
2241
|
this.updatePosition();
|
|
2169
2242
|
}
|
|
2243
|
+
/** Perform a deferred resize of the drawing buffer if needed */
|
|
2244
|
+
_resizeDrawingBufferIfNeeded() {
|
|
2245
|
+
if (this._needsDrawingBufferResize) {
|
|
2246
|
+
this._needsDrawingBufferResize = false;
|
|
2247
|
+
const sizeChanged = this.drawingBufferWidth !== this.canvas.width || this.drawingBufferHeight !== this.canvas.height;
|
|
2248
|
+
if (sizeChanged) {
|
|
2249
|
+
this.canvas.width = this.drawingBufferWidth;
|
|
2250
|
+
this.canvas.height = this.drawingBufferHeight;
|
|
2251
|
+
this._configureDevice();
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2170
2255
|
/** Monitor DPR changes */
|
|
2171
2256
|
_observeDevicePixelRatio() {
|
|
2172
2257
|
const oldRatio = this.devicePixelRatio;
|
|
@@ -2342,7 +2427,13 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2342
2427
|
depth;
|
|
2343
2428
|
/** mip levels in this texture */
|
|
2344
2429
|
mipLevels;
|
|
2345
|
-
/**
|
|
2430
|
+
/** Rows are multiples of this length, padded with extra bytes if needed */
|
|
2431
|
+
byteAlignment;
|
|
2432
|
+
/** The ready promise is always resolved. It is provided for type compatibility with DynamicTexture. */
|
|
2433
|
+
ready = Promise.resolve(this);
|
|
2434
|
+
/** isReady is always true. It is provided for type compatibility with DynamicTexture. */
|
|
2435
|
+
isReady = true;
|
|
2436
|
+
/** "Time" of last update. Monotonically increasing timestamp. TODO move to DynamicTexture? */
|
|
2346
2437
|
updateTimestamp;
|
|
2347
2438
|
get [Symbol.toStringTag]() {
|
|
2348
2439
|
return "Texture";
|
|
@@ -2351,7 +2442,7 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2351
2442
|
return `Texture(${this.id},${this.format},${this.width}x${this.height})`;
|
|
2352
2443
|
}
|
|
2353
2444
|
/** Do not use directly. Create with device.createTexture() */
|
|
2354
|
-
constructor(device, props) {
|
|
2445
|
+
constructor(device, props, backendProps) {
|
|
2355
2446
|
props = _Texture.normalizeProps(device, props);
|
|
2356
2447
|
super(device, props, _Texture.defaultProps);
|
|
2357
2448
|
this.dimension = this.props.dimension;
|
|
@@ -2361,6 +2452,9 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2361
2452
|
this.height = this.props.height;
|
|
2362
2453
|
this.depth = this.props.depth;
|
|
2363
2454
|
this.mipLevels = this.props.mipLevels;
|
|
2455
|
+
if (this.dimension === "cube") {
|
|
2456
|
+
this.depth = 6;
|
|
2457
|
+
}
|
|
2364
2458
|
if (this.props.width === void 0 || this.props.height === void 0) {
|
|
2365
2459
|
if (device.isExternalImage(props.data)) {
|
|
2366
2460
|
const size = device.getExternalImageSize(props.data);
|
|
@@ -2371,17 +2465,14 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2371
2465
|
this.height = 1;
|
|
2372
2466
|
if (this.props.width === void 0 || this.props.height === void 0) {
|
|
2373
2467
|
log.warn(
|
|
2374
|
-
`${this} created with undefined width or height. This is deprecated. Use
|
|
2468
|
+
`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`
|
|
2375
2469
|
)();
|
|
2376
2470
|
}
|
|
2377
2471
|
}
|
|
2378
2472
|
}
|
|
2473
|
+
this.byteAlignment = backendProps?.byteAlignment || 1;
|
|
2379
2474
|
this.updateTimestamp = device.incrementTimestamp();
|
|
2380
2475
|
}
|
|
2381
|
-
/** Set sampler props associated with this texture */
|
|
2382
|
-
setSampler(sampler) {
|
|
2383
|
-
this.sampler = sampler instanceof Sampler ? sampler : this.device.createSampler(sampler);
|
|
2384
|
-
}
|
|
2385
2476
|
/**
|
|
2386
2477
|
* Create a new texture with the same parameters and optionally a different size
|
|
2387
2478
|
* @note Textures are immutable and cannot be resized after creation, but we can create a similar texture with the same parameters but a new size.
|
|
@@ -2390,6 +2481,79 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2390
2481
|
clone(size) {
|
|
2391
2482
|
return this.device.createTexture({ ...this.props, ...size });
|
|
2392
2483
|
}
|
|
2484
|
+
/** Set sampler props associated with this texture */
|
|
2485
|
+
setSampler(sampler) {
|
|
2486
|
+
this.sampler = sampler instanceof Sampler ? sampler : this.device.createSampler(sampler);
|
|
2487
|
+
}
|
|
2488
|
+
/**
|
|
2489
|
+
* Calculates the memory layout of the texture, required when reading and writing data.
|
|
2490
|
+
* @return the memory layout of the texture, in particular bytesPerRow which includes required padding
|
|
2491
|
+
*/
|
|
2492
|
+
computeMemoryLayout(options_ = {}) {
|
|
2493
|
+
const options = this._normalizeTextureReadOptions(options_);
|
|
2494
|
+
const { width = this.width, height = this.height, depthOrArrayLayers = this.depth } = options;
|
|
2495
|
+
const { format, byteAlignment } = this;
|
|
2496
|
+
return textureFormatDecoder.computeMemoryLayout({
|
|
2497
|
+
format,
|
|
2498
|
+
width,
|
|
2499
|
+
height,
|
|
2500
|
+
depth: depthOrArrayLayers,
|
|
2501
|
+
byteAlignment
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* Read the contents of a texture into a GPU Buffer.
|
|
2506
|
+
* @returns A Buffer containing the texture data.
|
|
2507
|
+
*
|
|
2508
|
+
* @note The memory layout of the texture data is determined by the texture format and dimensions.
|
|
2509
|
+
* @note The application can call Texture.computeMemoryLayout() to compute the layout.
|
|
2510
|
+
* @note The application can call Buffer.readAsync()
|
|
2511
|
+
* @note If not supplied a buffer will be created and the application needs to call Buffer.destroy
|
|
2512
|
+
*/
|
|
2513
|
+
readBuffer(options, buffer) {
|
|
2514
|
+
throw new Error("readBuffer not implemented");
|
|
2515
|
+
}
|
|
2516
|
+
/**
|
|
2517
|
+
* Reads data from a texture into an ArrayBuffer.
|
|
2518
|
+
* @returns An ArrayBuffer containing the texture data.
|
|
2519
|
+
*
|
|
2520
|
+
* @note The memory layout of the texture data is determined by the texture format and dimensions.
|
|
2521
|
+
* @note The application can call Texture.computeMemoryLayout() to compute the layout.
|
|
2522
|
+
*/
|
|
2523
|
+
readDataAsync(options) {
|
|
2524
|
+
throw new Error("readBuffer not implemented");
|
|
2525
|
+
}
|
|
2526
|
+
/**
|
|
2527
|
+
* Writes an GPU Buffer into a texture.
|
|
2528
|
+
*
|
|
2529
|
+
* @note The memory layout of the texture data is determined by the texture format and dimensions.
|
|
2530
|
+
* @note The application can call Texture.computeMemoryLayout() to compute the layout.
|
|
2531
|
+
*/
|
|
2532
|
+
writeBuffer(buffer, options) {
|
|
2533
|
+
throw new Error("readBuffer not implemented");
|
|
2534
|
+
}
|
|
2535
|
+
/**
|
|
2536
|
+
* Writes an array buffer into a texture.
|
|
2537
|
+
*
|
|
2538
|
+
* @note The memory layout of the texture data is determined by the texture format and dimensions.
|
|
2539
|
+
* @note The application can call Texture.computeMemoryLayout() to compute the layout.
|
|
2540
|
+
*/
|
|
2541
|
+
writeData(data, options) {
|
|
2542
|
+
throw new Error("readBuffer not implemented");
|
|
2543
|
+
}
|
|
2544
|
+
// IMPLEMENTATION SPECIFIC
|
|
2545
|
+
/**
|
|
2546
|
+
* WebGL can read data synchronously.
|
|
2547
|
+
* @note While it is convenient, the performance penalty is very significant
|
|
2548
|
+
*/
|
|
2549
|
+
readDataSyncWebGL(options) {
|
|
2550
|
+
throw new Error("readDataSyncWebGL not available");
|
|
2551
|
+
}
|
|
2552
|
+
/** Generate mipmaps (WebGL only) */
|
|
2553
|
+
generateMipmapsWebGL() {
|
|
2554
|
+
throw new Error("generateMipmapsWebGL not available");
|
|
2555
|
+
}
|
|
2556
|
+
// HELPERS
|
|
2393
2557
|
/** Ensure we have integer coordinates */
|
|
2394
2558
|
static normalizeProps(device, props) {
|
|
2395
2559
|
const newProps = { ...props };
|
|
@@ -2402,7 +2566,6 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2402
2566
|
}
|
|
2403
2567
|
return newProps;
|
|
2404
2568
|
}
|
|
2405
|
-
// HELPERS
|
|
2406
2569
|
/** Initialize texture with supplied props */
|
|
2407
2570
|
// eslint-disable-next-line max-statements
|
|
2408
2571
|
_initializeData(data) {
|
|
@@ -2453,6 +2616,20 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2453
2616
|
options.height = Math.min(options.height, this.height - options.y);
|
|
2454
2617
|
return options;
|
|
2455
2618
|
}
|
|
2619
|
+
_normalizeTextureReadOptions(options_) {
|
|
2620
|
+
const { width, height } = this;
|
|
2621
|
+
const options = { ..._Texture.defaultTextureReadOptions, width, height, ...options_ };
|
|
2622
|
+
options.width = Math.min(options.width, this.width - options.x);
|
|
2623
|
+
options.height = Math.min(options.height, this.height - options.y);
|
|
2624
|
+
return options;
|
|
2625
|
+
}
|
|
2626
|
+
_normalizeTextureWriteOptions(options_) {
|
|
2627
|
+
const { width, height } = this;
|
|
2628
|
+
const options = { ..._Texture.defaultTextureReadOptions, width, height, ...options_ };
|
|
2629
|
+
options.width = Math.min(options.width, this.width - options.x);
|
|
2630
|
+
options.height = Math.min(options.height, this.height - options.y);
|
|
2631
|
+
return options;
|
|
2632
|
+
}
|
|
2456
2633
|
};
|
|
2457
2634
|
var Texture = _Texture;
|
|
2458
2635
|
/** The texture can be bound for use as a sampled texture in a shader */
|
|
@@ -2469,13 +2646,12 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2469
2646
|
__publicField(Texture, "TEXTURE", 4);
|
|
2470
2647
|
/** @deprecated Use Texture.RENDER */
|
|
2471
2648
|
__publicField(Texture, "RENDER_ATTACHMENT", 16);
|
|
2472
|
-
/** Default options */
|
|
2473
2649
|
__publicField(Texture, "defaultProps", {
|
|
2474
2650
|
...Resource.defaultProps,
|
|
2475
2651
|
data: null,
|
|
2476
2652
|
dimension: "2d",
|
|
2477
2653
|
format: "rgba8unorm",
|
|
2478
|
-
usage: _Texture.
|
|
2654
|
+
usage: _Texture.SAMPLE | _Texture.RENDER | _Texture.COPY_DST,
|
|
2479
2655
|
width: void 0,
|
|
2480
2656
|
height: void 0,
|
|
2481
2657
|
depth: 1,
|
|
@@ -2512,6 +2688,16 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2512
2688
|
premultipliedAlpha: false,
|
|
2513
2689
|
flipY: false
|
|
2514
2690
|
});
|
|
2691
|
+
__publicField(Texture, "defaultTextureReadOptions", {
|
|
2692
|
+
x: 0,
|
|
2693
|
+
y: 0,
|
|
2694
|
+
z: 0,
|
|
2695
|
+
width: void 0,
|
|
2696
|
+
height: void 0,
|
|
2697
|
+
depthOrArrayLayers: 1,
|
|
2698
|
+
mipLevel: 0,
|
|
2699
|
+
aspect: "all"
|
|
2700
|
+
});
|
|
2515
2701
|
|
|
2516
2702
|
// ../core/src/adapter/resources/texture-view.ts
|
|
2517
2703
|
var _TextureView = class extends Resource {
|
|
@@ -2752,7 +2938,12 @@ ${htmlLog}
|
|
|
2752
2938
|
(colorAttachment) => colorAttachment.texture.clone(size)
|
|
2753
2939
|
);
|
|
2754
2940
|
const depthStencilAttachment = this.depthStencilAttachment && this.depthStencilAttachment.texture.clone(size);
|
|
2755
|
-
return this.device.createFramebuffer({
|
|
2941
|
+
return this.device.createFramebuffer({
|
|
2942
|
+
...this.props,
|
|
2943
|
+
...size,
|
|
2944
|
+
colorAttachments,
|
|
2945
|
+
depthStencilAttachment
|
|
2946
|
+
});
|
|
2756
2947
|
}
|
|
2757
2948
|
resize(size) {
|
|
2758
2949
|
let updateSize = !size;
|
|
@@ -3348,6 +3539,18 @@ ${htmlLog}
|
|
|
3348
3539
|
count: void 0
|
|
3349
3540
|
});
|
|
3350
3541
|
|
|
3542
|
+
// ../core/src/adapter/resources/fence.ts
|
|
3543
|
+
var _Fence = class extends Resource {
|
|
3544
|
+
[Symbol.toStringTag] = "WEBGLFence";
|
|
3545
|
+
constructor(device, props = {}) {
|
|
3546
|
+
super(device, props, _Fence.defaultProps);
|
|
3547
|
+
}
|
|
3548
|
+
};
|
|
3549
|
+
var Fence = _Fence;
|
|
3550
|
+
__publicField(Fence, "defaultProps", {
|
|
3551
|
+
...Resource.defaultProps
|
|
3552
|
+
});
|
|
3553
|
+
|
|
3351
3554
|
// ../core/src/adapter/resources/pipeline-layout.ts
|
|
3352
3555
|
var _PipelineLayout = class extends Resource {
|
|
3353
3556
|
get [Symbol.toStringTag]() {
|
|
@@ -3379,17 +3582,6 @@ ${htmlLog}
|
|
|
3379
3582
|
return new Type(scratchArrayBuffer, 0, length);
|
|
3380
3583
|
}
|
|
3381
3584
|
|
|
3382
|
-
// ../core/src/utils/is-array.ts
|
|
3383
|
-
function isTypedArray(value) {
|
|
3384
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
3385
|
-
}
|
|
3386
|
-
function isNumberArray(value) {
|
|
3387
|
-
if (Array.isArray(value)) {
|
|
3388
|
-
return value.length === 0 || typeof value[0] === "number";
|
|
3389
|
-
}
|
|
3390
|
-
return isTypedArray(value);
|
|
3391
|
-
}
|
|
3392
|
-
|
|
3393
3585
|
// ../core/src/portable/uniform-buffer-layout.ts
|
|
3394
3586
|
var minBufferSize = 1024;
|
|
3395
3587
|
var UniformBufferLayout = class {
|
|
@@ -3400,67 +3592,114 @@ ${htmlLog}
|
|
|
3400
3592
|
constructor(uniformTypes, uniformSizes = {}) {
|
|
3401
3593
|
let size = 0;
|
|
3402
3594
|
for (const [key, uniformType] of Object.entries(uniformTypes)) {
|
|
3403
|
-
|
|
3404
|
-
const { type, components } = typeAndComponents;
|
|
3405
|
-
const count = components * (uniformSizes?.[key] ?? 1);
|
|
3406
|
-
size = alignTo(size, count);
|
|
3407
|
-
const offset = size;
|
|
3408
|
-
size += count;
|
|
3409
|
-
this.layout[key] = { type, size: count, offset };
|
|
3595
|
+
size = this._addToLayout(key, uniformType, size, uniformSizes?.[key]);
|
|
3410
3596
|
}
|
|
3411
3597
|
size += (4 - size % 4) % 4;
|
|
3412
|
-
|
|
3413
|
-
|
|
3598
|
+
this.byteLength = Math.max(size * 4, minBufferSize);
|
|
3599
|
+
}
|
|
3600
|
+
/** Does this layout have a field with specified name */
|
|
3601
|
+
has(name2) {
|
|
3602
|
+
return Boolean(this.layout[name2]);
|
|
3603
|
+
}
|
|
3604
|
+
/** Get offset and size for a field with specified name */
|
|
3605
|
+
get(name2) {
|
|
3606
|
+
const layout = this.layout[name2];
|
|
3607
|
+
return layout;
|
|
3414
3608
|
}
|
|
3415
3609
|
/** Get the data for the complete buffer */
|
|
3416
3610
|
getData(uniformValues) {
|
|
3417
|
-
const
|
|
3611
|
+
const buffer = getScratchArrayBuffer(this.byteLength);
|
|
3418
3612
|
const typedArrays = {
|
|
3419
|
-
i32: new Int32Array(
|
|
3420
|
-
u32: new Uint32Array(
|
|
3421
|
-
f32: new Float32Array(
|
|
3422
|
-
|
|
3423
|
-
f16: new Uint16Array(arrayBuffer2)
|
|
3613
|
+
i32: new Int32Array(buffer),
|
|
3614
|
+
u32: new Uint32Array(buffer),
|
|
3615
|
+
f32: new Float32Array(buffer),
|
|
3616
|
+
f16: new Uint16Array(buffer)
|
|
3424
3617
|
};
|
|
3425
3618
|
for (const [name2, value] of Object.entries(uniformValues)) {
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3619
|
+
this._writeCompositeValue(typedArrays, name2, value);
|
|
3620
|
+
}
|
|
3621
|
+
return new Uint8Array(buffer, 0, this.byteLength);
|
|
3622
|
+
}
|
|
3623
|
+
// Recursively add a uniform to the layout
|
|
3624
|
+
_addToLayout(name2, type, offset, count = 1) {
|
|
3625
|
+
if (typeof type === "string") {
|
|
3626
|
+
const info = getVariableShaderTypeInfo(type);
|
|
3627
|
+
const sizeInSlots = info.components * count;
|
|
3628
|
+
const alignedOffset = alignTo(offset, info.components);
|
|
3629
|
+
this.layout[name2] = {
|
|
3630
|
+
offset: alignedOffset,
|
|
3631
|
+
size: sizeInSlots,
|
|
3632
|
+
type: info.type
|
|
3633
|
+
};
|
|
3634
|
+
return alignedOffset + sizeInSlots;
|
|
3635
|
+
}
|
|
3636
|
+
if (Array.isArray(type)) {
|
|
3637
|
+
const elementType = type[0];
|
|
3638
|
+
const length = count > 1 ? count : type.length > 1 ? type[1] : 1;
|
|
3639
|
+
let arrayOffset = alignTo(offset, 4);
|
|
3640
|
+
for (let i = 0; i < length; i++) {
|
|
3641
|
+
arrayOffset = this._addToLayout(`${name2}[${i}]`, elementType, arrayOffset);
|
|
3430
3642
|
}
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
)();
|
|
3438
|
-
continue;
|
|
3439
|
-
}
|
|
3440
|
-
typedArray[offset] = Number(value);
|
|
3441
|
-
} else {
|
|
3442
|
-
if (!isNumberArray(value)) {
|
|
3443
|
-
log.warn(
|
|
3444
|
-
`Supplied value for multi component / array uniform ${name2} is not a numeric array: ${value}`
|
|
3445
|
-
)();
|
|
3446
|
-
continue;
|
|
3447
|
-
}
|
|
3448
|
-
typedArray.set(value, offset);
|
|
3643
|
+
return arrayOffset;
|
|
3644
|
+
}
|
|
3645
|
+
if (typeof type === "object") {
|
|
3646
|
+
let structOffset = alignTo(offset, 4);
|
|
3647
|
+
for (const [memberName, memberType] of Object.entries(type)) {
|
|
3648
|
+
structOffset = this._addToLayout(`${name2}.${memberName}`, memberType, structOffset);
|
|
3449
3649
|
}
|
|
3650
|
+
return structOffset;
|
|
3450
3651
|
}
|
|
3451
|
-
|
|
3652
|
+
throw new Error(`Unsupported CompositeShaderType for ${name2}`);
|
|
3452
3653
|
}
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3654
|
+
_writeCompositeValue(typedArrays, baseName, value) {
|
|
3655
|
+
if (this.layout[baseName]) {
|
|
3656
|
+
this._writeToBuffer(typedArrays, baseName, value);
|
|
3657
|
+
return;
|
|
3658
|
+
}
|
|
3659
|
+
if (Array.isArray(value)) {
|
|
3660
|
+
for (let i = 0; i < value.length; i++) {
|
|
3661
|
+
const element = value[i];
|
|
3662
|
+
const indexedName = `${baseName}[${i}]`;
|
|
3663
|
+
this._writeCompositeValue(typedArrays, indexedName, element);
|
|
3664
|
+
}
|
|
3665
|
+
return;
|
|
3666
|
+
}
|
|
3667
|
+
if (typeof value === "object" && value !== null) {
|
|
3668
|
+
for (const [key, subValue] of Object.entries(value)) {
|
|
3669
|
+
const nestedName = `${baseName}.${key}`;
|
|
3670
|
+
this._writeCompositeValue(typedArrays, nestedName, subValue);
|
|
3671
|
+
}
|
|
3672
|
+
return;
|
|
3673
|
+
}
|
|
3674
|
+
log.warn(`Unsupported uniform value for ${baseName}:`, value)();
|
|
3456
3675
|
}
|
|
3457
|
-
|
|
3458
|
-
get(name2) {
|
|
3676
|
+
_writeToBuffer(typedArrays, name2, value) {
|
|
3459
3677
|
const layout = this.layout[name2];
|
|
3460
|
-
|
|
3678
|
+
if (!layout) {
|
|
3679
|
+
log.warn(`Uniform ${name2} not found in layout`)();
|
|
3680
|
+
return;
|
|
3681
|
+
}
|
|
3682
|
+
const { type, size, offset } = layout;
|
|
3683
|
+
const array = typedArrays[type];
|
|
3684
|
+
if (size === 1) {
|
|
3685
|
+
array[offset] = Number(value);
|
|
3686
|
+
} else {
|
|
3687
|
+
array.set(value, offset);
|
|
3688
|
+
}
|
|
3461
3689
|
}
|
|
3462
3690
|
};
|
|
3463
3691
|
|
|
3692
|
+
// ../core/src/utils/is-array.ts
|
|
3693
|
+
function isTypedArray(value) {
|
|
3694
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
3695
|
+
}
|
|
3696
|
+
function isNumberArray(value) {
|
|
3697
|
+
if (Array.isArray(value)) {
|
|
3698
|
+
return value.length === 0 || typeof value[0] === "number";
|
|
3699
|
+
}
|
|
3700
|
+
return isTypedArray(value);
|
|
3701
|
+
}
|
|
3702
|
+
|
|
3464
3703
|
// ../core/src/utils/array-equal.ts
|
|
3465
3704
|
function arrayEqual(a, b, limit = 16) {
|
|
3466
3705
|
if (a !== b) {
|
|
@@ -3652,6 +3891,44 @@ ${htmlLog}
|
|
|
3652
3891
|
}
|
|
3653
3892
|
};
|
|
3654
3893
|
|
|
3894
|
+
// ../core/src/shadertypes/textures/texture-layout.ts
|
|
3895
|
+
function getTextureImageView(arrayBuffer2, memoryLayout, format, image = 0) {
|
|
3896
|
+
const formatInfo = textureFormatDecoder.getInfo(format);
|
|
3897
|
+
const bytesPerComponent = formatInfo.bytesPerPixel / formatInfo.components;
|
|
3898
|
+
const { bytesPerImage } = memoryLayout;
|
|
3899
|
+
const offset = bytesPerImage * image;
|
|
3900
|
+
const totalPixels = memoryLayout.bytesPerImage / bytesPerComponent;
|
|
3901
|
+
switch (format) {
|
|
3902
|
+
case "rgba8unorm":
|
|
3903
|
+
case "bgra8unorm":
|
|
3904
|
+
case "rgba8uint":
|
|
3905
|
+
return new Uint8Array(arrayBuffer2, offset, totalPixels);
|
|
3906
|
+
case "r8unorm":
|
|
3907
|
+
return new Uint8Array(arrayBuffer2, offset, totalPixels);
|
|
3908
|
+
case "r16uint":
|
|
3909
|
+
case "rgba16uint":
|
|
3910
|
+
return new Uint16Array(arrayBuffer2, offset, totalPixels);
|
|
3911
|
+
case "r32uint":
|
|
3912
|
+
case "rgba32uint":
|
|
3913
|
+
return new Uint32Array(arrayBuffer2, offset, totalPixels);
|
|
3914
|
+
case "r32float":
|
|
3915
|
+
return new Float32Array(arrayBuffer2, offset, totalPixels);
|
|
3916
|
+
case "rgba16float":
|
|
3917
|
+
return new Uint16Array(arrayBuffer2, offset, totalPixels);
|
|
3918
|
+
case "rgba32float":
|
|
3919
|
+
return new Float32Array(arrayBuffer2, offset, totalPixels);
|
|
3920
|
+
default:
|
|
3921
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
function setTextureImageData(arrayBuffer2, memoryLayout, format, data, image = 0) {
|
|
3925
|
+
const offset = 0;
|
|
3926
|
+
const totalPixels = memoryLayout.bytesPerImage / memoryLayout.bytesPerPixel;
|
|
3927
|
+
const subArray = data.subarray(0, totalPixels);
|
|
3928
|
+
const typedArray = getTextureImageView(arrayBuffer2, memoryLayout, format, image);
|
|
3929
|
+
typedArray.set(subArray, offset);
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3655
3932
|
// ../core/src/shadertypes/textures/pixel-utils.ts
|
|
3656
3933
|
function readPixel(pixelData, x, y, bitsPerChannel) {
|
|
3657
3934
|
if (x < 0 || x >= pixelData.width || y < 0 || y >= pixelData.height) {
|
package/dist/dist.min.js
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
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 Ht=Object.create;var k=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Wt=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty;var Vt=(r,e,t)=>e in r?k(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Ot=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),jt=(r,e)=>{for(var t in e)k(r,t,{get:e[t],enumerable:!0})},ce=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of kt(e))!Gt.call(r,n)&&n!==t&&k(r,n,{get:()=>e[n],enumerable:!(i=Nt(e,n))||i.enumerable});return r},ue=(r,e,t)=>(ce(r,e,"default"),t&&ce(t,e,"default")),Yt=(r,e,t)=>(t=r!=null?Ht(Wt(r)):{},ce(e||!r||!r.__esModule?k(t,"default",{value:r,enumerable:!0}):t,r)),Xt=r=>ce(k({},"__esModule",{value:!0}),r);var a=(r,e,t)=>(Vt(r,typeof e!="symbol"?e+"":e,t),t);var $t=Ot((vo,zt)=>{zt.exports=globalThis.luma});var ae={};jt(ae,{Adapter:()=>Ae,Buffer:()=>h,CanvasContext:()=>$,CommandBuffer:()=>re,CommandEncoder:()=>te,ComputePass:()=>ee,ComputePipeline:()=>Z,Device:()=>C,DeviceFeatures:()=>ve,DeviceLimits:()=>we,ExternalTexture:()=>q,Framebuffer:()=>J,PipelineLayout:()=>oe,QuerySet:()=>se,RenderPass:()=>S,RenderPipeline:()=>Q,Resource:()=>u,Sampler:()=>I,Shader:()=>K,Texture:()=>g,TextureFormatDecoder:()=>Y,TextureView:()=>X,TransformFeedback:()=>ne,UniformBlock:()=>N,UniformBufferLayout:()=>H,UniformStore:()=>Re,VertexArray:()=>ie,_getTextureFormatDefinition:()=>j,_getTextureFormatTable:()=>xt,getAttributeInfosFromLayouts:()=>Je,getAttributeShaderTypeInfo:()=>Ce,getDataType:()=>ge,getDataTypeInfo:()=>F,getNormalizedDataType:()=>pe,getScratchArray:()=>Lt,getTypedArrayConstructor:()=>ht,getVariableShaderTypeInfo:()=>_e,getVertexFormatFromAttribute:()=>pt,getVertexFormatInfo:()=>E,log:()=>l,luma:()=>Pt,makeVertexFormat:()=>Fe,readPixel:()=>Mt,textureFormatDecoder:()=>_,writePixel:()=>Ft});function W(){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 P=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=W(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(W()-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 D=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:i}=e,n=this.stats[t];return n||(e instanceof P?n=e:n=new P(t,i),this.stats[t]=n),n}};var Le=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new D({id:e})),this.stats.get(e)}},fe=new Le;var le=globalThis,qt=globalThis.document||{},me=globalThis.process||{},Kt=globalThis.console,Qr=globalThis.navigator||{};function it(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 x(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||it()}var De="4.1.0";function Qt(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var de=class{constructor(e,t,i="sessionStorage"){this.storage=Qt(i),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 nt(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 st(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var he;(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"})(he||(he={}));var Zt=10;function ot(r){return typeof r!="string"?r:(r=r.toUpperCase(),he[r]||he.WHITE)}function at(r,e,t){return!x&&typeof r=="string"&&(e&&(r=`\x1B[${ot(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${ot(t)+Zt}m${r}\x1B[49m`)),r}function ct(r,e=["constructor"]){let t=Object.getPrototypeOf(r),i=Object.getOwnPropertyNames(t),n=r;for(let s of i){let o=n[s];typeof o=="function"&&(e.find(c=>s===c)||(n[s]=o.bind(r)))}}function G(r,e){if(!r)throw new Error(e||"Assertion failed")}function A(){let r;if(x()&&le.performance)r=le?.performance?.now?.();else if("hrtime"in me){let e=me?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var B={debug:x()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},er={enabled:!0,level:0};function M(){}var ut={},ft={once:!0},v=class{constructor({id:e}={id:""}){this.VERSION=De,this._startTs=A(),this._deltaTs=A(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new de(`__probe-${this.id}__`,er),this.timeStamp(`${this.id} started`),ct(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((A()-this._startTs).toPrecision(10))}getDelta(){return Number((A()-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,ft)}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,ft)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||M,i&&[i],{tag:rr(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,i={collapsed:!1}){let n=lt({logLevel:e,message:t,opts:i}),{collapsed:s}=i;return n.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||M)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=mt(e)}_getLogFunction(e,t,i,n,s){if(this._shouldLog(e)){s=lt({logLevel:e,message:t,args:n,opts:s}),i=i||s.method,G(i),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=A();let o=s.tag||s.message;if(s.once&&o)if(!ut[o])ut[o]=A();else return M;return t=tr(this.id,s.message,s),i.bind(console,t,...s.args)}return M}};v.VERSION=De;function mt(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 G(Number.isFinite(e)&&e>=0),e}function lt(r){let{logLevel:e,message:t}=r;r.logLevel=mt(e);let i=r.args?Array.from(r.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let n=typeof r.message;return G(n==="string"||n==="object"),Object.assign(r,{args:i},r.opts)}function tr(r,e,t){if(typeof e=="string"){let i=t.time?st(nt(t.total)):"";e=t.time?`${r}: ${i} ${e}`:`${r}: ${e}`,e=at(e,t.color,t.background)}return e}function rr(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}globalThis.probe={};var Si=new v({id:"@probe.gl/log"});var l=new v({id:"luma.gl"});var Be={};function T(r="id"){Be[r]=Be[r]||1;let e=Be[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,i){if(!e)throw new Error("no device");this._device=e,this.props=ir(t,i);let n=this.props.id!=="undefined"?this.props.id:T(this[Symbol.toStringTag]);this.props.id=n,this.id=n,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 i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").addCount(e),i.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 ir(r,e){let t={...e};for(let i in r)r[i]!==void 0&&(t[i]=r[i]);return t}var V=class extends u{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let i={...t};(t.usage||0)&V.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?i.indexType="uint32":t.data instanceof Uint16Array&&(i.indexType="uint16")),delete i.data,super(e,i,V.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,t,i){let n=ArrayBuffer.isView(e)?e.buffer:e,s=Math.min(e?e.byteLength:i,V.DEBUG_DATA_MAX_LENGTH);n===null?this.debugData=new ArrayBuffer(s):t===0&&i===n.byteLength?this.debugData=n.slice(0,s):this.debugData=n.slice(t,t+s)}},h=V;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,"MAP_READ",1),a(h,"MAP_WRITE",2),a(h,"COPY_SRC",4),a(h,"COPY_DST",8),a(h,"DEBUG_DATA_MAX_LENGTH",32),a(h,"defaultProps",{...u.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});function F(r){let[e,t,i]=Me[r],n=r.includes("norm"),s=!n&&!r.startsWith("float"),o=r.startsWith("s");return{signedType:e,primitiveType:t,byteLength:i,normalized:n,integer:s,signed:o}}function pe(r){let e=r;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function dt(r,e){switch(e){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}function ge(r){let e=ArrayBuffer.isView(r)?r.constructor:r;if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Me).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function ht(r){let[,,,,e]=Me[r];return e}var Me={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function E(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,i]=r.split("x"),n=t,s=i?parseInt(i):1,o=F(n),c={type:n,components:s,byteLength:o.byteLength*s,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(c.webglOnly=!0),c}function Fe(r,e,t){let i=t?pe(r):r;switch(i){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${i}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${i}x${e}`;default:return e===1?i:`${i}x${e}`}}function pt(r,e,t){if(!e||e>4)throw new Error(`size ${e}`);let i=e,n=ge(r);return Fe(n,i,t)}function gt(r){let e;switch(r.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return r.components<=2?"float16x2":"float16x4"}return r.components===1?e:`${e}x${r.components}`}var b="texture-compression-bc",m="texture-compression-astc",y="texture-compression-etc2",nr="texture-compression-etc1-webgl",be="texture-compression-pvrtc-webgl",ze="texture-compression-atc-webgl",xe="float32-renderable-webgl",$e="float16-renderable-webgl",sr="rgb9e5ufloat-renderable-webgl",Ue="snorm8-renderable-webgl",O="norm16-renderable-webgl",He="snorm16-renderable-webgl",ye="float32-filterable",bt="float16-filterable-webgl";function j(r){let e=yt[r];if(!e)throw new Error(`Unsupported texture format ${r}`);return e}function xt(){return yt}var or={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:Ue},rg8snorm:{render:Ue},"rgb8snorm-webgl":{},rgba8snorm:{render:Ue},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:O},rg16unorm:{render:O},"rgb16unorm-webgl":{f:O},rgba16unorm:{render:O},r16snorm:{f:He},rg16snorm:{render:He},"rgb16snorm-webgl":{f:O},rgba16snorm:{render:He},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:$e,filter:"float16-filterable-webgl"},rg16float:{render:$e,filter:bt},rgba16float:{render:$e,filter:bt},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:xe,filter:ye},rg32float:{render:!1,filter:ye},"rgb32float-webgl":{render:xe,filter:ye},rgba32float:{render:xe,filter:ye},"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},rgb9e5ufloat:{channels:"rgb",packed:!0,render:sr},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:xe},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},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}},ar={"bc1-rgb-unorm-webgl":{f:b},"bc1-rgb-unorm-srgb-webgl":{f:b},"bc1-rgba-unorm":{f:b},"bc1-rgba-unorm-srgb":{f:b},"bc2-rgba-unorm":{f:b},"bc2-rgba-unorm-srgb":{f:b},"bc3-rgba-unorm":{f:b},"bc3-rgba-unorm-srgb":{f:b},"bc4-r-unorm":{f:b},"bc4-r-snorm":{f:b},"bc5-rg-unorm":{f:b},"bc5-rg-snorm":{f:b},"bc6h-rgb-ufloat":{f:b},"bc6h-rgb-float":{f:b},"bc7-rgba-unorm":{f:b},"bc7-rgba-unorm-srgb":{f:b},"etc2-rgb8unorm":{f:y},"etc2-rgb8unorm-srgb":{f:y},"etc2-rgb8a1unorm":{f:y},"etc2-rgb8a1unorm-srgb":{f:y},"etc2-rgba8unorm":{f:y},"etc2-rgba8unorm-srgb":{f:y},"eac-r11unorm":{f:y},"eac-r11snorm":{f:y},"eac-rg11unorm":{f:y},"eac-rg11snorm":{f:y},"astc-4x4-unorm":{f:m},"astc-4x4-unorm-srgb":{f:m},"astc-5x4-unorm":{f:m},"astc-5x4-unorm-srgb":{f:m},"astc-5x5-unorm":{f:m},"astc-5x5-unorm-srgb":{f:m},"astc-6x5-unorm":{f:m},"astc-6x5-unorm-srgb":{f:m},"astc-6x6-unorm":{f:m},"astc-6x6-unorm-srgb":{f:m},"astc-8x5-unorm":{f:m},"astc-8x5-unorm-srgb":{f:m},"astc-8x6-unorm":{f:m},"astc-8x6-unorm-srgb":{f:m},"astc-8x8-unorm":{f:m},"astc-8x8-unorm-srgb":{f:m},"astc-10x5-unorm":{f:m},"astc-10x5-unorm-srgb":{f:m},"astc-10x6-unorm":{f:m},"astc-10x6-unorm-srgb":{f:m},"astc-10x8-unorm":{f:m},"astc-10x8-unorm-srgb":{f:m},"astc-10x10-unorm":{f:m},"astc-10x10-unorm-srgb":{f:m},"astc-12x10-unorm":{f:m},"astc-12x10-unorm-srgb":{f:m},"astc-12x12-unorm":{f:m},"astc-12x12-unorm-srgb":{f:m},"pvrtc-rgb4unorm-webgl":{f:be},"pvrtc-rgba4unorm-webgl":{f:be},"pvrtc-rbg2unorm-webgl":{f:be},"pvrtc-rgba2unorm-webgl":{f:be},"etc1-rbg-unorm-webgl":{f:nr},"atc-rgb-unorm-webgl":{f:ze},"atc-rgba-unorm-webgl":{f:ze},"atc-rgbai-unorm-webgl":{f:ze}},yt={...or,...ar};var cr=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],ur=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,Y=class{getInfo(e){return wt(e)}isColor(e){return e.startsWith("rgba")||e.startsWith("bgra")||e.startsWith("rgb")}isDepthStencil(e){return e.startsWith("depth")||e.startsWith("stencil")}isCompressed(e){return cr.some(t=>e.startsWith(t))}getCapabilities(e){let t=j(e),i={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},n=wt(e),s=e.startsWith("depth")||e.startsWith("stencil"),o=n?.signed,c=n?.integer,f=n?.webgl;return i.render&&=!o,i.filter&&=!s&&!o&&!c&&!f,i}},_=new Y;function wt(r){let e=fr(r);if(_.isCompressed(r)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;let i=lr(r);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let t=ur.exec(r);if(t){let[,i,n,s,o,c]=t,f=`${s}${n}`,d=F(f),p=d.byteLength*8,L=i.length,Ut=[p,L>=2?p:0,L>=3?p:0,L>=4?p:0];e={format:r,attachment:e.attachment,dataType:d.signedType,components:L,channels:i,integer:d.integer,signed:d.signed,normalized:d.normalized,bitsPerChannel:Ut,bytesPerPixel:d.byteLength*i.length,packed:e.packed,srgb:e.srgb},c==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return r.endsWith("-webgl")&&(e.webgl=!0),r.endsWith("-srgb")&&(e.srgb=!0),e}function fr(r){let e=j(r),t=e.bytesPerPixel||1,i=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:i,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 lr(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,i,n]=t;return{blockWidth:Number(i),blockHeight:Number(n)}}return null}function vt(r){return typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement||typeof VideoFrame<"u"&&r instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas}function Tt(r){if(typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height};if(typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement)return{width:r.naturalWidth,height:r.naturalHeight};if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement)return{width:r.videoWidth,height:r.videoHeight};if(typeof VideoFrame<"u"&&r instanceof VideoFrame)return{width:r.displayWidth,height:r.displayHeight};throw new Error("Unknown image type")}var we=class{},ve=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)}},Ne=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=fe;timestamp=0;_reused=!1;_lumaData={};_textureCaps={};constructor(e){this.props={...Ne.defaultProps,...e},this.id=this.props.id||T(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return E(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return _.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){let n=Math.max(e,t,i);return 1+Math.floor(Math.log2(n))}isExternalImage(e){return vt(e)}getExternalImageSize(e){return Tt(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return _.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){return this.props.onError(e,t)?()=>{}:l.error(e.message,t,...i)}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
8
|
-
or create a device with the 'debug: true' prop.`;l.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(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")}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=_.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,n=i(t.create);return{format:e,create:n,render:n&&i(t.render),filter:n&&i(t.filter),blend:n&&i(t.blend),store:n&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&h.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array&&(t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}},C=Ne;a(C,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{let[i,n]=e.getDevicePixelSize();l.log(1,`${e} resized => ${i}x${n}px`)()},onPositionChange:(e,t)=>{let[i,n]=e.getPosition();l.log(1,`${e} repositioned => ${i},${n}`)()},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,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});var mr="set luma.log.level=1 (or higher) to trace rendering",St="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",Se=class{stats=fe;log=l;VERSION="9.2.5";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} - ${mr}`)(),globalThis.luma=this}async createDevice(e={}){let t={...Se.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(St);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){let i=this._getTypeFromHandle(e,t.adapters),n=i&&this.selectAdapter(i,t.adapters);if(!n)throw new Error(St);return await n?.attach?.(e,t)}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(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let n of t)if(i.get(n)?.isSupported?.())return n;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));let n=this._getAdapterMap(t);return i&&n.get(i)||null}enforceWebGL2(e=!0,t=[]){let n=this._getAdapterMap(t).get("webgl");n||l.warn("enforceWebGL2: webgl adapter not found")(),n?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(Se.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?l.warn("WebGL1 is not supported",e)():l.warn("Unknown handle type",e)(),null)}},Te=Se;a(Te,"defaultProps",{...C.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});var Pt=new Te;var Ae=class{get pageLoaded(){return pr()}},dr=x()&&typeof document<"u",hr=()=>dr&&document.readyState==="complete",Pe=null;function pr(){return Pe||(hr()||typeof window>"u"?Pe=Promise.resolve():Pe=new Promise(r=>window.addEventListener("load",()=>r()))),Pe}function At(){let r,e;return{promise:new Promise((i,n)=>{r=i,e=n}),resolve:r,reject:e}}var z=class{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=At();_resizeObserver;_intersectionObserver;_position;destroyed=!1;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){if(this.props={...z.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,x()?e.canvas?typeof e.canvas=="string"?this.canvas=br(e.canvas):this.canvas=e.canvas:this.canvas=xr(e):this.canvas={width:e.width||1,height:e.height||1},z.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):z.isOffscreenCanvas(this.canvas)?(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.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],z.isHTMLCanvas(this.canvas)){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),this.props.trackPosition&&this._trackPosition()}}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}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}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let i=this.cssToDeviceRatio(),[n,s]=this.getDrawingBufferSize();return yr(e,i,n,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDevicePixelSize();return e/t}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_handleIntersection(e){let t=e.find(n=>n.target===this.canvas);if(!t)return;let i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){let t=e.find(f=>f.target===this.canvas);if(!t)return;this.cssWidth=t.contentBoxSize[0].inlineSize,this.cssHeight=t.contentBoxSize[0].blockSize;let i=this.getDevicePixelSize(),n=t.devicePixelContentBoxSize?.[0].inlineSize||t.contentBoxSize[0].inlineSize*devicePixelRatio,s=t.devicePixelContentBoxSize?.[0].blockSize||t.contentBoxSize[0].blockSize*devicePixelRatio,[o,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(n,o)),this.devicePixelHeight=Math.max(1,Math.min(s,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:i})}_updateDrawingBufferSize(){if(this.props.autoResize){if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){let t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let n=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:n})}}}},$=z;a($,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});function gr(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 br(r){let e=document.getElementById(r);if(!$.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function xr(r){let{width:e,height:t}=r,i=document.createElement("canvas");i.id=T("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",r?.visible||(i.style.visibility="hidden");let n=gr(r?.container||null);return n.insertBefore(i,n.firstChild),i}function yr(r,e,t,i,n){let s=r,o=Et(s[0],e,t),c=_t(s[1],e,i,n),f=Et(s[0]+1,e,t),d=f===t-1?f:f-1;f=_t(s[1]+1,e,i,n);let p;return n?(f=f===0?f:f+1,p=c,c=f):p=f===i-1?f:f-1,{x:o,y:c,width:Math.max(d-o+1,1),height:Math.max(p-c+1,1)}}function Et(r,e,t){return Math.min(Math.round(r*e),t-1)}function _t(r,e,t,i){return i?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var Ee=class extends u{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=Ee.normalizeProps(e,t),super(e,t,Ee.defaultProps)}static normalizeProps(e,t){return t}},I=Ee;a(I,"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 wr={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},w=class extends u{dimension;baseDimension;format;width;height;depth;mipLevels;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t){if(t=w.normalizeProps(e,t),super(e,t,w.defaultProps),this.dimension=this.props.dimension,this.baseDimension=wr[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let i=e.getExternalImageSize(t.data);this.width=i?.width||1,this.height=i?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&l.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=e.incrementTimestamp()}setSampler(e){this.sampler=e instanceof I?e:this.device.createSampler(e)}clone(e){return this.device.createTexture({...this.props,...e})}static normalizeProps(e,t){let i={...t},{width:n,height:s}=i;return typeof n=="number"&&(i.width=Math.max(1,Math.ceil(n))),typeof s=="number"&&(i.height=Math.max(1,Math.ceil(s))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{width:t,height:i,depth:n}=this,s={...w.defaultCopyDataOptions,width:t,height:i,depth:n,...e},o=this.device.getTextureFormatInfo(this.format);if(!e.bytesPerRow&&!o.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return s.bytesPerRow=e.bytesPerRow||t*(o.bytesPerPixel||4),s.rowsPerImage=e.rowsPerImage||i,s}_normalizeCopyExternalImageOptions(e){let t=this.device.getExternalImageSize(e.image),i={...w.defaultCopyExternalImageOptions,...t,...e};return i.width=Math.min(i.width,this.width-i.x),i.height=Math.min(i.height,this.height-i.y),i}},g=w;a(g,"SAMPLE",4),a(g,"STORAGE",8),a(g,"RENDER",16),a(g,"COPY_SRC",1),a(g,"COPY_DST",2),a(g,"TEXTURE",4),a(g,"RENDER_ATTACHMENT",16),a(g,"defaultProps",{...u.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:w.TEXTURE|w.RENDER_ATTACHMENT|w.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),a(g,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),a(g,"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 ke=class extends u{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,ke.defaultProps)}},X=ke;a(X,"defaultProps",{...u.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var We=class extends u{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,We.defaultProps)}},q=We;a(q,"defaultProps",{...u.defaultProps,source:void 0,colorSpace:"srgb"});function Ct(r,e,t){let i="",n=e.split(/\r?\n/),s=r.slice().sort((o,c)=>o.lineNum-c.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let c=1;c<=n.length;c++)for(i+=It(n[c-1],c,t);s.length>o&&s[o].lineNum===c;){let f=s[o++];i+=Ge(f,n,f.lineNum,{...t,inlineSource:!1})}for(;s.length>o;){let c=s[o++];i+=Ge(c,[],0,{...t,inlineSource:!1})}return i;case"issues":case"no":for(let c of r)i+=Ge(c,n,c.lineNum,{inlineSource:t?.showSourceCode!=="no"});return i}}function Ge(r,e,t,i){if(i?.inlineSource){let s=vr(e,t),o=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^
|
|
7
|
+
"use strict";var __exports__=(()=>{var Gt=Object.create;var H=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var jt=Object.getPrototypeOf,Yt=Object.prototype.hasOwnProperty;var Xt=(r,e,t)=>e in r?H(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var qt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Kt=(r,e)=>{for(var t in e)H(r,t,{get:e[t],enumerable:!0})},ce=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Vt(e))!Yt.call(r,n)&&n!==t&&H(r,n,{get:()=>e[n],enumerable:!(i=Ot(e,n))||i.enumerable});return r},ue=(r,e,t)=>(ce(r,e,"default"),t&&ce(t,e,"default")),Jt=(r,e,t)=>(t=r!=null?Gt(jt(r)):{},ce(e||!r||!r.__esModule?H(t,"default",{value:r,enumerable:!0}):t,r)),Qt=r=>ce(H({},"__esModule",{value:!0}),r);var c=(r,e,t)=>(Xt(r,typeof e!="symbol"?e+"":e,t),t);var kt=qt(($o,Nt)=>{Nt.exports=globalThis.luma});var oe={};Kt(oe,{Adapter:()=>Ce,Buffer:()=>h,CanvasContext:()=>z,CommandBuffer:()=>ee,CommandEncoder:()=>Z,ComputePass:()=>Q,ComputePipeline:()=>J,Device:()=>C,DeviceFeatures:()=>Pe,DeviceLimits:()=>Se,ExternalTexture:()=>Y,Fence:()=>ne,Framebuffer:()=>q,PipelineLayout:()=>se,QuerySet:()=>ie,RenderPass:()=>P,RenderPipeline:()=>K,Resource:()=>u,Sampler:()=>I,Shader:()=>X,Texture:()=>p,TextureFormatDecoder:()=>V,TextureView:()=>j,TransformFeedback:()=>re,UniformBlock:()=>U,UniformBufferLayout:()=>$,UniformStore:()=>Me,VertexArray:()=>te,_getTextureFormatDefinition:()=>O,_getTextureFormatTable:()=>St,getAttributeInfosFromLayouts:()=>tt,getAttributeShaderTypeInfo:()=>Le,getDataType:()=>be,getDataTypeInfo:()=>M,getExternalImageSize:()=>ve,getNormalizedDataType:()=>pe,getScratchArray:()=>Mt,getTextureImageView:()=>ct,getTypedArrayConstructor:()=>yt,getVariableShaderTypeInfo:()=>Re,getVertexFormatFromAttribute:()=>wt,getVertexFormatInfo:()=>_,isExternalImage:()=>Te,log:()=>l,luma:()=>_t,makeVertexFormat:()=>He,readPixel:()=>Ut,setTextureImageData:()=>$t,textureFormatDecoder:()=>x,writePixel:()=>Ht});function N(){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 A=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=N(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(N()-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:i}=e,n=this.stats[t];return n||(e instanceof A?n=e:n=new A(t,i),this.stats[t]=n),n}};var Fe=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)}},fe=new Fe;var le=globalThis,Zt=globalThis.document||{},me=globalThis.process||{},er=globalThis.console,oi=globalThis.navigator||{};function ut(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)||ut()}var ze="4.1.0";function rr(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var he=class{constructor(e,t,i="sessionStorage"){this.storage=rr(i),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 ft(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 lt(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var de;(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"})(de||(de={}));var ir=10;function mt(r){return typeof r!="string"?r:(r=r.toUpperCase(),de[r]||de.WHITE)}function ht(r,e,t){return!y&&typeof r=="string"&&(e&&(r=`\x1B[${mt(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${mt(t)+ir}m${r}\x1B[49m`)),r}function dt(r,e=["constructor"]){let t=Object.getPrototypeOf(r),i=Object.getOwnPropertyNames(t),n=r;for(let s of i){let a=n[s];typeof a=="function"&&(e.find(o=>s===o)||(n[s]=a.bind(r)))}}function k(r,e){if(!r)throw new Error(e||"Assertion failed")}function E(){let r;if(y()&&le.performance)r=le?.performance?.now?.();else if("hrtime"in me){let e=me?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var D={debug:y()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},nr={enabled:!0,level:0};function B(){}var pt={},gt={once:!0},v=class{constructor({id:e}={id:""}){this.VERSION=ze,this._startTs=E(),this._deltaTs=E(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new he(`__probe-${this.id}__`,nr),this.timeStamp(`${this.id} started`),dt(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((E()-this._startTs).toPrecision(10))}getDelta(){return Number((E()-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,D.warn,arguments,gt)}error(e){return this._getLogFunction(0,e,D.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,D.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,D.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,D.debug||D.info,arguments,gt)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||B,i&&[i],{tag:or(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,i={collapsed:!1}){let n=bt({logLevel:e,message:t,opts:i}),{collapsed:s}=i;return n.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||B)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=xt(e)}_getLogFunction(e,t,i,n,s){if(this._shouldLog(e)){s=bt({logLevel:e,message:t,args:n,opts:s}),i=i||s.method,k(i),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=E();let a=s.tag||s.message;if(s.once&&a)if(!pt[a])pt[a]=E();else return B;return t=sr(this.id,s.message,s),i.bind(console,t,...s.args)}return B}};v.VERSION=ze;function xt(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 k(Number.isFinite(e)&&e>=0),e}function bt(r){let{logLevel:e,message:t}=r;r.logLevel=xt(e);let i=r.args?Array.from(r.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let n=typeof r.message;return k(n==="string"||n==="object"),Object.assign(r,{args:i},r.opts)}function sr(r,e,t){if(typeof e=="string"){let i=t.time?lt(ft(t.total)):"";e=t.time?`${r}: ${i} ${e}`:`${r}: ${e}`,e=ht(e,t.color,t.background)}return e}function or(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}globalThis.probe={};var Li=new v({id:"@probe.gl/log"});var l=new v({id:"luma.gl"});var $e={};function S(r="id"){$e[r]=$e[r]||1;let e=$e[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,i){if(!e)throw new Error("no device");this._device=e,this.props=ar(t,i);let n=this.props.id!=="undefined"?this.props.id:S(this[Symbol.toStringTag]);this.props.id=n,this.id=n,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 i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").addCount(e),i.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()}};c(u,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function ar(r,e){let t={...e};for(let i in r)r[i]!==void 0&&(t[i]=r[i]);return t}var W=class extends u{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let i={...t};(t.usage||0)&W.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?i.indexType="uint32":t.data instanceof Uint16Array?i.indexType="uint16":t.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,W.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,t,i){let n=ArrayBuffer.isView(e)?e.buffer:e,s=Math.min(e?e.byteLength:i,W.DEBUG_DATA_MAX_LENGTH);n===null?this.debugData=new ArrayBuffer(s):t===0&&i===n.byteLength?this.debugData=n.slice(0,s):this.debugData=n.slice(t,t+s)}},h=W;c(h,"INDEX",16),c(h,"VERTEX",32),c(h,"UNIFORM",64),c(h,"STORAGE",128),c(h,"INDIRECT",256),c(h,"QUERY_RESOLVE",512),c(h,"MAP_READ",1),c(h,"MAP_WRITE",2),c(h,"COPY_SRC",4),c(h,"COPY_DST",8),c(h,"DEBUG_DATA_MAX_LENGTH",32),c(h,"defaultProps",{...u.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});function M(r){let e=r.includes("norm"),t=!e&&!r.startsWith("float"),i=r.startsWith("s"),n=Ue[r],[s,a,o]=n||["uint8 ","i32",1];return{signedType:s,primitiveType:a,byteLength:o,normalized:e,integer:t,signed:i}}function pe(r){let e=r;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function ge(r,e){switch(e){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}function be(r){let e=ArrayBuffer.isView(r)?r.constructor:r;if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Ue).find(i=>e===i[4]);if(!t)throw new Error(e.name);return t[0]}function yt(r){let[,,,,e]=Ue[r];return e}var Ue={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function _(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,i]=r.split("x"),n=t,s=i?parseInt(i):1,a=M(n),o={type:n,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return e&&(o.webglOnly=!0),o}function He(r,e,t){let i=t?pe(r):r;switch(i){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${i}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${i}x${e}`;default:return e===1?i:`${i}x${e}`}}function wt(r,e,t){if(!e||e>4)throw new Error(`size ${e}`);let i=e,n=be(r);return He(n,i,t)}function Tt(r){let e;switch(r.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return r.components<=2?"float16x2":"float16x4"}return r.components===1?e:`${e}x${r.components}`}var g="texture-compression-bc",m="texture-compression-astc",T="texture-compression-etc2",cr="texture-compression-etc1-webgl",xe="texture-compression-pvrtc-webgl",Ne="texture-compression-atc-webgl",ye="float32-renderable-webgl",ke="float16-renderable-webgl",ur="rgb9e5ufloat-renderable-webgl",We="snorm8-renderable-webgl",G="norm16-renderable-webgl",Ge="snorm16-renderable-webgl",we="float32-filterable",vt="float16-filterable-webgl";function O(r){let e=Pt[r];if(!e)throw new Error(`Unsupported texture format ${r}`);return e}function St(){return Pt}var fr={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:We},rg8snorm:{render:We},"rgb8snorm-webgl":{},rgba8snorm:{render:We},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:G},rg16unorm:{render:G},"rgb16unorm-webgl":{f:G},rgba16unorm:{render:G},r16snorm:{f:Ge},rg16snorm:{render:Ge},"rgb16snorm-webgl":{f:G},rgba16snorm:{render:Ge},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:ke,filter:"float16-filterable-webgl"},rg16float:{render:ke,filter:vt},rgba16float:{render:ke,filter:vt},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:ye,filter:we},rg32float:{render:!1,filter:we},"rgb32float-webgl":{render:ye,filter:we},rgba32float:{render:ye,filter:we},"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},rgb9e5ufloat:{channels:"rgb",packed:!0,render:ur},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:ye},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},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}},lr={"bc1-rgb-unorm-webgl":{f:g},"bc1-rgb-unorm-srgb-webgl":{f:g},"bc1-rgba-unorm":{f:g},"bc1-rgba-unorm-srgb":{f:g},"bc2-rgba-unorm":{f:g},"bc2-rgba-unorm-srgb":{f:g},"bc3-rgba-unorm":{f:g},"bc3-rgba-unorm-srgb":{f:g},"bc4-r-unorm":{f:g},"bc4-r-snorm":{f:g},"bc5-rg-unorm":{f:g},"bc5-rg-snorm":{f:g},"bc6h-rgb-ufloat":{f:g},"bc6h-rgb-float":{f:g},"bc7-rgba-unorm":{f:g},"bc7-rgba-unorm-srgb":{f:g},"etc2-rgb8unorm":{f:T},"etc2-rgb8unorm-srgb":{f:T},"etc2-rgb8a1unorm":{f:T},"etc2-rgb8a1unorm-srgb":{f:T},"etc2-rgba8unorm":{f:T},"etc2-rgba8unorm-srgb":{f:T},"eac-r11unorm":{f:T},"eac-r11snorm":{f:T},"eac-rg11unorm":{f:T},"eac-rg11snorm":{f:T},"astc-4x4-unorm":{f:m},"astc-4x4-unorm-srgb":{f:m},"astc-5x4-unorm":{f:m},"astc-5x4-unorm-srgb":{f:m},"astc-5x5-unorm":{f:m},"astc-5x5-unorm-srgb":{f:m},"astc-6x5-unorm":{f:m},"astc-6x5-unorm-srgb":{f:m},"astc-6x6-unorm":{f:m},"astc-6x6-unorm-srgb":{f:m},"astc-8x5-unorm":{f:m},"astc-8x5-unorm-srgb":{f:m},"astc-8x6-unorm":{f:m},"astc-8x6-unorm-srgb":{f:m},"astc-8x8-unorm":{f:m},"astc-8x8-unorm-srgb":{f:m},"astc-10x5-unorm":{f:m},"astc-10x5-unorm-srgb":{f:m},"astc-10x6-unorm":{f:m},"astc-10x6-unorm-srgb":{f:m},"astc-10x8-unorm":{f:m},"astc-10x8-unorm-srgb":{f:m},"astc-10x10-unorm":{f:m},"astc-10x10-unorm-srgb":{f:m},"astc-12x10-unorm":{f:m},"astc-12x10-unorm-srgb":{f:m},"astc-12x12-unorm":{f:m},"astc-12x12-unorm-srgb":{f:m},"pvrtc-rgb4unorm-webgl":{f:xe},"pvrtc-rgba4unorm-webgl":{f:xe},"pvrtc-rbg2unorm-webgl":{f:xe},"pvrtc-rgba2unorm-webgl":{f:xe},"etc1-rbg-unorm-webgl":{f:cr},"atc-rgb-unorm-webgl":{f:Ne},"atc-rgba-unorm-webgl":{f:Ne},"atc-rgbai-unorm-webgl":{f:Ne}},Pt={...fr,...lr};var mr=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,hr=["rgb","rgba","bgra"],dr=["depth","stencil"],pr=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],V=class{isColor(e){return hr.some(t=>e.startsWith(t))}isDepthStencil(e){return dr.some(t=>e.startsWith(t))}isCompressed(e){return pr.some(t=>e.startsWith(t))}getInfo(e){return At(e)}getCapabilities(e){return br(e)}computeMemoryLayout(e){return gr(e)}},x=new V;function gr({format:r,width:e,height:t,depth:i,byteAlignment:n}){let{bytesPerPixel:s}=x.getInfo(r),a=e*s,o=Math.ceil(a/n)*n,f=t,d=o*f*i;return{bytesPerPixel:s,bytesPerRow:o,rowsPerImage:f,depthOrArrayLayers:i,bytesPerImage:o*f,byteLength:d}}function br(r){let e=O(r),t={format:r,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=At(r),n=r.startsWith("depth")||r.startsWith("stencil"),s=i?.signed,a=i?.integer,o=i?.webgl;return t.render&&=!s,t.filter&&=!n&&!s&&!a&&!o,t}function At(r){let e=xr(r);if(x.isCompressed(r)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;let i=yr(r);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let t=mr.exec(r);if(t){let[,i,n,s,a,o]=t,f=`${s}${n}`,d=M(f),b=d.byteLength*8,ae=i.length,Wt=[b,ae>=2?b:0,ae>=3?b:0,ae>=4?b:0];e={format:r,attachment:e.attachment,dataType:d.signedType,components:ae,channels:i,integer:d.integer,signed:d.signed,normalized:d.normalized,bitsPerChannel:Wt,bytesPerPixel:d.byteLength*i.length,packed:e.packed,srgb:e.srgb},o==="-webgl"&&(e.webgl=!0),a==="-srgb"&&(e.srgb=!0)}return r.endsWith("-webgl")&&(e.webgl=!0),r.endsWith("-srgb")&&(e.srgb=!0),e}function xr(r){let e=O(r),t=e.bytesPerPixel||1,i=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:i,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 yr(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,i,n]=t;return{blockWidth:Number(i),blockHeight:Number(n)}}return null}function Te(r){return typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement||typeof VideoFrame<"u"&&r instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas}function ve(r){if(typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height};if(typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement)return{width:r.naturalWidth,height:r.naturalHeight};if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement)return{width:r.videoWidth,height:r.videoHeight};if(typeof VideoFrame<"u"&&r instanceof VideoFrame)return{width:r.displayWidth,height:r.displayHeight};throw new Error("Unknown image type")}var Se=class{},Pe=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)}},Oe=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=fe;timestamp=0;_reused=!1;_moduleData={};_textureCaps={};constructor(e){this.props={...Oe.defaultProps,...e},this.id=this.props.id||S(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return _(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return x.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){let n=Math.max(e,t,i);return 1+Math.floor(Math.log2(n))}isExternalImage(e){return Te(e)}getExternalImageSize(e){return ve(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return x.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){return this.props.onError(e,t)?()=>{}:l.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,t,...i)}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
8
|
+
or create a device with the 'debug: true' prop.`;l.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(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")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=x.getCapabilities(e),i=s=>(typeof s=="string"?this.features.has(s):s)??!0,n=i(t.create);return{format:e,create:n,render:n&&i(t.render),filter:n&&i(t.filter),blend:n&&i(t.blend),store:n&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&h.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}},C=Oe;c(C,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{let[i,n]=e.getDevicePixelSize();l.log(1,`${e} resized => ${i}x${n}px`)()},onPositionChange:(e,t)=>{let[i,n]=e.getPosition();l.log(1,`${e} repositioned => ${i},${n}`)()},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,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});var wr="set luma.log.level=1 (or higher) to trace rendering",Et="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",Ee=class{stats=fe;log=l;VERSION="9.3.0-alpha.2";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} - ${wr}`)(),globalThis.luma=this}async createDevice(e={}){let t={...Ee.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(Et);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){let i=this._getTypeFromHandle(e,t.adapters),n=i&&this.selectAdapter(i,t.adapters);if(!n)throw new Error(Et);return await n?.attach?.(e,t)}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(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let n of t)if(i.get(n)?.isSupported?.())return n;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));let n=this._getAdapterMap(t);return i&&n.get(i)||null}enforceWebGL2(e=!0,t=[]){let n=this._getAdapterMap(t).get("webgl");n||l.warn("enforceWebGL2: webgl adapter not found")(),n?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(Ee.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?l.warn("WebGL1 is not supported",e)():l.warn("Unknown handle type",e)(),null)}},Ae=Ee;c(Ae,"defaultProps",{...C.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});var _t=new Ae;var Ce=class{get pageLoaded(){return Sr()}},Tr=y()&&typeof document<"u",vr=()=>Tr&&document.readyState==="complete",_e=null;function Sr(){return _e||(vr()||typeof window>"u"?_e=Promise.resolve():_e=new Promise(r=>window.addEventListener("load",()=>r()))),_e}function Ct(){let r,e;return{promise:new Promise((i,n)=>{r=i,e=n}),resolve:r,reject:e}}var F=class{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=Ct();_resizeObserver;_intersectionObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){if(this.props={...F.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,y()?e.canvas?typeof e.canvas=="string"?this.canvas=Ar(e.canvas):this.canvas=e.canvas:this.canvas=Er(e):this.canvas={width:e.width||1,height:e.height||1},F.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):F.isOffscreenCanvas(this.canvas)?(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.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],F.isHTMLCanvas(this.canvas)){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),this.props.trackPosition&&this._trackPosition()}}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){this.drawingBufferWidth=Math.floor(e),this.drawingBufferHeight=Math.floor(t),this._needsDrawingBufferResize=!0}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let i=this.cssToDeviceRatio(),[n,s]=this.getDrawingBufferSize();return _r(e,i,n,s,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDevicePixelSize();return e/t}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_handleIntersection(e){let t=e.find(n=>n.target===this.canvas);if(!t)return;let i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){let t=e.find(f=>f.target===this.canvas);if(!t)return;this.cssWidth=t.contentBoxSize[0].inlineSize,this.cssHeight=t.contentBoxSize[0].blockSize;let i=this.getDevicePixelSize(),n=t.devicePixelContentBoxSize?.[0].inlineSize||t.contentBoxSize[0].inlineSize*devicePixelRatio,s=t.devicePixelContentBoxSize?.[0].blockSize||t.contentBoxSize[0].blockSize*devicePixelRatio,[a,o]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(n,a)),this.devicePixelHeight=Math.max(1,Math.min(s,o)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:i})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){let t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let n=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:n})}}}},z=F;c(z,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});function Pr(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 Ar(r){let e=document.getElementById(r);if(!z.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function Er(r){let{width:e,height:t}=r,i=document.createElement("canvas");i.id=S("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",r?.visible||(i.style.visibility="hidden");let n=Pr(r?.container||null);return n.insertBefore(i,n.firstChild),i}function _r(r,e,t,i,n){let s=r,a=It(s[0],e,t),o=Rt(s[1],e,i,n),f=It(s[0]+1,e,t),d=f===t-1?f:f-1;f=Rt(s[1]+1,e,i,n);let b;return n?(f=f===0?f:f+1,b=o,o=f):b=f===i-1?f:f-1,{x:a,y:o,width:Math.max(d-a+1,1),height:Math.max(b-o+1,1)}}function It(r,e,t){return Math.min(Math.round(r*e),t-1)}function Rt(r,e,t,i){return i?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var Ie=class extends u{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=Ie.normalizeProps(e,t),super(e,t,Ie.defaultProps)}static normalizeProps(e,t){return t}},I=Ie;c(I,"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 Cr={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},w=class extends u{dimension;baseDimension;format;width;height;depth;mipLevels;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,i){if(t=w.normalizeProps(e,t),super(e,t,w.defaultProps),this.dimension=this.props.dimension,this.baseDimension=Cr[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let n=e.getExternalImageSize(t.data);this.width=n?.width||1,this.height=n?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&l.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof I?e:this.device.createSampler(e)}computeMemoryLayout(e={}){let t=this._normalizeTextureReadOptions(e),{width:i=this.width,height:n=this.height,depthOrArrayLayers:s=this.depth}=t,{format:a,byteAlignment:o}=this;return x.computeMemoryLayout({format:a,width:i,height:n,depth:s,byteAlignment:o})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){let i={...t},{width:n,height:s}=i;return typeof n=="number"&&(i.width=Math.max(1,Math.ceil(n))),typeof s=="number"&&(i.height=Math.max(1,Math.ceil(s))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{width:t,height:i,depth:n}=this,s={...w.defaultCopyDataOptions,width:t,height:i,depth:n,...e},a=this.device.getTextureFormatInfo(this.format);if(!e.bytesPerRow&&!a.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return s.bytesPerRow=e.bytesPerRow||t*(a.bytesPerPixel||4),s.rowsPerImage=e.rowsPerImage||i,s}_normalizeCopyExternalImageOptions(e){let t=this.device.getExternalImageSize(e.image),i={...w.defaultCopyExternalImageOptions,...t,...e};return i.width=Math.min(i.width,this.width-i.x),i.height=Math.min(i.height,this.height-i.y),i}_normalizeTextureReadOptions(e){let{width:t,height:i}=this,n={...w.defaultTextureReadOptions,width:t,height:i,...e};return n.width=Math.min(n.width,this.width-n.x),n.height=Math.min(n.height,this.height-n.y),n}_normalizeTextureWriteOptions(e){let{width:t,height:i}=this,n={...w.defaultTextureReadOptions,width:t,height:i,...e};return n.width=Math.min(n.width,this.width-n.x),n.height=Math.min(n.height,this.height-n.y),n}},p=w;c(p,"SAMPLE",4),c(p,"STORAGE",8),c(p,"RENDER",16),c(p,"COPY_SRC",1),c(p,"COPY_DST",2),c(p,"TEXTURE",4),c(p,"RENDER_ATTACHMENT",16),c(p,"defaultProps",{...u.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:w.SAMPLE|w.RENDER|w.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),c(p,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),c(p,"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}),c(p,"defaultTextureReadOptions",{x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"});var Ve=class extends u{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,Ve.defaultProps)}},j=Ve;c(j,"defaultProps",{...u.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var je=class extends u{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,je.defaultProps)}},Y=je;c(Y,"defaultProps",{...u.defaultProps,source:void 0,colorSpace:"srgb"});function Lt(r,e,t){let i="",n=e.split(/\r?\n/),s=r.slice().sort((a,o)=>a.lineNum-o.lineNum);switch(t?.showSourceCode||"no"){case"all":let a=0;for(let o=1;o<=n.length;o++)for(i+=Dt(n[o-1],o,t);s.length>a&&s[a].lineNum===o;){let f=s[a++];i+=Ye(f,n,f.lineNum,{...t,inlineSource:!1})}for(;s.length>a;){let o=s[a++];i+=Ye(o,[],0,{...t,inlineSource:!1})}return i;case"issues":case"no":for(let o of r)i+=Ye(o,n,o.lineNum,{inlineSource:t?.showSourceCode!=="no"});return i}}function Ye(r,e,t,i){if(i?.inlineSource){let s=Ir(e,t),a=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^
|
|
9
9
|
`:"";return`
|
|
10
|
-
${s}${
|
|
10
|
+
${s}${a}${r.type.toUpperCase()}: ${r.message}
|
|
11
11
|
|
|
12
|
-
`}let n=r.type==="error"?"red":"#8B4000";return i?.html?`<div class='luma-compiler-log-error' style="color:${n};"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function
|
|
13
|
-
`}`}function
|
|
12
|
+
`}let n=r.type==="error"?"red":"#8B4000";return i?.html?`<div class='luma-compiler-log-error' style="color:${n};"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function Ir(r,e,t){let i="";for(let n=e-2;n<=e;n++){let s=r[n-1];s!==void 0&&(i+=Dt(s,e,t))}return i}function Dt(r,e,t){let i=t?.html?Lr(r):r;return`${Rr(String(e),4)}: ${i}${t?.html?"<br/>":`
|
|
13
|
+
`}`}function Rr(r,e){let t="";for(let i=r.length;i<e;++i)t+=" ";return t+r}function Lr(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var Xe=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:Dr(t),...t},Xe.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,this.id)}_displayShaderLog(e,t){if(typeof document>"u"||!document?.createElement)return;let i=t,n=`${this.stage} shader "${i}"`,s=Lt(e,this.source,{showSourceCode:"all",html:!0}),a=this.getTranslatedSource();a&&(s+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${a}</pre></code>`);let o=document.createElement("Button");o.innerHTML=`
|
|
14
14
|
<h1>Compilation error in ${n}</h1><br /><br />
|
|
15
15
|
<code style="user-select:text;"><pre>
|
|
16
16
|
${s}
|
|
17
|
-
</pre></code>`,c.style.top="10px",c.style.left="10px",c.style.position="absolute",c.style.zIndex="9999",c.style.width="100%",c.style.textAlign="left",document.body.appendChild(c),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),c.onclick=()=>{let d=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(d)}}},K=Ve;a(K,"defaultProps",{...u.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});function Pr(r){return Ar(r.source)||r.id||T(`unnamed ${r.stage}-shader`)}function Ar(r,e="unnamed"){let i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return i?i[1]:e}var Oe=class extends u{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,Oe.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(n=>n.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:t,depthStencilAttachment:i})}resize(e){let t=!e;if(e){let[i,n]=Array.isArray(e)?e:[e.width,e.height];t=t||n!==this.height||i!==this.width,this.width=i,this.height=n}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,i)=>{if(typeof t=="string"){let n=this.createColorTexture(t,i);return this.attachResource(n),n.view}return t instanceof g?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 g?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:g.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:g.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let i=0;i<this.colorAttachments.length;++i)if(this.colorAttachments[i]){let n=this.colorAttachments[i].texture.clone({width:e,height:t});this.destroyAttachedResource(this.colorAttachments[i]),this.colorAttachments[i]=n.view,this.attachResource(n.view)}if(this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}},J=Oe;a(J,"defaultProps",{...u.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var je=class extends u{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,t){super(e,t,je.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}},Q=je;a(Q,"defaultProps",{...u.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 R=class extends u{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=R.normalizeProps(e,t),super(e,t,R.defaultProps)}static normalizeProps(e,t){return t}},S=R;a(S,"defaultClearColor",[0,0,0,1]),a(S,"defaultClearDepth",1),a(S,"defaultClearStencil",0),a(S,"defaultProps",{...u.defaultProps,framebuffer:null,parameters:void 0,clearColor:R.defaultClearColor,clearColors:void 0,clearDepth:R.defaultClearDepth,clearStencil:R.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Ye=class extends u{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,Ye.defaultProps),this.shaderLayout=t.shaderLayout}},Z=Ye;a(Z,"defaultProps",{...u.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var Xe=class extends u{constructor(e,t){super(e,t,Xe.defaultProps)}get[Symbol.toStringTag](){return"ComputePass"}},ee=Xe;a(ee,"defaultProps",{...u.defaultProps,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var qe=class extends u{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,qe.defaultProps)}},te=qe;a(te,"defaultProps",{...u.defaultProps,measureExecutionTime:void 0});var Ke=class extends u{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,Ke.defaultProps)}},re=Ke;a(re,"defaultProps",{...u.defaultProps});function _e(r){return Cr[r]}function Ce(r){let[e,t]=_r[r],i=e==="i32"||e==="u32",n=e!=="u32",s=Er[e]*t;return{primitiveType:e,components:t,byteLength:s,integer:i,signed:n}}var Er={f32:4,f16:2,i32:4,u32:4},_r={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]},Cr={f32:{type:"f32",components:1},f16:{type:"f16",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<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",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},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}},Ir={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},rs={...Ir,mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"};function Je(r,e){let t={};for(let i of r.attributes){let n=Rr(r,e,i.name);n&&(t[i.name]=n)}return t}function Rt(r,e,t=16){let i=Je(r,e),n=new Array(t).fill(null);for(let s of Object.values(i))n[s.location]=s;return n}function Rr(r,e,t){let i=Lr(r,t),n=Dr(e,t);if(!i)return null;let s=Ce(i.type),o=gt(s),c=n?.vertexFormat||o,f=E(c);return{attributeName:n?.attributeName||i.name,bufferName:n?.bufferName||i.name,location:i.location,shaderType:i.type,primitiveType:s.primitiveType,shaderComponents:s.components,vertexFormat:c,bufferDataType:f.type,bufferComponents:f.components,normalized:f.normalized,integer:s.integer,stepMode:n?.stepMode||i.stepMode||"vertex",byteOffset:n?.byteOffset||0,byteStride:n?.byteStride||0}}function Lr(r,e){let t=r.attributes.find(i=>i.name===e);return t||l.warn(`shader layout attribute "${e}" not present in shader`),t||null}function Dr(r,e){Br(r);let t=Mr(r,e);return t||(t=Fr(r,e),t)?t:(l.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function Br(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 Mr(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 Fr(r,e){for(let t of r){let i=t.byteStride;if(typeof t.byteStride!="number")for(let s of t.attributes||[]){let o=E(s.format);i+=o.byteLength}let n=t.attributes?.find(s=>s.attribute===e);if(n)return{attributeName:n.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:i}}return null}var Qe=class extends u{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,Qe.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Rt(t.shaderLayout,t.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}},ie=Qe;a(ie,"defaultProps",{...u.defaultProps,shaderLayout:void 0,bufferLayout:[]});var Ze=class extends u{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Ze.defaultProps)}},ne=Ze;a(ne,"defaultProps",{...u.defaultProps,layout:void 0,buffers:{}});var et=class extends u{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,et.defaultProps)}},se=et;a(se,"defaultProps",{...u.defaultProps,type:void 0,count:void 0});var tt=class extends u{get[Symbol.toStringTag](){return"PipelineLayout"}constructor(e,t){super(e,t,tt.defaultProps)}},oe=tt;a(oe,"defaultProps",{...u.defaultProps,shaderLayout:{attributes:[],bindings:[]}});var Ie;function rt(r){return(!Ie||Ie.byteLength<r)&&(Ie=new ArrayBuffer(r)),Ie}function Lt(r,e){let t=rt(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}function zr(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function U(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":zr(r)}var $r=1024,H=class{layout={};byteLength;constructor(e,t={}){let i=0;for(let[s,o]of Object.entries(e)){let c=_e(o),{type:f,components:d}=c,p=d*(t?.[s]??1);i=dt(i,p);let L=i;i+=p,this.layout[s]={type:f,size:p,offset:L}}i+=(4-i%4)%4;let n=i*4;this.byteLength=Math.max(n,$r)}getData(e){let t=rt(this.byteLength),i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(let[n,s]of Object.entries(e)){let o=this.layout[n];if(!o){l.warn(`Supplied uniform value ${n} not present in uniform block layout`)();continue}let{type:c,size:f,offset:d}=o,p=i[c];if(f===1){if(typeof s!="number"&&typeof s!="boolean"){l.warn(`Supplied value for single component uniform ${n} is not a number: ${s}`)();continue}p[d]=Number(s)}else{if(!U(s)){l.warn(`Supplied value for multi component / array uniform ${n} is not a numeric array: ${s}`)();continue}p.set(s,d)}}return new Uint8Array(t,0,this.byteLength)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}};function Dt(r,e,t=16){if(r!==e)return!1;let i=r,n=e;if(!U(i))return!1;if(U(n)&&i.length===n.length){for(let s=0;s<i.length;++s)if(n[s]!==i[s])return!1}return!0}function Bt(r){return U(r)?r.slice():r}var N=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(n=>n.type==="uniform"&&n.name===e?.name);if(!t)throw new Error(e?.name);let i=t;for(let n of i.uniforms||[])this.bindingLayout[n.name]=n}}setUniforms(e){for(let[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){Dt(this.uniforms[e],t)||(this.uniforms[e]=Bt(t),this.modifiedUniforms[e]=!0,this.modified=!0)}};var Re=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[t,i]of Object.entries(e)){let n=t,s=new H(i.uniformTypes??{},i.uniformSizes??{});this.uniformBufferLayouts.set(n,s);let o=new N({name:t});o.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(n,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,i]of Object.entries(e))this.uniformBlocks.get(t)?.setUniforms(i);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,i){i&&this.setUniforms(i);let n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:h.UNIFORM|h.COPY_DST,byteLength:n}),o=this.getUniformBufferData(t);return s.write(o),s}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){let i=this.getUniformBufferByteLength(t),n=e.createBuffer({usage:h.UNIFORM|h.COPY_DST,byteLength:i});this.uniformBuffers.set(t,n)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(t);e||=i}return e&&l.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),i=this.uniformBuffers.get(e),n=!1;if(i&&t?.needsRedraw){n||=t.needsRedraw;let s=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i?.write(s);let o=this.uniformBlocks.get(e)?.getAllUniforms();l.log(4,`Writing to uniform buffer ${String(e)}`,s,o)()}return n}};function Mt(r,e,t,i){if(e<0||e>=r.width||t<0||t>=r.height)throw new Error("Coordinates out of bounds.");let n=t*r.bytesPerRow+e*r.bytesPerPixel,s=new DataView(r.arrayBuffer,n,r.bytesPerPixel),o=0,c=[];for(let f=0;f<4;f++){let d=i[f];if(d<=0)c.push(0);else{let p=Ur(s,o,d);c.push(p),o+=d}}return[c[0],c[1],c[2],c[3]]}function Ft(r,e,t,i){let n=e;for(let s=0;s<4;s++){let o=t[s],c=(1<<o)-1,f=i[s]&c;Hr(r,n,o,f),n+=o}}function Ur(r,e,t){if(e%8===0){let n=e/8;if(t===8&&n+1<=r.byteLength)return r.getUint8(n);if(t===16&&n+2<=r.byteLength)return r.getUint16(n,!1);if(t===32&&n+4<=r.byteLength)return r.getUint32(n,!1)}let i=0;for(let n=0;n<t;n++){let s=e+n,o=Math.floor(s/8),c=s%8,d=r.getUint8(o)>>7-c&1;i=i<<1|d}return i}function Hr(r,e,t,i){if(e%8===0){let n=e/8;if(t===8&&n+1<=r.byteLength){r.setUint8(n,i&255);return}else if(t===16&&n+2<=r.byteLength){r.setUint16(n,i&65535,!1);return}else if(t===32&&n+4<=r.byteLength){r.setUint32(n,i,!1);return}}for(let n=0;n<t;n++){let s=e+n,o=Math.floor(s/8),f=1<<7-s%8,d=i>>t-1-n&1,p=r.getUint8(o);p&=~f,d&&(p|=f),r.setUint8(o,p)}}ue(ae,Yt($t(),1));return Xt(ae);})();
|
|
17
|
+
</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 d=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(d)}}},X=Xe;c(X,"defaultProps",{...u.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});function Dr(r){return Br(r.source)||r.id||S(`unnamed ${r.stage}-shader`)}function Br(r,e="unnamed"){let i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return i?i[1]:e}var qe=class extends u{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,qe.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(n=>n.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:i})}resize(e){let t=!e;if(e){let[i,n]=Array.isArray(e)?e:[e.width,e.height];t=t||n!==this.height||i!==this.width,this.width=i,this.height=n}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,i)=>{if(typeof t=="string"){let n=this.createColorTexture(t,i);return this.attachResource(n),n.view}return t instanceof p?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 p?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:p.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:p.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let i=0;i<this.colorAttachments.length;++i)if(this.colorAttachments[i]){let n=this.colorAttachments[i].texture.clone({width:e,height:t});this.destroyAttachedResource(this.colorAttachments[i]),this.colorAttachments[i]=n.view,this.attachResource(n.view)}if(this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}},q=qe;c(q,"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||[]}},K=Ke;c(K,"defaultProps",{...u.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 R=class extends u{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=R.normalizeProps(e,t),super(e,t,R.defaultProps)}static normalizeProps(e,t){return t}},P=R;c(P,"defaultClearColor",[0,0,0,1]),c(P,"defaultClearDepth",1),c(P,"defaultClearStencil",0),c(P,"defaultProps",{...u.defaultProps,framebuffer:null,parameters:void 0,clearColor:R.defaultClearColor,clearColors:void 0,clearDepth:R.defaultClearDepth,clearStencil:R.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Je=class extends u{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,Je.defaultProps),this.shaderLayout=t.shaderLayout}},J=Je;c(J,"defaultProps",{...u.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var Qe=class extends u{constructor(e,t){super(e,t,Qe.defaultProps)}get[Symbol.toStringTag](){return"ComputePass"}},Q=Qe;c(Q,"defaultProps",{...u.defaultProps,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Ze=class extends u{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Ze.defaultProps)}},Z=Ze;c(Z,"defaultProps",{...u.defaultProps,measureExecutionTime:void 0});var et=class extends u{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,et.defaultProps)}},ee=et;c(ee,"defaultProps",{...u.defaultProps});function Re(r){return zr[r]}function Le(r){let[e,t]=Fr[r],i=e==="i32"||e==="u32",n=e!=="u32",s=Mr[e]*t;return{primitiveType:e,components:t,byteLength:s,integer:i,signed:n}}var Mr={f32:4,f16:2,i32:4,u32:4},Fr={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]},zr={f32:{type:"f32",components:1},f16:{type:"f16",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<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",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},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}},$r={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},ls={...$r,mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"};function tt(r,e){let t={};for(let i of r.attributes){let n=Ur(r,e,i.name);n&&(t[i.name]=n)}return t}function Bt(r,e,t=16){let i=tt(r,e),n=new Array(t).fill(null);for(let s of Object.values(i))n[s.location]=s;return n}function Ur(r,e,t){let i=Hr(r,t),n=Nr(e,t);if(!i)return null;let s=Le(i.type),a=Tt(s),o=n?.vertexFormat||a,f=_(o);return{attributeName:n?.attributeName||i.name,bufferName:n?.bufferName||i.name,location:i.location,shaderType:i.type,primitiveType:s.primitiveType,shaderComponents:s.components,vertexFormat:o,bufferDataType:f.type,bufferComponents:f.components,normalized:f.normalized,integer:s.integer,stepMode:n?.stepMode||i.stepMode||"vertex",byteOffset:n?.byteOffset||0,byteStride:n?.byteStride||0}}function Hr(r,e){let t=r.attributes.find(i=>i.name===e);return t||l.warn(`shader layout attribute "${e}" not present in shader`),t||null}function Nr(r,e){kr(r);let t=Wr(r,e);return t||(t=Gr(r,e),t)?t:(l.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function kr(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 Wr(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 Gr(r,e){for(let t of r){let i=t.byteStride;if(typeof t.byteStride!="number")for(let s of t.attributes||[]){let a=_(s.format);i+=a.byteLength}let n=t.attributes?.find(s=>s.attribute===e);if(n)return{attributeName:n.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:i}}return null}var rt=class extends u{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,rt.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Bt(t.shaderLayout,t.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}},te=rt;c(te,"defaultProps",{...u.defaultProps,shaderLayout:void 0,bufferLayout:[]});var it=class extends u{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,it.defaultProps)}},re=it;c(re,"defaultProps",{...u.defaultProps,layout:void 0,buffers:{}});var nt=class extends u{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,nt.defaultProps)}},ie=nt;c(ie,"defaultProps",{...u.defaultProps,type:void 0,count:void 0});var st=class extends u{[Symbol.toStringTag]="WEBGLFence";constructor(e,t={}){super(e,t,st.defaultProps)}},ne=st;c(ne,"defaultProps",{...u.defaultProps});var ot=class extends u{get[Symbol.toStringTag](){return"PipelineLayout"}constructor(e,t){super(e,t,ot.defaultProps)}},se=ot;c(se,"defaultProps",{...u.defaultProps,shaderLayout:{attributes:[],bindings:[]}});var De;function at(r){return(!De||De.byteLength<r)&&(De=new ArrayBuffer(r)),De}function Mt(r,e){let t=at(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}var Or=1024,$=class{layout={};byteLength;constructor(e,t={}){let i=0;for(let[n,s]of Object.entries(e))i=this._addToLayout(n,s,i,t?.[n]);i+=(4-i%4)%4,this.byteLength=Math.max(i*4,Or)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}getData(e){let t=at(this.byteLength),i={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(let[n,s]of Object.entries(e))this._writeCompositeValue(i,n,s);return new Uint8Array(t,0,this.byteLength)}_addToLayout(e,t,i,n=1){if(typeof t=="string"){let s=Re(t),a=s.components*n,o=ge(i,s.components);return this.layout[e]={offset:o,size:a,type:s.type},o+a}if(Array.isArray(t)){let s=t[0],a=n>1?n:t.length>1?t[1]:1,o=ge(i,4);for(let f=0;f<a;f++)o=this._addToLayout(`${e}[${f}]`,s,o);return o}if(typeof t=="object"){let s=ge(i,4);for(let[a,o]of Object.entries(t))s=this._addToLayout(`${e}.${a}`,o,s);return s}throw new Error(`Unsupported CompositeShaderType for ${e}`)}_writeCompositeValue(e,t,i){if(this.layout[t]){this._writeToBuffer(e,t,i);return}if(Array.isArray(i)){for(let n=0;n<i.length;n++){let s=i[n],a=`${t}[${n}]`;this._writeCompositeValue(e,a,s)}return}if(typeof i=="object"&&i!==null){for(let[n,s]of Object.entries(i)){let a=`${t}.${n}`;this._writeCompositeValue(e,a,s)}return}l.warn(`Unsupported uniform value for ${t}:`,i)()}_writeToBuffer(e,t,i){let n=this.layout[t];if(!n){l.warn(`Uniform ${t} not found in layout`)();return}let{type:s,size:a,offset:o}=n,f=e[s];a===1?f[o]=Number(i):f.set(i,o)}};function Vr(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Be(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":Vr(r)}function Ft(r,e,t=16){if(r!==e)return!1;let i=r,n=e;if(!Be(i))return!1;if(Be(n)&&i.length===n.length){for(let s=0;s<i.length;++s)if(n[s]!==i[s])return!1}return!0}function zt(r){return Be(r)?r.slice():r}var U=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(n=>n.type==="uniform"&&n.name===e?.name);if(!t)throw new Error(e?.name);let i=t;for(let n of i.uniforms||[])this.bindingLayout[n.name]=n}}setUniforms(e){for(let[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){Ft(this.uniforms[e],t)||(this.uniforms[e]=zt(t),this.modifiedUniforms[e]=!0,this.modified=!0)}};var Me=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[t,i]of Object.entries(e)){let n=t,s=new $(i.uniformTypes??{},i.uniformSizes??{});this.uniformBufferLayouts.set(n,s);let a=new U({name:t});a.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(n,a)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,i]of Object.entries(e))this.uniformBlocks.get(t)?.setUniforms(i);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,i){i&&this.setUniforms(i);let n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:h.UNIFORM|h.COPY_DST,byteLength:n}),a=this.getUniformBufferData(t);return s.write(a),s}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){let i=this.getUniformBufferByteLength(t),n=e.createBuffer({usage:h.UNIFORM|h.COPY_DST,byteLength:i});this.uniformBuffers.set(t,n)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(t);e||=i}return e&&l.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),i=this.uniformBuffers.get(e),n=!1;if(i&&t?.needsRedraw){n||=t.needsRedraw;let s=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i?.write(s);let a=this.uniformBlocks.get(e)?.getAllUniforms();l.log(4,`Writing to uniform buffer ${String(e)}`,s,a)()}return n}};function ct(r,e,t,i=0){let n=x.getInfo(t),s=n.bytesPerPixel/n.components,{bytesPerImage:a}=e,o=a*i,f=e.bytesPerImage/s;switch(t){case"rgba8unorm":case"bgra8unorm":case"rgba8uint":return new Uint8Array(r,o,f);case"r8unorm":return new Uint8Array(r,o,f);case"r16uint":case"rgba16uint":return new Uint16Array(r,o,f);case"r32uint":case"rgba32uint":return new Uint32Array(r,o,f);case"r32float":return new Float32Array(r,o,f);case"rgba16float":return new Uint16Array(r,o,f);case"rgba32float":return new Float32Array(r,o,f);default:throw new Error(`Unsupported format: ${t}`)}}function $t(r,e,t,i,n=0){let a=e.bytesPerImage/e.bytesPerPixel,o=i.subarray(0,a);ct(r,e,t,n).set(o,0)}function Ut(r,e,t,i){if(e<0||e>=r.width||t<0||t>=r.height)throw new Error("Coordinates out of bounds.");let n=t*r.bytesPerRow+e*r.bytesPerPixel,s=new DataView(r.arrayBuffer,n,r.bytesPerPixel),a=0,o=[];for(let f=0;f<4;f++){let d=i[f];if(d<=0)o.push(0);else{let b=jr(s,a,d);o.push(b),a+=d}}return[o[0],o[1],o[2],o[3]]}function Ht(r,e,t,i){let n=e;for(let s=0;s<4;s++){let a=t[s],o=(1<<a)-1,f=i[s]&o;Yr(r,n,a,f),n+=a}}function jr(r,e,t){if(e%8===0){let n=e/8;if(t===8&&n+1<=r.byteLength)return r.getUint8(n);if(t===16&&n+2<=r.byteLength)return r.getUint16(n,!1);if(t===32&&n+4<=r.byteLength)return r.getUint32(n,!1)}let i=0;for(let n=0;n<t;n++){let s=e+n,a=Math.floor(s/8),o=s%8,d=r.getUint8(a)>>7-o&1;i=i<<1|d}return i}function Yr(r,e,t,i){if(e%8===0){let n=e/8;if(t===8&&n+1<=r.byteLength){r.setUint8(n,i&255);return}else if(t===16&&n+2<=r.byteLength){r.setUint16(n,i&65535,!1);return}else if(t===32&&n+4<=r.byteLength){r.setUint32(n,i,!1);return}}for(let n=0;n<t;n++){let s=e+n,a=Math.floor(s/8),f=1<<7-s%8,d=i>>t-1-n&1,b=r.getUint8(a);b&=~f,d&&(b|=f),r.setUint8(a,b)}}ue(oe,Jt(kt(),1));return Qt(oe);})();
|
|
18
18
|
return __exports__;
|
|
19
19
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/effects",
|
|
3
|
-
"version": "9.2
|
|
3
|
+
"version": "9.3.0-alpha.2",
|
|
4
4
|
"description": "Post-processing effects for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,12 +46,11 @@
|
|
|
46
46
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@luma.gl/shadertools": "
|
|
49
|
+
"@luma.gl/shadertools": "9.2.0-alpha.6"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@math.gl/core": "^4.1.0",
|
|
53
|
-
"@math.gl/types": "^4.1.0"
|
|
54
|
-
"wgsl_reflect": "^1.0.1"
|
|
53
|
+
"@math.gl/types": "^4.1.0"
|
|
55
54
|
},
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "7fedf8d8902f58490a4ffca9a873daee3c732f24"
|
|
57
56
|
}
|