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

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
 
@@ -594,7 +595,7 @@ var __exports__ = (() => {
594
595
  id: "@probe.gl/log"
595
596
  });
596
597
 
597
- // ../core/src/lib/utils/log.ts
598
+ // ../core/src/utils/log.ts
598
599
  var log = new Log({
599
600
  id: "luma.gl"
600
601
  });
@@ -790,7 +791,7 @@ var __exports__ = (() => {
790
791
  }
791
792
  };
792
793
 
793
- // ../core/src/lib/utils/stats-manager.ts
794
+ // ../core/src/utils/stats-manager.ts
794
795
  var StatsManager = class {
795
796
  stats = /* @__PURE__ */ new Map();
796
797
  getStats(name2) {
@@ -809,27 +810,27 @@ 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__ : "running from 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, `${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
 
832
- // ../core/src/lib/utils/is-array.ts
833
+ // ../core/src/utils/is-array.ts
833
834
  function isTypedArray(value) {
834
835
  return ArrayBuffer.isView(value) && !(value instanceof DataView) ? value : null;
835
836
  }
@@ -840,7 +841,7 @@ var __exports__ = (() => {
840
841
  return isTypedArray(value);
841
842
  }
842
843
 
843
- // ../core/src/lib/utils/utils.ts
844
+ // ../core/src/utils/utils.ts
844
845
  var uidCounters = {};
845
846
  function uid(id = "id") {
846
847
  uidCounters[id] = uidCounters[id] || 1;
@@ -1078,6 +1079,13 @@ var __exports__ = (() => {
1078
1079
  });
1079
1080
  __publicField(Device, "VERSION", VERSION2);
1080
1081
 
1082
+ // ../core/src/utils/assert.ts
1083
+ function assert2(condition, message2) {
1084
+ if (!condition) {
1085
+ throw new Error(message2 || "luma.gl: assertion failed.");
1086
+ }
1087
+ }
1088
+
1081
1089
  // ../core/src/adapter/canvas-context.ts
1082
1090
  var isPage = isBrowser() && typeof document !== "undefined";
1083
1091
  var isPageLoaded = () => isPage && document.readyState === "complete";
@@ -1502,7 +1510,10 @@ ${htmlLog}
1502
1510
  button.style.width = "100%";
1503
1511
  button.style.textAlign = "left";
1504
1512
  document.body.appendChild(button);
1505
- document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView();
1513
+ const errors = document.getElementsByClassName("luma-compiler-log-error");
1514
+ if (errors[0]?.scrollIntoView) {
1515
+ errors[0].scrollIntoView();
1516
+ }
1506
1517
  button.onclick = () => {
1507
1518
  const dataURI = `data:text/plain,${encodeURIComponent(this.source)}`;
1508
1519
  navigator.clipboard.writeText(dataURI);
@@ -2023,13 +2034,6 @@ ${htmlLog}
2023
2034
  buffers: {}
2024
2035
  });
2025
2036
 
2026
- // ../core/src/lib/utils/assert.ts
2027
- function assert2(condition, message2) {
2028
- if (!condition) {
2029
- throw new Error(message2 || "luma.gl: assertion failed.");
2030
- }
2031
- }
2032
-
2033
2037
  // ../core/src/adapter/type-utils/decode-shader-types.ts
2034
2038
  var UNIFORM_FORMATS = {
2035
2039
  "f32": {
@@ -2133,7 +2137,7 @@ ${htmlLog}
2133
2137
  }
2134
2138
  }
2135
2139
 
2136
- // ../core/src/lib/utils/array-utils-flat.ts
2140
+ // ../core/src/utils/array-utils-flat.ts
2137
2141
  var arrayBuffer;
2138
2142
  function getScratchArrayBuffer(byteLength) {
2139
2143
  if (!arrayBuffer || arrayBuffer.byteLength < byteLength) {
@@ -2242,7 +2246,7 @@ ${htmlLog}
2242
2246
  }
2243
2247
  };
2244
2248
 
2245
- // ../core/src/lib/utils/array-equal.ts
2249
+ // ../core/src/utils/array-equal.ts
2246
2250
  function arrayEqual(a, b, limit = 16) {
2247
2251
  if (a !== b) {
2248
2252
  return false;
@@ -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);
@@ -2554,12 +2558,12 @@ ${htmlLog}
2554
2558
  return `${dataType}x${components}`;
2555
2559
  }
2556
2560
 
2557
- // ../core/src/lib/utils/cast.ts
2561
+ // ../core/src/utils/cast.ts
2558
2562
  function cast(value) {
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
  }
@@ -2579,7 +2583,7 @@ ${htmlLog}
2579
2583
  return result;
2580
2584
  }
2581
2585
 
2582
- // ../core/src/lib/utils/stub-methods.ts
2586
+ // ../core/src/utils/stub-methods.ts
2583
2587
  function stubRemovedMethods(instance, className, version, methodNames) {
2584
2588
  const upgradeMessage = `See luma.gl ${version} Upgrade Guide at https://luma.gl/docs/upgrade-guide`;
2585
2589
  const prototype = Object.getPrototypeOf(instance);
@@ -2594,7 +2598,7 @@ ${htmlLog}
2594
2598
  });
2595
2599
  }
2596
2600
 
