Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ImmediateMesh

Inherits: Mesh < Resource < RefCounted < Object

Mesh optimized for creating geometry manually.

Description

A mesh type optimized for creating geometry manually, similar to OpenGL 1.x immediate mode.

Here's a sample on how to generate a triangular face:

var mesh = ImmediateMesh.new()
mesh.surface_begin(Mesh.PRIMITIVE_TRIANGLES)
mesh.surface_add_vertex(Vector3.LEFT)
mesh.surface_add_vertex(Vector3.FORWARD)
mesh.surface_add_vertex(Vector3.ZERO)
mesh.surface_end()

Note: Generating complex geometries with ImmediateMesh is highly inefficient. Instead, it is designed to generate simple geometry that changes often.

Tutorials

Methods

void

clear_surfaces ( )

void

surface_add_vertex ( Vector3 vertex )

void

surface_add_vertex_2d ( Vector2 vertex )

void

surface_begin ( PrimitiveType primitive, Material material=null )