diff --git a/3d-viewer/3d_cache/sg/sg_coords.cpp b/3d-viewer/3d_cache/sg/sg_coords.cpp index 94d818ea7c..a6ce86035c 100644 --- a/3d-viewer/3d_cache/sg/sg_coords.cpp +++ b/3d-viewer/3d_cache/sg/sg_coords.cpp @@ -223,10 +223,14 @@ bool SGCOORDS::WriteVRML( std::ofstream& aFile, bool aReuseFlag ) std::string tmp; size_t n = coords.size(); bool nline = false; + SGPOINT pt; for( size_t i = 0; i < n; ) { - S3D::FormatPoint( tmp, coords[i] ); + pt = coords[i]; + // ensure VRML output has 1U = 0.1 inch as per legacy kicad expectations + pt.x /= 2.54; + S3D::FormatPoint( tmp, pt ); aFile << tmp ; ++i; diff --git a/plugins/3d/vrml/v1/vrml1_coords.cpp b/plugins/3d/vrml/v1/vrml1_coords.cpp index b5fddeedc9..e7ab574885 100644 --- a/plugins/3d/vrml/v1/vrml1_coords.cpp +++ b/plugins/3d/vrml/v1/vrml1_coords.cpp @@ -163,6 +163,19 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) return false; } + // assuming legacy kicad expectation of 1U = 0.1 inch, + // convert to mm to meet the expectations of the SG structure + std::vector< WRLVEC3F >::iterator sP = points.begin(); + std::vector< WRLVEC3F >::iterator eP = points.end(); + + while( sP != eP ) + { + sP->x *= 2.54; + sP->y *= 2.54; + sP->z *= 2.54; + ++sP; + } + if( proc.Peek() == '}' ) { proc.Pop(); diff --git a/plugins/3d/vrml/v2/vrml2_coords.cpp b/plugins/3d/vrml/v2/vrml2_coords.cpp index 28e187ff88..5fa8162caa 100644 --- a/plugins/3d/vrml/v2/vrml2_coords.cpp +++ b/plugins/3d/vrml/v2/vrml2_coords.cpp @@ -173,6 +173,19 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) return false; } + // assuming legacy kicad expectation of 1U = 0.1 inch, + // convert to mm to meet the expectations of the SG structure + std::vector< WRLVEC3F >::iterator sP = points.begin(); + std::vector< WRLVEC3F >::iterator eP = points.end(); + + while( sP != eP ) + { + sP->x *= 2.54; + sP->y *= 2.54; + sP->z *= 2.54; + ++sP; + } + if( proc.Peek() == '}' ) { proc.Pop();