Remove material parameter from mesh.
This commit is contained in:
parent
88f928beae
commit
a13f82f687
@ -28,9 +28,6 @@ OV.Generator = class
|
|||||||
if (this.params.name !== null) {
|
if (this.params.name !== null) {
|
||||||
this.mesh.SetName (this.params.name);
|
this.mesh.SetName (this.params.name);
|
||||||
}
|
}
|
||||||
if (this.params.material !== null) {
|
|
||||||
this.mesh.SetMaterial (this.params.material);
|
|
||||||
}
|
|
||||||
this.curve = null;
|
this.curve = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +65,9 @@ OV.Generator = class
|
|||||||
AddTriangle (v0, v1, v2)
|
AddTriangle (v0, v1, v2)
|
||||||
{
|
{
|
||||||
let triangle = new OV.Triangle (v0, v1, v2);
|
let triangle = new OV.Triangle (v0, v1, v2);
|
||||||
|
if (this.params.material !== null) {
|
||||||
|
triangle.mat = this.params.material;
|
||||||
|
}
|
||||||
if (this.curve !== null) {
|
if (this.curve !== null) {
|
||||||
triangle.SetCurve (this.curve);
|
triangle.SetCurve (this.curve);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,6 @@ OV.Mesh = class extends OV.ModelObject3D
|
|||||||
this.normals = [];
|
this.normals = [];
|
||||||
this.uvs = [];
|
this.uvs = [];
|
||||||
this.triangles = [];
|
this.triangles = [];
|
||||||
this.mat = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexCount ()
|
VertexCount ()
|
||||||
@ -111,16 +110,6 @@ OV.Mesh = class extends OV.ModelObject3D
|
|||||||
return this.triangles[index];
|
return this.triangles[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMaterial (mat)
|
|
||||||
{
|
|
||||||
this.mat = mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
GetMaterial ()
|
|
||||||
{
|
|
||||||
return this.mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnumerateVertices (onVertex)
|
EnumerateVertices (onVertex)
|
||||||
{
|
{
|
||||||
for (const vertex of this.vertices) {
|
for (const vertex of this.vertices) {
|
||||||
@ -176,8 +165,6 @@ OV.Mesh = class extends OV.ModelObject3D
|
|||||||
cloned.AddTriangle (triangle.Clone ());
|
cloned.AddTriangle (triangle.Clone ());
|
||||||
}
|
}
|
||||||
|
|
||||||
cloned.SetMaterial (this.GetMaterial ());
|
|
||||||
|
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -111,13 +111,8 @@ OV.ModelFinalizer = class
|
|||||||
this.FinalizeTriangle (mesh, triangle, meshStatus);
|
this.FinalizeTriangle (mesh, triangle, meshStatus);
|
||||||
|
|
||||||
if (triangle.mat === null) {
|
if (triangle.mat === null) {
|
||||||
let meshMaterial = mesh.GetMaterial ();
|
|
||||||
if (meshMaterial !== null) {
|
|
||||||
triangle.mat = meshMaterial;
|
|
||||||
} else {
|
|
||||||
triangle.mat = this.GetDefaultMaterialIndex (model);
|
triangle.mat = this.GetDefaultMaterialIndex (model);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (triangle.HasVertexColors ()) {
|
if (triangle.HasVertexColors ()) {
|
||||||
let material = model.GetMaterial (triangle.mat);
|
let material = model.GetMaterial (triangle.mat);
|
||||||
@ -340,13 +335,6 @@ OV.CheckModel = function (model)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let meshMaterial = mesh.GetMaterial ();
|
|
||||||
if (meshMaterial !== null) {
|
|
||||||
if (!IsCorrectIndex (meshMaterial, model.MaterialCount ())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,10 @@ describe ('Generator', function () {
|
|||||||
it ('Cuboid with Material', function () {
|
it ('Cuboid with Material', function () {
|
||||||
const params = new OV.GeneratorParams ().SetMaterial (1);
|
const params = new OV.GeneratorParams ().SetMaterial (1);
|
||||||
const cuboid = OV.GenerateCuboid (params, 1.0, 1.0, 1.0);
|
const cuboid = OV.GenerateCuboid (params, 1.0, 1.0, 1.0);
|
||||||
assert.strictEqual (cuboid.GetMaterial (), 1);
|
for (let i = 0; i < cuboid.TriangleCount (); i++) {
|
||||||
|
const triangle = cuboid.GetTriangle (i);
|
||||||
|
assert.strictEqual (triangle.mat, 1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it ('Cylinder with Default Parameters', function () {
|
it ('Cylinder with Default Parameters', function () {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user