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.
- package/babylon.glTF2Serializer.js +219 -341
- package/babylon.glTF2Serializer.js.map +1 -1
- package/babylon.glTF2Serializer.min.js +1 -1
- package/babylon.glTF2Serializer.min.js.map +1 -1
- package/babylonjs.serializers.d.ts +10 -31
- package/babylonjs.serializers.js +219 -341
- package/babylonjs.serializers.js.map +1 -1
- package/babylonjs.serializers.min.js +1 -1
- package/babylonjs.serializers.min.js.map +1 -1
- package/babylonjs.serializers.module.d.ts +21 -64
- package/package.json +3 -3
|
@@ -1389,22 +1389,18 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1389
1389
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1390
1390
|
/* harmony export */ "KHR_texture_transform": () => (/* binding */ KHR_texture_transform)
|
|
1391
1391
|
/* harmony export */ });
|
|
1392
|
-
/* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/
|
|
1392
|
+
/* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Misc/tools */ "core/Maths/math.vector");
|
|
1393
1393
|
/* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
|
|
1394
1394
|
/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFExporter */ "../../../lts/serializers/dist/glTF/2.0/glTFExporter.js");
|
|
1395
|
-
/* 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");
|
|
1396
|
-
|
|
1397
1395
|
|
|
1398
1396
|
|
|
1399
1397
|
var NAME = "KHR_texture_transform";
|
|
1400
|
-
|
|
1401
1398
|
/**
|
|
1402
1399
|
* @internal
|
|
1403
1400
|
*/
|
|
1404
1401
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1405
1402
|
var KHR_texture_transform = /** @class */ (function () {
|
|
1406
1403
|
function KHR_texture_transform() {
|
|
1407
|
-
this._recordedTextures = [];
|
|
1408
1404
|
/** Name of this extension */
|
|
1409
1405
|
this.name = NAME;
|
|
1410
1406
|
/** Defines whether this extension is enabled */
|
|
@@ -1414,12 +1410,7 @@ var KHR_texture_transform = /** @class */ (function () {
|
|
|
1414
1410
|
/** Reference to the glTF exporter */
|
|
1415
1411
|
this._wasUsed = false;
|
|
1416
1412
|
}
|
|
1417
|
-
KHR_texture_transform.prototype.dispose = function () {
|
|
1418
|
-
for (var _i = 0, _a = this._recordedTextures; _i < _a.length; _i++) {
|
|
1419
|
-
var texture = _a[_i];
|
|
1420
|
-
texture.dispose();
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1413
|
+
KHR_texture_transform.prototype.dispose = function () { };
|
|
1423
1414
|
Object.defineProperty(KHR_texture_transform.prototype, "wasUsed", {
|
|
1424
1415
|
/** @internal */
|
|
1425
1416
|
get: function () {
|
|
@@ -1462,67 +1453,23 @@ var KHR_texture_transform = /** @class */ (function () {
|
|
|
1462
1453
|
}
|
|
1463
1454
|
};
|
|
1464
1455
|
KHR_texture_transform.prototype.preExportTextureAsync = function (context, babylonTexture) {
|
|
1465
|
-
var _this = this;
|
|
1466
1456
|
return new Promise(function (resolve, reject) {
|
|
1467
1457
|
var scene = babylonTexture.getScene();
|
|
1468
1458
|
if (!scene) {
|
|
1469
1459
|
reject("".concat(context, ": \"scene\" is not defined for Babylon texture ").concat(babylonTexture.name, "!"));
|
|
1470
1460
|
return;
|
|
1471
1461
|
}
|
|
1472
|
-
var bakeTextureTransform = false;
|
|
1473
1462
|
/*
|
|
1474
1463
|
* The KHR_texture_transform schema only supports rotation around the origin.
|
|
1475
|
-
*
|
|
1476
|
-
* see: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates
|
|
1464
|
+
* See https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates.
|
|
1477
1465
|
*/
|
|
1478
1466
|
if ((babylonTexture.uAng !== 0 || babylonTexture.wAng !== 0 || babylonTexture.vAng !== 0) &&
|
|
1479
1467
|
(babylonTexture.uRotationCenter !== 0 || babylonTexture.vRotationCenter !== 0)) {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
if (!bakeTextureTransform) {
|
|
1483
|
-
resolve(babylonTexture);
|
|
1484
|
-
return;
|
|
1485
|
-
}
|
|
1486
|
-
return _this._textureTransformTextureAsync(babylonTexture, scene)
|
|
1487
|
-
.then(function (proceduralTexture) {
|
|
1488
|
-
resolve(proceduralTexture);
|
|
1489
|
-
})
|
|
1490
|
-
.catch(function (e) {
|
|
1491
|
-
reject(e);
|
|
1492
|
-
});
|
|
1493
|
-
});
|
|
1494
|
-
};
|
|
1495
|
-
/**
|
|
1496
|
-
* Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
|
|
1497
|
-
* @param babylonTexture
|
|
1498
|
-
* @param scene
|
|
1499
|
-
*/
|
|
1500
|
-
KHR_texture_transform.prototype._textureTransformTextureAsync = function (babylonTexture, scene) {
|
|
1501
|
-
var _this = this;
|
|
1502
|
-
return new Promise(function (resolve) {
|
|
1503
|
-
var proceduralTexture = new core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.ProceduralTexture("".concat(babylonTexture.name), babylonTexture.getSize(), "textureTransform", scene);
|
|
1504
|
-
if (!proceduralTexture) {
|
|
1505
|
-
core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.Log("Cannot create procedural texture for ".concat(babylonTexture.name, "!"));
|
|
1506
|
-
resolve(babylonTexture);
|
|
1507
|
-
}
|
|
1508
|
-
proceduralTexture.reservedDataStore = {
|
|
1509
|
-
hidden: true,
|
|
1510
|
-
source: babylonTexture,
|
|
1511
|
-
};
|
|
1512
|
-
_this._recordedTextures.push(proceduralTexture);
|
|
1513
|
-
proceduralTexture.coordinatesIndex = babylonTexture.coordinatesIndex;
|
|
1514
|
-
proceduralTexture.setTexture("textureSampler", babylonTexture);
|
|
1515
|
-
proceduralTexture.setMatrix("textureTransformMat", babylonTexture.getTextureMatrix());
|
|
1516
|
-
// isReady trigger creation of effect if it doesnt exist yet
|
|
1517
|
-
if (proceduralTexture.isReady()) {
|
|
1518
|
-
proceduralTexture.render();
|
|
1519
|
-
resolve(proceduralTexture);
|
|
1468
|
+
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
|
+
resolve(null);
|
|
1520
1470
|
}
|
|
1521
1471
|
else {
|
|
1522
|
-
|
|
1523
|
-
proceduralTexture.render();
|
|
1524
|
-
resolve(proceduralTexture);
|
|
1525
|
-
});
|
|
1472
|
+
resolve(babylonTexture);
|
|
1526
1473
|
}
|
|
1527
1474
|
});
|
|
1528
1475
|
};
|
|
@@ -3356,8 +3303,8 @@ var _Exporter = /** @class */ (function () {
|
|
|
3356
3303
|
imageData = _this._imageData[image.uri];
|
|
3357
3304
|
_this._orderedImageData.push(imageData);
|
|
3358
3305
|
imageName = image.uri.split(".")[0] + " image";
|
|
3359
|
-
bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_3__._GLTFUtilities._CreateBufferView(0, byteOffset, imageData.data.
|
|
3360
|
-
byteOffset += imageData.data.
|
|
3306
|
+
bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_3__._GLTFUtilities._CreateBufferView(0, byteOffset, imageData.data.byteLength, undefined, imageName);
|
|
3307
|
+
byteOffset += imageData.data.byteLength;
|
|
3361
3308
|
_this._bufferViews.push(bufferView);
|
|
3362
3309
|
image.bufferView = _this._bufferViews.length - 1;
|
|
3363
3310
|
image.name = imageName;
|
|
@@ -3514,7 +3461,7 @@ var _Exporter = /** @class */ (function () {
|
|
|
3514
3461
|
var glbData = [headerBuffer, jsonChunkBuffer, binaryChunkBuffer, binaryBuffer];
|
|
3515
3462
|
// binary data
|
|
3516
3463
|
for (var i = 0; i < _this._orderedImageData.length; ++i) {
|
|
3517
|
-
glbData.push(_this._orderedImageData[i].data
|
|
3464
|
+
glbData.push(_this._orderedImageData[i].data);
|
|
3518
3465
|
}
|
|
3519
3466
|
glbData.push(binPaddingBuffer);
|
|
3520
3467
|
glbData.push(imagePaddingBuffer);
|
|
@@ -4621,6 +4568,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4621
4568
|
|
|
4622
4569
|
|
|
4623
4570
|
|
|
4571
|
+
function getFileExtensionFromMimeType(mimeType) {
|
|
4572
|
+
switch (mimeType) {
|
|
4573
|
+
case "image/jpeg" /* JPEG */:
|
|
4574
|
+
return ".jpg";
|
|
4575
|
+
case "image/png" /* PNG */:
|
|
4576
|
+
return ".png";
|
|
4577
|
+
case "image/webp" /* WEBP */:
|
|
4578
|
+
return ".webp";
|
|
4579
|
+
}
|
|
4580
|
+
}
|
|
4624
4581
|
/**
|
|
4625
4582
|
* Utility methods for working with glTF material conversion properties. This class should only be used internally
|
|
4626
4583
|
* @internal
|
|
@@ -4631,6 +4588,8 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
4631
4588
|
* Mapping to store textures
|
|
4632
4589
|
*/
|
|
4633
4590
|
this._textureMap = {};
|
|
4591
|
+
// Mapping of internal textures to images to avoid exporting duplicate images.
|
|
4592
|
+
this._internalTextureToImage = {};
|
|
4634
4593
|
this._textureMap = {};
|
|
4635
4594
|
this._exporter = exporter;
|
|
4636
4595
|
}
|
|
@@ -4815,68 +4774,68 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
4815
4774
|
var materialMap = this._exporter._materialMap;
|
|
4816
4775
|
var materials = this._exporter._materials;
|
|
4817
4776
|
var promises = [];
|
|
4818
|
-
var
|
|
4819
|
-
var
|
|
4777
|
+
var pbrMetallicRoughness = this._convertToGLTFPBRMetallicRoughness(babylonStandardMaterial);
|
|
4778
|
+
var material = { name: babylonStandardMaterial.name };
|
|
4820
4779
|
if (babylonStandardMaterial.backFaceCulling != null && !babylonStandardMaterial.backFaceCulling) {
|
|
4821
4780
|
if (!babylonStandardMaterial.twoSidedLighting) {
|
|
4822
4781
|
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.");
|
|
4823
4782
|
}
|
|
4824
|
-
|
|
4783
|
+
material.doubleSided = true;
|
|
4825
4784
|
}
|
|
4826
4785
|
if (hasTextureCoords) {
|
|
4827
4786
|
if (babylonStandardMaterial.diffuseTexture) {
|
|
4828
|
-
promises.push(this._exportTextureAsync(babylonStandardMaterial.diffuseTexture, mimeType).then(function (
|
|
4829
|
-
if (
|
|
4830
|
-
|
|
4787
|
+
promises.push(this._exportTextureAsync(babylonStandardMaterial.diffuseTexture, mimeType).then(function (textureInfo) {
|
|
4788
|
+
if (textureInfo) {
|
|
4789
|
+
pbrMetallicRoughness.baseColorTexture = textureInfo;
|
|
4831
4790
|
}
|
|
4832
4791
|
}));
|
|
4833
4792
|
}
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4793
|
+
var bumpTexture_1 = babylonStandardMaterial.bumpTexture;
|
|
4794
|
+
if (bumpTexture_1) {
|
|
4795
|
+
promises.push(this._exportTextureAsync(bumpTexture_1, mimeType).then(function (textureInfo) {
|
|
4796
|
+
if (textureInfo) {
|
|
4797
|
+
material.normalTexture = textureInfo;
|
|
4798
|
+
if (bumpTexture_1.level !== 1) {
|
|
4799
|
+
material.normalTexture.scale = bumpTexture_1.level;
|
|
4840
4800
|
}
|
|
4841
4801
|
}
|
|
4842
4802
|
}));
|
|
4843
4803
|
}
|
|
4844
4804
|
if (babylonStandardMaterial.emissiveTexture) {
|
|
4845
|
-
|
|
4846
|
-
promises.push(this._exportTextureAsync(babylonStandardMaterial.emissiveTexture, mimeType).then(function (
|
|
4847
|
-
if (
|
|
4848
|
-
|
|
4805
|
+
material.emissiveFactor = [1.0, 1.0, 1.0];
|
|
4806
|
+
promises.push(this._exportTextureAsync(babylonStandardMaterial.emissiveTexture, mimeType).then(function (textureInfo) {
|
|
4807
|
+
if (textureInfo) {
|
|
4808
|
+
material.emissiveTexture = textureInfo;
|
|
4849
4809
|
}
|
|
4850
4810
|
}));
|
|
4851
4811
|
}
|
|
4852
4812
|
if (babylonStandardMaterial.ambientTexture) {
|
|
4853
|
-
promises.push(this._exportTextureAsync(babylonStandardMaterial.ambientTexture, mimeType).then(function (
|
|
4854
|
-
if (
|
|
4813
|
+
promises.push(this._exportTextureAsync(babylonStandardMaterial.ambientTexture, mimeType).then(function (textureInfo) {
|
|
4814
|
+
if (textureInfo) {
|
|
4855
4815
|
var occlusionTexture = {
|
|
4856
|
-
index:
|
|
4816
|
+
index: textureInfo.index,
|
|
4857
4817
|
};
|
|
4858
|
-
|
|
4859
|
-
occlusionTexture.strength = 1.0;
|
|
4818
|
+
material.occlusionTexture = occlusionTexture;
|
|
4860
4819
|
}
|
|
4861
4820
|
}));
|
|
4862
4821
|
}
|
|
4863
4822
|
}
|
|
4864
4823
|
if (babylonStandardMaterial.alpha < 1.0 || babylonStandardMaterial.opacityTexture) {
|
|
4865
4824
|
if (babylonStandardMaterial.alphaMode === core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_COMBINE) {
|
|
4866
|
-
|
|
4825
|
+
material.alphaMode = "BLEND" /* BLEND */;
|
|
4867
4826
|
}
|
|
4868
4827
|
else {
|
|
4869
4828
|
core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn(babylonStandardMaterial.name + ": glTF 2.0 does not support alpha mode: " + babylonStandardMaterial.alphaMode.toString());
|
|
4870
4829
|
}
|
|
4871
4830
|
}
|
|
4872
4831
|
if (babylonStandardMaterial.emissiveColor && !_GLTFMaterialExporter._FuzzyEquals(babylonStandardMaterial.emissiveColor, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.Black(), _GLTFMaterialExporter._Epsilon)) {
|
|
4873
|
-
|
|
4832
|
+
material.emissiveFactor = babylonStandardMaterial.emissiveColor.asArray();
|
|
4874
4833
|
}
|
|
4875
|
-
|
|
4876
|
-
_GLTFMaterialExporter._SetAlphaMode(
|
|
4877
|
-
materials.push(
|
|
4834
|
+
material.pbrMetallicRoughness = pbrMetallicRoughness;
|
|
4835
|
+
_GLTFMaterialExporter._SetAlphaMode(material, babylonStandardMaterial);
|
|
4836
|
+
materials.push(material);
|
|
4878
4837
|
materialMap[babylonStandardMaterial.uniqueId] = materials.length - 1;
|
|
4879
|
-
return this._finishMaterial(promises,
|
|
4838
|
+
return this._finishMaterial(promises, material, babylonStandardMaterial, mimeType);
|
|
4880
4839
|
};
|
|
4881
4840
|
_GLTFMaterialExporter.prototype._finishMaterial = function (promises, glTFMaterial, babylonMaterial, mimeType) {
|
|
4882
4841
|
var _this = this;
|
|
@@ -4910,11 +4869,9 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
4910
4869
|
* @param mimeType mimetype of the image
|
|
4911
4870
|
* @returns base64 image string
|
|
4912
4871
|
*/
|
|
4913
|
-
_GLTFMaterialExporter.prototype.
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
return new Promise(function (resolve) { return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(_this, void 0, void 0, function () {
|
|
4917
|
-
var textureType, hostingScene, engine, tempTexture, data, base64;
|
|
4872
|
+
_GLTFMaterialExporter.prototype._getImageDataAsync = function (buffer, width, height, mimeType) {
|
|
4873
|
+
return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
|
|
4874
|
+
var textureType, hostingScene, engine, tempTexture, data;
|
|
4918
4875
|
return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
|
|
4919
4876
|
switch (_a.label) {
|
|
4920
4877
|
case 0:
|
|
@@ -4928,14 +4885,11 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
4928
4885
|
return [4 /*yield*/, engine._readTexturePixels(tempTexture, width, height)];
|
|
4929
4886
|
case 2:
|
|
4930
4887
|
data = _a.sent();
|
|
4931
|
-
return [4 /*yield*/, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DumpDataAsync(width, height, data, mimeType, undefined, true,
|
|
4932
|
-
case 3:
|
|
4933
|
-
base64 = _a.sent();
|
|
4934
|
-
resolve(base64);
|
|
4935
|
-
return [2 /*return*/];
|
|
4888
|
+
return [4 /*yield*/, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DumpDataAsync(width, height, data, mimeType, undefined, true, true)];
|
|
4889
|
+
case 3: return [2 /*return*/, (_a.sent())];
|
|
4936
4890
|
}
|
|
4937
4891
|
});
|
|
4938
|
-
});
|
|
4892
|
+
});
|
|
4939
4893
|
};
|
|
4940
4894
|
/**
|
|
4941
4895
|
* Generates a white texture based on the specified width and height
|
|
@@ -5026,11 +4980,11 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
5026
4980
|
_GLTFMaterialExporter.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync = function (diffuseTexture, specularGlossinessTexture, factors, mimeType) {
|
|
5027
4981
|
var _a;
|
|
5028
4982
|
return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
|
|
5029
|
-
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
|
|
4983
|
+
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;
|
|
5030
4984
|
return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_b) {
|
|
5031
4985
|
switch (_b.label) {
|
|
5032
4986
|
case 0:
|
|
5033
|
-
promises =
|
|
4987
|
+
promises = new Array();
|
|
5034
4988
|
if (!(diffuseTexture || specularGlossinessTexture)) {
|
|
5035
4989
|
return [2 /*return*/, Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!")];
|
|
5036
4990
|
}
|
|
@@ -5127,16 +5081,14 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
5127
5081
|
}
|
|
5128
5082
|
}
|
|
5129
5083
|
if (writeOutMetallicRoughnessTexture) {
|
|
5130
|
-
|
|
5131
|
-
metallicRoughnessFactors_1.
|
|
5132
|
-
});
|
|
5133
|
-
promises.push(promise);
|
|
5084
|
+
promises.push(this._getImageDataAsync(metallicRoughnessBuffer, width, height, mimeType).then(function (data) {
|
|
5085
|
+
metallicRoughnessFactors_1.metallicRoughnessTextureData = data;
|
|
5086
|
+
}));
|
|
5134
5087
|
}
|
|
5135
5088
|
if (writeOutBaseColorTexture) {
|
|
5136
|
-
|
|
5137
|
-
metallicRoughnessFactors_1.
|
|
5138
|
-
});
|
|
5139
|
-
promises.push(promise);
|
|
5089
|
+
promises.push(this._getImageDataAsync(baseColorBuffer, width, height, mimeType).then(function (data) {
|
|
5090
|
+
metallicRoughnessFactors_1.baseColorTextureData = data;
|
|
5091
|
+
}));
|
|
5140
5092
|
}
|
|
5141
5093
|
return [2 /*return*/, Promise.all(promises).then(function () {
|
|
5142
5094
|
return metallicRoughnessFactors_1;
|
|
@@ -5231,71 +5183,79 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
5231
5183
|
return metallicRoughness;
|
|
5232
5184
|
});
|
|
5233
5185
|
};
|
|
5234
|
-
_GLTFMaterialExporter.prototype.
|
|
5235
|
-
var sampler =
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5186
|
+
_GLTFMaterialExporter.prototype._getTextureSampler = function (texture) {
|
|
5187
|
+
var sampler = {};
|
|
5188
|
+
if (!texture || !(texture instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture)) {
|
|
5189
|
+
return sampler;
|
|
5190
|
+
}
|
|
5191
|
+
var wrapS = this._getGLTFTextureWrapMode(texture.wrapU);
|
|
5192
|
+
if (wrapS !== 10497 /* REPEAT */) {
|
|
5193
|
+
sampler.wrapS = wrapS;
|
|
5194
|
+
}
|
|
5195
|
+
var wrapT = this._getGLTFTextureWrapMode(texture.wrapV);
|
|
5196
|
+
if (wrapT !== 10497 /* REPEAT */) {
|
|
5197
|
+
sampler.wrapT = wrapT;
|
|
5198
|
+
}
|
|
5199
|
+
switch (texture.samplingMode) {
|
|
5200
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_LINEAR: {
|
|
5201
|
+
sampler.magFilter = 9729 /* LINEAR */;
|
|
5202
|
+
sampler.minFilter = 9729 /* LINEAR */;
|
|
5203
|
+
break;
|
|
5204
|
+
}
|
|
5205
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_NEAREST: {
|
|
5206
|
+
sampler.magFilter = 9729 /* LINEAR */;
|
|
5207
|
+
sampler.minFilter = 9728 /* NEAREST */;
|
|
5208
|
+
break;
|
|
5209
|
+
}
|
|
5210
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_LINEAR: {
|
|
5211
|
+
sampler.magFilter = 9728 /* NEAREST */;
|
|
5212
|
+
sampler.minFilter = 9729 /* LINEAR */;
|
|
5213
|
+
break;
|
|
5214
|
+
}
|
|
5215
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_LINEAR_MIPLINEAR: {
|
|
5216
|
+
sampler.magFilter = 9728 /* NEAREST */;
|
|
5217
|
+
sampler.minFilter = 9987 /* LINEAR_MIPMAP_LINEAR */;
|
|
5218
|
+
break;
|
|
5219
|
+
}
|
|
5220
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_NEAREST: {
|
|
5221
|
+
sampler.magFilter = 9728 /* NEAREST */;
|
|
5222
|
+
sampler.minFilter = 9728 /* NEAREST */;
|
|
5223
|
+
break;
|
|
5224
|
+
}
|
|
5225
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_LINEAR_MIPNEAREST: {
|
|
5226
|
+
sampler.magFilter = 9728 /* NEAREST */;
|
|
5227
|
+
sampler.minFilter = 9985 /* LINEAR_MIPMAP_NEAREST */;
|
|
5228
|
+
break;
|
|
5229
|
+
}
|
|
5230
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_NEAREST_MIPNEAREST: {
|
|
5231
|
+
sampler.magFilter = 9729 /* LINEAR */;
|
|
5232
|
+
sampler.minFilter = 9984 /* NEAREST_MIPMAP_NEAREST */;
|
|
5233
|
+
break;
|
|
5234
|
+
}
|
|
5235
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_NEAREST_MIPLINEAR: {
|
|
5236
|
+
sampler.magFilter = 9729 /* LINEAR */;
|
|
5237
|
+
sampler.minFilter = 9986 /* NEAREST_MIPMAP_LINEAR */;
|
|
5238
|
+
break;
|
|
5239
|
+
}
|
|
5240
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_NEAREST_MIPLINEAR: {
|
|
5241
|
+
sampler.magFilter = 9728 /* NEAREST */;
|
|
5242
|
+
sampler.minFilter = 9986 /* NEAREST_MIPMAP_LINEAR */;
|
|
5243
|
+
break;
|
|
5244
|
+
}
|
|
5245
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_LINEAR_MIPLINEAR: {
|
|
5246
|
+
sampler.magFilter = 9729 /* LINEAR */;
|
|
5247
|
+
sampler.minFilter = 9987 /* LINEAR_MIPMAP_LINEAR */;
|
|
5248
|
+
break;
|
|
5249
|
+
}
|
|
5250
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.LINEAR_LINEAR_MIPNEAREST: {
|
|
5251
|
+
sampler.magFilter = 9729 /* LINEAR */;
|
|
5252
|
+
sampler.minFilter = 9985 /* LINEAR_MIPMAP_NEAREST */;
|
|
5253
|
+
break;
|
|
5254
|
+
}
|
|
5255
|
+
case core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_NEAREST_MIPNEAREST: {
|
|
5256
|
+
sampler.magFilter = 9728 /* NEAREST */;
|
|
5257
|
+
sampler.minFilter = 9984 /* NEAREST_MIPMAP_NEAREST */;
|
|
5258
|
+
break;
|
|
5299
5259
|
}
|
|
5300
5260
|
}
|
|
5301
5261
|
return sampler;
|
|
@@ -5317,15 +5277,6 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
5317
5277
|
}
|
|
5318
5278
|
}
|
|
5319
5279
|
};
|
|
5320
|
-
_GLTFMaterialExporter.prototype._getGLTFTextureWrapModesSampler = function (texture) {
|
|
5321
|
-
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);
|
|
5322
|
-
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);
|
|
5323
|
-
if (wrapS === 10497 /* REPEAT */ && wrapT === 10497 /* REPEAT */) {
|
|
5324
|
-
// default wrapping mode in glTF, so omitting
|
|
5325
|
-
return {};
|
|
5326
|
-
}
|
|
5327
|
-
return { wrapS: wrapS, wrapT: wrapT };
|
|
5328
|
-
};
|
|
5329
5280
|
/**
|
|
5330
5281
|
* Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
|
|
5331
5282
|
* @param babylonPBRMaterial BJS PBR Metallic Roughness Material
|
|
@@ -5334,46 +5285,31 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
5334
5285
|
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
|
5335
5286
|
* @returns glTF PBR Metallic Roughness factors
|
|
5336
5287
|
*/
|
|
5337
|
-
_GLTFMaterialExporter.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType,
|
|
5288
|
+
_GLTFMaterialExporter.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, pbrMetallicRoughness, hasTextureCoords) {
|
|
5338
5289
|
var _this = this;
|
|
5339
5290
|
return Promise.resolve().then(function () {
|
|
5340
|
-
var samplers = _this._exporter._samplers;
|
|
5341
|
-
var textures = _this._exporter._textures;
|
|
5342
|
-
var diffuseColor = babylonPBRMaterial._albedoColor;
|
|
5343
|
-
var specularColor = babylonPBRMaterial._reflectivityColor;
|
|
5344
|
-
var glossiness = babylonPBRMaterial._microSurface;
|
|
5345
5291
|
var specGloss = {
|
|
5346
|
-
diffuseColor:
|
|
5347
|
-
specularColor:
|
|
5348
|
-
glossiness:
|
|
5292
|
+
diffuseColor: babylonPBRMaterial._albedoColor,
|
|
5293
|
+
specularColor: babylonPBRMaterial._reflectivityColor,
|
|
5294
|
+
glossiness: babylonPBRMaterial._microSurface,
|
|
5349
5295
|
};
|
|
5350
|
-
var samplerIndex = null;
|
|
5351
5296
|
var albedoTexture = babylonPBRMaterial._albedoTexture;
|
|
5352
5297
|
var reflectivityTexture = babylonPBRMaterial._reflectivityTexture;
|
|
5353
|
-
if (albedoTexture) {
|
|
5354
|
-
var sampler = _this._getGLTFTextureSampler(albedoTexture);
|
|
5355
|
-
if (sampler.magFilter != null && sampler.minFilter != null && sampler.wrapS != null && sampler.wrapT != null) {
|
|
5356
|
-
samplers.push(sampler);
|
|
5357
|
-
samplerIndex = samplers.length - 1;
|
|
5358
|
-
}
|
|
5359
|
-
}
|
|
5360
5298
|
var useMicrosurfaceFromReflectivityMapAlpha = babylonPBRMaterial._useMicroSurfaceFromReflectivityMapAlpha;
|
|
5361
5299
|
if (reflectivityTexture && !useMicrosurfaceFromReflectivityMapAlpha) {
|
|
5362
5300
|
return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");
|
|
5363
5301
|
}
|
|
5364
5302
|
if ((albedoTexture || reflectivityTexture) && hasTextureCoords) {
|
|
5303
|
+
var samplerIndex_1 = _this._exportTextureSampler(albedoTexture || reflectivityTexture);
|
|
5365
5304
|
return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(albedoTexture, reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
}
|
|
5305
|
+
var textures = _this._exporter._textures;
|
|
5306
|
+
if (metallicRoughnessFactors.baseColorTextureData) {
|
|
5307
|
+
var imageIndex = _this._exportImage("baseColor".concat(textures.length), mimeType, metallicRoughnessFactors.baseColorTextureData);
|
|
5308
|
+
pbrMetallicRoughness.baseColorTexture = _this._exportTextureInfo(imageIndex, samplerIndex_1, albedoTexture === null || albedoTexture === void 0 ? void 0 : albedoTexture.coordinatesIndex);
|
|
5371
5309
|
}
|
|
5372
|
-
if (metallicRoughnessFactors.
|
|
5373
|
-
var
|
|
5374
|
-
|
|
5375
|
-
glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFMRColorTexture;
|
|
5376
|
-
}
|
|
5310
|
+
if (metallicRoughnessFactors.metallicRoughnessTextureData) {
|
|
5311
|
+
var imageIndex = _this._exportImage("metallicRoughness".concat(textures.length), mimeType, metallicRoughnessFactors.metallicRoughnessTextureData);
|
|
5312
|
+
pbrMetallicRoughness.metallicRoughnessTexture = _this._exportTextureInfo(imageIndex, samplerIndex_1, reflectivityTexture === null || reflectivityTexture === void 0 ? void 0 : reflectivityTexture.coordinatesIndex);
|
|
5377
5313
|
}
|
|
5378
5314
|
return metallicRoughnessFactors;
|
|
5379
5315
|
});
|
|
@@ -5435,13 +5371,13 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
5435
5371
|
glTFMaterial.doubleSided = true;
|
|
5436
5372
|
}
|
|
5437
5373
|
if (hasTextureCoords) {
|
|
5438
|
-
var
|
|
5439
|
-
if (
|
|
5440
|
-
var promise = this._exportTextureAsync(
|
|
5374
|
+
var bumpTexture_2 = babylonPBRMaterial._bumpTexture;
|
|
5375
|
+
if (bumpTexture_2) {
|
|
5376
|
+
var promise = this._exportTextureAsync(bumpTexture_2, mimeType).then(function (glTFTexture) {
|
|
5441
5377
|
if (glTFTexture) {
|
|
5442
5378
|
glTFMaterial.normalTexture = glTFTexture;
|
|
5443
|
-
if (
|
|
5444
|
-
glTFMaterial.normalTexture.scale =
|
|
5379
|
+
if (bumpTexture_2.level !== 1) {
|
|
5380
|
+
glTFMaterial.normalTexture.scale = bumpTexture_2.level;
|
|
5445
5381
|
}
|
|
5446
5382
|
}
|
|
5447
5383
|
});
|
|
@@ -5510,10 +5446,8 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
5510
5446
|
});
|
|
5511
5447
|
};
|
|
5512
5448
|
_GLTFMaterialExporter.prototype._exportTextureInfoAsync = function (babylonTexture, mimeType) {
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
var textureUid, pixels, samplers, sampler, samplerIndex_1, foundSamplerIndex, i, s, size;
|
|
5516
|
-
var _this = this;
|
|
5449
|
+
return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
|
|
5450
|
+
var textureUid, pixels, samplerIndex, textureMimeType, internalTextureToImage, internalTextureUniqueId, imageIndex, size, data, textureInfo;
|
|
5517
5451
|
return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
|
|
5518
5452
|
switch (_a.label) {
|
|
5519
5453
|
case 0:
|
|
@@ -5526,118 +5460,86 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
5526
5460
|
if (!pixels) {
|
|
5527
5461
|
return [2 /*return*/, null];
|
|
5528
5462
|
}
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
for (i = 0; i < samplers.length; ++i) {
|
|
5534
|
-
s = samplers[i];
|
|
5535
|
-
if (s.minFilter === sampler.minFilter && s.magFilter === sampler.magFilter && s.wrapS === sampler.wrapS && s.wrapT === sampler.wrapT) {
|
|
5536
|
-
foundSamplerIndex = i;
|
|
5537
|
-
break;
|
|
5538
|
-
}
|
|
5539
|
-
}
|
|
5540
|
-
if (foundSamplerIndex == null) {
|
|
5541
|
-
samplers.push(sampler);
|
|
5542
|
-
samplerIndex_1 = samplers.length - 1;
|
|
5543
|
-
}
|
|
5544
|
-
else {
|
|
5545
|
-
samplerIndex_1 = foundSamplerIndex;
|
|
5546
|
-
}
|
|
5547
|
-
size = babylonTexture.getSize();
|
|
5548
|
-
// Preserve texture mime type if defined
|
|
5549
|
-
if (babylonTexture.mimeType) {
|
|
5550
|
-
switch (babylonTexture.mimeType) {
|
|
5463
|
+
samplerIndex = this._exportTextureSampler(babylonTexture);
|
|
5464
|
+
textureMimeType = babylonTexture.mimeType;
|
|
5465
|
+
if (textureMimeType) {
|
|
5466
|
+
switch (textureMimeType) {
|
|
5551
5467
|
case "image/jpeg":
|
|
5552
|
-
mimeType = "image/jpeg" /* JPEG */;
|
|
5553
|
-
break;
|
|
5554
5468
|
case "image/png":
|
|
5555
|
-
mimeType = "image/png" /* PNG */;
|
|
5556
|
-
break;
|
|
5557
5469
|
case "image/webp":
|
|
5558
|
-
mimeType =
|
|
5470
|
+
mimeType = textureMimeType;
|
|
5471
|
+
break;
|
|
5472
|
+
default:
|
|
5473
|
+
core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Unsupported media type: ${textureMimeType}");
|
|
5559
5474
|
break;
|
|
5560
5475
|
}
|
|
5561
5476
|
}
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5477
|
+
internalTextureToImage = this._internalTextureToImage;
|
|
5478
|
+
internalTextureUniqueId = babylonTexture.getInternalTexture().uniqueId;
|
|
5479
|
+
internalTextureToImage[internalTextureUniqueId] || (internalTextureToImage[internalTextureUniqueId] = {});
|
|
5480
|
+
imageIndex = internalTextureToImage[internalTextureUniqueId][mimeType];
|
|
5481
|
+
if (!(imageIndex === undefined)) return [3 /*break*/, 4];
|
|
5482
|
+
size = babylonTexture.getSize();
|
|
5483
|
+
return [4 /*yield*/, this._getImageDataAsync(pixels, size.width, size.height, mimeType)];
|
|
5484
|
+
case 3:
|
|
5485
|
+
data = _a.sent();
|
|
5486
|
+
imageIndex = this._exportImage(babylonTexture.name, mimeType, data);
|
|
5487
|
+
internalTextureToImage[internalTextureUniqueId][mimeType] = imageIndex;
|
|
5488
|
+
_a.label = 4;
|
|
5489
|
+
case 4:
|
|
5490
|
+
textureInfo = this._exportTextureInfo(imageIndex, samplerIndex, babylonTexture.coordinatesIndex);
|
|
5491
|
+
this._textureMap[textureUid] = textureInfo;
|
|
5492
|
+
return [2 /*return*/, textureInfo];
|
|
5570
5493
|
}
|
|
5571
5494
|
});
|
|
5572
|
-
});
|
|
5495
|
+
});
|
|
5573
5496
|
};
|
|
5574
|
-
|
|
5575
|
-
* Builds a texture from base64 string
|
|
5576
|
-
* @param base64Texture base64 texture string
|
|
5577
|
-
* @param baseTextureName Name to use for the texture
|
|
5578
|
-
* @param mimeType image mime type for the texture
|
|
5579
|
-
* @param texCoordIndex
|
|
5580
|
-
* @param samplerIndex
|
|
5581
|
-
* @returns glTF texture info, or null if the texture format is not supported
|
|
5582
|
-
*/
|
|
5583
|
-
_GLTFMaterialExporter.prototype._getTextureInfoFromBase64 = function (base64Texture, baseTextureName, mimeType, texCoordIndex, samplerIndex) {
|
|
5584
|
-
var textures = this._exporter._textures;
|
|
5585
|
-
var images = this._exporter._images;
|
|
5497
|
+
_GLTFMaterialExporter.prototype._exportImage = function (name, mimeType, data) {
|
|
5586
5498
|
var imageData = this._exporter._imageData;
|
|
5587
|
-
var
|
|
5588
|
-
var
|
|
5589
|
-
|
|
5590
|
-
|
|
5499
|
+
var baseName = name.replace(/\.\/|\/|\.\\|\\/g, "_");
|
|
5500
|
+
var extension = getFileExtensionFromMimeType(mimeType);
|
|
5501
|
+
var fileName = baseName + extension;
|
|
5502
|
+
if (fileName in imageData) {
|
|
5503
|
+
fileName = "".concat(baseName, "_").concat(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.RandomId()).concat(extension);
|
|
5504
|
+
}
|
|
5505
|
+
imageData[fileName] = {
|
|
5506
|
+
data: data,
|
|
5507
|
+
mimeType: mimeType,
|
|
5591
5508
|
};
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
var
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
imageData[textureName] = imageValues;
|
|
5609
|
-
if (mimeType === "image/jpeg" /* JPEG */ || mimeType === "image/png" /* PNG */ || mimeType === "image/webp" /* WEBP */) {
|
|
5610
|
-
var glTFImage = {
|
|
5611
|
-
name: baseTextureName,
|
|
5612
|
-
uri: textureName,
|
|
5613
|
-
};
|
|
5614
|
-
var foundIndex = null;
|
|
5615
|
-
for (var i = 0; i < images.length; ++i) {
|
|
5616
|
-
if (images[i].uri === originalTextureName) {
|
|
5617
|
-
foundIndex = i;
|
|
5618
|
-
break;
|
|
5619
|
-
}
|
|
5620
|
-
}
|
|
5621
|
-
if (foundIndex == null) {
|
|
5622
|
-
images.push(glTFImage);
|
|
5623
|
-
glTFTexture.source = images.length - 1;
|
|
5624
|
-
}
|
|
5625
|
-
else {
|
|
5626
|
-
glTFTexture.source = foundIndex;
|
|
5627
|
-
}
|
|
5628
|
-
textures.push(glTFTexture);
|
|
5629
|
-
textureInfo = {
|
|
5630
|
-
index: textures.length - 1,
|
|
5631
|
-
};
|
|
5632
|
-
if (texCoordIndex != null) {
|
|
5633
|
-
textureInfo.texCoord = texCoordIndex;
|
|
5634
|
-
}
|
|
5509
|
+
var images = this._exporter._images;
|
|
5510
|
+
images.push({
|
|
5511
|
+
name: name,
|
|
5512
|
+
uri: fileName,
|
|
5513
|
+
});
|
|
5514
|
+
return images.length - 1;
|
|
5515
|
+
};
|
|
5516
|
+
_GLTFMaterialExporter.prototype._exportTextureInfo = function (imageIndex, samplerIndex, coordinatesIndex) {
|
|
5517
|
+
var textures = this._exporter._textures;
|
|
5518
|
+
var textureIndex = textures.findIndex(function (t) { return t.sampler == samplerIndex && t.source === imageIndex; });
|
|
5519
|
+
if (textureIndex === -1) {
|
|
5520
|
+
textureIndex = textures.length;
|
|
5521
|
+
textures.push({
|
|
5522
|
+
source: imageIndex,
|
|
5523
|
+
sampler: samplerIndex,
|
|
5524
|
+
});
|
|
5635
5525
|
}
|
|
5636
|
-
|
|
5637
|
-
|
|
5526
|
+
var textureInfo = { index: textureIndex };
|
|
5527
|
+
if (coordinatesIndex) {
|
|
5528
|
+
textureInfo.texCoord = coordinatesIndex;
|
|
5638
5529
|
}
|
|
5639
5530
|
return textureInfo;
|
|
5640
5531
|
};
|
|
5532
|
+
_GLTFMaterialExporter.prototype._exportTextureSampler = function (texture) {
|
|
5533
|
+
var sampler = this._getTextureSampler(texture);
|
|
5534
|
+
// if a pre-existing sampler with identical parameters exists, then reuse the previous sampler
|
|
5535
|
+
var samplers = this._exporter._samplers;
|
|
5536
|
+
var samplerIndex = samplers.findIndex(function (s) { return s.minFilter === sampler.minFilter && s.magFilter === sampler.magFilter && s.wrapS === sampler.wrapS && s.wrapT === sampler.wrapT; });
|
|
5537
|
+
if (samplerIndex !== -1) {
|
|
5538
|
+
return samplerIndex;
|
|
5539
|
+
}
|
|
5540
|
+
samplers.push(sampler);
|
|
5541
|
+
return samplers.length - 1;
|
|
5542
|
+
};
|
|
5641
5543
|
/**
|
|
5642
5544
|
* Represents the dielectric specular values for R, G and B
|
|
5643
5545
|
*/
|
|
@@ -5993,30 +5895,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5993
5895
|
|
|
5994
5896
|
|
|
5995
5897
|
|
|
5996
|
-
/***/ }),
|
|
5997
|
-
|
|
5998
|
-
/***/ "../../../lts/serializers/dist/glTF/2.0/shaders/textureTransform.fragment.js":
|
|
5999
|
-
/*!***********************************************************************************!*\
|
|
6000
|
-
!*** ../../../lts/serializers/dist/glTF/2.0/shaders/textureTransform.fragment.js ***!
|
|
6001
|
-
\***********************************************************************************/
|
|
6002
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
6003
|
-
|
|
6004
|
-
__webpack_require__.r(__webpack_exports__);
|
|
6005
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
6006
|
-
/* harmony export */ "textureTransformPixelShader": () => (/* binding */ textureTransformPixelShader)
|
|
6007
|
-
/* harmony export */ });
|
|
6008
|
-
/* harmony import */ var core_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Engines/shaderStore */ "core/Maths/math.vector");
|
|
6009
|
-
/* harmony import */ var core_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
|
|
6010
|
-
// Do not edit.
|
|
6011
|
-
|
|
6012
|
-
var name = "textureTransformPixelShader";
|
|
6013
|
-
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}";
|
|
6014
|
-
// Sideeffect
|
|
6015
|
-
core_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__.ShaderStore.ShadersStore[name] = shader;
|
|
6016
|
-
/** @internal */
|
|
6017
|
-
var textureTransformPixelShader = { name: name, shader: shader };
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
5898
|
/***/ }),
|
|
6021
5899
|
|
|
6022
5900
|
/***/ "../../../lts/serializers/dist/glTF/glTFFileExporter.js":
|