Main Content


(To be removed) Import 3D file into virtual world or node

vrimport will be removed in a future release. For more information, see Version History.


node = vrimport(source) creates an empty VRML virtual world and imports the source 3D file into it. The format of the 3D file is detected automatically. You can import these file formats:

  • FBX (Autodesk® FilmBoX format)

  • DAE (Collada digital asset exchange)

  • SDF (simulation description format)

  • STL (STereoLithography)

  • URDF (unified robot description file)

  • XML (Physical Modeling XML files)

The function returns a handle to the newly created node.

node = vrimport(parent,source) specifies the existing virtual world or node to import the 3D source file into.

node = vrimport(___,format) explicitly specifies the file format of the 3D source file (for example, 'urdf'). If the format of the source file does not match the format specified in the format argument, the function returns an error.


[node,virtualWorld] = vrimport(___) returns the handle of the new node and the handle of the virtual world that contains that node.


collapse all

This example imports an STL file my STL file.stl. The example also shows how to add visual appearance and material nodes to the imported model in the virtual world.

Create a virtual world with the imported model.

[n,w] = vrimport(which('my STL file.stl'));

View the virtual world with the imported shape.


Scale the imported model from mm to dm to see it in the view.

n.scale = [0.01 0.01 0.01]

Explore the virtual world structure.


STL imported shapes have no visual properties. Add an Appearance and a Materials node to the shape. The Appearance node is created in the appearance field of the Shape. The Material node is create in the material field of the Appearance node.

Set the diffuse color to a shade of blue.

Save the virtual world.

save(w,'my STL file.x3d')

This example imports a my DAE file format file into a virtual world.

Import the my DAE file file to a node in a virtual world.

[n,w] = vrimport(which('my DAE file.dae'));

View the imported visual representation.


Save the virtual world.

save(w,'my DAE file.x3d')

Input Arguments

collapse all

3D source file path, specified as a character vector. The 3D file can be in DAE, SDF, STL, or URDF format.

File format of source 3D file, specified as a character vector. Use this argument to specify explicitly the required format for the source 3D file.

Virtual world or node to import 3D source file into, specified as a virtual world handle or node handle.

  • If the parent is a virtual world, the imported node is placed at the ROOT node of the parent.

  • If the parent is a node in a virtual world, the imported node is placed in the children field of the node.

Output Arguments

collapse all

New node, returned as a vrnode object.

Virtual world containing new node, returned as a vrworld object.

Version History

Introduced in R2016b

collapse all

R2023b: To be removed

The vrimport function will be removed in a future release. Instead, use sim3d classes and Simulation 3D blocks in Unreal Engine Scenario Applications to interface MATLAB® and Simulink® with the Unreal Engine® 3D simulation environment. To get started, see Get Started Creating Virtual World with Actors.