2597
- // ../core/src/lib/utils/check-props.ts
2601
+ // ../core/src/utils/check-props.ts
2598
2602
  function checkProps(className, props, propChecks) {
2599
2603
  const {
2600
2604
  removedProps = {},
@@ -2626,7 +2630,7 @@ ${htmlLog}
2626
2630
  return newProps || props;
2627
2631
  }
2628
2632
 
2629
- // ../core/src/lib/utils/load-file.ts
2633
+ // ../core/src/utils/load-file.ts
2630
2634
  var pathPrefix = "";
2631
2635
  async function loadImage(url, opts) {
2632
2636
  return new Promise((resolve, reject) => {
@@ -2659,7 +2663,7 @@ ${htmlLog}
2659
2663
  });
2660
2664
  }
2661
2665
 
2662
- // ../core/src/lib/utils/deep-equal.ts
2666
+ // ../core/src/utils/deep-equal.ts
2663
2667
  function deepEqual(a, b, depth) {
2664
2668
  if (a === b) {
2665
2669
  return true;
@@ -2850,11 +2854,616 @@ ${htmlLog}
2850
2854
  parsedMaterial.generatedTextures.push(texture);
2851
2855
  }
2852
2856
 
2857
+ // node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/assert.js
2858
+ function assert3(condition, message2) {
2859
+ if (!condition) {
2860
+ throw new Error(message2 || "loader assertion failed.");
2861
+ }
2862
+ }
2863
+
2864
+ // node_modules/@loaders.gl/loader-utils/dist/lib/path-utils/file-aliases.js
2865
+ var pathPrefix2 = "";
2866
+ var fileAliases = {};
2867
+ function resolvePath(filename) {
2868
+ for (const alias in fileAliases) {
2869
+ if (filename.startsWith(alias)) {
2870
+ const replacement = fileAliases[alias];
2871
+ filename = filename.replace(alias, replacement);
2872
+ }
2873
+ }
2874
+ if (!filename.startsWith("http://") && !filename.startsWith("https://")) {
2875
+ filename = `${pathPrefix2}${filename}`;
2876
+ }
2877
+ return filename;
2878
+ }
2879
+
2880
+ // ../../node_modules/@loaders.gl/images/dist/lib/utils/version.js
2881
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2882
+
2883
+ // ../../node_modules/@loaders.gl/images/node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/assert.js
2884
+ function assert4(condition, message2) {
2885
+ if (!condition) {
2886
+ throw new Error(message2 || "loader assertion failed.");
2887
+ }
2888
+ }
2889
+
2890
+ // ../../node_modules/@loaders.gl/images/node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/globals.js
2891
+ var globals = {
2892
+ self: typeof self !== "undefined" && self,
2893
+ window: typeof window !== "undefined" && window,
2894
+ global: typeof global !== "undefined" && global,
2895
+ document: typeof document !== "undefined" && document
2896
+ };
2897
+ var self_2 = globals.self || globals.window || globals.global || {};
2898
+ var window_2 = globals.window || globals.self || globals.global || {};
2899
+ var global_2 = globals.global || globals.self || globals.window || {};
2900
+ var document_2 = globals.document || {};
2901
+ var isBrowser3 = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
2902
+ var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
2903
+ var nodeVersion = matches && parseFloat(matches[1]) || 0;
2904
+
2905
+ // ../../node_modules/@loaders.gl/images/dist/lib/category-api/image-type.js
2906
+ var _globalThis$loaders;
2907
+ var parseImageNode = (_globalThis$loaders = globalThis.loaders) === null || _globalThis$loaders === void 0 ? void 0 : _globalThis$loaders.parseImageNode;
2908
+ var IMAGE_SUPPORTED = typeof Image !== "undefined";
2909
+ var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
2910
+ var NODE_IMAGE_SUPPORTED = Boolean(parseImageNode);
2911
+ var DATA_SUPPORTED = isBrowser3 ? true : NODE_IMAGE_SUPPORTED;
2912
+ function isImageTypeSupported(type) {
2913
+ switch (type) {
2914
+ case "auto":
2915
+ return IMAGE_BITMAP_SUPPORTED || IMAGE_SUPPORTED || DATA_SUPPORTED;
2916
+ case "imagebitmap":
2917
+ return IMAGE_BITMAP_SUPPORTED;
2918
+ case "image":
2919
+ return IMAGE_SUPPORTED;
2920
+ case "data":
2921
+ return DATA_SUPPORTED;
2922
+ default:
2923
+ throw new Error(`@loaders.gl/images: image ${type} not supported in this environment`);
2924
+ }
2925
+ }
2926
+ function getDefaultImageType() {
2927
+ if (IMAGE_BITMAP_SUPPORTED) {
2928
+ return "imagebitmap";
2929
+ }
2930
+ if (IMAGE_SUPPORTED) {
2931
+ return "image";
2932
+ }
2933
+ if (DATA_SUPPORTED) {
2934
+ return "data";
2935
+ }
2936
+ throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");
2937
+ }
2938
+
2939
+ // ../../node_modules/@loaders.gl/images/dist/lib/category-api/parsed-image-api.js
2940
+ function getImageType(image) {
2941
+ const format = getImageTypeOrNull(image);
2942
+ if (!format) {
2943
+ throw new Error("Not an image");
2944
+ }
2945
+ return format;
2946
+ }
2947
+ function getImageSize(image) {
2948
+ return getImageData(image);
2949
+ }
2950
+ function getImageData(image) {
2951
+ switch (getImageType(image)) {
2952
+ case "data":
2953
+ return image;
2954
+ case "image":
2955
+ case "imagebitmap":
2956
+ const canvas = document.createElement("canvas");
2957
+ const context = canvas.getContext("2d");
2958
+ if (!context) {
2959
+ throw new Error("getImageData");
2960
+ }
2961
+ canvas.width = image.width;
2962
+ canvas.height = image.height;
2963
+ context.drawImage(image, 0, 0);
2964
+ return context.getImageData(0, 0, image.width, image.height);
2965
+ default:
2966
+ throw new Error("getImageData");
2967
+ }
2968
+ }
2969
+ function getImageTypeOrNull(image) {
2970
+ if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
2971
+ return "imagebitmap";
2972
+ }
2973
+ if (typeof Image !== "undefined" && image instanceof Image) {
2974
+ return "image";
2975
+ }
2976
+ if (image && typeof image === "object" && image.data && image.width && image.height) {
2977
+ return "data";
2978
+ }
2979
+ return null;
2980
+ }
2981
+
2982
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/svg-utils.js
2983
+ var SVG_DATA_URL_PATTERN = /^data:image\/svg\+xml/;
2984
+ var SVG_URL_PATTERN = /\.svg((\?|#).*)?$/;
2985
+ function isSVG(url) {
2986
+ return url && (SVG_DATA_URL_PATTERN.test(url) || SVG_URL_PATTERN.test(url));
2987
+ }
2988
+ function getBlobOrSVGDataUrl(arrayBuffer2, url) {
2989
+ if (isSVG(url)) {
2990
+ const textDecoder = new TextDecoder();
2991
+ let xmlText = textDecoder.decode(arrayBuffer2);
2992
+ try {
2993
+ if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
2994
+ xmlText = unescape(encodeURIComponent(xmlText));
2995
+ }
2996
+ } catch (error2) {
2997
+ throw new Error(error2.message);
2998
+ }
2999
+ const src = `data:image/svg+xml;base64,${btoa(xmlText)}`;
3000
+ return src;
3001
+ }
3002
+ return getBlob(arrayBuffer2, url);
3003
+ }
3004
+ function getBlob(arrayBuffer2, url) {
3005
+ if (isSVG(url)) {
3006
+ throw new Error("SVG cannot be parsed directly to imagebitmap");
3007
+ }
3008
+ return new Blob([new Uint8Array(arrayBuffer2)]);
3009
+ }
3010
+
3011
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image.js
3012
+ async function parseToImage(arrayBuffer2, options, url) {
3013
+ const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer2, url);
3014
+ const URL = self.URL || self.webkitURL;
3015
+ const objectUrl = typeof blobOrDataUrl !== "string" && URL.createObjectURL(blobOrDataUrl);
3016
+ try {
3017
+ return await loadToImage(objectUrl || blobOrDataUrl, options);
3018
+ } finally {
3019
+ if (objectUrl) {
3020
+ URL.revokeObjectURL(objectUrl);
3021
+ }
3022
+ }
3023
+ }
3024
+ async function loadToImage(url, options) {
3025
+ const image = new Image();
3026
+ image.src = url;
3027
+ if (options.image && options.image.decode && image.decode) {
3028
+ await image.decode();
3029
+ return image;
3030
+ }
3031
+ return await new Promise((resolve, reject) => {
3032
+ try {
3033
+ image.onload = () => resolve(image);
3034
+ image.onerror = (error2) => {
3035
+ const message2 = error2 instanceof Error ? error2.message : "error";
3036
+ reject(new Error(message2));
3037
+ };
3038
+ } catch (error2) {
3039
+ reject(error2);
3040
+ }
3041
+ });
3042
+ }
3043
+
3044
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image-bitmap.js
3045
+ var EMPTY_OBJECT = {};
3046
+ var imagebitmapOptionsSupported = true;
3047
+ async function parseToImageBitmap(arrayBuffer2, options, url) {
3048
+ let blob;
3049
+ if (isSVG(url)) {
3050
+ const image = await parseToImage(arrayBuffer2, options, url);
3051
+ blob = image;
3052
+ } else {
3053
+ blob = getBlob(arrayBuffer2, url);
3054
+ }
3055
+ const imagebitmapOptions = options && options.imagebitmap;
3056
+ return await safeCreateImageBitmap(blob, imagebitmapOptions);
3057
+ }
3058
+ async function safeCreateImageBitmap(blob) {
3059
+ let imagebitmapOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
3060
+ if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) {
3061
+ imagebitmapOptions = null;
3062
+ }
3063
+ if (imagebitmapOptions) {
3064
+ try {
3065
+ return await createImageBitmap(blob, imagebitmapOptions);
3066
+ } catch (error2) {
3067
+ console.warn(error2);
3068
+ imagebitmapOptionsSupported = false;
3069
+ }
3070
+ }
3071
+ return await createImageBitmap(blob);
3072
+ }
3073
+ function isEmptyObject(object) {
3074
+ for (const key in object || EMPTY_OBJECT) {
3075
+ return false;
3076
+ }
3077
+ return true;
3078
+ }
3079
+
3080
+ // ../../node_modules/@loaders.gl/images/dist/lib/category-api/parse-isobmff-binary.js
3081
+ function getISOBMFFMediaType(buffer) {
3082
+ if (!checkString(buffer, "ftyp", 4)) {
3083
+ return null;
3084
+ }
3085
+ if ((buffer[8] & 96) === 0) {
3086
+ return null;
3087
+ }
3088
+ return decodeMajorBrand(buffer);
3089
+ }
3090
+ function decodeMajorBrand(buffer) {
3091
+ const brandMajor = getUTF8String(buffer, 8, 12).replace("\0", " ").trim();
3092
+ switch (brandMajor) {
3093
+ case "avif":
3094
+ case "avis":
3095
+ return {
3096
+ extension: "avif",
3097
+ mimeType: "image/avif"
3098
+ };
3099
+ default:
3100
+ return null;
3101
+ }
3102
+ }
3103
+ function getUTF8String(array, start, end) {
3104
+ return String.fromCharCode(...array.slice(start, end));
3105
+ }
3106
+ function stringToBytes(string) {
3107
+ return [...string].map((character) => character.charCodeAt(0));
3108
+ }
3109
+ function checkString(buffer, header) {
3110
+ let offset = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
3111
+ const headerBytes = stringToBytes(header);
3112
+ for (let i = 0; i < headerBytes.length; ++i) {
3113
+ if (headerBytes[i] !== buffer[i + offset]) {
3114
+ return false;
3115
+ }
3116
+ }
3117
+ return true;
3118
+ }
3119
+
3120
+ // ../../node_modules/@loaders.gl/images/dist/lib/category-api/binary-image-api.js
3121
+ var BIG_ENDIAN = false;
3122
+ var LITTLE_ENDIAN = true;
3123
+ function getBinaryImageMetadata(binaryData) {
3124
+ const dataView = toDataView(binaryData);
3125
+ return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView) || getISOBMFFMetadata(dataView);
3126
+ }
3127
+ function getISOBMFFMetadata(binaryData) {
3128
+ const buffer = new Uint8Array(binaryData instanceof DataView ? binaryData.buffer : binaryData);
3129
+ const mediaType = getISOBMFFMediaType(buffer);
3130
+ if (!mediaType) {
3131
+ return null;
3132
+ }
3133
+ return {
3134
+ mimeType: mediaType.mimeType,
3135
+ width: 0,
3136
+ height: 0
3137
+ };
3138
+ }
3139
+ function getPngMetadata(binaryData) {
3140
+ const dataView = toDataView(binaryData);
3141
+ const isPng = dataView.byteLength >= 24 && dataView.getUint32(0, BIG_ENDIAN) === 2303741511;
3142
+ if (!isPng) {
3143
+ return null;
3144
+ }
3145
+ return {
3146
+ mimeType: "image/png",
3147
+ width: dataView.getUint32(16, BIG_ENDIAN),
3148
+ height: dataView.getUint32(20, BIG_ENDIAN)
3149
+ };
3150
+ }
3151
+ function getGifMetadata(binaryData) {
3152
+ const dataView = toDataView(binaryData);
3153
+ const isGif = dataView.byteLength >= 10 && dataView.getUint32(0, BIG_ENDIAN) === 1195984440;
3154
+ if (!isGif) {
3155
+ return null;
3156
+ }
3157
+ return {
3158
+ mimeType: "image/gif",
3159
+ width: dataView.getUint16(6, LITTLE_ENDIAN),
3160
+ height: dataView.getUint16(8, LITTLE_ENDIAN)
3161
+ };
3162
+ }
3163
+ function getBmpMetadata(binaryData) {
3164
+ const dataView = toDataView(binaryData);
3165
+ const isBmp = dataView.byteLength >= 14 && dataView.getUint16(0, BIG_ENDIAN) === 16973 && dataView.getUint32(2, LITTLE_ENDIAN) === dataView.byteLength;
3166
+ if (!isBmp) {
3167
+ return null;
3168
+ }
3169
+ return {
3170
+ mimeType: "image/bmp",
3171
+ width: dataView.getUint32(18, LITTLE_ENDIAN),
3172
+ height: dataView.getUint32(22, LITTLE_ENDIAN)
3173
+ };
3174
+ }
3175
+ function getJpegMetadata(binaryData) {
3176
+ const dataView = toDataView(binaryData);
3177
+ const isJpeg = dataView.byteLength >= 3 && dataView.getUint16(0, BIG_ENDIAN) === 65496 && dataView.getUint8(2) === 255;
3178
+ if (!isJpeg) {
3179
+ return null;
3180
+ }
3181
+ const {
3182
+ tableMarkers,
3183
+ sofMarkers
3184
+ } = getJpegMarkers();
3185
+ let i = 2;
3186
+ while (i + 9 < dataView.byteLength) {
3187
+ const marker = dataView.getUint16(i, BIG_ENDIAN);
3188
+ if (sofMarkers.has(marker)) {
3189
+ return {
3190
+ mimeType: "image/jpeg",
3191
+ height: dataView.getUint16(i + 5, BIG_ENDIAN),
3192
+ width: dataView.getUint16(i + 7, BIG_ENDIAN)
3193
+ };
3194
+ }
3195
+ if (!tableMarkers.has(marker)) {
3196
+ return null;
3197
+ }
3198
+ i += 2;
3199
+ i += dataView.getUint16(i, BIG_ENDIAN);
3200
+ }
3201
+ return null;
3202
+ }
3203
+ function getJpegMarkers() {
3204
+ const tableMarkers = /* @__PURE__ */ new Set([65499, 65476, 65484, 65501, 65534]);
3205
+ for (let i = 65504; i < 65520; ++i) {
3206
+ tableMarkers.add(i);
3207
+ }
3208
+ const sofMarkers = /* @__PURE__ */ new Set([65472, 65473, 65474, 65475, 65477, 65478, 65479, 65481, 65482, 65483, 65485, 65486, 65487, 65502]);
3209
+ return {
3210
+ tableMarkers,
3211
+ sofMarkers
3212
+ };
3213
+ }
3214
+ function toDataView(data) {
3215
+ if (data instanceof DataView) {
3216
+ return data;
3217
+ }
3218
+ if (ArrayBuffer.isView(data)) {
3219
+ return new DataView(data.buffer);
3220
+ }
3221
+ if (data instanceof ArrayBuffer) {
3222
+ return new DataView(data);
3223
+ }
3224
+ throw new Error("toDataView");
3225
+ }
3226
+
3227
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-node-image.js
3228
+ async function parseToNodeImage(arrayBuffer2, options) {
3229
+ var _globalThis$loaders2;
3230
+ const {
3231
+ mimeType
3232
+ } = getBinaryImageMetadata(arrayBuffer2) || {};
3233
+ const parseImageNode2 = (_globalThis$loaders2 = globalThis.loaders) === null || _globalThis$loaders2 === void 0 ? void 0 : _globalThis$loaders2.parseImageNode;
3234
+ assert4(parseImageNode2);
3235
+ return await parseImageNode2(arrayBuffer2, mimeType);
3236
+ }
3237
+
3238
+ // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-image.js
3239
+ async function parseImage(arrayBuffer2, options, context) {
3240
+ options = options || {};
3241
+ const imageOptions = options.image || {};
3242
+ const imageType = imageOptions.type || "auto";
3243
+ const {
3244
+ url
3245
+ } = context || {};
3246
+ const loadType = getLoadableImageType(imageType);
3247
+ let image;
3248
+ switch (loadType) {
3249
+ case "imagebitmap":
3250
+ image = await parseToImageBitmap(arrayBuffer2, options, url);
3251
+ break;
3252
+ case "image":
3253
+ image = await parseToImage(arrayBuffer2, options, url);
3254
+ break;
3255
+ case "data":
3256
+ image = await parseToNodeImage(arrayBuffer2, options);
3257
+ break;
3258
+ default:
3259
+ assert4(false);
3260
+ }
3261
+ if (imageType === "data") {
3262
+ image = getImageData(image);
3263
+ }
3264
+ return image;
3265
+ }
3266
+ function getLoadableImageType(type) {
3267
+ switch (type) {
3268
+ case "auto":
3269
+ case "data":
3270
+ return getDefaultImageType();
3271
+ default:
3272
+ isImageTypeSupported(type);
3273
+ return type;
3274
+ }
3275
+ }
3276
+
3277
+ // ../../node_modules/@loaders.gl/images/dist/image-loader.js
3278
+ var EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
3279
+ var MIME_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp", "image/avif", "image/bmp", "image/vnd.microsoft.icon", "image/svg+xml"];
3280
+ var DEFAULT_IMAGE_LOADER_OPTIONS = {
3281
+ image: {
3282
+ type: "auto",
3283
+ decode: true
3284
+ }
3285
+ };
3286
+ var ImageLoader = {
3287
+ id: "image",
3288
+ module: "images",
3289
+ name: "Images",
3290
+ version: VERSION3,
3291
+ mimeTypes: MIME_TYPES,
3292
+ extensions: EXTENSIONS,
3293
+ parse: parseImage,
3294
+ tests: [(arrayBuffer2) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer2)))],
3295
+ options: DEFAULT_IMAGE_LOADER_OPTIONS
3296
+ };
3297
+
3298
+ // node_modules/@loaders.gl/textures/dist/lib/texture-api/generate-url.js
3299
+ function generateUrl(getUrl, options, urlOptions) {
3300
+ let url = typeof getUrl === "function" ? getUrl({
3301
+ ...options,
3302
+ ...urlOptions
3303
+ }) : getUrl;
3304
+ const baseUrl = options.baseUrl;
3305
+ if (baseUrl) {
3306
+ url = baseUrl[baseUrl.length - 1] === "/" ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
3307
+ }
3308
+ return resolvePath(url);
3309
+ }
3310
+
3311
+ // node_modules/@loaders.gl/textures/dist/lib/texture-api/async-deep-map.js
3312
+ var isObject = (value) => value && typeof value === "object";
3313
+ async function asyncDeepMap(tree, func) {
3314
+ let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3315
+ return await mapSubtree(tree, func, options);
3316
+ }
3317
+ async function mapSubtree(object, func, options) {
3318
+ if (Array.isArray(object)) {
3319
+ return await mapArray(object, func, options);
3320
+ }
3321
+ if (isObject(object)) {
3322
+ return await mapObject(object, func, options);
3323
+ }
3324
+ const url = object;
3325
+ return await func(url, options);
3326
+ }
3327
+ async function mapObject(object, func, options) {
3328
+ const promises = [];
3329
+ const values = {};
3330
+ for (const key in object) {
3331
+ const url = object[key];
3332
+ const promise = mapSubtree(url, func, options).then((value) => {
3333
+ values[key] = value;
3334
+ });
3335
+ promises.push(promise);
3336
+ }
3337
+ await Promise.all(promises);
3338
+ return values;
3339
+ }
3340
+ async function mapArray(urlArray, func) {
3341
+ let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3342
+ const promises = urlArray.map((url) => mapSubtree(url, func, options));
3343
+ return await Promise.all(promises);
3344
+ }
3345
+
3346
+ // node_modules/@loaders.gl/textures/dist/lib/texture-api/deep-load.js
3347
+ async function deepLoad(urlTree, load, options) {
3348
+ return await asyncDeepMap(urlTree, (url) => shallowLoad(url, load, options));
3349
+ }
3350
+ async function shallowLoad(url, load, options) {
3351
+ const response = await fetch(url, options.fetch);
3352
+ const arrayBuffer2 = await response.arrayBuffer();
3353
+ return await load(arrayBuffer2, options);
3354
+ }
3355
+
3356
+ // node_modules/@loaders.gl/textures/dist/lib/texture-api/load-image.js
3357
+ async function loadImageTexture(getUrl) {
3358
+ let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3359
+ const imageUrls = await getImageUrls(getUrl, options);
3360
+ return await deepLoad(imageUrls, ImageLoader.parse, options);
3361
+ }
3362
+ async function getImageUrls(getUrl, options) {
3363
+ let urlOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3364
+ const mipLevels = options && options.image && options.image.mipLevels || 0;
3365
+ return mipLevels !== 0 ? await getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) : generateUrl(getUrl, options, urlOptions);
3366
+ }
3367
+ async function getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) {
3368
+ const urls = [];
3369
+ if (mipLevels === "auto") {
3370
+ const url = generateUrl(getUrl, options, {
3371
+ ...urlOptions,
3372
+ lod: 0
3373
+ });
3374
+ const image = await shallowLoad(url, ImageLoader.parse, options);
3375
+ const {
3376
+ width,
3377
+ height
3378
+ } = getImageSize(image);
3379
+ mipLevels = getMipLevels({
3380
+ width,
3381
+ height
3382
+ });
3383
+ urls.push(url);
3384
+ }
3385
+ assert3(mipLevels > 0);
3386
+ for (let mipLevel = urls.length; mipLevel < mipLevels; ++mipLevel) {
3387
+ const url = generateUrl(getUrl, options, {
3388
+ ...urlOptions,
3389
+ lod: mipLevel
3390
+ });
3391
+ urls.push(url);
3392
+ }
3393
+ return urls;
3394
+ }
3395
+ function getMipLevels(size) {
3396
+ return 1 + Math.floor(Math.log2(Math.max(size.width, size.height)));
3397
+ }
3398
+
3399
+ // src/pbr/pbr-environment.ts
3400
+ function loadPBREnvironment(device, props) {
3401
+ const brdfLutTexture = device.createTexture({
3402
+ id: "brdfLUT",
3403
+ sampler: {
3404
+ wrapS: "clamp-to-edge",
3405
+ wrapT: "clamp-to-edge",
3406
+ minFilter: "linear",
3407
+ maxFilter: "linear"
3408
+ },
3409
+ data: loadImageTexture(props.brdfLutUrl)
3410
+ });
3411
+ const diffuseEnvSampler = makeCube(device, {
3412
+ id: "DiffuseEnvSampler",
3413
+ getTextureForFace: (dir) => loadImageTexture(props.getTexUrl("diffuse", dir, 0)),
3414
+ sampler: {
3415
+ wrapS: "clamp-to-edge",
3416
+ wrapT: "clamp-to-edge",
3417
+ minFilter: "linear",
3418
+ maxFilter: "linear"
3419
+ }
3420
+ });
3421
+ const specularEnvSampler = makeCube(device, {
3422
+ id: "SpecularEnvSampler",
3423
+ getTextureForFace: (dir) => {
3424
+ const imageArray = [];
3425
+ for (let lod = 0; lod <= props.specularMipLevels - 1; lod++) {
3426
+ imageArray.push(loadImageTexture(props.getTexUrl("specular", dir, lod)));
3427
+ }
3428
+ return imageArray;
3429
+ },
3430
+ sampler: {
3431
+ wrapS: "clamp-to-edge",
3432
+ wrapT: "clamp-to-edge",
3433
+ minFilter: "linear",
3434
+ maxFilter: "linear"
3435
+ }
3436
+ });
3437
+ return {
3438
+ brdfLutTexture,
3439
+ diffuseEnvSampler,
3440
+ specularEnvSampler
3441
+ };
3442
+ }
3443
+ var FACES = [0, 1, 2, 3, 4, 5];
3444
+ function makeCube(device, {
3445
+ id,
3446
+ getTextureForFace,
3447
+ sampler
3448
+ }) {
3449
+ const data = {};
3450
+ FACES.forEach((face) => {
3451
+ data[String(face)] = getTextureForFace(face);
3452
+ });
3453
+ return device.createTexture({
3454
+ id,
3455
+ dimension: "cube",
3456
+ mipmaps: false,
3457
+ sampler,
3458
+ data
3459
+ });
3460
+ }
3461
+
2853
3462
  // ../shadertools/src/lib/glsl-utils/highlight.ts
2854
3463
  var glsl = (x) => `${x}`;
2855
3464
 
2856
3465
  // ../shadertools/src/lib/utils/assert.ts
2857
- function assert3(condition, message2) {
3466
+ function assert5(condition, message2) {
2858
3467
  if (!condition) {
2859
3468
  throw new Error(message2 || "shadertools: assertion failed.");
2860
3469
  }
@@ -2887,7 +3496,7 @@ ${htmlLog}
2887
3496
  for (const [key, propsValidator] of Object.entries(propValidators)) {
2888
3497
  if (properties && key in properties && !propsValidator.private) {
2889
3498
  if (propsValidator.validate) {
2890
- assert3(propsValidator.validate(properties[key], propsValidator), `${errorMessage}: invalid ${key}`);
3499
+ assert5(propsValidator.validate(properties[key], propsValidator), `${errorMessage}: invalid ${key}`);
2891
3500
  }
2892
3501
  validated[key] = properties[key];
2893
3502
  } else {
@@ -3071,7 +3680,7 @@ ${htmlLog}
3071
3680
  if (module instanceof ShaderModuleInstance) {
3072
3681
  return module;
3073
3682
  }
3074
- assert3(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`);
3683
+ assert5(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`);
3075
3684
  if (!module.name) {
3076
3685
  console.warn("shader module has no name");
3077
3686
  module.name = `shader-module-${index++}`;
@@ -3093,7 +3702,7 @@ ${htmlLog}
3093
3702
  defines = {},
3094
3703
  inject = {}
3095
3704
  } = props;
3096
- assert3(typeof name2 === "string");
3705
+ assert5(typeof name2 === "string");
3097
3706
  this.name = name2;
3098
3707
  this.vs = vs3;
3099
3708
  this.fs = fs3;
@@ -3116,7 +3725,7 @@ ${htmlLog}
3116
3725
  moduleSource = this.fs || "";
3117
3726
  break;
3118
3727
  default:
3119
- assert3(false);
3728
+ assert5(false);
3120
3729
  }
3121
3730
  const moduleName = this.name.toUpperCase().replace(/[^0-9a-z]/gi, "_");
3122
3731
  return `// ----- MODULE ${this.name} ---------------
@@ -3165,7 +3774,7 @@ ${moduleSource}
3165
3774
  const propDef = propTypes[key];
3166
3775
  if (key in opts && !propDef.private) {
3167
3776
  if (propDef.validate) {
3168
- assert3(propDef.validate(opts[key], propDef), `${this.name}: invalid ${key}`);
3777
+ assert5(propDef.validate(opts[key], propDef), `${this.name}: invalid ${key}`);
3169
3778
  }
3170
3779
  uniforms[key] = opts[key];
3171
3780
  } else {
@@ -3529,7 +4138,7 @@ precision highp float;
3529
4138
  inject = {},
3530
4139
  log: log3
3531
4140
  } = options;
3532
- assert3(typeof source === "string", "shader source must be a string");
4141
+ assert5(typeof source === "string", "shader source must be a string");
3533
4142
  const coreSource = source;
3534
4143
  const allDefines = {};
3535
4144
  modules.forEach((module) => {
@@ -3603,7 +4212,7 @@ precision highp float;
3603
4212
  prologue = true,
3604
4213
  log: log3
3605
4214
  } = options;
3606
- assert3(typeof source === "string", "shader source must be a string");
4215
+ assert5(typeof source === "string", "shader source must be a string");
3607
4216
  const sourceVersion = language === "glsl" ? getShaderInfo2(source).version : -1;
3608
4217
  const targetVersion = platformInfo.shaderLanguageVersion;
3609
4218
  const sourceVersionDirective = sourceVersion === 100 ? "#version 100" : "#version 300 es";
@@ -4127,7 +4736,7 @@ ${getApplicationDefines(allDefines)}
4127
4736
  }
4128
4737
 
4129
4738
  // ../../node_modules/@math.gl/core/dist/lib/assert.js
4130
- function assert4(condition, message2) {
4739
+ function assert6(condition, message2) {
4131
4740
  if (!condition) {
4132
4741
  throw new Error("math.gl assertion ".concat(message2));
4133
4742
  }
@@ -4216,11 +4825,11 @@ ${getApplicationDefines(allDefines)}
4216
4825
  return this.distanceSquared(vector);
4217
4826
  }
4218
4827
  getComponent(i) {
4219
- assert4(i >= 0 && i < this.ELEMENTS, "index is out of range");
4828
+ assert6(i >= 0 && i < this.ELEMENTS, "index is out of range");
4220
4829
  return checkNumber(this[i]);
4221
4830
  }
4222
4831
  setComponent(i, value) {
4223
- assert4(i >= 0 && i < this.ELEMENTS, "index is out of range");
4832
+ assert6(i >= 0 && i < this.ELEMENTS, "index is out of range");
4224
4833
  this[i] = value;
4225
4834
  return this.check();
4226
4835
  }
@@ -6985,6 +7594,10 @@ vec4 pbr_filterColor(vec4 colorUnused)
6985
7594
  const moduleName = name2;
6986
7595
  const moduleProps = props[moduleName];
6987
7596
  const module = this.modules[moduleName];
7597
+ if (!module) {
7598
+ log.warn(`Module ${name2} not found`)();
7599
+ continue;
7600
+ }
6988
7601
  const oldUniforms = this.moduleUniforms[moduleName];
6989
7602
  const uniforms = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || moduleProps;
6990
7603
  this.moduleUniforms[moduleName] = {
@@ -7006,6 +7619,18 @@ vec4 pbr_filterColor(vec4 colorUnused)
7006
7619
  }
7007
7620
  return bindings;
7008
7621
  }
7622
+ getDebugTable() {
7623
+ const table = {};
7624
+ for (const [moduleName, module] of Object.entries(this.moduleUniforms)) {
7625
+ for (const [key, value] of Object.entries(module)) {
7626
+ table[`${moduleName}.${key}`] = {
7627
+ type: this.modules[moduleName].uniformTypes?.[key],
7628
+ value: String(value)
7629
+ };
7630
+ }
7631
+ }
7632
+ return table;
7633
+ }
7009
7634
  };
7010
7635
 
7011
7636
  // ../engine/src/geometry/gpu-geometry.ts
@@ -7086,6 +7711,9 @@ vec4 pbr_filterColor(vec4 colorUnused)
7086
7711
  case "TEXCOORD_0":
7087
7712
  name2 = "texCoords";
7088
7713
  break;
7714
+ case "COLOR_0":
7715
+ name2 = "colors";
7716
+ break;
7089
7717
  }
7090
7718
  attributes[name2] = device.createBuffer({
7091
7719
  data: attribute.value,
@@ -7202,7 +7830,30 @@ vec4 pbr_filterColor(vec4 colorUnused)
7202
7830
  fs: void 0
7203
7831
  });
7204
7832
 
7833
+ // ../engine/src/debug/debug-shader-layout.ts
7834
+ function getDebugTableForShaderLayout(layout, name2 = "") {
7835
+ const table = {};
7836
+ const header = `Shader Layout for ${name2}`;
7837
+ for (const attributeDeclaration of layout.attributes) {
7838
+ if (attributeDeclaration) {
7839
+ const glslDeclaration = `${attributeDeclaration.location} ${attributeDeclaration.name}: ${attributeDeclaration.type}`;
7840
+ table[`in ${glslDeclaration}`] = {
7841
+ [header]: attributeDeclaration.stepMode || "vertex"
7842
+ };
7843
+ }
7844
+ }
7845
+ for (const varyingDeclaration of layout.varyings || []) {
7846
+ const glslDeclaration = `${varyingDeclaration.location} ${varyingDeclaration.name}`;
7847
+ table[`out ${glslDeclaration}`] = {
7848
+ [header]: JSON.stringify(varyingDeclaration.accessor)
7849
+ };
7850
+ }
7851
+ return table;
7852
+ }
7853
+
7205
7854
  // ../engine/src/model/model.ts
7855
+ var LOG_DRAW_PRIORITY = 2;
7856
+ var LOG_DRAW_TIMEOUT = 1e4;
7206
7857
  var _Model = class {
7207
7858
  userData = {};
7208
7859
  instanceCount = 0;
@@ -7281,7 +7932,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
7281
7932
  this.setUniforms(props.uniforms);
7282
7933
  }
7283
7934
  if (props.moduleSettings) {
7284
- console.warn("Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()");
7935
+ log.warn("Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()")();
7285
7936
  this.updateModuleSettings(props.moduleSettings);
7286
7937
  }
7287
7938
  if (props.transformFeedback) {
@@ -7298,16 +7949,21 @@ vec4 pbr_filterColor(vec4 colorUnused)
7298
7949
  }
7299
7950
  draw(renderPass) {
7300
7951
  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
- });
7952
+ try {
7953
+ this._logDrawCallStart();
7954
+ this.pipeline = this._updatePipeline();
7955
+ this.pipeline.setBindings(this.bindings);
7956
+ this.pipeline.setUniforms(this.uniforms);
7957
+ this.pipeline.draw({
7958
+ renderPass,
7959
+ vertexArray: this.vertexArray,
7960
+ vertexCount: this.vertexCount,
7961
+ instanceCount: this.instanceCount,
7962
+ transformFeedback: this.transformFeedback
7963
+ });
7964
+ } finally {
7965
+ this._logDrawCallEnd();
7966
+ }
7311
7967
  }
7312
7968
  setGeometry(geometry) {
7313
7969
  const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);
@@ -7320,7 +7976,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
7320
7976
  }
7321
7977
  _setGeometryAttributes(gpuGeometry) {
7322
7978
  this.vertexCount = gpuGeometry.vertexCount;
7323
- this.setAttributes(gpuGeometry.attributes);
7979
+ this.setAttributes(gpuGeometry.attributes, "ignore-unknown");
7324
7980
  this.setIndexBuffer(gpuGeometry.indices);
7325
7981
  }
7326
7982
  setTopology(topology) {
@@ -7364,7 +8020,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
7364
8020
  this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());
7365
8021
  }
7366
8022
  updateModuleSettings(props) {
7367
- console.warn("Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()");
8023
+ log.warn("Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()")();
7368
8024
  const {
7369
8025
  bindings,
7370
8026
  uniforms
@@ -7385,9 +8041,9 @@ vec4 pbr_filterColor(vec4 colorUnused)
7385
8041
  setTransformFeedback(transformFeedback) {
7386
8042
  this.transformFeedback = transformFeedback;
7387
8043
  }
7388
- setAttributes(buffers) {
8044
+ setAttributes(buffers, _option) {
7389
8045
  if (buffers.indices) {
7390
- log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`);
8046
+ log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();
7391
8047
  }
7392
8048
  for (const [bufferName, buffer] of Object.entries(buffers)) {
7393
8049
  const bufferLayout = this.bufferLayout.find((layout) => layout.name === bufferName);
@@ -7404,7 +8060,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
7404
8060
  set2 = true;
7405
8061
  }
7406
8062
  }
