extends Node3D @export_subgroup("Noise", "noise") @export var noise_function : FastNoiseLite @export var noise_scale : Vector2 = Vector2(1., 1.) @export_subgroup("Terrain", "terrain") @export var terrain_size : Vector2i = Vector2i(96, 96) @export var terrain_height : float = 32 @onready var terrain_mesh : MultiMeshInstance3D = $%TerrainMesh func _ready() -> void: ($%Camera as Camera3D).look_at_from_position(Vector3(terrain_size.x / sqrt(2), terrain_height * 2.0, terrain_size.y / sqrt(2)), Vector3.ZERO) # Build terrain var point_count : int = terrain_size.x * terrain_size.y terrain_mesh.multimesh.set_instance_count(point_count) var idx : int = 0 for y in range(terrain_size.y): for x in range(terrain_size.x): var height : float = ((noise_function.get_noise_2d(x, y) + 1.0) * terrain_height) / 2.0 var transfo : Transform3D = Transform3D.IDENTITY transfo = transfo.translated(Vector3(x + 0.5 - (terrain_size.x / 2.0), height, y + 0.5 - (terrain_size.y / 2.0))) terrain_mesh.multimesh.set_instance_transform(idx, transfo) idx += 1
or share this direct link: