@deck.gl/geo-layers 9.3.0-alpha.1 → 9.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +1358 -1182
- package/dist.min.js +212 -109
- package/package.json +15 -15
package/dist/dist.dev.js
CHANGED
|
@@ -10208,7 +10208,7 @@ var __exports__ = (() => {
|
|
|
10208
10208
|
}
|
|
10209
10209
|
|
|
10210
10210
|
// ../../node_modules/@loaders.gl/xml/dist/xml-loader.js
|
|
10211
|
-
var VERSION = true ? "4.4.0-alpha.
|
|
10211
|
+
var VERSION = true ? "4.4.0-alpha.18" : "latest";
|
|
10212
10212
|
var XMLLoader = {
|
|
10213
10213
|
dataType: null,
|
|
10214
10214
|
batchType: null,
|
|
@@ -10269,14 +10269,14 @@ var __exports__ = (() => {
|
|
|
10269
10269
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
10270
10270
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
10271
10271
|
|
|
10272
|
-
// ../../node_modules/@probe.gl/
|
|
10272
|
+
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
10273
10273
|
var window_2 = globalThis;
|
|
10274
10274
|
var document_2 = globalThis.document || {};
|
|
10275
10275
|
var process_ = globalThis.process || {};
|
|
10276
10276
|
var console_ = globalThis.console;
|
|
10277
10277
|
var navigator_ = globalThis.navigator || {};
|
|
10278
10278
|
|
|
10279
|
-
// ../../node_modules/@probe.gl/
|
|
10279
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
10280
10280
|
function isElectron(mockUserAgent) {
|
|
10281
10281
|
if (typeof window !== "undefined" && window.process?.type === "renderer") {
|
|
10282
10282
|
return true;
|
|
@@ -10289,7 +10289,7 @@ var __exports__ = (() => {
|
|
|
10289
10289
|
return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
|
|
10290
10290
|
}
|
|
10291
10291
|
|
|
10292
|
-
// ../../node_modules/@probe.gl/
|
|
10292
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
10293
10293
|
function isBrowser2() {
|
|
10294
10294
|
const isNode = (
|
|
10295
10295
|
// @ts-expect-error
|
|
@@ -10298,7 +10298,7 @@ var __exports__ = (() => {
|
|
|
10298
10298
|
return !isNode || isElectron();
|
|
10299
10299
|
}
|
|
10300
10300
|
|
|
10301
|
-
// ../../node_modules/@probe.gl/
|
|
10301
|
+
// ../../node_modules/@probe.gl/env/dist/index.js
|
|
10302
10302
|
var VERSION2 = true ? "4.1.1" : "untranspiled source";
|
|
10303
10303
|
|
|
10304
10304
|
// ../../node_modules/@probe.gl/log/dist/utils/assert.js
|
|
@@ -10791,7 +10791,7 @@ var __exports__ = (() => {
|
|
|
10791
10791
|
var dist_default = new ProbeLog({ id: "@probe.gl/log" });
|
|
10792
10792
|
|
|
10793
10793
|
// ../../node_modules/@loaders.gl/loader-utils/dist/lib/log-utils/log.js
|
|
10794
|
-
var VERSION3 = true ? "4.4.0-alpha.
|
|
10794
|
+
var VERSION3 = true ? "4.4.0-alpha.18" : "latest";
|
|
10795
10795
|
var version = VERSION3[0] >= "0" && VERSION3[0] <= "9" ? `v${VERSION3}` : "";
|
|
10796
10796
|
function createLog() {
|
|
10797
10797
|
const log8 = new ProbeLog({ id: "loaders.gl" });
|
|
@@ -10846,7 +10846,7 @@ var __exports__ = (() => {
|
|
|
10846
10846
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
10847
10847
|
warningIssued = true;
|
|
10848
10848
|
} else {
|
|
10849
|
-
globalThis._loadersgl_.version = "4.4.0-alpha.
|
|
10849
|
+
globalThis._loadersgl_.version = "4.4.0-alpha.18";
|
|
10850
10850
|
}
|
|
10851
10851
|
}
|
|
10852
10852
|
return globalThis._loadersgl_.version;
|
|
@@ -10882,6 +10882,16 @@ var __exports__ = (() => {
|
|
|
10882
10882
|
|
|
10883
10883
|
// ../../node_modules/@loaders.gl/worker-utils/dist/lib/library-utils/library-utils.js
|
|
10884
10884
|
var loadLibraryPromises = {};
|
|
10885
|
+
function extractLoadLibraryOptions(options = {}) {
|
|
10886
|
+
const useLocalLibraries = options.useLocalLibraries ?? options.core?.useLocalLibraries;
|
|
10887
|
+
const CDN = options.CDN ?? options.core?.CDN;
|
|
10888
|
+
const modules = options.modules;
|
|
10889
|
+
return {
|
|
10890
|
+
...useLocalLibraries !== void 0 ? { useLocalLibraries } : {},
|
|
10891
|
+
...CDN !== void 0 ? { CDN } : {},
|
|
10892
|
+
...modules !== void 0 ? { modules } : {}
|
|
10893
|
+
};
|
|
10894
|
+
}
|
|
10885
10895
|
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
10886
10896
|
if (moduleName) {
|
|
10887
10897
|
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
@@ -11067,7 +11077,7 @@ var __exports__ = (() => {
|
|
|
11067
11077
|
return targetOffset + padToNBytes(sourceArray.byteLength, 4);
|
|
11068
11078
|
}
|
|
11069
11079
|
|
|
11070
|
-
// ../../node_modules/@
|
|
11080
|
+
// ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
11071
11081
|
function getHiResTimestamp2() {
|
|
11072
11082
|
let timestamp;
|
|
11073
11083
|
if (typeof window !== "undefined" && window.performance) {
|
|
@@ -11081,7 +11091,7 @@ var __exports__ = (() => {
|
|
|
11081
11091
|
return timestamp;
|
|
11082
11092
|
}
|
|
11083
11093
|
|
|
11084
|
-
// ../../node_modules/@
|
|
11094
|
+
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
11085
11095
|
var Stat = class {
|
|
11086
11096
|
constructor(name12, type) {
|
|
11087
11097
|
this.sampleSize = 1;
|
|
@@ -11202,7 +11212,7 @@ var __exports__ = (() => {
|
|
|
11202
11212
|
}
|
|
11203
11213
|
};
|
|
11204
11214
|
|
|
11205
|
-
// ../../node_modules/@
|
|
11215
|
+
// ../../node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
11206
11216
|
var Stats = class {
|
|
11207
11217
|
constructor(options) {
|
|
11208
11218
|
this.stats = {};
|
|
@@ -11665,7 +11675,7 @@ var __exports__ = (() => {
|
|
|
11665
11675
|
}
|
|
11666
11676
|
|
|
11667
11677
|
// ../../node_modules/@loaders.gl/wms/dist/wms-error-loader.js
|
|
11668
|
-
var VERSION5 = true ? "4.4.0-alpha.
|
|
11678
|
+
var VERSION5 = true ? "4.4.0-alpha.18" : "latest";
|
|
11669
11679
|
var WMSErrorLoader = {
|
|
11670
11680
|
dataType: null,
|
|
11671
11681
|
batchType: null,
|
|
@@ -11944,7 +11954,7 @@ var __exports__ = (() => {
|
|
|
11944
11954
|
}
|
|
11945
11955
|
|
|
11946
11956
|
// ../../node_modules/@loaders.gl/wms/dist/wms-capabilities-loader.js
|
|
11947
|
-
var VERSION6 = true ? "4.4.0-alpha.
|
|
11957
|
+
var VERSION6 = true ? "4.4.0-alpha.18" : "latest";
|
|
11948
11958
|
var WMSCapabilitiesLoader = {
|
|
11949
11959
|
dataType: null,
|
|
11950
11960
|
batchType: null,
|
|
@@ -12017,7 +12027,7 @@ var __exports__ = (() => {
|
|
|
12017
12027
|
};
|
|
12018
12028
|
|
|
12019
12029
|
// ../../node_modules/@loaders.gl/images/dist/lib/utils/version.js
|
|
12020
|
-
var VERSION7 = true ? "4.4.0-alpha.
|
|
12030
|
+
var VERSION7 = true ? "4.4.0-alpha.18" : "latest";
|
|
12021
12031
|
|
|
12022
12032
|
// ../../node_modules/@loaders.gl/images/dist/lib/category-api/image-type.js
|
|
12023
12033
|
var parseImageNode = globalThis.loaders?.parseImageNode;
|
|
@@ -15502,213 +15512,884 @@ out float vTime;
|
|
|
15502
15512
|
var import_layers8 = __toESM(require_layers(), 1);
|
|
15503
15513
|
var import_mesh_layers2 = __toESM(require_mesh_layers(), 1);
|
|
15504
15514
|
|
|
15505
|
-
// ../../node_modules/@
|
|
15506
|
-
var
|
|
15515
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/utils/version.js
|
|
15516
|
+
var VERSION8 = true ? "4.4.0-alpha.18" : "latest";
|
|
15507
15517
|
|
|
15508
|
-
// ../../node_modules/@
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
|
|
15514
|
-
|
|
15515
|
-
|
|
15516
|
-
|
|
15517
|
-
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
default:
|
|
15526
|
-
return void 0;
|
|
15527
|
-
}
|
|
15528
|
-
}
|
|
15529
|
-
function convertSamplerMagFilter(mode) {
|
|
15530
|
-
switch (mode) {
|
|
15531
|
-
case 9728:
|
|
15532
|
-
return "nearest";
|
|
15533
|
-
case 9729:
|
|
15534
|
-
return "linear";
|
|
15535
|
-
default:
|
|
15536
|
-
return void 0;
|
|
15518
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/parsers/basis-module-loader.js
|
|
15519
|
+
var BASIS_EXTERNAL_LIBRARIES = {
|
|
15520
|
+
/** Basis transcoder, javascript wrapper part */
|
|
15521
|
+
TRANSCODER: "basis_transcoder.js",
|
|
15522
|
+
/** Basis transcoder, compiled web assembly part */
|
|
15523
|
+
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
15524
|
+
/** Basis encoder, javascript wrapper part */
|
|
15525
|
+
ENCODER: "basis_encoder.js",
|
|
15526
|
+
/** Basis encoder, compiled web assembly part */
|
|
15527
|
+
ENCODER_WASM: "basis_encoder.wasm"
|
|
15528
|
+
};
|
|
15529
|
+
var loadBasisTranscoderPromise;
|
|
15530
|
+
async function loadBasisTranscoderModule(options) {
|
|
15531
|
+
registerJSModules(options.modules);
|
|
15532
|
+
const basis = getJSModuleOrNull("basis");
|
|
15533
|
+
if (basis) {
|
|
15534
|
+
return basis;
|
|
15537
15535
|
}
|
|
15536
|
+
loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
|
|
15537
|
+
return await loadBasisTranscoderPromise;
|
|
15538
15538
|
}
|
|
15539
|
-
function
|
|
15540
|
-
|
|
15541
|
-
|
|
15542
|
-
|
|
15543
|
-
|
|
15544
|
-
|
|
15545
|
-
|
|
15546
|
-
|
|
15547
|
-
|
|
15548
|
-
return { minFilter: "linear", mipmapFilter: "nearest" };
|
|
15549
|
-
case 9986:
|
|
15550
|
-
return { minFilter: "nearest", mipmapFilter: "linear" };
|
|
15551
|
-
case 9987:
|
|
15552
|
-
return { minFilter: "linear", mipmapFilter: "linear" };
|
|
15553
|
-
default:
|
|
15554
|
-
return {};
|
|
15555
|
-
}
|
|
15539
|
+
async function loadBasisTranscoder(options) {
|
|
15540
|
+
let BASIS2 = null;
|
|
15541
|
+
let wasmBinary = null;
|
|
15542
|
+
[BASIS2, wasmBinary] = await Promise.all([
|
|
15543
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
15544
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
15545
|
+
]);
|
|
15546
|
+
BASIS2 = BASIS2 || globalThis.BASIS;
|
|
15547
|
+
return await initializeBasisTranscoderModule(BASIS2, wasmBinary);
|
|
15556
15548
|
}
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15561
|
-
defines: {
|
|
15562
|
-
// TODO: Use EXT_sRGB if available (Standard in WebGL 2.0)
|
|
15563
|
-
MANUAL_SRGB: true,
|
|
15564
|
-
SRGB_FAST_APPROXIMATION: true
|
|
15565
|
-
},
|
|
15566
|
-
bindings: {},
|
|
15567
|
-
uniforms: {
|
|
15568
|
-
// TODO: find better values?
|
|
15569
|
-
camera: [0, 0, 0],
|
|
15570
|
-
// Model should override
|
|
15571
|
-
metallicRoughnessValues: [1, 1]
|
|
15572
|
-
// Default is 1 and 1
|
|
15573
|
-
},
|
|
15574
|
-
parameters: {},
|
|
15575
|
-
glParameters: {},
|
|
15576
|
-
generatedTextures: []
|
|
15577
|
-
};
|
|
15578
|
-
parsedMaterial.defines["USE_TEX_LOD"] = true;
|
|
15579
|
-
const { imageBasedLightingEnvironment } = options;
|
|
15580
|
-
if (imageBasedLightingEnvironment) {
|
|
15581
|
-
parsedMaterial.bindings.pbr_diffuseEnvSampler = imageBasedLightingEnvironment.diffuseEnvSampler.texture;
|
|
15582
|
-
parsedMaterial.bindings.pbr_specularEnvSampler = imageBasedLightingEnvironment.specularEnvSampler.texture;
|
|
15583
|
-
parsedMaterial.bindings.pbr_BrdfLUT = imageBasedLightingEnvironment.brdfLutTexture.texture;
|
|
15584
|
-
parsedMaterial.uniforms.scaleIBLAmbient = [1, 1];
|
|
15585
|
-
}
|
|
15586
|
-
if (options?.pbrDebug) {
|
|
15587
|
-
parsedMaterial.defines["PBR_DEBUG"] = true;
|
|
15588
|
-
parsedMaterial.uniforms.scaleDiffBaseMR = [0, 0, 0, 0];
|
|
15589
|
-
parsedMaterial.uniforms.scaleFGDSpec = [0, 0, 0, 0];
|
|
15590
|
-
}
|
|
15591
|
-
if (attributes["NORMAL"])
|
|
15592
|
-
parsedMaterial.defines["HAS_NORMALS"] = true;
|
|
15593
|
-
if (attributes["TANGENT"] && options?.useTangents)
|
|
15594
|
-
parsedMaterial.defines["HAS_TANGENTS"] = true;
|
|
15595
|
-
if (attributes["TEXCOORD_0"])
|
|
15596
|
-
parsedMaterial.defines["HAS_UV"] = true;
|
|
15597
|
-
if (options?.imageBasedLightingEnvironment)
|
|
15598
|
-
parsedMaterial.defines["USE_IBL"] = true;
|
|
15599
|
-
if (options?.lights)
|
|
15600
|
-
parsedMaterial.defines["USE_LIGHTS"] = true;
|
|
15601
|
-
if (material) {
|
|
15602
|
-
parseMaterial(device, material, parsedMaterial);
|
|
15549
|
+
function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
|
|
15550
|
+
const options = {};
|
|
15551
|
+
if (wasmBinary) {
|
|
15552
|
+
options.wasmBinary = wasmBinary;
|
|
15603
15553
|
}
|
|
15604
|
-
return
|
|
15554
|
+
return new Promise((resolve2) => {
|
|
15555
|
+
BasisModule(options).then((module) => {
|
|
15556
|
+
const { BasisFile, initializeBasis } = module;
|
|
15557
|
+
initializeBasis();
|
|
15558
|
+
resolve2({ BasisFile });
|
|
15559
|
+
});
|
|
15560
|
+
});
|
|
15605
15561
|
}
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
if (material.normalTexture) {
|
|
15612
|
-
addTexture(device, material.normalTexture, "pbr_normalSampler", "HAS_NORMALMAP", parsedMaterial);
|
|
15613
|
-
const { scale: scale12 = 1 } = material.normalTexture;
|
|
15614
|
-
parsedMaterial.uniforms.normalScale = scale12;
|
|
15615
|
-
}
|
|
15616
|
-
if (material.occlusionTexture) {
|
|
15617
|
-
addTexture(device, material.occlusionTexture, "pbr_occlusionSampler", "HAS_OCCLUSIONMAP", parsedMaterial);
|
|
15618
|
-
const { strength = 1 } = material.occlusionTexture;
|
|
15619
|
-
parsedMaterial.uniforms.occlusionStrength = strength;
|
|
15620
|
-
}
|
|
15621
|
-
if (material.emissiveTexture) {
|
|
15622
|
-
addTexture(device, material.emissiveTexture, "pbr_emissiveSampler", "HAS_EMISSIVEMAP", parsedMaterial);
|
|
15623
|
-
parsedMaterial.uniforms.emissiveFactor = material.emissiveFactor || [0, 0, 0];
|
|
15624
|
-
}
|
|
15625
|
-
switch (material.alphaMode || "MASK") {
|
|
15626
|
-
case "MASK":
|
|
15627
|
-
const { alphaCutoff = 0.5 } = material;
|
|
15628
|
-
parsedMaterial.defines["ALPHA_CUTOFF"] = true;
|
|
15629
|
-
parsedMaterial.uniforms.alphaCutoff = alphaCutoff;
|
|
15630
|
-
break;
|
|
15631
|
-
case "BLEND":
|
|
15632
|
-
import_core20.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")();
|
|
15633
|
-
parsedMaterial.parameters.blend = true;
|
|
15634
|
-
parsedMaterial.parameters.blendColorOperation = "add";
|
|
15635
|
-
parsedMaterial.parameters.blendColorSrcFactor = "src-alpha";
|
|
15636
|
-
parsedMaterial.parameters.blendColorDstFactor = "one-minus-src-alpha";
|
|
15637
|
-
parsedMaterial.parameters.blendAlphaOperation = "add";
|
|
15638
|
-
parsedMaterial.parameters.blendAlphaSrcFactor = "one";
|
|
15639
|
-
parsedMaterial.parameters.blendAlphaDstFactor = "one-minus-src-alpha";
|
|
15640
|
-
parsedMaterial.glParameters["blend"] = true;
|
|
15641
|
-
parsedMaterial.glParameters["blendEquation"] = 32774;
|
|
15642
|
-
parsedMaterial.glParameters["blendFunc"] = [
|
|
15643
|
-
770,
|
|
15644
|
-
771,
|
|
15645
|
-
1,
|
|
15646
|
-
771
|
|
15647
|
-
];
|
|
15648
|
-
break;
|
|
15562
|
+
var loadBasisEncoderPromise;
|
|
15563
|
+
async function loadBasisEncoderModule(options) {
|
|
15564
|
+
const modules = options.modules || {};
|
|
15565
|
+
if (modules.basisEncoder) {
|
|
15566
|
+
return modules.basisEncoder;
|
|
15649
15567
|
}
|
|
15568
|
+
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
15569
|
+
return await loadBasisEncoderPromise;
|
|
15650
15570
|
}
|
|
15651
|
-
function
|
|
15652
|
-
|
|
15653
|
-
|
|
15654
|
-
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
parsedMaterial.uniforms.metallicRoughnessValues = [metallicFactor, roughnessFactor];
|
|
15571
|
+
async function loadBasisEncoder(options) {
|
|
15572
|
+
let BASIS_ENCODER = null;
|
|
15573
|
+
let wasmBinary = null;
|
|
15574
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
15575
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
15576
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
15577
|
+
]);
|
|
15578
|
+
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
15579
|
+
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
15661
15580
|
}
|
|
15662
|
-
function
|
|
15663
|
-
const
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
textureOptions = image;
|
|
15667
|
-
} else {
|
|
15668
|
-
textureOptions = { data: image };
|
|
15581
|
+
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
15582
|
+
const options = {};
|
|
15583
|
+
if (wasmBinary) {
|
|
15584
|
+
options.wasmBinary = wasmBinary;
|
|
15669
15585
|
}
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
};
|
|
15677
|
-
const texture = device.createTexture({
|
|
15678
|
-
id: gltfTexture.uniformName || gltfTexture.id,
|
|
15679
|
-
sampler: convertSampler(gltfSampler),
|
|
15680
|
-
...textureOptions
|
|
15586
|
+
return new Promise((resolve2) => {
|
|
15587
|
+
BasisEncoderModule(options).then((module) => {
|
|
15588
|
+
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
15589
|
+
initializeBasis();
|
|
15590
|
+
resolve2({ BasisFile, KTX2File, BasisEncoder });
|
|
15591
|
+
});
|
|
15681
15592
|
});
|
|
15682
|
-
parsedMaterial.bindings[uniformName] = texture;
|
|
15683
|
-
if (define2)
|
|
15684
|
-
parsedMaterial.defines[define2] = true;
|
|
15685
|
-
parsedMaterial.generatedTextures.push(texture);
|
|
15686
15593
|
}
|
|
15687
15594
|
|
|
15688
|
-
// ../../node_modules/@
|
|
15689
|
-
var
|
|
15690
|
-
|
|
15691
|
-
|
|
15692
|
-
var
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15709
|
-
|
|
15710
|
-
|
|
15711
|
-
|
|
15595
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/gl-extensions.js
|
|
15596
|
+
var GL_RGBA4 = 32854;
|
|
15597
|
+
var GL_RGBA8 = 32856;
|
|
15598
|
+
var GL_RGB565 = 36194;
|
|
15599
|
+
var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
|
|
15600
|
+
var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779;
|
|
15601
|
+
var GL_COMPRESSED_RGBA8_ETC2_EAC = 37493;
|
|
15602
|
+
var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840;
|
|
15603
|
+
var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842;
|
|
15604
|
+
var GL_COMPRESSED_RGB_ETC1_WEBGL = 36196;
|
|
15605
|
+
var GL_COMPRESSED_RGB_ATC_WEBGL = 35986;
|
|
15606
|
+
var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 34798;
|
|
15607
|
+
var GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 37808;
|
|
15608
|
+
var GL_COMPRESSED_RED_RGTC1_EXT = 36283;
|
|
15609
|
+
var GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 36285;
|
|
15610
|
+
var GL_COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492;
|
|
15611
|
+
|
|
15612
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/utils/detect-supported-texture-formats.js
|
|
15613
|
+
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
15614
|
+
var WEBGL_TEXTURE_FORMATS = {
|
|
15615
|
+
/* eslint-disable camelcase */
|
|
15616
|
+
WEBGL_compressed_texture_s3tc: [
|
|
15617
|
+
"bc1-rgb-unorm-webgl",
|
|
15618
|
+
"bc1-rgba-unorm",
|
|
15619
|
+
"bc2-rgba-unorm",
|
|
15620
|
+
"bc3-rgba-unorm"
|
|
15621
|
+
],
|
|
15622
|
+
WEBGL_compressed_texture_s3tc_srgb: [
|
|
15623
|
+
"bc1-rgb-unorm-srgb-webgl",
|
|
15624
|
+
"bc1-rgba-unorm-srgb",
|
|
15625
|
+
"bc2-rgba-unorm-srgb",
|
|
15626
|
+
"bc3-rgba-unorm-srgb"
|
|
15627
|
+
],
|
|
15628
|
+
EXT_texture_compression_rgtc: ["bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm"],
|
|
15629
|
+
EXT_texture_compression_bptc: [
|
|
15630
|
+
"bc6h-rgb-ufloat",
|
|
15631
|
+
"bc6h-rgb-float",
|
|
15632
|
+
"bc7-rgba-unorm",
|
|
15633
|
+
"bc7-rgba-unorm-srgb"
|
|
15634
|
+
],
|
|
15635
|
+
WEBGL_compressed_texture_etc1: ["etc1-rbg-unorm-webgl"],
|
|
15636
|
+
WEBGL_compressed_texture_etc: [
|
|
15637
|
+
"etc2-rgb8unorm",
|
|
15638
|
+
"etc2-rgb8unorm-srgb",
|
|
15639
|
+
"etc2-rgb8a1unorm",
|
|
15640
|
+
"etc2-rgb8a1unorm-srgb",
|
|
15641
|
+
"etc2-rgba8unorm",
|
|
15642
|
+
"etc2-rgba8unorm-srgb",
|
|
15643
|
+
"eac-r11unorm",
|
|
15644
|
+
"eac-r11snorm",
|
|
15645
|
+
"eac-rg11unorm",
|
|
15646
|
+
"eac-rg11snorm"
|
|
15647
|
+
],
|
|
15648
|
+
WEBGL_compressed_texture_pvrtc: [
|
|
15649
|
+
"pvrtc-rgb4unorm-webgl",
|
|
15650
|
+
"pvrtc-rgba4unorm-webgl",
|
|
15651
|
+
"pvrtc-rbg2unorm-webgl",
|
|
15652
|
+
"pvrtc-rgba2unorm-webgl"
|
|
15653
|
+
],
|
|
15654
|
+
WEBGL_compressed_texture_atc: [
|
|
15655
|
+
"atc-rgb-unorm-webgl",
|
|
15656
|
+
"atc-rgba-unorm-webgl",
|
|
15657
|
+
"atc-rgbai-unorm-webgl"
|
|
15658
|
+
],
|
|
15659
|
+
WEBGL_compressed_texture_astc: [
|
|
15660
|
+
"astc-4x4-unorm",
|
|
15661
|
+
"astc-4x4-unorm-srgb",
|
|
15662
|
+
"astc-5x4-unorm",
|
|
15663
|
+
"astc-5x4-unorm-srgb",
|
|
15664
|
+
"astc-5x5-unorm",
|
|
15665
|
+
"astc-5x5-unorm-srgb",
|
|
15666
|
+
"astc-6x5-unorm",
|
|
15667
|
+
"astc-6x5-unorm-srgb",
|
|
15668
|
+
"astc-6x6-unorm",
|
|
15669
|
+
"astc-6x6-unorm-srgb",
|
|
15670
|
+
"astc-8x5-unorm",
|
|
15671
|
+
"astc-8x5-unorm-srgb",
|
|
15672
|
+
"astc-8x6-unorm",
|
|
15673
|
+
"astc-8x6-unorm-srgb",
|
|
15674
|
+
"astc-8x8-unorm",
|
|
15675
|
+
"astc-8x8-unorm-srgb",
|
|
15676
|
+
"astc-10x5-unorm",
|
|
15677
|
+
"astc-10x5-unorm-srgb",
|
|
15678
|
+
"astc-10x6-unorm",
|
|
15679
|
+
"astc-10x6-unorm-srgb",
|
|
15680
|
+
"astc-10x8-unorm",
|
|
15681
|
+
"astc-10x8-unorm-srgb",
|
|
15682
|
+
"astc-10x10-unorm",
|
|
15683
|
+
"astc-10x10-unorm-srgb",
|
|
15684
|
+
"astc-12x10-unorm",
|
|
15685
|
+
"astc-12x10-unorm-srgb",
|
|
15686
|
+
"astc-12x12-unorm",
|
|
15687
|
+
"astc-12x12-unorm-srgb"
|
|
15688
|
+
]
|
|
15689
|
+
/* eslint-enable camelcase */
|
|
15690
|
+
};
|
|
15691
|
+
var textureFormats = null;
|
|
15692
|
+
function detectSupportedTextureFormats(gl) {
|
|
15693
|
+
if (!textureFormats) {
|
|
15694
|
+
gl = gl || getWebGLContext() || void 0;
|
|
15695
|
+
textureFormats = /* @__PURE__ */ new Set();
|
|
15696
|
+
for (const prefix of BROWSER_PREFIXES) {
|
|
15697
|
+
for (const extension in WEBGL_TEXTURE_FORMATS) {
|
|
15698
|
+
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
15699
|
+
for (const textureFormat of WEBGL_TEXTURE_FORMATS[extension]) {
|
|
15700
|
+
textureFormats.add(textureFormat);
|
|
15701
|
+
}
|
|
15702
|
+
}
|
|
15703
|
+
}
|
|
15704
|
+
}
|
|
15705
|
+
}
|
|
15706
|
+
return textureFormats;
|
|
15707
|
+
}
|
|
15708
|
+
function getWebGLContext() {
|
|
15709
|
+
try {
|
|
15710
|
+
const canvas = document.createElement("canvas");
|
|
15711
|
+
return canvas.getContext("webgl");
|
|
15712
|
+
} catch (error) {
|
|
15713
|
+
return null;
|
|
15714
|
+
}
|
|
15715
|
+
}
|
|
15716
|
+
|
|
15717
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/parsers/parse-ktx.js
|
|
15718
|
+
var KTX2_ID = [
|
|
15719
|
+
// '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
|
|
15720
|
+
171,
|
|
15721
|
+
75,
|
|
15722
|
+
84,
|
|
15723
|
+
88,
|
|
15724
|
+
32,
|
|
15725
|
+
50,
|
|
15726
|
+
48,
|
|
15727
|
+
187,
|
|
15728
|
+
13,
|
|
15729
|
+
10,
|
|
15730
|
+
26,
|
|
15731
|
+
10
|
|
15732
|
+
];
|
|
15733
|
+
function isKTX(data) {
|
|
15734
|
+
const id = new Uint8Array(data);
|
|
15735
|
+
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || // '´'
|
|
15736
|
+
id[1] !== KTX2_ID[1] || // 'K'
|
|
15737
|
+
id[2] !== KTX2_ID[2] || // 'T'
|
|
15738
|
+
id[3] !== KTX2_ID[3] || // 'X'
|
|
15739
|
+
id[4] !== KTX2_ID[4] || // ' '
|
|
15740
|
+
id[5] !== KTX2_ID[5] || // '2'
|
|
15741
|
+
id[6] !== KTX2_ID[6] || // '0'
|
|
15742
|
+
id[7] !== KTX2_ID[7] || // 'ª'
|
|
15743
|
+
id[8] !== KTX2_ID[8] || // '\r'
|
|
15744
|
+
id[9] !== KTX2_ID[9] || // '\n'
|
|
15745
|
+
id[10] !== KTX2_ID[10] || // '\x1A'
|
|
15746
|
+
id[11] !== KTX2_ID[11];
|
|
15747
|
+
return !notKTX;
|
|
15748
|
+
}
|
|
15749
|
+
|
|
15750
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/parsers/parse-basis.js
|
|
15751
|
+
var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
|
|
15752
|
+
etc1: {
|
|
15753
|
+
basisFormat: 0,
|
|
15754
|
+
compressed: true,
|
|
15755
|
+
format: GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
15756
|
+
textureFormat: "etc1-rbg-unorm-webgl"
|
|
15757
|
+
},
|
|
15758
|
+
etc2: {
|
|
15759
|
+
basisFormat: 1,
|
|
15760
|
+
compressed: true,
|
|
15761
|
+
format: GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
15762
|
+
textureFormat: "etc2-rgba8unorm"
|
|
15763
|
+
},
|
|
15764
|
+
bc1: {
|
|
15765
|
+
basisFormat: 2,
|
|
15766
|
+
compressed: true,
|
|
15767
|
+
format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
15768
|
+
textureFormat: "bc1-rgb-unorm-webgl"
|
|
15769
|
+
},
|
|
15770
|
+
bc3: {
|
|
15771
|
+
basisFormat: 3,
|
|
15772
|
+
compressed: true,
|
|
15773
|
+
format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
15774
|
+
textureFormat: "bc3-rgba-unorm"
|
|
15775
|
+
},
|
|
15776
|
+
bc4: {
|
|
15777
|
+
basisFormat: 4,
|
|
15778
|
+
compressed: true,
|
|
15779
|
+
format: GL_COMPRESSED_RED_RGTC1_EXT,
|
|
15780
|
+
textureFormat: "bc4-r-unorm"
|
|
15781
|
+
},
|
|
15782
|
+
bc5: {
|
|
15783
|
+
basisFormat: 5,
|
|
15784
|
+
compressed: true,
|
|
15785
|
+
format: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
15786
|
+
textureFormat: "bc5-rg-unorm"
|
|
15787
|
+
},
|
|
15788
|
+
"bc7-m6-opaque-only": {
|
|
15789
|
+
basisFormat: 6,
|
|
15790
|
+
compressed: true,
|
|
15791
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
15792
|
+
textureFormat: "bc7-rgba-unorm"
|
|
15793
|
+
},
|
|
15794
|
+
"bc7-m5": {
|
|
15795
|
+
basisFormat: 7,
|
|
15796
|
+
compressed: true,
|
|
15797
|
+
format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
15798
|
+
textureFormat: "bc7-rgba-unorm"
|
|
15799
|
+
},
|
|
15800
|
+
"pvrtc1-4-rgb": {
|
|
15801
|
+
basisFormat: 8,
|
|
15802
|
+
compressed: true,
|
|
15803
|
+
format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
15804
|
+
textureFormat: "pvrtc-rgb4unorm-webgl"
|
|
15805
|
+
},
|
|
15806
|
+
"pvrtc1-4-rgba": {
|
|
15807
|
+
basisFormat: 9,
|
|
15808
|
+
compressed: true,
|
|
15809
|
+
format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
15810
|
+
textureFormat: "pvrtc-rgba4unorm-webgl"
|
|
15811
|
+
},
|
|
15812
|
+
"astc-4x4": {
|
|
15813
|
+
basisFormat: 10,
|
|
15814
|
+
compressed: true,
|
|
15815
|
+
format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
15816
|
+
textureFormat: "astc-4x4-unorm"
|
|
15817
|
+
},
|
|
15818
|
+
"atc-rgb": {
|
|
15819
|
+
basisFormat: 11,
|
|
15820
|
+
compressed: true,
|
|
15821
|
+
format: GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
15822
|
+
textureFormat: "atc-rgb-unorm-webgl"
|
|
15823
|
+
},
|
|
15824
|
+
"atc-rgba-interpolated-alpha": {
|
|
15825
|
+
basisFormat: 12,
|
|
15826
|
+
compressed: true,
|
|
15827
|
+
format: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
15828
|
+
textureFormat: "atc-rgbai-unorm-webgl"
|
|
15829
|
+
},
|
|
15830
|
+
rgba32: {
|
|
15831
|
+
basisFormat: 13,
|
|
15832
|
+
compressed: false,
|
|
15833
|
+
format: GL_RGBA8,
|
|
15834
|
+
textureFormat: "rgba8unorm"
|
|
15835
|
+
},
|
|
15836
|
+
rgb565: {
|
|
15837
|
+
basisFormat: 14,
|
|
15838
|
+
compressed: false,
|
|
15839
|
+
format: GL_RGB565,
|
|
15840
|
+
textureFormat: "rgb565unorm-webgl"
|
|
15841
|
+
},
|
|
15842
|
+
bgr565: {
|
|
15843
|
+
basisFormat: 15,
|
|
15844
|
+
compressed: false,
|
|
15845
|
+
format: GL_RGB565,
|
|
15846
|
+
textureFormat: "rgb565unorm-webgl"
|
|
15847
|
+
},
|
|
15848
|
+
rgba4444: {
|
|
15849
|
+
basisFormat: 16,
|
|
15850
|
+
compressed: false,
|
|
15851
|
+
format: GL_RGBA4,
|
|
15852
|
+
textureFormat: "rgba4unorm-webgl"
|
|
15853
|
+
}
|
|
15854
|
+
};
|
|
15855
|
+
var BASIS_FORMATS = Object.freeze(Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS));
|
|
15856
|
+
async function parseBasis(data, options = {}) {
|
|
15857
|
+
const loadLibraryOptions = extractLoadLibraryOptions(options);
|
|
15858
|
+
if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
|
|
15859
|
+
if (isKTX(data)) {
|
|
15860
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
15861
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
15862
|
+
}
|
|
15863
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
15864
|
+
return parseBasisFile(BasisFile, data, options);
|
|
15865
|
+
}
|
|
15866
|
+
switch (options.basis.module) {
|
|
15867
|
+
case "encoder":
|
|
15868
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
15869
|
+
switch (options.basis.containerFormat) {
|
|
15870
|
+
case "ktx2":
|
|
15871
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
15872
|
+
case "basis":
|
|
15873
|
+
default:
|
|
15874
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
15875
|
+
}
|
|
15876
|
+
case "transcoder":
|
|
15877
|
+
default:
|
|
15878
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
15879
|
+
return parseBasisFile(BasisFile, data, options);
|
|
15880
|
+
}
|
|
15881
|
+
}
|
|
15882
|
+
function parseBasisFile(BasisFile, data, options) {
|
|
15883
|
+
const basisFile = new BasisFile(new Uint8Array(data));
|
|
15884
|
+
try {
|
|
15885
|
+
if (!basisFile.startTranscoding()) {
|
|
15886
|
+
throw new Error("Failed to start basis transcoding");
|
|
15887
|
+
}
|
|
15888
|
+
const imageCount = basisFile.getNumImages();
|
|
15889
|
+
const images = [];
|
|
15890
|
+
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
15891
|
+
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
15892
|
+
const levels = [];
|
|
15893
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
15894
|
+
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
15895
|
+
}
|
|
15896
|
+
images.push(levels);
|
|
15897
|
+
}
|
|
15898
|
+
return images;
|
|
15899
|
+
} finally {
|
|
15900
|
+
basisFile.close();
|
|
15901
|
+
basisFile.delete();
|
|
15902
|
+
}
|
|
15903
|
+
}
|
|
15904
|
+
function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
15905
|
+
const width = basisFile.getImageWidth(imageIndex, levelIndex);
|
|
15906
|
+
const height = basisFile.getImageHeight(imageIndex, levelIndex);
|
|
15907
|
+
const hasAlpha = basisFile.getHasAlpha(
|
|
15908
|
+
/* imageIndex, levelIndex */
|
|
15909
|
+
);
|
|
15910
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha);
|
|
15911
|
+
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
15912
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
15913
|
+
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
15914
|
+
throw new Error("failed to start Basis transcoding");
|
|
15915
|
+
}
|
|
15916
|
+
return {
|
|
15917
|
+
// standard loaders.gl image category payload
|
|
15918
|
+
shape: "texture-level",
|
|
15919
|
+
width,
|
|
15920
|
+
height,
|
|
15921
|
+
data: decodedData,
|
|
15922
|
+
compressed,
|
|
15923
|
+
...format !== void 0 ? { format } : {},
|
|
15924
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
15925
|
+
// Additional fields
|
|
15926
|
+
// Add levelSize field.
|
|
15927
|
+
hasAlpha
|
|
15928
|
+
};
|
|
15929
|
+
}
|
|
15930
|
+
function parseKTX2File(KTX2File, data, options) {
|
|
15931
|
+
const ktx2File = new KTX2File(new Uint8Array(data));
|
|
15932
|
+
try {
|
|
15933
|
+
if (!ktx2File.startTranscoding()) {
|
|
15934
|
+
throw new Error("failed to start KTX2 transcoding");
|
|
15935
|
+
}
|
|
15936
|
+
const levelsCount = ktx2File.getLevels();
|
|
15937
|
+
const levels = [];
|
|
15938
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
15939
|
+
levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
|
|
15940
|
+
}
|
|
15941
|
+
return [levels];
|
|
15942
|
+
} finally {
|
|
15943
|
+
ktx2File.close();
|
|
15944
|
+
ktx2File.delete();
|
|
15945
|
+
}
|
|
15946
|
+
}
|
|
15947
|
+
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
15948
|
+
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
15949
|
+
const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag);
|
|
15950
|
+
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
15951
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
15952
|
+
if (!ktx2File.transcodeImage(
|
|
15953
|
+
decodedData,
|
|
15954
|
+
levelIndex,
|
|
15955
|
+
0,
|
|
15956
|
+
0,
|
|
15957
|
+
basisFormat,
|
|
15958
|
+
0,
|
|
15959
|
+
-1,
|
|
15960
|
+
-1
|
|
15961
|
+
/* channel1 */
|
|
15962
|
+
)) {
|
|
15963
|
+
throw new Error("Failed to transcode KTX2 image");
|
|
15964
|
+
}
|
|
15965
|
+
return {
|
|
15966
|
+
// standard loaders.gl image category payload
|
|
15967
|
+
shape: "texture-level",
|
|
15968
|
+
width,
|
|
15969
|
+
height,
|
|
15970
|
+
data: decodedData,
|
|
15971
|
+
compressed,
|
|
15972
|
+
...format !== void 0 ? { format } : {},
|
|
15973
|
+
...textureFormat !== void 0 ? { textureFormat } : {},
|
|
15974
|
+
// Additional fields
|
|
15975
|
+
levelSize: decodedSize,
|
|
15976
|
+
hasAlpha: alphaFlag
|
|
15977
|
+
};
|
|
15978
|
+
}
|
|
15979
|
+
function getBasisOptions(options, hasAlpha) {
|
|
15980
|
+
let format = options.basis?.format || "auto";
|
|
15981
|
+
if (format === "auto") {
|
|
15982
|
+
format = options.basis?.supportedTextureFormats ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat();
|
|
15983
|
+
}
|
|
15984
|
+
if (typeof format === "object") {
|
|
15985
|
+
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
15986
|
+
}
|
|
15987
|
+
const normalizedFormat = format.toLowerCase();
|
|
15988
|
+
const basisOutputOptions = BASIS_FORMAT_TO_OUTPUT_OPTIONS[normalizedFormat];
|
|
15989
|
+
if (!basisOutputOptions) {
|
|
15990
|
+
throw new Error(`Unknown Basis format ${format}`);
|
|
15991
|
+
}
|
|
15992
|
+
return basisOutputOptions;
|
|
15993
|
+
}
|
|
15994
|
+
function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) {
|
|
15995
|
+
const textureFormats2 = new Set(supportedTextureFormats);
|
|
15996
|
+
if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) {
|
|
15997
|
+
return "astc-4x4";
|
|
15998
|
+
} else if (hasSupportedTextureFormat(textureFormats2, ["bc7-rgba-unorm", "bc7-rgba-unorm-srgb"])) {
|
|
15999
|
+
return {
|
|
16000
|
+
alpha: "bc7-m5",
|
|
16001
|
+
noAlpha: "bc7-m6-opaque-only"
|
|
16002
|
+
};
|
|
16003
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
16004
|
+
"bc1-rgb-unorm-webgl",
|
|
16005
|
+
"bc1-rgb-unorm-srgb-webgl",
|
|
16006
|
+
"bc1-rgba-unorm",
|
|
16007
|
+
"bc1-rgba-unorm-srgb",
|
|
16008
|
+
"bc2-rgba-unorm",
|
|
16009
|
+
"bc2-rgba-unorm-srgb",
|
|
16010
|
+
"bc3-rgba-unorm",
|
|
16011
|
+
"bc3-rgba-unorm-srgb"
|
|
16012
|
+
])) {
|
|
16013
|
+
return {
|
|
16014
|
+
alpha: "bc3",
|
|
16015
|
+
noAlpha: "bc1"
|
|
16016
|
+
};
|
|
16017
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
16018
|
+
"pvrtc-rgb4unorm-webgl",
|
|
16019
|
+
"pvrtc-rgba4unorm-webgl",
|
|
16020
|
+
"pvrtc-rbg2unorm-webgl",
|
|
16021
|
+
"pvrtc-rgba2unorm-webgl"
|
|
16022
|
+
])) {
|
|
16023
|
+
return {
|
|
16024
|
+
alpha: "pvrtc1-4-rgba",
|
|
16025
|
+
noAlpha: "pvrtc1-4-rgb"
|
|
16026
|
+
};
|
|
16027
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
16028
|
+
"etc2-rgb8unorm",
|
|
16029
|
+
"etc2-rgb8unorm-srgb",
|
|
16030
|
+
"etc2-rgb8a1unorm",
|
|
16031
|
+
"etc2-rgb8a1unorm-srgb",
|
|
16032
|
+
"etc2-rgba8unorm",
|
|
16033
|
+
"etc2-rgba8unorm-srgb",
|
|
16034
|
+
"eac-r11unorm",
|
|
16035
|
+
"eac-r11snorm",
|
|
16036
|
+
"eac-rg11unorm",
|
|
16037
|
+
"eac-rg11snorm"
|
|
16038
|
+
])) {
|
|
16039
|
+
return "etc2";
|
|
16040
|
+
} else if (textureFormats2.has("etc1-rbg-unorm-webgl")) {
|
|
16041
|
+
return "etc1";
|
|
16042
|
+
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
16043
|
+
"atc-rgb-unorm-webgl",
|
|
16044
|
+
"atc-rgba-unorm-webgl",
|
|
16045
|
+
"atc-rgbai-unorm-webgl"
|
|
16046
|
+
])) {
|
|
16047
|
+
return {
|
|
16048
|
+
alpha: "atc-rgba-interpolated-alpha",
|
|
16049
|
+
noAlpha: "atc-rgb"
|
|
16050
|
+
};
|
|
16051
|
+
}
|
|
16052
|
+
return "rgb565";
|
|
16053
|
+
}
|
|
16054
|
+
function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) {
|
|
16055
|
+
return candidateTextureFormats.some((textureFormat) => supportedTextureFormats.has(textureFormat));
|
|
16056
|
+
}
|
|
16057
|
+
|
|
16058
|
+
// ../../node_modules/@loaders.gl/textures/dist/basis-loader.js
|
|
16059
|
+
var BasisWorkerLoader = {
|
|
16060
|
+
dataType: null,
|
|
16061
|
+
batchType: null,
|
|
16062
|
+
name: "Basis",
|
|
16063
|
+
id: "basis",
|
|
16064
|
+
module: "textures",
|
|
16065
|
+
version: VERSION8,
|
|
16066
|
+
worker: true,
|
|
16067
|
+
extensions: ["basis", "ktx2"],
|
|
16068
|
+
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
16069
|
+
tests: ["sB"],
|
|
16070
|
+
binary: true,
|
|
16071
|
+
options: {
|
|
16072
|
+
basis: {
|
|
16073
|
+
format: "auto",
|
|
16074
|
+
containerFormat: "auto",
|
|
16075
|
+
module: "transcoder"
|
|
16076
|
+
}
|
|
16077
|
+
}
|
|
16078
|
+
};
|
|
16079
|
+
var BasisLoader = {
|
|
16080
|
+
...BasisWorkerLoader,
|
|
16081
|
+
parse: parseBasis
|
|
16082
|
+
};
|
|
16083
|
+
|
|
16084
|
+
// ../../node_modules/@luma.gl/gltf/dist/parsers/parse-pbr-material.js
|
|
16085
|
+
var import_core20 = __toESM(require_core3(), 1);
|
|
16086
|
+
|
|
16087
|
+
// ../../node_modules/@luma.gl/gltf/dist/webgl-to-webgpu/convert-webgl-sampler.js
|
|
16088
|
+
function convertSampler(gltfSampler) {
|
|
16089
|
+
return {
|
|
16090
|
+
addressModeU: convertSamplerWrapMode(gltfSampler.wrapS),
|
|
16091
|
+
addressModeV: convertSamplerWrapMode(gltfSampler.wrapT),
|
|
16092
|
+
magFilter: convertSamplerMagFilter(gltfSampler.magFilter),
|
|
16093
|
+
...convertSamplerMinFilter(gltfSampler.minFilter)
|
|
16094
|
+
};
|
|
16095
|
+
}
|
|
16096
|
+
function convertSamplerWrapMode(mode) {
|
|
16097
|
+
switch (mode) {
|
|
16098
|
+
case 33071:
|
|
16099
|
+
return "clamp-to-edge";
|
|
16100
|
+
case 10497:
|
|
16101
|
+
return "repeat";
|
|
16102
|
+
case 33648:
|
|
16103
|
+
return "mirror-repeat";
|
|
16104
|
+
default:
|
|
16105
|
+
return void 0;
|
|
16106
|
+
}
|
|
16107
|
+
}
|
|
16108
|
+
function convertSamplerMagFilter(mode) {
|
|
16109
|
+
switch (mode) {
|
|
16110
|
+
case 9728:
|
|
16111
|
+
return "nearest";
|
|
16112
|
+
case 9729:
|
|
16113
|
+
return "linear";
|
|
16114
|
+
default:
|
|
16115
|
+
return void 0;
|
|
16116
|
+
}
|
|
16117
|
+
}
|
|
16118
|
+
function convertSamplerMinFilter(mode) {
|
|
16119
|
+
switch (mode) {
|
|
16120
|
+
case 9728:
|
|
16121
|
+
return { minFilter: "nearest" };
|
|
16122
|
+
case 9729:
|
|
16123
|
+
return { minFilter: "linear" };
|
|
16124
|
+
case 9984:
|
|
16125
|
+
return { minFilter: "nearest", mipmapFilter: "nearest" };
|
|
16126
|
+
case 9985:
|
|
16127
|
+
return { minFilter: "linear", mipmapFilter: "nearest" };
|
|
16128
|
+
case 9986:
|
|
16129
|
+
return { minFilter: "nearest", mipmapFilter: "linear" };
|
|
16130
|
+
case 9987:
|
|
16131
|
+
return { minFilter: "linear", mipmapFilter: "linear" };
|
|
16132
|
+
default:
|
|
16133
|
+
return {};
|
|
16134
|
+
}
|
|
16135
|
+
}
|
|
16136
|
+
|
|
16137
|
+
// ../../node_modules/@luma.gl/gltf/dist/parsers/parse-pbr-material.js
|
|
16138
|
+
function parsePBRMaterial(device, material, attributes, options) {
|
|
16139
|
+
const parsedMaterial = {
|
|
16140
|
+
defines: {
|
|
16141
|
+
// TODO: Use EXT_sRGB if available (Standard in WebGL 2.0)
|
|
16142
|
+
MANUAL_SRGB: true,
|
|
16143
|
+
SRGB_FAST_APPROXIMATION: true
|
|
16144
|
+
},
|
|
16145
|
+
bindings: {},
|
|
16146
|
+
uniforms: {
|
|
16147
|
+
// TODO: find better values?
|
|
16148
|
+
camera: [0, 0, 0],
|
|
16149
|
+
// Model should override
|
|
16150
|
+
metallicRoughnessValues: [1, 1]
|
|
16151
|
+
// Default is 1 and 1
|
|
16152
|
+
},
|
|
16153
|
+
parameters: {},
|
|
16154
|
+
glParameters: {},
|
|
16155
|
+
generatedTextures: []
|
|
16156
|
+
};
|
|
16157
|
+
parsedMaterial.defines["USE_TEX_LOD"] = true;
|
|
16158
|
+
const { imageBasedLightingEnvironment } = options;
|
|
16159
|
+
if (imageBasedLightingEnvironment) {
|
|
16160
|
+
parsedMaterial.bindings.pbr_diffuseEnvSampler = imageBasedLightingEnvironment.diffuseEnvSampler.texture;
|
|
16161
|
+
parsedMaterial.bindings.pbr_specularEnvSampler = imageBasedLightingEnvironment.specularEnvSampler.texture;
|
|
16162
|
+
parsedMaterial.bindings.pbr_BrdfLUT = imageBasedLightingEnvironment.brdfLutTexture.texture;
|
|
16163
|
+
parsedMaterial.uniforms.scaleIBLAmbient = [1, 1];
|
|
16164
|
+
}
|
|
16165
|
+
if (options?.pbrDebug) {
|
|
16166
|
+
parsedMaterial.defines["PBR_DEBUG"] = true;
|
|
16167
|
+
parsedMaterial.uniforms.scaleDiffBaseMR = [0, 0, 0, 0];
|
|
16168
|
+
parsedMaterial.uniforms.scaleFGDSpec = [0, 0, 0, 0];
|
|
16169
|
+
}
|
|
16170
|
+
if (attributes["NORMAL"])
|
|
16171
|
+
parsedMaterial.defines["HAS_NORMALS"] = true;
|
|
16172
|
+
if (attributes["TANGENT"] && options?.useTangents)
|
|
16173
|
+
parsedMaterial.defines["HAS_TANGENTS"] = true;
|
|
16174
|
+
if (attributes["TEXCOORD_0"])
|
|
16175
|
+
parsedMaterial.defines["HAS_UV"] = true;
|
|
16176
|
+
if (attributes["JOINTS_0"] && attributes["WEIGHTS_0"])
|
|
16177
|
+
parsedMaterial.defines["HAS_SKIN"] = true;
|
|
16178
|
+
if (attributes["COLOR_0"])
|
|
16179
|
+
parsedMaterial.defines["HAS_COLORS"] = true;
|
|
16180
|
+
if (options?.imageBasedLightingEnvironment)
|
|
16181
|
+
parsedMaterial.defines["USE_IBL"] = true;
|
|
16182
|
+
if (options?.lights)
|
|
16183
|
+
parsedMaterial.defines["USE_LIGHTS"] = true;
|
|
16184
|
+
if (material) {
|
|
16185
|
+
parseMaterial(device, material, parsedMaterial);
|
|
16186
|
+
}
|
|
16187
|
+
return parsedMaterial;
|
|
16188
|
+
}
|
|
16189
|
+
function parseMaterial(device, material, parsedMaterial) {
|
|
16190
|
+
parsedMaterial.uniforms.unlit = Boolean(material.unlit);
|
|
16191
|
+
if (material.pbrMetallicRoughness) {
|
|
16192
|
+
parsePbrMetallicRoughness(device, material.pbrMetallicRoughness, parsedMaterial);
|
|
16193
|
+
}
|
|
16194
|
+
if (material.normalTexture) {
|
|
16195
|
+
addTexture(device, material.normalTexture, "pbr_normalSampler", "HAS_NORMALMAP", parsedMaterial);
|
|
16196
|
+
const { scale: scale12 = 1 } = material.normalTexture;
|
|
16197
|
+
parsedMaterial.uniforms.normalScale = scale12;
|
|
16198
|
+
}
|
|
16199
|
+
if (material.occlusionTexture) {
|
|
16200
|
+
addTexture(device, material.occlusionTexture, "pbr_occlusionSampler", "HAS_OCCLUSIONMAP", parsedMaterial);
|
|
16201
|
+
const { strength = 1 } = material.occlusionTexture;
|
|
16202
|
+
parsedMaterial.uniforms.occlusionStrength = strength;
|
|
16203
|
+
}
|
|
16204
|
+
if (material.emissiveTexture) {
|
|
16205
|
+
addTexture(device, material.emissiveTexture, "pbr_emissiveSampler", "HAS_EMISSIVEMAP", parsedMaterial);
|
|
16206
|
+
parsedMaterial.uniforms.emissiveFactor = material.emissiveFactor || [0, 0, 0];
|
|
16207
|
+
}
|
|
16208
|
+
switch (material.alphaMode || "MASK") {
|
|
16209
|
+
case "MASK":
|
|
16210
|
+
const { alphaCutoff = 0.5 } = material;
|
|
16211
|
+
parsedMaterial.defines["ALPHA_CUTOFF"] = true;
|
|
16212
|
+
parsedMaterial.uniforms.alphaCutoff = alphaCutoff;
|
|
16213
|
+
break;
|
|
16214
|
+
case "BLEND":
|
|
16215
|
+
import_core20.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")();
|
|
16216
|
+
parsedMaterial.parameters.blend = true;
|
|
16217
|
+
parsedMaterial.parameters.blendColorOperation = "add";
|
|
16218
|
+
parsedMaterial.parameters.blendColorSrcFactor = "src-alpha";
|
|
16219
|
+
parsedMaterial.parameters.blendColorDstFactor = "one-minus-src-alpha";
|
|
16220
|
+
parsedMaterial.parameters.blendAlphaOperation = "add";
|
|
16221
|
+
parsedMaterial.parameters.blendAlphaSrcFactor = "one";
|
|
16222
|
+
parsedMaterial.parameters.blendAlphaDstFactor = "one-minus-src-alpha";
|
|
16223
|
+
parsedMaterial.glParameters["blend"] = true;
|
|
16224
|
+
parsedMaterial.glParameters["blendEquation"] = 32774;
|
|
16225
|
+
parsedMaterial.glParameters["blendFunc"] = [
|
|
16226
|
+
770,
|
|
16227
|
+
771,
|
|
16228
|
+
1,
|
|
16229
|
+
771
|
|
16230
|
+
];
|
|
16231
|
+
break;
|
|
16232
|
+
}
|
|
16233
|
+
}
|
|
16234
|
+
function parsePbrMetallicRoughness(device, pbrMetallicRoughness, parsedMaterial) {
|
|
16235
|
+
if (pbrMetallicRoughness.baseColorTexture) {
|
|
16236
|
+
addTexture(device, pbrMetallicRoughness.baseColorTexture, "pbr_baseColorSampler", "HAS_BASECOLORMAP", parsedMaterial);
|
|
16237
|
+
}
|
|
16238
|
+
parsedMaterial.uniforms.baseColorFactor = pbrMetallicRoughness.baseColorFactor || [1, 1, 1, 1];
|
|
16239
|
+
if (pbrMetallicRoughness.metallicRoughnessTexture) {
|
|
16240
|
+
addTexture(device, pbrMetallicRoughness.metallicRoughnessTexture, "pbr_metallicRoughnessSampler", "HAS_METALROUGHNESSMAP", parsedMaterial);
|
|
16241
|
+
}
|
|
16242
|
+
const { metallicFactor = 1, roughnessFactor = 1 } = pbrMetallicRoughness;
|
|
16243
|
+
parsedMaterial.uniforms.metallicRoughnessValues = [metallicFactor, roughnessFactor];
|
|
16244
|
+
}
|
|
16245
|
+
function addTexture(device, gltfTexture, uniformName, define2, parsedMaterial) {
|
|
16246
|
+
const image = gltfTexture.texture.source.image;
|
|
16247
|
+
const gltfSampler = {
|
|
16248
|
+
wrapS: 10497,
|
|
16249
|
+
// default REPEAT S (U) wrapping mode.
|
|
16250
|
+
wrapT: 10497,
|
|
16251
|
+
// default REPEAT T (V) wrapping mode.
|
|
16252
|
+
minFilter: 9729,
|
|
16253
|
+
// default LINEAR filtering
|
|
16254
|
+
magFilter: 9729,
|
|
16255
|
+
// default LINEAR filtering
|
|
16256
|
+
...gltfTexture?.texture?.sampler
|
|
16257
|
+
};
|
|
16258
|
+
const baseOptions = {
|
|
16259
|
+
id: gltfTexture.uniformName || gltfTexture.id,
|
|
16260
|
+
sampler: convertSampler(gltfSampler)
|
|
16261
|
+
};
|
|
16262
|
+
let texture;
|
|
16263
|
+
if (image.compressed) {
|
|
16264
|
+
texture = createCompressedTexture(device, image, baseOptions);
|
|
16265
|
+
} else {
|
|
16266
|
+
const { width, height } = device.getExternalImageSize(image);
|
|
16267
|
+
texture = device.createTexture({
|
|
16268
|
+
...baseOptions,
|
|
16269
|
+
width,
|
|
16270
|
+
height,
|
|
16271
|
+
data: image
|
|
16272
|
+
});
|
|
16273
|
+
}
|
|
16274
|
+
parsedMaterial.bindings[uniformName] = texture;
|
|
16275
|
+
if (define2)
|
|
16276
|
+
parsedMaterial.defines[define2] = true;
|
|
16277
|
+
parsedMaterial.generatedTextures.push(texture);
|
|
16278
|
+
}
|
|
16279
|
+
function createCompressedTextureFallback(device, baseOptions) {
|
|
16280
|
+
return device.createTexture({
|
|
16281
|
+
...baseOptions,
|
|
16282
|
+
format: "rgba8unorm",
|
|
16283
|
+
width: 1,
|
|
16284
|
+
height: 1,
|
|
16285
|
+
mipLevels: 1
|
|
16286
|
+
});
|
|
16287
|
+
}
|
|
16288
|
+
function resolveCompressedTextureFormat(level) {
|
|
16289
|
+
return level.textureFormat;
|
|
16290
|
+
}
|
|
16291
|
+
function getMaxCompressedMipLevels(baseWidth, baseHeight, format) {
|
|
16292
|
+
const { blockWidth = 1, blockHeight = 1 } = import_core20.textureFormatDecoder.getInfo(format);
|
|
16293
|
+
let count = 1;
|
|
16294
|
+
for (let i = 1; ; i++) {
|
|
16295
|
+
const w2 = Math.max(1, baseWidth >> i);
|
|
16296
|
+
const h = Math.max(1, baseHeight >> i);
|
|
16297
|
+
if (w2 < blockWidth || h < blockHeight)
|
|
16298
|
+
break;
|
|
16299
|
+
count++;
|
|
16300
|
+
}
|
|
16301
|
+
return count;
|
|
16302
|
+
}
|
|
16303
|
+
function createCompressedTexture(device, image, baseOptions) {
|
|
16304
|
+
let levels;
|
|
16305
|
+
if (Array.isArray(image.data) && image.data[0]?.data) {
|
|
16306
|
+
levels = image.data;
|
|
16307
|
+
} else if ("mipmaps" in image && Array.isArray(image.mipmaps)) {
|
|
16308
|
+
levels = image.mipmaps;
|
|
16309
|
+
} else {
|
|
16310
|
+
levels = [];
|
|
16311
|
+
}
|
|
16312
|
+
if (levels.length === 0 || !levels[0]?.data) {
|
|
16313
|
+
import_core20.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")();
|
|
16314
|
+
return createCompressedTextureFallback(device, baseOptions);
|
|
16315
|
+
}
|
|
16316
|
+
const baseLevel = levels[0];
|
|
16317
|
+
const baseWidth = baseLevel.width ?? image.width ?? 0;
|
|
16318
|
+
const baseHeight = baseLevel.height ?? image.height ?? 0;
|
|
16319
|
+
if (baseWidth <= 0 || baseHeight <= 0) {
|
|
16320
|
+
import_core20.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")();
|
|
16321
|
+
return createCompressedTextureFallback(device, baseOptions);
|
|
16322
|
+
}
|
|
16323
|
+
const format = resolveCompressedTextureFormat(baseLevel);
|
|
16324
|
+
if (!format) {
|
|
16325
|
+
import_core20.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")();
|
|
16326
|
+
return createCompressedTextureFallback(device, baseOptions);
|
|
16327
|
+
}
|
|
16328
|
+
const maxMipLevels = getMaxCompressedMipLevels(baseWidth, baseHeight, format);
|
|
16329
|
+
const levelLimit = Math.min(levels.length, maxMipLevels);
|
|
16330
|
+
let validLevelCount = 1;
|
|
16331
|
+
for (let i = 1; i < levelLimit; i++) {
|
|
16332
|
+
const level = levels[i];
|
|
16333
|
+
if (!level.data || level.width <= 0 || level.height <= 0) {
|
|
16334
|
+
import_core20.log.warn(`createCompressedTexture: mip level ${i} has invalid data/dimensions, truncating`)();
|
|
16335
|
+
break;
|
|
16336
|
+
}
|
|
16337
|
+
const levelFormat = resolveCompressedTextureFormat(level);
|
|
16338
|
+
if (levelFormat && levelFormat !== format) {
|
|
16339
|
+
import_core20.log.warn(`createCompressedTexture: mip level ${i} format '${levelFormat}' differs from base '${format}', truncating`)();
|
|
16340
|
+
break;
|
|
16341
|
+
}
|
|
16342
|
+
const expectedW = Math.max(1, baseWidth >> i);
|
|
16343
|
+
const expectedH = Math.max(1, baseHeight >> i);
|
|
16344
|
+
if (level.width !== expectedW || level.height !== expectedH) {
|
|
16345
|
+
import_core20.log.warn(`createCompressedTexture: mip level ${i} dimensions ${level.width}x${level.height} don't match expected ${expectedW}x${expectedH}, truncating`)();
|
|
16346
|
+
break;
|
|
16347
|
+
}
|
|
16348
|
+
validLevelCount++;
|
|
16349
|
+
}
|
|
16350
|
+
const texture = device.createTexture({
|
|
16351
|
+
...baseOptions,
|
|
16352
|
+
format,
|
|
16353
|
+
usage: import_core20.Texture.TEXTURE | import_core20.Texture.COPY_DST,
|
|
16354
|
+
width: baseWidth,
|
|
16355
|
+
height: baseHeight,
|
|
16356
|
+
mipLevels: validLevelCount,
|
|
16357
|
+
data: baseLevel.data
|
|
16358
|
+
});
|
|
16359
|
+
for (let i = 1; i < validLevelCount; i++) {
|
|
16360
|
+
texture.writeData(levels[i].data, {
|
|
16361
|
+
width: levels[i].width,
|
|
16362
|
+
height: levels[i].height,
|
|
16363
|
+
mipLevel: i
|
|
16364
|
+
});
|
|
16365
|
+
}
|
|
16366
|
+
return texture;
|
|
16367
|
+
}
|
|
16368
|
+
|
|
16369
|
+
// ../../node_modules/@luma.gl/shadertools/dist/modules/lighting/lights/lighting.js
|
|
16370
|
+
var import_core21 = __toESM(require_core3(), 1);
|
|
16371
|
+
|
|
16372
|
+
// ../../node_modules/@luma.gl/shadertools/dist/modules/lighting/lights/lighting-glsl.js
|
|
16373
|
+
var lightingUniformsGLSL = (
|
|
16374
|
+
/* glsl */
|
|
16375
|
+
`precision highp int;
|
|
16376
|
+
|
|
16377
|
+
// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
16378
|
+
struct AmbientLight {
|
|
16379
|
+
vec3 color;
|
|
16380
|
+
};
|
|
16381
|
+
|
|
16382
|
+
struct PointLight {
|
|
16383
|
+
vec3 color;
|
|
16384
|
+
vec3 position;
|
|
16385
|
+
vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential
|
|
16386
|
+
};
|
|
16387
|
+
|
|
16388
|
+
struct DirectionalLight {
|
|
16389
|
+
vec3 color;
|
|
16390
|
+
vec3 direction;
|
|
16391
|
+
};
|
|
16392
|
+
|
|
15712
16393
|
uniform lightingUniforms {
|
|
15713
16394
|
int enabled;
|
|
15714
16395
|
int lightType;
|
|
@@ -15732,6 +16413,16 @@ uniform lightingUniforms {
|
|
|
15732
16413
|
vec3 lightPosition2;
|
|
15733
16414
|
vec3 lightDirection2;
|
|
15734
16415
|
vec3 lightAttenuation2;
|
|
16416
|
+
|
|
16417
|
+
vec3 lightColor3;
|
|
16418
|
+
vec3 lightPosition3;
|
|
16419
|
+
vec3 lightDirection3;
|
|
16420
|
+
vec3 lightAttenuation3;
|
|
16421
|
+
|
|
16422
|
+
vec3 lightColor4;
|
|
16423
|
+
vec3 lightPosition4;
|
|
16424
|
+
vec3 lightDirection4;
|
|
16425
|
+
vec3 lightAttenuation4;
|
|
15735
16426
|
} lighting;
|
|
15736
16427
|
|
|
15737
16428
|
PointLight lighting_getPointLight(int index) {
|
|
@@ -15741,8 +16432,12 @@ PointLight lighting_getPointLight(int index) {
|
|
|
15741
16432
|
case 1:
|
|
15742
16433
|
return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
|
|
15743
16434
|
case 2:
|
|
15744
|
-
default:
|
|
15745
16435
|
return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
|
|
16436
|
+
case 3:
|
|
16437
|
+
return PointLight(lighting.lightColor3, lighting.lightPosition3, lighting.lightAttenuation3);
|
|
16438
|
+
case 4:
|
|
16439
|
+
default:
|
|
16440
|
+
return PointLight(lighting.lightColor4, lighting.lightPosition4, lighting.lightAttenuation4);
|
|
15746
16441
|
}
|
|
15747
16442
|
}
|
|
15748
16443
|
|
|
@@ -15753,8 +16448,12 @@ DirectionalLight lighting_getDirectionalLight(int index) {
|
|
|
15753
16448
|
case 1:
|
|
15754
16449
|
return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
|
|
15755
16450
|
case 2:
|
|
15756
|
-
default:
|
|
15757
16451
|
return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
|
|
16452
|
+
case 3:
|
|
16453
|
+
return DirectionalLight(lighting.lightColor3, lighting.lightDirection3);
|
|
16454
|
+
case 4:
|
|
16455
|
+
default:
|
|
16456
|
+
return DirectionalLight(lighting.lightColor4, lighting.lightDirection4);
|
|
15758
16457
|
}
|
|
15759
16458
|
}
|
|
15760
16459
|
|
|
@@ -15772,6 +16471,8 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
15772
16471
|
var lightingUniformsWGSL = (
|
|
15773
16472
|
/* wgsl */
|
|
15774
16473
|
`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
16474
|
+
const MAX_LIGHTS: i32 = 5;
|
|
16475
|
+
|
|
15775
16476
|
struct AmbientLight {
|
|
15776
16477
|
color: vec3<f32>,
|
|
15777
16478
|
};
|
|
@@ -15789,32 +16490,80 @@ struct DirectionalLight {
|
|
|
15789
16490
|
|
|
15790
16491
|
struct lightingUniforms {
|
|
15791
16492
|
enabled: i32,
|
|
15792
|
-
|
|
16493
|
+
lightType: i32,
|
|
16494
|
+
|
|
15793
16495
|
directionalLightCount: i32,
|
|
16496
|
+
pointLightCount: i32,
|
|
15794
16497
|
|
|
15795
16498
|
ambientColor: vec3<f32>,
|
|
15796
16499
|
|
|
15797
|
-
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15802
|
-
|
|
15803
|
-
|
|
15804
|
-
|
|
15805
|
-
|
|
15806
|
-
|
|
16500
|
+
lightColor0: vec3<f32>,
|
|
16501
|
+
lightPosition0: vec3<f32>,
|
|
16502
|
+
lightDirection0: vec3<f32>,
|
|
16503
|
+
lightAttenuation0: vec3<f32>,
|
|
16504
|
+
|
|
16505
|
+
lightColor1: vec3<f32>,
|
|
16506
|
+
lightPosition1: vec3<f32>,
|
|
16507
|
+
lightDirection1: vec3<f32>,
|
|
16508
|
+
lightAttenuation1: vec3<f32>,
|
|
16509
|
+
|
|
16510
|
+
lightColor2: vec3<f32>,
|
|
16511
|
+
lightPosition2: vec3<f32>,
|
|
16512
|
+
lightDirection2: vec3<f32>,
|
|
16513
|
+
lightAttenuation2: vec3<f32>,
|
|
16514
|
+
|
|
16515
|
+
lightColor3: vec3<f32>,
|
|
16516
|
+
lightPosition3: vec3<f32>,
|
|
16517
|
+
lightDirection3: vec3<f32>,
|
|
16518
|
+
lightAttenuation3: vec3<f32>,
|
|
16519
|
+
|
|
16520
|
+
lightColor4: vec3<f32>,
|
|
16521
|
+
lightPosition4: vec3<f32>,
|
|
16522
|
+
lightDirection4: vec3<f32>,
|
|
16523
|
+
lightAttenuation4: vec3<f32>,
|
|
15807
16524
|
};
|
|
15808
16525
|
|
|
15809
16526
|
// Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)
|
|
15810
16527
|
@binding(1) @group(0) var<uniform> lighting : lightingUniforms;
|
|
15811
16528
|
|
|
15812
16529
|
fn lighting_getPointLight(index: i32) -> PointLight {
|
|
15813
|
-
|
|
16530
|
+
switch (index) {
|
|
16531
|
+
case 0: {
|
|
16532
|
+
return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
|
|
16533
|
+
}
|
|
16534
|
+
case 1: {
|
|
16535
|
+
return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
|
|
16536
|
+
}
|
|
16537
|
+
case 2: {
|
|
16538
|
+
return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
|
|
16539
|
+
}
|
|
16540
|
+
case 3: {
|
|
16541
|
+
return PointLight(lighting.lightColor3, lighting.lightPosition3, lighting.lightAttenuation3);
|
|
16542
|
+
}
|
|
16543
|
+
case 4, default: {
|
|
16544
|
+
return PointLight(lighting.lightColor4, lighting.lightPosition4, lighting.lightAttenuation4);
|
|
16545
|
+
}
|
|
16546
|
+
}
|
|
15814
16547
|
}
|
|
15815
16548
|
|
|
15816
16549
|
fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
|
|
15817
|
-
|
|
16550
|
+
switch (index) {
|
|
16551
|
+
case 0: {
|
|
16552
|
+
return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
|
|
16553
|
+
}
|
|
16554
|
+
case 1: {
|
|
16555
|
+
return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
|
|
16556
|
+
}
|
|
16557
|
+
case 2: {
|
|
16558
|
+
return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
|
|
16559
|
+
}
|
|
16560
|
+
case 3: {
|
|
16561
|
+
return DirectionalLight(lighting.lightColor3, lighting.lightDirection3);
|
|
16562
|
+
}
|
|
16563
|
+
case 4, default: {
|
|
16564
|
+
return DirectionalLight(lighting.lightColor4, lighting.lightDirection4);
|
|
16565
|
+
}
|
|
16566
|
+
}
|
|
15818
16567
|
}
|
|
15819
16568
|
|
|
15820
16569
|
fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
|
|
@@ -15859,7 +16608,15 @@ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
|
|
|
15859
16608
|
lightColor2: "vec3<f32>",
|
|
15860
16609
|
lightPosition2: "vec3<f32>",
|
|
15861
16610
|
lightDirection2: "vec3<f32>",
|
|
15862
|
-
lightAttenuation2: "vec3<f32>"
|
|
16611
|
+
lightAttenuation2: "vec3<f32>",
|
|
16612
|
+
lightColor3: "vec3<f32>",
|
|
16613
|
+
lightPosition3: "vec3<f32>",
|
|
16614
|
+
lightDirection3: "vec3<f32>",
|
|
16615
|
+
lightAttenuation3: "vec3<f32>",
|
|
16616
|
+
lightColor4: "vec3<f32>",
|
|
16617
|
+
lightPosition4: "vec3<f32>",
|
|
16618
|
+
lightDirection4: "vec3<f32>",
|
|
16619
|
+
lightAttenuation4: "vec3<f32>"
|
|
15863
16620
|
},
|
|
15864
16621
|
defaultUniforms: {
|
|
15865
16622
|
enabled: 1,
|
|
@@ -15879,7 +16636,15 @@ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
|
|
|
15879
16636
|
lightColor2: [1, 1, 1],
|
|
15880
16637
|
lightPosition2: [1, 1, 2],
|
|
15881
16638
|
lightDirection2: [1, 1, 1],
|
|
15882
|
-
lightAttenuation2: [1, 0, 0]
|
|
16639
|
+
lightAttenuation2: [1, 0, 0],
|
|
16640
|
+
lightColor3: [1, 1, 1],
|
|
16641
|
+
lightPosition3: [1, 1, 2],
|
|
16642
|
+
lightDirection3: [1, 1, 1],
|
|
16643
|
+
lightAttenuation3: [1, 0, 0],
|
|
16644
|
+
lightColor4: [1, 1, 1],
|
|
16645
|
+
lightPosition4: [1, 1, 2],
|
|
16646
|
+
lightDirection4: [1, 1, 1],
|
|
16647
|
+
lightAttenuation4: [1, 0, 0]
|
|
15883
16648
|
},
|
|
15884
16649
|
source: lightingUniformsWGSL,
|
|
15885
16650
|
vs: lightingUniformsGLSL,
|
|
@@ -15913,26 +16678,36 @@ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
|
|
|
15913
16678
|
const lightSourceUniforms = {};
|
|
15914
16679
|
lightSourceUniforms.ambientColor = convertColor(ambientLight);
|
|
15915
16680
|
let currentLight = 0;
|
|
16681
|
+
let pointLightCount = 0;
|
|
16682
|
+
let directionalLightCount = 0;
|
|
15916
16683
|
for (const pointLight of pointLights) {
|
|
16684
|
+
if (currentLight >= MAX_LIGHTS) {
|
|
16685
|
+
break;
|
|
16686
|
+
}
|
|
15917
16687
|
lightSourceUniforms.lightType = LIGHT_TYPE.POINT;
|
|
15918
16688
|
const i = currentLight;
|
|
15919
16689
|
lightSourceUniforms[`lightColor${i}`] = convertColor(pointLight);
|
|
15920
16690
|
lightSourceUniforms[`lightPosition${i}`] = pointLight.position;
|
|
15921
16691
|
lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0];
|
|
15922
16692
|
currentLight++;
|
|
16693
|
+
pointLightCount++;
|
|
15923
16694
|
}
|
|
15924
16695
|
for (const directionalLight of directionalLights) {
|
|
16696
|
+
if (currentLight >= MAX_LIGHTS) {
|
|
16697
|
+
break;
|
|
16698
|
+
}
|
|
15925
16699
|
lightSourceUniforms.lightType = LIGHT_TYPE.DIRECTIONAL;
|
|
15926
16700
|
const i = currentLight;
|
|
15927
16701
|
lightSourceUniforms[`lightColor${i}`] = convertColor(directionalLight);
|
|
15928
16702
|
lightSourceUniforms[`lightDirection${i}`] = directionalLight.direction;
|
|
15929
16703
|
currentLight++;
|
|
16704
|
+
directionalLightCount++;
|
|
15930
16705
|
}
|
|
15931
|
-
if (
|
|
15932
|
-
import_core21.log.warn(
|
|
16706
|
+
if (pointLights.length + directionalLights.length > MAX_LIGHTS) {
|
|
16707
|
+
import_core21.log.warn(`MAX_LIGHTS exceeded, truncating to ${MAX_LIGHTS}`)();
|
|
15933
16708
|
}
|
|
15934
|
-
lightSourceUniforms.directionalLightCount =
|
|
15935
|
-
lightSourceUniforms.pointLightCount =
|
|
16709
|
+
lightSourceUniforms.directionalLightCount = directionalLightCount;
|
|
16710
|
+
lightSourceUniforms.pointLightCount = pointLightCount;
|
|
15936
16711
|
return lightSourceUniforms;
|
|
15937
16712
|
}
|
|
15938
16713
|
function extractLightTypes(lights) {
|
|
@@ -16465,51 +17240,55 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
16465
17240
|
`struct PBRFragmentInputs {
|
|
16466
17241
|
pbr_vPosition: vec3f,
|
|
16467
17242
|
pbr_vUV: vec2f,
|
|
16468
|
-
pbr_vTBN:
|
|
17243
|
+
pbr_vTBN: mat3x3f,
|
|
16469
17244
|
pbr_vNormal: vec3f
|
|
16470
17245
|
};
|
|
16471
17246
|
|
|
16472
|
-
var fragmentInputs: PBRFragmentInputs;
|
|
17247
|
+
var<private> fragmentInputs: PBRFragmentInputs;
|
|
16473
17248
|
|
|
16474
17249
|
fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)
|
|
16475
17250
|
{
|
|
16476
17251
|
var pos: vec4f = pbrProjection.modelMatrix * position;
|
|
16477
|
-
fragmentInputs.pbr_vPosition =
|
|
17252
|
+
fragmentInputs.pbr_vPosition = pos.xyz / pos.w;
|
|
17253
|
+
fragmentInputs.pbr_vNormal = vec3f(0.0, 0.0, 1.0);
|
|
17254
|
+
fragmentInputs.pbr_vTBN = mat3x3f(
|
|
17255
|
+
vec3f(1.0, 0.0, 0.0),
|
|
17256
|
+
vec3f(0.0, 1.0, 0.0),
|
|
17257
|
+
vec3f(0.0, 0.0, 1.0)
|
|
17258
|
+
);
|
|
17259
|
+
fragmentInputs.pbr_vUV = vec2f(0.0, 0.0);
|
|
16478
17260
|
|
|
16479
17261
|
#ifdef HAS_NORMALS
|
|
17262
|
+
let normalW: vec3f = normalize((pbrProjection.normalMatrix * vec4f(normal.xyz, 0.0)).xyz);
|
|
17263
|
+
fragmentInputs.pbr_vNormal = normalW;
|
|
16480
17264
|
#ifdef HAS_TANGENTS
|
|
16481
|
-
let
|
|
16482
|
-
let tangentW: vec3f = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
|
|
17265
|
+
let tangentW: vec3f = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz);
|
|
16483
17266
|
let bitangentW: vec3f = cross(normalW, tangentW) * tangent.w;
|
|
16484
|
-
fragmentInputs.pbr_vTBN =
|
|
16485
|
-
#else // HAS_TANGENTS != 1
|
|
16486
|
-
fragmentInputs.pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
|
|
17267
|
+
fragmentInputs.pbr_vTBN = mat3x3f(tangentW, bitangentW, normalW);
|
|
16487
17268
|
#endif
|
|
16488
17269
|
#endif
|
|
16489
17270
|
|
|
16490
17271
|
#ifdef HAS_UV
|
|
16491
17272
|
fragmentInputs.pbr_vUV = uv;
|
|
16492
|
-
#else
|
|
16493
|
-
fragmentInputs.pbr_vUV = vec2(0.,0.);
|
|
16494
17273
|
#endif
|
|
16495
17274
|
}
|
|
16496
17275
|
|
|
16497
17276
|
struct pbrMaterialUniforms {
|
|
16498
17277
|
// Material is unlit
|
|
16499
|
-
unlit:
|
|
17278
|
+
unlit: u32,
|
|
16500
17279
|
|
|
16501
17280
|
// Base color map
|
|
16502
|
-
baseColorMapEnabled:
|
|
17281
|
+
baseColorMapEnabled: u32,
|
|
16503
17282
|
baseColorFactor: vec4f,
|
|
16504
17283
|
|
|
16505
|
-
normalMapEnabled :
|
|
17284
|
+
normalMapEnabled : u32,
|
|
16506
17285
|
normalScale: f32, // #ifdef HAS_NORMALMAP
|
|
16507
17286
|
|
|
16508
|
-
emissiveMapEnabled:
|
|
17287
|
+
emissiveMapEnabled: u32,
|
|
16509
17288
|
emissiveFactor: vec3f, // #ifdef HAS_EMISSIVEMAP
|
|
16510
17289
|
|
|
16511
17290
|
metallicRoughnessValues: vec2f,
|
|
16512
|
-
metallicRoughnessMapEnabled:
|
|
17291
|
+
metallicRoughnessMapEnabled: u32,
|
|
16513
17292
|
|
|
16514
17293
|
occlusionMapEnabled: i32,
|
|
16515
17294
|
occlusionStrength: f32, // #ifdef HAS_OCCLUSIONMAP
|
|
@@ -16524,7 +17303,7 @@ struct pbrMaterialUniforms {
|
|
|
16524
17303
|
// debugging flags used for shader output of intermediate PBR variables
|
|
16525
17304
|
// #ifdef PBR_DEBUG
|
|
16526
17305
|
scaleDiffBaseMR: vec4f,
|
|
16527
|
-
scaleFGDSpec: vec4f
|
|
17306
|
+
scaleFGDSpec: vec4f,
|
|
16528
17307
|
// #endif
|
|
16529
17308
|
}
|
|
16530
17309
|
|
|
@@ -16532,24 +17311,32 @@ struct pbrMaterialUniforms {
|
|
|
16532
17311
|
|
|
16533
17312
|
// Samplers
|
|
16534
17313
|
#ifdef HAS_BASECOLORMAP
|
|
16535
|
-
|
|
17314
|
+
@binding(3) @group(0) var pbr_baseColorSampler: texture_2d<f32>;
|
|
17315
|
+
@binding(4) @group(0) var pbr_baseColorSamplerSampler: sampler;
|
|
16536
17316
|
#endif
|
|
16537
17317
|
#ifdef HAS_NORMALMAP
|
|
16538
|
-
|
|
17318
|
+
@binding(5) @group(0) var pbr_normalSampler: texture_2d<f32>;
|
|
17319
|
+
@binding(6) @group(0) var pbr_normalSamplerSampler: sampler;
|
|
16539
17320
|
#endif
|
|
16540
17321
|
#ifdef HAS_EMISSIVEMAP
|
|
16541
|
-
|
|
17322
|
+
@binding(7) @group(0) var pbr_emissiveSampler: texture_2d<f32>;
|
|
17323
|
+
@binding(8) @group(0) var pbr_emissiveSamplerSampler: sampler;
|
|
16542
17324
|
#endif
|
|
16543
17325
|
#ifdef HAS_METALROUGHNESSMAP
|
|
16544
|
-
|
|
17326
|
+
@binding(9) @group(0) var pbr_metallicRoughnessSampler: texture_2d<f32>;
|
|
17327
|
+
@binding(10) @group(0) var pbr_metallicRoughnessSamplerSampler: sampler;
|
|
16545
17328
|
#endif
|
|
16546
17329
|
#ifdef HAS_OCCLUSIONMAP
|
|
16547
|
-
|
|
17330
|
+
@binding(11) @group(0) var pbr_occlusionSampler: texture_2d<f32>;
|
|
17331
|
+
@binding(12) @group(0) var pbr_occlusionSamplerSampler: sampler;
|
|
16548
17332
|
#endif
|
|
16549
17333
|
#ifdef USE_IBL
|
|
16550
|
-
|
|
16551
|
-
|
|
16552
|
-
|
|
17334
|
+
@binding(13) @group(0) var pbr_diffuseEnvSampler: texture_cube<f32>;
|
|
17335
|
+
@binding(14) @group(0) var pbr_diffuseEnvSamplerSampler: sampler;
|
|
17336
|
+
@binding(15) @group(0) var pbr_specularEnvSampler: texture_cube<f32>;
|
|
17337
|
+
@binding(16) @group(0) var pbr_specularEnvSamplerSampler: sampler;
|
|
17338
|
+
@binding(17) @group(0) var pbr_BrdfLUT: texture_2d<f32>;
|
|
17339
|
+
@binding(18) @group(0) var pbr_BrdfLUTSampler: sampler;
|
|
16553
17340
|
#endif
|
|
16554
17341
|
|
|
16555
17342
|
// Encapsulate the various inputs used by the various functions in the shading equation
|
|
@@ -16577,17 +17364,19 @@ const c_MinRoughness = 0.04;
|
|
|
16577
17364
|
|
|
16578
17365
|
fn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f
|
|
16579
17366
|
{
|
|
17367
|
+
var linOut: vec3f = srgbIn.xyz;
|
|
16580
17368
|
#ifdef MANUAL_SRGB
|
|
17369
|
+
let bLess: vec3f = step(vec3f(0.04045), srgbIn.xyz);
|
|
17370
|
+
linOut = mix(
|
|
17371
|
+
srgbIn.xyz / vec3f(12.92),
|
|
17372
|
+
pow((srgbIn.xyz + vec3f(0.055)) / vec3f(1.055), vec3f(2.4)),
|
|
17373
|
+
bLess
|
|
17374
|
+
);
|
|
16581
17375
|
#ifdef SRGB_FAST_APPROXIMATION
|
|
16582
|
-
|
|
16583
|
-
#
|
|
16584
|
-
|
|
16585
|
-
|
|
16586
|
-
#endif //SRGB_FAST_APPROXIMATION
|
|
16587
|
-
return vec4f(linOut,srgbIn.w);;
|
|
16588
|
-
#else //MANUAL_SRGB
|
|
16589
|
-
return srgbIn;
|
|
16590
|
-
#endif //MANUAL_SRGB
|
|
17376
|
+
linOut = pow(srgbIn.xyz, vec3f(2.2));
|
|
17377
|
+
#endif
|
|
17378
|
+
#endif
|
|
17379
|
+
return vec4f(linOut, srgbIn.w);
|
|
16591
17380
|
}
|
|
16592
17381
|
|
|
16593
17382
|
// Find the normal for this fragment, pulling either from a predefined normal map
|
|
@@ -16595,32 +17384,28 @@ fn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f
|
|
|
16595
17384
|
fn getNormal() -> vec3f
|
|
16596
17385
|
{
|
|
16597
17386
|
// Retrieve the tangent space matrix
|
|
16598
|
-
|
|
16599
|
-
|
|
16600
|
-
|
|
16601
|
-
|
|
16602
|
-
var
|
|
16603
|
-
var t: vec3f = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
|
|
17387
|
+
let pos_dx: vec3f = dpdx(fragmentInputs.pbr_vPosition);
|
|
17388
|
+
let pos_dy: vec3f = dpdy(fragmentInputs.pbr_vPosition);
|
|
17389
|
+
let tex_dx: vec3f = dpdx(vec3f(fragmentInputs.pbr_vUV, 0.0));
|
|
17390
|
+
let tex_dy: vec3f = dpdy(vec3f(fragmentInputs.pbr_vUV, 0.0));
|
|
17391
|
+
var t: vec3f = (tex_dy.y * pos_dx - tex_dx.y * pos_dy) / (tex_dx.x * tex_dy.y - tex_dy.x * tex_dx.y);
|
|
16604
17392
|
|
|
16605
|
-
#ifdef HAS_NORMALS
|
|
16606
|
-
var ng: vec3f = normalize(fragmentInputs.pbr_vNormal);
|
|
16607
|
-
#else
|
|
16608
17393
|
var ng: vec3f = cross(pos_dx, pos_dy);
|
|
17394
|
+
#ifdef HAS_NORMALS
|
|
17395
|
+
ng = normalize(fragmentInputs.pbr_vNormal);
|
|
16609
17396
|
#endif
|
|
16610
|
-
|
|
16611
17397
|
t = normalize(t - ng * dot(ng, t));
|
|
16612
17398
|
var b: vec3f = normalize(cross(ng, t));
|
|
16613
|
-
var tbn:
|
|
16614
|
-
#
|
|
16615
|
-
|
|
17399
|
+
var tbn: mat3x3f = mat3x3f(t, b, ng);
|
|
17400
|
+
#ifdef HAS_TANGENTS
|
|
17401
|
+
tbn = fragmentInputs.pbr_vTBN;
|
|
16616
17402
|
#endif
|
|
16617
17403
|
|
|
16618
|
-
#ifdef HAS_NORMALMAP
|
|
16619
|
-
vec3 n = texture(pbr_normalSampler, fragmentInputs.pbr_vUV).rgb;
|
|
16620
|
-
n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
|
|
16621
|
-
#else
|
|
16622
17404
|
// The tbn matrix is linearly interpolated, so we need to re-normalize
|
|
16623
|
-
|
|
17405
|
+
var n: vec3f = normalize(tbn[2].xyz);
|
|
17406
|
+
#ifdef HAS_NORMALMAP
|
|
17407
|
+
n = textureSample(pbr_normalSampler, pbr_normalSamplerSampler, fragmentInputs.pbr_vUV).rgb;
|
|
17408
|
+
n = normalize(tbn * ((2.0 * n - 1.0) * vec3f(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
|
|
16624
17409
|
#endif
|
|
16625
17410
|
|
|
16626
17411
|
return n;
|
|
@@ -16630,27 +17415,37 @@ fn getNormal() -> vec3f
|
|
|
16630
17415
|
// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
|
|
16631
17416
|
// See our README.md on Environment Maps [3] for additional discussion.
|
|
16632
17417
|
#ifdef USE_IBL
|
|
16633
|
-
fn getIBLContribution(PBRInfo
|
|
17418
|
+
fn getIBLContribution(pbrInfo: PBRInfo, n: vec3f, reflection: vec3f) -> vec3f
|
|
16634
17419
|
{
|
|
16635
|
-
|
|
16636
|
-
|
|
17420
|
+
let mipCount: f32 = 9.0; // resolution of 512x512
|
|
17421
|
+
let lod: f32 = pbrInfo.perceptualRoughness * mipCount;
|
|
16637
17422
|
// retrieve a scale and bias to F0. See [1], Figure 3
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
|
|
16641
|
-
|
|
17423
|
+
let brdf = SRGBtoLINEAR(
|
|
17424
|
+
textureSample(
|
|
17425
|
+
pbr_BrdfLUT,
|
|
17426
|
+
pbr_BrdfLUTSampler,
|
|
17427
|
+
vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness)
|
|
17428
|
+
)
|
|
17429
|
+
).rgb;
|
|
17430
|
+
let diffuseLight =
|
|
17431
|
+
SRGBtoLINEAR(textureSample(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, n)).rgb;
|
|
17432
|
+
let specularLightDefault =
|
|
17433
|
+
SRGBtoLINEAR(textureSample(pbr_specularEnvSampler, pbr_specularEnvSamplerSampler, reflection)).rgb;
|
|
17434
|
+
var specularLight = specularLightDefault;
|
|
16642
17435
|
#ifdef USE_TEX_LOD
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
|
|
17436
|
+
specularLight = SRGBtoLINEAR(
|
|
17437
|
+
textureSampleLevel(
|
|
17438
|
+
pbr_specularEnvSampler,
|
|
17439
|
+
pbr_specularEnvSamplerSampler,
|
|
17440
|
+
reflection,
|
|
17441
|
+
lod
|
|
17442
|
+
)
|
|
17443
|
+
).rgb;
|
|
16646
17444
|
#endif
|
|
16647
17445
|
|
|
16648
|
-
|
|
16649
|
-
|
|
16650
|
-
|
|
16651
|
-
// For presentation, this allows us to disable IBL terms
|
|
16652
|
-
diffuse *= pbrMaterial.scaleIBLAmbient.x;
|
|
16653
|
-
specular *= pbrMaterial.scaleIBLAmbient.y;
|
|
17446
|
+
let diffuse = diffuseLight * pbrInfo.diffuseColor * pbrMaterial.scaleIBLAmbient.x;
|
|
17447
|
+
let specular =
|
|
17448
|
+
specularLight * (pbrInfo.specularColor * brdf.x + brdf.y) * pbrMaterial.scaleIBLAmbient.y;
|
|
16654
17449
|
|
|
16655
17450
|
return diffuse + specular;
|
|
16656
17451
|
}
|
|
@@ -16694,7 +17489,7 @@ fn geometricOcclusion(pbrInfo: PBRInfo) -> f32 {
|
|
|
16694
17489
|
fn microfacetDistribution(pbrInfo: PBRInfo) -> f32 {
|
|
16695
17490
|
let roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;
|
|
16696
17491
|
let f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;
|
|
16697
|
-
return roughnessSq / (
|
|
17492
|
+
return roughnessSq / (M_PI * f * f);
|
|
16698
17493
|
}
|
|
16699
17494
|
|
|
16700
17495
|
fn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) {
|
|
@@ -16736,11 +17531,11 @@ fn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> {
|
|
|
16736
17531
|
|
|
16737
17532
|
fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
16738
17533
|
// The albedo may be defined from a base texture or a flat color
|
|
16739
|
-
var baseColor: vec4<f32
|
|
17534
|
+
var baseColor: vec4<f32> = pbrMaterial.baseColorFactor;
|
|
16740
17535
|
#ifdef HAS_BASECOLORMAP
|
|
16741
|
-
baseColor = SRGBtoLINEAR(
|
|
16742
|
-
|
|
16743
|
-
|
|
17536
|
+
baseColor = SRGBtoLINEAR(
|
|
17537
|
+
textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, fragmentInputs.pbr_vUV)
|
|
17538
|
+
) * pbrMaterial.baseColorFactor;
|
|
16744
17539
|
#endif
|
|
16745
17540
|
|
|
16746
17541
|
#ifdef ALPHA_CUTOFF
|
|
@@ -16751,7 +17546,7 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
16751
17546
|
|
|
16752
17547
|
var color = vec3<f32>(0.0, 0.0, 0.0);
|
|
16753
17548
|
|
|
16754
|
-
if (pbrMaterial.unlit) {
|
|
17549
|
+
if (pbrMaterial.unlit != 0u) {
|
|
16755
17550
|
color = baseColor.rgb;
|
|
16756
17551
|
} else {
|
|
16757
17552
|
// Metallic and Roughness material properties are packed together
|
|
@@ -16762,7 +17557,11 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
16762
17557
|
#ifdef HAS_METALROUGHNESSMAP
|
|
16763
17558
|
// Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
|
|
16764
17559
|
// This layout intentionally reserves the 'r' channel for (optional) occlusion map data
|
|
16765
|
-
let mrSample = textureSample(
|
|
17560
|
+
let mrSample = textureSample(
|
|
17561
|
+
pbr_metallicRoughnessSampler,
|
|
17562
|
+
pbr_metallicRoughnessSamplerSampler,
|
|
17563
|
+
fragmentInputs.pbr_vUV
|
|
17564
|
+
);
|
|
16766
17565
|
perceptualRoughness = mrSample.g * perceptualRoughness;
|
|
16767
17566
|
metallic = mrSample.b * metallic;
|
|
16768
17567
|
#endif
|
|
@@ -16839,22 +17638,25 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
16839
17638
|
|
|
16840
17639
|
// Calculate lighting contribution from image based lighting source (IBL)
|
|
16841
17640
|
#ifdef USE_IBL
|
|
16842
|
-
if (pbrMaterial.IBLenabled) {
|
|
17641
|
+
if (pbrMaterial.IBLenabled != 0) {
|
|
16843
17642
|
color += getIBLContribution(pbrInfo, n, reflection);
|
|
16844
17643
|
}
|
|
16845
17644
|
#endif
|
|
16846
17645
|
|
|
16847
17646
|
// Apply optional PBR terms for additional (optional) shading
|
|
16848
17647
|
#ifdef HAS_OCCLUSIONMAP
|
|
16849
|
-
if (pbrMaterial.occlusionMapEnabled) {
|
|
16850
|
-
let ao =
|
|
17648
|
+
if (pbrMaterial.occlusionMapEnabled != 0) {
|
|
17649
|
+
let ao =
|
|
17650
|
+
textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, fragmentInputs.pbr_vUV).r;
|
|
16851
17651
|
color = mix(color, color * ao, pbrMaterial.occlusionStrength);
|
|
16852
17652
|
}
|
|
16853
17653
|
#endif
|
|
16854
17654
|
|
|
16855
17655
|
#ifdef HAS_EMISSIVEMAP
|
|
16856
|
-
if (pbrMaterial.emissiveMapEnabled) {
|
|
16857
|
-
let emissive = SRGBtoLINEAR(
|
|
17656
|
+
if (pbrMaterial.emissiveMapEnabled != 0u) {
|
|
17657
|
+
let emissive = SRGBtoLINEAR(
|
|
17658
|
+
textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, fragmentInputs.pbr_vUV)
|
|
17659
|
+
).rgb * pbrMaterial.emissiveFactor;
|
|
16858
17660
|
color += emissive;
|
|
16859
17661
|
}
|
|
16860
17662
|
#endif
|
|
@@ -16890,10 +17692,23 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
16890
17692
|
mat4 normalMatrix;
|
|
16891
17693
|
vec3 camera;
|
|
16892
17694
|
} pbrProjection;
|
|
17695
|
+
`
|
|
17696
|
+
);
|
|
17697
|
+
var wgslUniformBlock = (
|
|
17698
|
+
/* wgsl */
|
|
17699
|
+
`struct pbrProjectionUniforms {
|
|
17700
|
+
modelViewProjectionMatrix: mat4x4<f32>,
|
|
17701
|
+
modelMatrix: mat4x4<f32>,
|
|
17702
|
+
normalMatrix: mat4x4<f32>,
|
|
17703
|
+
camera: vec3<f32>
|
|
17704
|
+
};
|
|
17705
|
+
|
|
17706
|
+
@binding(0) @group(0) var<uniform> pbrProjection: pbrProjectionUniforms;
|
|
16893
17707
|
`
|
|
16894
17708
|
);
|
|
16895
17709
|
var pbrProjection = {
|
|
16896
17710
|
name: "pbrProjection",
|
|
17711
|
+
source: wgslUniformBlock,
|
|
16897
17712
|
vs: uniformBlock2,
|
|
16898
17713
|
fs: uniformBlock2,
|
|
16899
17714
|
// TODO why is this needed?
|
|
@@ -16902,7 +17717,7 @@ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
|
|
|
16902
17717
|
modelViewProjectionMatrix: "mat4x4<f32>",
|
|
16903
17718
|
modelMatrix: "mat4x4<f32>",
|
|
16904
17719
|
normalMatrix: "mat4x4<f32>",
|
|
16905
|
-
camera: "vec3<
|
|
17720
|
+
camera: "vec3<f32>"
|
|
16906
17721
|
}
|
|
16907
17722
|
};
|
|
16908
17723
|
|
|
@@ -17608,227 +18423,34 @@ void main(void) {
|
|
|
17608
18423
|
scratchPosition2.from(cartesian);
|
|
17609
18424
|
const positionX = scratchPosition2.x;
|
|
17610
18425
|
const positionY = scratchPosition2.y;
|
|
17611
|
-
const positionZ = scratchPosition2.z;
|
|
17612
|
-
const oneOverRadiiSquared = this.oneOverRadiiSquared;
|
|
17613
|
-
const beta = 1 / Math.sqrt(positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z);
|
|
17614
|
-
return scratchPosition2.multiplyScalar(beta).to(result);
|
|
17615
|
-
}
|
|
17616
|
-
/** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
|
|
17617
|
-
* its components by the result of `Ellipsoid#oneOverRadii` */
|
|
17618
|
-
transformPositionToScaledSpace(position, result = [0, 0, 0]) {
|
|
17619
|
-
return scratchPosition2.from(position).scale(this.oneOverRadii).to(result);
|
|
17620
|
-
}
|
|
17621
|
-
/** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
|
|
17622
|
-
* its components by the result of `Ellipsoid#radii`. */
|
|
17623
|
-
transformPositionFromScaledSpace(position, result = [0, 0, 0]) {
|
|
17624
|
-
return scratchPosition2.from(position).scale(this.radii).to(result);
|
|
17625
|
-
}
|
|
17626
|
-
/** Computes a point which is the intersection of the surface normal with the z-axis. */
|
|
17627
|
-
getSurfaceNormalIntersectionWithZAxis(position, buffer = 0, result = [0, 0, 0]) {
|
|
17628
|
-
assert2(equals7(this.radii.x, this.radii.y, math_utils_exports.EPSILON15));
|
|
17629
|
-
assert2(this.radii.z > 0);
|
|
17630
|
-
scratchPosition2.from(position);
|
|
17631
|
-
const z = scratchPosition2.z * (1 - this.squaredXOverSquaredZ);
|
|
17632
|
-
if (Math.abs(z) >= this.radii.z - buffer) {
|
|
17633
|
-
return void 0;
|
|
17634
|
-
}
|
|
17635
|
-
return scratchPosition2.set(0, 0, z).to(result);
|
|
17636
|
-
}
|
|
17637
|
-
};
|
|
17638
|
-
Ellipsoid.WGS84 = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
|
|
17639
|
-
|
|
17640
|
-
// ../../node_modules/@loaders.gl/tiles/node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
17641
|
-
function getHiResTimestamp3() {
|
|
17642
|
-
let timestamp;
|
|
17643
|
-
if (typeof window !== "undefined" && window.performance) {
|
|
17644
|
-
timestamp = window.performance.now();
|
|
17645
|
-
} else if (typeof process !== "undefined" && process.hrtime) {
|
|
17646
|
-
const timeParts = process.hrtime();
|
|
17647
|
-
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
17648
|
-
} else {
|
|
17649
|
-
timestamp = Date.now();
|
|
17650
|
-
}
|
|
17651
|
-
return timestamp;
|
|
17652
|
-
}
|
|
17653
|
-
|
|
17654
|
-
// ../../node_modules/@loaders.gl/tiles/node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
17655
|
-
var Stat2 = class {
|
|
17656
|
-
constructor(name12, type) {
|
|
17657
|
-
this.sampleSize = 1;
|
|
17658
|
-
this.time = 0;
|
|
17659
|
-
this.count = 0;
|
|
17660
|
-
this.samples = 0;
|
|
17661
|
-
this.lastTiming = 0;
|
|
17662
|
-
this.lastSampleTime = 0;
|
|
17663
|
-
this.lastSampleCount = 0;
|
|
17664
|
-
this._count = 0;
|
|
17665
|
-
this._time = 0;
|
|
17666
|
-
this._samples = 0;
|
|
17667
|
-
this._startTime = 0;
|
|
17668
|
-
this._timerPending = false;
|
|
17669
|
-
this.name = name12;
|
|
17670
|
-
this.type = type;
|
|
17671
|
-
this.reset();
|
|
17672
|
-
}
|
|
17673
|
-
reset() {
|
|
17674
|
-
this.time = 0;
|
|
17675
|
-
this.count = 0;
|
|
17676
|
-
this.samples = 0;
|
|
17677
|
-
this.lastTiming = 0;
|
|
17678
|
-
this.lastSampleTime = 0;
|
|
17679
|
-
this.lastSampleCount = 0;
|
|
17680
|
-
this._count = 0;
|
|
17681
|
-
this._time = 0;
|
|
17682
|
-
this._samples = 0;
|
|
17683
|
-
this._startTime = 0;
|
|
17684
|
-
this._timerPending = false;
|
|
17685
|
-
return this;
|
|
17686
|
-
}
|
|
17687
|
-
setSampleSize(samples) {
|
|
17688
|
-
this.sampleSize = samples;
|
|
17689
|
-
return this;
|
|
17690
|
-
}
|
|
17691
|
-
/** Call to increment count (+1) */
|
|
17692
|
-
incrementCount() {
|
|
17693
|
-
this.addCount(1);
|
|
17694
|
-
return this;
|
|
17695
|
-
}
|
|
17696
|
-
/** Call to decrement count (-1) */
|
|
17697
|
-
decrementCount() {
|
|
17698
|
-
this.subtractCount(1);
|
|
17699
|
-
return this;
|
|
17700
|
-
}
|
|
17701
|
-
/** Increase count */
|
|
17702
|
-
addCount(value) {
|
|
17703
|
-
this._count += value;
|
|
17704
|
-
this._samples++;
|
|
17705
|
-
this._checkSampling();
|
|
17706
|
-
return this;
|
|
17707
|
-
}
|
|
17708
|
-
/** Decrease count */
|
|
17709
|
-
subtractCount(value) {
|
|
17710
|
-
this._count -= value;
|
|
17711
|
-
this._samples++;
|
|
17712
|
-
this._checkSampling();
|
|
17713
|
-
return this;
|
|
17714
|
-
}
|
|
17715
|
-
/** Add an arbitrary timing and bump the count */
|
|
17716
|
-
addTime(time) {
|
|
17717
|
-
this._time += time;
|
|
17718
|
-
this.lastTiming = time;
|
|
17719
|
-
this._samples++;
|
|
17720
|
-
this._checkSampling();
|
|
17721
|
-
return this;
|
|
17722
|
-
}
|
|
17723
|
-
/** Start a timer */
|
|
17724
|
-
timeStart() {
|
|
17725
|
-
this._startTime = getHiResTimestamp3();
|
|
17726
|
-
this._timerPending = true;
|
|
17727
|
-
return this;
|
|
17728
|
-
}
|
|
17729
|
-
/** End a timer. Adds to time and bumps the timing count. */
|
|
17730
|
-
timeEnd() {
|
|
17731
|
-
if (!this._timerPending) {
|
|
17732
|
-
return this;
|
|
17733
|
-
}
|
|
17734
|
-
this.addTime(getHiResTimestamp3() - this._startTime);
|
|
17735
|
-
this._timerPending = false;
|
|
17736
|
-
this._checkSampling();
|
|
17737
|
-
return this;
|
|
17738
|
-
}
|
|
17739
|
-
getSampleAverageCount() {
|
|
17740
|
-
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
|
|
17741
|
-
}
|
|
17742
|
-
/** Calculate average time / count for the previous window */
|
|
17743
|
-
getSampleAverageTime() {
|
|
17744
|
-
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
|
|
17745
|
-
}
|
|
17746
|
-
/** Calculate counts per second for the previous window */
|
|
17747
|
-
getSampleHz() {
|
|
17748
|
-
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
|
|
17749
|
-
}
|
|
17750
|
-
getAverageCount() {
|
|
17751
|
-
return this.samples > 0 ? this.count / this.samples : 0;
|
|
17752
|
-
}
|
|
17753
|
-
/** Calculate average time / count */
|
|
17754
|
-
getAverageTime() {
|
|
17755
|
-
return this.samples > 0 ? this.time / this.samples : 0;
|
|
17756
|
-
}
|
|
17757
|
-
/** Calculate counts per second */
|
|
17758
|
-
getHz() {
|
|
17759
|
-
return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
|
|
17760
|
-
}
|
|
17761
|
-
_checkSampling() {
|
|
17762
|
-
if (this._samples === this.sampleSize) {
|
|
17763
|
-
this.lastSampleTime = this._time;
|
|
17764
|
-
this.lastSampleCount = this._count;
|
|
17765
|
-
this.count += this._count;
|
|
17766
|
-
this.time += this._time;
|
|
17767
|
-
this.samples += this._samples;
|
|
17768
|
-
this._time = 0;
|
|
17769
|
-
this._count = 0;
|
|
17770
|
-
this._samples = 0;
|
|
17771
|
-
}
|
|
17772
|
-
}
|
|
17773
|
-
};
|
|
17774
|
-
|
|
17775
|
-
// ../../node_modules/@loaders.gl/tiles/node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
17776
|
-
var Stats2 = class {
|
|
17777
|
-
constructor(options) {
|
|
17778
|
-
this.stats = {};
|
|
17779
|
-
this.id = options.id;
|
|
17780
|
-
this.stats = {};
|
|
17781
|
-
this._initializeStats(options.stats);
|
|
17782
|
-
Object.seal(this);
|
|
17783
|
-
}
|
|
17784
|
-
/** Acquire a stat. Create if it doesn't exist. */
|
|
17785
|
-
get(name12, type = "count") {
|
|
17786
|
-
return this._getOrCreate({ name: name12, type });
|
|
17787
|
-
}
|
|
17788
|
-
get size() {
|
|
17789
|
-
return Object.keys(this.stats).length;
|
|
17790
|
-
}
|
|
17791
|
-
/** Reset all stats */
|
|
17792
|
-
reset() {
|
|
17793
|
-
for (const stat of Object.values(this.stats)) {
|
|
17794
|
-
stat.reset();
|
|
17795
|
-
}
|
|
17796
|
-
return this;
|
|
17797
|
-
}
|
|
17798
|
-
forEach(fn) {
|
|
17799
|
-
for (const stat of Object.values(this.stats)) {
|
|
17800
|
-
fn(stat);
|
|
17801
|
-
}
|
|
18426
|
+
const positionZ = scratchPosition2.z;
|
|
18427
|
+
const oneOverRadiiSquared = this.oneOverRadiiSquared;
|
|
18428
|
+
const beta = 1 / Math.sqrt(positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z);
|
|
18429
|
+
return scratchPosition2.multiplyScalar(beta).to(result);
|
|
17802
18430
|
}
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
time: stat.time || 0,
|
|
17808
|
-
count: stat.count || 0,
|
|
17809
|
-
average: stat.getAverageTime() || 0,
|
|
17810
|
-
hz: stat.getHz() || 0
|
|
17811
|
-
};
|
|
17812
|
-
});
|
|
17813
|
-
return table;
|
|
18431
|
+
/** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
|
|
18432
|
+
* its components by the result of `Ellipsoid#oneOverRadii` */
|
|
18433
|
+
transformPositionToScaledSpace(position, result = [0, 0, 0]) {
|
|
18434
|
+
return scratchPosition2.from(position).scale(this.oneOverRadii).to(result);
|
|
17814
18435
|
}
|
|
17815
|
-
|
|
17816
|
-
|
|
18436
|
+
/** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
|
|
18437
|
+
* its components by the result of `Ellipsoid#radii`. */
|
|
18438
|
+
transformPositionFromScaledSpace(position, result = [0, 0, 0]) {
|
|
18439
|
+
return scratchPosition2.from(position).scale(this.radii).to(result);
|
|
17817
18440
|
}
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
}
|
|
17827
|
-
this.stats[name12] = result;
|
|
18441
|
+
/** Computes a point which is the intersection of the surface normal with the z-axis. */
|
|
18442
|
+
getSurfaceNormalIntersectionWithZAxis(position, buffer = 0, result = [0, 0, 0]) {
|
|
18443
|
+
assert2(equals7(this.radii.x, this.radii.y, math_utils_exports.EPSILON15));
|
|
18444
|
+
assert2(this.radii.z > 0);
|
|
18445
|
+
scratchPosition2.from(position);
|
|
18446
|
+
const z = scratchPosition2.z * (1 - this.squaredXOverSquaredZ);
|
|
18447
|
+
if (Math.abs(z) >= this.radii.z - buffer) {
|
|
18448
|
+
return void 0;
|
|
17828
18449
|
}
|
|
17829
|
-
return result;
|
|
18450
|
+
return scratchPosition2.set(0, 0, z).to(result);
|
|
17830
18451
|
}
|
|
17831
18452
|
};
|
|
18453
|
+
Ellipsoid.WGS84 = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
|
|
17832
18454
|
|
|
17833
18455
|
// ../../node_modules/@loaders.gl/tiles/dist/utils/doubly-linked-list-node.js
|
|
17834
18456
|
var DoublyLinkedListNode = class {
|
|
@@ -19774,7 +20396,7 @@ void main(void) {
|
|
|
19774
20396
|
this.memoryAdjustedScreenSpaceError = this.options.maximumScreenSpaceError;
|
|
19775
20397
|
this._cacheBytes = this.options.maximumMemoryUsage * 1024 * 1024;
|
|
19776
20398
|
this._cacheOverflowBytes = this.options.memoryCacheOverflow * 1024 * 1024;
|
|
19777
|
-
this.stats = new
|
|
20399
|
+
this.stats = new Stats({ id: this.url });
|
|
19778
20400
|
this._initializeStats();
|
|
19779
20401
|
this.tilesetInitializationPromise = this._initializeTileSet(tileset);
|
|
19780
20402
|
}
|
|
@@ -20334,7 +20956,7 @@ void main(void) {
|
|
|
20334
20956
|
};
|
|
20335
20957
|
|
|
20336
20958
|
// ../../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/version.js
|
|
20337
|
-
var
|
|
20959
|
+
var VERSION9 = true ? "4.4.0-alpha.18" : "latest";
|
|
20338
20960
|
|
|
20339
20961
|
// ../../node_modules/@loaders.gl/3d-tiles/dist/lib/constants.js
|
|
20340
20962
|
var TILE3D_TYPE = {
|
|
@@ -20453,7 +21075,7 @@ void main(void) {
|
|
|
20453
21075
|
}
|
|
20454
21076
|
|
|
20455
21077
|
// ../../node_modules/@loaders.gl/draco/dist/lib/utils/version.js
|
|
20456
|
-
var
|
|
21078
|
+
var VERSION10 = true ? "4.4.0-alpha.18" : "latest";
|
|
20457
21079
|
|
|
20458
21080
|
// ../../node_modules/@loaders.gl/schema-utils/dist/lib/schema/data-type.js
|
|
20459
21081
|
function getDataTypeFromTypedArray(array) {
|
|
@@ -21024,7 +21646,7 @@ void main(void) {
|
|
|
21024
21646
|
id: "draco",
|
|
21025
21647
|
module: "draco",
|
|
21026
21648
|
// shapes: ['mesh'],
|
|
21027
|
-
version:
|
|
21649
|
+
version: VERSION10,
|
|
21028
21650
|
worker: true,
|
|
21029
21651
|
extensions: ["drc"],
|
|
21030
21652
|
mimeTypes: ["application/octet-stream"],
|
|
@@ -21034,7 +21656,6 @@ void main(void) {
|
|
|
21034
21656
|
draco: {
|
|
21035
21657
|
decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
|
|
21036
21658
|
// 'js' for IE11
|
|
21037
|
-
libraryPath: "libs/",
|
|
21038
21659
|
extraAttributes: {},
|
|
21039
21660
|
attributeNameEntry: void 0
|
|
21040
21661
|
}
|
|
@@ -21045,7 +21666,7 @@ void main(void) {
|
|
|
21045
21666
|
parse
|
|
21046
21667
|
};
|
|
21047
21668
|
async function parse(arrayBuffer, options) {
|
|
21048
|
-
const { draco } = await loadDracoDecoderModule(options
|
|
21669
|
+
const { draco } = await loadDracoDecoderModule(extractLoadLibraryOptions(options), options?.draco?.decoderType || "wasm");
|
|
21049
21670
|
const dracoParser = new DracoParser(draco);
|
|
21050
21671
|
try {
|
|
21051
21672
|
return dracoParser.parseSync(arrayBuffer, options?.draco);
|
|
@@ -23651,690 +24272,246 @@ void main(void) {
|
|
|
23651
24272
|
for (const value of array) {
|
|
23652
24273
|
numberArray.push(Number(value));
|
|
23653
24274
|
}
|
|
23654
|
-
const Construct = COMPONENT_TYPE_TO_ARRAY_CONSTRUCTOR[componentType];
|
|
23655
|
-
if (!Construct) {
|
|
23656
|
-
throw new Error("Illegal component type");
|
|
23657
|
-
}
|
|
23658
|
-
return new Construct(numberArray);
|
|
23659
|
-
}
|
|
23660
|
-
function createPropertyDataString(strings) {
|
|
23661
|
-
const utf8Encode = new TextEncoder();
|
|
23662
|
-
const arr = [];
|
|
23663
|
-
let len5 = 0;
|
|
23664
|
-
for (const str7 of strings) {
|
|
23665
|
-
const uint8Array = utf8Encode.encode(str7);
|
|
23666
|
-
len5 += uint8Array.length;
|
|
23667
|
-
arr.push(uint8Array);
|
|
23668
|
-
}
|
|
23669
|
-
const strArray = new Uint8Array(len5);
|
|
23670
|
-
const strOffsets = [];
|
|
23671
|
-
let offset = 0;
|
|
23672
|
-
for (const str7 of arr) {
|
|
23673
|
-
strArray.set(str7, offset);
|
|
23674
|
-
strOffsets.push(offset);
|
|
23675
|
-
offset += str7.length;
|
|
23676
|
-
}
|
|
23677
|
-
strOffsets.push(offset);
|
|
23678
|
-
const stringOffsetsTypedArray = new Uint32Array(strOffsets);
|
|
23679
|
-
return { stringData: strArray, stringOffsets: stringOffsetsTypedArray };
|
|
23680
|
-
}
|
|
23681
|
-
function createBufferView(typedArray, scenegraph) {
|
|
23682
|
-
scenegraph.gltf.buffers.push({
|
|
23683
|
-
arrayBuffer: ensureArrayBuffer(typedArray.buffer),
|
|
23684
|
-
byteOffset: typedArray.byteOffset,
|
|
23685
|
-
byteLength: typedArray.byteLength
|
|
23686
|
-
});
|
|
23687
|
-
return scenegraph.addBufferView(typedArray);
|
|
23688
|
-
}
|
|
23689
|
-
|
|
23690
|
-
// ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/EXT_feature_metadata.js
|
|
23691
|
-
var EXT_feature_metadata_exports = {};
|
|
23692
|
-
__export(EXT_feature_metadata_exports, {
|
|
23693
|
-
decode: () => decode3,
|
|
23694
|
-
name: () => name3
|
|
23695
|
-
});
|
|
23696
|
-
var EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
|
|
23697
|
-
var name3 = EXT_FEATURE_METADATA_NAME;
|
|
23698
|
-
async function decode3(gltfData, options) {
|
|
23699
|
-
const scenegraph = new GLTFScenegraph(gltfData);
|
|
23700
|
-
decodeExtFeatureMetadata(scenegraph, options);
|
|
23701
|
-
}
|
|
23702
|
-
function decodeExtFeatureMetadata(scenegraph, options) {
|
|
23703
|
-
if (!options.gltf?.loadBuffers) {
|
|
23704
|
-
return;
|
|
23705
|
-
}
|
|
23706
|
-
const extension = scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);
|
|
23707
|
-
if (!extension) {
|
|
23708
|
-
return;
|
|
23709
|
-
}
|
|
23710
|
-
if (options.gltf?.loadImages) {
|
|
23711
|
-
decodePropertyTextures2(scenegraph, extension);
|
|
23712
|
-
}
|
|
23713
|
-
decodePropertyTables2(scenegraph, extension);
|
|
23714
|
-
}
|
|
23715
|
-
function decodePropertyTextures2(scenegraph, extension) {
|
|
23716
|
-
const schema = extension.schema;
|
|
23717
|
-
if (!schema) {
|
|
23718
|
-
return;
|
|
23719
|
-
}
|
|
23720
|
-
const schemaClasses = schema.classes;
|
|
23721
|
-
const { featureTextures } = extension;
|
|
23722
|
-
if (schemaClasses && featureTextures) {
|
|
23723
|
-
for (const schemaName in schemaClasses) {
|
|
23724
|
-
const schemaClass = schemaClasses[schemaName];
|
|
23725
|
-
const featureTexture = findFeatureTextureByClass(featureTextures, schemaName);
|
|
23726
|
-
if (featureTexture) {
|
|
23727
|
-
handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);
|
|
23728
|
-
}
|
|
23729
|
-
}
|
|
23730
|
-
}
|
|
23731
|
-
}
|
|
23732
|
-
function decodePropertyTables2(scenegraph, extension) {
|
|
23733
|
-
const schema = extension.schema;
|
|
23734
|
-
if (!schema) {
|
|
23735
|
-
return;
|
|
23736
|
-
}
|
|
23737
|
-
const schemaClasses = schema.classes;
|
|
23738
|
-
const propertyTables = extension.featureTables;
|
|
23739
|
-
if (schemaClasses && propertyTables) {
|
|
23740
|
-
for (const schemaName in schemaClasses) {
|
|
23741
|
-
const propertyTable = findPropertyTableByClass2(propertyTables, schemaName);
|
|
23742
|
-
if (propertyTable) {
|
|
23743
|
-
processPropertyTable2(scenegraph, schema, propertyTable);
|
|
23744
|
-
}
|
|
23745
|
-
}
|
|
23746
|
-
}
|
|
23747
|
-
}
|
|
23748
|
-
function findPropertyTableByClass2(propertyTables, schemaClassName) {
|
|
23749
|
-
for (const propertyTableName in propertyTables) {
|
|
23750
|
-
const propertyTable = propertyTables[propertyTableName];
|
|
23751
|
-
if (propertyTable.class === schemaClassName) {
|
|
23752
|
-
return propertyTable;
|
|
23753
|
-
}
|
|
23754
|
-
}
|
|
23755
|
-
return null;
|
|
23756
|
-
}
|
|
23757
|
-
function findFeatureTextureByClass(featureTextures, schemaClassName) {
|
|
23758
|
-
for (const featureTexturesName in featureTextures) {
|
|
23759
|
-
const featureTable = featureTextures[featureTexturesName];
|
|
23760
|
-
if (featureTable.class === schemaClassName) {
|
|
23761
|
-
return featureTable;
|
|
23762
|
-
}
|
|
23763
|
-
}
|
|
23764
|
-
return null;
|
|
23765
|
-
}
|
|
23766
|
-
function processPropertyTable2(scenegraph, schema, propertyTable) {
|
|
23767
|
-
if (!propertyTable.class) {
|
|
23768
|
-
return;
|
|
23769
|
-
}
|
|
23770
|
-
const schemaClass = schema.classes?.[propertyTable.class];
|
|
23771
|
-
if (!schemaClass) {
|
|
23772
|
-
throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`);
|
|
23773
|
-
}
|
|
23774
|
-
const numberOfElements = propertyTable.count;
|
|
23775
|
-
for (const propertyName in schemaClass.properties) {
|
|
23776
|
-
const classProperty = schemaClass.properties[propertyName];
|
|
23777
|
-
const propertyTableProperty = propertyTable.properties?.[propertyName];
|
|
23778
|
-
if (propertyTableProperty) {
|
|
23779
|
-
const data = getPropertyDataFromBinarySource2(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty);
|
|
23780
|
-
propertyTableProperty.data = data;
|
|
23781
|
-
}
|
|
23782
|
-
}
|
|
23783
|
-
}
|
|
23784
|
-
function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) {
|
|
23785
|
-
const attributeName = featureTexture.class;
|
|
23786
|
-
for (const propertyName in schemaClass.properties) {
|
|
23787
|
-
const featureTextureProperty = featureTexture?.properties?.[propertyName];
|
|
23788
|
-
if (featureTextureProperty) {
|
|
23789
|
-
const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);
|
|
23790
|
-
featureTextureProperty.data = data;
|
|
23791
|
-
}
|
|
23792
|
-
}
|
|
23793
|
-
}
|
|
23794
|
-
function getPropertyDataFromBinarySource2(scenegraph, schema, classProperty, numberOfFeatures, featureTableProperty) {
|
|
23795
|
-
let data = [];
|
|
23796
|
-
const bufferView = featureTableProperty.bufferView;
|
|
23797
|
-
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
23798
|
-
const arrayOffsets = getArrayOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures);
|
|
23799
|
-
const stringOffsets = getStringOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures);
|
|
23800
|
-
if (classProperty.type === "STRING" || classProperty.componentType === "STRING") {
|
|
23801
|
-
data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets);
|
|
23802
|
-
} else if (isNumericProperty(classProperty)) {
|
|
23803
|
-
data = getPropertyDataNumeric2(classProperty, numberOfFeatures, dataArray, arrayOffsets);
|
|
23804
|
-
}
|
|
23805
|
-
return data;
|
|
23806
|
-
}
|
|
23807
|
-
function getArrayOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
23808
|
-
if (classProperty.type === "ARRAY" && // `componentCount` is a number of fixed-length array elements.
|
|
23809
|
-
// If `componentCount` is NOT defined, it's a VARIABLE-length array
|
|
23810
|
-
typeof classProperty.componentCount === "undefined" && // `arrayOffsetBufferView` is an index of the buffer view containing offsets for variable-length arrays.
|
|
23811
|
-
typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") {
|
|
23812
|
-
return getOffsetsForProperty(
|
|
23813
|
-
scenegraph,
|
|
23814
|
-
propertyTableProperty.arrayOffsetBufferView,
|
|
23815
|
-
propertyTableProperty.offsetType || "UINT32",
|
|
23816
|
-
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
23817
|
-
numberOfElements
|
|
23818
|
-
);
|
|
23819
|
-
}
|
|
23820
|
-
return null;
|
|
23821
|
-
}
|
|
23822
|
-
function getStringOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
23823
|
-
if (typeof propertyTableProperty.stringOffsetBufferView !== "undefined") {
|
|
23824
|
-
return getOffsetsForProperty(
|
|
23825
|
-
scenegraph,
|
|
23826
|
-
propertyTableProperty.stringOffsetBufferView,
|
|
23827
|
-
propertyTableProperty.offsetType || "UINT32",
|
|
23828
|
-
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
23829
|
-
numberOfElements
|
|
23830
|
-
);
|
|
23831
|
-
}
|
|
23832
|
-
return null;
|
|
23833
|
-
}
|
|
23834
|
-
function isNumericProperty(schemaProperty) {
|
|
23835
|
-
const types = [
|
|
23836
|
-
"UINT8",
|
|
23837
|
-
"INT16",
|
|
23838
|
-
"UINT16",
|
|
23839
|
-
"INT32",
|
|
23840
|
-
"UINT32",
|
|
23841
|
-
"INT64",
|
|
23842
|
-
"UINT64",
|
|
23843
|
-
"FLOAT32",
|
|
23844
|
-
"FLOAT64"
|
|
23845
|
-
];
|
|
23846
|
-
return types.includes(schemaProperty.type) || typeof schemaProperty.componentType !== "undefined" && types.includes(schemaProperty.componentType);
|
|
23847
|
-
}
|
|
23848
|
-
function getPropertyDataNumeric2(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
23849
|
-
const isArray2 = classProperty.type === "ARRAY";
|
|
23850
|
-
const arrayCount = classProperty.componentCount;
|
|
23851
|
-
const attributeType = "SCALAR";
|
|
23852
|
-
const componentType = classProperty.componentType || classProperty.type;
|
|
23853
|
-
const elementSize = getArrayElementByteSize(attributeType, componentType);
|
|
23854
|
-
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
23855
|
-
const valuesData = convertRawBufferToMetadataArray(valuesDataBytes, attributeType, componentType, elementCount);
|
|
23856
|
-
if (isArray2) {
|
|
23857
|
-
if (arrayOffsets) {
|
|
23858
|
-
return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
|
|
23859
|
-
}
|
|
23860
|
-
if (arrayCount) {
|
|
23861
|
-
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
23862
|
-
}
|
|
23863
|
-
return [];
|
|
24275
|
+
const Construct = COMPONENT_TYPE_TO_ARRAY_CONSTRUCTOR[componentType];
|
|
24276
|
+
if (!Construct) {
|
|
24277
|
+
throw new Error("Illegal component type");
|
|
23864
24278
|
}
|
|
23865
|
-
return
|
|
24279
|
+
return new Construct(numberArray);
|
|
23866
24280
|
}
|
|
23867
|
-
function
|
|
23868
|
-
const
|
|
23869
|
-
|
|
23870
|
-
|
|
24281
|
+
function createPropertyDataString(strings) {
|
|
24282
|
+
const utf8Encode = new TextEncoder();
|
|
24283
|
+
const arr = [];
|
|
24284
|
+
let len5 = 0;
|
|
24285
|
+
for (const str7 of strings) {
|
|
24286
|
+
const uint8Array = utf8Encode.encode(str7);
|
|
24287
|
+
len5 += uint8Array.length;
|
|
24288
|
+
arr.push(uint8Array);
|
|
23871
24289
|
}
|
|
23872
|
-
const
|
|
23873
|
-
|
|
23874
|
-
|
|
23875
|
-
|
|
23876
|
-
|
|
24290
|
+
const strArray = new Uint8Array(len5);
|
|
24291
|
+
const strOffsets = [];
|
|
24292
|
+
let offset = 0;
|
|
24293
|
+
for (const str7 of arr) {
|
|
24294
|
+
strArray.set(str7, offset);
|
|
24295
|
+
strOffsets.push(offset);
|
|
24296
|
+
offset += str7.length;
|
|
23877
24297
|
}
|
|
23878
|
-
|
|
24298
|
+
strOffsets.push(offset);
|
|
24299
|
+
const stringOffsetsTypedArray = new Uint32Array(strOffsets);
|
|
24300
|
+
return { stringData: strArray, stringOffsets: stringOffsetsTypedArray };
|
|
23879
24301
|
}
|
|
23880
|
-
function
|
|
23881
|
-
|
|
23882
|
-
|
|
23883
|
-
|
|
23884
|
-
|
|
23885
|
-
|
|
23886
|
-
|
|
23887
|
-
return;
|
|
23888
|
-
}
|
|
23889
|
-
primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTextureTable, primitive);
|
|
24302
|
+
function createBufferView(typedArray, scenegraph) {
|
|
24303
|
+
scenegraph.gltf.buffers.push({
|
|
24304
|
+
arrayBuffer: ensureArrayBuffer(typedArray.buffer),
|
|
24305
|
+
byteOffset: typedArray.byteOffset,
|
|
24306
|
+
byteLength: typedArray.byteLength
|
|
24307
|
+
});
|
|
24308
|
+
return scenegraph.addBufferView(typedArray);
|
|
23890
24309
|
}
|
|
23891
24310
|
|
|
23892
|
-
// ../../node_modules/@loaders.gl/gltf/dist/lib/
|
|
23893
|
-
var
|
|
23894
|
-
|
|
23895
|
-
|
|
23896
|
-
|
|
23897
|
-
|
|
23898
|
-
|
|
23899
|
-
var
|
|
23900
|
-
|
|
23901
|
-
|
|
23902
|
-
|
|
23903
|
-
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
23904
|
-
/** Basis encoder, javascript wrapper part */
|
|
23905
|
-
ENCODER: "basis_encoder.js",
|
|
23906
|
-
/** Basis encoder, compiled web assembly part */
|
|
23907
|
-
ENCODER_WASM: "basis_encoder.wasm"
|
|
23908
|
-
};
|
|
23909
|
-
var loadBasisTranscoderPromise;
|
|
23910
|
-
async function loadBasisTranscoderModule(options) {
|
|
23911
|
-
registerJSModules(options.modules);
|
|
23912
|
-
const basis = getJSModuleOrNull("basis");
|
|
23913
|
-
if (basis) {
|
|
23914
|
-
return basis;
|
|
23915
|
-
}
|
|
23916
|
-
loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
|
|
23917
|
-
return await loadBasisTranscoderPromise;
|
|
23918
|
-
}
|
|
23919
|
-
async function loadBasisTranscoder(options) {
|
|
23920
|
-
let BASIS2 = null;
|
|
23921
|
-
let wasmBinary = null;
|
|
23922
|
-
[BASIS2, wasmBinary] = await Promise.all([
|
|
23923
|
-
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
23924
|
-
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
23925
|
-
]);
|
|
23926
|
-
BASIS2 = BASIS2 || globalThis.BASIS;
|
|
23927
|
-
return await initializeBasisTranscoderModule(BASIS2, wasmBinary);
|
|
24311
|
+
// ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/EXT_feature_metadata.js
|
|
24312
|
+
var EXT_feature_metadata_exports = {};
|
|
24313
|
+
__export(EXT_feature_metadata_exports, {
|
|
24314
|
+
decode: () => decode3,
|
|
24315
|
+
name: () => name3
|
|
24316
|
+
});
|
|
24317
|
+
var EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
|
|
24318
|
+
var name3 = EXT_FEATURE_METADATA_NAME;
|
|
24319
|
+
async function decode3(gltfData, options) {
|
|
24320
|
+
const scenegraph = new GLTFScenegraph(gltfData);
|
|
24321
|
+
decodeExtFeatureMetadata(scenegraph, options);
|
|
23928
24322
|
}
|
|
23929
|
-
function
|
|
23930
|
-
|
|
23931
|
-
|
|
23932
|
-
options.wasmBinary = wasmBinary;
|
|
24323
|
+
function decodeExtFeatureMetadata(scenegraph, options) {
|
|
24324
|
+
if (!options.gltf?.loadBuffers) {
|
|
24325
|
+
return;
|
|
23933
24326
|
}
|
|
23934
|
-
|
|
23935
|
-
|
|
23936
|
-
|
|
23937
|
-
initializeBasis();
|
|
23938
|
-
resolve2({ BasisFile });
|
|
23939
|
-
});
|
|
23940
|
-
});
|
|
23941
|
-
}
|
|
23942
|
-
var loadBasisEncoderPromise;
|
|
23943
|
-
async function loadBasisEncoderModule(options) {
|
|
23944
|
-
const modules = options.modules || {};
|
|
23945
|
-
if (modules.basisEncoder) {
|
|
23946
|
-
return modules.basisEncoder;
|
|
24327
|
+
const extension = scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);
|
|
24328
|
+
if (!extension) {
|
|
24329
|
+
return;
|
|
23947
24330
|
}
|
|
23948
|
-
|
|
23949
|
-
|
|
23950
|
-
}
|
|
23951
|
-
async function loadBasisEncoder(options) {
|
|
23952
|
-
let BASIS_ENCODER = null;
|
|
23953
|
-
let wasmBinary = null;
|
|
23954
|
-
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
23955
|
-
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
23956
|
-
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
23957
|
-
]);
|
|
23958
|
-
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
23959
|
-
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
23960
|
-
}
|
|
23961
|
-
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
23962
|
-
const options = {};
|
|
23963
|
-
if (wasmBinary) {
|
|
23964
|
-
options.wasmBinary = wasmBinary;
|
|
24331
|
+
if (options.gltf?.loadImages) {
|
|
24332
|
+
decodePropertyTextures2(scenegraph, extension);
|
|
23965
24333
|
}
|
|
23966
|
-
|
|
23967
|
-
BasisEncoderModule(options).then((module) => {
|
|
23968
|
-
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
23969
|
-
initializeBasis();
|
|
23970
|
-
resolve2({ BasisFile, KTX2File, BasisEncoder });
|
|
23971
|
-
});
|
|
23972
|
-
});
|
|
24334
|
+
decodePropertyTables2(scenegraph, extension);
|
|
23973
24335
|
}
|
|
23974
|
-
|
|
23975
|
-
|
|
23976
|
-
|
|
23977
|
-
|
|
23978
|
-
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
|
|
23982
|
-
|
|
23983
|
-
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
COMPRESSED_RGB8_ETC2: 37492,
|
|
23988
|
-
COMPRESSED_RGBA8_ETC2_EAC: 37493,
|
|
23989
|
-
COMPRESSED_SRGB8_ETC2: 37494,
|
|
23990
|
-
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
23991
|
-
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
23992
|
-
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
23993
|
-
// WEBGL_compressed_texture_pvrtc
|
|
23994
|
-
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
23995
|
-
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
23996
|
-
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
23997
|
-
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
23998
|
-
// WEBGL_compressed_texture_etc1
|
|
23999
|
-
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
24000
|
-
// WEBGL_compressed_texture_atc
|
|
24001
|
-
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
24002
|
-
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
24003
|
-
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
24004
|
-
// WEBGL_compressed_texture_astc
|
|
24005
|
-
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
24006
|
-
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
24007
|
-
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
24008
|
-
COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
|
|
24009
|
-
COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
|
|
24010
|
-
COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
|
|
24011
|
-
COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
|
|
24012
|
-
COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
|
|
24013
|
-
COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
|
|
24014
|
-
COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
|
|
24015
|
-
COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
|
|
24016
|
-
COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
|
|
24017
|
-
COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
|
|
24018
|
-
COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
|
|
24019
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
|
|
24020
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
|
|
24021
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
|
|
24022
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
|
|
24023
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
|
|
24024
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
|
|
24025
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
|
|
24026
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
|
|
24027
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
|
|
24028
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
|
|
24029
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
|
|
24030
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
24031
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
24032
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
24033
|
-
// EXT_texture_compression_rgtc
|
|
24034
|
-
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
24035
|
-
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
24036
|
-
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
24037
|
-
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
24038
|
-
// WEBGL_compressed_texture_s3tc_srgb
|
|
24039
|
-
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
24040
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
24041
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
24042
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
|
|
24043
|
-
};
|
|
24044
|
-
|
|
24045
|
-
// ../../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/textures/dist/lib/utils/texture-formats.js
|
|
24046
|
-
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
24047
|
-
var WEBGL_EXTENSIONS = {
|
|
24048
|
-
/* eslint-disable camelcase */
|
|
24049
|
-
WEBGL_compressed_texture_s3tc: "dxt",
|
|
24050
|
-
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
24051
|
-
WEBGL_compressed_texture_etc1: "etc1",
|
|
24052
|
-
WEBGL_compressed_texture_etc: "etc2",
|
|
24053
|
-
WEBGL_compressed_texture_pvrtc: "pvrtc",
|
|
24054
|
-
WEBGL_compressed_texture_atc: "atc",
|
|
24055
|
-
WEBGL_compressed_texture_astc: "astc",
|
|
24056
|
-
EXT_texture_compression_rgtc: "rgtc"
|
|
24057
|
-
/* eslint-enable camelcase */
|
|
24058
|
-
};
|
|
24059
|
-
var formats = null;
|
|
24060
|
-
function getSupportedGPUTextureFormats(gl) {
|
|
24061
|
-
if (!formats) {
|
|
24062
|
-
gl = gl || getWebGLContext() || void 0;
|
|
24063
|
-
formats = /* @__PURE__ */ new Set();
|
|
24064
|
-
for (const prefix of BROWSER_PREFIXES) {
|
|
24065
|
-
for (const extension in WEBGL_EXTENSIONS) {
|
|
24066
|
-
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
24067
|
-
const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
|
|
24068
|
-
formats.add(gpuTextureFormat);
|
|
24069
|
-
}
|
|
24336
|
+
function decodePropertyTextures2(scenegraph, extension) {
|
|
24337
|
+
const schema = extension.schema;
|
|
24338
|
+
if (!schema) {
|
|
24339
|
+
return;
|
|
24340
|
+
}
|
|
24341
|
+
const schemaClasses = schema.classes;
|
|
24342
|
+
const { featureTextures } = extension;
|
|
24343
|
+
if (schemaClasses && featureTextures) {
|
|
24344
|
+
for (const schemaName in schemaClasses) {
|
|
24345
|
+
const schemaClass = schemaClasses[schemaName];
|
|
24346
|
+
const featureTexture = findFeatureTextureByClass(featureTextures, schemaName);
|
|
24347
|
+
if (featureTexture) {
|
|
24348
|
+
handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);
|
|
24070
24349
|
}
|
|
24071
24350
|
}
|
|
24072
24351
|
}
|
|
24073
|
-
return formats;
|
|
24074
|
-
}
|
|
24075
|
-
function getWebGLContext() {
|
|
24076
|
-
try {
|
|
24077
|
-
const canvas = document.createElement("canvas");
|
|
24078
|
-
return canvas.getContext("webgl");
|
|
24079
|
-
} catch (error) {
|
|
24080
|
-
return null;
|
|
24081
|
-
}
|
|
24082
|
-
}
|
|
24083
|
-
|
|
24084
|
-
// ../../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/textures/dist/lib/parsers/parse-ktx.js
|
|
24085
|
-
var KTX2_ID = [
|
|
24086
|
-
// '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
|
|
24087
|
-
171,
|
|
24088
|
-
75,
|
|
24089
|
-
84,
|
|
24090
|
-
88,
|
|
24091
|
-
32,
|
|
24092
|
-
50,
|
|
24093
|
-
48,
|
|
24094
|
-
187,
|
|
24095
|
-
13,
|
|
24096
|
-
10,
|
|
24097
|
-
26,
|
|
24098
|
-
10
|
|
24099
|
-
];
|
|
24100
|
-
function isKTX(data) {
|
|
24101
|
-
const id = new Uint8Array(data);
|
|
24102
|
-
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || // '´'
|
|
24103
|
-
id[1] !== KTX2_ID[1] || // 'K'
|
|
24104
|
-
id[2] !== KTX2_ID[2] || // 'T'
|
|
24105
|
-
id[3] !== KTX2_ID[3] || // 'X'
|
|
24106
|
-
id[4] !== KTX2_ID[4] || // ' '
|
|
24107
|
-
id[5] !== KTX2_ID[5] || // '2'
|
|
24108
|
-
id[6] !== KTX2_ID[6] || // '0'
|
|
24109
|
-
id[7] !== KTX2_ID[7] || // 'ª'
|
|
24110
|
-
id[8] !== KTX2_ID[8] || // '\r'
|
|
24111
|
-
id[9] !== KTX2_ID[9] || // '\n'
|
|
24112
|
-
id[10] !== KTX2_ID[10] || // '\x1A'
|
|
24113
|
-
id[11] !== KTX2_ID[11];
|
|
24114
|
-
return !notKTX;
|
|
24115
24352
|
}
|
|
24116
|
-
|
|
24117
|
-
|
|
24118
|
-
|
|
24119
|
-
|
|
24120
|
-
basisFormat: 0,
|
|
24121
|
-
compressed: true,
|
|
24122
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
24123
|
-
},
|
|
24124
|
-
etc2: { basisFormat: 1, compressed: true },
|
|
24125
|
-
bc1: {
|
|
24126
|
-
basisFormat: 2,
|
|
24127
|
-
compressed: true,
|
|
24128
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
|
|
24129
|
-
},
|
|
24130
|
-
bc3: {
|
|
24131
|
-
basisFormat: 3,
|
|
24132
|
-
compressed: true,
|
|
24133
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
24134
|
-
},
|
|
24135
|
-
bc4: { basisFormat: 4, compressed: true },
|
|
24136
|
-
bc5: { basisFormat: 5, compressed: true },
|
|
24137
|
-
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
24138
|
-
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
24139
|
-
"pvrtc1-4-rgb": {
|
|
24140
|
-
basisFormat: 8,
|
|
24141
|
-
compressed: true,
|
|
24142
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
|
24143
|
-
},
|
|
24144
|
-
"pvrtc1-4-rgba": {
|
|
24145
|
-
basisFormat: 9,
|
|
24146
|
-
compressed: true,
|
|
24147
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
|
24148
|
-
},
|
|
24149
|
-
"astc-4x4": {
|
|
24150
|
-
basisFormat: 10,
|
|
24151
|
-
compressed: true,
|
|
24152
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
24153
|
-
},
|
|
24154
|
-
"atc-rgb": { basisFormat: 11, compressed: true },
|
|
24155
|
-
"atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
|
|
24156
|
-
rgba32: { basisFormat: 13, compressed: false },
|
|
24157
|
-
rgb565: { basisFormat: 14, compressed: false },
|
|
24158
|
-
bgr565: { basisFormat: 15, compressed: false },
|
|
24159
|
-
rgba4444: { basisFormat: 16, compressed: false }
|
|
24160
|
-
};
|
|
24161
|
-
async function parseBasis(data, options = {}) {
|
|
24162
|
-
if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
|
|
24163
|
-
if (isKTX(data)) {
|
|
24164
|
-
const fileConstructors = await loadBasisEncoderModule(options?.core || {});
|
|
24165
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
24166
|
-
}
|
|
24167
|
-
const { BasisFile } = await loadBasisTranscoderModule(options?.core || {});
|
|
24168
|
-
return parseBasisFile(BasisFile, data, options);
|
|
24353
|
+
function decodePropertyTables2(scenegraph, extension) {
|
|
24354
|
+
const schema = extension.schema;
|
|
24355
|
+
if (!schema) {
|
|
24356
|
+
return;
|
|
24169
24357
|
}
|
|
24170
|
-
|
|
24171
|
-
|
|
24172
|
-
|
|
24173
|
-
|
|
24174
|
-
|
|
24175
|
-
|
|
24176
|
-
|
|
24177
|
-
default:
|
|
24178
|
-
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
24358
|
+
const schemaClasses = schema.classes;
|
|
24359
|
+
const propertyTables = extension.featureTables;
|
|
24360
|
+
if (schemaClasses && propertyTables) {
|
|
24361
|
+
for (const schemaName in schemaClasses) {
|
|
24362
|
+
const propertyTable = findPropertyTableByClass2(propertyTables, schemaName);
|
|
24363
|
+
if (propertyTable) {
|
|
24364
|
+
processPropertyTable2(scenegraph, schema, propertyTable);
|
|
24179
24365
|
}
|
|
24180
|
-
|
|
24181
|
-
default:
|
|
24182
|
-
const { BasisFile } = await loadBasisTranscoderModule(options.core || {});
|
|
24183
|
-
return parseBasisFile(BasisFile, data, options);
|
|
24366
|
+
}
|
|
24184
24367
|
}
|
|
24185
24368
|
}
|
|
24186
|
-
function
|
|
24187
|
-
const
|
|
24188
|
-
|
|
24189
|
-
if (
|
|
24190
|
-
|
|
24191
|
-
}
|
|
24192
|
-
const imageCount = basisFile.getNumImages();
|
|
24193
|
-
const images = [];
|
|
24194
|
-
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
24195
|
-
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
24196
|
-
const levels = [];
|
|
24197
|
-
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
24198
|
-
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
24199
|
-
}
|
|
24200
|
-
images.push(levels);
|
|
24369
|
+
function findPropertyTableByClass2(propertyTables, schemaClassName) {
|
|
24370
|
+
for (const propertyTableName in propertyTables) {
|
|
24371
|
+
const propertyTable = propertyTables[propertyTableName];
|
|
24372
|
+
if (propertyTable.class === schemaClassName) {
|
|
24373
|
+
return propertyTable;
|
|
24201
24374
|
}
|
|
24202
|
-
return images;
|
|
24203
|
-
} finally {
|
|
24204
|
-
basisFile.close();
|
|
24205
|
-
basisFile.delete();
|
|
24206
24375
|
}
|
|
24376
|
+
return null;
|
|
24207
24377
|
}
|
|
24208
|
-
function
|
|
24209
|
-
const
|
|
24210
|
-
|
|
24211
|
-
|
|
24212
|
-
|
|
24213
|
-
|
|
24214
|
-
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
24215
|
-
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
24216
|
-
const decodedData = new Uint8Array(decodedSize);
|
|
24217
|
-
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
24218
|
-
throw new Error("failed to start Basis transcoding");
|
|
24378
|
+
function findFeatureTextureByClass(featureTextures, schemaClassName) {
|
|
24379
|
+
for (const featureTexturesName in featureTextures) {
|
|
24380
|
+
const featureTable = featureTextures[featureTexturesName];
|
|
24381
|
+
if (featureTable.class === schemaClassName) {
|
|
24382
|
+
return featureTable;
|
|
24383
|
+
}
|
|
24219
24384
|
}
|
|
24220
|
-
return
|
|
24221
|
-
// standard loaders.gl image category payload
|
|
24222
|
-
width,
|
|
24223
|
-
height,
|
|
24224
|
-
data: decodedData,
|
|
24225
|
-
compressed,
|
|
24226
|
-
format,
|
|
24227
|
-
// Additional fields
|
|
24228
|
-
// Add levelSize field.
|
|
24229
|
-
hasAlpha
|
|
24230
|
-
};
|
|
24385
|
+
return null;
|
|
24231
24386
|
}
|
|
24232
|
-
function
|
|
24233
|
-
|
|
24234
|
-
|
|
24235
|
-
|
|
24236
|
-
|
|
24387
|
+
function processPropertyTable2(scenegraph, schema, propertyTable) {
|
|
24388
|
+
if (!propertyTable.class) {
|
|
24389
|
+
return;
|
|
24390
|
+
}
|
|
24391
|
+
const schemaClass = schema.classes?.[propertyTable.class];
|
|
24392
|
+
if (!schemaClass) {
|
|
24393
|
+
throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`);
|
|
24394
|
+
}
|
|
24395
|
+
const numberOfElements = propertyTable.count;
|
|
24396
|
+
for (const propertyName in schemaClass.properties) {
|
|
24397
|
+
const classProperty = schemaClass.properties[propertyName];
|
|
24398
|
+
const propertyTableProperty = propertyTable.properties?.[propertyName];
|
|
24399
|
+
if (propertyTableProperty) {
|
|
24400
|
+
const data = getPropertyDataFromBinarySource2(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty);
|
|
24401
|
+
propertyTableProperty.data = data;
|
|
24237
24402
|
}
|
|
24238
|
-
|
|
24239
|
-
|
|
24240
|
-
|
|
24241
|
-
|
|
24403
|
+
}
|
|
24404
|
+
}
|
|
24405
|
+
function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) {
|
|
24406
|
+
const attributeName = featureTexture.class;
|
|
24407
|
+
for (const propertyName in schemaClass.properties) {
|
|
24408
|
+
const featureTextureProperty = featureTexture?.properties?.[propertyName];
|
|
24409
|
+
if (featureTextureProperty) {
|
|
24410
|
+
const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);
|
|
24411
|
+
featureTextureProperty.data = data;
|
|
24242
24412
|
}
|
|
24243
|
-
return [levels];
|
|
24244
|
-
} finally {
|
|
24245
|
-
ktx2File.close();
|
|
24246
|
-
ktx2File.delete();
|
|
24247
24413
|
}
|
|
24248
24414
|
}
|
|
24249
|
-
function
|
|
24250
|
-
|
|
24251
|
-
const
|
|
24252
|
-
const
|
|
24253
|
-
const
|
|
24254
|
-
|
|
24255
|
-
|
|
24256
|
-
|
|
24257
|
-
|
|
24258
|
-
|
|
24259
|
-
basisFormat,
|
|
24260
|
-
0,
|
|
24261
|
-
-1,
|
|
24262
|
-
-1
|
|
24263
|
-
/* channel1 */
|
|
24264
|
-
)) {
|
|
24265
|
-
throw new Error("Failed to transcode KTX2 image");
|
|
24415
|
+
function getPropertyDataFromBinarySource2(scenegraph, schema, classProperty, numberOfFeatures, featureTableProperty) {
|
|
24416
|
+
let data = [];
|
|
24417
|
+
const bufferView = featureTableProperty.bufferView;
|
|
24418
|
+
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
24419
|
+
const arrayOffsets = getArrayOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures);
|
|
24420
|
+
const stringOffsets = getStringOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures);
|
|
24421
|
+
if (classProperty.type === "STRING" || classProperty.componentType === "STRING") {
|
|
24422
|
+
data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets);
|
|
24423
|
+
} else if (isNumericProperty(classProperty)) {
|
|
24424
|
+
data = getPropertyDataNumeric2(classProperty, numberOfFeatures, dataArray, arrayOffsets);
|
|
24266
24425
|
}
|
|
24267
|
-
return
|
|
24268
|
-
// standard loaders.gl image category payload
|
|
24269
|
-
width,
|
|
24270
|
-
height,
|
|
24271
|
-
data: decodedData,
|
|
24272
|
-
compressed,
|
|
24273
|
-
// Additional fields
|
|
24274
|
-
levelSize: decodedSize,
|
|
24275
|
-
hasAlpha: alphaFlag,
|
|
24276
|
-
format
|
|
24277
|
-
};
|
|
24426
|
+
return data;
|
|
24278
24427
|
}
|
|
24279
|
-
function
|
|
24280
|
-
|
|
24281
|
-
|
|
24282
|
-
|
|
24428
|
+
function getArrayOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
24429
|
+
if (classProperty.type === "ARRAY" && // `componentCount` is a number of fixed-length array elements.
|
|
24430
|
+
// If `componentCount` is NOT defined, it's a VARIABLE-length array
|
|
24431
|
+
typeof classProperty.componentCount === "undefined" && // `arrayOffsetBufferView` is an index of the buffer view containing offsets for variable-length arrays.
|
|
24432
|
+
typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") {
|
|
24433
|
+
return getOffsetsForProperty(
|
|
24434
|
+
scenegraph,
|
|
24435
|
+
propertyTableProperty.arrayOffsetBufferView,
|
|
24436
|
+
propertyTableProperty.offsetType || "UINT32",
|
|
24437
|
+
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
24438
|
+
numberOfElements
|
|
24439
|
+
);
|
|
24283
24440
|
}
|
|
24284
|
-
|
|
24285
|
-
|
|
24441
|
+
return null;
|
|
24442
|
+
}
|
|
24443
|
+
function getStringOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
24444
|
+
if (typeof propertyTableProperty.stringOffsetBufferView !== "undefined") {
|
|
24445
|
+
return getOffsetsForProperty(
|
|
24446
|
+
scenegraph,
|
|
24447
|
+
propertyTableProperty.stringOffsetBufferView,
|
|
24448
|
+
propertyTableProperty.offsetType || "UINT32",
|
|
24449
|
+
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
24450
|
+
numberOfElements
|
|
24451
|
+
);
|
|
24286
24452
|
}
|
|
24287
|
-
|
|
24288
|
-
return OutputFormat[format];
|
|
24453
|
+
return null;
|
|
24289
24454
|
}
|
|
24290
|
-
function
|
|
24291
|
-
const
|
|
24292
|
-
|
|
24293
|
-
|
|
24294
|
-
|
|
24295
|
-
|
|
24296
|
-
|
|
24297
|
-
|
|
24298
|
-
|
|
24299
|
-
|
|
24300
|
-
|
|
24301
|
-
|
|
24302
|
-
|
|
24303
|
-
|
|
24304
|
-
|
|
24305
|
-
|
|
24306
|
-
|
|
24307
|
-
|
|
24455
|
+
function isNumericProperty(schemaProperty) {
|
|
24456
|
+
const types = [
|
|
24457
|
+
"UINT8",
|
|
24458
|
+
"INT16",
|
|
24459
|
+
"UINT16",
|
|
24460
|
+
"INT32",
|
|
24461
|
+
"UINT32",
|
|
24462
|
+
"INT64",
|
|
24463
|
+
"UINT64",
|
|
24464
|
+
"FLOAT32",
|
|
24465
|
+
"FLOAT64"
|
|
24466
|
+
];
|
|
24467
|
+
return types.includes(schemaProperty.type) || typeof schemaProperty.componentType !== "undefined" && types.includes(schemaProperty.componentType);
|
|
24468
|
+
}
|
|
24469
|
+
function getPropertyDataNumeric2(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
24470
|
+
const isArray2 = classProperty.type === "ARRAY";
|
|
24471
|
+
const arrayCount = classProperty.componentCount;
|
|
24472
|
+
const attributeType = "SCALAR";
|
|
24473
|
+
const componentType = classProperty.componentType || classProperty.type;
|
|
24474
|
+
const elementSize = getArrayElementByteSize(attributeType, componentType);
|
|
24475
|
+
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
24476
|
+
const valuesData = convertRawBufferToMetadataArray(valuesDataBytes, attributeType, componentType, elementCount);
|
|
24477
|
+
if (isArray2) {
|
|
24478
|
+
if (arrayOffsets) {
|
|
24479
|
+
return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
|
|
24480
|
+
}
|
|
24481
|
+
if (arrayCount) {
|
|
24482
|
+
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
24483
|
+
}
|
|
24484
|
+
return [];
|
|
24308
24485
|
}
|
|
24309
|
-
return
|
|
24486
|
+
return valuesData;
|
|
24310
24487
|
}
|
|
24311
|
-
|
|
24312
|
-
|
|
24313
|
-
|
|
24314
|
-
|
|
24315
|
-
|
|
24316
|
-
|
|
24317
|
-
|
|
24318
|
-
|
|
24319
|
-
|
|
24320
|
-
worker: true,
|
|
24321
|
-
extensions: ["basis", "ktx2"],
|
|
24322
|
-
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
24323
|
-
tests: ["sB"],
|
|
24324
|
-
binary: true,
|
|
24325
|
-
options: {
|
|
24326
|
-
basis: {
|
|
24327
|
-
format: "auto",
|
|
24328
|
-
libraryPath: "libs/",
|
|
24329
|
-
containerFormat: "auto",
|
|
24330
|
-
module: "transcoder"
|
|
24488
|
+
function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
|
|
24489
|
+
const json = scenegraph.gltf.json;
|
|
24490
|
+
if (!json.meshes) {
|
|
24491
|
+
return [];
|
|
24492
|
+
}
|
|
24493
|
+
const featureTextureTable = [];
|
|
24494
|
+
for (const mesh of json.meshes) {
|
|
24495
|
+
for (const primitive of mesh.primitives) {
|
|
24496
|
+
processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive);
|
|
24331
24497
|
}
|
|
24332
24498
|
}
|
|
24333
|
-
|
|
24334
|
-
|
|
24335
|
-
|
|
24336
|
-
|
|
24337
|
-
|
|
24499
|
+
return featureTextureTable;
|
|
24500
|
+
}
|
|
24501
|
+
function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) {
|
|
24502
|
+
const textureInfoTopLevel = {
|
|
24503
|
+
channels: featureTextureProperty.channels,
|
|
24504
|
+
...featureTextureProperty.texture
|
|
24505
|
+
};
|
|
24506
|
+
const propertyData = getPrimitiveTextureData(scenegraph, textureInfoTopLevel, primitive);
|
|
24507
|
+
if (!propertyData) {
|
|
24508
|
+
return;
|
|
24509
|
+
}
|
|
24510
|
+
primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTextureTable, primitive);
|
|
24511
|
+
}
|
|
24512
|
+
|
|
24513
|
+
// ../../node_modules/@loaders.gl/gltf/dist/lib/utils/version.js
|
|
24514
|
+
var VERSION11 = true ? "4.4.0-alpha.18" : "latest";
|
|
24338
24515
|
|
|
24339
24516
|
// ../../node_modules/@loaders.gl/gltf/dist/lib/parsers/parse-glb.js
|
|
24340
24517
|
var LITTLE_ENDIAN2 = true;
|
|
@@ -25587,8 +25764,7 @@ void main(void) {
|
|
|
25587
25764
|
const strictOptions = options;
|
|
25588
25765
|
const gltfOptions = {
|
|
25589
25766
|
...strictOptions,
|
|
25590
|
-
core: { ...strictOptions?.core, mimeType: image.mimeType }
|
|
25591
|
-
basis: strictOptions.basis || { format: selectSupportedBasisFormat() }
|
|
25767
|
+
core: { ...strictOptions?.core, mimeType: image.mimeType }
|
|
25592
25768
|
};
|
|
25593
25769
|
let parsedImage = await parseFromContext(arrayBuffer, [ImageLoader, BasisLoader], gltfOptions, context);
|
|
25594
25770
|
if (parsedImage && parsedImage[0]) {
|
|
@@ -25612,7 +25788,7 @@ void main(void) {
|
|
|
25612
25788
|
name: "glTF",
|
|
25613
25789
|
id: "gltf",
|
|
25614
25790
|
module: "gltf",
|
|
25615
|
-
version:
|
|
25791
|
+
version: VERSION11,
|
|
25616
25792
|
extensions: ["gltf", "glb"],
|
|
25617
25793
|
mimeTypes: ["model/gltf+json", "model/gltf-binary"],
|
|
25618
25794
|
text: true,
|
|
@@ -26377,7 +26553,7 @@ void main(void) {
|
|
|
26377
26553
|
id: "3d-tiles-subtree",
|
|
26378
26554
|
name: "3D Tiles Subtree",
|
|
26379
26555
|
module: "3d-tiles",
|
|
26380
|
-
version:
|
|
26556
|
+
version: VERSION9,
|
|
26381
26557
|
extensions: ["subtree"],
|
|
26382
26558
|
mimeTypes: ["application/octet-stream"],
|
|
26383
26559
|
tests: ["subtree"],
|
|
@@ -27964,7 +28140,7 @@ void main(void) {
|
|
|
27964
28140
|
id: "3d-tiles",
|
|
27965
28141
|
name: "3D Tiles",
|
|
27966
28142
|
module: "3d-tiles",
|
|
27967
|
-
version:
|
|
28143
|
+
version: VERSION9,
|
|
27968
28144
|
extensions: ["cmpt", "pnts", "b3dm", "i3dm"],
|
|
27969
28145
|
mimeTypes: ["application/octet-stream"],
|
|
27970
28146
|
tests: ["cmpt", "pnts", "b3dm", "i3dm"],
|
|
@@ -29298,7 +29474,7 @@ void main(void) {
|
|
|
29298
29474
|
}
|
|
29299
29475
|
|
|
29300
29476
|
// ../../node_modules/@loaders.gl/terrain/dist/lib/utils/version.js
|
|
29301
|
-
var VERSION12 = true ? "4.4.0-alpha.
|
|
29477
|
+
var VERSION12 = true ? "4.4.0-alpha.18" : "latest";
|
|
29302
29478
|
|
|
29303
29479
|
// ../../node_modules/@loaders.gl/terrain/dist/terrain-loader.js
|
|
29304
29480
|
var TerrainLoader = {
|
|
@@ -31170,7 +31346,7 @@ void main(void) {
|
|
|
31170
31346
|
};
|
|
31171
31347
|
|
|
31172
31348
|
// ../../node_modules/@loaders.gl/mvt/dist/mvt-loader.js
|
|
31173
|
-
var VERSION13 = true ? "4.4.0-alpha.
|
|
31349
|
+
var VERSION13 = true ? "4.4.0-alpha.18" : "latest";
|
|
31174
31350
|
var MVTWorkerLoader = {
|
|
31175
31351
|
...MVTFormat,
|
|
31176
31352
|
dataType: null,
|