7407
- if (!set2) {
8063
+ if (!set2 && _option !== "ignore-unknown") {
7408
8064
  log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
7409
8065
  }
7410
8066
  }
@@ -7448,6 +8104,34 @@ vec4 pbr_filterColor(vec4 colorUnused)
7448
8104
  }
7449
8105
  return this.pipeline;
7450
8106
  }
8107
+ _lastLogTime = 0;
8108
+ _logOpen = false;
8109
+ _logDrawCallStart() {
8110
+ const logDrawTimeout = log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
8111
+ if (Date.now() - this._lastLogTime < logDrawTimeout) {
8112
+ return void 0;
8113
+ }
8114
+ this._lastLogTime = Date.now();
8115
+ this._logOpen = true;
8116
+ log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, {
8117
+ collapsed: log.level <= 2
8118
+ })();
8119
+ }
8120
+ _logDrawCallEnd() {
8121
+ if (this._logOpen) {
8122
+ const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout);
8123
+ log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
8124
+ const uniformTable = this.shaderInputs.getDebugTable();
8125
+ for (const [name2, value] of Object.entries(this.uniforms)) {
8126
+ uniformTable[name2] = {
8127
+ value
8128
+ };
8129
+ }
8130
+ log.table(LOG_DRAW_PRIORITY, uniformTable)();
8131
+ log.groupEnd(LOG_DRAW_PRIORITY)();
8132
+ this._logOpen = false;
8133
+ }
8134
+ }
7451
8135
  };
