@babylonjs/serializers 5.0.0-alpha.9 → 5.0.0-beta.4
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/OBJ/index.js +1 -1
- package/OBJ/objSerializer.js +19 -12
- package/OBJ/objSerializer.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +8 -8
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +24 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +91 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +6 -11
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +13 -37
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -3
- package/glTF/2.0/Extensions/KHR_texture_transform.js +4 -4
- package/glTF/2.0/Extensions/index.d.ts +1 -0
- package/glTF/2.0/Extensions/index.js +5 -4
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFAnimation.js +10 -9
- package/glTF/2.0/glTFAnimation.js.map +1 -1
- package/glTF/2.0/glTFData.js +1 -1
- package/glTF/2.0/glTFData.js.map +1 -1
- package/glTF/2.0/glTFExporter.d.ts +7 -0
- package/glTF/2.0/glTFExporter.js +133 -97
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFExporterExtension.js.map +1 -1
- package/glTF/2.0/glTFMaterialExporter.d.ts +8 -6
- package/glTF/2.0/glTFMaterialExporter.js +67 -48
- package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
- package/glTF/2.0/glTFSerializer.d.ts +4 -0
- package/glTF/2.0/glTFSerializer.js +1 -1
- package/glTF/2.0/glTFSerializer.js.map +1 -1
- package/glTF/2.0/glTFUtilities.d.ts +1 -2
- package/glTF/2.0/glTFUtilities.js +1 -5
- package/glTF/2.0/glTFUtilities.js.map +1 -1
- package/glTF/2.0/index.d.ts +1 -1
- package/glTF/2.0/index.js +8 -8
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/2.0/shaders/textureTransform.fragment.js +3 -3
- package/glTF/2.0/shaders/textureTransform.fragment.js.map +1 -1
- package/glTF/index.d.ts +1 -1
- package/glTF/index.js +2 -2
- package/glTF/index.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/legacy/legacy-glTF2Serializer.d.ts +1 -1
- package/legacy/legacy-glTF2Serializer.js +7 -7
- package/legacy/legacy-glTF2Serializer.js.map +1 -1
- package/legacy/legacy-objSerializer.d.ts +1 -1
- package/legacy/legacy-objSerializer.js +2 -2
- package/legacy/legacy-objSerializer.js.map +1 -1
- package/legacy/legacy-stlSerializer.d.ts +1 -1
- package/legacy/legacy-stlSerializer.js +2 -2
- package/legacy/legacy-stlSerializer.js.map +1 -1
- package/legacy/legacy.js +4 -4
- package/package.json +7 -4
- package/stl/index.js +1 -1
- package/stl/stlSerializer.js +2 -2
- package/stl/stlSerializer.js.map +1 -1
package/glTF/2.0/glTFExporter.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Vector2, Vector3, Vector4, Quaternion
|
|
3
|
-
import { Color3, Color4 } from "@babylonjs/core/Maths/math.color";
|
|
4
|
-
import { Tools } from "@babylonjs/core/Misc/tools";
|
|
5
|
-
import { VertexBuffer } from "@babylonjs/core/
|
|
6
|
-
import { TransformNode } from "@babylonjs/core/Meshes/transformNode";
|
|
7
|
-
import { Mesh } from "@babylonjs/core/Meshes/mesh";
|
|
8
|
-
import { LinesMesh } from "@babylonjs/core/Meshes/linesMesh";
|
|
9
|
-
import { InstancedMesh } from "@babylonjs/core/Meshes/instancedMesh";
|
|
10
|
-
import { Material } from "@babylonjs/core/Materials/material";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { GLTFData } from "./glTFData";
|
|
16
|
-
import { _GLTFAnimation } from "./glTFAnimation";
|
|
17
|
-
import { Epsilon } from '@babylonjs/core/Maths/math.constants';
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
import { Vector2, Vector3, Vector4, Quaternion } from "@babylonjs/core/Maths/math.vector.js";
|
|
3
|
+
import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
|
|
4
|
+
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
|
5
|
+
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
|
6
|
+
import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
|
7
|
+
import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
8
|
+
import { LinesMesh } from "@babylonjs/core/Meshes/linesMesh.js";
|
|
9
|
+
import { InstancedMesh } from "@babylonjs/core/Meshes/instancedMesh.js";
|
|
10
|
+
import { Material } from "@babylonjs/core/Materials/material.js";
|
|
11
|
+
import { _GLTFMaterialExporter } from "./glTFMaterialExporter.js";
|
|
12
|
+
import { _GLTFUtilities } from "./glTFUtilities.js";
|
|
13
|
+
import { GLTFData } from "./glTFData.js";
|
|
14
|
+
import { _GLTFAnimation } from "./glTFAnimation.js";
|
|
18
15
|
/**
|
|
19
16
|
* Converts Babylon Scene into glTF 2.0.
|
|
20
17
|
* @hidden
|
|
@@ -537,7 +534,7 @@ var _Exporter = /** @class */ (function () {
|
|
|
537
534
|
}
|
|
538
535
|
case VertexBuffer.ColorKind: {
|
|
539
536
|
var meshMaterial = babylonTransformNode.material;
|
|
540
|
-
var convertToLinear = meshMaterial ? (meshMaterial
|
|
537
|
+
var convertToLinear = meshMaterial ? (meshMaterial.getClassName() === "StandardMaterial") : true;
|
|
541
538
|
var vertexData = stride === 3 ? new Color3() : new Color4();
|
|
542
539
|
for (var k = 0, length_5 = meshAttributeArray.length / stride; k < length_5; ++k) {
|
|
543
540
|
index = k * stride;
|
|
@@ -863,7 +860,14 @@ var _Exporter = /** @class */ (function () {
|
|
|
863
860
|
var headerLength = 12;
|
|
864
861
|
var chunkLengthPrefix = 8;
|
|
865
862
|
var jsonLength = jsonText.length;
|
|
863
|
+
var encodedJsonText;
|
|
866
864
|
var imageByteLength = 0;
|
|
865
|
+
// make use of TextEncoder when available
|
|
866
|
+
if (typeof TextEncoder !== "undefined") {
|
|
867
|
+
var encoder = new TextEncoder();
|
|
868
|
+
encodedJsonText = encoder.encode(jsonText);
|
|
869
|
+
jsonLength = encodedJsonText.length;
|
|
870
|
+
}
|
|
867
871
|
for (var i = 0; i < _this._orderedImageData.length; ++i) {
|
|
868
872
|
imageByteLength += _this._orderedImageData[i].data.byteLength;
|
|
869
873
|
}
|
|
@@ -884,8 +888,22 @@ var _Exporter = /** @class */ (function () {
|
|
|
884
888
|
jsonChunkBufferView.setUint32(4, 0x4E4F534A, true);
|
|
885
889
|
//json chunk bytes
|
|
886
890
|
var jsonData = new Uint8Array(jsonChunkBuffer, chunkLengthPrefix);
|
|
887
|
-
|
|
888
|
-
|
|
891
|
+
// if TextEncoder was available, we can simply copy the encoded array
|
|
892
|
+
if (encodedJsonText) {
|
|
893
|
+
jsonData.set(encodedJsonText);
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
896
|
+
var blankCharCode = "_".charCodeAt(0);
|
|
897
|
+
for (var i = 0; i < jsonLength; ++i) {
|
|
898
|
+
var charCode = jsonText.charCodeAt(i);
|
|
899
|
+
// if the character doesn't fit into a single UTF-16 code unit, just put a blank character
|
|
900
|
+
if (charCode != jsonText.codePointAt(i)) {
|
|
901
|
+
jsonData[i] = blankCharCode;
|
|
902
|
+
}
|
|
903
|
+
else {
|
|
904
|
+
jsonData[i] = charCode;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
889
907
|
}
|
|
890
908
|
//json padding
|
|
891
909
|
var jsonPaddingView = new Uint8Array(jsonChunkBuffer, chunkLengthPrefix + jsonLength);
|
|
@@ -1235,7 +1253,7 @@ var _Exporter = /** @class */ (function () {
|
|
|
1235
1253
|
this._materials.push(material);
|
|
1236
1254
|
materialIndex = this._materials.length - 1;
|
|
1237
1255
|
}
|
|
1238
|
-
else if (babylonMaterial
|
|
1256
|
+
else if (babylonMaterial.getClassName() === "MultiMaterial") {
|
|
1239
1257
|
var subMaterial = babylonMaterial.subMaterials[submesh.materialIndex];
|
|
1240
1258
|
if (subMaterial) {
|
|
1241
1259
|
babylonMaterial = subMaterial;
|
|
@@ -1252,8 +1270,8 @@ var _Exporter = /** @class */ (function () {
|
|
|
1252
1270
|
for (var _d = 0, attributeData_2 = attributeData; _d < attributeData_2.length; _d++) {
|
|
1253
1271
|
var attribute = attributeData_2[_d];
|
|
1254
1272
|
var attributeKind = attribute.kind;
|
|
1255
|
-
if (attributeKind === VertexBuffer.UVKind || attributeKind === VertexBuffer.UV2Kind) {
|
|
1256
|
-
if (glTFMaterial
|
|
1273
|
+
if ((attributeKind === VertexBuffer.UVKind || attributeKind === VertexBuffer.UV2Kind) && !this._options.exportUnusedUVs) {
|
|
1274
|
+
if (!glTFMaterial || !this._glTFMaterialExporter._hasTexturesPresent(glTFMaterial)) {
|
|
1257
1275
|
continue;
|
|
1258
1276
|
}
|
|
1259
1277
|
}
|
|
@@ -1320,10 +1338,8 @@ var _Exporter = /** @class */ (function () {
|
|
|
1320
1338
|
}
|
|
1321
1339
|
}
|
|
1322
1340
|
mesh.primitives.push(meshPrimitive);
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
promises.push();
|
|
1326
|
-
}
|
|
1341
|
+
this._extensionsPostExportMeshPrimitiveAsync("postExport", meshPrimitive, submesh, binaryWriter);
|
|
1342
|
+
promises.push();
|
|
1327
1343
|
}
|
|
1328
1344
|
}
|
|
1329
1345
|
}
|
|
@@ -1343,13 +1359,8 @@ var _Exporter = /** @class */ (function () {
|
|
|
1343
1359
|
}
|
|
1344
1360
|
// Transform
|
|
1345
1361
|
var matrix = node.getWorldMatrix();
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
var matrixIdentity = Matrix.IdentityReadOnly;
|
|
1349
|
-
for (var i = 0; i < 16; i++) {
|
|
1350
|
-
if (Math.abs(matrixProduct.m[i] - matrixIdentity.m[i]) > Epsilon) {
|
|
1351
|
-
return false;
|
|
1352
|
-
}
|
|
1362
|
+
if (matrix.determinant() === 1) {
|
|
1363
|
+
return false;
|
|
1353
1364
|
}
|
|
1354
1365
|
// Geometry
|
|
1355
1366
|
if ((node instanceof Mesh && node.geometry !== null) ||
|
|
@@ -1375,7 +1386,7 @@ var _Exporter = /** @class */ (function () {
|
|
|
1375
1386
|
var glTFNodeIndex;
|
|
1376
1387
|
var glTFNode;
|
|
1377
1388
|
var directDescendents;
|
|
1378
|
-
var nodes =
|
|
1389
|
+
var nodes = __spreadArray(__spreadArray(__spreadArray([], babylonScene.transformNodes, true), babylonScene.meshes, true), babylonScene.lights, true);
|
|
1379
1390
|
var rootNodesToLeftHanded = [];
|
|
1380
1391
|
this._convertToRightHandedSystem = !babylonScene.useRightHandedSystem;
|
|
1381
1392
|
this._convertToRightHandedSystemMap = {};
|
|
@@ -1401,8 +1412,9 @@ var _Exporter = /** @class */ (function () {
|
|
|
1401
1412
|
});
|
|
1402
1413
|
}
|
|
1403
1414
|
});
|
|
1404
|
-
|
|
1405
|
-
|
|
1415
|
+
var _a = this.getExportNodes(nodes), exportNodes = _a[0], exportMaterials = _a[1];
|
|
1416
|
+
return this._glTFMaterialExporter._convertMaterialsToGLTFAsync(exportMaterials, "image/png" /* PNG */, true).then(function () {
|
|
1417
|
+
return _this.createNodeMapAndAnimationsAsync(babylonScene, exportNodes, binaryWriter).then(function (nodeMap) {
|
|
1406
1418
|
return _this.createSkinsAsync(babylonScene, nodeMap, binaryWriter).then(function (skinMap) {
|
|
1407
1419
|
_this._nodeMap = nodeMap;
|
|
1408
1420
|
_this._totalByteLength = binaryWriter.getByteOffset();
|
|
@@ -1467,6 +1479,41 @@ var _Exporter = /** @class */ (function () {
|
|
|
1467
1479
|
});
|
|
1468
1480
|
});
|
|
1469
1481
|
};
|
|
1482
|
+
/**
|
|
1483
|
+
* Getting the nodes and materials that would be exported.
|
|
1484
|
+
* @param nodes Babylon transform nodes
|
|
1485
|
+
* @returns Array of nodes which would be exported.
|
|
1486
|
+
* @returns Set of materials which would be exported.
|
|
1487
|
+
*/
|
|
1488
|
+
_Exporter.prototype.getExportNodes = function (nodes) {
|
|
1489
|
+
var exportNodes = [];
|
|
1490
|
+
var exportMaterials = new Set();
|
|
1491
|
+
for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
|
|
1492
|
+
var babylonNode = nodes_2[_i];
|
|
1493
|
+
if (!this._options.shouldExportNode || this._options.shouldExportNode(babylonNode)) {
|
|
1494
|
+
exportNodes.push(babylonNode);
|
|
1495
|
+
if (babylonNode.getClassName() === "Mesh") {
|
|
1496
|
+
var mesh = babylonNode;
|
|
1497
|
+
if (mesh.material) {
|
|
1498
|
+
exportMaterials.add(mesh.material);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
else {
|
|
1502
|
+
var meshes = babylonNode.getChildMeshes(false);
|
|
1503
|
+
for (var _a = 0, meshes_1 = meshes; _a < meshes_1.length; _a++) {
|
|
1504
|
+
var mesh = meshes_1[_a];
|
|
1505
|
+
if (mesh.material) {
|
|
1506
|
+
exportMaterials.add(mesh.material);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
else {
|
|
1512
|
+
"Excluding node " + babylonNode.name;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return [exportNodes, exportMaterials];
|
|
1516
|
+
};
|
|
1470
1517
|
/**
|
|
1471
1518
|
* Creates a mapping of Node unique id to node index and handles animations
|
|
1472
1519
|
* @param babylonScene Babylon Scene
|
|
@@ -1486,41 +1533,35 @@ var _Exporter = /** @class */ (function () {
|
|
|
1486
1533
|
};
|
|
1487
1534
|
var idleGLTFAnimations = [];
|
|
1488
1535
|
var _loop_1 = function (babylonNode) {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
_GLTFAnimation._CreateNodeAnimationFromNodeAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, convertToRightHandedSystem, _this._animationSampleRate);
|
|
1510
|
-
}
|
|
1536
|
+
promiseChain = promiseChain.then(function () {
|
|
1537
|
+
var convertToRightHandedSystem = _this._convertToRightHandedSystemMap[babylonNode.uniqueId];
|
|
1538
|
+
return _this.createNodeAsync(babylonNode, binaryWriter, convertToRightHandedSystem, nodeMap).then(function (node) {
|
|
1539
|
+
var promise = _this._extensionsPostExportNodeAsync("createNodeAsync", node, babylonNode, nodeMap);
|
|
1540
|
+
if (promise == null) {
|
|
1541
|
+
Tools.Warn("Not exporting node " + babylonNode.name);
|
|
1542
|
+
return Promise.resolve();
|
|
1543
|
+
}
|
|
1544
|
+
else {
|
|
1545
|
+
return promise.then(function (node) {
|
|
1546
|
+
if (!node) {
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
_this._nodes.push(node);
|
|
1550
|
+
nodeIndex = _this._nodes.length - 1;
|
|
1551
|
+
nodeMap[babylonNode.uniqueId] = nodeIndex;
|
|
1552
|
+
if (!babylonScene.animationGroups.length) {
|
|
1553
|
+
_GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, convertToRightHandedSystem, _this._animationSampleRate);
|
|
1554
|
+
if (babylonNode.animations.length) {
|
|
1555
|
+
_GLTFAnimation._CreateNodeAnimationFromNodeAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, convertToRightHandedSystem, _this._animationSampleRate);
|
|
1511
1556
|
}
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1515
1560
|
});
|
|
1516
|
-
}
|
|
1517
|
-
else {
|
|
1518
|
-
"Excluding node " + babylonNode.name;
|
|
1519
|
-
}
|
|
1561
|
+
});
|
|
1520
1562
|
};
|
|
1521
|
-
var
|
|
1522
|
-
|
|
1523
|
-
var babylonNode = nodes_2[_i];
|
|
1563
|
+
for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
|
|
1564
|
+
var babylonNode = nodes_3[_i];
|
|
1524
1565
|
_loop_1(babylonNode);
|
|
1525
1566
|
}
|
|
1526
1567
|
return promiseChain.then(function () {
|
|
@@ -1589,59 +1630,54 @@ var _Exporter = /** @class */ (function () {
|
|
|
1589
1630
|
* @returns Node mapping of unique id to index
|
|
1590
1631
|
*/
|
|
1591
1632
|
_Exporter.prototype.createSkinsAsync = function (babylonScene, nodeMap, binaryWriter) {
|
|
1633
|
+
var _a;
|
|
1592
1634
|
var promiseChain = Promise.resolve();
|
|
1593
1635
|
var skinMap = {};
|
|
1594
|
-
var
|
|
1636
|
+
for (var _i = 0, _b = babylonScene.skeletons; _i < _b.length; _i++) {
|
|
1637
|
+
var skeleton = _b[_i];
|
|
1595
1638
|
// create skin
|
|
1596
1639
|
var skin = { joints: [] };
|
|
1597
1640
|
var inverseBindMatrices = [];
|
|
1598
|
-
var skeletonMesh = babylonScene.meshes.find(function (mesh) { mesh.skeleton === skeleton; });
|
|
1599
|
-
skin.skeleton = skeleton.overrideMesh === null ? (skeletonMesh ? nodeMap[skeletonMesh.uniqueId] : undefined) : nodeMap[skeleton.overrideMesh.uniqueId];
|
|
1600
1641
|
var boneIndexMap = {};
|
|
1601
|
-
var
|
|
1602
|
-
var
|
|
1603
|
-
|
|
1604
|
-
var
|
|
1605
|
-
boneIndex
|
|
1606
|
-
if (boneIndex > -1) {
|
|
1642
|
+
var maxBoneIndex = -1;
|
|
1643
|
+
for (var i = 0; i < skeleton.bones.length; ++i) {
|
|
1644
|
+
var bone = skeleton.bones[i];
|
|
1645
|
+
var boneIndex = (_a = bone.getIndex()) !== null && _a !== void 0 ? _a : i;
|
|
1646
|
+
if (boneIndex !== -1) {
|
|
1607
1647
|
boneIndexMap[boneIndex] = bone;
|
|
1648
|
+
if (boneIndex > maxBoneIndex) {
|
|
1649
|
+
maxBoneIndex = boneIndex;
|
|
1650
|
+
}
|
|
1608
1651
|
}
|
|
1609
|
-
boneIndexMax = Math.max(boneIndexMax, boneIndex);
|
|
1610
1652
|
}
|
|
1611
|
-
for (var
|
|
1612
|
-
var bone = boneIndexMap[
|
|
1653
|
+
for (var boneIndex = 0; boneIndex <= maxBoneIndex; ++boneIndex) {
|
|
1654
|
+
var bone = boneIndexMap[boneIndex];
|
|
1655
|
+
inverseBindMatrices.push(bone.getInvertedAbsoluteTransform());
|
|
1613
1656
|
var transformNode = bone.getTransformNode();
|
|
1614
1657
|
if (transformNode) {
|
|
1615
|
-
var boneMatrix = bone.getInvertedAbsoluteTransform();
|
|
1616
|
-
if (this_2._convertToRightHandedSystem) {
|
|
1617
|
-
_GLTFUtilities._GetRightHandedMatrixFromRef(boneMatrix);
|
|
1618
|
-
}
|
|
1619
|
-
inverseBindMatrices.push(boneMatrix);
|
|
1620
1658
|
skin.joints.push(nodeMap[transformNode.uniqueId]);
|
|
1621
1659
|
}
|
|
1660
|
+
else {
|
|
1661
|
+
Tools.Warn("Exporting a bone without a linked transform node is currently unsupported");
|
|
1662
|
+
}
|
|
1622
1663
|
}
|
|
1623
1664
|
// create buffer view for inverse bind matrices
|
|
1624
1665
|
var byteStride = 64; // 4 x 4 matrix of 32 bit float
|
|
1625
1666
|
var byteLength = inverseBindMatrices.length * byteStride;
|
|
1626
1667
|
var bufferViewOffset = binaryWriter.getByteOffset();
|
|
1627
|
-
var bufferView = _GLTFUtilities._CreateBufferView(0, bufferViewOffset, byteLength,
|
|
1628
|
-
|
|
1629
|
-
var bufferViewIndex =
|
|
1668
|
+
var bufferView = _GLTFUtilities._CreateBufferView(0, bufferViewOffset, byteLength, undefined, "InverseBindMatrices" + " - " + skeleton.name);
|
|
1669
|
+
this._bufferViews.push(bufferView);
|
|
1670
|
+
var bufferViewIndex = this._bufferViews.length - 1;
|
|
1630
1671
|
var bindMatrixAccessor = _GLTFUtilities._CreateAccessor(bufferViewIndex, "InverseBindMatrices" + " - " + skeleton.name, "MAT4" /* MAT4 */, 5126 /* FLOAT */, inverseBindMatrices.length, null, null, null);
|
|
1631
|
-
var inverseBindAccessorIndex =
|
|
1672
|
+
var inverseBindAccessorIndex = this._accessors.push(bindMatrixAccessor) - 1;
|
|
1632
1673
|
skin.inverseBindMatrices = inverseBindAccessorIndex;
|
|
1633
|
-
|
|
1634
|
-
skinMap[skeleton.uniqueId] =
|
|
1674
|
+
this._skins.push(skin);
|
|
1675
|
+
skinMap[skeleton.uniqueId] = this._skins.length - 1;
|
|
1635
1676
|
inverseBindMatrices.forEach(function (mat) {
|
|
1636
1677
|
mat.m.forEach(function (cell) {
|
|
1637
1678
|
binaryWriter.setFloat32(cell);
|
|
1638
1679
|
});
|
|
1639
1680
|
});
|
|
1640
|
-
};
|
|
1641
|
-
var this_2 = this;
|
|
1642
|
-
for (var _i = 0, _a = babylonScene.skeletons; _i < _a.length; _i++) {
|
|
1643
|
-
var skeleton = _a[_i];
|
|
1644
|
-
_loop_2(skeleton);
|
|
1645
1681
|
}
|
|
1646
1682
|
return promiseChain.then(function () {
|
|
1647
1683
|
return skinMap;
|