@luma.gl/gltf 9.0.0-alpha.51 → 9.0.0-alpha.52

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 CHANGED
@@ -33,6 +33,7 @@ var __exports__ = (() => {
33
33
  __export(src_exports, {
34
34
  GLTFAnimator: () => GLTFAnimator,
35
35
  createScenegraphsFromGLTF: () => createScenegraphsFromGLTF,
36
+ loadPBREnvironment: () => loadPBREnvironment,
36
37
  parsePBRMaterial: () => parsePBRMaterial
37
38
  });
38
39
 
@@ -809,23 +810,23 @@ var __exports__ = (() => {
809
810
 
810
811
  // ../core/src/init.ts
811
812
  function initializeLuma() {
812
- const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
813
+ const VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
813
814
  const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
814
- if (globalThis.luma && globalThis.luma.VERSION !== VERSION3) {
815
- throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION3}`);
815
+ if (globalThis.luma && globalThis.luma.VERSION !== VERSION4) {
816
+ throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION4}`);
816
817
  }
817
818
  if (!globalThis.luma) {
818
819
  if (isBrowser()) {
819
- log.log(1, `luma.gl ${VERSION3} - ${STARTUP_MESSAGE}`)();
820
+ log.log(1, `luma.gl ${VERSION4} - ${STARTUP_MESSAGE}`)();
820
821
  }
821
822
  globalThis.luma = globalThis.luma || {
822
- VERSION: VERSION3,
823
- version: VERSION3,
823
+ VERSION: VERSION4,
824
+ version: VERSION4,
824
825
  log,
825
826
  stats: lumaStats
826
827
  };
827
828
  }
828
- return VERSION3;
829
+ return VERSION4;
829
830
  }
830
831
  var VERSION2 = initializeLuma();
831
832
 
@@ -1502,7 +1503,10 @@ ${htmlLog}
1502
1503
  button.style.width = "100%";
1503
1504
  button.style.textAlign = "left";
1504
1505
  document.body.appendChild(button);
1505
- document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView();
1506
+ const errors = document.getElementsByClassName("luma-compiler-log-error");
1507
+ if (errors[0]?.scrollIntoView) {
1508
+ errors[0].scrollIntoView();
1509
+ }
1506
1510
  button.onclick = () => {
1507
1511
  const dataURI = `data:text/plain,${encodeURIComponent(this.source)}`;
1508
1512
  navigator.clipboard.writeText(dataURI);
@@ -2404,9 +2408,9 @@ ${htmlLog}
2404
2408
  // ../core/src/adapter/type-utils/decode-texture-format.ts
2405
2409
  var REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
2406
2410
  function decodeTextureFormat(format) {
2407
- const matches = REGEX.exec(format);
2408
- if (matches) {
2409
- const [, format2, length4, type, srgb, suffix] = matches;
2411
+ const matches2 = REGEX.exec(format);
2412
+ if (matches2) {
2413
+ const [, format2, length4, type, srgb, suffix] = matches2;
2410
2414
  if (format2) {
2411
2415
  const dataType = `${type}${length4}`;
2412
2416
  const decodedType = decodeVertexType(dataType);
@@ -2559,7 +2563,7 @@ ${htmlLog}
2559
2563
  return value;
2560
2564
  }
2561
2565
 
2562
- // ../core/src/lib/utils/uniform.ts
2566
+ // ../core/src/lib/uniforms/uniform.ts
2563
2567
  function isUniformValue(value) {
2564
2568
  return isNumberArray(value) !== null || typeof value === "number" || typeof value === "boolean";
2565
2569
  }
@@ -2700,6 +2704,27 @@ ${htmlLog}
2700
2704
  return false;
2701
2705
  }
2702
2706
 
2707
+ // ../core/src/lib/debug/debug-shader-layout.ts
2708
+ function getDebugTableForShaderLayout(layout, name2 = "") {
2709
+ const table = {};
2710
+ const header = `Shader Layout for ${name2}`;
2711
+ for (const attributeDeclaration of layout.attributes) {
2712
+ if (attributeDeclaration) {
2713
+ const glslDeclaration = `${attributeDeclaration.location} ${attributeDeclaration.name}: ${attributeDeclaration.type}`;
2714
+ table[`in ${glslDeclaration}`] = {
2715
+ [header]: attributeDeclaration.stepMode || "vertex"
2716
+ };
2717
+ }
2718
+ }
2719
+ for (const varyingDeclaration of layout.varyings || []) {
2720
+ const glslDeclaration = `${varyingDeclaration.location} ${varyingDeclaration.name}`;
2721
+ table[`out ${glslDeclaration}`] = {
2722
+ [header]: JSON.stringify(varyingDeclaration.accessor)
2723
+ };
2724
+ }
2725
+ return table;
2726
+ }
2727
+
2703
2728
  // src/pbr/parse-pbr-material.ts
2704
2729
  var GLEnum = function(GLEnum4) {
2705
2730
  GLEnum4[GLEnum4["FUNC_ADD"] = 32774] = "FUNC_ADD";
@@ -2850,11 +2875,616 @@ ${htmlLog}
2850
2875
  parsedMaterial.generatedTextures.push(texture);
2851
2876
  }
2852
2877
 
2878
+ // node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/assert.js
2879
+ function assert3(condition, message2) {
2880
+ if (!condition) {
2881
+ throw new Error(message2 || "loader assertion failed.");
2882
+ }
2883
+ }
2884
+
2885
+ // node_modules/@loaders.gl/loader-utils/dist/lib/path-utils/file-aliases.js
2886
+ var pathPrefix2 = "";
2887
+ var fileAliases = {};
2888
+ function resolvePath(filename) {
2889
+ for (const alias in fileAliases) {
2890
+ if (filename.startsWith(alias)) {
2891
+ const replacement = fileAliases[alias];
2892
+ filename = filename.replace(alias, replacement);
2893
+ }
2894
+ }
2895
+ if (!filename.startsWith("http://") && !filename.startsWith("https://")) {
2896
+ filename = `${pathPrefix2}${filename}`;
2897
+ }
2898
+ return filename;
2899
+ }
2900
+
2901
+ // ../../node_modules/@loaders.gl/images/dist/lib/utils/version.js
2902
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2903
+
2904
+ // ../../node_modules/@loaders.gl/images/node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/assert.js
2905
+ function assert4(condition, message2) {
2906
+ if (!condition) {
2907
+ throw new Error(message2 || "loader assertion failed.");
2908
+ }
2909
+ }
2910
+
2911
+ // ../../node_modules/@loaders.gl/images/node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/globals.js
2912
+ var globals = {
2913
+ self: typeof self !== "undefined" && self,
2914
+ window: typeof window !== "undefined" && window,
2915
+ global: typeof global !== "undefined" && global,
2916
+ document: typeof document !== "undefined" && document
2917
+ };
2918
+ var self_2 = globals.self || globals.window || globals.global || {};
2919
+ var window_2 = globals.window || globals.self || globals.global || {};
2920
+ var global_2 = globals.global || globals.self || globals.window || {};
2921
+ var document_2 = globals.document || {};
2922
+ var isBrowser3 = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
2923
+ var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
2924
+ var nodeVersion = matches && parseFloat(matches[1]) || 0;
2925
+
2926
+ // ../../node_modules/@loaders.gl/images/dist/lib/category-api/image-type.js
2927
+ var _globalThis$loaders;
2928
+ var parseImageNode = (_globalThis$loaders = globalThis.loaders) === null || _globalThis$loaders === void 0 ? void 0 : _globalThis$loaders.parseImageNode;
2929
+ var IMAGE_SUPPORTED = typeof Image !== "undefined";
2930
+ var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
2931
+ var NODE_IMAGE_SUPPORTED = Boolean(parseImageNode);
2932
+ var DATA_SUPPORTED = isBrowser3 ? true : NODE_IMAGE_SUPPORTED;
2933
+ function isImageTypeSupported(type) {
2934
+ switch (type) {
2935
+ case "auto":
2936
+ return IMAGE_BITMAP_SUPPORTED || IMAGE_SUPPORTED || DATA_SUPPORTED;
2937
+ case "imagebitmap":
2938
+ return IMAGE_BITMAP_SUPPORTED;
2939
+ case "image":
2940
+ return IMAGE_SUPPORTED;
2941
+ case "data":
2942
+ return DATA_SUPPORTED;
2943
+ default:
2944
+ throw new Error(`@loaders.gl/images: image ${type} not supported in this environment`);
2945
+ }
2946
+ }
2947
+ function getDefaultImageType() {
2948
+ if (IMAGE_BITMAP_SUPPORTED) {
2949
+ return "imagebitmap";
2950
+ }
2951
+ if (IMAGE_SUPPORTED) {
2952
+ return "image";
2953
+ }
2954
+ if (DATA_SUPPORTED) {
2955
+ return "data";
2956
+ }
2957
+ throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");
2958
+ }
2959
+
2960
+ // ../../node_modules/@loaders.gl/images/dist/lib/category-api/parsed-image-api.js
2961
+ function getImageType(image) {
2962
+ const format = getImageTypeOrNull(image);
2963
+ if (!format) {
2964
+ throw new Error("Not an image");
2965
+ }
2966
+ return format;
2967
+ }
2968
+ function getImageSize(image) {
2969
+ return getImageData(image);
2970
+ }
2971
+ function getImageData(image) {
2972
+ switch (getImageType(image)) {
2973
+ case "data":
2974
+ return image;
2975
+ case "image":
2976
+ case "imagebitmap":
2977
+ const canvas = document.createElement("canvas");
2978
+ const context = canvas.getContext("2d");
2979
+ if (!context) {
2980
+ throw new Error("getImageData");
2981
+ }
2982
+ canvas.width = image.width;
2983
+ canvas.height = image.height;
2984
+ context.drawImage(image, 0, 0);
2985
+ return context.getImageData(0, 0, image.width, image.height);
2986
+ default:
2987
+ throw new Error("getImageData");
2988
+ }
2989
+ }
2990
+ function getImageTypeOrNull(image) {
2991
+ if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
2992
+ return "imagebitmap";
2993
+ }
2994
+ if (typeof Image !== "undefined" && image instanceof Image) {
2995
+ return "image";
2996
+ }
2997
+ if (image && typeof image === "object" && image.data && image.width && image.height) {
2998
+ return "data";
2999
+ }
3000
+ return null;
3001
+ }
3002
+
3003
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/svg-utils.js
3004
+ var SVG_DATA_URL_PATTERN = /^data:image\/svg\+xml/;
3005
+ var SVG_URL_PATTERN = /\.svg((\?|#).*)?$/;
3006
+ function isSVG(url) {
3007
+ return url && (SVG_DATA_URL_PATTERN.test(url) || SVG_URL_PATTERN.test(url));
3008
+ }
3009
+ function getBlobOrSVGDataUrl(arrayBuffer2, url) {
3010
+ if (isSVG(url)) {
3011
+ const textDecoder = new TextDecoder();
3012
+ let xmlText = textDecoder.decode(arrayBuffer2);
3013
+ try {
3014
+ if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
3015
+ xmlText = unescape(encodeURIComponent(xmlText));
3016
+ }
3017
+ } catch (error2) {
3018
+ throw new Error(error2.message);
3019
+ }
3020
+ const src = `data:image/svg+xml;base64,${btoa(xmlText)}`;
3021
+ return src;
3022
+ }
3023
+ return getBlob(arrayBuffer2, url);
3024
+ }
3025
+ function getBlob(arrayBuffer2, url) {
3026
+ if (isSVG(url)) {
3027
+ throw new Error("SVG cannot be parsed directly to imagebitmap");
3028
+ }
3029
+ return new Blob([new Uint8Array(arrayBuffer2)]);
3030
+ }
3031
+
3032
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image.js
3033
+ async function parseToImage(arrayBuffer2, options, url) {
3034
+ const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer2, url);
3035
+ const URL = self.URL || self.webkitURL;
3036
+ const objectUrl = typeof blobOrDataUrl !== "string" && URL.createObjectURL(blobOrDataUrl);
3037
+ try {
3038
+ return await loadToImage(objectUrl || blobOrDataUrl, options);
3039
+ } finally {
3040
+ if (objectUrl) {
3041
+ URL.revokeObjectURL(objectUrl);
3042
+ }
3043
+ }
3044
+ }
3045
+ async function loadToImage(url, options) {
3046
+ const image = new Image();
3047
+ image.src = url;
3048
+ if (options.image && options.image.decode && image.decode) {
3049
+ await image.decode();
3050
+ return image;
3051
+ }
3052
+ return await new Promise((resolve, reject) => {
3053
+ try {
3054
+ image.onload = () => resolve(image);
3055
+ image.onerror = (error2) => {
3056
+ const message2 = error2 instanceof Error ? error2.message : "error";
3057
+ reject(new Error(message2));
3058
+ };
3059
+ } catch (error2) {
3060
+ reject(error2);
3061
+ }
3062
+ });
3063
+ }
3064
+
3065
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image-bitmap.js
3066
+ var EMPTY_OBJECT = {};
3067
+ var imagebitmapOptionsSupported = true;
3068
+ async function parseToImageBitmap(arrayBuffer2, options, url) {
3069
+ let blob;
3070
+ if (isSVG(url)) {
3071
+ const image = await parseToImage(arrayBuffer2, options, url);
3072
+ blob = image;
3073
+ } else {
3074
+ blob = getBlob(arrayBuffer2, url);
3075
+ }
3076
+ const imagebitmapOptions = options && options.imagebitmap;
3077
+ return await safeCreateImageBitmap(blob, imagebitmapOptions);
3078
+ }
3079
+ async function safeCreateImageBitmap(blob) {
3080
+ let imagebitmapOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
3081
+ if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) {
3082
+ imagebitmapOptions = null;
3083
+ }
3084
+ if (imagebitmapOptions) {
3085
+ try {
3086
+ return await createImageBitmap(blob, imagebitmapOptions);
3087
+ } catch (error2) {
3088
+ console.warn(error2);
3089
+ imagebitmapOptionsSupported = false;
3090
+ }
3091
+ }
3092
+ return await createImageBitmap(blob);
3093
+ }
3094
+ function isEmptyObject(object) {
3095
+ for (const key in object || EMPTY_OBJECT) {
3096
+ return false;
3097
+ }
3098
+ return true;
3099
+ }
3100
+
3101
+ // ../../node_modules/@loaders.gl/images/dist/lib/category-api/parse-isobmff-binary.js
3102
+ function getISOBMFFMediaType(buffer) {
3103
+ if (!checkString(buffer, "ftyp", 4)) {
3104
+ return null;
3105
+ }
3106
+ if ((buffer[8] & 96) === 0) {
3107
+ return null;
3108
+ }
3109
+ return decodeMajorBrand(buffer);
3110
+ }
3111
+ function decodeMajorBrand(buffer) {
3112
+ const brandMajor = getUTF8String(buffer, 8, 12).replace("\0", " ").trim();
3113
+ switch (brandMajor) {
3114
+ case "avif":
3115
+ case "avis":
3116
+ return {
3117
+ extension: "avif",
3118
+ mimeType: "image/avif"
3119
+ };
3120
+ default:
3121
+ return null;
3122
+ }
3123
+ }
3124
+ function getUTF8String(array, start, end) {
3125
+ return String.fromCharCode(...array.slice(start, end));
3126
+ }
3127
+ function stringToBytes(string) {
3128
+ return [...string].map((character) => character.charCodeAt(0));
3129
+ }
3130
+ function checkString(buffer, header) {
3131
+ let offset = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
3132
+ const headerBytes = stringToBytes(header);
3133
+ for (let i = 0; i < headerBytes.length; ++i) {
3134
+ if (headerBytes[i] !== buffer[i + offset]) {
3135
+ return false;
3136
+ }
3137
+ }
3138
+ return true;
3139
+ }
3140
+
3141
+ // ../../node_modules/@loaders.gl/images/dist/lib/category-api/binary-image-api.js
3142
+ var BIG_ENDIAN = false;
3143
+ var LITTLE_ENDIAN = true;
3144
+ function getBinaryImageMetadata(binaryData) {
3145
+ const dataView = toDataView(binaryData);
3146
+ return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView) || getISOBMFFMetadata(dataView);
3147
+ }
3148
+ function getISOBMFFMetadata(binaryData) {
3149
+ const buffer = new Uint8Array(binaryData instanceof DataView ? binaryData.buffer : binaryData);
3150
+ const mediaType = getISOBMFFMediaType(buffer);
3151
+ if (!mediaType) {
3152
+ return null;
3153
+ }
3154
+ return {
3155
+ mimeType: mediaType.mimeType,
3156
+ width: 0,
3157
+ height: 0
3158
+ };
3159
+ }
3160
+ function getPngMetadata(binaryData) {
3161
+ const dataView = toDataView(binaryData);
3162
+ const isPng = dataView.byteLength >= 24 && dataView.getUint32(0, BIG_ENDIAN) === 2303741511;
3163
+ if (!isPng) {
3164
+ return null;
3165
+ }
3166
+ return {
3167
+ mimeType: "image/png",
3168
+ width: dataView.getUint32(16, BIG_ENDIAN),
3169
+ height: dataView.getUint32(20, BIG_ENDIAN)
3170
+ };
3171
+ }
3172
+ function getGifMetadata(binaryData) {
3173
+ const dataView = toDataView(binaryData);
3174
+ const isGif = dataView.byteLength >= 10 && dataView.getUint32(0, BIG_ENDIAN) === 1195984440;
3175
+ if (!isGif) {
3176
+ return null;
3177
+ }
3178
+ return {
3179
+ mimeType: "image/gif",
3180
+ width: dataView.getUint16(6, LITTLE_ENDIAN),
3181
+ height: dataView.getUint16(8, LITTLE_ENDIAN)
3182
+ };
3183
+ }
3184
+ function getBmpMetadata(binaryData) {
3185
+ const dataView = toDataView(binaryData);
3186
+ const isBmp = dataView.byteLength >= 14 && dataView.getUint16(0, BIG_ENDIAN) === 16973 && dataView.getUint32(2, LITTLE_ENDIAN) === dataView.byteLength;
3187
+ if (!isBmp) {
3188
+ return null;
3189
+ }
3190
+ return {
3191
+ mimeType: "image/bmp",
3192
+ width: dataView.getUint32(18, LITTLE_ENDIAN),
3193
+ height: dataView.getUint32(22, LITTLE_ENDIAN)
3194
+ };
3195
+ }
3196
+ function getJpegMetadata(binaryData) {
3197
+ const dataView = toDataView(binaryData);
3198
+ const isJpeg = dataView.byteLength >= 3 && dataView.getUint16(0, BIG_ENDIAN) === 65496 && dataView.getUint8(2) === 255;
3199
+ if (!isJpeg) {
3200
+ return null;
3201
+ }
3202
+ const {
3203
+ tableMarkers,
3204
+ sofMarkers
3205
+ } = getJpegMarkers();
3206
+ let i = 2;
3207
+ while (i + 9 < dataView.byteLength) {
3208
+ const marker = dataView.getUint16(i, BIG_ENDIAN);
3209
+ if (sofMarkers.has(marker)) {
3210
+ return {
3211
+ mimeType: "image/jpeg",
3212
+ height: dataView.getUint16(i + 5, BIG_ENDIAN),
3213
+ width: dataView.getUint16(i + 7, BIG_ENDIAN)
3214
+ };
3215
+ }
3216
+ if (!tableMarkers.has(marker)) {
3217
+ return null;
3218
+ }
3219
+ i += 2;
3220
+ i += dataView.getUint16(i, BIG_ENDIAN);
3221
+ }
3222
+ return null;
3223
+ }
3224
+ function getJpegMarkers() {
3225
+ const tableMarkers = /* @__PURE__ */ new Set([65499, 65476, 65484, 65501, 65534]);
3226
+ for (let i = 65504; i < 65520; ++i) {
3227
+ tableMarkers.add(i);
3228
+ }
3229
+ const sofMarkers = /* @__PURE__ */ new Set([65472, 65473, 65474, 65475, 65477, 65478, 65479, 65481, 65482, 65483, 65485, 65486, 65487, 65502]);
3230
+ return {
3231
+ tableMarkers,
3232
+ sofMarkers
3233
+ };
3234
+ }
3235
+ function toDataView(data) {
3236
+ if (data instanceof DataView) {
3237
+ return data;
3238
+ }
3239
+ if (ArrayBuffer.isView(data)) {
3240
+ return new DataView(data.buffer);
3241
+ }
3242
+ if (data instanceof ArrayBuffer) {
3243
+ return new DataView(data);
3244
+ }
3245
+ throw new Error("toDataView");
3246
+ }
3247
+
3248
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-node-image.js
3249
+ async function parseToNodeImage(arrayBuffer2, options) {
3250
+ var _globalThis$loaders2;
3251
+ const {
3252
+ mimeType
3253
+ } = getBinaryImageMetadata(arrayBuffer2) || {};
3254
+ const parseImageNode2 = (_globalThis$loaders2 = globalThis.loaders) === null || _globalThis$loaders2 === void 0 ? void 0 : _globalThis$loaders2.parseImageNode;
3255
+ assert4(parseImageNode2);
3256
+ return await parseImageNode2(arrayBuffer2, mimeType);
3257
+ }
3258
+
3259
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-image.js
3260
+ async function parseImage(arrayBuffer2, options, context) {
3261
+ options = options || {};
3262
+ const imageOptions = options.image || {};
3263
+ const imageType = imageOptions.type || "auto";
3264
+ const {
3265
+ url
3266
+ } = context || {};
3267
+ const loadType = getLoadableImageType(imageType);
3268
+ let image;
3269
+ switch (loadType) {
3270
+ case "imagebitmap":
3271
+ image = await parseToImageBitmap(arrayBuffer2, options, url);
3272
+ break;
3273
+ case "image":
3274
+ image = await parseToImage(arrayBuffer2, options, url);
3275
+ break;
3276
+ case "data":
3277
+ image = await parseToNodeImage(arrayBuffer2, options);
3278
+ break;
3279
+ default:
3280
+ assert4(false);
3281
+ }
3282
+ if (imageType === "data") {
3283
+ image = getImageData(image);
3284
+ }
3285
+ return image;
3286
+ }
3287
+ function getLoadableImageType(type) {
3288
+ switch (type) {
3289
+ case "auto":
3290
+ case "data":
3291
+ return getDefaultImageType();
3292
+ default:
3293
+ isImageTypeSupported(type);
3294
+ return type;
3295
+ }
3296
+ }
3297
+
3298
+ // ../../node_modules/@loaders.gl/images/dist/image-loader.js
3299
+ var EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
3300
+ var MIME_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp", "image/avif", "image/bmp", "image/vnd.microsoft.icon", "image/svg+xml"];
3301
+ var DEFAULT_IMAGE_LOADER_OPTIONS = {
3302
+ image: {
3303
+ type: "auto",
3304
+ decode: true
3305
+ }
3306
+ };
3307
+ var ImageLoader = {
3308
+ id: "image",
3309
+ module: "images",
3310
+ name: "Images",
3311
+ version: VERSION3,
3312
+ mimeTypes: MIME_TYPES,
3313
+ extensions: EXTENSIONS,
3314
+ parse: parseImage,
3315
+ tests: [(arrayBuffer2) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer2)))],
3316
+ options: DEFAULT_IMAGE_LOADER_OPTIONS
3317
+ };
3318
+
3319
+ // node_modules/@loaders.gl/textures/dist/lib/texture-api/generate-url.js
3320
+ function generateUrl(getUrl, options, urlOptions) {
3321
+ let url = typeof getUrl === "function" ? getUrl({
3322
+ ...options,
3323
+ ...urlOptions
3324
+ }) : getUrl;
3325
+ const baseUrl = options.baseUrl;
3326
+ if (baseUrl) {
3327
+ url = baseUrl[baseUrl.length - 1] === "/" ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
3328
+ }
3329
+ return resolvePath(url);
3330
+ }
3331
+
3332
+ // node_modules/@loaders.gl/textures/dist/lib/texture-api/async-deep-map.js
3333
+ var isObject = (value) => value && typeof value === "object";
3334
+ async function asyncDeepMap(tree, func) {
3335
+ let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3336
+ return await mapSubtree(tree, func, options);
3337
+ }
3338
+ async function mapSubtree(object, func, options) {
3339
+ if (Array.isArray(object)) {
3340
+ return await mapArray(object, func, options);
3341
+ }
3342
+ if (isObject(object)) {
3343
+ return await mapObject(object, func, options);
3344
+ }
3345
+ const url = object;
3346
+ return await func(url, options);
3347
+ }
3348
+ async function mapObject(object, func, options) {
3349
+ const promises = [];
3350
+ const values = {};
3351
+ for (const key in object) {
3352
+ const url = object[key];
3353
+ const promise = mapSubtree(url, func, options).then((value) => {
3354
+ values[key] = value;
3355
+ });
3356
+ promises.push(promise);
3357
+ }
3358
+ await Promise.all(promises);
3359
+ return values;
3360
+ }
3361
+ async function mapArray(urlArray, func) {
3362
+ let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3363
+ const promises = urlArray.map((url) => mapSubtree(url, func, options));
3364
+ return await Promise.all(promises);
3365
+ }
3366
+
3367
+ // node_modules/@loaders.gl/textures/dist/lib/texture-api/deep-load.js
3368
+ async function deepLoad(urlTree, load, options) {
3369
+ return await asyncDeepMap(urlTree, (url) => shallowLoad(url, load, options));
3370
+ }
3371
+ async function shallowLoad(url, load, options) {
3372
+ const response = await fetch(url, options.fetch);
3373
+ const arrayBuffer2 = await response.arrayBuffer();
3374
+ return await load(arrayBuffer2, options);
3375
+ }
3376
+
3377
+ // node_modules/@loaders.gl/textures/dist/lib/texture-api/load-image.js
3378
+ async function loadImageTexture(getUrl) {
3379
+ let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3380
+ const imageUrls = await getImageUrls(getUrl, options);
3381
+ return await deepLoad(imageUrls, ImageLoader.parse, options);
3382
+ }
3383
+ async function getImageUrls(getUrl, options) {
3384
+ let urlOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3385
+ const mipLevels = options && options.image && options.image.mipLevels || 0;
3386
+ return mipLevels !== 0 ? await getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) : generateUrl(getUrl, options, urlOptions);
3387
+ }
3388
+ async function getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) {
3389
+ const urls = [];
3390
+ if (mipLevels === "auto") {
3391
+ const url = generateUrl(getUrl, options, {
3392
+ ...urlOptions,
3393
+ lod: 0
3394
+ });
3395
+ const image = await shallowLoad(url, ImageLoader.parse, options);
3396
+ const {
3397
+ width,
3398
+ height
3399
+ } = getImageSize(image);
3400
+ mipLevels = getMipLevels({
3401
+ width,
3402
+ height
3403
+ });
3404
+ urls.push(url);
3405
+ }
3406
+ assert3(mipLevels > 0);
3407
+ for (let mipLevel = urls.length; mipLevel < mipLevels; ++mipLevel) {
3408
+ const url = generateUrl(getUrl, options, {
3409
+ ...urlOptions,
3410
+ lod: mipLevel
3411
+ });
3412
+ urls.push(url);
3413
+ }
3414
+ return urls;
3415
+ }
3416
+ function getMipLevels(size) {
3417
+ return 1 + Math.floor(Math.log2(Math.max(size.width, size.height)));
3418
+ }
3419
+
3420
+ // src/pbr/pbr-environment.ts
3421
+ function loadPBREnvironment(device, props) {
3422
+ const brdfLutTexture = device.createTexture({
3423
+ id: "brdfLUT",
3424
+ sampler: {
3425
+ wrapS: "clamp-to-edge",
3426
+ wrapT: "clamp-to-edge",
3427
+ minFilter: "linear",
3428
+ maxFilter: "linear"
3429
+ },
3430
+ data: loadImageTexture(props.brdfLutUrl)
3431
+ });
3432
+ const diffuseEnvSampler = makeCube(device, {
3433
+ id: "DiffuseEnvSampler",
3434
+ getTextureForFace: (dir) => loadImageTexture(props.getTexUrl("diffuse", dir, 0)),
3435
+ sampler: {
3436
+ wrapS: "clamp-to-edge",
3437
+ wrapT: "clamp-to-edge",
3438
+ minFilter: "linear",
3439
+ maxFilter: "linear"
3440
+ }
3441
+ });
3442
+ const specularEnvSampler = makeCube(device, {
3443
+ id: "SpecularEnvSampler",
3444
+ getTextureForFace: (dir) => {
3445
+ const imageArray = [];
3446
+ for (let lod = 0; lod <= props.specularMipLevels - 1; lod++) {
3447
+ imageArray.push(loadImageTexture(props.getTexUrl("specular", dir, lod)));
3448
+ }
3449
+ return imageArray;
3450
+ },
3451
+ sampler: {
3452
+ wrapS: "clamp-to-edge",
3453
+ wrapT: "clamp-to-edge",
3454
+ minFilter: "linear",
3455
+ maxFilter: "linear"
3456
+ }
3457
+ });
3458
+ return {
3459
+ brdfLutTexture,
3460
+ diffuseEnvSampler,
3461
+ specularEnvSampler
3462
+ };
3463
+ }
3464
+ var FACES = [0, 1, 2, 3, 4, 5];
3465
+ function makeCube(device, {
3466
+ id,
3467
+ getTextureForFace,
3468
+ sampler
3469
+ }) {
3470
+ const data = {};
3471
+ FACES.forEach((face) => {
3472
+ data[String(face)] = getTextureForFace(face);
3473
+ });
3474
+ return device.createTexture({
3475
+ id,
3476
+ dimension: "cube",
3477
+ mipmaps: false,
3478
+ sampler,
3479
+ data
3480
+ });
3481
+ }
3482
+
2853
3483
  // ../shadertools/src/lib/glsl-utils/highlight.ts
2854
3484
  var glsl = (x) => `${x}`;
2855
3485
 
2856
3486
  // ../shadertools/src/lib/utils/assert.ts
2857
- function assert3(condition, message2) {
3487
+ function assert5(condition, message2) {
2858
3488
  if (!condition) {
2859
3489
  throw new Error(message2 || "shadertools: assertion failed.");
2860
3490
  }
@@ -2887,7 +3517,7 @@ ${htmlLog}
2887
3517
  for (const [key, propsValidator] of Object.entries(propValidators)) {
2888
3518
  if (properties && key in properties && !propsValidator.private) {
2889
3519
  if (propsValidator.validate) {
2890
- assert3(propsValidator.validate(properties[key], propsValidator), `${errorMessage}: invalid ${key}`);
3520
+ assert5(propsValidator.validate(properties[key], propsValidator), `${errorMessage}: invalid ${key}`);
2891
3521
  }
2892
3522
  validated[key] = properties[key];
2893
3523
  } else {
@@ -3071,7 +3701,7 @@ ${htmlLog}
3071
3701
  if (module instanceof ShaderModuleInstance) {
3072
3702
  return module;
3073
3703
  }
3074
- assert3(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`);
3704
+ assert5(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`);
3075
3705
  if (!module.name) {
3076
3706
  console.warn("shader module has no name");
3077
3707
  module.name = `shader-module-${index++}`;
@@ -3093,7 +3723,7 @@ ${htmlLog}
3093
3723
  defines = {},
3094
3724
  inject = {}
3095
3725
  } = props;
3096
- assert3(typeof name2 === "string");
3726
+ assert5(typeof name2 === "string");
3097
3727
  this.name = name2;
3098
3728
  this.vs = vs3;
3099
3729
  this.fs = fs3;
@@ -3116,7 +3746,7 @@ ${htmlLog}
3116
3746
  moduleSource = this.fs || "";
3117
3747
  break;
3118
3748
  default:
3119
- assert3(false);
3749
+ assert5(false);
3120
3750
  }
3121
3751
  const moduleName = this.name.toUpperCase().replace(/[^0-9a-z]/gi, "_");
3122
3752
  return `// ----- MODULE ${this.name} ---------------
@@ -3165,7 +3795,7 @@ ${moduleSource}
3165
3795
  const propDef = propTypes[key];
3166
3796
  if (key in opts && !propDef.private) {
3167
3797
  if (propDef.validate) {
3168
- assert3(propDef.validate(opts[key], propDef), `${this.name}: invalid ${key}`);
3798
+ assert5(propDef.validate(opts[key], propDef), `${this.name}: invalid ${key}`);
3169
3799
  }
3170
3800
  uniforms[key] = opts[key];
3171
3801
  } else {
@@ -3529,7 +4159,7 @@ precision highp float;
3529
4159
  inject = {},
3530
4160
  log: log3
3531
4161
  } = options;
3532
- assert3(typeof source === "string", "shader source must be a string");
4162
+ assert5(typeof source === "string", "shader source must be a string");
3533
4163
  const coreSource = source;
3534
4164
  const allDefines = {};
3535
4165
  modules.forEach((module) => {
@@ -3603,7 +4233,7 @@ precision highp float;
3603
4233
  prologue = true,
3604
4234
  log: log3
3605
4235
  } = options;
3606
- assert3(typeof source === "string", "shader source must be a string");
4236
+ assert5(typeof source === "string", "shader source must be a string");
3607
4237
  const sourceVersion = language === "glsl" ? getShaderInfo2(source).version : -1;
3608
4238
  const targetVersion = platformInfo.shaderLanguageVersion;
3609
4239
  const sourceVersionDirective = sourceVersion === 100 ? "#version 100" : "#version 300 es";
@@ -4127,7 +4757,7 @@ ${getApplicationDefines(allDefines)}
4127
4757
  }
4128
4758
 
4129
4759
  // ../../node_modules/@math.gl/core/dist/lib/assert.js
4130
- function assert4(condition, message2) {
4760
+ function assert6(condition, message2) {
4131
4761
  if (!condition) {
4132
4762
  throw new Error("math.gl assertion ".concat(message2));
4133
4763
  }
@@ -4216,11 +4846,11 @@ ${getApplicationDefines(allDefines)}
4216
4846
  return this.distanceSquared(vector);
4217
4847
  }
4218
4848
  getComponent(i) {
4219
- assert4(i >= 0 && i < this.ELEMENTS, "index is out of range");
4849
+ assert6(i >= 0 && i < this.ELEMENTS, "index is out of range");
4220
4850
  return checkNumber(this[i]);
4221
4851
  }
4222
4852
  setComponent(i, value) {
4223
- assert4(i >= 0 && i < this.ELEMENTS, "index is out of range");
4853
+ assert6(i >= 0 && i < this.ELEMENTS, "index is out of range");
4224
4854
  this[i] = value;
4225
4855
  return this.check();
4226
4856
  }
@@ -6985,6 +7615,10 @@ vec4 pbr_filterColor(vec4 colorUnused)
6985
7615
  const moduleName = name2;
6986
7616
  const moduleProps = props[moduleName];
6987
7617
  const module = this.modules[moduleName];
7618
+ if (!module) {
7619
+ log.warn(`Module ${name2} not found`)();
7620
+ continue;
7621
+ }
6988
7622
  const oldUniforms = this.moduleUniforms[moduleName];
6989
7623
  const uniforms = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || moduleProps;
6990
7624
  this.moduleUniforms[moduleName] = {
@@ -7203,6 +7837,8 @@ vec4 pbr_filterColor(vec4 colorUnused)
7203
7837
  });
7204
7838
 
7205
7839
  // ../engine/src/model/model.ts
7840
+ var LOG_DRAW_PRIORITY = 2;
7841
+ var LOG_DRAW_TIMEOUT = 1e4;
7206
7842
  var _Model = class {
7207
7843
  userData = {};
7208
7844
  instanceCount = 0;
@@ -7298,16 +7934,21 @@ vec4 pbr_filterColor(vec4 colorUnused)
7298
7934
  }
7299
7935
  draw(renderPass) {
7300
7936
  this.predraw();
7301
- this.pipeline = this._updatePipeline();
7302
- this.pipeline.setBindings(this.bindings);
7303
- this.pipeline.setUniforms(this.uniforms);
7304
- this.pipeline.draw({
7305
- renderPass,
7306
- vertexArray: this.vertexArray,
7307
- vertexCount: this.vertexCount,
7308
- instanceCount: this.instanceCount,
7309
- transformFeedback: this.transformFeedback
7310
- });
7937
+ try {
7938
+ this._logDrawCallStart();
7939
+ this.pipeline = this._updatePipeline();
7940
+ this.pipeline.setBindings(this.bindings);
7941
+ this.pipeline.setUniforms(this.uniforms);
7942
+ this.pipeline.draw({
7943
+ renderPass,
7944
+ vertexArray: this.vertexArray,
7945
+ vertexCount: this.vertexCount,
7946
+ instanceCount: this.instanceCount,
7947
+ transformFeedback: this.transformFeedback
7948
+ });
7949
+ } finally {
7950
+ this._logDrawCallEnd();
7951
+ }
7311
7952
  }
7312
7953
  setGeometry(geometry) {
7313
7954
  const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);
@@ -7448,6 +8089,27 @@ vec4 pbr_filterColor(vec4 colorUnused)
7448
8089
  }
7449
8090
  return this.pipeline;
7450
8091
  }
8092
+ _lastLogTime = 0;
8093
+ _logOpen = false;
8094
+ _logDrawCallStart() {
8095
+ const logDrawTimeout = log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
8096
+ if (Date.now() - this._lastLogTime < logDrawTimeout) {
8097
+ return void 0;
8098
+ }
8099
+ this._lastLogTime = Date.now();
8100
+ this._logOpen = true;
8101
+ log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, {
8102
+ collapsed: log.level <= 2
8103
+ })();
8104
+ }
8105
+ _logDrawCallEnd() {
8106
+ if (this._logOpen) {
8107
+ const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout);
8108
+ log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
8109
+ log.groupEnd(LOG_DRAW_PRIORITY)();
8110
+ this._logOpen = false;
8111
+ }
8112
+ }
7451
8113
  };
7452
8114
  var Model = _Model;
7453
8115
  __publicField(Model, "defaultProps", {
@@ -7916,7 +8578,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
7916
8578
  this.cached = [this.size, this.type, this.normalized, this.stride, this.offset].join(":");
7917
8579
  };
7918
8580
  var OESVertexArrayObject = function OESVertexArrayObject2(gl) {
7919
- const self = this;
8581
+ const self2 = this;
7920
8582
  this.gl = gl;
7921
8583
  wrapGLError(gl);
7922
8584
  const original = this.original = {
@@ -7928,23 +8590,23 @@ vec4 pbr_filterColor(vec4 colorUnused)
7928
8590
  vertexAttribPointer: gl.vertexAttribPointer
7929
8591
  };
7930
8592
  gl.getParameter = function getParameter(pname) {
7931
- if (pname === self.VERTEX_ARRAY_BINDING_OES) {
7932
- if (self.currentVertexArrayObject === self.defaultVertexArrayObject) {
8593
+ if (pname === self2.VERTEX_ARRAY_BINDING_OES) {
8594
+ if (self2.currentVertexArrayObject === self2.defaultVertexArrayObject) {
7933
8595
  return null;
7934
8596
  }
7935
- return self.currentVertexArrayObject;
8597
+ return self2.currentVertexArrayObject;
7936
8598
  }
7937
8599
  return original.getParameter.apply(this, arguments);
7938
8600
  };
7939
8601
  gl.enableVertexAttribArray = function enableVertexAttribArray(index2) {
7940
- const vao = self.currentVertexArrayObject;
8602
+ const vao = self2.currentVertexArrayObject;
7941
8603
  vao.maxAttrib = Math.max(vao.maxAttrib, index2);
7942
8604
  const attrib = vao.attribs[index2];
7943
8605
  attrib.enabled = true;
7944
8606
  return original.enableVertexAttribArray.apply(this, arguments);
7945
8607
  };
7946
8608
  gl.disableVertexAttribArray = function disableVertexAttribArray(index2) {
7947
- const vao = self.currentVertexArrayObject;
8609
+ const vao = self2.currentVertexArrayObject;
7948
8610
  vao.maxAttrib = Math.max(vao.maxAttrib, index2);
7949
8611
  const attrib = vao.attribs[index2];
7950
8612
  attrib.enabled = false;
@@ -7953,17 +8615,17 @@ vec4 pbr_filterColor(vec4 colorUnused)
7953
8615
  gl.bindBuffer = function bindBuffer2(target, buffer) {
7954
8616
  switch (target) {
7955
8617
  case gl.ARRAY_BUFFER:
7956
- self.currentArrayBuffer = buffer;
8618
+ self2.currentArrayBuffer = buffer;
7957
8619
  break;
7958
8620
  case gl.ELEMENT_ARRAY_BUFFER:
7959
- self.currentVertexArrayObject.elementArrayBuffer = buffer;
8621
+ self2.currentVertexArrayObject.elementArrayBuffer = buffer;
7960
8622
  break;
7961
8623
  default:
7962
8624
  }
7963
8625
  return original.bindBuffer.apply(this, arguments);
7964
8626
  };
7965
8627
  gl.getVertexAttrib = function getVertexAttrib(index2, pname) {
7966
- const vao = self.currentVertexArrayObject;
8628
+ const vao = self2.currentVertexArrayObject;
7967
8629
  const attrib = vao.attribs[index2];
7968
8630
  switch (pname) {
7969
8631
  case gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
@@ -7983,10 +8645,10 @@ vec4 pbr_filterColor(vec4 colorUnused)
7983
8645
  }
7984
8646
  };
7985
8647
  gl.vertexAttribPointer = function vertexAttribPointer(indx, size, type, normalized, stride, offset) {
7986
- const vao = self.currentVertexArrayObject;
8648
+ const vao = self2.currentVertexArrayObject;
7987
8649
  vao.maxAttrib = Math.max(vao.maxAttrib, indx);
7988
8650
  const attrib = vao.attribs[indx];
7989
- attrib.buffer = self.currentArrayBuffer;
8651
+ attrib.buffer = self2.currentArrayBuffer;
7990
8652
  attrib.size = size;
7991
8653
  attrib.type = type;
7992
8654
  attrib.normalized = normalized;
@@ -8001,7 +8663,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
8001
8663
  if (gl.canvas) {
8002
8664
  gl.canvas.addEventListener("webglcontextrestored", () => {
8003
8665
  log2("OESVertexArrayObject emulation library context restored");
8004
- self.reset_();
8666
+ self2.reset_();
8005
8667
  }, true);
8006
8668
  }
8007
8669
  this.reset_();
@@ -9064,8 +9726,8 @@ vec4 pbr_filterColor(vec4 colorUnused)
9064
9726
  }
9065
9727
  function initializeExtensions(gl) {
9066
9728
  const contextState = getContextData(gl);
9067
- const EXTENSIONS = gl.getSupportedExtensions() || [];
9068
- for (const extensionName of EXTENSIONS) {
9729
+ const EXTENSIONS2 = gl.getSupportedExtensions() || [];
9730
+ for (const extensionName of EXTENSIONS2) {
9069
9731
  const extension = gl.getExtension(extensionName);
9070
9732
  contextState._extensions[extensionName] = extension;
9071
9733
  }
@@ -13286,14 +13948,14 @@ ${source2}`;
13286
13948
  };
13287
13949
  }
13288
13950
  const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
13289
- const matches = UNIFORM_NAME_REGEXP.exec(name2);
13290
- if (!matches || matches.length < 2) {
13951
+ const matches2 = UNIFORM_NAME_REGEXP.exec(name2);
13952
+ if (!matches2 || matches2.length < 2) {
13291
13953
  throw new Error(`Failed to parse GLSL uniform name ${name2}`);
13292
13954
  }
13293
13955
  return {
13294
- name: matches[1],
13295
- length: matches[2] ? 1 : 0,
13296
- isArray: Boolean(matches[2])
13956
+ name: matches2[1],
13957
+ length: matches2[2] ? 1 : 0,
13958
+ isArray: Boolean(matches2[2])
13297
13959
  };
13298
13960
  }
13299
13961