babylonjs-serializers 5.35.1 → 5.37.0

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.
@@ -759,6 +759,75 @@ var KHR_materials_clearcoat = /** @class */ (function () {
759
759
  _glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_clearcoat(exporter); });
760
760
 
761
761
 
762
+ /***/ }),
763
+
764
+ /***/ "../../../lts/serializers/dist/glTF/2.0/Extensions/KHR_materials_emissive_strength.js":
765
+ /*!********************************************************************************************!*\
766
+ !*** ../../../lts/serializers/dist/glTF/2.0/Extensions/KHR_materials_emissive_strength.js ***!
767
+ \********************************************************************************************/
768
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
769
+
770
+ __webpack_require__.r(__webpack_exports__);
771
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
772
+ /* harmony export */ "KHR_materials_emissive_strength": () => (/* binding */ KHR_materials_emissive_strength)
773
+ /* harmony export */ });
774
+ /* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../lts/serializers/dist/glTF/2.0/glTFExporter.js");
775
+ /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Maths/math.vector");
776
+ /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__);
777
+
778
+
779
+ var NAME = "KHR_materials_emissive_strength";
780
+ /**
781
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md)
782
+ */
783
+ // eslint-disable-next-line @typescript-eslint/naming-convention
784
+ var KHR_materials_emissive_strength = /** @class */ (function () {
785
+ function KHR_materials_emissive_strength() {
786
+ /** Name of this extension */
787
+ this.name = NAME;
788
+ /** Defines whether this extension is enabled */
789
+ this.enabled = true;
790
+ /** Defines whether this extension is required */
791
+ this.required = false;
792
+ this._wasUsed = false;
793
+ }
794
+ KHR_materials_emissive_strength.prototype.dispose = function () { };
795
+ Object.defineProperty(KHR_materials_emissive_strength.prototype, "wasUsed", {
796
+ /** @interal */
797
+ get: function () {
798
+ return this._wasUsed;
799
+ },
800
+ enumerable: false,
801
+ configurable: true
802
+ });
803
+ KHR_materials_emissive_strength.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) {
804
+ var _this = this;
805
+ return new Promise(function (resolve) {
806
+ if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial)) {
807
+ return resolve(node);
808
+ }
809
+ var emissiveColor = babylonMaterial.emissiveColor.asArray();
810
+ var tempEmissiveStrength = Math.max.apply(Math, emissiveColor);
811
+ if (tempEmissiveStrength > 1) {
812
+ _this._wasUsed = true;
813
+ node.extensions || (node.extensions = {});
814
+ var emissiveStrengthInfo = {
815
+ emissiveStrength: tempEmissiveStrength,
816
+ };
817
+ // Normalize each value of the emissive factor to have a max value of 1
818
+ var newEmissiveFactor = babylonMaterial.emissiveColor.scale(1 / emissiveStrengthInfo.emissiveStrength);
819
+ node.emissiveFactor = newEmissiveFactor.asArray();
820
+ node.extensions[NAME] = emissiveStrengthInfo;
821
+ }
822
+ return resolve(node);
823
+ });
824
+ };
825
+ return KHR_materials_emissive_strength;
826
+ }());
827
+
828
+ _glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_emissive_strength(); });
829
+
830
+
762
831
  /***/ }),
763
832
 
764
833
  /***/ "../../../lts/serializers/dist/glTF/2.0/Extensions/KHR_materials_ior.js":
@@ -1435,7 +1504,7 @@ var KHR_texture_transform = /** @class */ (function () {
1435
1504
  transformIsRequired = true;
1436
1505
  }
1437
1506
  if (babylonTexture.wAng !== 0) {
1438
- textureTransform.rotation = babylonTexture.wAng;
1507
+ textureTransform.rotation = -babylonTexture.wAng;
1439
1508
  transformIsRequired = true;
1440
1509
  }
1441
1510
  if (babylonTexture.coordinatesIndex !== 0) {
@@ -1460,11 +1529,14 @@ var KHR_texture_transform = /** @class */ (function () {
1460
1529
  return;
1461
1530
  }
1462
1531
  /*
1463
- * The KHR_texture_transform schema only supports rotation around the origin.
1532
+ * The KHR_texture_transform schema only supports w rotation around the origin.
1464
1533
  * See https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates.
1465
1534
  */
1466
- if ((babylonTexture.uAng !== 0 || babylonTexture.wAng !== 0 || babylonTexture.vAng !== 0) &&
1467
- (babylonTexture.uRotationCenter !== 0 || babylonTexture.vRotationCenter !== 0)) {
1535
+ if (babylonTexture.uAng !== 0 || babylonTexture.vAng !== 0) {
1536
+ core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("".concat(context, ": Texture ").concat(babylonTexture.name, " with rotation in the u or v axis is not supported in glTF."));
1537
+ resolve(null);
1538
+ }
1539
+ else if (babylonTexture.wAng !== 0 && (babylonTexture.uRotationCenter !== 0 || babylonTexture.vRotationCenter !== 0)) {
1468
1540
  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));
1469
1541
  resolve(null);
1470
1542
  }
@@ -1492,6 +1564,7 @@ __webpack_require__.r(__webpack_exports__);
1492
1564
  /* harmony export */ "EXT_mesh_gpu_instancing": () => (/* reexport safe */ _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_10__.EXT_mesh_gpu_instancing),
1493
1565
  /* harmony export */ "KHR_lights_punctual": () => (/* reexport safe */ _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_1__.KHR_lights_punctual),
1494
1566
  /* harmony export */ "KHR_materials_clearcoat": () => (/* reexport safe */ _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_2__.KHR_materials_clearcoat),
1567
+ /* harmony export */ "KHR_materials_emissive_strength": () => (/* reexport safe */ _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__.KHR_materials_emissive_strength),
1495
1568
  /* harmony export */ "KHR_materials_ior": () => (/* reexport safe */ _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_6__.KHR_materials_ior),
1496
1569
  /* harmony export */ "KHR_materials_iridescence": () => (/* reexport safe */ _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_iridescence),
1497
1570
  /* harmony export */ "KHR_materials_sheen": () => (/* reexport safe */ _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_sheen),
@@ -1512,6 +1585,8 @@ __webpack_require__.r(__webpack_exports__);
1512
1585
  /* harmony import */ var _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KHR_materials_volume */ "../../../lts/serializers/dist/glTF/2.0/Extensions/KHR_materials_volume.js");
1513
1586
  /* harmony import */ var _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./KHR_materials_transmission */ "../../../lts/serializers/dist/glTF/2.0/Extensions/KHR_materials_transmission.js");
