babylonjs-serializers 5.32.1 → 5.32.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.
@@ -1595,22 +1595,18 @@ __webpack_require__.r(__webpack_exports__);
1595
1595
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1596
1596
  /* harmony export */ "KHR_texture_transform": () => (/* binding */ KHR_texture_transform)
1597
1597
  /* harmony export */ });
1598
- /* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/Textures/Procedurals/proceduralTexture */ "core/Maths/math.vector");
1598
+ /* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Misc/tools */ "core/Maths/math.vector");
1599
1599
  /* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
1600
1600
  /* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFExporter */ "../../../lts/serializers/dist/glTF/2.0/glTFExporter.js");
1601
- /* harmony import */ var _shaders_textureTransform_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../shaders/textureTransform.fragment */ "../../../lts/serializers/dist/glTF/2.0/shaders/textureTransform.fragment.js");
1602
-
1603
1601
 
1604
1602
 
1605
1603
  var NAME = "KHR_texture_transform";
1606
-
1607
1604
  /**
1608
1605
  * @internal
1609
1606
  */
1610
1607
  // eslint-disable-next-line @typescript-eslint/naming-convention
1611
1608
  var KHR_texture_transform = /** @class */ (function () {
1612
1609
  function KHR_texture_transform() {
1613
- this._recordedTextures = [];
1614
1610
  /** Name of this extension */
1615
1611
  this.name = NAME;
1616
1612
  /** Defines whether this extension is enabled */
@@ -1620,12 +1616,7 @@ var KHR_texture_transform = /** @class */ (function () {
1620
1616
  /** Reference to the glTF exporter */
1621
1617
  this._wasUsed = false;
1622
1618
  }
1623
- KHR_texture_transform.prototype.dispose = function () {
1624
- for (var _i = 0, _a = this._recordedTextures; _i < _a.length; _i++) {
1625
- var texture = _a[_i];
1626
- texture.dispose();
1627
- }
1628
- };
1619
+ KHR_texture_transform.prototype.dispose = function () { };
1629
1620
  Object.defineProperty(KHR_texture_transform.prototype, "wasUsed", {
1630
1621
  /** @internal */
1631
1622
  get: function () {
@@ -1668,67 +1659,23 @@ var KHR_texture_transform = /** @class */ (function () {
1668
1659
  }
1669
1660
  };
1670
1661
  KHR_texture_transform.prototype.preExportTextureAsync = function (context, babylonTexture) {
1671
- var _this = this;
1672
1662
  return new Promise(function (resolve, reject) {
1673
1663
  var scene = babylonTexture.getScene();
1674
1664
  if (!scene) {
1675
1665
  reject("".concat(context, ": \"scene\" is not defined for Babylon texture ").concat(babylonTexture.name, "!"));
1676
1666
  return;
1677
1667
  }
1678
- var bakeTextureTransform = false;
1679
1668
  /*
1680
1669
  * The KHR_texture_transform schema only supports rotation around the origin.
1681
- * the texture must be baked to preserve appearance.
1682
- * see: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates
1670
+ * See https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates.
1683
1671
  */
1684
1672
  if ((babylonTexture.uAng !== 0 || babylonTexture.wAng !== 0 || babylonTexture.vAng !== 0) &&
1685
1673
  (babylonTexture.uRotationCenter !== 0 || babylonTexture.vRotationCenter !== 0)) {
1686
- bakeTextureTransform = true;
1687
- }
1688
- if (!bakeTextureTransform) {
1689
- resolve(babylonTexture);
1690
- return;
1691
- }
1692
- return _this._textureTransformTextureAsync(babylonTexture, scene)
1693
- .then(function (proceduralTexture) {
1694
- resolve(proceduralTexture);
1695
- })
1696
- .catch(function (e) {
1697
- reject(e);
1698
- });
1699
- });
1700
- };
1701
- /**
1702
- * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
1703
- * @param babylonTexture
1704
- * @param scene
1705
- */
1706
- KHR_texture_transform.prototype._textureTransformTextureAsync = function (babylonTexture, scene) {
1707
- var _this = this;
1708
- return new Promise(function (resolve) {
1709
- var proceduralTexture = new core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture("".concat(babylonTexture.name), babylonTexture.getSize(), "textureTransform", scene);
1710
- if (!proceduralTexture) {
1711
- core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.Log("Cannot create procedural texture for ".concat(babylonTexture.name, "!"));
1712
- resolve(babylonTexture);
1713
- }
1714
- proceduralTexture.reservedDataStore = {
1715
- hidden: true,
1716
- source: babylonTexture,
1717
- };
1718
- _this._recordedTextures.push(proceduralTexture);
1719
- proceduralTexture.coordinatesIndex = babylonTexture.coordinatesIndex;
1720
- proceduralTexture.setTexture("textureSampler", babylonTexture);
1721
- proceduralTexture.setMatrix("textureTransformMat", babylonTexture.getTextureMatrix());
1722
- // isReady trigger creation of effect if it doesnt exist yet
1723
- if (proceduralTexture.isReady()) {
1724
- proceduralTexture.render();
1725
- resolve(proceduralTexture);
1674
+ core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("".concat(context, ": Texture ").concat(babylonTexture.name, " with rotation not centered at the origin cannot be exported with ").concat(NAME));
1675
+ resolve(null);
1726
1676
  }
1727
1677
  else {
1728
- proceduralTexture.getEffect().executeWhenCompiled(function () {
1729
- proceduralTexture.render();
1730
- resolve(proceduralTexture);
1731
- });
1678
+ resolve(babylonTexture);
1732
1679
  }
1733
1680
  });
1734
1681
  };
@@ -3562,8 +3509,8 @@ var _Exporter = /** @class */ (function () {
3562
3509
  imageData = _this._imageData[image.uri];
3563
3510
  _this._orderedImageData.push(imageData);
3564
3511
  imageName = image.uri.split(".")[0] + " image";
3565
- bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_3__._GLTFUtilities._CreateBufferView(0, byteOffset, imageData.data.length, undefined, imageName);
3566
- byteOffset += imageData.data.buffer.byteLength;
3512
+ bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_3__._GLTFUtilities._CreateBufferView(0, byteOffset, imageData.data.byteLength, undefined, imageName);
3513
+ byteOffset += imageData.data.byteLength;
3567
3514
  _this._bufferViews.push(bufferView);
3568
3515
  image.bufferView = _this._bufferViews.length - 1;
3569
3516
  image.name = imageName;
@@ -3720,7 +3667,7 @@ var _Exporter = /** @class */ (function () {
3720
3667
  var glbData = [headerBuffer, jsonChunkBuffer, binaryChunkBuffer, binaryBuffer];
3721
3668
  // binary data
3722
3669
  for (var i = 0; i < _this._orderedImageData.length; ++i) {
3723
- glbData.push(_this._orderedImageData[i].data.buffer);
3670
+ glbData.push(_this._orderedImageData[i].data);
3724
3671
  }
3725
3672
  glbData.push(binPaddingBuffer);
3726
3673
  glbData.push(imagePaddingBuffer);
@@ -4827,6 +4774,16 @@ __webpack_require__.r(__webpack_exports__);
4827
4774
 
4828
4775
 
4829
4776
 
4777
+ function getFileExtensionFromMimeType(mimeType) {
4778
+ switch (mimeType) {
4779
+ case "image/jpeg" /* JPEG */:
4780
+ return ".jpg";
4781
+ case "image/png" /* PNG */:
4782
+ return ".png";
4783
+ case "image/webp" /* WEBP */:
4784
+ return ".webp";
4785
+ }
4786
+ }
4830
4787
  /**
4831
4788
  * Utility methods for working with glTF material conversion properties. This class should only be used internally
4832
4789
  * @internal
@@ -4837,6 +4794,8 @@ var _GLTFMaterialExporter = /** @class */ (function () {
4837
4794
  * Mapping to store textures
4838
4795
  */
4839
4796
  this._textureMap = {};
4797
+ // Mapping of internal textures to images to avoid exporting duplicate images.
4798
+ this._internalTextureToImage = {};
4840
4799
  this._textureMap = {};
4841
4800
  this._exporter = exporter;
4842
4801
  }
@@ -5021,68 +4980,68 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5021
4980
  var materialMap = this._exporter._materialMap;
5022
4981
  var materials = this._exporter._materials;
5023
4982
  var promises = [];
5024
- var glTFPbrMetallicRoughness = this._convertToGLTFPBRMetallicRoughness(babylonStandardMaterial);
5025
- var glTFMaterial = { name: babylonStandardMaterial.name };
4983
+ var pbrMetallicRoughness = this._convertToGLTFPBRMetallicRoughness(babylonStandardMaterial);
4984
+ var material = { name: babylonStandardMaterial.name };
5026
4985
  if (babylonStandardMaterial.backFaceCulling != null && !babylonStandardMaterial.backFaceCulling) {
5027
4986
  if (!babylonStandardMaterial.twoSidedLighting) {
5028
4987
  core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn(babylonStandardMaterial.name + ": Back-face culling disabled and two-sided lighting disabled is not supported in glTF.");
5029
4988
  }
5030
- glTFMaterial.doubleSided = true;
4989
+ material.doubleSided = true;
5031
4990
  }
5032
4991
  if (hasTextureCoords) {
5033
4992
  if (babylonStandardMaterial.diffuseTexture) {
5034
- promises.push(this._exportTextureAsync(babylonStandardMaterial.diffuseTexture, mimeType).then(function (glTFTexture) {
5035
- if (glTFTexture) {
5036
- glTFPbrMetallicRoughness.baseColorTexture = glTFTexture;
4993
+ promises.push(this._exportTextureAsync(babylonStandardMaterial.diffuseTexture, mimeType).then(function (textureInfo) {
4994
+ if (textureInfo) {
4995
+ pbrMetallicRoughness.baseColorTexture = textureInfo;
5037
4996
  }
5038
4997
  }));
5039
4998
  }
5040
- if (babylonStandardMaterial.bumpTexture) {
5041
- promises.push(this._exportTextureAsync(babylonStandardMaterial.bumpTexture, mimeType).then(function (glTFTexture) {
5042
- if (glTFTexture) {
5043
- glTFMaterial.normalTexture = glTFTexture;
5044
- if (babylonStandardMaterial.bumpTexture != null && babylonStandardMaterial.bumpTexture.level !== 1) {
5045
- glTFMaterial.normalTexture.scale = babylonStandardMaterial.bumpTexture.level;
4999
+ var bumpTexture_1 = babylonStandardMaterial.bumpTexture;
5000
+ if (bumpTexture_1) {
5001
+ promises.push(this._exportTextureAsync(bumpTexture_1, mimeType).then(function (textureInfo) {
5002
+ if (textureInfo) {
5003
+ material.normalTexture = textureInfo;
5004
+ if (bumpTexture_1.level !== 1) {
5005
+ material.normalTexture.scale = bumpTexture_1.level;
5046
5006
  }
5047
5007
  }
5048
5008
  }));
5049
5009
  }
5050
5010
  if (babylonStandardMaterial.emissiveTexture) {
5051
- glTFMaterial.emissiveFactor = [1.0, 1.0, 1.0];
5052
- promises.push(this._exportTextureAsync(babylonStandardMaterial.emissiveTexture, mimeType).then(function (glTFEmissiveTexture) {
5053
- if (glTFEmissiveTexture) {
5054
- glTFMaterial.emissiveTexture = glTFEmissiveTexture;
5011
+ material.emissiveFactor = [1.0, 1.0, 1.0];
5012
+ promises.push(this._exportTextureAsync(babylonStandardMaterial.emissiveTexture, mimeType).then(function (textureInfo) {
5013
+ if (textureInfo) {
5014
+ material.emissiveTexture = textureInfo;
5055
5015
  }
5056
5016
  }));
5057
5017
  }
5058
5018
  if (babylonStandardMaterial.ambientTexture) {
5059
- promises.push(this._exportTextureAsync(babylonStandardMaterial.ambientTexture, mimeType).then(function (glTFTexture) {
5060
- if (glTFTexture) {
5019
+ promises.push(this._exportTextureAsync(babylonStandardMaterial.ambientTexture, mimeType).then(function (textureInfo) {
5020
+ if (textureInfo) {
5061
5021
  var occlusionTexture = {
5062
- index: glTFTexture.index,
5022
+ index: textureInfo.index,
5063
5023
  };
5064
- glTFMaterial.occlusionTexture = occlusionTexture;
5065
- occlusionTexture.strength = 1.0;
5024
+ material.occlusionTexture = occlusionTexture;
5066
5025
  }
5067
5026
  }));
5068
5027
  }
5069
5028
  }
5070
5029
  if (babylonStandardMaterial.alpha < 1.0 || babylonStandardMaterial.opacityTexture) {
5071
5030
  if (babylonStandardMaterial.alphaMode === core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_COMBINE) {
5072
- glTFMaterial.alphaMode = "BLEND" /* BLEND */;
5031
+ material.alphaMode = "BLEND" /* BLEND */;
5073
5032
  }
5074
5033
  else {
5075
5034
  core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn(babylonStandardMaterial.name + ": glTF 2.0 does not support alpha mode: " + babylonStandardMaterial.alphaMode.toString());
5076
5035
  }
5077
5036
  }
5078
5037
  if (babylonStandardMaterial.emissiveColor && !_GLTFMaterialExporter._FuzzyEquals(babylonStandardMaterial.emissiveColor, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.Black(), _GLTFMaterialExporter._Epsilon)) {
5079
- glTFMaterial.emissiveFactor = babylonStandardMaterial.emissiveColor.asArray();
5038
+ material.emissiveFactor = babylonStandardMaterial.emissiveColor.asArray();
5080
5039
  }
5081
- glTFMaterial.pbrMetallicRoughness = glTFPbrMetallicRoughness;
5082
- _GLTFMaterialExporter._SetAlphaMode(glTFMaterial, babylonStandardMaterial);
5083
- materials.push(glTFMaterial);
5040
+ material.pbrMetallicRoughness = pbrMetallicRoughness;
5041
+ _GLTFMaterialExporter._SetAlphaMode(material, babylonStandardMaterial);
5042
+ materials.push(material);
5084
5043
  materialMap[babylonStandardMaterial.uniqueId] = materials.length - 1;
5085
- return this._finishMaterial(promises, glTFMaterial, babylonStandardMaterial, mimeType);
5044
+ return this._finishMaterial(promises, material, babylonStandardMaterial, mimeType);
5086
5045
  };
5087
5046
  _GLTFMaterialExporter.prototype._finishMaterial = function (promises, glTFMaterial, babylonMaterial, mimeType) {
5088
5047
  var _this = this;
@@ -5116,11 +5075,9 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5116
5075
  * @param mimeType mimetype of the image
5117
5076
  * @returns base64 image string
5118
5077
  */
5119
- _GLTFMaterialExporter.prototype._createBase64FromCanvasAsync = function (buffer, width, height, mimeType) {
5120
- var _this = this;
5121
- // eslint-disable-next-line no-async-promise-executor
5122
- return new Promise(function (resolve) { return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(_this, void 0, void 0, function () {
5123
- var textureType, hostingScene, engine, tempTexture, data, base64;
5078
+ _GLTFMaterialExporter.prototype._getImageDataAsync = function (buffer, width, height, mimeType) {
5079
+ return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
5080
+ var textureType, hostingScene, engine, tempTexture, data;
5124
5081
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
5125
5082
  switch (_a.label) {
5126
5083
  case 0:
@@ -5134,14 +5091,11 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5134
5091
  return [4 /*yield*/, engine._readTexturePixels(tempTexture, width, height)];
5135
5092
  case 2:
5136
5093
  data = _a.sent();
5137
- return [4 /*yield*/, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DumpDataAsync(width, height, data, mimeType, undefined, true, false)];
5138
- case 3:
5139
- base64 = _a.sent();
5140
- resolve(base64);
5141
- return [2 /*return*/];
5094
+ return [4 /*yield*/, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DumpDataAsync(width, height, data, mimeType, undefined, true, true)];
5095
+ case 3: return [2 /*return*/, (_a.sent())];
5142
5096
  }
5143
5097
  });
5144
- }); });
5098
+ });
5145
5099
  };
5146
5100
  /**
5147
5101
  * Generates a white texture based on the specified width and height
@@ -5232,11 +5186,11 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5232
5186
  _GLTFMaterialExporter.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync = function (diffuseTexture, specularGlossinessTexture, factors, mimeType) {
5233
5187
  var _a;
5234
5188
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
5235
- var promises, scene, resizedTextures, diffuseSize, diffuseBuffer, specularGlossinessBuffer, width, height, diffusePixels, specularPixels, byteLength, metallicRoughnessBuffer, baseColorBuffer, strideSize, maxBaseColor, maxMetallic, maxRoughness, h, w, offset, diffuseColor, specularColor, glossiness, specularGlossiness, metallicRoughness, metallicRoughnessFactors_1, writeOutMetallicRoughnessTexture, writeOutBaseColorTexture, h, w, destinationOffset, linearBaseColorPixel, sRGBBaseColorPixel, metallicRoughnessPixel, promise, promise;
5189
+ var promises, scene, resizedTextures, diffuseSize, diffuseBuffer, specularGlossinessBuffer, width, height, diffusePixels, specularPixels, byteLength, metallicRoughnessBuffer, baseColorBuffer, strideSize, maxBaseColor, maxMetallic, maxRoughness, h, w, offset, diffuseColor, specularColor, glossiness, specularGlossiness, metallicRoughness, metallicRoughnessFactors_1, writeOutMetallicRoughnessTexture, writeOutBaseColorTexture, h, w, destinationOffset, linearBaseColorPixel, sRGBBaseColorPixel, metallicRoughnessPixel;
5236
5190
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_b) {
5237
5191
  switch (_b.label) {
5238
5192
  case 0:
5239
- promises = [];
5193
+ promises = new Array();
5240
5194
  if (!(diffuseTexture || specularGlossinessTexture)) {
5241
5195
  return [2 /*return*/, Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!")];
5242
5196
  }
@@ -5333,16 +5287,14 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5333
5287
  }
5334
5288
  }
5335
5289
  if (writeOutMetallicRoughnessTexture) {
5336
- promise = this._createBase64FromCanvasAsync(metallicRoughnessBuffer, width, height, mimeType).then(function (metallicRoughnessBase64) {
5337
- metallicRoughnessFactors_1.metallicRoughnessTextureBase64 = metallicRoughnessBase64;
5338
- });
5339
- promises.push(promise);
5290
+ promises.push(this._getImageDataAsync(metallicRoughnessBuffer, width, height, mimeType).then(function (data) {
5291
+ metallicRoughnessFactors_1.metallicRoughnessTextureData = data;
5292
+ }));
5340
5293
  }
5341
5294
  if (writeOutBaseColorTexture) {
5342
- promise = this._createBase64FromCanvasAsync(baseColorBuffer, width, height, mimeType).then(function (baseColorBase64) {
5343
- metallicRoughnessFactors_1.baseColorTextureBase64 = baseColorBase64;
5344
- });
5345
- promises.push(promise);
5295
+ promises.push(this._getImageDataAsync(baseColorBuffer, width, height, mimeType).then(function (data) {
5296
+ metallicRoughnessFactors_1.baseColorTextureData = data;
5297
+ }));
5346
5298
  }
5347
5299
  return [2 /*return*/, Promise.all(promises).then(function () {
5348
5300
  return metallicRoughnessFactors_1;
@@ -5437,71 +5389,79 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5437
5389
  return metallicRoughness;
5438
5390
  });
5439
5391
  };
5440
- _GLTFMaterialExporter.prototype._getGLTFTextureSampler = function (texture) {
5441
- var sampler = this._getGLTFTextureWrapModesSampler(texture);
5442
- var samplingMode = texture instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture ? texture.samplingMode : null;
5443
- if (samplingMode != null) {
5444
- switch (samplingMode) {
5445
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_LINEAR: {
5446
- sampler.magFilter = 9729 /* LINEAR */;
5447
- sampler.minFilter = 9729 /* LINEAR */;
5448
- break;
5449
- }
5450
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_NEAREST: {
5451
- sampler.magFilter = 9729 /* LINEAR */;
5452
- sampler.minFilter = 9728 /* NEAREST */;
5453
- break;
5454
- }
5455
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_LINEAR: {
5456
- sampler.magFilter = 9728 /* NEAREST */;
5457
- sampler.minFilter = 9729 /* LINEAR */;
5458
- break;
5459
- }
5460
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_LINEAR_MIPLINEAR: {
5461
- sampler.magFilter = 9728 /* NEAREST */;
5462
- sampler.minFilter = 9987 /* LINEAR_MIPMAP_LINEAR */;
5463
- break;
5464
- }
5465
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_NEAREST: {
5466
- sampler.magFilter = 9728 /* NEAREST */;
5467
- sampler.minFilter = 9728 /* NEAREST */;
5468
- break;
5469
- }
5470
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_LINEAR_MIPNEAREST: {
5471
- sampler.magFilter = 9728 /* NEAREST */;
5472
- sampler.minFilter = 9985 /* LINEAR_MIPMAP_NEAREST */;
5473
- break;
5474
- }
5475
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_NEAREST_MIPNEAREST: {
5476
- sampler.magFilter = 9729 /* LINEAR */;
5477
- sampler.minFilter = 9984 /* NEAREST_MIPMAP_NEAREST */;
5478
- break;
5479
- }
5480
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_NEAREST_MIPLINEAR: {
5481
- sampler.magFilter = 9729 /* LINEAR */;
5482
- sampler.minFilter = 9986 /* NEAREST_MIPMAP_LINEAR */;
5483
- break;
5484
- }
5485
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_NEAREST_MIPLINEAR: {
5486
- sampler.magFilter = 9728 /* NEAREST */;
5487
- sampler.minFilter = 9986 /* NEAREST_MIPMAP_LINEAR */;
5488
- break;
5489
- }
5490
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_LINEAR_MIPLINEAR: {
5491
- sampler.magFilter = 9729 /* LINEAR */;
5492
- sampler.minFilter = 9987 /* LINEAR_MIPMAP_LINEAR */;
5493
- break;
5494
- }
5495
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_LINEAR_MIPNEAREST: {
5496
- sampler.magFilter = 9729 /* LINEAR */;
5497
- sampler.minFilter = 9985 /* LINEAR_MIPMAP_NEAREST */;
5498
- break;
5499
- }
5500
- case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_NEAREST_MIPNEAREST: {
5501
- sampler.magFilter = 9728 /* NEAREST */;
5502
- sampler.minFilter = 9984 /* NEAREST_MIPMAP_NEAREST */;
5503
- break;
5504
- }
5392
+ _GLTFMaterialExporter.prototype._getTextureSampler = function (texture) {
5393
+ var sampler = {};
5394
+ if (!texture || !(texture instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture)) {
5395
+ return sampler;
5396
+ }
5397
+ var wrapS = this._getGLTFTextureWrapMode(texture.wrapU);
5398
+ if (wrapS !== 10497 /* REPEAT */) {
5399
+ sampler.wrapS = wrapS;
5400
+ }
5401
+ var wrapT = this._getGLTFTextureWrapMode(texture.wrapV);
5402
+ if (wrapT !== 10497 /* REPEAT */) {
5403
+ sampler.wrapT = wrapT;
5404
+ }
5405
+ switch (texture.samplingMode) {
5406
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_LINEAR: {
5407
+ sampler.magFilter = 9729 /* LINEAR */;
5408
+ sampler.minFilter = 9729 /* LINEAR */;
5409
+ break;
5410
+ }
5411
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_NEAREST: {
5412
+ sampler.magFilter = 9729 /* LINEAR */;
5413
+ sampler.minFilter = 9728 /* NEAREST */;
5414
+ break;
5415
+ }
5416
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_LINEAR: {
5417
+ sampler.magFilter = 9728 /* NEAREST */;
5418
+ sampler.minFilter = 9729 /* LINEAR */;
5419
+ break;
5420
+ }
5421
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_LINEAR_MIPLINEAR: {
5422
+ sampler.magFilter = 9728 /* NEAREST */;
5423
+ sampler.minFilter = 9987 /* LINEAR_MIPMAP_LINEAR */;
5424
+ break;
5425
+ }
5426
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_NEAREST: {
5427
+ sampler.magFilter = 9728 /* NEAREST */;
5428
+ sampler.minFilter = 9728 /* NEAREST */;
5429
+ break;
5430
+ }
5431
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_LINEAR_MIPNEAREST: {
5432
+ sampler.magFilter = 9728 /* NEAREST */;
5433
+ sampler.minFilter = 9985 /* LINEAR_MIPMAP_NEAREST */;
5434
+ break;
5435
+ }
5436
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_NEAREST_MIPNEAREST: {
5437
+ sampler.magFilter = 9729 /* LINEAR */;
5438
+ sampler.minFilter = 9984 /* NEAREST_MIPMAP_NEAREST */;
5439
+ break;
5440
+ }
5441
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_NEAREST_MIPLINEAR: {
5442
+ sampler.magFilter = 9729 /* LINEAR */;
5443
+ sampler.minFilter = 9986 /* NEAREST_MIPMAP_LINEAR */;
5444
+ break;
5445
+ }
5446
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_NEAREST_MIPLINEAR: {
5447
+ sampler.magFilter = 9728 /* NEAREST */;
5448
+ sampler.minFilter = 9986 /* NEAREST_MIPMAP_LINEAR */;
5449
+ break;
5450
+ }
5451
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_LINEAR_MIPLINEAR: {
5452
+ sampler.magFilter = 9729 /* LINEAR */;
5453
+ sampler.minFilter = 9987 /* LINEAR_MIPMAP_LINEAR */;
5454
+ break;
5455
+ }
5456
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_LINEAR_MIPNEAREST: {
5457
+ sampler.magFilter = 9729 /* LINEAR */;
5458
+ sampler.minFilter = 9985 /* LINEAR_MIPMAP_NEAREST */;
5459
+ break;
5460
+ }
5461
+ case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_NEAREST_MIPNEAREST: {
5462
+ sampler.magFilter = 9728 /* NEAREST */;
5463
+ sampler.minFilter = 9984 /* NEAREST_MIPMAP_NEAREST */;
5464
+ break;
5505
5465
  }
5506
5466
  }
5507
5467
  return sampler;
@@ -5523,15 +5483,6 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5523
5483
  }
5524
5484
  }
5525
5485
  };
5526
- _GLTFMaterialExporter.prototype._getGLTFTextureWrapModesSampler = function (texture) {
5527
- var wrapS = this._getGLTFTextureWrapMode(texture instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture ? texture.wrapU : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE);
5528
- var wrapT = this._getGLTFTextureWrapMode(texture instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture ? texture.wrapV : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE);
5529
- if (wrapS === 10497 /* REPEAT */ && wrapT === 10497 /* REPEAT */) {
5530
- // default wrapping mode in glTF, so omitting
5531
- return {};
5532
- }
5533
- return { wrapS: wrapS, wrapT: wrapT };
5534
- };
5535
5486
  /**
5536
5487
  * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
5537
5488
  * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
@@ -5540,46 +5491,31 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5540
5491
  * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
5541
5492
  * @returns glTF PBR Metallic Roughness factors
5542
5493
  */
5543
- _GLTFMaterialExporter.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
5494
+ _GLTFMaterialExporter.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, pbrMetallicRoughness, hasTextureCoords) {
5544
5495
  var _this = this;
5545
5496
  return Promise.resolve().then(function () {
5546
- var samplers = _this._exporter._samplers;
5547
- var textures = _this._exporter._textures;
5548
- var diffuseColor = babylonPBRMaterial._albedoColor;
5549
- var specularColor = babylonPBRMaterial._reflectivityColor;
5550
- var glossiness = babylonPBRMaterial._microSurface;
5551
5497
  var specGloss = {
5552
- diffuseColor: diffuseColor,
5553
- specularColor: specularColor,
5554
- glossiness: glossiness,
5498
+ diffuseColor: babylonPBRMaterial._albedoColor,
5499
+ specularColor: babylonPBRMaterial._reflectivityColor,
5500
+ glossiness: babylonPBRMaterial._microSurface,
5555
5501
  };
5556
- var samplerIndex = null;
5557
5502
  var albedoTexture = babylonPBRMaterial._albedoTexture;
5558
5503
  var reflectivityTexture = babylonPBRMaterial._reflectivityTexture;
5559
- if (albedoTexture) {
5560
- var sampler = _this._getGLTFTextureSampler(albedoTexture);
5561
- if (sampler.magFilter != null && sampler.minFilter != null && sampler.wrapS != null && sampler.wrapT != null) {
5562
- samplers.push(sampler);
5563
- samplerIndex = samplers.length - 1;
5564
- }
5565
- }
5566
5504
  var useMicrosurfaceFromReflectivityMapAlpha = babylonPBRMaterial._useMicroSurfaceFromReflectivityMapAlpha;
5567
5505
  if (reflectivityTexture && !useMicrosurfaceFromReflectivityMapAlpha) {
5568
5506
  return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");
5569
5507
  }
5570
5508
  if ((albedoTexture || reflectivityTexture) && hasTextureCoords) {
5509
+ var samplerIndex_1 = _this._exportTextureSampler(albedoTexture || reflectivityTexture);
5571
5510
  return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(albedoTexture, reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
5572
- if (metallicRoughnessFactors.baseColorTextureBase64) {
5573
- var glTFBaseColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + textures.length + ".png", mimeType, albedoTexture ? albedoTexture.coordinatesIndex : null, samplerIndex);
5574
- if (glTFBaseColorTexture) {
5575
- glTFPbrMetallicRoughness.baseColorTexture = glTFBaseColorTexture;
5576
- }
5511
+ var textures = _this._exporter._textures;
5512
+ if (metallicRoughnessFactors.baseColorTextureData) {
5513
+ var imageIndex = _this._exportImage("baseColor".concat(textures.length), mimeType, metallicRoughnessFactors.baseColorTextureData);
5514
+ pbrMetallicRoughness.baseColorTexture = _this._exportTextureInfo(imageIndex, samplerIndex_1, albedoTexture === null || albedoTexture === void 0 ? void 0 : albedoTexture.coordinatesIndex);
5577
5515
  }
5578
- if (metallicRoughnessFactors.metallicRoughnessTextureBase64) {
5579
- var glTFMRColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + textures.length + ".png", mimeType, reflectivityTexture ? reflectivityTexture.coordinatesIndex : null, samplerIndex);
5580
- if (glTFMRColorTexture) {
5581
- glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFMRColorTexture;
5582
- }
5516
+ if (metallicRoughnessFactors.metallicRoughnessTextureData) {
5517
+ var imageIndex = _this._exportImage("metallicRoughness".concat(textures.length), mimeType, metallicRoughnessFactors.metallicRoughnessTextureData);
5518
+ pbrMetallicRoughness.metallicRoughnessTexture = _this._exportTextureInfo(imageIndex, samplerIndex_1, reflectivityTexture === null || reflectivityTexture === void 0 ? void 0 : reflectivityTexture.coordinatesIndex);
5583
5519
  }
5584
5520
  return metallicRoughnessFactors;
5585
5521
  });
@@ -5641,13 +5577,13 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5641
5577
  glTFMaterial.doubleSided = true;
5642
5578
  }
5643
5579
  if (hasTextureCoords) {
5644
- var bumpTexture_1 = babylonPBRMaterial._bumpTexture;
5645
- if (bumpTexture_1) {
5646
- var promise = this._exportTextureAsync(bumpTexture_1, mimeType).then(function (glTFTexture) {
5580
+ var bumpTexture_2 = babylonPBRMaterial._bumpTexture;
5581
+ if (bumpTexture_2) {
5582
+ var promise = this._exportTextureAsync(bumpTexture_2, mimeType).then(function (glTFTexture) {
5647
5583
  if (glTFTexture) {
5648
5584
  glTFMaterial.normalTexture = glTFTexture;
5649
- if (bumpTexture_1.level !== 1) {
5650
- glTFMaterial.normalTexture.scale = bumpTexture_1.level;
5585
+ if (bumpTexture_2.level !== 1) {
5586
+ glTFMaterial.normalTexture.scale = bumpTexture_2.level;
5651
5587
  }
5652
5588
  }
5653
5589
  });
@@ -5716,10 +5652,8 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5716
5652
  });
5717
5653
  };
5718
5654
  _GLTFMaterialExporter.prototype._exportTextureInfoAsync = function (babylonTexture, mimeType) {
5719
- var _this = this;
5720
- return Promise.resolve().then(function () { return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(_this, void 0, void 0, function () {
5721
- var textureUid, pixels, samplers, sampler, samplerIndex_1, foundSamplerIndex, i, s, size;
5722
- var _this = this;
5655
+ return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
5656
+ var textureUid, pixels, samplerIndex, textureMimeType, internalTextureToImage, internalTextureUniqueId, imageIndex, size, data, textureInfo;
5723
5657
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
5724
5658
  switch (_a.label) {
5725
5659
  case 0:
@@ -5732,118 +5666,86 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5732
5666
  if (!pixels) {
5733
5667
  return [2 /*return*/, null];
5734
5668
  }
5735
- samplers = this._exporter._samplers;
5736
- sampler = this._getGLTFTextureSampler(babylonTexture);
5737
- samplerIndex_1 = null;
5738
- foundSamplerIndex = null;
5739
- for (i = 0; i < samplers.length; ++i) {
5740
- s = samplers[i];
5741
- if (s.minFilter === sampler.minFilter && s.magFilter === sampler.magFilter && s.wrapS === sampler.wrapS && s.wrapT === sampler.wrapT) {
5742
- foundSamplerIndex = i;
5743
- break;
5744
- }
5745
- }
5746
- if (foundSamplerIndex == null) {
5747
- samplers.push(sampler);
5748
- samplerIndex_1 = samplers.length - 1;
5749
- }
5750
- else {
5751
- samplerIndex_1 = foundSamplerIndex;
5752
- }
5753
- size = babylonTexture.getSize();
5754
- // Preserve texture mime type if defined
5755
- if (babylonTexture.mimeType) {
5756
- switch (babylonTexture.mimeType) {
5669
+ samplerIndex = this._exportTextureSampler(babylonTexture);
5670
+ textureMimeType = babylonTexture.mimeType;
5671
+ if (textureMimeType) {
5672
+ switch (textureMimeType) {
5757
5673
  case "image/jpeg":
5758
- mimeType = "image/jpeg" /* JPEG */;
5759
- break;
5760
5674
  case "image/png":
5761
- mimeType = "image/png" /* PNG */;
5762
- break;
5763
5675
  case "image/webp":
5764
- mimeType = "image/webp" /* WEBP */;
5676
+ mimeType = textureMimeType;
5677
+ break;
5678
+ default:
5679
+ core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Unsupported media type: ${textureMimeType}");
5765
5680
  break;
5766
5681
  }
5767
5682
  }
5768
- return [2 /*return*/, this._createBase64FromCanvasAsync(pixels, size.width, size.height, mimeType).then(function (base64Data) {
5769
- var textureInfo = _this._getTextureInfoFromBase64(base64Data, babylonTexture.name.replace(/\.\/|\/|\.\\|\\/g, "_"), mimeType, babylonTexture.coordinatesIndex, samplerIndex_1);
5770
- if (textureInfo) {
5771
- _this._textureMap[textureUid] = textureInfo;
5772
- _this._exporter._extensionsPostExportTextures("linkTextureInfo", textureInfo, babylonTexture);
5773
- }
5774
- return textureInfo;
5775
- })];
5683
+ internalTextureToImage = this._internalTextureToImage;
5684
+ internalTextureUniqueId = babylonTexture.getInternalTexture().uniqueId;
5685
+ internalTextureToImage[internalTextureUniqueId] || (internalTextureToImage[internalTextureUniqueId] = {});
5686
+ imageIndex = internalTextureToImage[internalTextureUniqueId][mimeType];
5687
+ if (!(imageIndex === undefined)) return [3 /*break*/, 4];
5688
+ size = babylonTexture.getSize();
5689
+ return [4 /*yield*/, this._getImageDataAsync(pixels, size.width, size.height, mimeType)];
5690
+ case 3:
5691
+ data = _a.sent();
5692
+ imageIndex = this._exportImage(babylonTexture.name, mimeType, data);
5693
+ internalTextureToImage[internalTextureUniqueId][mimeType] = imageIndex;
5694
+ _a.label = 4;
5695
+ case 4:
5696
+ textureInfo = this._exportTextureInfo(imageIndex, samplerIndex, babylonTexture.coordinatesIndex);
5697
+ this._textureMap[textureUid] = textureInfo;
5698
+ return [2 /*return*/, textureInfo];
5776
5699
  }
5777
5700
  });
5778
- }); });
5701
+ });
5779
5702
  };
5780
- /**
5781
- * Builds a texture from base64 string
5782
- * @param base64Texture base64 texture string
5783
- * @param baseTextureName Name to use for the texture
5784
- * @param mimeType image mime type for the texture
5785
- * @param texCoordIndex
5786
- * @param samplerIndex
5787
- * @returns glTF texture info, or null if the texture format is not supported
5788
- */
5789
- _GLTFMaterialExporter.prototype._getTextureInfoFromBase64 = function (base64Texture, baseTextureName, mimeType, texCoordIndex, samplerIndex) {
5790
- var textures = this._exporter._textures;
5791
- var images = this._exporter._images;
5703
+ _GLTFMaterialExporter.prototype._exportImage = function (name, mimeType, data) {
5792
5704
  var imageData = this._exporter._imageData;
5793
- var textureInfo = null;
5794
- var glTFTexture = {
5795
- source: images.length,
5796
- name: baseTextureName,
5705
+ var baseName = name.replace(/\.\/|\/|\.\\|\\/g, "_");
5706
+ var extension = getFileExtensionFromMimeType(mimeType);
5707
+ var fileName = baseName + extension;
5708
+ if (fileName in imageData) {
5709
+ fileName = "".concat(baseName, "_").concat(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.RandomId()).concat(extension);
5710
+ }
5711
+ imageData[fileName] = {
5712
+ data: data,
5713
+ mimeType: mimeType,
5797
5714
  };
5798
- if (samplerIndex != null) {
5799
- glTFTexture.sampler = samplerIndex;
5800
- }
5801
- var binStr = atob(base64Texture.split(",")[1]);
5802
- var arrBuff = new ArrayBuffer(binStr.length);
5803
- var arr = new Uint8Array(arrBuff);
5804
- for (var i = 0, length_2 = binStr.length; i < length_2; ++i) {
5805
- arr[i] = binStr.charCodeAt(i);
5806
- }
5807
- var imageValues = { data: arr, mimeType: mimeType };
5808
- var extension = mimeType === "image/jpeg" /* JPEG */ ? ".jpeg" : ".png";
5809
- var textureName = baseTextureName + extension;
5810
- var originalTextureName = textureName;
5811
- if (textureName in imageData) {
5812
- textureName = "".concat(baseTextureName, "_").concat(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.RandomId()).concat(extension);
5813
- }
5814
- imageData[textureName] = imageValues;
5815
- if (mimeType === "image/jpeg" /* JPEG */ || mimeType === "image/png" /* PNG */ || mimeType === "image/webp" /* WEBP */) {
5816
- var glTFImage = {
5817
- name: baseTextureName,
5818
- uri: textureName,
5819
- };
5820
- var foundIndex = null;
5821
- for (var i = 0; i < images.length; ++i) {
5822
- if (images[i].uri === originalTextureName) {
5823
- foundIndex = i;
5824
- break;
5825
- }
5826
- }
5827
- if (foundIndex == null) {
5828
- images.push(glTFImage);
5829
- glTFTexture.source = images.length - 1;
5830
- }
5831
- else {
5832
- glTFTexture.source = foundIndex;
5833
- }
5834
- textures.push(glTFTexture);
5835
- textureInfo = {
5836
- index: textures.length - 1,
5837
- };
5838
- if (texCoordIndex != null) {
5839
- textureInfo.texCoord = texCoordIndex;
5840
- }
5715
+ var images = this._exporter._images;
5716
+ images.push({
5717
+ name: name,
5718
+ uri: fileName,
5719
+ });
5720
+ return images.length - 1;
5721
+ };
5722
+ _GLTFMaterialExporter.prototype._exportTextureInfo = function (imageIndex, samplerIndex, coordinatesIndex) {
5723
+ var textures = this._exporter._textures;
5724
+ var textureIndex = textures.findIndex(function (t) { return t.sampler == samplerIndex && t.source === imageIndex; });
5725
+ if (textureIndex === -1) {
5726
+ textureIndex = textures.length;
5727
+ textures.push({
5728
+ source: imageIndex,
5729
+ sampler: samplerIndex,
5730
+ });
5841
5731
  }
5842
- else {
5843
- core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Unsupported texture mime type ".concat(mimeType));
5732
+ var textureInfo = { index: textureIndex };
5733
+ if (coordinatesIndex) {
5734
+ textureInfo.texCoord = coordinatesIndex;
5844
5735
  }
5845
5736
  return textureInfo;
5846
5737
  };
5738
+ _GLTFMaterialExporter.prototype._exportTextureSampler = function (texture) {
5739
+ var sampler = this._getTextureSampler(texture);
5740
+ // if a pre-existing sampler with identical parameters exists, then reuse the previous sampler
5741
+ var samplers = this._exporter._samplers;
5742
+ var samplerIndex = samplers.findIndex(function (s) { return s.minFilter === sampler.minFilter && s.magFilter === sampler.magFilter && s.wrapS === sampler.wrapS && s.wrapT === sampler.wrapT; });
5743
+ if (samplerIndex !== -1) {
5744
+ return samplerIndex;
5745
+ }
5746
+ samplers.push(sampler);
5747
+ return samplers.length - 1;
5748
+ };
5847
5749
  /**
5848
5750
  * Represents the dielectric specular values for R, G and B
5849
5751
  */
@@ -6199,30 +6101,6 @@ __webpack_require__.r(__webpack_exports__);
6199
6101
 
6200
6102
 
6201
6103
 
6202
- /***/ }),
6203
-
6204
- /***/ "../../../lts/serializers/dist/glTF/2.0/shaders/textureTransform.fragment.js":
6205
- /*!***********************************************************************************!*\
6206
- !*** ../../../lts/serializers/dist/glTF/2.0/shaders/textureTransform.fragment.js ***!
6207
- \***********************************************************************************/
6208
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6209
-
6210
- __webpack_require__.r(__webpack_exports__);
6211
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6212
- /* harmony export */ "textureTransformPixelShader": () => (/* binding */ textureTransformPixelShader)
6213
- /* harmony export */ });
6214
- /* harmony import */ var core_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Engines/shaderStore */ "core/Maths/math.vector");
6215
- /* harmony import */ var core_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
6216
- // Do not edit.
6217
-
6218
- var name = "textureTransformPixelShader";
6219
- var shader = "precision highp float;varying vec2 vUV;uniform sampler2D textureSampler;uniform mat4 textureTransformMat;void main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec2 uvTransformed=(textureTransformMat*vec4(vUV.xy,1,1)).xy;gl_FragColor=texture2D(textureSampler,uvTransformed);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
6220
- // Sideeffect
6221
- core_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
6222
- /** @internal */
6223
- var textureTransformPixelShader = { name: name, shader: shader };
6224
-
6225
-
6226
6104
  /***/ }),
6227
6105
 
6228
6106
  /***/ "../../../lts/serializers/dist/glTF/glTFFileExporter.js":