X3D (.x3d)

Background & Context

    • MIME type: model/x3d+xml
    • Web3D geometry format.
    • Commonly used for distributing 3D models on the web and in media applications.
    • XML format.
    • Can store multiple geometries.
    • Introduced in 2003, maintained by the Web3D Consortium.
    • Successor of the VRML format.

Import & Export

  • Import["file.x3d"] imports an X3D file as a MeshRegion object representing the surface.
  • Import["file.x3d",elem] imports the specified element from an X3D file.
  • The import format can be specified with Import["file","X3D"] or Import["file",{"X3D",elem,}].
  • Export["file.x3d",expr] exports a 3D mesh-based geometric region to a X3D file. The expr can be any region that is ConstantRegionQ or a Graphics or Graphics3D object.
  • The export format can be specified with Export["file",expr,"X3D"] or Export["file",expr,{"X3D",opt1->val1,}].
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the X3D format.

Import Elements

  • General Import elements:
  • "Elements"list of elements available in this file
    "Rules"list of rules for each element
    "Options"list of options and settings
    "Summary"summary of properties
  • Data format representation elements:
  • "LineData"lines represented as lists of indices, referencing the vertices as given by the "VertexData" element
    "PointData"point data in indexed form
    "PolygonData"list of polygon elements in indexed form
    "VertexData"list of vertex coordinates
    "VertexNormals"normal vectors corresponding to the vertices given by "VertexData"
  • Geometry representation elements:
  • "BoundaryMeshRegion"boundary mesh representation of a solid
    "MeshRegion"mesh representation of a surface
    "Region"region representation of a surface
  • Graphics representation elements:
  • "Graphics3D"X3D file represented as a Graphics3D object
    "GraphicsComplex"X3D file as a GraphicsComplex object
    "LineObjects"list of Line primitives given in absolute coordinates
    "PointObjects"list of Point primitives given in absolute coordinates
    "PolygonObjects"list of polygon primitives in absolute coordinates
  • Import and Export use the "MeshRegion" element by default for X3D files.

Options

  • Advanced options:
  • "InvertNormals"Falsewhether to invert the orientation of vertex normals
    "VerticalAxis"{0,0,1}orientation to assume for the coordinate system used in the file
  • By default, the Wolfram Language assumes that in the coordinate system used by the X3D format, the vertical axis corresponds to the third coordinate.
  • With the setting "VerticalAxis"->{0,1,0}, the Wolfram Language will apply the transformation {x,y,z}->{x,z,-y} to all graphics coordinates when exporting to X3D.

Examples

open allclose all

Basic Examples  (3)

Import a 3D model from X3D as a MeshRegion object:

"Summary" properties of the solid model:

Export a 3D model to an ASCII X3D file:

Print the raw textual contents of the file:

Export a 3D model:

Scope  (8)

Import  (4)

Import works on X3D file:

Any accessible URL:

Stream:

Import provides access to elements in the X3D file:

Export  (4)

Export works on 3D graphics:

Special regions:

Formula regions:

Mesh regions:

Import Elements  (13)

"BoundaryMeshRegion"  (1)

"Graphics3D"  (1)

Give the Graphics3D object:

"GraphicsComplex"  (1)

Give the GraphicsComplex object:

"MeshRegion"  (1)

Give a MeshRegion:

"LineData"  (1)

Give the "LineData" object:

"LineObjects"  (1)

Give the "LineObjects" object:

"PointData"  (1)

Give the "PointData" object:

"PointObjects"  (1)

Give the "PointObjects" object:

"PolygonData"  (1)

Give the polygon elements in indexed form:

"PolygonObjects"  (1)

Give the list of Polygon primitives given in absolute coordinates:

"Region"  (1)

Give a Region:

"Summary"  (1)

Give the "Summary" of properties:

File size:

"VertexData"  (1)

Give the vertex coordinates:

Export Options  (2)

InterpretationBox[Cell["\t", "ExampleDelimiter", ExpressionUUID -> "b94638f8-693f-4756-b8c8-b6117dce0299"], $Line = 0; Null]  (1)

Invert normals:

InterpretationBox[Cell["\t", "ExampleDelimiter", ExpressionUUID -> "4f7b9b71-87cd-4788-a5e4-da61674cf837"], $Line = 0; Null]  (1)

Set vertical axis: