@colijnit/configuratorcore 262.1.6 → 300.1.1

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.
@@ -1736,7 +1736,7 @@ class VariationHelper extends VariationCacheHelper {
1736
1736
  const lastKnownVariations = [];
1737
1737
  const variationPromise = [];
1738
1738
  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) => {
1739
+ variationPromise.push(this.loadCachedVariation(variations[j].materialUrl ? this.getFileNameFromUrl(variations[j].materialUrl) : (variations[j].gameObjectName || parts[i].decoId)).then(async (variationSettings) => {
1740
1740
  const newVariation = this._createVariationFromNode(variations[j]);
1741
1741
  newVariation.material = await AssetUtils.CreateMaterialFromAsset(variationSettings);
1742
1742
  this.loadedAsset = variations[j].materialUrl ? variations[j].materialUrl : VariationUtils.GetUrl(assetPath, parts[i].schema, variations[j].gameObjectName || parts[i].decoId);
@@ -1757,6 +1757,12 @@ class VariationHelper extends VariationCacheHelper {
1757
1757
  }
1758
1758
  });
1759
1759
  }
1760
+ getFileNameFromUrl(url) {
1761
+ // Make sure that when we are referencing a material, we always use the URL values and not the code.
1762
+ // materialCode can be different than the materialUrl file part and will cause issues.
1763
+ const fileNameFromUrl = url ? url.substr(url.lastIndexOf('/') + 1, url.length) : null;
1764
+ return fileNameFromUrl ? fileNameFromUrl.substr(0, fileNameFromUrl.lastIndexOf('.')) : null;
1765
+ }
1760
1766
  async loadVariationFromLocalFile(id, file, obj) {
1761
1767
  try {
1762
1768
  const variationSettings = await VariationUtils.GetVariationSettingsFromFile(id, file);