1514
1587
  /* harmony import */ var _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./EXT_mesh_gpu_instancing */ "../../../lts/serializers/dist/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js");
1588
+ /* harmony import */ var _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./KHR_materials_emissive_strength */ "../../../lts/serializers/dist/glTF/2.0/Extensions/KHR_materials_emissive_strength.js");
1589
+
1515
1590
 
1516
1591
 
1517
1592
 
@@ -5454,10 +5529,9 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5454
5529
  switch (_b.label) {
5455
5530
  case 0:
5456
5531
  textureUid = babylonTexture.uid;
5457
- if (!(textureUid in this._textureMap)) return [3 /*break*/, 1];
5458
- return [2 /*return*/, this._textureMap[textureUid]];
5459
- case 1: return [4 /*yield*/, this._getPixelsFromTexture(babylonTexture)];
5460
- case 2:
5532
+ if (!!(textureUid in this._textureMap)) return [3 /*break*/, 3];
5533
+ return [4 /*yield*/, this._getPixelsFromTexture(babylonTexture)];
5534
+ case 1:
5461
5535
  pixels_1 = _b.sent();
5462
5536
  if (!pixels_1) {
5463
5537
  return [2 /*return*/, null];
@@ -5497,10 +5571,12 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5497
5571
  }
5498
5572
  _a = this._exportTextureInfo;
5499
5573
  return [4 /*yield*/, imageIndexPromise];
5500
- case 3:
5574
+ case 2:
5501
5575
  textureInfo = _a.apply(this, [_b.sent(), samplerIndex, babylonTexture.coordinatesIndex]);
5502
5576
  this._textureMap[textureUid] = textureInfo;
5503
- return [2 /*return*/, textureInfo];
5577
+ this._exporter._extensionsPostExportTextures("exporter", this._textureMap[textureUid], babylonTexture);
5578
+ _b.label = 3;
5579
+ case 3: return [2 /*return*/, this._textureMap[textureUid]];
5504
5580
  }
5505
5581
  });
5506
5582
  });
@@ -5872,6 +5948,7 @@ __webpack_require__.r(__webpack_exports__);
5872
5948
  /* harmony export */ "GLTFData": () => (/* reexport safe */ _glTFData__WEBPACK_IMPORTED_MODULE_1__.GLTFData),
5873
5949
  /* harmony export */ "KHR_lights_punctual": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_lights_punctual),
5874
5950
  /* harmony export */ "KHR_materials_clearcoat": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_clearcoat),
5951
+ /* harmony export */ "KHR_materials_emissive_strength": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_emissive_strength),
5875
5952
  /* harmony export */ "KHR_materials_ior": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_ior),
5876
5953
  /* harmony export */ "KHR_materials_iridescence": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_iridescence),
5877
5954
  /* harmony export */ "KHR_materials_sheen": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_sheen),
@@ -5938,6 +6015,7 @@ __webpack_require__.r(__webpack_exports__);
5938
6015
  /* harmony export */ "GLTFData": () => (/* reexport safe */ _glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.GLTFData),
5939
6016
  /* harmony export */ "KHR_lights_punctual": () => (/* reexport safe */ _glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_lights_punctual),
5940
6017
  /* harmony export */ "KHR_materials_clearcoat": () => (/* reexport safe */ _glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_clearcoat),
6018
+ /* harmony export */ "KHR_materials_emissive_strength": () => (/* reexport safe */ _glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_emissive_strength),
5941
6019
  /* harmony export */ "KHR_materials_ior": () => (/* reexport safe */ _glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_ior),
5942
6020
  /* harmony export */ "KHR_materials_iridescence": () => (/* reexport safe */ _glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_iridescence),
5943
6021
  /* harmony export */ "KHR_materials_sheen": () => (/* reexport safe */ _glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_sheen),