Get mesh type instead of checking triangle count.

This commit is contained in:
kovacsv 2021-12-31 10:37:16 +01:00
parent 3d04114d86
commit 3795b5cacd
4 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,17 @@
OV.MeshType =
{
Empty : 0,
TriangleMesh : 1
};
OV.GetMeshType = function (mesh)
{
if (mesh.TriangleCount () > 0) {
return OV.MeshType.TriangleMesh;
}
return OV.MeshType.Empty;
};
OV.CalculateTriangleNormal = function (v0, v1, v2)
{
let v = OV.SubCoord3D (v1, v0);

View File

@ -23,7 +23,8 @@ OV.ModelFinalizer = class
{
for (let i = 0; i < model.MeshCount (); i++) {
let mesh = model.GetMesh (i);
if (mesh.TriangleCount () === 0) {
let type = OV.GetMeshType (mesh);
if (type === OV.MeshType.Empty) {
model.RemoveMesh (i);
i = i - 1;
continue;

View File

@ -2,7 +2,7 @@ OV.IsModelEmpty = function (model)
{
let isEmpty = true;
model.EnumerateMeshInstances ((meshInstance) => {
if (meshInstance.TriangleCount () > 0) {
if (OV.GetMeshType (meshInstance) !== OV.MeshType.Empty) {
isEmpty = false;
}
});

View File

@ -197,9 +197,6 @@ OV.ConvertModelToThreeObject = function (model, params, output, callbacks)
{
let mesh = model.GetMesh (meshInstanceId.meshIndex);
let triangleCount = mesh.TriangleCount ();
if (triangleCount === 0) {
return null;
}
let triangleIndices = [];
for (let i = 0; i < triangleCount; i++) {
@ -312,7 +309,8 @@ OV.ConvertModelToThreeObject = function (model, params, output, callbacks)
function ConvertMesh (threeObject, model, meshInstanceId, modelThreeMaterials)
{
let mesh = model.GetMesh (meshInstanceId.meshIndex);
if (mesh.TriangleCount () > 0) {
let type = OV.GetMeshType (mesh);
if (type === OV.MeshType.TriangleMesh) {
let threeMesh = CreateThreeMesh (model, meshInstanceId, modelThreeMaterials);
threeObject.add (threeMesh);
}