# Exporting a 3D plot into a 3D viewing format and axis scaling

I've been trying to export a Plot3D into an X3D (JVX, VRML) file using the Mathematica's Export function. The problem is that when the PlotRange is large compared to the other two dimensions the output is essentially stretched into a thin line. Is there a way to maintain the original scaling?

Try the following:

Export["file.x3d", Plot3D[x^2+y^2,{x,-10,10},{y,-10,10}]];


The VerticalAxis option does not seem to help...

Thanks.

The "original scaling" of the displayed plot in Mathematica is determined by the BoxRatios setting for the plot, so it isn't intrinsic to the surface you're trying to export. When you export the plot, only the mesh is kept, with its actual 3D coordinates and without the scaling due to BoxRatios.

Therefore, if you want to export the surface in a "squished" form, you'll have to do the squishing yourself:

p = Plot3D[x^2+y^2,{x,-10,10},{y,-10,10}];
With[{zScale = .05},
Export["squishedPlot.wrl",
p /. Graphics3D[gr_, opts___] :>
Graphics3D[
GeometricTransformation[gr, ScalingTransform[{1, 1, zScale}]],
opts]]
]


I checked that this produces the desired "aspect ratio" by importing the file into Blender.

• Alternatively, one can encase the X3D file inside <transform> tags, setting an inhomogeneous scale='1. 1. 0.05'. Commented May 22, 2015 at 0:42
• @episanty Wouldn't that also squish the axis labels?
– Jens
Commented May 22, 2015 at 1:09
• I've not seen x3d export produce axes or labels to go on them (the output is verbose but easy to inspect as it is essentially xml), but maybe there's options that will do it cleanly (which I would like to see indeed). I doubt that VRML works too differently. Commented May 22, 2015 at 1:48
• @episanty Good point - I think adding a transformation after the fact is certainly equally possible.
– Jens
Commented May 22, 2015 at 3:58