@colijnit/configuratorcore 300.1.0 → 300.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -373,7 +373,6 @@ class ObjectUtils {
373
373
  }
374
374
 
375
375
  class ThreedUtils {
376
- clips = [];
377
376
  _objectCache = new Map();
378
377
  clearCache() {
379
378
  const objs = Array.from(this._objectCache.values());
@@ -450,8 +449,8 @@ class ThreedUtils {
450
449
  loader.dracoLoader.setDecoderPath(dracoPath);
451
450
  loader.dracoLoader.setDecoderConfig({ type: 'js' });
452
451
  loader.load(file, async (object) => {
453
- this.clips = object.animations || [];
454
452
  const obj = this._cleanedUpObjects(object.scene, cleanUp);
453
+ obj.animations = object.animations || [];
455
454
  this._objectCache.set(file, obj);
456
455
  resolve(obj);
457
456
  }, xhr => this._handleUpdateProgressBar(xhr.loaded / xhr.total * 100), error => {
@@ -640,6 +639,8 @@ class ImageUtils {
640
639
  return 'data:image/gif;base64,' + documentBody;
641
640
  case 'bmp':
642
641
  return 'data:image/bmp;base64,' + documentBody;
642
+ case 'webp':
643
+ return 'data:image/webp;base64,' + documentBody;
643
644
  default:
644
645
  return 'data:image/png;base64,' + documentBody;
645
646
  }
@@ -999,7 +1000,8 @@ class FileUtils {
999
1000
  // Return the mimetype of the given filename.
1000
1001
  static MimeTypeFromFilename(fileName) {
1001
1002
  const regEx = /(?:\.([^.]+))?$/; // regex to find extension
1002
- const extension = regEx.exec(fileName)[1];
1003
+ const match = regEx.exec(fileName)[1];
1004
+ const extension = match ? match.toLowerCase() : '';
1003
1005
  switch (extension) {
1004
1006
  case 'jpg':
1005
1007
  case 'jpeg':
@@ -1008,6 +1010,8 @@ class FileUtils {
1008
1010
  return 'image/png';
1009
1011
  case 'bmp':
1010
1012
  return 'image/bmp';
1013
+ case 'webp':
1014
+ return 'image/webp';
1011
1015
  }
1012
1016
  }
1013
1017
  /**
@@ -1490,6 +1494,7 @@ class VariationUtils {
1490
1494
  case 'jpeg':
1491
1495
  case 'png':
1492
1496
  case 'bmp':
1497
+ case 'webp':
1493
1498
  return true;
1494
1499
  default:
1495
1500
  return false;
@@ -1505,6 +1510,8 @@ class VariationUtils {
1505
1510
  return 'png';
1506
1511
  case 'bmp':
1507
1512
  return 'bmp';
1513
+ case 'webp':
1514
+ return 'webp';
1508
1515
  default:
1509
1516
  return 'jpeg';
1510
1517
  }
@@ -1736,7 +1743,7 @@ class VariationHelper extends VariationCacheHelper {
1736
1743
  const lastKnownVariations = [];
1737
1744
  const variationPromise = [];
1738
1745
  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) => {
1746
+ variationPromise.push(this.loadCachedVariation(variations[j].materialUrl ? this.getFileNameFromUrl(variations[j].materialUrl) : (variations[j].gameObjectName || parts[i].decoId)).then(async (variationSettings) => {
1740
1747
  const newVariation = this._createVariationFromNode(variations[j]);
1741
1748
  newVariation.material = await AssetUtils.CreateMaterialFromAsset(variationSettings);
1742
1749
  this.loadedAsset = variations[j].materialUrl ? variations[j].materialUrl : VariationUtils.GetUrl(assetPath, parts[i].schema, variations[j].gameObjectName || parts[i].decoId);
@@ -1757,6 +1764,12 @@ class VariationHelper extends VariationCacheHelper {
1757
1764
  }
1758
1765
  });
1759
1766
  }
1767
+ getFileNameFromUrl(url) {
1768
+ // Make sure that when we are referencing a material, we always use the URL values and not the code.
1769
+ // materialCode can be different than the materialUrl file part and will cause issues.
1770
+ const fileNameFromUrl = url ? url.substr(url.lastIndexOf('/') + 1, url.length) : null;
1771
+ return fileNameFromUrl ? fileNameFromUrl.substr(0, fileNameFromUrl.lastIndexOf('.')) : null;
1772
+ }
1760
1773
  async loadVariationFromLocalFile(id, file, obj) {
1761
1774
  try {
1762
1775
  const variationSettings = await VariationUtils.GetVariationSettingsFromFile(id, file);