|
@@ -848,6 +848,9 @@ var BABYLON;
|
|
* @param babylonMesh The BabylonJS mesh
|
|
* @param babylonMesh The BabylonJS mesh
|
|
*/
|
|
*/
|
|
_Exporter.prototype.getMeshPrimitiveMode = function (babylonMesh) {
|
|
_Exporter.prototype.getMeshPrimitiveMode = function (babylonMesh) {
|
|
|
|
+ if (babylonMesh instanceof BABYLON.LinesMesh) {
|
|
|
|
+ return BABYLON.Material.LineListDrawMode;
|
|
|
|
+ }
|
|
return babylonMesh.material ? babylonMesh.material.fillMode : BABYLON.Material.TriangleFillMode;
|
|
return babylonMesh.material ? babylonMesh.material.fillMode : BABYLON.Material.TriangleFillMode;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -991,7 +994,20 @@ var BABYLON;
|
|
var babylonMaterial = submesh.getMaterial();
|
|
var babylonMaterial = submesh.getMaterial();
|
|
var materialIndex = null;
|
|
var materialIndex = null;
|
|
if (babylonMaterial) {
|
|
if (babylonMaterial) {
|
|
- if (babylonMaterial instanceof BABYLON.MultiMaterial) {
|
|
|
|
|
|
+ if (bufferMesh instanceof BABYLON.LinesMesh) {
|
|
|
|
+ // get the color from the lines mesh and set it in the material
|
|
|
|
+ var material = {
|
|
|
|
+ name: bufferMesh.name + ' material'
|
|
|
|
+ };
|
|
|
|
+ if (!bufferMesh.color.equals(BABYLON.Color3.White()) || bufferMesh.alpha < 1) {
|
|
|
|
+ material.pbrMetallicRoughness = {
|
|
|
|
+ baseColorFactor: bufferMesh.color.asArray().concat([bufferMesh.alpha])
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ this.materials.push(material);
|
|
|
|
+ materialIndex = this.materials.length - 1;
|
|
|
|
+ }
|
|
|
|
+ else if (babylonMaterial instanceof BABYLON.MultiMaterial) {
|
|
babylonMaterial = babylonMaterial.subMaterials[submesh.materialIndex];
|
|
babylonMaterial = babylonMaterial.subMaterials[submesh.materialIndex];
|
|
if (babylonMaterial) {
|
|
if (babylonMaterial) {
|
|
materialIndex = this.babylonScene.materials.indexOf(babylonMaterial);
|
|
materialIndex = this.babylonScene.materials.indexOf(babylonMaterial);
|
|
@@ -1003,6 +1019,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
var glTFMaterial = materialIndex != null ? this.materials[materialIndex] : null;
|
|
var glTFMaterial = materialIndex != null ? this.materials[materialIndex] : null;
|
|
var meshPrimitive = { attributes: {} };
|
|
var meshPrimitive = { attributes: {} };
|
|
|
|
+ this.setPrimitiveMode(meshPrimitive, primitiveMode);
|
|
for (var _c = 0, attributeData_2 = attributeData; _c < attributeData_2.length; _c++) {
|
|
for (var _c = 0, attributeData_2 = attributeData; _c < attributeData_2.length; _c++) {
|
|
var attribute = attributeData_2[_c];
|
|
var attribute = attributeData_2[_c];
|
|
var attributeKind = attribute.kind;
|
|
var attributeKind = attribute.kind;
|
|
@@ -1041,7 +1058,6 @@ var BABYLON;
|
|
if (babylonMaterial) {
|
|
if (babylonMaterial) {
|
|
if (materialIndex != null && Object.keys(meshPrimitive.attributes).length > 0) {
|
|
if (materialIndex != null && Object.keys(meshPrimitive.attributes).length > 0) {
|
|
var sideOrientation = this.babylonScene.materials[materialIndex].sideOrientation;
|
|
var sideOrientation = this.babylonScene.materials[materialIndex].sideOrientation;
|
|
- this.setPrimitiveMode(meshPrimitive, primitiveMode);
|
|
|
|
if (this.convertToRightHandedSystem && sideOrientation === BABYLON.Material.ClockWiseSideOrientation) {
|
|
if (this.convertToRightHandedSystem && sideOrientation === BABYLON.Material.ClockWiseSideOrientation) {
|
|
//Overwrite the indices to be counter-clockwise
|
|
//Overwrite the indices to be counter-clockwise
|
|
var byteOffset = indexBufferViewIndex != null ? this.bufferViews[indexBufferViewIndex].byteOffset : null;
|
|
var byteOffset = indexBufferViewIndex != null ? this.bufferViews[indexBufferViewIndex].byteOffset : null;
|