@colijnit/configuratorcore 262.1.6 → 262.1.8

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.
@@ -640,6 +640,8 @@ class ImageUtils {
640
640
  return 'data:image/gif;base64,' + documentBody;
641
641
  case 'bmp':
642
642
  return 'data:image/bmp;base64,' + documentBody;
643
+ case 'webp':
644
+ return 'data:image/webp;base64,' + documentBody;
643
645
  default:
644
646
  return 'data:image/png;base64,' + documentBody;
645
647
  }
@@ -999,7 +1001,8 @@ class FileUtils {
999
1001
  // Return the mimetype of the given filename.
1000
1002
  static MimeTypeFromFilename(fileName) {
1001
1003
  const regEx = /(?:\.([^.]+))?$/; // regex to find extension
1002
- const extension = regEx.exec(fileName)[1];
1004
+ const match = regEx.exec(fileName)[1];
1005
+ const extension = match ? match.toLowerCase() : '';
1003
1006
  switch (extension) {
1004
1007
  case 'jpg':
1005
1008
  case 'jpeg':
@@ -1008,6 +1011,8 @@ class FileUtils {
1008
1011
  return 'image/png';
1009
1012
  case 'bmp':
1010
1013
  return 'image/bmp';
1014
+ case 'webp':
1015
+ return 'image/webp';
1011
1016
  }
1012
1017
  }
1013
1018
  /**
@@ -1490,6 +1495,7 @@ class VariationUtils {
1490
1495
  case 'jpeg':
1491
1496
  case 'png':
1492
1497
  case 'bmp':
1498
+ case 'webp':
1493
1499
  return true;
1494
1500
  default:
1495
1501
  return false;
@@ -1505,6 +1511,8 @@ class VariationUtils {
1505
1511
  return 'png';
1506
1512
  case 'bmp':
1507
1513
  return 'bmp';
1514
+ case 'webp':
1515
+ return 'webp';
1508
1516
  default:
1509
1517
  return 'jpeg';
1510
1518
  }
@@ -1736,7 +1744,7 @@ class VariationHelper extends VariationCacheHelper {
1736
1744
  const lastKnownVariations = [];
1737
1745
  const variationPromise = [];
1738
1746
  for (let j = 0; j < variations.length; j++) {
1739
- variationPromise.push(this.loadCachedVariation(variations[j].materialUrl ? variations[j].materialCode : (variations[j].gameObjectName || parts[i].decoId)).then(async (variationSettings) => {
1747
+ variationPromise.push(this.loadCachedVariation(variations[j].materialUrl ? this.getFileNameFromUrl(variations[j].materialUrl) : (variations[j].gameObjectName || parts[i].decoId)).then(async (variationSettings) => {
1740
1748
  const newVariation = this._createVariationFromNode(variations[j]);
1741
1749
  newVariation.material = await AssetUtils.CreateMaterialFromAsset(variationSettings);
1742
1750
  this.loadedAsset = variations[j].materialUrl ? variations[j].materialUrl : VariationUtils.GetUrl(assetPath, parts[i].schema, variations[j].gameObjectName || parts[i].decoId);
@@ -1757,6 +1765,12 @@ class VariationHelper extends VariationCacheHelper {
1757
1765
  }
1758
1766
  });
1759
1767
  }
1768
+ getFileNameFromUrl(url) {
1769
+ // Make sure that when we are referencing a material, we always use the URL values and not the code.
1770
+ // materialCode can be different than the materialUrl file part and will cause issues.
1771
+ const fileNameFromUrl = url ? url.substr(url.lastIndexOf('/') + 1, url.length) : null;
1772
+ return fileNameFromUrl ? fileNameFromUrl.substr(0, fileNameFromUrl.lastIndexOf('.')) : null;
1773
+ }
1760
1774
  async loadVariationFromLocalFile(id, file, obj) {
1761
1775
  try {
1762
1776
  const variationSettings = await VariationUtils.GetVariationSettingsFromFile(id, file);