Add default value to segment count.
This commit is contained in:
parent
2a53e933ea
commit
61e09c78f3
@ -100,11 +100,12 @@ OV.ImporterO3dv = class extends OV.ImporterBase
|
||||
const mesh = OV.GenerateCuboid (genParams, parameters.size_x, parameters.size_y, parameters.size_z);
|
||||
this.model.AddMesh (mesh);
|
||||
} else if (meshContent.type === 'cylinder') {
|
||||
if (parameters.radius === undefined || parameters.height === undefined || parameters.segments === undefined) {
|
||||
if (parameters.radius === undefined || parameters.height === undefined) {
|
||||
return;
|
||||
}
|
||||
let isSmooth = OV.ValueOrDefault (parameters.smooth, true);
|
||||
const mesh = OV.GenerateCylinder (genParams, parameters.radius, parameters.height, parameters.segments, isSmooth);
|
||||
let segments = OV.ValueOrDefault (parameters.segments, 25);
|
||||
let smooth = OV.ValueOrDefault (parameters.smooth, true);
|
||||
const mesh = OV.GenerateCylinder (genParams, parameters.radius, parameters.height, segments, smooth);
|
||||
this.model.AddMesh (mesh);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ OV.GeneratorHelper = class
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
GenerateExtrude (vertices, height, isSmooth)
|
||||
GenerateExtrude (vertices, height, smooth)
|
||||
{
|
||||
let topPolygon = [];
|
||||
let bottomPolygon = [];
|
||||
@ -124,10 +124,10 @@ OV.GeneratorHelper = class
|
||||
bottomPolygon.push (this.generator.AddVertex (vertex.x, vertex.y, 0.0));
|
||||
topPolygon.push (this.generator.AddVertex (vertex.x, vertex.y, height));
|
||||
}
|
||||
if (isSmooth) {
|
||||
if (smooth) {
|
||||
this.generator.SetCurve (1);
|
||||
}
|
||||
this.GenerateSurfaceBetweenPolygons (bottomPolygon, topPolygon, isSmooth);
|
||||
this.GenerateSurfaceBetweenPolygons (bottomPolygon, topPolygon, smooth);
|
||||
this.generator.ResetCurve ();
|
||||
|
||||
this.generator.AddConvexPolygonInverted (bottomPolygon);
|
||||
@ -167,7 +167,7 @@ OV.GenerateCuboid = function (genParams, xSize, ySize, zSize)
|
||||
return generator.GetMesh ();
|
||||
};
|
||||
|
||||
OV.GenerateCylinder = function (genParams, radius, height, segments, isSmooth)
|
||||
OV.GenerateCylinder = function (genParams, radius, height, segments, smooth)
|
||||
{
|
||||
function GetCylindricalCoord (radius, angle)
|
||||
{
|
||||
@ -185,6 +185,6 @@ OV.GenerateCylinder = function (genParams, radius, height, segments, isSmooth)
|
||||
baseVertices.push (cylindrical);
|
||||
}
|
||||
let helper = new OV.GeneratorHelper (generator);
|
||||
helper.GenerateExtrude (baseVertices, height, isSmooth);
|
||||
helper.GenerateExtrude (baseVertices, height, smooth);
|
||||
return generator.GetMesh ();
|
||||
};
|
||||
|
||||
@ -4,8 +4,7 @@
|
||||
"type" : "cylinder",
|
||||
"parameters" : {
|
||||
"radius" : 0.5,
|
||||
"height" : 1.0,
|
||||
"segments" : 20
|
||||
"height" : 1.0
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
12
test/testfiles/o3dv/cylinder_segments.o3dv
Normal file
12
test/testfiles/o3dv/cylinder_segments.o3dv
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"meshes" : [
|
||||
{
|
||||
"type" : "cylinder",
|
||||
"parameters" : {
|
||||
"radius" : 0.5,
|
||||
"height" : 1.0,
|
||||
"segments" : 50
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user