@deck.gl/geo-layers 9.0.0-beta.6 → 9.0.0-beta.7
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 +801 -935
- package/dist.min.js +191 -322
- package/package.json +10 -17
package/dist/dist.dev.js
CHANGED
|
@@ -12087,188 +12087,6 @@ in float vTime;
|
|
|
12087
12087
|
parsedMaterial.generatedTextures.push(texture);
|
|
12088
12088
|
}
|
|
12089
12089
|
|
|
12090
|
-
// ../../node_modules/@loaders.gl/textures/dist/lib/utils/version.js
|
|
12091
|
-
var VERSION6 = true ? "4.1.0" : "latest";
|
|
12092
|
-
|
|
12093
|
-
// ../../node_modules/@loaders.gl/textures/dist/lib/parsers/basis-module-loader.js
|
|
12094
|
-
var BASIS_EXTERNAL_LIBRARIES = {
|
|
12095
|
-
TRANSCODER: "basis_transcoder.js",
|
|
12096
|
-
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
12097
|
-
ENCODER: "basis_encoder.js",
|
|
12098
|
-
ENCODER_WASM: "basis_encoder.wasm"
|
|
12099
|
-
};
|
|
12100
|
-
var loadBasisTranscoderPromise;
|
|
12101
|
-
async function loadBasisTranscoderModule(options) {
|
|
12102
|
-
const modules = options.modules || {};
|
|
12103
|
-
if (modules.basis) {
|
|
12104
|
-
return modules.basis;
|
|
12105
|
-
}
|
|
12106
|
-
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
|
|
12107
|
-
return await loadBasisTranscoderPromise;
|
|
12108
|
-
}
|
|
12109
|
-
async function loadBasisTranscoder(options) {
|
|
12110
|
-
let BASIS = null;
|
|
12111
|
-
let wasmBinary = null;
|
|
12112
|
-
[BASIS, wasmBinary] = await Promise.all([await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options), await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)]);
|
|
12113
|
-
BASIS = BASIS || globalThis.BASIS;
|
|
12114
|
-
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
12115
|
-
}
|
|
12116
|
-
function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
|
|
12117
|
-
const options = {};
|
|
12118
|
-
if (wasmBinary) {
|
|
12119
|
-
options.wasmBinary = wasmBinary;
|
|
12120
|
-
}
|
|
12121
|
-
return new Promise((resolve2) => {
|
|
12122
|
-
BasisModule(options).then((module) => {
|
|
12123
|
-
const {
|
|
12124
|
-
BasisFile,
|
|
12125
|
-
initializeBasis
|
|
12126
|
-
} = module;
|
|
12127
|
-
initializeBasis();
|
|
12128
|
-
resolve2({
|
|
12129
|
-
BasisFile
|
|
12130
|
-
});
|
|
12131
|
-
});
|
|
12132
|
-
});
|
|
12133
|
-
}
|
|
12134
|
-
var loadBasisEncoderPromise;
|
|
12135
|
-
async function loadBasisEncoderModule(options) {
|
|
12136
|
-
const modules = options.modules || {};
|
|
12137
|
-
if (modules.basisEncoder) {
|
|
12138
|
-
return modules.basisEncoder;
|
|
12139
|
-
}
|
|
12140
|
-
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
12141
|
-
return await loadBasisEncoderPromise;
|
|
12142
|
-
}
|
|
12143
|
-
async function loadBasisEncoder(options) {
|
|
12144
|
-
let BASIS_ENCODER = null;
|
|
12145
|
-
let wasmBinary = null;
|
|
12146
|
-
[BASIS_ENCODER, wasmBinary] = await Promise.all([await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options), await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)]);
|
|
12147
|
-
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
12148
|
-
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
12149
|
-
}
|
|
12150
|
-
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
12151
|
-
const options = {};
|
|
12152
|
-
if (wasmBinary) {
|
|
12153
|
-
options.wasmBinary = wasmBinary;
|
|
12154
|
-
}
|
|
12155
|
-
return new Promise((resolve2) => {
|
|
12156
|
-
BasisEncoderModule(options).then((module) => {
|
|
12157
|
-
const {
|
|
12158
|
-
BasisFile,
|
|
12159
|
-
KTX2File,
|
|
12160
|
-
initializeBasis,
|
|
12161
|
-
BasisEncoder
|
|
12162
|
-
} = module;
|
|
12163
|
-
initializeBasis();
|
|
12164
|
-
resolve2({
|
|
12165
|
-
BasisFile,
|
|
12166
|
-
KTX2File,
|
|
12167
|
-
BasisEncoder
|
|
12168
|
-
});
|
|
12169
|
-
});
|
|
12170
|
-
});
|
|
12171
|
-
}
|
|
12172
|
-
|
|
12173
|
-
// ../../node_modules/@loaders.gl/textures/dist/lib/gl-extensions.js
|
|
12174
|
-
var GL_EXTENSIONS_CONSTANTS = {
|
|
12175
|
-
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
12176
|
-
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
12177
|
-
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
12178
|
-
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
12179
|
-
COMPRESSED_R11_EAC: 37488,
|
|
12180
|
-
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
12181
|
-
COMPRESSED_RG11_EAC: 37490,
|
|
12182
|
-
COMPRESSED_SIGNED_RG11_EAC: 37491,
|
|
12183
|
-
COMPRESSED_RGB8_ETC2: 37492,
|
|
12184
|
-
COMPRESSED_RGBA8_ETC2_EAC: 37493,
|
|
12185
|
-
COMPRESSED_SRGB8_ETC2: 37494,
|
|
12186
|
-
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
12187
|
-
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
12188
|
-
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
12189
|
-
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
12190
|
-
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
12191
|
-
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
12192
|
-
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
12193
|
-
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
12194
|
-
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
12195
|
-
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
12196
|
-
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
12197
|
-
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
12198
|
-
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
12199
|
-
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
12200
|
-
COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
|
|
12201
|
-
COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
|
|
12202
|
-
COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
|
|
12203
|
-
COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
|
|
12204
|
-
COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
|
|
12205
|
-
COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
|
|
12206
|
-
COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
|
|
12207
|
-
COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
|
|
12208
|
-
COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
|
|
12209
|
-
COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
|
|
12210
|
-
COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
|
|
12211
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
|
|
12212
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
|
|
12213
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
|
|
12214
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
|
|
12215
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
|
|
12216
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
|
|
12217
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
|
|
12218
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
|
|
12219
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
|
|
12220
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
|
|
12221
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
|
|
12222
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
12223
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
12224
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
12225
|
-
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
12226
|
-
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
12227
|
-
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
12228
|
-
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
12229
|
-
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
12230
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
12231
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
12232
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
|
|
12233
|
-
};
|
|
12234
|
-
|
|
12235
|
-
// ../../node_modules/@loaders.gl/textures/dist/lib/utils/texture-formats.js
|
|
12236
|
-
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
12237
|
-
var WEBGL_EXTENSIONS = {
|
|
12238
|
-
WEBGL_compressed_texture_s3tc: "dxt",
|
|
12239
|
-
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
12240
|
-
WEBGL_compressed_texture_etc1: "etc1",
|
|
12241
|
-
WEBGL_compressed_texture_etc: "etc2",
|
|
12242
|
-
WEBGL_compressed_texture_pvrtc: "pvrtc",
|
|
12243
|
-
WEBGL_compressed_texture_atc: "atc",
|
|
12244
|
-
WEBGL_compressed_texture_astc: "astc",
|
|
12245
|
-
EXT_texture_compression_rgtc: "rgtc"
|
|
12246
|
-
};
|
|
12247
|
-
var formats = null;
|
|
12248
|
-
function getSupportedGPUTextureFormats(gl) {
|
|
12249
|
-
if (!formats) {
|
|
12250
|
-
gl = gl || getWebGLContext() || void 0;
|
|
12251
|
-
formats = /* @__PURE__ */ new Set();
|
|
12252
|
-
for (const prefix of BROWSER_PREFIXES) {
|
|
12253
|
-
for (const extension in WEBGL_EXTENSIONS) {
|
|
12254
|
-
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
12255
|
-
const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
|
|
12256
|
-
formats.add(gpuTextureFormat);
|
|
12257
|
-
}
|
|
12258
|
-
}
|
|
12259
|
-
}
|
|
12260
|
-
}
|
|
12261
|
-
return formats;
|
|
12262
|
-
}
|
|
12263
|
-
function getWebGLContext() {
|
|
12264
|
-
try {
|
|
12265
|
-
const canvas = document.createElement("canvas");
|
|
12266
|
-
return canvas.getContext("webgl");
|
|
12267
|
-
} catch (error) {
|
|
12268
|
-
return null;
|
|
12269
|
-
}
|
|
12270
|
-
}
|
|
12271
|
-
|
|
12272
12090
|
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
12273
12091
|
var t = new Uint8Array([0]);
|
|
12274
12092
|
var n;
|
|
@@ -12297,424 +12115,113 @@ in float vTime;
|
|
|
12297
12115
|
t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
|
|
12298
12116
|
}(f || (f = {}));
|
|
12299
12117
|
|
|
12300
|
-
// ../../node_modules/@
|
|
12301
|
-
var
|
|
12302
|
-
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
|
|
12306
|
-
|
|
12118
|
+
// ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/lights/lights-glsl.js
|
|
12119
|
+
var lightingShader = `#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
12120
|
+
struct AmbientLight {
|
|
12121
|
+
vec3 color;
|
|
12122
|
+
};
|
|
12123
|
+
struct PointLight {
|
|
12124
|
+
vec3 color;
|
|
12125
|
+
vec3 position;
|
|
12126
|
+
vec3 attenuation;
|
|
12127
|
+
};
|
|
12128
|
+
struct DirectionalLight {
|
|
12129
|
+
vec3 color;
|
|
12130
|
+
vec3 direction;
|
|
12131
|
+
};
|
|
12132
|
+
uniform AmbientLight lighting_uAmbientLight;
|
|
12133
|
+
uniform PointLight lighting_uPointLight[MAX_LIGHTS];
|
|
12134
|
+
uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];
|
|
12135
|
+
uniform int lighting_uPointLightCount;
|
|
12136
|
+
uniform int lighting_uDirectionalLightCount;
|
|
12137
|
+
uniform bool lighting_uEnabled;
|
|
12138
|
+
float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
12139
|
+
return pointLight.attenuation.x
|
|
12140
|
+
+ pointLight.attenuation.y * distance
|
|
12141
|
+
+ pointLight.attenuation.z * distance * distance;
|
|
12142
|
+
}
|
|
12143
|
+
#endif
|
|
12144
|
+
`;
|
|
12307
12145
|
|
|
12308
|
-
// ../../node_modules/@
|
|
12309
|
-
var
|
|
12310
|
-
|
|
12311
|
-
basisFormat: 0,
|
|
12312
|
-
compressed: true,
|
|
12313
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
12314
|
-
},
|
|
12315
|
-
etc2: {
|
|
12316
|
-
basisFormat: 1,
|
|
12317
|
-
compressed: true
|
|
12318
|
-
},
|
|
12319
|
-
bc1: {
|
|
12320
|
-
basisFormat: 2,
|
|
12321
|
-
compressed: true,
|
|
12322
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
|
|
12323
|
-
},
|
|
12324
|
-
bc3: {
|
|
12325
|
-
basisFormat: 3,
|
|
12326
|
-
compressed: true,
|
|
12327
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
12328
|
-
},
|
|
12329
|
-
bc4: {
|
|
12330
|
-
basisFormat: 4,
|
|
12331
|
-
compressed: true
|
|
12332
|
-
},
|
|
12333
|
-
bc5: {
|
|
12334
|
-
basisFormat: 5,
|
|
12335
|
-
compressed: true
|
|
12336
|
-
},
|
|
12337
|
-
"bc7-m6-opaque-only": {
|
|
12338
|
-
basisFormat: 6,
|
|
12339
|
-
compressed: true
|
|
12340
|
-
},
|
|
12341
|
-
"bc7-m5": {
|
|
12342
|
-
basisFormat: 7,
|
|
12343
|
-
compressed: true
|
|
12344
|
-
},
|
|
12345
|
-
"pvrtc1-4-rgb": {
|
|
12346
|
-
basisFormat: 8,
|
|
12347
|
-
compressed: true,
|
|
12348
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
|
12349
|
-
},
|
|
12350
|
-
"pvrtc1-4-rgba": {
|
|
12351
|
-
basisFormat: 9,
|
|
12352
|
-
compressed: true,
|
|
12353
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
|
12354
|
-
},
|
|
12355
|
-
"astc-4x4": {
|
|
12356
|
-
basisFormat: 10,
|
|
12357
|
-
compressed: true,
|
|
12358
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
12359
|
-
},
|
|
12360
|
-
"atc-rgb": {
|
|
12361
|
-
basisFormat: 11,
|
|
12362
|
-
compressed: true
|
|
12363
|
-
},
|
|
12364
|
-
"atc-rgba-interpolated-alpha": {
|
|
12365
|
-
basisFormat: 12,
|
|
12366
|
-
compressed: true
|
|
12367
|
-
},
|
|
12368
|
-
rgba32: {
|
|
12369
|
-
basisFormat: 13,
|
|
12370
|
-
compressed: false
|
|
12371
|
-
},
|
|
12372
|
-
rgb565: {
|
|
12373
|
-
basisFormat: 14,
|
|
12374
|
-
compressed: false
|
|
12375
|
-
},
|
|
12376
|
-
bgr565: {
|
|
12377
|
-
basisFormat: 15,
|
|
12378
|
-
compressed: false
|
|
12379
|
-
},
|
|
12380
|
-
rgba4444: {
|
|
12381
|
-
basisFormat: 16,
|
|
12382
|
-
compressed: false
|
|
12383
|
-
}
|
|
12146
|
+
// ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/lights/lights.js
|
|
12147
|
+
var INITIAL_MODULE_OPTIONS = {
|
|
12148
|
+
lightSources: {}
|
|
12384
12149
|
};
|
|
12385
|
-
|
|
12386
|
-
|
|
12387
|
-
|
|
12388
|
-
const fileConstructors = await loadBasisEncoderModule(options);
|
|
12389
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
12390
|
-
}
|
|
12391
|
-
const {
|
|
12392
|
-
BasisFile
|
|
12393
|
-
} = await loadBasisTranscoderModule(options);
|
|
12394
|
-
return parseBasisFile(BasisFile, data, options);
|
|
12395
|
-
}
|
|
12396
|
-
switch (options.basis.module) {
|
|
12397
|
-
case "encoder":
|
|
12398
|
-
const fileConstructors = await loadBasisEncoderModule(options);
|
|
12399
|
-
switch (options.basis.containerFormat) {
|
|
12400
|
-
case "ktx2":
|
|
12401
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
12402
|
-
case "basis":
|
|
12403
|
-
default:
|
|
12404
|
-
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
12405
|
-
}
|
|
12406
|
-
case "transcoder":
|
|
12407
|
-
default:
|
|
12408
|
-
const {
|
|
12409
|
-
BasisFile
|
|
12410
|
-
} = await loadBasisTranscoderModule(options);
|
|
12411
|
-
return parseBasisFile(BasisFile, data, options);
|
|
12412
|
-
}
|
|
12413
|
-
}
|
|
12414
|
-
function parseBasisFile(BasisFile, data, options) {
|
|
12415
|
-
const basisFile = new BasisFile(new Uint8Array(data));
|
|
12416
|
-
try {
|
|
12417
|
-
if (!basisFile.startTranscoding()) {
|
|
12418
|
-
throw new Error("Failed to start basis transcoding");
|
|
12419
|
-
}
|
|
12420
|
-
const imageCount = basisFile.getNumImages();
|
|
12421
|
-
const images = [];
|
|
12422
|
-
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
12423
|
-
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
12424
|
-
const levels = [];
|
|
12425
|
-
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
12426
|
-
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
12427
|
-
}
|
|
12428
|
-
images.push(levels);
|
|
12429
|
-
}
|
|
12430
|
-
return images;
|
|
12431
|
-
} finally {
|
|
12432
|
-
basisFile.close();
|
|
12433
|
-
basisFile.delete();
|
|
12434
|
-
}
|
|
12150
|
+
function convertColor(colorDef = {}) {
|
|
12151
|
+
const { color = [0, 0, 0], intensity = 1 } = colorDef;
|
|
12152
|
+
return color.map((component) => component * intensity / 255);
|
|
12435
12153
|
}
|
|
12436
|
-
function
|
|
12437
|
-
const
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
format,
|
|
12443
|
-
basisFormat
|
|
12444
|
-
} = getBasisOptions(options, hasAlpha);
|
|
12445
|
-
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
12446
|
-
const decodedData = new Uint8Array(decodedSize);
|
|
12447
|
-
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
12448
|
-
throw new Error("failed to start Basis transcoding");
|
|
12154
|
+
function getLightSourceUniforms({ ambientLight, pointLights = [], directionalLights = [] }) {
|
|
12155
|
+
const lightSourceUniforms = {};
|
|
12156
|
+
if (ambientLight) {
|
|
12157
|
+
lightSourceUniforms["lighting_uAmbientLight.color"] = convertColor(ambientLight);
|
|
12158
|
+
} else {
|
|
12159
|
+
lightSourceUniforms["lighting_uAmbientLight.color"] = [0, 0, 0];
|
|
12449
12160
|
}
|
|
12450
|
-
|
|
12451
|
-
|
|
12452
|
-
|
|
12453
|
-
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
12161
|
+
pointLights.forEach((pointLight, index) => {
|
|
12162
|
+
lightSourceUniforms[`lighting_uPointLight[${index}].color`] = convertColor(pointLight);
|
|
12163
|
+
lightSourceUniforms[`lighting_uPointLight[${index}].position`] = pointLight.position;
|
|
12164
|
+
lightSourceUniforms[`lighting_uPointLight[${index}].attenuation`] = pointLight.attenuation || [
|
|
12165
|
+
1,
|
|
12166
|
+
0,
|
|
12167
|
+
0
|
|
12168
|
+
];
|
|
12169
|
+
});
|
|
12170
|
+
lightSourceUniforms.lighting_uPointLightCount = pointLights.length;
|
|
12171
|
+
directionalLights.forEach((directionalLight, index) => {
|
|
12172
|
+
lightSourceUniforms[`lighting_uDirectionalLight[${index}].color`] = convertColor(directionalLight);
|
|
12173
|
+
lightSourceUniforms[`lighting_uDirectionalLight[${index}].direction`] = directionalLight.direction;
|
|
12174
|
+
});
|
|
12175
|
+
lightSourceUniforms.lighting_uDirectionalLightCount = directionalLights.length;
|
|
12176
|
+
return lightSourceUniforms;
|
|
12458
12177
|
}
|
|
12459
|
-
function
|
|
12460
|
-
|
|
12461
|
-
|
|
12462
|
-
|
|
12463
|
-
|
|
12464
|
-
|
|
12465
|
-
const levelsCount = ktx2File.getLevels();
|
|
12466
|
-
const levels = [];
|
|
12467
|
-
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
12468
|
-
levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
|
|
12469
|
-
break;
|
|
12178
|
+
function getUniforms(opts = INITIAL_MODULE_OPTIONS) {
|
|
12179
|
+
if ("lightSources" in opts) {
|
|
12180
|
+
const { ambientLight, pointLights, directionalLights } = opts.lightSources || {};
|
|
12181
|
+
const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0;
|
|
12182
|
+
if (!hasLights) {
|
|
12183
|
+
return { lighting_uEnabled: false };
|
|
12470
12184
|
}
|
|
12471
|
-
return
|
|
12472
|
-
|
|
12473
|
-
|
|
12474
|
-
ktx2File.delete();
|
|
12475
|
-
}
|
|
12476
|
-
}
|
|
12477
|
-
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
12478
|
-
const {
|
|
12479
|
-
alphaFlag,
|
|
12480
|
-
height,
|
|
12481
|
-
width
|
|
12482
|
-
} = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
12483
|
-
const {
|
|
12484
|
-
compressed,
|
|
12485
|
-
format,
|
|
12486
|
-
basisFormat
|
|
12487
|
-
} = getBasisOptions(options, alphaFlag);
|
|
12488
|
-
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
12489
|
-
const decodedData = new Uint8Array(decodedSize);
|
|
12490
|
-
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
|
|
12491
|
-
throw new Error("Failed to transcode KTX2 image");
|
|
12492
|
-
}
|
|
12493
|
-
return {
|
|
12494
|
-
width,
|
|
12495
|
-
height,
|
|
12496
|
-
data: decodedData,
|
|
12497
|
-
compressed,
|
|
12498
|
-
levelSize: decodedSize,
|
|
12499
|
-
hasAlpha: alphaFlag,
|
|
12500
|
-
format
|
|
12501
|
-
};
|
|
12502
|
-
}
|
|
12503
|
-
function getBasisOptions(options, hasAlpha) {
|
|
12504
|
-
let format = options && options.basis && options.basis.format;
|
|
12505
|
-
if (format === "auto") {
|
|
12506
|
-
format = selectSupportedBasisFormat();
|
|
12507
|
-
}
|
|
12508
|
-
if (typeof format === "object") {
|
|
12509
|
-
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
12185
|
+
return Object.assign({}, getLightSourceUniforms({ ambientLight, pointLights, directionalLights }), {
|
|
12186
|
+
lighting_uEnabled: true
|
|
12187
|
+
});
|
|
12510
12188
|
}
|
|
12511
|
-
|
|
12512
|
-
|
|
12513
|
-
|
|
12514
|
-
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12524
|
-
|
|
12525
|
-
|
|
12526
|
-
|
|
12527
|
-
};
|
|
12528
|
-
} else if (supportedFormats.has("etc1")) {
|
|
12529
|
-
return "etc1";
|
|
12530
|
-
} else if (supportedFormats.has("etc2")) {
|
|
12531
|
-
return "etc2";
|
|
12189
|
+
if ("lights" in opts) {
|
|
12190
|
+
const lightSources = { pointLights: [], directionalLights: [] };
|
|
12191
|
+
for (const light of opts.lights || []) {
|
|
12192
|
+
switch (light.type) {
|
|
12193
|
+
case "ambient":
|
|
12194
|
+
lightSources.ambientLight = light;
|
|
12195
|
+
break;
|
|
12196
|
+
case "directional":
|
|
12197
|
+
lightSources.directionalLights?.push(light);
|
|
12198
|
+
break;
|
|
12199
|
+
case "point":
|
|
12200
|
+
lightSources.pointLights?.push(light);
|
|
12201
|
+
break;
|
|
12202
|
+
default:
|
|
12203
|
+
}
|
|
12204
|
+
}
|
|
12205
|
+
return getUniforms({ lightSources });
|
|
12532
12206
|
}
|
|
12533
|
-
return
|
|
12207
|
+
return {};
|
|
12534
12208
|
}
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
worker: true,
|
|
12543
|
-
extensions: ["basis", "ktx2"],
|
|
12544
|
-
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
12545
|
-
tests: ["sB"],
|
|
12546
|
-
binary: true,
|
|
12547
|
-
options: {
|
|
12548
|
-
basis: {
|
|
12549
|
-
format: "auto",
|
|
12550
|
-
libraryPath: "libs/",
|
|
12551
|
-
containerFormat: "auto",
|
|
12552
|
-
module: "transcoder"
|
|
12553
|
-
}
|
|
12554
|
-
}
|
|
12555
|
-
};
|
|
12556
|
-
var BasisLoader = {
|
|
12557
|
-
...BasisWorkerLoader,
|
|
12558
|
-
parse: parseBasis
|
|
12559
|
-
};
|
|
12560
|
-
|
|
12561
|
-
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
12562
|
-
function isElectron(mockUserAgent) {
|
|
12563
|
-
if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
|
|
12564
|
-
return true;
|
|
12565
|
-
}
|
|
12566
|
-
if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
|
|
12567
|
-
return true;
|
|
12568
|
-
}
|
|
12569
|
-
const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
|
|
12570
|
-
const userAgent = mockUserAgent || realUserAgent;
|
|
12571
|
-
if (userAgent && userAgent.indexOf("Electron") >= 0) {
|
|
12572
|
-
return true;
|
|
12573
|
-
}
|
|
12574
|
-
return false;
|
|
12575
|
-
}
|
|
12576
|
-
|
|
12577
|
-
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
12578
|
-
function isBrowser3() {
|
|
12579
|
-
const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
|
|
12580
|
-
return !isNode || isElectron();
|
|
12581
|
-
}
|
|
12582
|
-
|
|
12583
|
-
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
12584
|
-
var self_3 = globalThis.self || globalThis.window || globalThis.global;
|
|
12585
|
-
var window_3 = globalThis.window || globalThis.self || globalThis.global;
|
|
12586
|
-
var document_3 = globalThis.document || {};
|
|
12587
|
-
var process_ = globalThis.process || {};
|
|
12588
|
-
var console_ = globalThis.console;
|
|
12589
|
-
var navigator_ = globalThis.navigator || {};
|
|
12590
|
-
|
|
12591
|
-
// ../../node_modules/@probe.gl/env/dist/utils/globals.js
|
|
12592
|
-
var VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
|
|
12593
|
-
var isBrowser4 = isBrowser3();
|
|
12594
|
-
|
|
12595
|
-
// ../../node_modules/@luma.gl/shadertools/dist/lib/glsl-utils/highlight.js
|
|
12596
|
-
var glsl = (x2) => `${x2}`;
|
|
12597
|
-
|
|
12598
|
-
// ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/lights/lights-glsl.js
|
|
12599
|
-
var lightingShader = glsl`\
|
|
12600
|
-
#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
12601
|
-
|
|
12602
|
-
struct AmbientLight {
|
|
12603
|
-
vec3 color;
|
|
12604
|
-
};
|
|
12605
|
-
|
|
12606
|
-
struct PointLight {
|
|
12607
|
-
vec3 color;
|
|
12608
|
-
vec3 position;
|
|
12609
|
-
|
|
12610
|
-
// Constant-Linear-Exponential
|
|
12611
|
-
vec3 attenuation;
|
|
12612
|
-
};
|
|
12613
|
-
|
|
12614
|
-
struct DirectionalLight {
|
|
12615
|
-
vec3 color;
|
|
12616
|
-
vec3 direction;
|
|
12617
|
-
};
|
|
12618
|
-
|
|
12619
|
-
uniform AmbientLight lighting_uAmbientLight;
|
|
12620
|
-
uniform PointLight lighting_uPointLight[MAX_LIGHTS];
|
|
12621
|
-
uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];
|
|
12622
|
-
uniform int lighting_uPointLightCount;
|
|
12623
|
-
uniform int lighting_uDirectionalLightCount;
|
|
12624
|
-
|
|
12625
|
-
uniform bool lighting_uEnabled;
|
|
12626
|
-
|
|
12627
|
-
float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
12628
|
-
return pointLight.attenuation.x
|
|
12629
|
-
+ pointLight.attenuation.y * distance
|
|
12630
|
-
+ pointLight.attenuation.z * distance * distance;
|
|
12631
|
-
}
|
|
12632
|
-
|
|
12633
|
-
#endif
|
|
12634
|
-
`;
|
|
12635
|
-
|
|
12636
|
-
// ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/lights/lights.js
|
|
12637
|
-
var INITIAL_MODULE_OPTIONS = {
|
|
12638
|
-
lightSources: {}
|
|
12639
|
-
};
|
|
12640
|
-
function convertColor(colorDef = {}) {
|
|
12641
|
-
const { color = [0, 0, 0], intensity = 1 } = colorDef;
|
|
12642
|
-
return color.map((component) => component * intensity / 255);
|
|
12643
|
-
}
|
|
12644
|
-
function getLightSourceUniforms({ ambientLight, pointLights = [], directionalLights = [] }) {
|
|
12645
|
-
const lightSourceUniforms = {};
|
|
12646
|
-
if (ambientLight) {
|
|
12647
|
-
lightSourceUniforms["lighting_uAmbientLight.color"] = convertColor(ambientLight);
|
|
12648
|
-
} else {
|
|
12649
|
-
lightSourceUniforms["lighting_uAmbientLight.color"] = [0, 0, 0];
|
|
12650
|
-
}
|
|
12651
|
-
pointLights.forEach((pointLight, index) => {
|
|
12652
|
-
lightSourceUniforms[`lighting_uPointLight[${index}].color`] = convertColor(pointLight);
|
|
12653
|
-
lightSourceUniforms[`lighting_uPointLight[${index}].position`] = pointLight.position;
|
|
12654
|
-
lightSourceUniforms[`lighting_uPointLight[${index}].attenuation`] = pointLight.attenuation || [
|
|
12655
|
-
1,
|
|
12656
|
-
0,
|
|
12657
|
-
0
|
|
12658
|
-
];
|
|
12659
|
-
});
|
|
12660
|
-
lightSourceUniforms.lighting_uPointLightCount = pointLights.length;
|
|
12661
|
-
directionalLights.forEach((directionalLight, index) => {
|
|
12662
|
-
lightSourceUniforms[`lighting_uDirectionalLight[${index}].color`] = convertColor(directionalLight);
|
|
12663
|
-
lightSourceUniforms[`lighting_uDirectionalLight[${index}].direction`] = directionalLight.direction;
|
|
12664
|
-
});
|
|
12665
|
-
lightSourceUniforms.lighting_uDirectionalLightCount = directionalLights.length;
|
|
12666
|
-
return lightSourceUniforms;
|
|
12667
|
-
}
|
|
12668
|
-
function getUniforms(opts = INITIAL_MODULE_OPTIONS) {
|
|
12669
|
-
if ("lightSources" in opts) {
|
|
12670
|
-
const { ambientLight, pointLights, directionalLights } = opts.lightSources || {};
|
|
12671
|
-
const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0;
|
|
12672
|
-
if (!hasLights) {
|
|
12673
|
-
return { lighting_uEnabled: false };
|
|
12674
|
-
}
|
|
12675
|
-
return Object.assign({}, getLightSourceUniforms({ ambientLight, pointLights, directionalLights }), {
|
|
12676
|
-
lighting_uEnabled: true
|
|
12677
|
-
});
|
|
12678
|
-
}
|
|
12679
|
-
if ("lights" in opts) {
|
|
12680
|
-
const lightSources = { pointLights: [], directionalLights: [] };
|
|
12681
|
-
for (const light of opts.lights || []) {
|
|
12682
|
-
switch (light.type) {
|
|
12683
|
-
case "ambient":
|
|
12684
|
-
lightSources.ambientLight = light;
|
|
12685
|
-
break;
|
|
12686
|
-
case "directional":
|
|
12687
|
-
lightSources.directionalLights?.push(light);
|
|
12688
|
-
break;
|
|
12689
|
-
case "point":
|
|
12690
|
-
lightSources.pointLights?.push(light);
|
|
12691
|
-
break;
|
|
12692
|
-
default:
|
|
12693
|
-
}
|
|
12694
|
-
}
|
|
12695
|
-
return getUniforms({ lightSources });
|
|
12696
|
-
}
|
|
12697
|
-
return {};
|
|
12698
|
-
}
|
|
12699
|
-
var lights = {
|
|
12700
|
-
name: "lights",
|
|
12701
|
-
vs: lightingShader,
|
|
12702
|
-
fs: lightingShader,
|
|
12703
|
-
getUniforms,
|
|
12704
|
-
defines: {
|
|
12705
|
-
MAX_LIGHTS: 3
|
|
12209
|
+
var lights = {
|
|
12210
|
+
name: "lights",
|
|
12211
|
+
vs: lightingShader,
|
|
12212
|
+
fs: lightingShader,
|
|
12213
|
+
getUniforms,
|
|
12214
|
+
defines: {
|
|
12215
|
+
MAX_LIGHTS: 3
|
|
12706
12216
|
}
|
|
12707
12217
|
};
|
|
12708
12218
|
|
|
12709
12219
|
// ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js
|
|
12710
|
-
var vs =
|
|
12711
|
-
uniform mat4 u_MVPMatrix;
|
|
12220
|
+
var vs = `uniform mat4 u_MVPMatrix;
|
|
12712
12221
|
uniform mat4 u_ModelMatrix;
|
|
12713
12222
|
uniform mat4 u_NormalMatrix;
|
|
12714
|
-
|
|
12715
12223
|
out vec3 pbr_vPosition;
|
|
12716
12224
|
out vec2 pbr_vUV;
|
|
12717
|
-
|
|
12718
12225
|
#ifdef HAS_NORMALS
|
|
12719
12226
|
# ifdef HAS_TANGENTS
|
|
12720
12227
|
out mat3 pbr_vTBN;
|
|
@@ -12722,52 +12229,43 @@ out mat3 pbr_vTBN;
|
|
|
12722
12229
|
out vec3 pbr_vNormal;
|
|
12723
12230
|
# endif
|
|
12724
12231
|
#endif
|
|
12725
|
-
|
|
12726
12232
|
void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
|
|
12727
12233
|
{
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12234
|
+
vec4 pos = u_ModelMatrix * position;
|
|
12235
|
+
pbr_vPosition = vec3(pos.xyz) / pos.w;
|
|
12731
12236
|
#ifdef HAS_NORMALS
|
|
12732
12237
|
#ifdef HAS_TANGENTS
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
#else
|
|
12738
|
-
|
|
12238
|
+
vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));
|
|
12239
|
+
vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));
|
|
12240
|
+
vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
|
|
12241
|
+
pbr_vTBN = mat3(tangentW, bitangentW, normalW);
|
|
12242
|
+
#else
|
|
12243
|
+
pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));
|
|
12739
12244
|
#endif
|
|
12740
12245
|
#endif
|
|
12741
|
-
|
|
12742
12246
|
#ifdef HAS_UV
|
|
12743
|
-
|
|
12247
|
+
pbr_vUV = uv;
|
|
12744
12248
|
#else
|
|
12745
|
-
|
|
12249
|
+
pbr_vUV = vec2(0.,0.);
|
|
12746
12250
|
#endif
|
|
12747
12251
|
}
|
|
12748
12252
|
`;
|
|
12749
12253
|
|
|
12750
12254
|
// ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js
|
|
12751
|
-
var fs =
|
|
12752
|
-
#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
|
|
12255
|
+
var fs = `#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
|
|
12753
12256
|
# error PBR fragment shader: Texture LOD is not available
|
|
12754
12257
|
#endif
|
|
12755
|
-
|
|
12756
12258
|
#if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)
|
|
12757
12259
|
# error PBR fragment shader: Derivatives are not available
|
|
12758
12260
|
#endif
|
|
12759
|
-
|
|
12760
12261
|
precision highp float;
|
|
12761
|
-
|
|
12762
12262
|
uniform bool pbr_uUnlit;
|
|
12763
|
-
|
|
12764
12263
|
#ifdef USE_IBL
|
|
12765
12264
|
uniform samplerCube u_DiffuseEnvSampler;
|
|
12766
12265
|
uniform samplerCube u_SpecularEnvSampler;
|
|
12767
12266
|
uniform sampler2D u_brdfLUT;
|
|
12768
12267
|
uniform vec2 u_ScaleIBLAmbient;
|
|
12769
12268
|
#endif
|
|
12770
|
-
|
|
12771
12269
|
#ifdef HAS_BASECOLORMAP
|
|
12772
12270
|
uniform sampler2D u_BaseColorSampler;
|
|
12773
12271
|
#endif
|
|
@@ -12786,26 +12284,18 @@ uniform sampler2D u_MetallicRoughnessSampler;
|
|
|
12786
12284
|
uniform sampler2D u_OcclusionSampler;
|
|
12787
12285
|
uniform float u_OcclusionStrength;
|
|
12788
12286
|
#endif
|
|
12789
|
-
|
|
12790
12287
|
#ifdef ALPHA_CUTOFF
|
|
12791
12288
|
uniform float u_AlphaCutoff;
|
|
12792
12289
|
#endif
|
|
12793
|
-
|
|
12794
12290
|
uniform vec2 u_MetallicRoughnessValues;
|
|
12795
12291
|
uniform vec4 u_BaseColorFactor;
|
|
12796
|
-
|
|
12797
12292
|
uniform vec3 u_Camera;
|
|
12798
|
-
|
|
12799
|
-
// debugging flags used for shader output of intermediate PBR variables
|
|
12800
12293
|
#ifdef PBR_DEBUG
|
|
12801
12294
|
uniform vec4 u_ScaleDiffBaseMR;
|
|
12802
12295
|
uniform vec4 u_ScaleFGDSpec;
|
|
12803
12296
|
#endif
|
|
12804
|
-
|
|
12805
12297
|
in vec3 pbr_vPosition;
|
|
12806
|
-
|
|
12807
12298
|
in vec2 pbr_vUV;
|
|
12808
|
-
|
|
12809
12299
|
#ifdef HAS_NORMALS
|
|
12810
12300
|
#ifdef HAS_TANGENTS
|
|
12811
12301
|
in mat3 pbr_vTBN;
|
|
@@ -12813,330 +12303,229 @@ in mat3 pbr_vTBN;
|
|
|
12813
12303
|
in vec3 pbr_vNormal;
|
|
12814
12304
|
#endif
|
|
12815
12305
|
#endif
|
|
12816
|
-
|
|
12817
|
-
// Encapsulate the various inputs used by the various functions in the shading equation
|
|
12818
|
-
// We store values in this struct to simplify the integration of alternative implementations
|
|
12819
|
-
// of the shading terms, outlined in the Readme.MD Appendix.
|
|
12820
12306
|
struct PBRInfo
|
|
12821
12307
|
{
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12308
|
+
float NdotL;
|
|
12309
|
+
float NdotV;
|
|
12310
|
+
float NdotH;
|
|
12311
|
+
float LdotH;
|
|
12312
|
+
float VdotH;
|
|
12313
|
+
float perceptualRoughness;
|
|
12314
|
+
float metalness;
|
|
12315
|
+
vec3 reflectance0;
|
|
12316
|
+
vec3 reflectance90;
|
|
12317
|
+
float alphaRoughness;
|
|
12318
|
+
vec3 diffuseColor;
|
|
12319
|
+
vec3 specularColor;
|
|
12320
|
+
vec3 n;
|
|
12321
|
+
vec3 v;
|
|
12836
12322
|
};
|
|
12837
|
-
|
|
12838
12323
|
const float M_PI = 3.141592653589793;
|
|
12839
12324
|
const float c_MinRoughness = 0.04;
|
|
12840
|
-
|
|
12841
12325
|
vec4 SRGBtoLINEAR(vec4 srgbIn)
|
|
12842
12326
|
{
|
|
12843
12327
|
#ifdef MANUAL_SRGB
|
|
12844
12328
|
#ifdef SRGB_FAST_APPROXIMATION
|
|
12845
|
-
|
|
12846
|
-
#else
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
#endif
|
|
12850
|
-
|
|
12851
|
-
#else
|
|
12852
|
-
|
|
12853
|
-
#endif
|
|
12329
|
+
vec3 linOut = pow(srgbIn.xyz,vec3(2.2));
|
|
12330
|
+
#else
|
|
12331
|
+
vec3 bLess = step(vec3(0.04045),srgbIn.xyz);
|
|
12332
|
+
vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
|
|
12333
|
+
#endif
|
|
12334
|
+
return vec4(linOut,srgbIn.w);;
|
|
12335
|
+
#else
|
|
12336
|
+
return srgbIn;
|
|
12337
|
+
#endif
|
|
12854
12338
|
}
|
|
12855
|
-
|
|
12856
|
-
// Find the normal for this fragment, pulling either from a predefined normal map
|
|
12857
|
-
// or from the interpolated mesh normal and tangent attributes.
|
|
12858
12339
|
vec3 getNormal()
|
|
12859
12340
|
{
|
|
12860
|
-
// Retrieve the tangent space matrix
|
|
12861
12341
|
#ifndef HAS_TANGENTS
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12342
|
+
vec3 pos_dx = dFdx(pbr_vPosition);
|
|
12343
|
+
vec3 pos_dy = dFdy(pbr_vPosition);
|
|
12344
|
+
vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));
|
|
12345
|
+
vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));
|
|
12346
|
+
vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
|
|
12868
12347
|
#ifdef HAS_NORMALS
|
|
12869
|
-
|
|
12348
|
+
vec3 ng = normalize(pbr_vNormal);
|
|
12870
12349
|
#else
|
|
12871
|
-
|
|
12350
|
+
vec3 ng = cross(pos_dx, pos_dy);
|
|
12872
12351
|
#endif
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
mat3 tbn = pbr_vTBN;
|
|
12352
|
+
t = normalize(t - ng * dot(ng, t));
|
|
12353
|
+
vec3 b = normalize(cross(ng, t));
|
|
12354
|
+
mat3 tbn = mat3(t, b, ng);
|
|
12355
|
+
#else
|
|
12356
|
+
mat3 tbn = pbr_vTBN;
|
|
12879
12357
|
#endif
|
|
12880
|
-
|
|
12881
12358
|
#ifdef HAS_NORMALMAP
|
|
12882
|
-
|
|
12883
|
-
|
|
12359
|
+
vec3 n = texture(u_NormalSampler, pbr_vUV).rgb;
|
|
12360
|
+
n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));
|
|
12884
12361
|
#else
|
|
12885
|
-
|
|
12886
|
-
vec3 n = normalize(tbn[2].xyz);
|
|
12362
|
+
vec3 n = normalize(tbn[2].xyz);
|
|
12887
12363
|
#endif
|
|
12888
|
-
|
|
12889
|
-
return n;
|
|
12364
|
+
return n;
|
|
12890
12365
|
}
|
|
12891
|
-
|
|
12892
|
-
// Calculation of the lighting contribution from an optional Image Based Light source.
|
|
12893
|
-
// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
|
|
12894
|
-
// See our README.md on Environment Maps [3] for additional discussion.
|
|
12895
12366
|
#ifdef USE_IBL
|
|
12896
12367
|
vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)
|
|
12897
12368
|
{
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
|
|
12904
|
-
|
|
12369
|
+
float mipCount = 9.0;
|
|
12370
|
+
float lod = (pbrInputs.perceptualRoughness * mipCount);
|
|
12371
|
+
vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,
|
|
12372
|
+
vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;
|
|
12373
|
+
vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
|
|
12905
12374
|
#ifdef USE_TEX_LOD
|
|
12906
|
-
|
|
12375
|
+
vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;
|
|
12907
12376
|
#else
|
|
12908
|
-
|
|
12377
|
+
vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;
|
|
12909
12378
|
#endif
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
diffuse *= u_ScaleIBLAmbient.x;
|
|
12916
|
-
specular *= u_ScaleIBLAmbient.y;
|
|
12917
|
-
|
|
12918
|
-
return diffuse + specular;
|
|
12379
|
+
vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;
|
|
12380
|
+
vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);
|
|
12381
|
+
diffuse *= u_ScaleIBLAmbient.x;
|
|
12382
|
+
specular *= u_ScaleIBLAmbient.y;
|
|
12383
|
+
return diffuse + specular;
|
|
12919
12384
|
}
|
|
12920
12385
|
#endif
|
|
12921
|
-
|
|
12922
|
-
// Basic Lambertian diffuse
|
|
12923
|
-
// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog
|
|
12924
|
-
// See also [1], Equation 1
|
|
12925
12386
|
vec3 diffuse(PBRInfo pbrInputs)
|
|
12926
12387
|
{
|
|
12927
|
-
|
|
12388
|
+
return pbrInputs.diffuseColor / M_PI;
|
|
12928
12389
|
}
|
|
12929
|
-
|
|
12930
|
-
// The following equation models the Fresnel reflectance term of the spec equation (aka F())
|
|
12931
|
-
// Implementation of fresnel from [4], Equation 15
|
|
12932
12390
|
vec3 specularReflection(PBRInfo pbrInputs)
|
|
12933
12391
|
{
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12392
|
+
return pbrInputs.reflectance0 +
|
|
12393
|
+
(pbrInputs.reflectance90 - pbrInputs.reflectance0) *
|
|
12394
|
+
pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);
|
|
12937
12395
|
}
|
|
12938
|
-
|
|
12939
|
-
// This calculates the specular geometric attenuation (aka G()),
|
|
12940
|
-
// where rougher material will reflect less light back to the viewer.
|
|
12941
|
-
// This implementation is based on [1] Equation 4, and we adopt their modifications to
|
|
12942
|
-
// alphaRoughness as input as originally proposed in [2].
|
|
12943
12396
|
float geometricOcclusion(PBRInfo pbrInputs)
|
|
12944
12397
|
{
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
return attenuationL * attenuationV;
|
|
12398
|
+
float NdotL = pbrInputs.NdotL;
|
|
12399
|
+
float NdotV = pbrInputs.NdotV;
|
|
12400
|
+
float r = pbrInputs.alphaRoughness;
|
|
12401
|
+
float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
|
|
12402
|
+
float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
|
|
12403
|
+
return attenuationL * attenuationV;
|
|
12952
12404
|
}
|
|
12953
|
-
|
|
12954
|
-
// The following equation(s) model the distribution of microfacet normals across
|
|
12955
|
-
// the area being drawn (aka D())
|
|
12956
|
-
// Implementation from "Average Irregularity Representation of a Roughened Surface
|
|
12957
|
-
// for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz
|
|
12958
|
-
// Follows the distribution function recommended in the SIGGRAPH 2013 course notes
|
|
12959
|
-
// from EPIC Games [1], Equation 3.
|
|
12960
12405
|
float microfacetDistribution(PBRInfo pbrInputs)
|
|
12961
12406
|
{
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12407
|
+
float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;
|
|
12408
|
+
float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;
|
|
12409
|
+
return roughnessSq / (M_PI * f * f);
|
|
12965
12410
|
}
|
|
12966
|
-
|
|
12967
12411
|
void PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
|
|
12971
|
-
|
|
12412
|
+
pbrInputs.NdotL = 1.0;
|
|
12413
|
+
pbrInputs.NdotH = 0.0;
|
|
12414
|
+
pbrInputs.LdotH = 0.0;
|
|
12415
|
+
pbrInputs.VdotH = 1.0;
|
|
12972
12416
|
}
|
|
12973
|
-
|
|
12974
12417
|
void PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);
|
|
12418
|
+
vec3 n = pbrInputs.n;
|
|
12419
|
+
vec3 v = pbrInputs.v;
|
|
12420
|
+
vec3 l = normalize(lightDirection);
|
|
12421
|
+
vec3 h = normalize(l+v);
|
|
12422
|
+
pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);
|
|
12423
|
+
pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);
|
|
12424
|
+
pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);
|
|
12425
|
+
pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);
|
|
12984
12426
|
}
|
|
12985
|
-
|
|
12986
12427
|
void PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {
|
|
12987
|
-
|
|
12988
|
-
|
|
12428
|
+
vec3 light_direction = normalize(pointLight.position - pbr_vPosition);
|
|
12429
|
+
PBRInfo_setDirectionalLight(pbrInputs, light_direction);
|
|
12989
12430
|
}
|
|
12990
|
-
|
|
12991
12431
|
vec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
12997
|
-
|
|
12998
|
-
vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);
|
|
12999
|
-
vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);
|
|
13000
|
-
// Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
|
|
13001
|
-
return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);
|
|
12432
|
+
vec3 F = specularReflection(pbrInputs);
|
|
12433
|
+
float G = geometricOcclusion(pbrInputs);
|
|
12434
|
+
float D = microfacetDistribution(pbrInputs);
|
|
12435
|
+
vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);
|
|
12436
|
+
vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);
|
|
12437
|
+
return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);
|
|
13002
12438
|
}
|
|
13003
|
-
|
|
13004
12439
|
vec4 pbr_filterColor(vec4 colorUnused)
|
|
13005
12440
|
{
|
|
13006
|
-
// The albedo may be defined from a base texture or a flat color
|
|
13007
12441
|
#ifdef HAS_BASECOLORMAP
|
|
13008
|
-
|
|
12442
|
+
vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;
|
|
13009
12443
|
#else
|
|
13010
|
-
|
|
12444
|
+
vec4 baseColor = u_BaseColorFactor;
|
|
13011
12445
|
#endif
|
|
13012
|
-
|
|
13013
12446
|
#ifdef ALPHA_CUTOFF
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
12447
|
+
if (baseColor.a < u_AlphaCutoff) {
|
|
12448
|
+
discard;
|
|
12449
|
+
}
|
|
13017
12450
|
#endif
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
// Metallic and Roughness material properties are packed together
|
|
13026
|
-
// In glTF, these factors can be specified by fixed scalar values
|
|
13027
|
-
// or from a metallic-roughness map
|
|
13028
|
-
float perceptualRoughness = u_MetallicRoughnessValues.y;
|
|
13029
|
-
float metallic = u_MetallicRoughnessValues.x;
|
|
12451
|
+
vec3 color = vec3(0, 0, 0);
|
|
12452
|
+
if(pbr_uUnlit){
|
|
12453
|
+
color.rgb = baseColor.rgb;
|
|
12454
|
+
}
|
|
12455
|
+
else{
|
|
12456
|
+
float perceptualRoughness = u_MetallicRoughnessValues.y;
|
|
12457
|
+
float metallic = u_MetallicRoughnessValues.x;
|
|
13030
12458
|
#ifdef HAS_METALROUGHNESSMAP
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
perceptualRoughness = mrSample.g * perceptualRoughness;
|
|
13035
|
-
metallic = mrSample.b * metallic;
|
|
12459
|
+
vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV);
|
|
12460
|
+
perceptualRoughness = mrSample.g * perceptualRoughness;
|
|
12461
|
+
metallic = mrSample.b * metallic;
|
|
13036
12462
|
#endif
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
|
|
13065
|
-
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
0.0, // NdotH
|
|
13069
|
-
0.0, // LdotH
|
|
13070
|
-
0.0, // VdotH
|
|
13071
|
-
perceptualRoughness,
|
|
13072
|
-
metallic,
|
|
13073
|
-
specularEnvironmentR0,
|
|
13074
|
-
specularEnvironmentR90,
|
|
13075
|
-
alphaRoughness,
|
|
13076
|
-
diffuseColor,
|
|
13077
|
-
specularColor,
|
|
13078
|
-
n,
|
|
13079
|
-
v
|
|
13080
|
-
);
|
|
13081
|
-
|
|
12463
|
+
perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
|
|
12464
|
+
metallic = clamp(metallic, 0.0, 1.0);
|
|
12465
|
+
float alphaRoughness = perceptualRoughness * perceptualRoughness;
|
|
12466
|
+
vec3 f0 = vec3(0.04);
|
|
12467
|
+
vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
|
|
12468
|
+
diffuseColor *= 1.0 - metallic;
|
|
12469
|
+
vec3 specularColor = mix(f0, baseColor.rgb, metallic);
|
|
12470
|
+
float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
|
|
12471
|
+
float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
|
|
12472
|
+
vec3 specularEnvironmentR0 = specularColor.rgb;
|
|
12473
|
+
vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
|
|
12474
|
+
vec3 n = getNormal();
|
|
12475
|
+
vec3 v = normalize(u_Camera - pbr_vPosition);
|
|
12476
|
+
float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
|
|
12477
|
+
vec3 reflection = -normalize(reflect(v, n));
|
|
12478
|
+
PBRInfo pbrInputs = PBRInfo(
|
|
12479
|
+
0.0,
|
|
12480
|
+
NdotV,
|
|
12481
|
+
0.0,
|
|
12482
|
+
0.0,
|
|
12483
|
+
0.0,
|
|
12484
|
+
perceptualRoughness,
|
|
12485
|
+
metallic,
|
|
12486
|
+
specularEnvironmentR0,
|
|
12487
|
+
specularEnvironmentR90,
|
|
12488
|
+
alphaRoughness,
|
|
12489
|
+
diffuseColor,
|
|
12490
|
+
specularColor,
|
|
12491
|
+
n,
|
|
12492
|
+
v
|
|
12493
|
+
);
|
|
13082
12494
|
#ifdef USE_LIGHTS
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);
|
|
13099
|
-
float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
|
|
13100
|
-
color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);
|
|
13101
|
-
}
|
|
13102
|
-
}
|
|
12495
|
+
PBRInfo_setAmbientLight(pbrInputs);
|
|
12496
|
+
color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);
|
|
12497
|
+
for(int i = 0, i < lighting_uDirectionalLightCount, i++) {
|
|
12498
|
+
if (i < lighting_uDirectionalLightCount) {
|
|
12499
|
+
PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);
|
|
12500
|
+
color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);
|
|
12501
|
+
}
|
|
12502
|
+
}
|
|
12503
|
+
for(int i = 0, i < lighting_uPointLightCount, i++) {
|
|
12504
|
+
if (i < lighting_uPointLightCount) {
|
|
12505
|
+
PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);
|
|
12506
|
+
float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
|
|
12507
|
+
color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);
|
|
12508
|
+
}
|
|
12509
|
+
}
|
|
13103
12510
|
#endif
|
|
13104
|
-
|
|
13105
|
-
// Calculate lighting contribution from image based lighting source (IBL)
|
|
13106
12511
|
#ifdef USE_IBL
|
|
13107
|
-
|
|
12512
|
+
color += getIBLContribution(pbrInputs, n, reflection);
|
|
13108
12513
|
#endif
|
|
13109
|
-
|
|
13110
|
-
// Apply optional PBR terms for additional (optional) shading
|
|
13111
12514
|
#ifdef HAS_OCCLUSIONMAP
|
|
13112
|
-
|
|
13113
|
-
|
|
12515
|
+
float ao = texture(u_OcclusionSampler, pbr_vUV).r;
|
|
12516
|
+
color = mix(color, color * ao, u_OcclusionStrength);
|
|
13114
12517
|
#endif
|
|
13115
|
-
|
|
13116
12518
|
#ifdef HAS_EMISSIVEMAP
|
|
13117
|
-
|
|
13118
|
-
|
|
12519
|
+
vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;
|
|
12520
|
+
color += emissive;
|
|
13119
12521
|
#endif
|
|
13120
|
-
|
|
13121
|
-
// This section uses mix to override final color for reference app visualization
|
|
13122
|
-
// of various parameters in the lighting equation.
|
|
13123
12522
|
#ifdef PBR_DEBUG
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
// color = mix(color, vec3(G), u_ScaleFGDSpec.y);
|
|
13128
|
-
// color = mix(color, vec3(D), u_ScaleFGDSpec.z);
|
|
13129
|
-
// color = mix(color, specContrib, u_ScaleFGDSpec.w);
|
|
13130
|
-
|
|
13131
|
-
// color = mix(color, diffuseContrib, u_ScaleDiffBaseMR.x);
|
|
13132
|
-
color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);
|
|
13133
|
-
color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);
|
|
13134
|
-
color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);
|
|
12523
|
+
color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);
|
|
12524
|
+
color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);
|
|
12525
|
+
color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);
|
|
13135
12526
|
#endif
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
|
|
12527
|
+
}
|
|
12528
|
+
return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
|
|
13140
12529
|
}
|
|
13141
12530
|
`;
|
|
13142
12531
|
|
|
@@ -15968,7 +15357,7 @@ void main(void) {
|
|
|
15968
15357
|
};
|
|
15969
15358
|
|
|
15970
15359
|
// ../../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/version.js
|
|
15971
|
-
var
|
|
15360
|
+
var VERSION6 = true ? "4.1.0" : "latest";
|
|
15972
15361
|
|
|
15973
15362
|
// ../../node_modules/@loaders.gl/3d-tiles/dist/lib/constants.js
|
|
15974
15363
|
var TILE3D_TYPE = {
|
|
@@ -15997,14 +15386,14 @@ void main(void) {
|
|
|
15997
15386
|
}
|
|
15998
15387
|
|
|
15999
15388
|
// ../../node_modules/@loaders.gl/draco/dist/lib/utils/version.js
|
|
16000
|
-
var
|
|
15389
|
+
var VERSION7 = true ? "4.1.0" : "latest";
|
|
16001
15390
|
|
|
16002
15391
|
// ../../node_modules/@loaders.gl/draco/dist/draco-loader.js
|
|
16003
15392
|
var DracoLoader = {
|
|
16004
15393
|
name: "Draco",
|
|
16005
15394
|
id: "draco",
|
|
16006
15395
|
module: "draco",
|
|
16007
|
-
version:
|
|
15396
|
+
version: VERSION7,
|
|
16008
15397
|
worker: true,
|
|
16009
15398
|
extensions: ["drc"],
|
|
16010
15399
|
mimeTypes: ["application/octet-stream"],
|
|
@@ -18961,82 +18350,525 @@ void main(void) {
|
|
|
18961
18350
|
featureTextureProperty.data = data;
|
|
18962
18351
|
}
|
|
18963
18352
|
}
|
|
18964
|
-
}
|
|
18965
|
-
function getPropertyDataFromBinarySource2(scenegraph, schema, classProperty, numberOfFeatures, featureTableProperty) {
|
|
18966
|
-
let data = [];
|
|
18967
|
-
const bufferView = featureTableProperty.bufferView;
|
|
18968
|
-
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
18969
|
-
const arrayOffsets = getArrayOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures);
|
|
18970
|
-
const stringOffsets = getStringOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures);
|
|
18971
|
-
if (classProperty.type === "STRING" || classProperty.componentType === "STRING") {
|
|
18972
|
-
data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets);
|
|
18973
|
-
} else if (isNumericProperty(classProperty)) {
|
|
18974
|
-
data = getPropertyDataNumeric2(classProperty, numberOfFeatures, dataArray, arrayOffsets);
|
|
18353
|
+
}
|
|
18354
|
+
function getPropertyDataFromBinarySource2(scenegraph, schema, classProperty, numberOfFeatures, featureTableProperty) {
|
|
18355
|
+
let data = [];
|
|
18356
|
+
const bufferView = featureTableProperty.bufferView;
|
|
18357
|
+
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
18358
|
+
const arrayOffsets = getArrayOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures);
|
|
18359
|
+
const stringOffsets = getStringOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures);
|
|
18360
|
+
if (classProperty.type === "STRING" || classProperty.componentType === "STRING") {
|
|
18361
|
+
data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets);
|
|
18362
|
+
} else if (isNumericProperty(classProperty)) {
|
|
18363
|
+
data = getPropertyDataNumeric2(classProperty, numberOfFeatures, dataArray, arrayOffsets);
|
|
18364
|
+
}
|
|
18365
|
+
return data;
|
|
18366
|
+
}
|
|
18367
|
+
function getArrayOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
18368
|
+
if (classProperty.type === "ARRAY" && typeof classProperty.componentCount === "undefined" && typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") {
|
|
18369
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsetBufferView, propertyTableProperty.offsetType || "UINT32", numberOfElements);
|
|
18370
|
+
}
|
|
18371
|
+
return null;
|
|
18372
|
+
}
|
|
18373
|
+
function getStringOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
18374
|
+
if (typeof propertyTableProperty.stringOffsetBufferView !== "undefined") {
|
|
18375
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.stringOffsetBufferView, propertyTableProperty.offsetType || "UINT32", numberOfElements);
|
|
18376
|
+
}
|
|
18377
|
+
return null;
|
|
18378
|
+
}
|
|
18379
|
+
function isNumericProperty(schemaProperty) {
|
|
18380
|
+
const types = ["UINT8", "INT16", "UINT16", "INT32", "UINT32", "INT64", "UINT64", "FLOAT32", "FLOAT64"];
|
|
18381
|
+
return types.includes(schemaProperty.type) || typeof schemaProperty.componentType !== "undefined" && types.includes(schemaProperty.componentType);
|
|
18382
|
+
}
|
|
18383
|
+
function getPropertyDataNumeric2(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
18384
|
+
const isArray2 = classProperty.type === "ARRAY";
|
|
18385
|
+
const arrayCount = classProperty.componentCount;
|
|
18386
|
+
const attributeType = "SCALAR";
|
|
18387
|
+
const componentType = classProperty.componentType || classProperty.type;
|
|
18388
|
+
const elementSize = getArrayElementByteSize(attributeType, componentType);
|
|
18389
|
+
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
18390
|
+
const valuesData = convertRawBufferToMetadataArray(valuesDataBytes, attributeType, componentType, elementCount);
|
|
18391
|
+
if (isArray2) {
|
|
18392
|
+
if (arrayOffsets) {
|
|
18393
|
+
return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
|
|
18394
|
+
}
|
|
18395
|
+
if (arrayCount) {
|
|
18396
|
+
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
18397
|
+
}
|
|
18398
|
+
return [];
|
|
18399
|
+
}
|
|
18400
|
+
return valuesData;
|
|
18401
|
+
}
|
|
18402
|
+
function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
|
|
18403
|
+
const json = scenegraph.gltf.json;
|
|
18404
|
+
if (!json.meshes) {
|
|
18405
|
+
return [];
|
|
18406
|
+
}
|
|
18407
|
+
const featureTextureTable = [];
|
|
18408
|
+
for (const mesh of json.meshes) {
|
|
18409
|
+
for (const primitive of mesh.primitives) {
|
|
18410
|
+
processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive);
|
|
18411
|
+
}
|
|
18412
|
+
}
|
|
18413
|
+
return featureTextureTable;
|
|
18414
|
+
}
|
|
18415
|
+
function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) {
|
|
18416
|
+
const textureInfoTopLevel = {
|
|
18417
|
+
channels: featureTextureProperty.channels,
|
|
18418
|
+
...featureTextureProperty.texture
|
|
18419
|
+
};
|
|
18420
|
+
const propertyData = getPrimitiveTextureData(scenegraph, textureInfoTopLevel, primitive);
|
|
18421
|
+
if (!propertyData) {
|
|
18422
|
+
return;
|
|
18423
|
+
}
|
|
18424
|
+
primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTextureTable, primitive);
|
|
18425
|
+
}
|
|
18426
|
+
|
|
18427
|
+
// ../../node_modules/@loaders.gl/gltf/dist/lib/utils/version.js
|
|
18428
|
+
var VERSION8 = true ? "4.1.0" : "latest";
|
|
18429
|
+
|
|
18430
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/utils/version.js
|
|
18431
|
+
var VERSION9 = true ? "4.1.0" : "latest";
|
|
18432
|
+
|
|
18433
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/parsers/basis-module-loader.js
|
|
18434
|
+
var BASIS_EXTERNAL_LIBRARIES = {
|
|
18435
|
+
TRANSCODER: "basis_transcoder.js",
|
|
18436
|
+
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
18437
|
+
ENCODER: "basis_encoder.js",
|
|
18438
|
+
ENCODER_WASM: "basis_encoder.wasm"
|
|
18439
|
+
};
|
|
18440
|
+
var loadBasisTranscoderPromise;
|
|
18441
|
+
async function loadBasisTranscoderModule(options) {
|
|
18442
|
+
const modules = options.modules || {};
|
|
18443
|
+
if (modules.basis) {
|
|
18444
|
+
return modules.basis;
|
|
18445
|
+
}
|
|
18446
|
+
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
|
|
18447
|
+
return await loadBasisTranscoderPromise;
|
|
18448
|
+
}
|
|
18449
|
+
async function loadBasisTranscoder(options) {
|
|
18450
|
+
let BASIS = null;
|
|
18451
|
+
let wasmBinary = null;
|
|
18452
|
+
[BASIS, wasmBinary] = await Promise.all([await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options), await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)]);
|
|
18453
|
+
BASIS = BASIS || globalThis.BASIS;
|
|
18454
|
+
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
18455
|
+
}
|
|
18456
|
+
function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
|
|
18457
|
+
const options = {};
|
|
18458
|
+
if (wasmBinary) {
|
|
18459
|
+
options.wasmBinary = wasmBinary;
|
|
18460
|
+
}
|
|
18461
|
+
return new Promise((resolve2) => {
|
|
18462
|
+
BasisModule(options).then((module) => {
|
|
18463
|
+
const {
|
|
18464
|
+
BasisFile,
|
|
18465
|
+
initializeBasis
|
|
18466
|
+
} = module;
|
|
18467
|
+
initializeBasis();
|
|
18468
|
+
resolve2({
|
|
18469
|
+
BasisFile
|
|
18470
|
+
});
|
|
18471
|
+
});
|
|
18472
|
+
});
|
|
18473
|
+
}
|
|
18474
|
+
var loadBasisEncoderPromise;
|
|
18475
|
+
async function loadBasisEncoderModule(options) {
|
|
18476
|
+
const modules = options.modules || {};
|
|
18477
|
+
if (modules.basisEncoder) {
|
|
18478
|
+
return modules.basisEncoder;
|
|
18479
|
+
}
|
|
18480
|
+
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
18481
|
+
return await loadBasisEncoderPromise;
|
|
18482
|
+
}
|
|
18483
|
+
async function loadBasisEncoder(options) {
|
|
18484
|
+
let BASIS_ENCODER = null;
|
|
18485
|
+
let wasmBinary = null;
|
|
18486
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options), await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)]);
|
|
18487
|
+
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
18488
|
+
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
18489
|
+
}
|
|
18490
|
+
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
18491
|
+
const options = {};
|
|
18492
|
+
if (wasmBinary) {
|
|
18493
|
+
options.wasmBinary = wasmBinary;
|
|
18494
|
+
}
|
|
18495
|
+
return new Promise((resolve2) => {
|
|
18496
|
+
BasisEncoderModule(options).then((module) => {
|
|
18497
|
+
const {
|
|
18498
|
+
BasisFile,
|
|
18499
|
+
KTX2File,
|
|
18500
|
+
initializeBasis,
|
|
18501
|
+
BasisEncoder
|
|
18502
|
+
} = module;
|
|
18503
|
+
initializeBasis();
|
|
18504
|
+
resolve2({
|
|
18505
|
+
BasisFile,
|
|
18506
|
+
KTX2File,
|
|
18507
|
+
BasisEncoder
|
|
18508
|
+
});
|
|
18509
|
+
});
|
|
18510
|
+
});
|
|
18511
|
+
}
|
|
18512
|
+
|
|
18513
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/gl-extensions.js
|
|
18514
|
+
var GL_EXTENSIONS_CONSTANTS = {
|
|
18515
|
+
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
18516
|
+
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
18517
|
+
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
18518
|
+
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
18519
|
+
COMPRESSED_R11_EAC: 37488,
|
|
18520
|
+
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
18521
|
+
COMPRESSED_RG11_EAC: 37490,
|
|
18522
|
+
COMPRESSED_SIGNED_RG11_EAC: 37491,
|
|
18523
|
+
COMPRESSED_RGB8_ETC2: 37492,
|
|
18524
|
+
COMPRESSED_RGBA8_ETC2_EAC: 37493,
|
|
18525
|
+
COMPRESSED_SRGB8_ETC2: 37494,
|
|
18526
|
+
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
18527
|
+
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
18528
|
+
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
18529
|
+
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
18530
|
+
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
18531
|
+
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
18532
|
+
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
18533
|
+
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
18534
|
+
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
18535
|
+
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
18536
|
+
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
18537
|
+
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
18538
|
+
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
18539
|
+
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
18540
|
+
COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
|
|
18541
|
+
COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
|
|
18542
|
+
COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
|
|
18543
|
+
COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
|
|
18544
|
+
COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
|
|
18545
|
+
COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
|
|
18546
|
+
COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
|
|
18547
|
+
COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
|
|
18548
|
+
COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
|
|
18549
|
+
COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
|
|
18550
|
+
COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
|
|
18551
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
|
|
18552
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
|
|
18553
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
|
|
18554
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
|
|
18555
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
|
|
18556
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
|
|
18557
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
|
|
18558
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
|
|
18559
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
|
|
18560
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
|
|
18561
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
|
|
18562
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
18563
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
18564
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
18565
|
+
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
18566
|
+
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
18567
|
+
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
18568
|
+
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
18569
|
+
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
18570
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
18571
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
18572
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
|
|
18573
|
+
};
|
|
18574
|
+
|
|
18575
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/utils/texture-formats.js
|
|
18576
|
+
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
18577
|
+
var WEBGL_EXTENSIONS = {
|
|
18578
|
+
WEBGL_compressed_texture_s3tc: "dxt",
|
|
18579
|
+
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
18580
|
+
WEBGL_compressed_texture_etc1: "etc1",
|
|
18581
|
+
WEBGL_compressed_texture_etc: "etc2",
|
|
18582
|
+
WEBGL_compressed_texture_pvrtc: "pvrtc",
|
|
18583
|
+
WEBGL_compressed_texture_atc: "atc",
|
|
18584
|
+
WEBGL_compressed_texture_astc: "astc",
|
|
18585
|
+
EXT_texture_compression_rgtc: "rgtc"
|
|
18586
|
+
};
|
|
18587
|
+
var formats = null;
|
|
18588
|
+
function getSupportedGPUTextureFormats(gl) {
|
|
18589
|
+
if (!formats) {
|
|
18590
|
+
gl = gl || getWebGLContext() || void 0;
|
|
18591
|
+
formats = /* @__PURE__ */ new Set();
|
|
18592
|
+
for (const prefix of BROWSER_PREFIXES) {
|
|
18593
|
+
for (const extension in WEBGL_EXTENSIONS) {
|
|
18594
|
+
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
18595
|
+
const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
|
|
18596
|
+
formats.add(gpuTextureFormat);
|
|
18597
|
+
}
|
|
18598
|
+
}
|
|
18599
|
+
}
|
|
18600
|
+
}
|
|
18601
|
+
return formats;
|
|
18602
|
+
}
|
|
18603
|
+
function getWebGLContext() {
|
|
18604
|
+
try {
|
|
18605
|
+
const canvas = document.createElement("canvas");
|
|
18606
|
+
return canvas.getContext("webgl");
|
|
18607
|
+
} catch (error) {
|
|
18608
|
+
return null;
|
|
18609
|
+
}
|
|
18610
|
+
}
|
|
18611
|
+
|
|
18612
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/parsers/parse-ktx.js
|
|
18613
|
+
var KTX2_ID = [171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10];
|
|
18614
|
+
function isKTX(data) {
|
|
18615
|
+
const id = new Uint8Array(data);
|
|
18616
|
+
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11];
|
|
18617
|
+
return !notKTX;
|
|
18618
|
+
}
|
|
18619
|
+
|
|
18620
|
+
// ../../node_modules/@loaders.gl/textures/dist/lib/parsers/parse-basis.js
|
|
18621
|
+
var OutputFormat = {
|
|
18622
|
+
etc1: {
|
|
18623
|
+
basisFormat: 0,
|
|
18624
|
+
compressed: true,
|
|
18625
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
18626
|
+
},
|
|
18627
|
+
etc2: {
|
|
18628
|
+
basisFormat: 1,
|
|
18629
|
+
compressed: true
|
|
18630
|
+
},
|
|
18631
|
+
bc1: {
|
|
18632
|
+
basisFormat: 2,
|
|
18633
|
+
compressed: true,
|
|
18634
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
|
|
18635
|
+
},
|
|
18636
|
+
bc3: {
|
|
18637
|
+
basisFormat: 3,
|
|
18638
|
+
compressed: true,
|
|
18639
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
18640
|
+
},
|
|
18641
|
+
bc4: {
|
|
18642
|
+
basisFormat: 4,
|
|
18643
|
+
compressed: true
|
|
18644
|
+
},
|
|
18645
|
+
bc5: {
|
|
18646
|
+
basisFormat: 5,
|
|
18647
|
+
compressed: true
|
|
18648
|
+
},
|
|
18649
|
+
"bc7-m6-opaque-only": {
|
|
18650
|
+
basisFormat: 6,
|
|
18651
|
+
compressed: true
|
|
18652
|
+
},
|
|
18653
|
+
"bc7-m5": {
|
|
18654
|
+
basisFormat: 7,
|
|
18655
|
+
compressed: true
|
|
18656
|
+
},
|
|
18657
|
+
"pvrtc1-4-rgb": {
|
|
18658
|
+
basisFormat: 8,
|
|
18659
|
+
compressed: true,
|
|
18660
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
|
18661
|
+
},
|
|
18662
|
+
"pvrtc1-4-rgba": {
|
|
18663
|
+
basisFormat: 9,
|
|
18664
|
+
compressed: true,
|
|
18665
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
|
18666
|
+
},
|
|
18667
|
+
"astc-4x4": {
|
|
18668
|
+
basisFormat: 10,
|
|
18669
|
+
compressed: true,
|
|
18670
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
18671
|
+
},
|
|
18672
|
+
"atc-rgb": {
|
|
18673
|
+
basisFormat: 11,
|
|
18674
|
+
compressed: true
|
|
18675
|
+
},
|
|
18676
|
+
"atc-rgba-interpolated-alpha": {
|
|
18677
|
+
basisFormat: 12,
|
|
18678
|
+
compressed: true
|
|
18679
|
+
},
|
|
18680
|
+
rgba32: {
|
|
18681
|
+
basisFormat: 13,
|
|
18682
|
+
compressed: false
|
|
18683
|
+
},
|
|
18684
|
+
rgb565: {
|
|
18685
|
+
basisFormat: 14,
|
|
18686
|
+
compressed: false
|
|
18687
|
+
},
|
|
18688
|
+
bgr565: {
|
|
18689
|
+
basisFormat: 15,
|
|
18690
|
+
compressed: false
|
|
18691
|
+
},
|
|
18692
|
+
rgba4444: {
|
|
18693
|
+
basisFormat: 16,
|
|
18694
|
+
compressed: false
|
|
18695
|
+
}
|
|
18696
|
+
};
|
|
18697
|
+
async function parseBasis(data, options) {
|
|
18698
|
+
if (options.basis.containerFormat === "auto") {
|
|
18699
|
+
if (isKTX(data)) {
|
|
18700
|
+
const fileConstructors = await loadBasisEncoderModule(options);
|
|
18701
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
18702
|
+
}
|
|
18703
|
+
const {
|
|
18704
|
+
BasisFile
|
|
18705
|
+
} = await loadBasisTranscoderModule(options);
|
|
18706
|
+
return parseBasisFile(BasisFile, data, options);
|
|
18707
|
+
}
|
|
18708
|
+
switch (options.basis.module) {
|
|
18709
|
+
case "encoder":
|
|
18710
|
+
const fileConstructors = await loadBasisEncoderModule(options);
|
|
18711
|
+
switch (options.basis.containerFormat) {
|
|
18712
|
+
case "ktx2":
|
|
18713
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
18714
|
+
case "basis":
|
|
18715
|
+
default:
|
|
18716
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
18717
|
+
}
|
|
18718
|
+
case "transcoder":
|
|
18719
|
+
default:
|
|
18720
|
+
const {
|
|
18721
|
+
BasisFile
|
|
18722
|
+
} = await loadBasisTranscoderModule(options);
|
|
18723
|
+
return parseBasisFile(BasisFile, data, options);
|
|
18975
18724
|
}
|
|
18976
|
-
return data;
|
|
18977
18725
|
}
|
|
18978
|
-
function
|
|
18979
|
-
|
|
18980
|
-
|
|
18726
|
+
function parseBasisFile(BasisFile, data, options) {
|
|
18727
|
+
const basisFile = new BasisFile(new Uint8Array(data));
|
|
18728
|
+
try {
|
|
18729
|
+
if (!basisFile.startTranscoding()) {
|
|
18730
|
+
throw new Error("Failed to start basis transcoding");
|
|
18731
|
+
}
|
|
18732
|
+
const imageCount = basisFile.getNumImages();
|
|
18733
|
+
const images = [];
|
|
18734
|
+
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
18735
|
+
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
18736
|
+
const levels = [];
|
|
18737
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
18738
|
+
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
18739
|
+
}
|
|
18740
|
+
images.push(levels);
|
|
18741
|
+
}
|
|
18742
|
+
return images;
|
|
18743
|
+
} finally {
|
|
18744
|
+
basisFile.close();
|
|
18745
|
+
basisFile.delete();
|
|
18981
18746
|
}
|
|
18982
|
-
return null;
|
|
18983
18747
|
}
|
|
18984
|
-
function
|
|
18985
|
-
|
|
18986
|
-
|
|
18748
|
+
function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
18749
|
+
const width = basisFile.getImageWidth(imageIndex, levelIndex);
|
|
18750
|
+
const height = basisFile.getImageHeight(imageIndex, levelIndex);
|
|
18751
|
+
const hasAlpha = basisFile.getHasAlpha();
|
|
18752
|
+
const {
|
|
18753
|
+
compressed,
|
|
18754
|
+
format,
|
|
18755
|
+
basisFormat
|
|
18756
|
+
} = getBasisOptions(options, hasAlpha);
|
|
18757
|
+
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
18758
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
18759
|
+
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
18760
|
+
throw new Error("failed to start Basis transcoding");
|
|
18987
18761
|
}
|
|
18988
|
-
return
|
|
18989
|
-
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18762
|
+
return {
|
|
18763
|
+
width,
|
|
18764
|
+
height,
|
|
18765
|
+
data: decodedData,
|
|
18766
|
+
compressed,
|
|
18767
|
+
format,
|
|
18768
|
+
hasAlpha
|
|
18769
|
+
};
|
|
18993
18770
|
}
|
|
18994
|
-
function
|
|
18995
|
-
const
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
|
|
18999
|
-
const elementSize = getArrayElementByteSize(attributeType, componentType);
|
|
19000
|
-
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
19001
|
-
const valuesData = convertRawBufferToMetadataArray(valuesDataBytes, attributeType, componentType, elementCount);
|
|
19002
|
-
if (isArray2) {
|
|
19003
|
-
if (arrayOffsets) {
|
|
19004
|
-
return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
|
|
18771
|
+
function parseKTX2File(KTX2File, data, options) {
|
|
18772
|
+
const ktx2File = new KTX2File(new Uint8Array(data));
|
|
18773
|
+
try {
|
|
18774
|
+
if (!ktx2File.startTranscoding()) {
|
|
18775
|
+
throw new Error("failed to start KTX2 transcoding");
|
|
19005
18776
|
}
|
|
19006
|
-
|
|
19007
|
-
|
|
18777
|
+
const levelsCount = ktx2File.getLevels();
|
|
18778
|
+
const levels = [];
|
|
18779
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
18780
|
+
levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
|
|
18781
|
+
break;
|
|
19008
18782
|
}
|
|
19009
|
-
return [];
|
|
18783
|
+
return [levels];
|
|
18784
|
+
} finally {
|
|
18785
|
+
ktx2File.close();
|
|
18786
|
+
ktx2File.delete();
|
|
19010
18787
|
}
|
|
19011
|
-
return valuesData;
|
|
19012
18788
|
}
|
|
19013
|
-
function
|
|
19014
|
-
const
|
|
19015
|
-
|
|
19016
|
-
|
|
18789
|
+
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
18790
|
+
const {
|
|
18791
|
+
alphaFlag,
|
|
18792
|
+
height,
|
|
18793
|
+
width
|
|
18794
|
+
} = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
18795
|
+
const {
|
|
18796
|
+
compressed,
|
|
18797
|
+
format,
|
|
18798
|
+
basisFormat
|
|
18799
|
+
} = getBasisOptions(options, alphaFlag);
|
|
18800
|
+
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
18801
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
18802
|
+
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
|
|
18803
|
+
throw new Error("Failed to transcode KTX2 image");
|
|
19017
18804
|
}
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
18805
|
+
return {
|
|
18806
|
+
width,
|
|
18807
|
+
height,
|
|
18808
|
+
data: decodedData,
|
|
18809
|
+
compressed,
|
|
18810
|
+
levelSize: decodedSize,
|
|
18811
|
+
hasAlpha: alphaFlag,
|
|
18812
|
+
format
|
|
18813
|
+
};
|
|
18814
|
+
}
|
|
18815
|
+
function getBasisOptions(options, hasAlpha) {
|
|
18816
|
+
let format = options && options.basis && options.basis.format;
|
|
18817
|
+
if (format === "auto") {
|
|
18818
|
+
format = selectSupportedBasisFormat();
|
|
19023
18819
|
}
|
|
19024
|
-
|
|
18820
|
+
if (typeof format === "object") {
|
|
18821
|
+
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
18822
|
+
}
|
|
18823
|
+
format = format.toLowerCase();
|
|
18824
|
+
return OutputFormat[format];
|
|
19025
18825
|
}
|
|
19026
|
-
function
|
|
19027
|
-
const
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
}
|
|
19031
|
-
|
|
19032
|
-
|
|
19033
|
-
|
|
18826
|
+
function selectSupportedBasisFormat() {
|
|
18827
|
+
const supportedFormats = getSupportedGPUTextureFormats();
|
|
18828
|
+
if (supportedFormats.has("astc")) {
|
|
18829
|
+
return "astc-4x4";
|
|
18830
|
+
} else if (supportedFormats.has("dxt")) {
|
|
18831
|
+
return {
|
|
18832
|
+
alpha: "bc3",
|
|
18833
|
+
noAlpha: "bc1"
|
|
18834
|
+
};
|
|
18835
|
+
} else if (supportedFormats.has("pvrtc")) {
|
|
18836
|
+
return {
|
|
18837
|
+
alpha: "pvrtc1-4-rgba",
|
|
18838
|
+
noAlpha: "pvrtc1-4-rgb"
|
|
18839
|
+
};
|
|
18840
|
+
} else if (supportedFormats.has("etc1")) {
|
|
18841
|
+
return "etc1";
|
|
18842
|
+
} else if (supportedFormats.has("etc2")) {
|
|
18843
|
+
return "etc2";
|
|
19034
18844
|
}
|
|
19035
|
-
|
|
18845
|
+
return "rgb565";
|
|
19036
18846
|
}
|
|
19037
18847
|
|
|
19038
|
-
// ../../node_modules/@loaders.gl/
|
|
19039
|
-
var
|
|
18848
|
+
// ../../node_modules/@loaders.gl/textures/dist/basis-loader.js
|
|
18849
|
+
var BasisWorkerLoader = {
|
|
18850
|
+
name: "Basis",
|
|
18851
|
+
id: "basis",
|
|
18852
|
+
module: "textures",
|
|
18853
|
+
version: VERSION9,
|
|
18854
|
+
worker: true,
|
|
18855
|
+
extensions: ["basis", "ktx2"],
|
|
18856
|
+
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
18857
|
+
tests: ["sB"],
|
|
18858
|
+
binary: true,
|
|
18859
|
+
options: {
|
|
18860
|
+
basis: {
|
|
18861
|
+
format: "auto",
|
|
18862
|
+
libraryPath: "libs/",
|
|
18863
|
+
containerFormat: "auto",
|
|
18864
|
+
module: "transcoder"
|
|
18865
|
+
}
|
|
18866
|
+
}
|
|
18867
|
+
};
|
|
18868
|
+
var BasisLoader = {
|
|
18869
|
+
...BasisWorkerLoader,
|
|
18870
|
+
parse: parseBasis
|
|
18871
|
+
};
|
|
19040
18872
|
|
|
19041
18873
|
// ../../node_modules/@loaders.gl/gltf/dist/lib/parsers/parse-glb.js
|
|
19042
18874
|
var LITTLE_ENDIAN2 = true;
|
|
@@ -20244,7 +20076,7 @@ void main(void) {
|
|
|
20244
20076
|
name: "glTF",
|
|
20245
20077
|
id: "gltf",
|
|
20246
20078
|
module: "gltf",
|
|
20247
|
-
version:
|
|
20079
|
+
version: VERSION8,
|
|
20248
20080
|
extensions: ["gltf", "glb"],
|
|
20249
20081
|
mimeTypes: ["model/gltf+json", "model/gltf-binary"],
|
|
20250
20082
|
text: true,
|
|
@@ -21022,7 +20854,7 @@ void main(void) {
|
|
|
21022
20854
|
id: "3d-tiles-subtree",
|
|
21023
20855
|
name: "3D Tiles Subtree",
|
|
21024
20856
|
module: "3d-tiles",
|
|
21025
|
-
version:
|
|
20857
|
+
version: VERSION6,
|
|
21026
20858
|
extensions: ["subtree"],
|
|
21027
20859
|
mimeTypes: ["application/octet-stream"],
|
|
21028
20860
|
tests: ["subtree"],
|
|
@@ -21036,6 +20868,40 @@ void main(void) {
|
|
|
21036
20868
|
// ../../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js
|
|
21037
20869
|
var import_core41 = __toESM(require_core3(), 1);
|
|
21038
20870
|
|
|
20871
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
20872
|
+
function isElectron(mockUserAgent) {
|
|
20873
|
+
if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
|
|
20874
|
+
return true;
|
|
20875
|
+
}
|
|
20876
|
+
if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
|
|
20877
|
+
return true;
|
|
20878
|
+
}
|
|
20879
|
+
const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
|
|
20880
|
+
const userAgent = mockUserAgent || realUserAgent;
|
|
20881
|
+
if (userAgent && userAgent.indexOf("Electron") >= 0) {
|
|
20882
|
+
return true;
|
|
20883
|
+
}
|
|
20884
|
+
return false;
|
|
20885
|
+
}
|
|
20886
|
+
|
|
20887
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
20888
|
+
function isBrowser3() {
|
|
20889
|
+
const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
|
|
20890
|
+
return !isNode || isElectron();
|
|
20891
|
+
}
|
|
20892
|
+
|
|
20893
|
+
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
20894
|
+
var self_3 = globalThis.self || globalThis.window || globalThis.global;
|
|
20895
|
+
var window_3 = globalThis.window || globalThis.self || globalThis.global;
|
|
20896
|
+
var document_3 = globalThis.document || {};
|
|
20897
|
+
var process_ = globalThis.process || {};
|
|
20898
|
+
var console_ = globalThis.console;
|
|
20899
|
+
var navigator_ = globalThis.navigator || {};
|
|
20900
|
+
|
|
20901
|
+
// ../../node_modules/@probe.gl/env/dist/utils/globals.js
|
|
20902
|
+
var VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
|
|
20903
|
+
var isBrowser4 = isBrowser3();
|
|
20904
|
+
|
|
21039
20905
|
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
21040
20906
|
function getStorage(type) {
|
|
21041
20907
|
try {
|
|
@@ -21218,7 +21084,7 @@ void main(void) {
|
|
|
21218
21084
|
id: ""
|
|
21219
21085
|
};
|
|
21220
21086
|
this.id = void 0;
|
|
21221
|
-
this.VERSION =
|
|
21087
|
+
this.VERSION = VERSION10;
|
|
21222
21088
|
this._startTs = getHiResTimestamp2();
|
|
21223
21089
|
this._deltaTs = getHiResTimestamp2();
|
|
21224
21090
|
this._storage = void 0;
|
|
@@ -21421,7 +21287,7 @@ void main(void) {
|
|
|
21421
21287
|
return noop;
|
|
21422
21288
|
}
|
|
21423
21289
|
};
|
|
21424
|
-
Log.VERSION =
|
|
21290
|
+
Log.VERSION = VERSION10;
|
|
21425
21291
|
function normalizeLogLevel(logLevel) {
|
|
21426
21292
|
if (!logLevel) {
|
|
21427
21293
|
return 0;
|
|
@@ -23161,7 +23027,7 @@ void main(void) {
|
|
|
23161
23027
|
id: "3d-tiles",
|
|
23162
23028
|
name: "3D Tiles",
|
|
23163
23029
|
module: "3d-tiles",
|
|
23164
|
-
version:
|
|
23030
|
+
version: VERSION6,
|
|
23165
23031
|
extensions: ["cmpt", "pnts", "b3dm", "i3dm"],
|
|
23166
23032
|
mimeTypes: ["application/octet-stream"],
|
|
23167
23033
|
tests: ["cmpt", "pnts", "b3dm", "i3dm"],
|