7452
8136
  var Model = _Model;
7453
8137
  __publicField(Model, "defaultProps", {
@@ -7916,7 +8600,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
7916
8600
  this.cached = [this.size, this.type, this.normalized, this.stride, this.offset].join(":");
7917
8601
  };
7918
8602
  var OESVertexArrayObject = function OESVertexArrayObject2(gl) {
7919
- const self = this;
8603
+ const self2 = this;
7920
8604
  this.gl = gl;
7921
8605
  wrapGLError(gl);
7922
8606
  const original = this.original = {
@@ -7928,23 +8612,23 @@ vec4 pbr_filterColor(vec4 colorUnused)
7928
8612
  vertexAttribPointer: gl.vertexAttribPointer
7929
8613
  };
7930
8614
  gl.getParameter = function getParameter(pname) {
7931
- if (pname === self.VERTEX_ARRAY_BINDING_OES) {
7932
- if (self.currentVertexArrayObject === self.defaultVertexArrayObject) {
8615
+ if (pname === self2.VERTEX_ARRAY_BINDING_OES) {
8616
+ if (self2.currentVertexArrayObject === self2.defaultVertexArrayObject) {
7933
8617
  return null;
7934
8618
  }
7935
- return self.currentVertexArrayObject;
8619
+ return self2.currentVertexArrayObject;
7936
8620
  }
7937
8621
  return original.getParameter.apply(this, arguments);
7938
8622
  };
7939
8623
  gl.enableVertexAttribArray = function enableVertexAttribArray(index2) {
7940
- const vao = self.currentVertexArrayObject;
8624
+ const vao = self2.currentVertexArrayObject;
7941
8625
  vao.maxAttrib = Math.max(vao.maxAttrib, index2);
7942
8626
  const attrib = vao.attribs[index2];
7943
8627
  attrib.enabled = true;
7944
8628
  return original.enableVertexAttribArray.apply(this, arguments);
7945
8629
  };
7946
8630
  gl.disableVertexAttribArray = function disableVertexAttribArray(index2) {
7947
- const vao = self.currentVertexArrayObject;
8631
+ const vao = self2.currentVertexArrayObject;
7948
8632
  vao.maxAttrib = Math.max(vao.maxAttrib, index2);
7949
8633
  const attrib = vao.attribs[index2];
7950
8634
  attrib.enabled = false;
@@ -7953,17 +8637,17 @@ vec4 pbr_filterColor(vec4 colorUnused)
7953
8637
  gl.bindBuffer = function bindBuffer2(target, buffer) {
7954
8638
  switch (target) {
7955
8639
  case gl.ARRAY_BUFFER:
7956
- self.currentArrayBuffer = buffer;
8640
+ self2.currentArrayBuffer = buffer;
7957
8641
  break;
7958
8642
  case gl.ELEMENT_ARRAY_BUFFER:
7959
- self.currentVertexArrayObject.elementArrayBuffer = buffer;
8643
+ self2.currentVertexArrayObject.elementArrayBuffer = buffer;
7960
8644
  break;
7961
8645
  default:
7962
8646
  }
7963
8647
  return original.bindBuffer.apply(this, arguments);
7964
8648
  };
7965
8649
  gl.getVertexAttrib = function getVertexAttrib(index2, pname) {
7966
- const vao = self.currentVertexArrayObject;
8650
+ const vao = self2.currentVertexArrayObject;
7967
8651
  const attrib = vao.attribs[index2];
7968
8652
  switch (pname) {
7969
8653
  case gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
@@ -7983,10 +8667,10 @@ vec4 pbr_filterColor(vec4 colorUnused)
7983
8667
  }
7984
8668
  };
7985
8669
  gl.vertexAttribPointer = function vertexAttribPointer(indx, size, type, normalized, stride, offset) {
7986
- const vao = self.currentVertexArrayObject;
8670
+ const vao = self2.currentVertexArrayObject;
7987
8671
  vao.maxAttrib = Math.max(vao.maxAttrib, indx);
7988
8672
  const attrib = vao.attribs[indx];
7989
- attrib.buffer = self.currentArrayBuffer;
8673
+ attrib.buffer = self2.currentArrayBuffer;
7990
8674
  attrib.size = size;
7991
8675
  attrib.type = type;
7992
8676
  attrib.normalized = normalized;
@@ -8001,7 +8685,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
8001
8685
  if (gl.canvas) {
8002
8686
  gl.canvas.addEventListener("webglcontextrestored", () => {
8003
8687
  log2("OESVertexArrayObject emulation library context restored");
8004
- self.reset_();
8688
+ self2.reset_();
8005
8689
  }, true);
8006
8690
  }
8007
8691
  this.reset_();
@@ -9064,10 +9748,13 @@ vec4 pbr_filterColor(vec4 colorUnused)
9064
9748
  }
9065
9749
  function initializeExtensions(gl) {
9066
9750
  const contextState = getContextData(gl);
9067
- const EXTENSIONS = gl.getSupportedExtensions() || [];
9068
- for (const extensionName of EXTENSIONS) {
9069
- const extension = gl.getExtension(extensionName);
9070
- contextState._extensions[extensionName] = extension;
9751
+ const EXTENSIONS2 = gl.getSupportedExtensions() || [];
9752
+ const IGNORE_EXTENSIONS = ["WEBGL_polygon_mode"];
9753
+ for (const extensionName of EXTENSIONS2) {
9754
+ if (!IGNORE_EXTENSIONS.includes(extensionName)) {
9755
+ const extension = gl.getExtension(extensionName);
9756
+ contextState._extensions[extensionName] = extension;
9757
+ }
9071
9758
  }
9072
9759
  }
9073
9760
  function installPolyfills(gl, polyfills) {
@@ -9821,11 +10508,13 @@ vec4 pbr_filterColor(vec4 colorUnused)
9821
10508
  const version = gl.getParameter(GLEnum2.VERSION);
9822
10509
  const gpu = identifyGPUVendor(vendor, renderer);
9823
10510
  const gpuBackend = identifyGPUBackend(vendor, renderer);
10511
+ const gpuType = identifyGPUType(vendor, renderer);
9824
10512
  const shadingLanguage = "glsl";
9825
10513
  const shadingLanguageVersion = isWebGL2(gl) ? 300 : 100;
9826
10514
  return {
9827
10515
  type: isWebGL2(gl) ? "webgl2" : "webgl",
9828
10516
  gpu,
10517
+ gpuType,
9829
10518
  gpuBackend,
9830
10519
  vendor,
9831
10520
  renderer,
@@ -9853,14 +10542,30 @@ vec4 pbr_filterColor(vec4 colorUnused)
9853
10542
  return "unknown";
9854
10543
  }
9855
10544
  function identifyGPUBackend(vendor, renderer) {
9856
- if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
9857
- return "angle";
9858
- }
9859
10545
  if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {
9860
10546
  return "metal";
9861
10547
  }
10548
+ if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
10549
+ return "opengl";
10550
+ }
9862
10551
  return "unknown";
9863
10552
  }
10553
+ function identifyGPUType(vendor, renderer) {
10554
+ if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
10555
+ return "cpu";
10556
+ }
10557
+ const gpuVendor = identifyGPUVendor(vendor, renderer);
10558
+ switch (gpuVendor) {
10559
+ case "intel":
10560
+ return "integrated";
10561
+ case "software":
10562
+ return "cpu";
10563
+ case "unknown":
10564
+ return "unknown";
10565
+ default:
10566
+ return "discrete";
10567
+ }
10568
+ }
9864
10569
 
9865
10570
  // ../webgl/src/adapter/device-helpers/is-old-ie.ts
9866
10571
  function isOldIE(opts = {}) {
@@ -11182,6 +11887,17 @@ void main(void) {}`;
11182
11887
  }
11183
11888
  return params;
11184
11889
  }
11890
+ function updateSamplerParametersForNPOT(parameters) {
11891
+ const newParameters = {
11892
+ ...parameters
11893
+ };
11894
+ if (parameters[GLEnum2.TEXTURE_MIN_FILTER] !== GLEnum2.NEAREST) {
11895
+ newParameters[GLEnum2.TEXTURE_MIN_FILTER] = GLEnum2.LINEAR;
11896
+ }
11897
+ newParameters[GLEnum2.TEXTURE_WRAP_S] = GLEnum2.CLAMP_TO_EDGE;
11898
+ newParameters[GLEnum2.TEXTURE_WRAP_T] = GLEnum2.CLAMP_TO_EDGE;
11899
+ return newParameters;
11900
+ }
11185
11901
  function convertAddressMode(addressMode) {
11186
11902
  switch (addressMode) {
11187
11903
  case "clamp-to-edge":
@@ -11211,17 +11927,6 @@ void main(void) {}`;
11211
11927
  return mipmapFilter === "nearest" ? GLEnum2.LINEAR_MIPMAP_NEAREST : GLEnum2.LINEAR_MIPMAP_LINEAR;
11212
11928
  }
11213
11929
  }
11214
- function updateSamplerParametersForNPOT(parameters) {
11215
- const newParameters = {
11216
- ...parameters
11217
- };
11218
- if (parameters[GLEnum2.TEXTURE_MIN_FILTER] !== GLEnum2.NEAREST) {
11219
- newParameters[GLEnum2.TEXTURE_MIN_FILTER] = GLEnum2.LINEAR;
11220
- }
11221
- newParameters[GLEnum2.TEXTURE_WRAP_S] = GLEnum2.CLAMP_TO_EDGE;
11222
- newParameters[GLEnum2.TEXTURE_WRAP_T] = GLEnum2.CLAMP_TO_EDGE;
11223
- return newParameters;
11224
- }
11225
11930
 
11226
11931
  // ../webgl/src/adapter/resources/webgl-buffer.ts
11227
11932
  var DEBUG_DATA_LENGTH = 10;
@@ -11404,7 +12109,7 @@ void main(void) {}`;
11404
12109
  format: "rgba8unorm",
11405
12110
  ...props
11406
12111
  });
11407
- this.device = cast(device);
12112
+ this.device = device;
11408
12113
  this.gl = this.device.gl;
11409
12114
  this.gl2 = this.device.gl2;
11410
12115
  this.handle = this.props.handle || this.gl.createTexture();
@@ -13286,14 +13991,14 @@ ${source2}`;
13286
13991
  };
13287
13992
  }
13288
13993
  const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
13289
- const matches = UNIFORM_NAME_REGEXP.exec(name2);
13290
- if (!matches || matches.length < 2) {
13994
+ const matches2 = UNIFORM_NAME_REGEXP.exec(name2);
13995
+ if (!matches2 || matches2.length < 2) {
13291
13996
  throw new Error(`Failed to parse GLSL uniform name ${name2}`);
13292
13997
  }
13293
13998
  return {
13294
- name: matches[1],
13295
- length: matches[2] ? 1 : 0,
13296
- isArray: Boolean(matches[2])
13999
+ name: matches2[1],
14000
+ length: matches2[2] ? 1 : 0,
14001
+ isArray: Boolean(matches2[2])
13297
14002
  };
13298
14003
  }
13299
14004
 
@@ -14186,7 +14891,7 @@ ${source2}`;
14186
14891
  });
14187
14892
  }
14188
14893
  static async create(props = {}) {
14189
- log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created");
14894
+ log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
14190
14895
  if (typeof props.canvas === "string") {
14191
14896
  await CanvasContext.pageLoaded;
14192
14897
  }
@@ -14203,7 +14908,12 @@ ${source2}`;
14203
14908
  if (props.gl && props.gl.device) {
14204
14909
  return _WebGLDevice.attach(props.gl);
14205
14910
  }
14206
- return new _WebGLDevice(props);
14911
+ const device = new _WebGLDevice(props);
14912
+ const message2 = `Created ${device.info.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
14913
+ log.probe(LOG_LEVEL2, message2)();
14914
+ log.table(LOG_LEVEL2, device.info)();
14915
+ log.groupEnd(LOG_LEVEL2)();
14916
+ return device;
14207
14917
  }
14208
14918
  constructor(props) {
14209
14919
  super({
@@ -14270,9 +14980,6 @@ ${source2}`;
14270
14980
  canvas
14271
14981
  });
14272
14982
  }
14273
- const message2 = `Created ${this.info.type}${this.debug ? " debug" : ""} context: ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;
14274
- log.probe(LOG_LEVEL2, message2)();
14275
- log.groupEnd(LOG_LEVEL2)();
14276
14983
  }
14277
14984
  destroy() {
14278
14985
  const ext = this.gl.getExtension("STACKGL_destroy_context");