Main Content

show

R2026b

Display mesh or scene object in interactive 3D viewer

Since R2026b

Description

Add-On Required: This feature requires the 3D Asset Processing Library for MATLAB add-on.

show(meshORsceneObj) displays the mesh or scene object meshORsceneObj in an interactive 3D viewer. The viewer renders the mesh with its textures, materials, and colors. The viewer aligns the grid plane and axes orientation according to the UpAxis property of the mesh.

You can interact with the viewer using these mouse controls:

  • Left-click + drag — Rotate or orbit around the target.

  • Middle-click + drag or scroll wheel — Zoom in or zoom out.

  • Right-click + drag — Pan.

figHandle = show(meshORsceneObj,Name=Value) displays the mesh or scene object meshORsceneObj using one or more name-value arguments and returns the figure handle. For example, Background="#FFFFFF" specifies the background color as white.

example

Examples

collapse all

Define a simple pyramid with 5 vertices and 6 triangular faces.

vertices = [0 0 0; 1 0 0; 1 1 0; 0 1 0; 0.5 0.5 1];
faces = [1 2 5; 2 3 5; 3 4 5; 4 1 5; 1 3 4; 1 2 3];

Create a mesh with per-face color.

faceColors = uint8([230 50  50;    % red - front
                    50  180 50;    % green - right
                    50  100 230;   % blue - back
                    230 180 25;    % yellow - left
                    150 75  200;   % purple - bottom 1
                    25  200 200]); % cyan - bottom 2
pyramidMesh = asset3d.Mesh(vertices,faces,FaceColors=faceColors);

Display the mesh.

show(pyramidMesh,Background="#CCCCCC",Grid=true,Axes=true)

Displays a pyramid mesh with different face colors

Input Arguments

collapse all

Source mesh or scene, specified as a Mesh object or Scene object.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: show(mesh,Background="#FFFFFF",Grid=true) displays the mesh with a white background and grid lines.

Background color, specified as a hexadecimal color string. For example, "#CCCCCC".

Data Types: string

Light intensity, specified as a positive scalar.

Data Types: double

Show grid lines, specified as a logical 1 (true) or 0 (false).

Data Types: logical

Show axes, specified as a logical 1 (true) or 0 (false).

Data Types: logical

Zoom level, specified as a positive scalar.

Data Types: double

View preset, specified as one of these values:

  • "default" — Elevated 3/4 view along the current up-axis.

  • "isometric" — Isometric view.

  • "XY+", "XY-", "YZ+", "YZ-", "XZ+", "XZ-" — Views the specified plane from the positive or negative direction of the remaining axis. For example, "XY+" views the XY plane from +Z-axis.

This argument is mutually exclusive with the CameraPosition name-value argument.

Data Types: string

Absolute camera position in world coordinates, specified as a three-element row vector of the form [x y z]. When you specify this argument, it overrides the view preset specified by View name-value argument.

Data Types: double

Camera look-at point in world coordinates, specified as a three-element row vector of the form [x y z]. By default, the camera looks at the center of the model bounding box.

Data Types: double

Container for the viewer, specified as a Figure object or Panel object. If you specify a parent, the function embeds the viewer into the existing container and does not create a new figure.

Explode scene for inspection, specified as a logical 1 (true) or 0 (false). When set to true, the viewer visually displaces each geometry in the scene outward from the explosion origin, allowing you to inspect individual parts of the scene. This does not modify the scene data.

Note

This name-value argument is applicable only when you specify the first input argument as a Scene object.

Data Types: logical

Explosion direction, specified as a positive scalar or a three-element row vector of the form [x y z].

  • If you specify a scalar, the function displaces each geometry in the direction from ExplodeOrigin to the geometry centroid, scaled by the scalar value.

  • If you specify a three-element vector, the function displaces each geometry along the specified direction, proportional to the projection of the vector from ExplodeOrigin to the geometry centroid onto this direction.

If not specified when Explode is true, the function automatically computes the default magnitude from the scene extents.

Note

This name-value argument is applicable only when you specify the first input argument as a Scene object and Explode is set to true.

Data Types: double

Explosion origin point, specified as a three-element row vector of the form [x y z]. The function displaces geometries outward from this point.

Note

This name-value argument is applicable only when you specify the first input argument as a Scene object and Explode is set to true.

Data Types: double

Output Arguments

collapse all

Figure handle, returned as a Figure object. You can use the figure handle to query and modify figure properties. For more information, see Figure.

Version History

Introduced in R2026b

See Also

| | |