@deck.gl/core 9.3.0-alpha.5 → 9.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +876 -315
- package/dist/index.cjs +145 -67
- package/dist/index.cjs.map +3 -3
- package/dist/lib/attribute/attribute.d.ts +2 -0
- package/dist/lib/attribute/attribute.d.ts.map +1 -1
- package/dist/lib/attribute/attribute.js +57 -27
- package/dist/lib/attribute/attribute.js.map +1 -1
- package/dist/lib/constants.d.ts +11 -6
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +8 -9
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/deck.d.ts.map +1 -1
- package/dist/lib/deck.js +1 -1
- package/dist/lib/deck.js.map +1 -1
- package/dist/lib/init.js +2 -2
- package/dist/lib/init.js.map +1 -1
- package/dist/lib/layer.d.ts.map +1 -1
- package/dist/lib/layer.js +4 -6
- package/dist/lib/layer.js.map +1 -1
- package/dist/passes/layers-pass.d.ts.map +1 -1
- package/dist/passes/layers-pass.js +13 -0
- package/dist/passes/layers-pass.js.map +1 -1
- package/dist/shaderlib/index.d.ts +1 -2
- package/dist/shaderlib/index.d.ts.map +1 -1
- package/dist/shaderlib/index.js +1 -2
- package/dist/shaderlib/index.js.map +1 -1
- package/dist/shaderlib/picking/picking.d.ts +4 -4
- package/dist/shaderlib/picking/picking.js +4 -4
- package/dist/shaderlib/picking/picking.js.map +1 -1
- package/dist/shaderlib/project/project-functions.d.ts.map +1 -1
- package/dist/shaderlib/project/project-functions.js +19 -10
- package/dist/shaderlib/project/project-functions.js.map +1 -1
- package/dist/shaderlib/project/project.glsl.d.ts.map +1 -1
- package/dist/shaderlib/project/project.glsl.js +10 -5
- package/dist/shaderlib/project/project.glsl.js.map +1 -1
- package/dist/shaderlib/project/project.wgsl.d.ts.map +1 -1
- package/dist/shaderlib/project/project.wgsl.js +10 -5
- package/dist/shaderlib/project/project.wgsl.js.map +1 -1
- package/dist/shaderlib/project/viewport-uniforms.d.ts +1 -0
- package/dist/shaderlib/project/viewport-uniforms.d.ts.map +1 -1
- package/dist/shaderlib/project/viewport-uniforms.js +28 -17
- package/dist/shaderlib/project/viewport-uniforms.js.map +1 -1
- package/dist/shaderlib/shadow/shadow.d.ts +1 -1
- package/dist/shaderlib/shadow/shadow.d.ts.map +1 -1
- package/dist/shaderlib/shadow/shadow.js +3 -2
- package/dist/shaderlib/shadow/shadow.js.map +1 -1
- package/dist/utils/texture.d.ts.map +1 -1
- package/dist/utils/texture.js +3 -0
- package/dist/utils/texture.js.map +1 -1
- package/dist.min.js +162 -99
- package/package.json +8 -8
- package/src/lib/attribute/attribute.ts +70 -27
- package/src/lib/constants.ts +18 -12
- package/src/lib/deck.ts +1 -1
- package/src/lib/layer.ts +4 -6
- package/src/passes/layers-pass.ts +21 -1
- package/src/shaderlib/index.ts +1 -3
- package/src/shaderlib/picking/picking.ts +4 -4
- package/src/shaderlib/project/project-functions.ts +20 -10
- package/src/shaderlib/project/project.glsl.ts +15 -6
- package/src/shaderlib/project/project.wgsl.ts +15 -6
- package/src/shaderlib/project/viewport-uniforms.ts +30 -21
- package/src/shaderlib/shadow/shadow.ts +6 -2
- package/src/utils/texture.ts +2 -0
package/dist/dist.dev.js
CHANGED
|
@@ -1569,12 +1569,51 @@ var __exports__ = (() => {
|
|
|
1569
1569
|
}
|
|
1570
1570
|
return `${dataType}x${components}`;
|
|
1571
1571
|
case "snorm8":
|
|
1572
|
+
if (components === 1) {
|
|
1573
|
+
return "snorm8";
|
|
1574
|
+
}
|
|
1575
|
+
if (components === 3) {
|
|
1576
|
+
return "snorm8x3-webgl";
|
|
1577
|
+
}
|
|
1578
|
+
return `${dataType}x${components}`;
|
|
1572
1579
|
case "uint8":
|
|
1573
1580
|
case "sint8":
|
|
1581
|
+
if (components === 1 || components === 3) {
|
|
1582
|
+
throw new Error(`size: ${components}`);
|
|
1583
|
+
}
|
|
1584
|
+
return `${dataType}x${components}`;
|
|
1574
1585
|
case "uint16":
|
|
1586
|
+
if (components === 1) {
|
|
1587
|
+
return "uint16";
|
|
1588
|
+
}
|
|
1589
|
+
if (components === 3) {
|
|
1590
|
+
return "uint16x3-webgl";
|
|
1591
|
+
}
|
|
1592
|
+
return `${dataType}x${components}`;
|
|
1575
1593
|
case "sint16":
|
|
1594
|
+
if (components === 1) {
|
|
1595
|
+
return "sint16";
|
|
1596
|
+
}
|
|
1597
|
+
if (components === 3) {
|
|
1598
|
+
return "sint16x3-webgl";
|
|
1599
|
+
}
|
|
1600
|
+
return `${dataType}x${components}`;
|
|
1576
1601
|
case "unorm16":
|
|
1602
|
+
if (components === 1) {
|
|
1603
|
+
return "unorm16";
|
|
1604
|
+
}
|
|
1605
|
+
if (components === 3) {
|
|
1606
|
+
return "unorm16x3-webgl";
|
|
1607
|
+
}
|
|
1608
|
+
return `${dataType}x${components}`;
|
|
1577
1609
|
case "snorm16":
|
|
1610
|
+
if (components === 1) {
|
|
1611
|
+
return "snorm16";
|
|
1612
|
+
}
|
|
1613
|
+
if (components === 3) {
|
|
1614
|
+
return "snorm16x3-webgl";
|
|
1615
|
+
}
|
|
1616
|
+
return `${dataType}x${components}`;
|
|
1578
1617
|
case "float16":
|
|
1579
1618
|
if (components === 1 || components === 3) {
|
|
1580
1619
|
throw new Error(`size: ${components}`);
|
|
@@ -2308,7 +2347,7 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2308
2347
|
throw new Error("_createBindGroupLayoutWebGPU() not implemented");
|
|
2309
2348
|
}
|
|
2310
2349
|
/** Internal WebGPU-only helper for creating a native bind group. */
|
|
2311
|
-
_createBindGroupWebGPU(_bindGroupLayout, _shaderLayout, _bindings, _group) {
|
|
2350
|
+
_createBindGroupWebGPU(_bindGroupLayout, _shaderLayout, _bindings, _group, _label) {
|
|
2312
2351
|
throw new Error("_createBindGroupWebGPU() not implemented");
|
|
2313
2352
|
}
|
|
2314
2353
|
/**
|
|
@@ -2522,7 +2561,7 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2522
2561
|
VERSION = (
|
|
2523
2562
|
// Version detection using build plugin
|
|
2524
2563
|
// @ts-expect-error no-undef
|
|
2525
|
-
true ? "9.3.
|
|
2564
|
+
true ? "9.3.2" : "running from source"
|
|
2526
2565
|
);
|
|
2527
2566
|
spector;
|
|
2528
2567
|
preregisteredAdapters = /* @__PURE__ */ new Map();
|
|
@@ -2820,11 +2859,11 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2820
2859
|
return document.body;
|
|
2821
2860
|
}
|
|
2822
2861
|
function getCanvasFromDOM(canvasId) {
|
|
2823
|
-
const
|
|
2824
|
-
if (!CanvasSurface.isHTMLCanvas(
|
|
2862
|
+
const canvas = document.getElementById(canvasId);
|
|
2863
|
+
if (!CanvasSurface.isHTMLCanvas(canvas)) {
|
|
2825
2864
|
throw new Error("Object is not a canvas element");
|
|
2826
2865
|
}
|
|
2827
|
-
return
|
|
2866
|
+
return canvas;
|
|
2828
2867
|
}
|
|
2829
2868
|
function createCanvasElement(props) {
|
|
2830
2869
|
const { width, height } = props;
|
|
@@ -2878,11 +2917,11 @@ or create a device with the 'debug: true' prop.`;
|
|
|
2878
2917
|
init_promise_utils();
|
|
2879
2918
|
init_assert2();
|
|
2880
2919
|
_CanvasSurface = class {
|
|
2881
|
-
static isHTMLCanvas(
|
|
2882
|
-
return typeof HTMLCanvasElement !== "undefined" &&
|
|
2920
|
+
static isHTMLCanvas(canvas) {
|
|
2921
|
+
return typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement;
|
|
2883
2922
|
}
|
|
2884
|
-
static isOffscreenCanvas(
|
|
2885
|
-
return typeof OffscreenCanvas !== "undefined" &&
|
|
2923
|
+
static isOffscreenCanvas(canvas) {
|
|
2924
|
+
return typeof OffscreenCanvas !== "undefined" && canvas instanceof OffscreenCanvas;
|
|
2886
2925
|
}
|
|
2887
2926
|
id;
|
|
2888
2927
|
props;
|
|
@@ -7465,7 +7504,7 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
7465
7504
|
});
|
|
7466
7505
|
|
|
7467
7506
|
// ../../node_modules/@luma.gl/webgl/dist/context/helpers/create-browser-context.js
|
|
7468
|
-
function createBrowserContext(
|
|
7507
|
+
function createBrowserContext(canvas, props, webglContextAttributes) {
|
|
7469
7508
|
let errorMessage = "";
|
|
7470
7509
|
const onCreateError = (event) => {
|
|
7471
7510
|
const statusMessage = event.statusMessage;
|
|
@@ -7473,7 +7512,7 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
7473
7512
|
errorMessage ||= statusMessage;
|
|
7474
7513
|
}
|
|
7475
7514
|
};
|
|
7476
|
-
|
|
7515
|
+
canvas.addEventListener("webglcontextcreationerror", onCreateError, false);
|
|
7477
7516
|
const allowSoftwareRenderer = webglContextAttributes.failIfMajorPerformanceCaveat !== true;
|
|
7478
7517
|
const webglProps = {
|
|
7479
7518
|
preserveDrawingBuffer: true,
|
|
@@ -7483,18 +7522,18 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
7483
7522
|
};
|
|
7484
7523
|
let gl = null;
|
|
7485
7524
|
try {
|
|
7486
|
-
gl ||=
|
|
7525
|
+
gl ||= canvas.getContext("webgl2", webglProps);
|
|
7487
7526
|
if (!gl && webglProps.failIfMajorPerformanceCaveat) {
|
|
7488
7527
|
errorMessage ||= "Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.";
|
|
7489
7528
|
}
|
|
7490
7529
|
let softwareRenderer = false;
|
|
7491
7530
|
if (!gl && allowSoftwareRenderer) {
|
|
7492
7531
|
webglProps.failIfMajorPerformanceCaveat = false;
|
|
7493
|
-
gl =
|
|
7532
|
+
gl = canvas.getContext("webgl2", webglProps);
|
|
7494
7533
|
softwareRenderer = true;
|
|
7495
7534
|
}
|
|
7496
7535
|
if (!gl) {
|
|
7497
|
-
gl =
|
|
7536
|
+
gl = canvas.getContext("webgl", {});
|
|
7498
7537
|
if (gl) {
|
|
7499
7538
|
gl = null;
|
|
7500
7539
|
errorMessage ||= "Your browser only supports WebGL1";
|
|
@@ -7507,11 +7546,11 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
7507
7546
|
const luma2 = getWebGLContextData(gl);
|
|
7508
7547
|
luma2.softwareRenderer = softwareRenderer;
|
|
7509
7548
|
const { onContextLost, onContextRestored } = props;
|
|
7510
|
-
|
|
7511
|
-
|
|
7549
|
+
canvas.addEventListener("webglcontextlost", (event) => onContextLost(event), false);
|
|
7550
|
+
canvas.addEventListener("webglcontextrestored", (event) => onContextRestored(event), false);
|
|
7512
7551
|
return gl;
|
|
7513
7552
|
} finally {
|
|
7514
|
-
|
|
7553
|
+
canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
|
|
7515
7554
|
}
|
|
7516
7555
|
}
|
|
7517
7556
|
var init_create_browser_context = __esm({
|
|
@@ -8610,11 +8649,11 @@ ${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.m
|
|
|
8610
8649
|
continue;
|
|
8611
8650
|
}
|
|
8612
8651
|
let lineNum = parseInt(lineNumber, 10);
|
|
8613
|
-
if (isNaN(lineNum)) {
|
|
8652
|
+
if (Number.isNaN(lineNum)) {
|
|
8614
8653
|
lineNum = 0;
|
|
8615
8654
|
}
|
|
8616
8655
|
let linePos = parseInt(linePosition, 10);
|
|
8617
|
-
if (isNaN(linePos)) {
|
|
8656
|
+
if (Number.isNaN(linePos)) {
|
|
8618
8657
|
linePos = 0;
|
|
8619
8658
|
}
|
|
8620
8659
|
messages.push({
|
|
@@ -9884,29 +9923,29 @@ ${source3}`;
|
|
|
9884
9923
|
if (!options?.disableWarnings) {
|
|
9885
9924
|
log.warn(`No binding "${name2}" in render pipeline "${this.id}", expected one of ${validBindings}`, value)();
|
|
9886
9925
|
}
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9926
|
+
} else {
|
|
9927
|
+
if (!value) {
|
|
9928
|
+
log.warn(`Unsetting binding "${name2}" in render pipeline "${this.id}"`)();
|
|
9929
|
+
}
|
|
9930
|
+
switch (binding.type) {
|
|
9931
|
+
case "uniform":
|
|
9932
|
+
if (!(value instanceof WEBGLBuffer) && !(value.buffer instanceof WEBGLBuffer)) {
|
|
9933
|
+
throw new Error("buffer value");
|
|
9934
|
+
}
|
|
9935
|
+
break;
|
|
9936
|
+
case "texture":
|
|
9937
|
+
if (!(value instanceof WEBGLTextureView || value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
9938
|
+
throw new Error(`${this} Bad texture binding for ${name2}`);
|
|
9939
|
+
}
|
|
9940
|
+
break;
|
|
9941
|
+
case "sampler":
|
|
9942
|
+
log.warn(`Ignoring sampler ${name2}`)();
|
|
9943
|
+
break;
|
|
9944
|
+
default:
|
|
9945
|
+
throw new Error(binding.type);
|
|
9946
|
+
}
|
|
9947
|
+
this.bindings[name2] = value;
|
|
9908
9948
|
}
|
|
9909
|
-
this.bindings[name2] = value;
|
|
9910
9949
|
}
|
|
9911
9950
|
}
|
|
9912
9951
|
/** @todo needed for portable model
|
|
@@ -11963,7 +12002,10 @@ ${source3}`;
|
|
|
11963
12002
|
this.spectorJS = initializeSpectorJS({ ...this.props, gl: this.handle });
|
|
11964
12003
|
const contextData = getWebGLContextData(this.handle);
|
|
11965
12004
|
contextData.device = this;
|
|
11966
|
-
|
|
12005
|
+
if (!contextData.extensions) {
|
|
12006
|
+
contextData.extensions = {};
|
|
12007
|
+
}
|
|
12008
|
+
this.extensions = contextData.extensions;
|
|
11967
12009
|
this.info = getDeviceInfo(this.gl, this.extensions);
|
|
11968
12010
|
this.limits = new WebGLDeviceLimits(this.gl);
|
|
11969
12011
|
this.features = new WebGLDeviceFeatures(this.gl, this.extensions, this.props._disabledFeatures);
|
|
@@ -12775,13 +12817,13 @@ ${source3}`;
|
|
|
12775
12817
|
if (!this.device || !canvasContext) {
|
|
12776
12818
|
throw new Error("loop");
|
|
12777
12819
|
}
|
|
12778
|
-
const
|
|
12820
|
+
const canvas = canvasContext?.canvas;
|
|
12779
12821
|
const useDevicePixels = canvasContext.props.useDevicePixels;
|
|
12780
12822
|
this.animationProps = {
|
|
12781
12823
|
animationLoop: this,
|
|
12782
12824
|
device: this.device,
|
|
12783
12825
|
canvasContext,
|
|
12784
|
-
canvas
|
|
12826
|
+
canvas,
|
|
12785
12827
|
// @ts-expect-error Deprecated
|
|
12786
12828
|
useDevicePixels,
|
|
12787
12829
|
timeline: this.timeline,
|
|
@@ -13373,9 +13415,27 @@ ${source3}`;
|
|
|
13373
13415
|
return true;
|
|
13374
13416
|
}
|
|
13375
13417
|
function formatShaderModuleUniformLayoutError(validationResult) {
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13418
|
+
const { expectedUniformNames, actualUniformNames } = validationResult;
|
|
13419
|
+
const missingUniformNames = expectedUniformNames.filter((uniformName) => !actualUniformNames.includes(uniformName));
|
|
13420
|
+
const unexpectedUniformNames = actualUniformNames.filter((uniformName) => !expectedUniformNames.includes(uniformName));
|
|
13421
|
+
const mismatchDetails = [
|
|
13422
|
+
`Expected ${expectedUniformNames.length} fields, found ${actualUniformNames.length}.`
|
|
13423
|
+
];
|
|
13424
|
+
const firstMismatchDescription = getFirstUniformMismatchDescription(expectedUniformNames, actualUniformNames);
|
|
13425
|
+
if (firstMismatchDescription) {
|
|
13426
|
+
mismatchDetails.push(firstMismatchDescription);
|
|
13427
|
+
}
|
|
13428
|
+
if (missingUniformNames.length) {
|
|
13429
|
+
mismatchDetails.push(`Missing from shader block (${missingUniformNames.length}): ${formatUniformNameList(missingUniformNames)}.`);
|
|
13430
|
+
}
|
|
13431
|
+
if (unexpectedUniformNames.length) {
|
|
13432
|
+
mismatchDetails.push(`Unexpected in shader block (${unexpectedUniformNames.length}): ${formatUniformNameList(unexpectedUniformNames)}.`);
|
|
13433
|
+
}
|
|
13434
|
+
if (expectedUniformNames.length <= 12 && actualUniformNames.length <= 12 && (missingUniformNames.length || unexpectedUniformNames.length)) {
|
|
13435
|
+
mismatchDetails.push(`Expected: ${expectedUniformNames.join(", ")}.`);
|
|
13436
|
+
mismatchDetails.push(`Actual: ${actualUniformNames.join(", ")}.`);
|
|
13437
|
+
}
|
|
13438
|
+
return `${validationResult.moduleName}: ${validationResult.stage} shader uniform block ${validationResult.uniformBlockName} does not match module.uniformTypes. ${mismatchDetails.join(" ")}`;
|
|
13379
13439
|
}
|
|
13380
13440
|
function stripShaderComments(shaderSource) {
|
|
13381
13441
|
return shaderSource.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
|
|
@@ -13383,6 +13443,28 @@ Actual: ${validationResult.actualUniformNames.join(", ")}`;
|
|
|
13383
13443
|
function normalizeWhitespace(value) {
|
|
13384
13444
|
return value.replace(/\s+/g, " ").trim();
|
|
13385
13445
|
}
|
|
13446
|
+
function getFirstUniformMismatchDescription(expectedUniformNames, actualUniformNames) {
|
|
13447
|
+
const minimumLength = Math.min(expectedUniformNames.length, actualUniformNames.length);
|
|
13448
|
+
for (let index = 0; index < minimumLength; index++) {
|
|
13449
|
+
if (expectedUniformNames[index] !== actualUniformNames[index]) {
|
|
13450
|
+
return `First mismatch at field ${index + 1}: expected ${expectedUniformNames[index]}, found ${actualUniformNames[index]}.`;
|
|
13451
|
+
}
|
|
13452
|
+
}
|
|
13453
|
+
if (expectedUniformNames.length > actualUniformNames.length) {
|
|
13454
|
+
return `Shader block ends after field ${actualUniformNames.length}; expected next field ${expectedUniformNames[actualUniformNames.length]}.`;
|
|
13455
|
+
}
|
|
13456
|
+
if (actualUniformNames.length > expectedUniformNames.length) {
|
|
13457
|
+
return `Shader block has extra field ${actualUniformNames.length}: ${actualUniformNames[expectedUniformNames.length]}.`;
|
|
13458
|
+
}
|
|
13459
|
+
return null;
|
|
13460
|
+
}
|
|
13461
|
+
function formatUniformNameList(uniformNames, maxNames = 8) {
|
|
13462
|
+
if (uniformNames.length <= maxNames) {
|
|
13463
|
+
return uniformNames.join(", ");
|
|
13464
|
+
}
|
|
13465
|
+
const remainingCount = uniformNames.length - maxNames;
|
|
13466
|
+
return `${uniformNames.slice(0, maxNames).join(", ")}, ... (${remainingCount} more)`;
|
|
13467
|
+
}
|
|
13386
13468
|
|
|
13387
13469
|
// ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/platform-defines.js
|
|
13388
13470
|
function getPlatformShaderDefines(platformInfo) {
|
|
@@ -13568,12 +13650,156 @@ Actual: ${validationResult.actualUniformNames.join(", ")}`;
|
|
|
13568
13650
|
return version2;
|
|
13569
13651
|
}
|
|
13570
13652
|
|
|
13653
|
+
// ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/wgsl-binding-scan.js
|
|
13654
|
+
var WGSL_BINDABLE_VARIABLE_PATTERN = "(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)";
|
|
13655
|
+
var WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN = "\\s*";
|
|
13656
|
+
var MODULE_WGSL_BINDING_DECLARATION_REGEXES = [
|
|
13657
|
+
new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g"),
|
|
13658
|
+
new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g")
|
|
13659
|
+
];
|
|
13660
|
+
var WGSL_BINDING_DECLARATION_REGEXES = [
|
|
13661
|
+
new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g"),
|
|
13662
|
+
new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g")
|
|
13663
|
+
];
|
|
13664
|
+
var WGSL_EXPLICIT_BINDING_DECLARATION_REGEXES = [
|
|
13665
|
+
new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g"),
|
|
13666
|
+
new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@binding\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g")
|
|
13667
|
+
];
|
|
13668
|
+
var WGSL_AUTO_BINDING_DECLARATION_REGEXES = [
|
|
13669
|
+
new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g"),
|
|
13670
|
+
new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g"),
|
|
13671
|
+
new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g"),
|
|
13672
|
+
new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${WGSL_BINDABLE_VARIABLE_PATTERN}`, "g")
|
|
13673
|
+
];
|
|
13674
|
+
function maskWGSLComments(source3) {
|
|
13675
|
+
const maskedCharacters = source3.split("");
|
|
13676
|
+
let index = 0;
|
|
13677
|
+
let blockCommentDepth = 0;
|
|
13678
|
+
let inLineComment = false;
|
|
13679
|
+
let inString = false;
|
|
13680
|
+
let isEscaped = false;
|
|
13681
|
+
while (index < source3.length) {
|
|
13682
|
+
const character = source3[index];
|
|
13683
|
+
const nextCharacter = source3[index + 1];
|
|
13684
|
+
if (inString) {
|
|
13685
|
+
if (isEscaped) {
|
|
13686
|
+
isEscaped = false;
|
|
13687
|
+
} else if (character === "\\") {
|
|
13688
|
+
isEscaped = true;
|
|
13689
|
+
} else if (character === '"') {
|
|
13690
|
+
inString = false;
|
|
13691
|
+
}
|
|
13692
|
+
index++;
|
|
13693
|
+
continue;
|
|
13694
|
+
}
|
|
13695
|
+
if (inLineComment) {
|
|
13696
|
+
if (character === "\n" || character === "\r") {
|
|
13697
|
+
inLineComment = false;
|
|
13698
|
+
} else {
|
|
13699
|
+
maskedCharacters[index] = " ";
|
|
13700
|
+
}
|
|
13701
|
+
index++;
|
|
13702
|
+
continue;
|
|
13703
|
+
}
|
|
13704
|
+
if (blockCommentDepth > 0) {
|
|
13705
|
+
if (character === "/" && nextCharacter === "*") {
|
|
13706
|
+
maskedCharacters[index] = " ";
|
|
13707
|
+
maskedCharacters[index + 1] = " ";
|
|
13708
|
+
blockCommentDepth++;
|
|
13709
|
+
index += 2;
|
|
13710
|
+
continue;
|
|
13711
|
+
}
|
|
13712
|
+
if (character === "*" && nextCharacter === "/") {
|
|
13713
|
+
maskedCharacters[index] = " ";
|
|
13714
|
+
maskedCharacters[index + 1] = " ";
|
|
13715
|
+
blockCommentDepth--;
|
|
13716
|
+
index += 2;
|
|
13717
|
+
continue;
|
|
13718
|
+
}
|
|
13719
|
+
if (character !== "\n" && character !== "\r") {
|
|
13720
|
+
maskedCharacters[index] = " ";
|
|
13721
|
+
}
|
|
13722
|
+
index++;
|
|
13723
|
+
continue;
|
|
13724
|
+
}
|
|
13725
|
+
if (character === '"') {
|
|
13726
|
+
inString = true;
|
|
13727
|
+
index++;
|
|
13728
|
+
continue;
|
|
13729
|
+
}
|
|
13730
|
+
if (character === "/" && nextCharacter === "/") {
|
|
13731
|
+
maskedCharacters[index] = " ";
|
|
13732
|
+
maskedCharacters[index + 1] = " ";
|
|
13733
|
+
inLineComment = true;
|
|
13734
|
+
index += 2;
|
|
13735
|
+
continue;
|
|
13736
|
+
}
|
|
13737
|
+
if (character === "/" && nextCharacter === "*") {
|
|
13738
|
+
maskedCharacters[index] = " ";
|
|
13739
|
+
maskedCharacters[index + 1] = " ";
|
|
13740
|
+
blockCommentDepth = 1;
|
|
13741
|
+
index += 2;
|
|
13742
|
+
continue;
|
|
13743
|
+
}
|
|
13744
|
+
index++;
|
|
13745
|
+
}
|
|
13746
|
+
return maskedCharacters.join("");
|
|
13747
|
+
}
|
|
13748
|
+
function getWGSLBindingDeclarationMatches(source3, regexes) {
|
|
13749
|
+
const maskedSource = maskWGSLComments(source3);
|
|
13750
|
+
const matches3 = [];
|
|
13751
|
+
for (const regex of regexes) {
|
|
13752
|
+
regex.lastIndex = 0;
|
|
13753
|
+
let match;
|
|
13754
|
+
match = regex.exec(maskedSource);
|
|
13755
|
+
while (match) {
|
|
13756
|
+
const isBindingFirst = regex === regexes[0];
|
|
13757
|
+
const index = match.index;
|
|
13758
|
+
const length4 = match[0].length;
|
|
13759
|
+
matches3.push({
|
|
13760
|
+
match: source3.slice(index, index + length4),
|
|
13761
|
+
index,
|
|
13762
|
+
length: length4,
|
|
13763
|
+
bindingToken: match[isBindingFirst ? 1 : 2],
|
|
13764
|
+
groupToken: match[isBindingFirst ? 2 : 1],
|
|
13765
|
+
accessDeclaration: match[3]?.trim(),
|
|
13766
|
+
name: match[4]
|
|
13767
|
+
});
|
|
13768
|
+
match = regex.exec(maskedSource);
|
|
13769
|
+
}
|
|
13770
|
+
}
|
|
13771
|
+
return matches3.sort((left, right) => left.index - right.index);
|
|
13772
|
+
}
|
|
13773
|
+
function replaceWGSLBindingDeclarationMatches(source3, regexes, replacer) {
|
|
13774
|
+
const matches3 = getWGSLBindingDeclarationMatches(source3, regexes);
|
|
13775
|
+
if (!matches3.length) {
|
|
13776
|
+
return source3;
|
|
13777
|
+
}
|
|
13778
|
+
let relocatedSource = "";
|
|
13779
|
+
let lastIndex = 0;
|
|
13780
|
+
for (const match of matches3) {
|
|
13781
|
+
relocatedSource += source3.slice(lastIndex, match.index);
|
|
13782
|
+
relocatedSource += replacer(match);
|
|
13783
|
+
lastIndex = match.index + match.length;
|
|
13784
|
+
}
|
|
13785
|
+
relocatedSource += source3.slice(lastIndex);
|
|
13786
|
+
return relocatedSource;
|
|
13787
|
+
}
|
|
13788
|
+
function hasWGSLAutoBinding(source3) {
|
|
13789
|
+
return /@binding\(\s*auto\s*\)/.test(maskWGSLComments(source3));
|
|
13790
|
+
}
|
|
13791
|
+
function getFirstWGSLAutoBindingDeclarationMatch(source3, regexes) {
|
|
13792
|
+
const autoBindingRegexes = regexes === MODULE_WGSL_BINDING_DECLARATION_REGEXES || regexes === WGSL_BINDING_DECLARATION_REGEXES ? WGSL_AUTO_BINDING_DECLARATION_REGEXES : regexes;
|
|
13793
|
+
return getWGSLBindingDeclarationMatches(source3, autoBindingRegexes).find((declarationMatch) => declarationMatch.bindingToken === "auto");
|
|
13794
|
+
}
|
|
13795
|
+
|
|
13571
13796
|
// ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/wgsl-binding-debug.js
|
|
13572
13797
|
var WGSL_BINDING_DEBUG_REGEXES = [
|
|
13573
|
-
|
|
13574
|
-
|
|
13798
|
+
new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${WGSL_BINDABLE_VARIABLE_PATTERN}\\s*:\\s*([^;]+);`, "g"),
|
|
13799
|
+
new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${WGSL_BINDABLE_VARIABLE_PATTERN}\\s*:\\s*([^;]+);`, "g")
|
|
13575
13800
|
];
|
|
13576
13801
|
function getShaderBindingDebugRowsFromWGSL(source3, bindingAssignments = []) {
|
|
13802
|
+
const maskedSource = maskWGSLComments(source3);
|
|
13577
13803
|
const assignmentMap = /* @__PURE__ */ new Map();
|
|
13578
13804
|
for (const bindingAssignment of bindingAssignments) {
|
|
13579
13805
|
assignmentMap.set(getBindingAssignmentKey(bindingAssignment.name, bindingAssignment.group, bindingAssignment.location), bindingAssignment.moduleName);
|
|
@@ -13582,7 +13808,8 @@ Actual: ${validationResult.actualUniformNames.join(", ")}`;
|
|
|
13582
13808
|
for (const regex of WGSL_BINDING_DEBUG_REGEXES) {
|
|
13583
13809
|
regex.lastIndex = 0;
|
|
13584
13810
|
let match;
|
|
13585
|
-
|
|
13811
|
+
match = regex.exec(maskedSource);
|
|
13812
|
+
while (match) {
|
|
13586
13813
|
const isBindingFirst = regex === WGSL_BINDING_DEBUG_REGEXES[0];
|
|
13587
13814
|
const binding = Number(match[isBindingFirst ? 1 : 2]);
|
|
13588
13815
|
const group = Number(match[isBindingFirst ? 2 : 1]);
|
|
@@ -13599,6 +13826,7 @@ Actual: ${validationResult.actualUniformNames.join(", ")}`;
|
|
|
13599
13826
|
accessDeclaration,
|
|
13600
13827
|
resourceType
|
|
13601
13828
|
}));
|
|
13829
|
+
match = regex.exec(maskedSource);
|
|
13602
13830
|
}
|
|
13603
13831
|
}
|
|
13604
13832
|
return rows.sort((left, right) => {
|
|
@@ -13710,14 +13938,6 @@ Actual: ${validationResult.actualUniformNames.join(", ")}`;
|
|
|
13710
13938
|
|
|
13711
13939
|
${DECLARATION_INJECT_MARKER}
|
|
13712
13940
|
`;
|
|
13713
|
-
var MODULE_WGSL_BINDING_DECLARATION_REGEXES = [
|
|
13714
|
-
/@binding\(\s*(auto|\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g,
|
|
13715
|
-
/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(auto|\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g
|
|
13716
|
-
];
|
|
13717
|
-
var WGSL_BINDING_DECLARATION_REGEXES = [
|
|
13718
|
-
/@binding\(\s*(\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g,
|
|
13719
|
-
/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g
|
|
13720
|
-
];
|
|
13721
13941
|
var RESERVED_APPLICATION_GROUP_0_BINDING_LIMIT = 100;
|
|
13722
13942
|
var FRAGMENT_SHADER_PROLOGUE = (
|
|
13723
13943
|
/* glsl */
|
|
@@ -13797,7 +14017,8 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
13797
14017
|
}
|
|
13798
14018
|
}
|
|
13799
14019
|
const modulesToInject = modules;
|
|
13800
|
-
const
|
|
14020
|
+
const applicationRelocation = relocateWGSLApplicationBindings(coreSource);
|
|
14021
|
+
const usedBindingsByGroup = getUsedBindingsByGroupFromApplicationWGSL(applicationRelocation.source);
|
|
13801
14022
|
const reservedBindingKeysByGroup = reserveRegisteredModuleBindings(modulesToInject, options._bindingRegistry, usedBindingsByGroup);
|
|
13802
14023
|
const bindingAssignments = [];
|
|
13803
14024
|
for (const module of modulesToInject) {
|
|
@@ -13830,7 +14051,7 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
13830
14051
|
assembledSource = injectShader(assembledSource, stage, declInjections);
|
|
13831
14052
|
assembledSource += getShaderHooks(hookFunctionMap[stage], hookInjections);
|
|
13832
14053
|
assembledSource += formatWGSLBindingAssignmentComments(bindingAssignments);
|
|
13833
|
-
assembledSource +=
|
|
14054
|
+
assembledSource += applicationRelocation.source;
|
|
13834
14055
|
assembledSource = injectShader(assembledSource, stage, mainInjections);
|
|
13835
14056
|
assertNoUnresolvedAutoBindings(assembledSource);
|
|
13836
14057
|
return { source: assembledSource, bindingAssignments };
|
|
@@ -13980,43 +14201,56 @@ ${getApplicationDefines(allDefines)}
|
|
|
13980
14201
|
}
|
|
13981
14202
|
function getUsedBindingsByGroupFromApplicationWGSL(source3) {
|
|
13982
14203
|
const usedBindingsByGroup = /* @__PURE__ */ new Map();
|
|
13983
|
-
for (const
|
|
13984
|
-
|
|
13985
|
-
|
|
13986
|
-
|
|
13987
|
-
|
|
13988
|
-
const location = Number(match[isBindingFirst ? 1 : 2]);
|
|
13989
|
-
const group = Number(match[isBindingFirst ? 2 : 1]);
|
|
13990
|
-
const name2 = match[4];
|
|
13991
|
-
validateApplicationWGSLBinding(group, location, name2);
|
|
13992
|
-
registerUsedBindingLocation(usedBindingsByGroup, group, location, `application binding "${name2}"`);
|
|
13993
|
-
}
|
|
14204
|
+
for (const match of getWGSLBindingDeclarationMatches(source3, WGSL_EXPLICIT_BINDING_DECLARATION_REGEXES)) {
|
|
14205
|
+
const location = Number(match.bindingToken);
|
|
14206
|
+
const group = Number(match.groupToken);
|
|
14207
|
+
validateApplicationWGSLBinding(group, location, match.name);
|
|
14208
|
+
registerUsedBindingLocation(usedBindingsByGroup, group, location, `application binding "${match.name}"`);
|
|
13994
14209
|
}
|
|
13995
14210
|
return usedBindingsByGroup;
|
|
13996
14211
|
}
|
|
14212
|
+
function relocateWGSLApplicationBindings(source3) {
|
|
14213
|
+
const declarationMatches = getWGSLBindingDeclarationMatches(source3, WGSL_BINDING_DECLARATION_REGEXES);
|
|
14214
|
+
const usedBindingsByGroup = /* @__PURE__ */ new Map();
|
|
14215
|
+
for (const declarationMatch of declarationMatches) {
|
|
14216
|
+
if (declarationMatch.bindingToken === "auto") {
|
|
14217
|
+
continue;
|
|
14218
|
+
}
|
|
14219
|
+
const location = Number(declarationMatch.bindingToken);
|
|
14220
|
+
const group = Number(declarationMatch.groupToken);
|
|
14221
|
+
validateApplicationWGSLBinding(group, location, declarationMatch.name);
|
|
14222
|
+
registerUsedBindingLocation(usedBindingsByGroup, group, location, `application binding "${declarationMatch.name}"`);
|
|
14223
|
+
}
|
|
14224
|
+
const relocationState = {
|
|
14225
|
+
sawSupportedBindingDeclaration: declarationMatches.length > 0
|
|
14226
|
+
};
|
|
14227
|
+
const relocatedSource = replaceWGSLBindingDeclarationMatches(source3, WGSL_BINDING_DECLARATION_REGEXES, (declarationMatch) => relocateWGSLApplicationBindingMatch(declarationMatch, usedBindingsByGroup, relocationState));
|
|
14228
|
+
if (hasWGSLAutoBinding(source3) && !relocationState.sawSupportedBindingDeclaration) {
|
|
14229
|
+
throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');
|
|
14230
|
+
}
|
|
14231
|
+
return { source: relocatedSource };
|
|
14232
|
+
}
|
|
13997
14233
|
function relocateWGSLModuleBindings(moduleSource, module, context) {
|
|
13998
14234
|
const bindingAssignments = [];
|
|
14235
|
+
const declarationMatches = getWGSLBindingDeclarationMatches(moduleSource, MODULE_WGSL_BINDING_DECLARATION_REGEXES);
|
|
13999
14236
|
const relocationState = {
|
|
14000
|
-
sawSupportedBindingDeclaration:
|
|
14237
|
+
sawSupportedBindingDeclaration: declarationMatches.length > 0,
|
|
14001
14238
|
nextHintedBindingLocation: typeof module.firstBindingSlot === "number" ? module.firstBindingSlot : null
|
|
14002
14239
|
};
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
|
|
14240
|
+
const relocatedSource = replaceWGSLBindingDeclarationMatches(moduleSource, MODULE_WGSL_BINDING_DECLARATION_REGEXES, (declarationMatch) => relocateWGSLModuleBindingMatch(declarationMatch, {
|
|
14241
|
+
module,
|
|
14242
|
+
context,
|
|
14243
|
+
bindingAssignments,
|
|
14244
|
+
relocationState
|
|
14245
|
+
}));
|
|
14246
|
+
if (hasWGSLAutoBinding(moduleSource) && !relocationState.sawSupportedBindingDeclaration) {
|
|
14247
|
+
throw new Error(`Unsupported @binding(auto) declaration form in module "${module.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);
|
|
14007
14248
|
}
|
|
14008
14249
|
return { source: relocatedSource, bindingAssignments };
|
|
14009
14250
|
}
|
|
14010
|
-
function
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
function relocateWGSLModuleBindingMatch(replaceArguments, params) {
|
|
14014
|
-
const { isBindingFirst, module, context, bindingAssignments, relocationState } = params;
|
|
14015
|
-
relocationState.sawSupportedBindingDeclaration = true;
|
|
14016
|
-
const match = replaceArguments[0];
|
|
14017
|
-
const bindingToken = replaceArguments[isBindingFirst ? 1 : 2];
|
|
14018
|
-
const groupToken = replaceArguments[isBindingFirst ? 2 : 1];
|
|
14019
|
-
const name2 = replaceArguments[4];
|
|
14251
|
+
function relocateWGSLModuleBindingMatch(declarationMatch, params) {
|
|
14252
|
+
const { module, context, bindingAssignments, relocationState } = params;
|
|
14253
|
+
const { match, bindingToken, groupToken, name: name2 } = declarationMatch;
|
|
14020
14254
|
const group = Number(groupToken);
|
|
14021
14255
|
if (bindingToken === "auto") {
|
|
14022
14256
|
const registryKey = getBindingRegistryKey(group, module.name, name2);
|
|
@@ -14041,6 +14275,18 @@ ${getApplicationDefines(allDefines)}
|
|
|
14041
14275
|
bindingAssignments.push({ moduleName: module.name, name: name2, group, location });
|
|
14042
14276
|
return match;
|
|
14043
14277
|
}
|
|
14278
|
+
function relocateWGSLApplicationBindingMatch(declarationMatch, usedBindingsByGroup, relocationState) {
|
|
14279
|
+
const { match, bindingToken, groupToken, name: name2 } = declarationMatch;
|
|
14280
|
+
const group = Number(groupToken);
|
|
14281
|
+
if (bindingToken === "auto") {
|
|
14282
|
+
const location = allocateApplicationAutoBindingLocation(group, usedBindingsByGroup);
|
|
14283
|
+
validateApplicationWGSLBinding(group, location, name2);
|
|
14284
|
+
registerUsedBindingLocation(usedBindingsByGroup, group, location, `application binding "${name2}"`);
|
|
14285
|
+
return match.replace(/@binding\(\s*auto\s*\)/, `@binding(${location})`);
|
|
14286
|
+
}
|
|
14287
|
+
relocationState.sawSupportedBindingDeclaration = true;
|
|
14288
|
+
return match;
|
|
14289
|
+
}
|
|
14044
14290
|
function reserveRegisteredModuleBindings(modules, bindingRegistry, usedBindingsByGroup) {
|
|
14045
14291
|
const reservedBindingKeysByGroup = /* @__PURE__ */ new Map();
|
|
14046
14292
|
if (!bindingRegistry) {
|
|
@@ -14081,16 +14327,11 @@ ${getApplicationDefines(allDefines)}
|
|
|
14081
14327
|
function getModuleWGSLBindingDeclarations(module) {
|
|
14082
14328
|
const declarations = [];
|
|
14083
14329
|
const moduleSource = module.source || "";
|
|
14084
|
-
for (const
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
declarations.push({
|
|
14090
|
-
name: match[4],
|
|
14091
|
-
group: Number(match[isBindingFirst ? 2 : 1])
|
|
14092
|
-
});
|
|
14093
|
-
}
|
|
14330
|
+
for (const match of getWGSLBindingDeclarationMatches(moduleSource, MODULE_WGSL_BINDING_DECLARATION_REGEXES)) {
|
|
14331
|
+
declarations.push({
|
|
14332
|
+
name: match.name,
|
|
14333
|
+
group: Number(match.groupToken)
|
|
14334
|
+
});
|
|
14094
14335
|
}
|
|
14095
14336
|
return declarations;
|
|
14096
14337
|
}
|
|
@@ -14120,10 +14361,27 @@ ${getApplicationDefines(allDefines)}
|
|
|
14120
14361
|
}
|
|
14121
14362
|
return nextBinding;
|
|
14122
14363
|
}
|
|
14364
|
+
function allocateApplicationAutoBindingLocation(group, usedBindingsByGroup) {
|
|
14365
|
+
const usedBindings = usedBindingsByGroup.get(group) || /* @__PURE__ */ new Set();
|
|
14366
|
+
let nextBinding = 0;
|
|
14367
|
+
while (usedBindings.has(nextBinding)) {
|
|
14368
|
+
nextBinding++;
|
|
14369
|
+
}
|
|
14370
|
+
return nextBinding;
|
|
14371
|
+
}
|
|
14123
14372
|
function assertNoUnresolvedAutoBindings(source3) {
|
|
14124
|
-
|
|
14125
|
-
|
|
14373
|
+
const unresolvedBinding = getFirstWGSLAutoBindingDeclarationMatch(source3, MODULE_WGSL_BINDING_DECLARATION_REGEXES);
|
|
14374
|
+
if (!unresolvedBinding) {
|
|
14375
|
+
return;
|
|
14376
|
+
}
|
|
14377
|
+
const moduleName = getWGSLModuleNameAtIndex(source3, unresolvedBinding.index);
|
|
14378
|
+
if (moduleName) {
|
|
14379
|
+
throw new Error(`Unresolved @binding(auto) for module "${moduleName}" binding "${unresolvedBinding.name}" remained in assembled WGSL source.`);
|
|
14126
14380
|
}
|
|
14381
|
+
if (isInApplicationWGSLSection(source3, unresolvedBinding.index)) {
|
|
14382
|
+
throw new Error(`Unresolved @binding(auto) for application binding "${unresolvedBinding.name}" remained in assembled WGSL source.`);
|
|
14383
|
+
}
|
|
14384
|
+
throw new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${formatWGSLSourceSnippet(unresolvedBinding.match)}".`);
|
|
14127
14385
|
}
|
|
14128
14386
|
function formatWGSLBindingAssignmentComments(bindingAssignments) {
|
|
14129
14387
|
if (bindingAssignments.length === 0) {
|
|
@@ -14140,6 +14398,24 @@ ${getApplicationDefines(allDefines)}
|
|
|
14140
14398
|
function getBindingRegistryKey(group, moduleName, bindingName) {
|
|
14141
14399
|
return `${group}:${moduleName}:${bindingName}`;
|
|
14142
14400
|
}
|
|
14401
|
+
function getWGSLModuleNameAtIndex(source3, index) {
|
|
14402
|
+
const moduleHeaderRegex = /^\/\/ ----- MODULE ([^\n]+) ---------------$/gm;
|
|
14403
|
+
let moduleName;
|
|
14404
|
+
let match;
|
|
14405
|
+
match = moduleHeaderRegex.exec(source3);
|
|
14406
|
+
while (match && match.index <= index) {
|
|
14407
|
+
moduleName = match[1];
|
|
14408
|
+
match = moduleHeaderRegex.exec(source3);
|
|
14409
|
+
}
|
|
14410
|
+
return moduleName;
|
|
14411
|
+
}
|
|
14412
|
+
function isInApplicationWGSLSection(source3, index) {
|
|
14413
|
+
const injectionMarkerIndex = source3.indexOf(INJECT_SHADER_DECLARATIONS);
|
|
14414
|
+
return injectionMarkerIndex >= 0 ? index > injectionMarkerIndex : true;
|
|
14415
|
+
}
|
|
14416
|
+
function formatWGSLSourceSnippet(source3) {
|
|
14417
|
+
return source3.replace(/\s+/g, " ").trim();
|
|
14418
|
+
}
|
|
14143
14419
|
|
|
14144
14420
|
// ../../node_modules/@luma.gl/shadertools/dist/lib/preprocessor/preprocessor.js
|
|
14145
14421
|
var DEFINE_NAME_PATTERN = "([a-zA-Z_][a-zA-Z0-9_]*)";
|
|
@@ -18280,6 +18556,28 @@ void main() {
|
|
|
18280
18556
|
return matrixFP64;
|
|
18281
18557
|
}
|
|
18282
18558
|
|
|
18559
|
+
// ../../node_modules/@luma.gl/shadertools/dist/lib/color/normalize-byte-colors.js
|
|
18560
|
+
function resolveUseByteColors(useByteColors, defaultUseByteColors = true) {
|
|
18561
|
+
return useByteColors ?? defaultUseByteColors;
|
|
18562
|
+
}
|
|
18563
|
+
function normalizeByteColor3(color = [0, 0, 0], useByteColors = true) {
|
|
18564
|
+
if (!useByteColors) {
|
|
18565
|
+
return [...color];
|
|
18566
|
+
}
|
|
18567
|
+
return color.map((component) => component / 255);
|
|
18568
|
+
}
|
|
18569
|
+
function normalizeByteColor4(color, useByteColors = true) {
|
|
18570
|
+
const normalizedColor = normalizeByteColor3(color.slice(0, 3), useByteColors);
|
|
18571
|
+
const hasAlpha = Number.isFinite(color[3]);
|
|
18572
|
+
const alpha = hasAlpha ? color[3] : 1;
|
|
18573
|
+
return [
|
|
18574
|
+
normalizedColor[0],
|
|
18575
|
+
normalizedColor[1],
|
|
18576
|
+
normalizedColor[2],
|
|
18577
|
+
useByteColors && hasAlpha ? alpha / 255 : alpha
|
|
18578
|
+
];
|
|
18579
|
+
}
|
|
18580
|
+
|
|
18283
18581
|
// ../../node_modules/@luma.gl/shadertools/dist/modules/math/fp32/fp32.js
|
|
18284
18582
|
var fp32shader = (
|
|
18285
18583
|
/* glsl */
|
|
@@ -18878,6 +19176,90 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
18878
19176
|
fp64ifyMatrix4
|
|
18879
19177
|
};
|
|
18880
19178
|
|
|
19179
|
+
// ../../node_modules/@luma.gl/shadertools/dist/modules/color/float-colors.js
|
|
19180
|
+
var GLSL_UNIFORMS = (
|
|
19181
|
+
/* glsl */
|
|
19182
|
+
`layout(std140) uniform floatColorsUniforms {
|
|
19183
|
+
float useByteColors;
|
|
19184
|
+
} floatColors;
|
|
19185
|
+
|
|
19186
|
+
vec3 floatColors_normalize(vec3 inputColor) {
|
|
19187
|
+
return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;
|
|
19188
|
+
}
|
|
19189
|
+
|
|
19190
|
+
vec4 floatColors_normalize(vec4 inputColor) {
|
|
19191
|
+
return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;
|
|
19192
|
+
}
|
|
19193
|
+
|
|
19194
|
+
vec4 floatColors_premultiplyAlpha(vec4 inputColor) {
|
|
19195
|
+
return vec4(inputColor.rgb * inputColor.a, inputColor.a);
|
|
19196
|
+
}
|
|
19197
|
+
|
|
19198
|
+
vec4 floatColors_unpremultiplyAlpha(vec4 inputColor) {
|
|
19199
|
+
return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0);
|
|
19200
|
+
}
|
|
19201
|
+
|
|
19202
|
+
vec4 floatColors_premultiply_alpha(vec4 inputColor) {
|
|
19203
|
+
return floatColors_premultiplyAlpha(inputColor);
|
|
19204
|
+
}
|
|
19205
|
+
|
|
19206
|
+
vec4 floatColors_unpremultiply_alpha(vec4 inputColor) {
|
|
19207
|
+
return floatColors_unpremultiplyAlpha(inputColor);
|
|
19208
|
+
}
|
|
19209
|
+
`
|
|
19210
|
+
);
|
|
19211
|
+
var WGSL_UNIFORMS = (
|
|
19212
|
+
/* wgsl */
|
|
19213
|
+
`struct floatColorsUniforms {
|
|
19214
|
+
useByteColors: f32
|
|
19215
|
+
};
|
|
19216
|
+
|
|
19217
|
+
@group(0) @binding(auto) var<uniform> floatColors : floatColorsUniforms;
|
|
19218
|
+
|
|
19219
|
+
fn floatColors_normalize(inputColor: vec3<f32>) -> vec3<f32> {
|
|
19220
|
+
return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);
|
|
19221
|
+
}
|
|
19222
|
+
|
|
19223
|
+
fn floatColors_normalize4(inputColor: vec4<f32>) -> vec4<f32> {
|
|
19224
|
+
return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);
|
|
19225
|
+
}
|
|
19226
|
+
|
|
19227
|
+
fn floatColors_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
19228
|
+
return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a);
|
|
19229
|
+
}
|
|
19230
|
+
|
|
19231
|
+
fn floatColors_unpremultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
19232
|
+
return select(
|
|
19233
|
+
vec4<f32>(0.0),
|
|
19234
|
+
vec4<f32>(inputColor.rgb / inputColor.a, inputColor.a),
|
|
19235
|
+
inputColor.a > 0.0
|
|
19236
|
+
);
|
|
19237
|
+
}
|
|
19238
|
+
|
|
19239
|
+
fn floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
19240
|
+
return floatColors_premultiplyAlpha(inputColor);
|
|
19241
|
+
}
|
|
19242
|
+
|
|
19243
|
+
fn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
19244
|
+
return floatColors_unpremultiplyAlpha(inputColor);
|
|
19245
|
+
}
|
|
19246
|
+
`
|
|
19247
|
+
);
|
|
19248
|
+
var floatColors = {
|
|
19249
|
+
name: "floatColors",
|
|
19250
|
+
props: {},
|
|
19251
|
+
uniforms: {},
|
|
19252
|
+
vs: GLSL_UNIFORMS,
|
|
19253
|
+
fs: GLSL_UNIFORMS,
|
|
19254
|
+
source: WGSL_UNIFORMS,
|
|
19255
|
+
uniformTypes: {
|
|
19256
|
+
useByteColors: "f32"
|
|
19257
|
+
},
|
|
19258
|
+
defaultUniforms: {
|
|
19259
|
+
useByteColors: true
|
|
19260
|
+
}
|
|
19261
|
+
};
|
|
19262
|
+
|
|
18881
19263
|
// ../../node_modules/@luma.gl/shadertools/dist/modules/engine/picking/picking.js
|
|
18882
19264
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
18883
19265
|
var vs = (
|
|
@@ -18886,7 +19268,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
18886
19268
|
float isActive;
|
|
18887
19269
|
float isAttribute;
|
|
18888
19270
|
float isHighlightActive;
|
|
18889
|
-
float
|
|
19271
|
+
float useByteColors;
|
|
18890
19272
|
vec3 highlightedObjectColor;
|
|
18891
19273
|
vec4 highlightColor;
|
|
18892
19274
|
} picking;
|
|
@@ -18895,12 +19277,12 @@ out vec4 picking_vRGBcolor_Avalid;
|
|
|
18895
19277
|
|
|
18896
19278
|
// Normalize unsigned byte color to 0-1 range
|
|
18897
19279
|
vec3 picking_normalizeColor(vec3 color) {
|
|
18898
|
-
return picking.
|
|
19280
|
+
return picking.useByteColors > 0.5 ? color / 255.0 : color;
|
|
18899
19281
|
}
|
|
18900
19282
|
|
|
18901
19283
|
// Normalize unsigned byte color to 0-1 range
|
|
18902
19284
|
vec4 picking_normalizeColor(vec4 color) {
|
|
18903
|
-
return picking.
|
|
19285
|
+
return picking.useByteColors > 0.5 ? color / 255.0 : color;
|
|
18904
19286
|
}
|
|
18905
19287
|
|
|
18906
19288
|
bool picking_isColorZero(vec3 color) {
|
|
@@ -18961,7 +19343,7 @@ void picking_setPickingAttribute(vec3 value) {
|
|
|
18961
19343
|
float isActive;
|
|
18962
19344
|
float isAttribute;
|
|
18963
19345
|
float isHighlightActive;
|
|
18964
|
-
float
|
|
19346
|
+
float useByteColors;
|
|
18965
19347
|
vec3 highlightedObjectColor;
|
|
18966
19348
|
vec4 highlightColor;
|
|
18967
19349
|
} picking;
|
|
@@ -19023,7 +19405,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19023
19405
|
isActive: "f32",
|
|
19024
19406
|
isAttribute: "f32",
|
|
19025
19407
|
isHighlightActive: "f32",
|
|
19026
|
-
|
|
19408
|
+
useByteColors: "f32",
|
|
19027
19409
|
highlightedObjectColor: "vec3<f32>",
|
|
19028
19410
|
highlightColor: "vec4<f32>"
|
|
19029
19411
|
},
|
|
@@ -19031,7 +19413,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19031
19413
|
isActive: false,
|
|
19032
19414
|
isAttribute: false,
|
|
19033
19415
|
isHighlightActive: false,
|
|
19034
|
-
|
|
19416
|
+
useByteColors: true,
|
|
19035
19417
|
highlightedObjectColor: [0, 0, 0],
|
|
19036
19418
|
highlightColor: DEFAULT_HIGHLIGHT_COLOR
|
|
19037
19419
|
},
|
|
@@ -19041,6 +19423,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19041
19423
|
};
|
|
19042
19424
|
function getUniforms(opts = {}, prevUniforms) {
|
|
19043
19425
|
const uniforms = {};
|
|
19426
|
+
const useByteColors = resolveUseByteColors(opts.useByteColors, true);
|
|
19044
19427
|
if (opts.highlightedObjectColor === void 0) {
|
|
19045
19428
|
} else if (opts.highlightedObjectColor === null) {
|
|
19046
19429
|
uniforms.isHighlightActive = false;
|
|
@@ -19050,18 +19433,14 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19050
19433
|
uniforms.highlightedObjectColor = highlightedObjectColor;
|
|
19051
19434
|
}
|
|
19052
19435
|
if (opts.highlightColor) {
|
|
19053
|
-
|
|
19054
|
-
if (!Number.isFinite(color[3])) {
|
|
19055
|
-
color[3] = 1;
|
|
19056
|
-
}
|
|
19057
|
-
uniforms.highlightColor = color;
|
|
19436
|
+
uniforms.highlightColor = normalizeByteColor4(opts.highlightColor, useByteColors);
|
|
19058
19437
|
}
|
|
19059
19438
|
if (opts.isActive !== void 0) {
|
|
19060
19439
|
uniforms.isActive = Boolean(opts.isActive);
|
|
19061
19440
|
uniforms.isAttribute = Boolean(opts.isAttribute);
|
|
19062
19441
|
}
|
|
19063
|
-
if (opts.
|
|
19064
|
-
uniforms.
|
|
19442
|
+
if (opts.useByteColors !== void 0) {
|
|
19443
|
+
uniforms.useByteColors = Boolean(opts.useByteColors);
|
|
19065
19444
|
}
|
|
19066
19445
|
return uniforms;
|
|
19067
19446
|
}
|
|
@@ -19242,7 +19621,6 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
19242
19621
|
|
|
19243
19622
|
// ../../node_modules/@luma.gl/shadertools/dist/modules/lighting/lights/lighting.js
|
|
19244
19623
|
var MAX_LIGHTS = 5;
|
|
19245
|
-
var COLOR_FACTOR = 255;
|
|
19246
19624
|
var LIGHT_UNIFORM_TYPE = {
|
|
19247
19625
|
color: "vec3<f32>",
|
|
19248
19626
|
position: "vec3<f32>",
|
|
@@ -19281,7 +19659,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
19281
19659
|
if (props.lights) {
|
|
19282
19660
|
props = { ...props, ...extractLightTypes(props.lights), lights: void 0 };
|
|
19283
19661
|
}
|
|
19284
|
-
const { ambientLight, pointLights, spotLights, directionalLights } = props || {};
|
|
19662
|
+
const { useByteColors, ambientLight, pointLights, spotLights, directionalLights } = props || {};
|
|
19285
19663
|
const hasLights = ambientLight || pointLights && pointLights.length > 0 || spotLights && spotLights.length > 0 || directionalLights && directionalLights.length > 0;
|
|
19286
19664
|
if (!hasLights) {
|
|
19287
19665
|
return {
|
|
@@ -19291,14 +19669,20 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
19291
19669
|
}
|
|
19292
19670
|
const uniforms = {
|
|
19293
19671
|
...createDefaultLightingUniforms(),
|
|
19294
|
-
...getLightSourceUniforms({
|
|
19672
|
+
...getLightSourceUniforms({
|
|
19673
|
+
useByteColors,
|
|
19674
|
+
ambientLight,
|
|
19675
|
+
pointLights,
|
|
19676
|
+
spotLights,
|
|
19677
|
+
directionalLights
|
|
19678
|
+
})
|
|
19295
19679
|
};
|
|
19296
19680
|
if (props.enabled !== void 0) {
|
|
19297
19681
|
uniforms.enabled = props.enabled ? 1 : 0;
|
|
19298
19682
|
}
|
|
19299
19683
|
return uniforms;
|
|
19300
19684
|
}
|
|
19301
|
-
function getLightSourceUniforms({ ambientLight, pointLights = [], spotLights = [], directionalLights = [] }) {
|
|
19685
|
+
function getLightSourceUniforms({ useByteColors, ambientLight, pointLights = [], spotLights = [], directionalLights = [] }) {
|
|
19302
19686
|
const lights = createDefaultLightUniforms();
|
|
19303
19687
|
let currentLight = 0;
|
|
19304
19688
|
let pointLightCount = 0;
|
|
@@ -19310,7 +19694,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
19310
19694
|
}
|
|
19311
19695
|
lights[currentLight] = {
|
|
19312
19696
|
...lights[currentLight],
|
|
19313
|
-
color: convertColor(pointLight),
|
|
19697
|
+
color: convertColor(pointLight, useByteColors),
|
|
19314
19698
|
position: pointLight.position,
|
|
19315
19699
|
attenuation: pointLight.attenuation || [1, 0, 0]
|
|
19316
19700
|
};
|
|
@@ -19323,7 +19707,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
19323
19707
|
}
|
|
19324
19708
|
lights[currentLight] = {
|
|
19325
19709
|
...lights[currentLight],
|
|
19326
|
-
color: convertColor(spotLight),
|
|
19710
|
+
color: convertColor(spotLight, useByteColors),
|
|
19327
19711
|
position: spotLight.position,
|
|
19328
19712
|
direction: spotLight.direction,
|
|
19329
19713
|
attenuation: spotLight.attenuation || [1, 0, 0],
|
|
@@ -19338,7 +19722,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
19338
19722
|
}
|
|
19339
19723
|
lights[currentLight] = {
|
|
19340
19724
|
...lights[currentLight],
|
|
19341
|
-
color: convertColor(directionalLight),
|
|
19725
|
+
color: convertColor(directionalLight, useByteColors),
|
|
19342
19726
|
direction: directionalLight.direction
|
|
19343
19727
|
};
|
|
19344
19728
|
currentLight++;
|
|
@@ -19348,7 +19732,7 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
19348
19732
|
log.warn(`MAX_LIGHTS exceeded, truncating to ${MAX_LIGHTS}`)();
|
|
19349
19733
|
}
|
|
19350
19734
|
return {
|
|
19351
|
-
ambientColor: convertColor(ambientLight),
|
|
19735
|
+
ambientColor: convertColor(ambientLight, useByteColors),
|
|
19352
19736
|
directionalLightCount,
|
|
19353
19737
|
pointLightCount,
|
|
19354
19738
|
spotLightCount,
|
|
@@ -19376,9 +19760,10 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
19376
19760
|
}
|
|
19377
19761
|
return lightSources;
|
|
19378
19762
|
}
|
|
19379
|
-
function convertColor(colorDef = {}) {
|
|
19763
|
+
function convertColor(colorDef = {}, useByteColors) {
|
|
19380
19764
|
const { color = [0, 0, 0], intensity = 1 } = colorDef;
|
|
19381
|
-
|
|
19765
|
+
const normalizedColor = normalizeByteColor3(color, resolveUseByteColors(useByteColors, true));
|
|
19766
|
+
return normalizedColor.map((component) => component * intensity);
|
|
19382
19767
|
}
|
|
19383
19768
|
function createDefaultLightingUniforms() {
|
|
19384
19769
|
return {
|
|
@@ -19439,7 +19824,7 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
|
|
|
19439
19824
|
specular = pow(specular_angle, material.shininess);
|
|
19440
19825
|
}
|
|
19441
19826
|
lambertian = max(lambertian, 0.0);
|
|
19442
|
-
return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
|
|
19827
|
+
return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;
|
|
19443
19828
|
}
|
|
19444
19829
|
|
|
19445
19830
|
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
|
|
@@ -19504,7 +19889,10 @@ fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, v
|
|
|
19504
19889
|
specular = pow(specular_angle, phongMaterial.shininess);
|
|
19505
19890
|
}
|
|
19506
19891
|
lambertian = max(lambertian, 0.0);
|
|
19507
|
-
return (
|
|
19892
|
+
return (
|
|
19893
|
+
lambertian * phongMaterial.diffuse * surfaceColor +
|
|
19894
|
+
specular * floatColors_normalize(phongMaterial.specularColor)
|
|
19895
|
+
) * color;
|
|
19508
19896
|
}
|
|
19509
19897
|
|
|
19510
19898
|
fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {
|
|
@@ -19609,6 +19997,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
19609
19997
|
);
|
|
19610
19998
|
|
|
19611
19999
|
// ../../node_modules/@luma.gl/shadertools/dist/modules/lighting/gouraud-material/gouraud-material.js
|
|
20000
|
+
var DEFAULT_SPECULAR_COLOR = [38.25, 38.25, 38.25];
|
|
19612
20001
|
var gouraudMaterial = {
|
|
19613
20002
|
props: {},
|
|
19614
20003
|
name: "gouraudMaterial",
|
|
@@ -19620,7 +20009,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
19620
20009
|
defines: {
|
|
19621
20010
|
LIGHTING_VERTEX: true
|
|
19622
20011
|
},
|
|
19623
|
-
dependencies: [lighting],
|
|
20012
|
+
dependencies: [lighting, floatColors],
|
|
19624
20013
|
uniformTypes: {
|
|
19625
20014
|
unlit: "i32",
|
|
19626
20015
|
ambient: "f32",
|
|
@@ -19633,23 +20022,20 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
19633
20022
|
ambient: 0.35,
|
|
19634
20023
|
diffuse: 0.6,
|
|
19635
20024
|
shininess: 32,
|
|
19636
|
-
specularColor:
|
|
20025
|
+
specularColor: DEFAULT_SPECULAR_COLOR
|
|
19637
20026
|
},
|
|
19638
20027
|
getUniforms(props) {
|
|
19639
|
-
|
|
19640
|
-
if (uniforms.specularColor) {
|
|
19641
|
-
uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
|
|
19642
|
-
}
|
|
19643
|
-
return { ...gouraudMaterial.defaultUniforms, ...uniforms };
|
|
20028
|
+
return { ...gouraudMaterial.defaultUniforms, ...props };
|
|
19644
20029
|
}
|
|
19645
20030
|
};
|
|
19646
20031
|
|
|
19647
20032
|
// ../../node_modules/@luma.gl/shadertools/dist/modules/lighting/phong-material/phong-material.js
|
|
20033
|
+
var DEFAULT_SPECULAR_COLOR2 = [38.25, 38.25, 38.25];
|
|
19648
20034
|
var phongMaterial = {
|
|
19649
20035
|
name: "phongMaterial",
|
|
19650
20036
|
firstBindingSlot: 0,
|
|
19651
20037
|
bindingLayout: [{ name: "phongMaterial", group: 3 }],
|
|
19652
|
-
dependencies: [lighting],
|
|
20038
|
+
dependencies: [lighting, floatColors],
|
|
19653
20039
|
// Note these are switched between phong and gouraud
|
|
19654
20040
|
source: PHONG_WGSL,
|
|
19655
20041
|
vs: PHONG_VS,
|
|
@@ -19669,14 +20055,10 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
19669
20055
|
ambient: 0.35,
|
|
19670
20056
|
diffuse: 0.6,
|
|
19671
20057
|
shininess: 32,
|
|
19672
|
-
specularColor:
|
|
20058
|
+
specularColor: DEFAULT_SPECULAR_COLOR2
|
|
19673
20059
|
},
|
|
19674
20060
|
getUniforms(props) {
|
|
19675
|
-
|
|
19676
|
-
if (uniforms.specularColor) {
|
|
19677
|
-
uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
|
|
19678
|
-
}
|
|
19679
|
-
return { ...phongMaterial.defaultUniforms, ...uniforms };
|
|
20061
|
+
return { ...phongMaterial.defaultUniforms, ...props };
|
|
19680
20062
|
}
|
|
19681
20063
|
};
|
|
19682
20064
|
|
|
@@ -19770,6 +20152,9 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
19770
20152
|
case "TEXCOORD_0":
|
|
19771
20153
|
name2 = "texCoords";
|
|
19772
20154
|
break;
|
|
20155
|
+
case "TEXCOORD_1":
|
|
20156
|
+
name2 = "texCoords1";
|
|
20157
|
+
break;
|
|
19773
20158
|
case "COLOR_0":
|
|
19774
20159
|
name2 = "colors";
|
|
19775
20160
|
break;
|
|
@@ -19814,41 +20199,93 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
19814
20199
|
}
|
|
19815
20200
|
|
|
19816
20201
|
// ../../node_modules/@luma.gl/engine/dist/debug/debug-framebuffer.js
|
|
19817
|
-
var
|
|
19818
|
-
var
|
|
19819
|
-
function debugFramebuffer(
|
|
19820
|
-
if (
|
|
19821
|
-
|
|
19822
|
-
|
|
19823
|
-
|
|
19824
|
-
|
|
19825
|
-
|
|
19826
|
-
|
|
19827
|
-
|
|
19828
|
-
|
|
19829
|
-
|
|
19830
|
-
|
|
19831
|
-
|
|
19832
|
-
|
|
19833
|
-
|
|
19834
|
-
|
|
19835
|
-
canvas.height = fbo.height / 2;
|
|
19836
|
-
canvas.style.width = "400px";
|
|
19837
|
-
canvas.style.height = "400px";
|
|
19838
|
-
}
|
|
19839
|
-
const color = fbo.device.readPixelsToArrayWebGL(fbo);
|
|
19840
|
-
const imageData = ctx?.createImageData(fbo.width, fbo.height);
|
|
19841
|
-
if (imageData) {
|
|
19842
|
-
const offset = 0;
|
|
19843
|
-
for (let i = 0; i < color.length; i += 4) {
|
|
19844
|
-
imageData.data[offset + i + 0] = color[i + 0] * rgbaScale;
|
|
19845
|
-
imageData.data[offset + i + 1] = color[i + 1] * rgbaScale;
|
|
19846
|
-
imageData.data[offset + i + 2] = color[i + 2] * rgbaScale;
|
|
19847
|
-
imageData.data[offset + i + 3] = opaque ? 255 : color[i + 3] * rgbaScale;
|
|
19848
|
-
}
|
|
19849
|
-
ctx?.putImageData(imageData, 0, 0);
|
|
20202
|
+
var DEBUG_FRAMEBUFFER_STATE_KEY = "__debugFramebufferState";
|
|
20203
|
+
var DEFAULT_MARGIN_PX = 8;
|
|
20204
|
+
function debugFramebuffer(renderPass, source3, options) {
|
|
20205
|
+
if (renderPass.device.type !== "webgl") {
|
|
20206
|
+
return;
|
|
20207
|
+
}
|
|
20208
|
+
const state = getDebugFramebufferState(renderPass.device);
|
|
20209
|
+
if (state.flushing) {
|
|
20210
|
+
return;
|
|
20211
|
+
}
|
|
20212
|
+
if (isDefaultRenderPass(renderPass)) {
|
|
20213
|
+
flushDebugFramebuffers(renderPass, options, state);
|
|
20214
|
+
return;
|
|
20215
|
+
}
|
|
20216
|
+
if (source3 && isFramebuffer(source3) && source3.handle !== null) {
|
|
20217
|
+
if (!state.queuedFramebuffers.includes(source3)) {
|
|
20218
|
+
state.queuedFramebuffers.push(source3);
|
|
20219
|
+
}
|
|
19850
20220
|
}
|
|
19851
20221
|
}
|
|
20222
|
+
function flushDebugFramebuffers(renderPass, options, state) {
|
|
20223
|
+
if (state.queuedFramebuffers.length === 0) {
|
|
20224
|
+
return;
|
|
20225
|
+
}
|
|
20226
|
+
const webglDevice = renderPass.device;
|
|
20227
|
+
const { gl } = webglDevice;
|
|
20228
|
+
const previousReadFramebuffer = gl.getParameter(36010);
|
|
20229
|
+
const previousDrawFramebuffer = gl.getParameter(36006);
|
|
20230
|
+
const [targetWidth, targetHeight] = renderPass.device.getDefaultCanvasContext().getDrawingBufferSize();
|
|
20231
|
+
let topPx = parseCssPixel(options.top, DEFAULT_MARGIN_PX);
|
|
20232
|
+
const leftPx = parseCssPixel(options.left, DEFAULT_MARGIN_PX);
|
|
20233
|
+
state.flushing = true;
|
|
20234
|
+
try {
|
|
20235
|
+
for (const framebuffer of state.queuedFramebuffers) {
|
|
20236
|
+
const [targetX0, targetY0, targetX1, targetY1, previewHeight] = getOverlayRect({
|
|
20237
|
+
framebuffer,
|
|
20238
|
+
targetWidth,
|
|
20239
|
+
targetHeight,
|
|
20240
|
+
topPx,
|
|
20241
|
+
leftPx,
|
|
20242
|
+
minimap: options.minimap
|
|
20243
|
+
});
|
|
20244
|
+
gl.bindFramebuffer(36008, framebuffer.handle);
|
|
20245
|
+
gl.bindFramebuffer(36009, null);
|
|
20246
|
+
gl.blitFramebuffer(0, 0, framebuffer.width, framebuffer.height, targetX0, targetY0, targetX1, targetY1, 16384, 9728);
|
|
20247
|
+
topPx += previewHeight + DEFAULT_MARGIN_PX;
|
|
20248
|
+
}
|
|
20249
|
+
} finally {
|
|
20250
|
+
gl.bindFramebuffer(36008, previousReadFramebuffer);
|
|
20251
|
+
gl.bindFramebuffer(36009, previousDrawFramebuffer);
|
|
20252
|
+
state.flushing = false;
|
|
20253
|
+
}
|
|
20254
|
+
}
|
|
20255
|
+
function getOverlayRect(options) {
|
|
20256
|
+
const { framebuffer, targetWidth, targetHeight, topPx, leftPx, minimap } = options;
|
|
20257
|
+
const maxWidth = minimap ? Math.max(Math.floor(targetWidth / 4), 1) : targetWidth;
|
|
20258
|
+
const maxHeight = minimap ? Math.max(Math.floor(targetHeight / 4), 1) : targetHeight;
|
|
20259
|
+
const scale5 = Math.min(maxWidth / framebuffer.width, maxHeight / framebuffer.height);
|
|
20260
|
+
const previewWidth = Math.max(Math.floor(framebuffer.width * scale5), 1);
|
|
20261
|
+
const previewHeight = Math.max(Math.floor(framebuffer.height * scale5), 1);
|
|
20262
|
+
const targetX0 = leftPx;
|
|
20263
|
+
const targetY0 = Math.max(targetHeight - topPx - previewHeight, 0);
|
|
20264
|
+
const targetX1 = targetX0 + previewWidth;
|
|
20265
|
+
const targetY1 = targetY0 + previewHeight;
|
|
20266
|
+
return [targetX0, targetY0, targetX1, targetY1, previewHeight];
|
|
20267
|
+
}
|
|
20268
|
+
function getDebugFramebufferState(device) {
|
|
20269
|
+
device.userData[DEBUG_FRAMEBUFFER_STATE_KEY] ||= {
|
|
20270
|
+
flushing: false,
|
|
20271
|
+
queuedFramebuffers: []
|
|
20272
|
+
};
|
|
20273
|
+
return device.userData[DEBUG_FRAMEBUFFER_STATE_KEY];
|
|
20274
|
+
}
|
|
20275
|
+
function isFramebuffer(value) {
|
|
20276
|
+
return "colorAttachments" in value;
|
|
20277
|
+
}
|
|
20278
|
+
function isDefaultRenderPass(renderPass) {
|
|
20279
|
+
const framebuffer = renderPass.props.framebuffer;
|
|
20280
|
+
return !framebuffer || framebuffer.handle === null;
|
|
20281
|
+
}
|
|
20282
|
+
function parseCssPixel(value, defaultValue) {
|
|
20283
|
+
if (!value) {
|
|
20284
|
+
return defaultValue;
|
|
20285
|
+
}
|
|
20286
|
+
const parsedValue = Number.parseInt(value, 10);
|
|
20287
|
+
return Number.isFinite(parsedValue) ? parsedValue : defaultValue;
|
|
20288
|
+
}
|
|
19852
20289
|
|
|
19853
20290
|
// ../../node_modules/@luma.gl/engine/dist/utils/deep-equal.js
|
|
19854
20291
|
function deepEqual(a, b, depth) {
|
|
@@ -20057,12 +20494,11 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
20057
20494
|
this.moduleUniforms = {};
|
|
20058
20495
|
this.moduleBindings = {};
|
|
20059
20496
|
for (const [name2, module] of Object.entries(modules)) {
|
|
20060
|
-
if (
|
|
20061
|
-
|
|
20062
|
-
|
|
20063
|
-
|
|
20064
|
-
|
|
20065
|
-
log.warn(`Module name: ${name2} vs ${module.name}`)();
|
|
20497
|
+
if (module) {
|
|
20498
|
+
this._addModule(module);
|
|
20499
|
+
if (module.name && name2 !== module.name && !this.options.disableWarnings) {
|
|
20500
|
+
log.warn(`Module name: ${name2} vs ${module.name}`)();
|
|
20501
|
+
}
|
|
20066
20502
|
}
|
|
20067
20503
|
}
|
|
20068
20504
|
}
|
|
@@ -20081,14 +20517,14 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
20081
20517
|
if (!this.options.disableWarnings) {
|
|
20082
20518
|
log.warn(`Module ${name2} not found`)();
|
|
20083
20519
|
}
|
|
20084
|
-
|
|
20520
|
+
} else {
|
|
20521
|
+
const oldUniforms = this.moduleUniforms[moduleName];
|
|
20522
|
+
const oldBindings = this.moduleBindings[moduleName];
|
|
20523
|
+
const uniformsAndBindings = module.getUniforms?.(moduleProps, oldUniforms) || moduleProps;
|
|
20524
|
+
const { uniforms, bindings } = splitUniformsAndBindings(uniformsAndBindings, module.uniformTypes);
|
|
20525
|
+
this.moduleUniforms[moduleName] = mergeModuleUniforms(oldUniforms, uniforms, module.uniformTypes);
|
|
20526
|
+
this.moduleBindings[moduleName] = { ...oldBindings, ...bindings };
|
|
20085
20527
|
}
|
|
20086
|
-
const oldUniforms = this.moduleUniforms[moduleName];
|
|
20087
|
-
const oldBindings = this.moduleBindings[moduleName];
|
|
20088
|
-
const uniformsAndBindings = module.getUniforms?.(moduleProps, oldUniforms) || moduleProps;
|
|
20089
|
-
const { uniforms, bindings } = splitUniformsAndBindings(uniformsAndBindings, module.uniformTypes);
|
|
20090
|
-
this.moduleUniforms[moduleName] = mergeModuleUniforms(oldUniforms, uniforms, module.uniformTypes);
|
|
20091
|
-
this.moduleBindings[moduleName] = { ...oldBindings, ...bindings };
|
|
20092
20528
|
}
|
|
20093
20529
|
}
|
|
20094
20530
|
/**
|
|
@@ -20133,10 +20569,9 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
20133
20569
|
function mergeModuleUniforms(currentUniforms = {}, nextUniforms = {}, uniformTypes = {}) {
|
|
20134
20570
|
const mergedUniforms = { ...currentUniforms };
|
|
20135
20571
|
for (const [key, value] of Object.entries(nextUniforms)) {
|
|
20136
|
-
if (value
|
|
20137
|
-
|
|
20572
|
+
if (value !== void 0) {
|
|
20573
|
+
mergedUniforms[key] = mergeModuleUniformValue(currentUniforms[key], value, uniformTypes[key]);
|
|
20138
20574
|
}
|
|
20139
|
-
mergedUniforms[key] = mergeModuleUniformValue(currentUniforms[key], value, uniformTypes[key]);
|
|
20140
20575
|
}
|
|
20141
20576
|
return mergedUniforms;
|
|
20142
20577
|
}
|
|
@@ -20152,10 +20587,9 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
20152
20587
|
const mergedArray = currentArray.slice();
|
|
20153
20588
|
for (let index = 0; index < nextValue.length; index++) {
|
|
20154
20589
|
const elementValue = nextValue[index];
|
|
20155
|
-
if (elementValue
|
|
20156
|
-
|
|
20590
|
+
if (elementValue !== void 0) {
|
|
20591
|
+
mergedArray[index] = mergeModuleUniformValue(currentArray[index], elementValue, uniformType[0]);
|
|
20157
20592
|
}
|
|
20158
|
-
mergedArray[index] = mergeModuleUniformValue(currentArray[index], elementValue, uniformType[0]);
|
|
20159
20593
|
}
|
|
20160
20594
|
return mergedArray;
|
|
20161
20595
|
}
|
|
@@ -20166,10 +20600,9 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
20166
20600
|
const currentObject = isPlainUniformObject(currentValue) ? currentValue : {};
|
|
20167
20601
|
const mergedObject = { ...currentObject };
|
|
20168
20602
|
for (const [key, value] of Object.entries(nextValue)) {
|
|
20169
|
-
if (value
|
|
20170
|
-
|
|
20603
|
+
if (value !== void 0) {
|
|
20604
|
+
mergedObject[key] = mergeModuleUniformValue(currentObject[key], value, uniformStruct[key]);
|
|
20171
20605
|
}
|
|
20172
|
-
mergedObject[key] = mergeModuleUniformValue(currentObject[key], value, uniformStruct[key]);
|
|
20173
20606
|
}
|
|
20174
20607
|
return mergedObject;
|
|
20175
20608
|
}
|
|
@@ -20406,7 +20839,9 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
20406
20839
|
return "DynamicTexture";
|
|
20407
20840
|
}
|
|
20408
20841
|
toString() {
|
|
20409
|
-
|
|
20842
|
+
const width = this._texture?.width ?? this.props.width ?? "?";
|
|
20843
|
+
const height = this._texture?.height ?? this.props.height ?? "?";
|
|
20844
|
+
return `DynamicTexture:"${this.id}":${width}x${height}px:(${this.isReady ? "ready" : "loading..."})`;
|
|
20410
20845
|
}
|
|
20411
20846
|
constructor(device, props) {
|
|
20412
20847
|
this.device = device;
|
|
@@ -20839,6 +21274,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
20839
21274
|
// ../../node_modules/@luma.gl/engine/dist/model/model.js
|
|
20840
21275
|
var LOG_DRAW_PRIORITY = 2;
|
|
20841
21276
|
var LOG_DRAW_TIMEOUT = 1e4;
|
|
21277
|
+
var PIPELINE_INITIALIZATION_FAILED = "render pipeline initialization failed";
|
|
20842
21278
|
var _Model = class {
|
|
20843
21279
|
/** Device that created this model */
|
|
20844
21280
|
device;
|
|
@@ -21047,35 +21483,42 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
21047
21483
|
renderPass.popDebugGroup();
|
|
21048
21484
|
}
|
|
21049
21485
|
let drawSuccess;
|
|
21486
|
+
let pipelineErrored = this.pipeline.isErrored;
|
|
21050
21487
|
try {
|
|
21051
21488
|
renderPass.pushDebugGroup(`${this}.draw(${renderPass})`);
|
|
21052
21489
|
this._logDrawCallStart();
|
|
21053
21490
|
this.pipeline = this._updatePipeline();
|
|
21054
|
-
|
|
21055
|
-
|
|
21056
|
-
|
|
21057
|
-
|
|
21058
|
-
|
|
21059
|
-
|
|
21060
|
-
|
|
21061
|
-
|
|
21062
|
-
|
|
21063
|
-
|
|
21064
|
-
|
|
21065
|
-
|
|
21066
|
-
|
|
21067
|
-
|
|
21068
|
-
|
|
21069
|
-
|
|
21070
|
-
|
|
21071
|
-
|
|
21072
|
-
|
|
21073
|
-
|
|
21074
|
-
|
|
21075
|
-
|
|
21076
|
-
|
|
21077
|
-
|
|
21078
|
-
|
|
21491
|
+
pipelineErrored = this.pipeline.isErrored;
|
|
21492
|
+
if (pipelineErrored) {
|
|
21493
|
+
log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`)();
|
|
21494
|
+
drawSuccess = false;
|
|
21495
|
+
} else {
|
|
21496
|
+
const syncBindings = this._getBindings();
|
|
21497
|
+
const syncBindGroups = this._getBindGroups();
|
|
21498
|
+
const { indexBuffer } = this.vertexArray;
|
|
21499
|
+
const indexCount = indexBuffer ? indexBuffer.byteLength / (indexBuffer.indexType === "uint32" ? 4 : 2) : void 0;
|
|
21500
|
+
drawSuccess = this.pipeline.draw({
|
|
21501
|
+
renderPass,
|
|
21502
|
+
vertexArray: this.vertexArray,
|
|
21503
|
+
isInstanced: this.isInstanced,
|
|
21504
|
+
vertexCount: this.vertexCount,
|
|
21505
|
+
instanceCount: this.instanceCount,
|
|
21506
|
+
indexCount,
|
|
21507
|
+
transformFeedback: this.transformFeedback || void 0,
|
|
21508
|
+
// Pipelines may be shared across models when caching is enabled, so bindings
|
|
21509
|
+
// and WebGL uniforms must be supplied on every draw instead of being stored
|
|
21510
|
+
// on the pipeline instance.
|
|
21511
|
+
bindings: syncBindings,
|
|
21512
|
+
bindGroups: syncBindGroups,
|
|
21513
|
+
_bindGroupCacheKeys: this._getBindGroupCacheKeys(),
|
|
21514
|
+
uniforms: this.props.uniforms,
|
|
21515
|
+
// WebGL shares underlying cached pipelines even for models that have different parameters and topology,
|
|
21516
|
+
// so we must provide our unique parameters to each draw
|
|
21517
|
+
// (In WebGPU most parameters are encoded in the pipeline and cannot be changed per draw call)
|
|
21518
|
+
parameters: this.parameters,
|
|
21519
|
+
topology: this.topology
|
|
21520
|
+
});
|
|
21521
|
+
}
|
|
21079
21522
|
} finally {
|
|
21080
21523
|
renderPass.popDebugGroup();
|
|
21081
21524
|
this._logDrawCallEnd();
|
|
@@ -21084,6 +21527,8 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
21084
21527
|
if (drawSuccess) {
|
|
21085
21528
|
this._lastDrawTimestamp = this.device.timestamp;
|
|
21086
21529
|
this._needsRedraw = false;
|
|
21530
|
+
} else if (pipelineErrored) {
|
|
21531
|
+
this._needsRedraw = PIPELINE_INITIALIZATION_FAILED;
|
|
21087
21532
|
} else {
|
|
21088
21533
|
this._needsRedraw = "waiting for resource initialization";
|
|
21089
21534
|
}
|
|
@@ -21434,9 +21879,10 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
21434
21879
|
return;
|
|
21435
21880
|
}
|
|
21436
21881
|
const framebuffer = renderPass.props.framebuffer;
|
|
21437
|
-
|
|
21438
|
-
|
|
21439
|
-
|
|
21882
|
+
debugFramebuffer(renderPass, framebuffer, {
|
|
21883
|
+
id: framebuffer?.id || `${this.id}-framebuffer`,
|
|
21884
|
+
minimap: true
|
|
21885
|
+
});
|
|
21440
21886
|
}
|
|
21441
21887
|
_getAttributeDebugTable() {
|
|
21442
21888
|
const table = {};
|
|
@@ -22864,7 +23310,7 @@ ${props.source}` };
|
|
|
22864
23310
|
|
|
22865
23311
|
// ../../node_modules/@loaders.gl/loader-utils/dist/lib/log-utils/log.js
|
|
22866
23312
|
init_dist3();
|
|
22867
|
-
var VERSION2 = true ? "4.4.
|
|
23313
|
+
var VERSION2 = true ? "4.4.1" : "latest";
|
|
22868
23314
|
var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
|
|
22869
23315
|
function createLog() {
|
|
22870
23316
|
const log3 = new ProbeLog({ id: "loaders.gl" });
|
|
@@ -22912,7 +23358,7 @@ ${props.source}` };
|
|
|
22912
23358
|
}
|
|
22913
23359
|
|
|
22914
23360
|
// ../../node_modules/@loaders.gl/worker-utils/dist/lib/npm-tag.js
|
|
22915
|
-
var NPM_TAG = "
|
|
23361
|
+
var NPM_TAG = "latest";
|
|
22916
23362
|
|
|
22917
23363
|
// ../../node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js
|
|
22918
23364
|
function getVersion() {
|
|
@@ -22923,7 +23369,7 @@ ${props.source}` };
|
|
|
22923
23369
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
22924
23370
|
warningIssued = true;
|
|
22925
23371
|
} else {
|
|
22926
|
-
globalThis._loadersgl_.version = "4.4.
|
|
23372
|
+
globalThis._loadersgl_.version = "4.4.1";
|
|
22927
23373
|
}
|
|
22928
23374
|
}
|
|
22929
23375
|
return globalThis._loadersgl_.version;
|
|
@@ -24043,8 +24489,8 @@ ${props.source}` };
|
|
|
24043
24489
|
// ../../node_modules/@loaders.gl/core/dist/lib/loader-utils/option-defaults.js
|
|
24044
24490
|
var DEFAULT_LOADER_OPTIONS = {
|
|
24045
24491
|
core: {
|
|
24046
|
-
|
|
24047
|
-
//
|
|
24492
|
+
baseUrl: void 0,
|
|
24493
|
+
// baseUrl
|
|
24048
24494
|
fetch: null,
|
|
24049
24495
|
mimeType: void 0,
|
|
24050
24496
|
fallbackMimeType: void 0,
|
|
@@ -24076,8 +24522,8 @@ ${props.source}` };
|
|
|
24076
24522
|
}
|
|
24077
24523
|
};
|
|
24078
24524
|
var REMOVED_LOADER_OPTIONS = {
|
|
24079
|
-
//
|
|
24080
|
-
baseUri: "core.
|
|
24525
|
+
// deprecated top-level alias
|
|
24526
|
+
baseUri: "core.baseUrl",
|
|
24081
24527
|
fetch: "core.fetch",
|
|
24082
24528
|
mimeType: "core.mimeType",
|
|
24083
24529
|
fallbackMimeType: "core.fallbackMimeType",
|
|
@@ -24102,7 +24548,7 @@ ${props.source}` };
|
|
|
24102
24548
|
// Older deprecations
|
|
24103
24549
|
throws: "nothrow",
|
|
24104
24550
|
dataType: "(no longer used)",
|
|
24105
|
-
uri: "
|
|
24551
|
+
uri: "core.baseUrl",
|
|
24106
24552
|
// Warn if fetch options are used on toplevel
|
|
24107
24553
|
method: "core.fetch.method",
|
|
24108
24554
|
headers: "core.fetch.headers",
|
|
@@ -24120,7 +24566,7 @@ ${props.source}` };
|
|
|
24120
24566
|
|
|
24121
24567
|
// ../../node_modules/@loaders.gl/core/dist/lib/loader-utils/option-utils.js
|
|
24122
24568
|
var CORE_LOADER_OPTION_KEYS = [
|
|
24123
|
-
"
|
|
24569
|
+
"baseUrl",
|
|
24124
24570
|
"fetch",
|
|
24125
24571
|
"mimeType",
|
|
24126
24572
|
"fallbackMimeType",
|
|
@@ -24260,11 +24706,10 @@ ${props.source}` };
|
|
|
24260
24706
|
if (!url) {
|
|
24261
24707
|
return;
|
|
24262
24708
|
}
|
|
24263
|
-
const
|
|
24264
|
-
|
|
24265
|
-
if (!hasTopLevelBaseUri && !hasCoreBaseUri) {
|
|
24709
|
+
const hasCoreBaseUrl = options.core?.baseUrl !== void 0;
|
|
24710
|
+
if (!hasCoreBaseUrl) {
|
|
24266
24711
|
options.core ||= {};
|
|
24267
|
-
options.core.
|
|
24712
|
+
options.core.baseUrl = path_exports.dirname(stripQueryString(url));
|
|
24268
24713
|
}
|
|
24269
24714
|
}
|
|
24270
24715
|
function cloneLoaderOptions(options) {
|
|
@@ -24275,6 +24720,12 @@ ${props.source}` };
|
|
|
24275
24720
|
return clonedOptions;
|
|
24276
24721
|
}
|
|
24277
24722
|
function moveDeprecatedTopLevelOptionsToCore(options) {
|
|
24723
|
+
if (options.baseUri !== void 0) {
|
|
24724
|
+
options.core ||= {};
|
|
24725
|
+
if (options.core.baseUrl === void 0) {
|
|
24726
|
+
options.core.baseUrl = options.baseUri;
|
|
24727
|
+
}
|
|
24728
|
+
}
|
|
24278
24729
|
for (const key of CORE_LOADER_OPTION_KEYS) {
|
|
24279
24730
|
if (options[key] !== void 0) {
|
|
24280
24731
|
const coreOptions = options.core = options.core || {};
|
|
@@ -24364,6 +24815,13 @@ ${props.source}` };
|
|
|
24364
24815
|
}
|
|
24365
24816
|
const normalizedOptions = normalizeLoaderOptions(options || {});
|
|
24366
24817
|
normalizedOptions.core ||= {};
|
|
24818
|
+
if (data instanceof Response && mayContainText(data)) {
|
|
24819
|
+
const text = await data.clone().text();
|
|
24820
|
+
const textLoader = selectLoaderSync(text, loaders, { ...normalizedOptions, core: { ...normalizedOptions.core, nothrow: true } }, context);
|
|
24821
|
+
if (textLoader) {
|
|
24822
|
+
return textLoader;
|
|
24823
|
+
}
|
|
24824
|
+
}
|
|
24367
24825
|
let loader = selectLoaderSync(data, loaders, { ...normalizedOptions, core: { ...normalizedOptions.core, nothrow: true } }, context);
|
|
24368
24826
|
if (loader) {
|
|
24369
24827
|
return loader;
|
|
@@ -24372,11 +24830,19 @@ ${props.source}` };
|
|
|
24372
24830
|
data = await data.slice(0, 10).arrayBuffer();
|
|
24373
24831
|
loader = selectLoaderSync(data, loaders, normalizedOptions, context);
|
|
24374
24832
|
}
|
|
24833
|
+
if (!loader && data instanceof Response && mayContainText(data)) {
|
|
24834
|
+
const text = await data.clone().text();
|
|
24835
|
+
loader = selectLoaderSync(text, loaders, normalizedOptions, context);
|
|
24836
|
+
}
|
|
24375
24837
|
if (!loader && !normalizedOptions.core.nothrow) {
|
|
24376
24838
|
throw new Error(getNoValidLoaderMessage(data));
|
|
24377
24839
|
}
|
|
24378
24840
|
return loader;
|
|
24379
24841
|
}
|
|
24842
|
+
function mayContainText(response) {
|
|
24843
|
+
const mimeType = getResourceMIMEType(response);
|
|
24844
|
+
return Boolean(mimeType && (mimeType.startsWith("text/") || mimeType === "application/json" || mimeType.endsWith("+json")));
|
|
24845
|
+
}
|
|
24380
24846
|
function selectLoaderSync(data, loaders = [], options, context) {
|
|
24381
24847
|
if (!validHTTPResponse(data)) {
|
|
24382
24848
|
return null;
|
|
@@ -24805,11 +25271,23 @@ ${props.source}` };
|
|
|
24805
25271
|
if (isBlob(url)) {
|
|
24806
25272
|
data = await fetch2(url);
|
|
24807
25273
|
}
|
|
25274
|
+
if (typeof url === "string") {
|
|
25275
|
+
const normalizedOptions = normalizeLoaderOptions(resolvedOptions || {});
|
|
25276
|
+
if (!normalizedOptions.core?.baseUrl) {
|
|
25277
|
+
resolvedOptions = {
|
|
25278
|
+
...resolvedOptions,
|
|
25279
|
+
core: {
|
|
25280
|
+
...resolvedOptions?.core,
|
|
25281
|
+
baseUrl: url
|
|
25282
|
+
}
|
|
25283
|
+
};
|
|
25284
|
+
}
|
|
25285
|
+
}
|
|
24808
25286
|
return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions) : await parse(data, resolvedLoaders, resolvedOptions);
|
|
24809
25287
|
}
|
|
24810
25288
|
|
|
24811
25289
|
// ../../node_modules/@loaders.gl/images/dist/lib/utils/version.js
|
|
24812
|
-
var VERSION4 = true ? "4.4.
|
|
25290
|
+
var VERSION4 = true ? "4.4.1" : "latest";
|
|
24813
25291
|
|
|
24814
25292
|
// ../../node_modules/@loaders.gl/images/dist/lib/category-api/image-type.js
|
|
24815
25293
|
var parseImageNode = globalThis.loaders?.parseImageNode;
|
|
@@ -24858,13 +25336,13 @@ ${props.source}` };
|
|
|
24858
25336
|
return image;
|
|
24859
25337
|
case "image":
|
|
24860
25338
|
case "imagebitmap":
|
|
24861
|
-
const
|
|
24862
|
-
const context =
|
|
25339
|
+
const canvas = document.createElement("canvas");
|
|
25340
|
+
const context = canvas.getContext("2d");
|
|
24863
25341
|
if (!context) {
|
|
24864
25342
|
throw new Error("getImageData");
|
|
24865
25343
|
}
|
|
24866
|
-
|
|
24867
|
-
|
|
25344
|
+
canvas.width = image.width;
|
|
25345
|
+
canvas.height = image.height;
|
|
24868
25346
|
context.drawImage(image, 0, 0);
|
|
24869
25347
|
return context.getImageData(0, 0, image.width, image.height);
|
|
24870
25348
|
default:
|
|
@@ -27270,33 +27748,33 @@ float smoothedge(float edge, float x) {
|
|
|
27270
27748
|
/**
|
|
27271
27749
|
* `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise
|
|
27272
27750
|
*/
|
|
27273
|
-
DEFAULT:
|
|
27751
|
+
DEFAULT: "default",
|
|
27274
27752
|
/**
|
|
27275
27753
|
* Positions are interpreted as [longitude, latitude, elevation]
|
|
27276
27754
|
* longitude/latitude are in degrees, elevation is in meters.
|
|
27277
27755
|
* Dimensions are in meters.
|
|
27278
27756
|
*/
|
|
27279
|
-
LNGLAT:
|
|
27757
|
+
LNGLAT: "lnglat",
|
|
27280
27758
|
/**
|
|
27281
27759
|
* Positions are interpreted as [x, y, z] in meter offsets from the coordinate origin.
|
|
27282
27760
|
* Dimensions are in meters.
|
|
27283
27761
|
*/
|
|
27284
|
-
METER_OFFSETS:
|
|
27762
|
+
METER_OFFSETS: "meter-offsets",
|
|
27285
27763
|
/**
|
|
27286
27764
|
* Positions are interpreted as [deltaLng, deltaLat, elevation] from the coordinate origin.
|
|
27287
27765
|
* deltaLng/deltaLat are in degrees, elevation is in meters.
|
|
27288
27766
|
* Dimensions are in meters.
|
|
27289
27767
|
*/
|
|
27290
|
-
LNGLAT_OFFSETS:
|
|
27768
|
+
LNGLAT_OFFSETS: "lnglat-offsets",
|
|
27291
27769
|
/**
|
|
27292
27770
|
* Positions and dimensions are in the common units of the viewport.
|
|
27293
27771
|
*/
|
|
27294
|
-
CARTESIAN:
|
|
27772
|
+
CARTESIAN: "cartesian"
|
|
27295
27773
|
};
|
|
27296
27774
|
Object.defineProperty(COORDINATE_SYSTEM, "IDENTITY", {
|
|
27297
27775
|
get: () => {
|
|
27298
27776
|
log_default.deprecated("COORDINATE_SYSTEM.IDENTITY", "COORDINATE_SYSTEM.CARTESIAN")();
|
|
27299
|
-
return
|
|
27777
|
+
return COORDINATE_SYSTEM.CARTESIAN;
|
|
27300
27778
|
}
|
|
27301
27779
|
});
|
|
27302
27780
|
var PROJECTION_MODE = {
|
|
@@ -27382,6 +27860,20 @@ float smoothedge(float edge, float x) {
|
|
|
27382
27860
|
var IDENTITY_MATRIX2 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
27383
27861
|
var DEFAULT_PIXELS_PER_UNIT2 = [0, 0, 0];
|
|
27384
27862
|
var DEFAULT_COORDINATE_ORIGIN = [0, 0, 0];
|
|
27863
|
+
var COORDINATE_SYSTEM_NUMBERS = {
|
|
27864
|
+
default: -1,
|
|
27865
|
+
cartesian: 0,
|
|
27866
|
+
lnglat: 1,
|
|
27867
|
+
"meter-offsets": 2,
|
|
27868
|
+
"lnglat-offsets": 3
|
|
27869
|
+
};
|
|
27870
|
+
function getShaderCoordinateSystem(coordinateSystem) {
|
|
27871
|
+
const shaderCoordinateSystem = COORDINATE_SYSTEM_NUMBERS[coordinateSystem];
|
|
27872
|
+
if (shaderCoordinateSystem === void 0) {
|
|
27873
|
+
throw new Error(`Invalid coordinateSystem: ${coordinateSystem}`);
|
|
27874
|
+
}
|
|
27875
|
+
return shaderCoordinateSystem;
|
|
27876
|
+
}
|
|
27385
27877
|
var getMemoizedViewportUniforms = memoize(calculateViewportUniforms);
|
|
27386
27878
|
function getOffsetOrigin(viewport, coordinateSystem, coordinateOrigin = DEFAULT_COORDINATE_ORIGIN) {
|
|
27387
27879
|
if (coordinateOrigin.length < 3) {
|
|
@@ -27390,7 +27882,7 @@ float smoothedge(float edge, float x) {
|
|
|
27390
27882
|
let shaderCoordinateOrigin = coordinateOrigin;
|
|
27391
27883
|
let geospatialOrigin;
|
|
27392
27884
|
let offsetMode = true;
|
|
27393
|
-
if (coordinateSystem ===
|
|
27885
|
+
if (coordinateSystem === "lnglat-offsets" || coordinateSystem === "meter-offsets") {
|
|
27394
27886
|
geospatialOrigin = coordinateOrigin;
|
|
27395
27887
|
} else {
|
|
27396
27888
|
geospatialOrigin = viewport.isGeospatial ? (
|
|
@@ -27400,15 +27892,15 @@ float smoothedge(float edge, float x) {
|
|
|
27400
27892
|
}
|
|
27401
27893
|
switch (viewport.projectionMode) {
|
|
27402
27894
|
case PROJECTION_MODE.WEB_MERCATOR:
|
|
27403
|
-
if (coordinateSystem ===
|
|
27895
|
+
if (coordinateSystem === "lnglat" || coordinateSystem === "cartesian") {
|
|
27404
27896
|
geospatialOrigin = [0, 0, 0];
|
|
27405
27897
|
offsetMode = false;
|
|
27406
27898
|
}
|
|
27407
27899
|
break;
|
|
27408
27900
|
case PROJECTION_MODE.WEB_MERCATOR_AUTO_OFFSET:
|
|
27409
|
-
if (coordinateSystem ===
|
|
27901
|
+
if (coordinateSystem === "lnglat") {
|
|
27410
27902
|
shaderCoordinateOrigin = geospatialOrigin;
|
|
27411
|
-
} else if (coordinateSystem ===
|
|
27903
|
+
} else if (coordinateSystem === "cartesian") {
|
|
27412
27904
|
shaderCoordinateOrigin = [
|
|
27413
27905
|
Math.fround(viewport.center[0]),
|
|
27414
27906
|
Math.fround(viewport.center[1]),
|
|
@@ -27472,12 +27964,12 @@ float smoothedge(float edge, float x) {
|
|
|
27472
27964
|
devicePixelRatio: devicePixelRatio2 = 1,
|
|
27473
27965
|
modelMatrix = null,
|
|
27474
27966
|
// Match Layer.defaultProps
|
|
27475
|
-
coordinateSystem =
|
|
27967
|
+
coordinateSystem = "default",
|
|
27476
27968
|
coordinateOrigin = DEFAULT_COORDINATE_ORIGIN,
|
|
27477
27969
|
autoWrapLongitude = false
|
|
27478
27970
|
}) {
|
|
27479
|
-
if (coordinateSystem ===
|
|
27480
|
-
coordinateSystem = viewport.isGeospatial ?
|
|
27971
|
+
if (coordinateSystem === "default") {
|
|
27972
|
+
coordinateSystem = viewport.isGeospatial ? "lnglat" : "cartesian";
|
|
27481
27973
|
}
|
|
27482
27974
|
const uniforms = getMemoizedViewportUniforms({
|
|
27483
27975
|
viewport,
|
|
@@ -27511,7 +28003,7 @@ float smoothedge(float edge, float x) {
|
|
|
27511
28003
|
const focalDistance = vec4_exports.transformMat4([], [0, 0, -viewport.focalDistance, 1], viewport.projectionMatrix)[3] || 1;
|
|
27512
28004
|
const uniforms = {
|
|
27513
28005
|
// Projection mode values
|
|
27514
|
-
coordinateSystem,
|
|
28006
|
+
coordinateSystem: getShaderCoordinateSystem(coordinateSystem),
|
|
27515
28007
|
projectionMode: viewport.projectionMode,
|
|
27516
28008
|
coordinateOrigin: shaderCoordinateOrigin,
|
|
27517
28009
|
commonOrigin: originCommon.slice(0, 3),
|
|
@@ -27538,19 +28030,19 @@ float smoothedge(float edge, float x) {
|
|
|
27538
28030
|
if (geospatialOrigin) {
|
|
27539
28031
|
const distanceScalesAtOrigin = viewport.getDistanceScales(geospatialOrigin);
|
|
27540
28032
|
switch (coordinateSystem) {
|
|
27541
|
-
case
|
|
28033
|
+
case "meter-offsets":
|
|
27542
28034
|
uniforms.commonUnitsPerWorldUnit = distanceScalesAtOrigin.unitsPerMeter;
|
|
27543
28035
|
uniforms.commonUnitsPerWorldUnit2 = distanceScalesAtOrigin.unitsPerMeter2;
|
|
27544
28036
|
break;
|
|
27545
|
-
case
|
|
27546
|
-
case
|
|
28037
|
+
case "lnglat":
|
|
28038
|
+
case "lnglat-offsets":
|
|
27547
28039
|
if (!viewport._pseudoMeters) {
|
|
27548
28040
|
uniforms.commonUnitsPerMeter = distanceScalesAtOrigin.unitsPerMeter;
|
|
27549
28041
|
}
|
|
27550
28042
|
uniforms.commonUnitsPerWorldUnit = distanceScalesAtOrigin.unitsPerDegree;
|
|
27551
28043
|
uniforms.commonUnitsPerWorldUnit2 = distanceScalesAtOrigin.unitsPerDegree2;
|
|
27552
28044
|
break;
|
|
27553
|
-
case
|
|
28045
|
+
case "cartesian":
|
|
27554
28046
|
uniforms.commonUnitsPerWorldUnit = [1, 1, distanceScalesAtOrigin.unitsPerMeter[2]];
|
|
27555
28047
|
uniforms.commonUnitsPerWorldUnit2 = [0, 0, distanceScalesAtOrigin.unitsPerMeter2[2]];
|
|
27556
28048
|
break;
|
|
@@ -27562,7 +28054,16 @@ float smoothedge(float edge, float x) {
|
|
|
27562
28054
|
}
|
|
27563
28055
|
|
|
27564
28056
|
// src/shaderlib/project/project.wgsl.ts
|
|
27565
|
-
var
|
|
28057
|
+
var SHADER_COORDINATE_SYSTEMS = [
|
|
28058
|
+
"default",
|
|
28059
|
+
"lnglat",
|
|
28060
|
+
"meter-offsets",
|
|
28061
|
+
"lnglat-offsets",
|
|
28062
|
+
"cartesian"
|
|
28063
|
+
];
|
|
28064
|
+
var COORDINATE_SYSTEM_WGSL_CONSTANTS = SHADER_COORDINATE_SYSTEMS.map(
|
|
28065
|
+
(coordinateSystem) => `const COORDINATE_SYSTEM_${coordinateSystem.toUpperCase().replaceAll("-", "_")}: i32 = ${getShaderCoordinateSystem(coordinateSystem)};`
|
|
28066
|
+
).join("");
|
|
27566
28067
|
var PROJECTION_MODE_WGSL_CONSTANTS = Object.keys(PROJECTION_MODE).map((key) => `const PROJECTION_MODE_${key}: i32 = ${PROJECTION_MODE[key]};`).join("");
|
|
27567
28068
|
var UNIT_WGSL_CONSTANTS = Object.keys(UNIT).map((key) => `const UNIT_${key.toUpperCase()}: i32 = ${UNIT[key]};`).join("");
|
|
27568
28069
|
var projectWGSLHeader = (
|
|
@@ -27856,7 +28357,16 @@ fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {
|
|
|
27856
28357
|
);
|
|
27857
28358
|
|
|
27858
28359
|
// src/shaderlib/project/project.glsl.ts
|
|
27859
|
-
var
|
|
28360
|
+
var SHADER_COORDINATE_SYSTEMS2 = [
|
|
28361
|
+
"default",
|
|
28362
|
+
"lnglat",
|
|
28363
|
+
"meter-offsets",
|
|
28364
|
+
"lnglat-offsets",
|
|
28365
|
+
"cartesian"
|
|
28366
|
+
];
|
|
28367
|
+
var COORDINATE_SYSTEM_GLSL_CONSTANTS = SHADER_COORDINATE_SYSTEMS2.map(
|
|
28368
|
+
(coordinateSystem) => `const int COORDINATE_SYSTEM_${coordinateSystem.toUpperCase().replaceAll("-", "_")} = ${getShaderCoordinateSystem(coordinateSystem)};`
|
|
28369
|
+
).join("");
|
|
27860
28370
|
var PROJECTION_MODE_GLSL_CONSTANTS = Object.keys(PROJECTION_MODE).map((key) => `const int PROJECTION_MODE_${key} = ${PROJECTION_MODE[key]};`).join("");
|
|
27861
28371
|
var UNIT_GLSL_CONSTANTS = Object.keys(UNIT).map((key) => `const int UNIT_${key.toUpperCase()} = ${UNIT[key]};`).join("");
|
|
27862
28372
|
var projectGLSL = (
|
|
@@ -28764,7 +29274,7 @@ ${fragment}
|
|
|
28764
29274
|
for (let i = 0; i < opts.shadowMatrices.length; i++) {
|
|
28765
29275
|
const viewProjectionMatrix = viewProjectionMatrices[i];
|
|
28766
29276
|
const viewProjectionMatrixCentered = viewProjectionMatrix.clone().translate(new Vector3(projectProps.viewport.center).negate());
|
|
28767
|
-
if (projectUniforms.coordinateSystem ===
|
|
29277
|
+
if (projectUniforms.coordinateSystem === getShaderCoordinateSystem("lnglat") && projectUniforms.projectionMode === PROJECTION_MODE.WEB_MERCATOR) {
|
|
28768
29278
|
viewProjectionMatrices[i] = viewProjectionMatrixCentered;
|
|
28769
29279
|
projectCenters[i] = center;
|
|
28770
29280
|
} else {
|
|
@@ -28824,7 +29334,7 @@ ${fragment}
|
|
|
28824
29334
|
isActive: f32,
|
|
28825
29335
|
isAttribute: f32,
|
|
28826
29336
|
isHighlightActive: f32,
|
|
28827
|
-
|
|
29337
|
+
useByteColors: f32,
|
|
28828
29338
|
highlightedObjectColor: vec3<f32>,
|
|
28829
29339
|
highlightColor: vec4<f32>,
|
|
28830
29340
|
};
|
|
@@ -28832,11 +29342,11 @@ ${fragment}
|
|
|
28832
29342
|
@group(0) @binding(auto) var<uniform> picking: pickingUniforms;
|
|
28833
29343
|
|
|
28834
29344
|
fn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {
|
|
28835
|
-
return select(color / 255.0,
|
|
29345
|
+
return select(color, color / 255.0, picking.useByteColors > 0.5);
|
|
28836
29346
|
}
|
|
28837
29347
|
|
|
28838
29348
|
fn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {
|
|
28839
|
-
return select(color / 255.0,
|
|
29349
|
+
return select(color, color / 255.0, picking.useByteColors > 0.5);
|
|
28840
29350
|
}
|
|
28841
29351
|
|
|
28842
29352
|
fn picking_isColorZero(color: vec3<f32>) -> bool {
|
|
@@ -28851,7 +29361,7 @@ fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
|
28851
29361
|
var picking_default = {
|
|
28852
29362
|
...picking,
|
|
28853
29363
|
source: sourceWGSL,
|
|
28854
|
-
defaultUniforms: { ...picking.defaultUniforms,
|
|
29364
|
+
defaultUniforms: { ...picking.defaultUniforms, useByteColors: true },
|
|
28855
29365
|
inject: {
|
|
28856
29366
|
"vs:DECKGL_FILTER_GL_POSITION": `
|
|
28857
29367
|
// for picking depth values
|
|
@@ -28957,6 +29467,16 @@ fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
|
28957
29467
|
};
|
|
28958
29468
|
|
|
28959
29469
|
// src/passes/layers-pass.ts
|
|
29470
|
+
var WEBGPU_DEFAULT_DRAW_PARAMETERS = {
|
|
29471
|
+
depthWriteEnabled: true,
|
|
29472
|
+
depthCompare: "less-equal",
|
|
29473
|
+
blendColorOperation: "add",
|
|
29474
|
+
blendColorSrcFactor: "src-alpha",
|
|
29475
|
+
blendColorDstFactor: "one",
|
|
29476
|
+
blendAlphaOperation: "add",
|
|
29477
|
+
blendAlphaSrcFactor: "one-minus-dst-alpha",
|
|
29478
|
+
blendAlphaDstFactor: "one"
|
|
29479
|
+
};
|
|
28960
29480
|
var LayersPass = class extends Pass {
|
|
28961
29481
|
constructor() {
|
|
28962
29482
|
super(...arguments);
|
|
@@ -29073,7 +29593,9 @@ fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
|
29073
29593
|
pass,
|
|
29074
29594
|
shaderModuleProps
|
|
29075
29595
|
);
|
|
29596
|
+
const defaultParams = layer.context.device.type === "webgpu" ? WEBGPU_DEFAULT_DRAW_PARAMETERS : null;
|
|
29076
29597
|
layerParam.layerParameters = {
|
|
29598
|
+
...defaultParams,
|
|
29077
29599
|
...layer.context.deck?.props.parameters,
|
|
29078
29600
|
...this.getLayerParameters(layer, layerIndex, viewport)
|
|
29079
29601
|
};
|
|
@@ -30219,11 +30741,13 @@ fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
|
30219
30741
|
function normalizeParameters(opts) {
|
|
30220
30742
|
const { viewport, modelMatrix, coordinateOrigin } = opts;
|
|
30221
30743
|
let { coordinateSystem, fromCoordinateSystem, fromCoordinateOrigin } = opts;
|
|
30222
|
-
if (coordinateSystem ===
|
|
30223
|
-
coordinateSystem = viewport.isGeospatial ?
|
|
30744
|
+
if (coordinateSystem === "default") {
|
|
30745
|
+
coordinateSystem = viewport.isGeospatial ? "lnglat" : "cartesian";
|
|
30224
30746
|
}
|
|
30225
30747
|
if (fromCoordinateSystem === void 0) {
|
|
30226
30748
|
fromCoordinateSystem = coordinateSystem;
|
|
30749
|
+
} else if (fromCoordinateSystem === "default") {
|
|
30750
|
+
fromCoordinateSystem = viewport.isGeospatial ? "lnglat" : "cartesian";
|
|
30227
30751
|
}
|
|
30228
30752
|
if (fromCoordinateOrigin === void 0) {
|
|
30229
30753
|
fromCoordinateOrigin = coordinateOrigin;
|
|
@@ -30249,23 +30773,32 @@ fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
|
30249
30773
|
[x, y, z] = vec4_exports.transformMat4([], [x, y, z, 1], modelMatrix);
|
|
30250
30774
|
}
|
|
30251
30775
|
switch (coordinateSystem) {
|
|
30252
|
-
case
|
|
30776
|
+
case "default":
|
|
30777
|
+
return getWorldPosition(position, {
|
|
30778
|
+
viewport,
|
|
30779
|
+
modelMatrix,
|
|
30780
|
+
coordinateSystem: viewport.isGeospatial ? "lnglat" : "cartesian",
|
|
30781
|
+
coordinateOrigin,
|
|
30782
|
+
offsetMode
|
|
30783
|
+
});
|
|
30784
|
+
case "lnglat":
|
|
30253
30785
|
return lngLatZToWorldPosition([x, y, z], viewport, offsetMode);
|
|
30254
|
-
case
|
|
30786
|
+
case "lnglat-offsets":
|
|
30255
30787
|
return lngLatZToWorldPosition(
|
|
30256
30788
|
[x + coordinateOrigin[0], y + coordinateOrigin[1], z + (coordinateOrigin[2] || 0)],
|
|
30257
30789
|
viewport,
|
|
30258
30790
|
offsetMode
|
|
30259
30791
|
);
|
|
30260
|
-
case
|
|
30792
|
+
case "meter-offsets":
|
|
30261
30793
|
return lngLatZToWorldPosition(
|
|
30262
30794
|
addMetersToLngLat(coordinateOrigin, [x, y, z]),
|
|
30263
30795
|
viewport,
|
|
30264
30796
|
offsetMode
|
|
30265
30797
|
);
|
|
30266
|
-
case
|
|
30267
|
-
default:
|
|
30798
|
+
case "cartesian":
|
|
30268
30799
|
return viewport.isGeospatial ? [x + coordinateOrigin[0], y + coordinateOrigin[1], z + coordinateOrigin[2]] : viewport.projectPosition([x, y, z]);
|
|
30800
|
+
default:
|
|
30801
|
+
throw new Error(`Invalid coordinateSystem: ${coordinateSystem}`);
|
|
30269
30802
|
}
|
|
30270
30803
|
}
|
|
30271
30804
|
function projectPosition(position, params) {
|
|
@@ -34014,9 +34547,9 @@ void main() {
|
|
|
34014
34547
|
this.depthFBO = depthFBO;
|
|
34015
34548
|
}
|
|
34016
34549
|
}
|
|
34017
|
-
const { canvas
|
|
34018
|
-
this.pickingFBO?.resize({ width:
|
|
34019
|
-
this.depthFBO?.resize({ width:
|
|
34550
|
+
const { canvas } = this.device.getDefaultCanvasContext();
|
|
34551
|
+
this.pickingFBO?.resize({ width: canvas.width, height: canvas.height });
|
|
34552
|
+
this.depthFBO?.resize({ width: canvas.width, height: canvas.height });
|
|
34020
34553
|
}
|
|
34021
34554
|
/** Preliminary filtering of the layers list. Skid picking pass if no layer is pickable. */
|
|
34022
34555
|
_getPickable(layers) {
|
|
@@ -35660,25 +36193,25 @@ void main() {
|
|
|
35660
36193
|
}
|
|
35661
36194
|
/** Resolve props.canvas to element */
|
|
35662
36195
|
_createCanvas(props) {
|
|
35663
|
-
let
|
|
35664
|
-
if (typeof
|
|
35665
|
-
|
|
35666
|
-
assert9(
|
|
35667
|
-
}
|
|
35668
|
-
if (!
|
|
35669
|
-
|
|
35670
|
-
|
|
36196
|
+
let canvas = props.canvas;
|
|
36197
|
+
if (typeof canvas === "string") {
|
|
36198
|
+
canvas = document.getElementById(canvas);
|
|
36199
|
+
assert9(canvas);
|
|
36200
|
+
}
|
|
36201
|
+
if (!canvas) {
|
|
36202
|
+
canvas = document.createElement("canvas");
|
|
36203
|
+
canvas.id = props.id || "deckgl-overlay";
|
|
35671
36204
|
if (props.width && typeof props.width === "number") {
|
|
35672
|
-
|
|
36205
|
+
canvas.width = props.width;
|
|
35673
36206
|
}
|
|
35674
36207
|
if (props.height && typeof props.height === "number") {
|
|
35675
|
-
|
|
36208
|
+
canvas.height = props.height;
|
|
35676
36209
|
}
|
|
35677
36210
|
const parent = props.parent || document.body;
|
|
35678
|
-
parent.appendChild(
|
|
36211
|
+
parent.appendChild(canvas);
|
|
35679
36212
|
}
|
|
35680
|
-
Object.assign(
|
|
35681
|
-
return
|
|
36213
|
+
Object.assign(canvas.style, props.style);
|
|
36214
|
+
return canvas;
|
|
35682
36215
|
}
|
|
35683
36216
|
/** Updates canvas width and/or height, if provided as props */
|
|
35684
36217
|
_setCanvasSize(props) {
|
|
@@ -35698,12 +36231,12 @@ void main() {
|
|
|
35698
36231
|
}
|
|
35699
36232
|
/** If canvas size has changed, reads out the new size and update */
|
|
35700
36233
|
_updateCanvasSize() {
|
|
35701
|
-
const { canvas
|
|
35702
|
-
if (!
|
|
36234
|
+
const { canvas } = this;
|
|
36235
|
+
if (!canvas) {
|
|
35703
36236
|
return;
|
|
35704
36237
|
}
|
|
35705
|
-
const newWidth =
|
|
35706
|
-
const newHeight =
|
|
36238
|
+
const newWidth = canvas.clientWidth ?? canvas.width;
|
|
36239
|
+
const newHeight = canvas.clientHeight ?? canvas.height;
|
|
35707
36240
|
if (newWidth !== this.width || newHeight !== this.height) {
|
|
35708
36241
|
this.width = newWidth;
|
|
35709
36242
|
this.height = newHeight;
|
|
@@ -36714,10 +37247,14 @@ void main() {
|
|
|
36714
37247
|
}
|
|
36715
37248
|
if (!this.value) {
|
|
36716
37249
|
} else if (this.constant || !this.buffer || this.buffer.byteLength < this.value.byteLength + this.byteOffset) {
|
|
36717
|
-
this.
|
|
36718
|
-
|
|
36719
|
-
|
|
36720
|
-
|
|
37250
|
+
if (this.constant) {
|
|
37251
|
+
this.setConstantValue(context, this.value);
|
|
37252
|
+
} else {
|
|
37253
|
+
this.setData({
|
|
37254
|
+
value: this.value,
|
|
37255
|
+
constant: this.constant
|
|
37256
|
+
});
|
|
37257
|
+
}
|
|
36721
37258
|
this.constant = false;
|
|
36722
37259
|
} else {
|
|
36723
37260
|
for (const [startRow, endRow] of updateRanges) {
|
|
@@ -36737,17 +37274,13 @@ void main() {
|
|
|
36737
37274
|
// Use generic value
|
|
36738
37275
|
// Returns true if successful
|
|
36739
37276
|
setConstantValue(context, value) {
|
|
36740
|
-
|
|
36741
|
-
if (isWebGPU || value === void 0 || typeof value === "function") {
|
|
36742
|
-
if (isWebGPU && typeof value !== "function") {
|
|
36743
|
-
const normalisedValue = this._normalizeValue(value, [], 0);
|
|
36744
|
-
if (!this._areValuesEqual(normalisedValue, this.value)) {
|
|
36745
|
-
this.setNeedsUpdate("WebGPU constant updated");
|
|
36746
|
-
}
|
|
36747
|
-
}
|
|
37277
|
+
if (value === void 0 || typeof value === "function") {
|
|
36748
37278
|
return false;
|
|
36749
37279
|
}
|
|
36750
37280
|
const transformedValue = this.settings.transform && context ? this.settings.transform.call(context, value) : value;
|
|
37281
|
+
if (this.device.type === "webgpu") {
|
|
37282
|
+
return this.setConstantBufferValue(transformedValue, this.numInstances);
|
|
37283
|
+
}
|
|
36751
37284
|
const hasChanged = this.setData({ constant: true, value: transformedValue });
|
|
36752
37285
|
if (hasChanged) {
|
|
36753
37286
|
this.setNeedsRedraw();
|
|
@@ -36755,6 +37288,41 @@ void main() {
|
|
|
36755
37288
|
this.clearNeedsUpdate();
|
|
36756
37289
|
return true;
|
|
36757
37290
|
}
|
|
37291
|
+
setConstantBufferValue(value, numInstances) {
|
|
37292
|
+
const ArrayType = this.settings.defaultType;
|
|
37293
|
+
const constantValue = this._normalizeValue(value, new ArrayType(this.size), 0);
|
|
37294
|
+
if (this._hasConstantBufferValue(constantValue, numInstances)) {
|
|
37295
|
+
this.constant = false;
|
|
37296
|
+
this.clearNeedsUpdate();
|
|
37297
|
+
return false;
|
|
37298
|
+
}
|
|
37299
|
+
const repeatedValue = new ArrayType(Math.max(numInstances, 1) * this.size);
|
|
37300
|
+
for (let i = 0; i < repeatedValue.length; i += this.size) {
|
|
37301
|
+
repeatedValue.set(constantValue, i);
|
|
37302
|
+
}
|
|
37303
|
+
const hasChanged = this.setData({ value: repeatedValue });
|
|
37304
|
+
this.constant = false;
|
|
37305
|
+
this.clearNeedsUpdate();
|
|
37306
|
+
if (hasChanged) {
|
|
37307
|
+
this.setNeedsRedraw();
|
|
37308
|
+
}
|
|
37309
|
+
return hasChanged;
|
|
37310
|
+
}
|
|
37311
|
+
_hasConstantBufferValue(value, numInstances) {
|
|
37312
|
+
const currentValue = this.value;
|
|
37313
|
+
const expectedLength = Math.max(numInstances, 1) * this.size;
|
|
37314
|
+
if (!ArrayBuffer.isView(currentValue) || currentValue.length !== expectedLength || currentValue.length % this.size !== 0) {
|
|
37315
|
+
return false;
|
|
37316
|
+
}
|
|
37317
|
+
for (let i = 0; i < currentValue.length; i += this.size) {
|
|
37318
|
+
for (let j = 0; j < this.size; j++) {
|
|
37319
|
+
if (currentValue[i + j] !== value[j]) {
|
|
37320
|
+
return false;
|
|
37321
|
+
}
|
|
37322
|
+
}
|
|
37323
|
+
}
|
|
37324
|
+
return true;
|
|
37325
|
+
}
|
|
36758
37326
|
// Use external buffer
|
|
36759
37327
|
// Returns true if successful
|
|
36760
37328
|
// eslint-disable-next-line max-statements
|
|
@@ -36863,18 +37431,10 @@ void main() {
|
|
|
36863
37431
|
props,
|
|
36864
37432
|
numInstances
|
|
36865
37433
|
}) {
|
|
36866
|
-
if (attribute.constant) {
|
|
36867
|
-
if (this.context.device.type !== "webgpu") {
|
|
36868
|
-
return;
|
|
36869
|
-
}
|
|
36870
|
-
}
|
|
36871
37434
|
const { settings, state, value, size, startIndices } = attribute;
|
|
36872
37435
|
const { accessor, transform } = settings;
|
|
36873
|
-
|
|
37436
|
+
const accessorFunc = state.binaryAccessor || // @ts-ignore
|
|
36874
37437
|
(typeof accessor === "function" ? accessor : props[accessor]);
|
|
36875
|
-
if (typeof accessorFunc !== "function" && typeof accessor === "string") {
|
|
36876
|
-
accessorFunc = () => props[accessor];
|
|
36877
|
-
}
|
|
36878
37438
|
assert9(typeof accessorFunc === "function", `accessor "${accessor}" is not a function`);
|
|
36879
37439
|
let i = attribute.getVertexOffset(startRow);
|
|
36880
37440
|
const { iterable, objectInfo } = createIterable(data, startRow, endRow);
|
|
@@ -38318,6 +38878,8 @@ void main(void) {
|
|
|
38318
38878
|
});
|
|
38319
38879
|
if (device.type === "webgl") {
|
|
38320
38880
|
texture.generateMipmapsWebGL();
|
|
38881
|
+
} else if (device.type === "webgpu") {
|
|
38882
|
+
device.generateMipmapsWebGPU(texture);
|
|
38321
38883
|
}
|
|
38322
38884
|
internalTextures[texture.id] = owner;
|
|
38323
38885
|
return texture;
|
|
@@ -39028,7 +39590,7 @@ void main(void) {
|
|
|
39028
39590
|
onDragStart: { type: "function", value: null, optional: true },
|
|
39029
39591
|
onDrag: { type: "function", value: null, optional: true },
|
|
39030
39592
|
onDragEnd: { type: "function", value: null, optional: true },
|
|
39031
|
-
coordinateSystem:
|
|
39593
|
+
coordinateSystem: "default",
|
|
39032
39594
|
coordinateOrigin: { type: "array", value: [0, 0, 0], compare: true },
|
|
39033
39595
|
modelMatrix: { type: "array", value: null, compare: true, optional: true },
|
|
39034
39596
|
wrapLongitude: false,
|
|
@@ -39172,7 +39734,7 @@ void main(void) {
|
|
|
39172
39734
|
}
|
|
39173
39735
|
use64bitPositions() {
|
|
39174
39736
|
const { coordinateSystem } = this.props;
|
|
39175
|
-
return coordinateSystem ===
|
|
39737
|
+
return coordinateSystem === "default" || coordinateSystem === "lnglat" || coordinateSystem === "cartesian";
|
|
39176
39738
|
}
|
|
39177
39739
|
// Event handling
|
|
39178
39740
|
onHover(info, pickingEvent) {
|
|
@@ -39552,7 +40114,6 @@ void main(void) {
|
|
|
39552
40114
|
/* (Internal) Called by layer manager when a new layer is found */
|
|
39553
40115
|
_initialize() {
|
|
39554
40116
|
assert9(!this.internalState);
|
|
39555
|
-
assert9(Number.isFinite(this.props.coordinateSystem));
|
|
39556
40117
|
debug(TRACE_INITIALIZE, this);
|
|
39557
40118
|
const attributeManager = this._getAttributeManager();
|
|
39558
40119
|
if (attributeManager) {
|