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) {
|
||||
this.mesh.SetName (this.params.name);
|
||||
}
|
||||
if (this.params.material !== null) {
|
||||
this.mesh.SetMaterial (this.params.material);
|
||||
}
|
||||
this.curve = null;
|
||||
}
|
||||
|
||||
@ -68,6 +65,9 @@ OV.Generator = class
|
||||
AddTriangle (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) {
|
||||
triangle.SetCurve (this.curve);
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ OV.Mesh = class extends OV.ModelObject3D
|
||||
this.normals = [];
|
||||
this.uvs = [];
|
||||
this.triangles = [];
|
||||
this.mat = null;
|
||||
}
|
||||
|
||||
VertexCount ()
|
||||
@ -111,16 +110,6 @@ OV.Mesh = class extends OV.ModelObject3D
|
||||
return this.triangles[index];
|
||||
}
|
||||
|
||||
SetMaterial (mat)
|
||||
{
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
GetMaterial ()
|
||||
{
|
||||
return this.mat;
|
||||
}
|
||||
|
||||
EnumerateVertices (onVertex)
|
||||
{
|
||||
for (const vertex of this.vertices) {
|
||||
@ -176,8 +165,6 @@ OV.Mesh = class extends OV.ModelObject3D
|
||||
cloned.AddTriangle (triangle.Clone ());
|
||||
}
|
||||
|
||||
cloned.SetMaterial (this.GetMaterial ());
|
||||
|
||||
return cloned;
|
||||
}
|
||||
};
|
||||
|
||||
@ -111,12 +111,7 @@ OV.ModelFinalizer = class
|
||||
this.FinalizeTriangle (mesh, triangle, meshStatus);
|
||||
|
||||
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 ()) {
|
||||
@ -340,13 +335,6 @@ OV.CheckModel = function (model)
|
||||
}
|
||||
}
|
||||
|
||||
let meshMaterial = mesh.GetMaterial ();
|
||||
if (meshMaterial !== null) {
|
||||
if (!IsCorrectIndex (meshMaterial, model.MaterialCount ())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,10 @@ describe ('Generator', function () {
|
||||
it ('Cuboid with Material', function () {
|
||||
const params = new OV.GeneratorParams ().SetMaterial (1);
|
||||
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 () {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user