Main Content

Open a Virtual World with MATLAB

Open a virtual world to view the virtual world in a virtual world viewer, scan its structure, and change virtual world properties from the MATLAB® Command Window.

After you create a vrworld object, you can open the virtual world by using the vrworld object associated with that virtual world. This procedure uses the vrworld object myworld associated with the virtual world virtual world.x3d as an example:

  1. In the MATLAB Command Window, type

    open(virtual world object name);
    

    The MATLAB Command Window opens the virtual world.

  2. Type

    set(virtual world object name, 'Description', 'My first virtual world');
    

    The Description property is changed to My first virtual world. This description displays in all Simulink® 3D Animation™ object listings, in the title bar of the Simulink 3D Animation Viewer, and in the list of virtual worlds on the Simulink 3D Animation HTML page.

  3. Display the virtual world. Type

    view(virtual world object name)
    

    The viewer that is set as the default viewer displays the virtual scene. The default viewer is typically the Simulink 3D Animation Viewer unless you have a different viewer set.

Alternatively, you can display the virtual world in an HTML5-enabled web browser.

  1. Repeat steps 1 and 2 of the preceding procedure.

  2. Open a web browser. In the Address box, type

    http://localhost:8123
    

    The browser displays the Simulink 3D Animation HTML page with a link to My first virtual world. The number 8123 is the default Simulink 3D Animation port number. If you set a different port number on your system, enter that number in place of 8123 and restart MATLAB. For more information on the Simulink 3D Animation HTML page, see View Virtual World on Host Computer.

  3. If the web browser has the VRML or X3D plug-in installed, in the browser window, click My first virtual world.

  4. Your default HTML5-enabled web browser displays the virtual world virtual world object name.

    Note

    If your web browser is not HTML5-enabled, clicking a virtual world link such as My first virtual world results in a broken link message. The browser cannot display the virtual world.

For more information on changing your default viewer, see Set the Default Viewer.

See Also

Functions

Related Topics