diff --git a/source/import/importero3dv.js b/source/import/importero3dv.js index a056580..ae2acc5 100644 --- a/source/import/importero3dv.js +++ b/source/import/importero3dv.js @@ -74,19 +74,8 @@ OV.ImporterO3dv = class extends OV.ImporterBase } if (meshContent.transformation !== undefined) { - let translation = new OV.Coord3D (0.0, 0.0, 0.0); - let rotation = new OV.Quaternion (0.0, 0.0, 0.0, 1.0); - let scale = new OV.Coord3D (1.0, 1.0, 1.0); - if (meshContent.transformation.translation !== undefined) { - translation = OV.ArrayToCoord3D (meshContent.transformation.translation); - } - if (meshContent.transformation.rotation !== undefined) { - rotation = OV.ArrayToQuaternion (meshContent.transformation.rotation); - } - if (meshContent.transformation.scale !== undefined) { - scale = OV.ArrayToCoord3D (meshContent.transformation.scale); - } - genParams.SetTransformation (translation, rotation, scale); + let meshTransformation = this.GetTransformation (meshContent.transformation); + genParams.SetTransformation (meshTransformation); } let parameters = meshContent.parameters; @@ -127,25 +116,25 @@ OV.ImporterO3dv = class extends OV.ImporterBase } } - ImportNode (nodeContent, meshNode) + ImportNode (nodeContent, node) { if (nodeContent.name !== undefined) { - meshNode.SetName (nodeContent.name); + node.SetName (nodeContent.name); } if (nodeContent.transformation !== undefined) { const nodeTransformation = this.GetTransformation (nodeContent.transformation); - meshNode.SetTransformation (nodeTransformation); + node.SetTransformation (nodeTransformation); } if (nodeContent.meshes !== undefined) { for (const meshIndex of nodeContent.meshes) { - meshNode.AddMeshIndex (meshIndex); + node.AddMeshIndex (meshIndex); } } if (nodeContent.children !== undefined) { for (const child of nodeContent.children) { - let childMeshNode = new OV.Node (); - meshNode.AddChildNode (childMeshNode); - this.ImportNode (child, childMeshNode); + let childNode = new OV.Node (); + node.AddChildNode (childNode); + this.ImportNode (child, childNode); } } } diff --git a/source/model/generator.js b/source/model/generator.js index 09caec8..5b9349e 100644 --- a/source/model/generator.js +++ b/source/model/generator.js @@ -19,7 +19,7 @@ OV.GeneratorParams = class return this; } - SetTransformation (translation, rotation, scale) + SetTransformationTRS (translation, rotation, scale) { const matrix = new OV.Matrix ().ComposeTRS (translation, rotation, scale); return this.SetTransformationMatrix (matrix); @@ -27,7 +27,12 @@ OV.GeneratorParams = class SetTransformationMatrix (matrix) { - this.transformation = new OV.Transformation (matrix); + return this.SetTransformation (new OV.Transformation (matrix)); + } + + SetTransformation (transformation) + { + this.transformation = transformation; return this; } }; diff --git a/test/tests/generator_test.js b/test/tests/generator_test.js index 9ee13df..186ed43 100644 --- a/test/tests/generator_test.js +++ b/test/tests/generator_test.js @@ -17,7 +17,7 @@ describe ('Generator', function () { }); it ('Cuboid with Transformation', function () { - const params = new OV.GeneratorParams ().SetTransformation ( + const params = new OV.GeneratorParams ().SetTransformationTRS ( new OV.Coord3D (1.0, 0.0, 0.0), new OV.Quaternion (0.0, 0.0, 0.0, 1.0), new OV.Coord3D (1.0, 1.0, 1.0) @@ -60,5 +60,5 @@ describe ('Generator', function () { let icosahedron = OV.GeneratePlatonicSolid (null, 'icosahedron', 1.0); assert (OV.IsSolid (icosahedron)); assert (OV.IsEqual (OV.CalculateVolume (icosahedron), 2.5361507101204093)); - }); + }); });