Create 3D meshes

A polygon mesh is a collection of vertices, edges and faces that define the surface of a polyhedral object.

img

The above image shows these basic concepts:

  • a vertex is a point in 3D space (Vector3)

  • an edge is a connection between two vertices

  • a face is a closed set of edges, such as a triangle or a quad (quadrilateral)

  • a polygon is a flat (coplanar) set of faces

  • a surface is a grouping of connected polygons

Explore the MeshInstances3D

Create a new scene with cmd+N, or by clicking on the + sign.

  • add a root Node3D and rename to MeshInstance3D

  • add a child node of MeshInstance3D class and rename to BoxMesh

img

The Mesh attribute in the inspector will be empty.
You can select among these predefined meshes:

img

  • select the BoxMesh

  • then add another MeshInstance3D with a CapsuleMesh

  • and add finally a node with a CylinderMesh

img

Add some more mesh instances:

  • the PlaneMesh is a flat square which can be used as a floor.

  • the QuadMesh is basically the same thing as the PaneMesh, but vertical.

  • the PrismMesh is a triangular prism which can be deformed.

img

Finally add a:

  • SphereMesh

  • TextMesh which displays text in 3D

  • TorusMesh

img

Add an automatic label

The text on top of each mesh has been added with a Label3D child node.

img

You notice the blue script icon. In fact the text of the label is automatically set to be the parent’s name.

 1@tool
 2extends Label3D
 3
 4## Button action to update the text.
 5@export_tool_button("Update") var action := create
 6
 7# Called when the node enters the scene tree for the first time.
 8func _ready() -> void:
 9	create()
10
11## Sets the `Label3D` text attribute to the parent's name.
12func create():
13	var parent = get_parent()
14	text = parent.name

Exercice 1

Create the 3 shapes, which are created from a red cube and a blue sphere

tree

scene

Exercice 2

Create these complex shapes, which are combined with a

  • red cube

  • blue sphere

  • 3 green cylinders

tree

scene