-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode3D.gd
More file actions
37 lines (25 loc) · 935 Bytes
/
Node3D.gd
File metadata and controls
37 lines (25 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
extends Node3D
func _ready():
var noise = FastNoiseLite.new()
noise.frequency = 80
noise.fractal_octaves = 6
var plane_mesh = PlaneMesh.new()
plane_mesh.size = Vector2(400,400)
plane_mesh.subdivide_depth = 200
plane_mesh.subdivide_width = 200
var surface_tool = SurfaceTool.new()
surface_tool.create_from(plane_mesh,0)
var array_plane = surface_tool.commit()
var data_tool = MeshDataTool.new()
data_tool.create_from_surface(array_plane,0)
for i in range(data_tool.get_vertex_count()):
var vertex = data_tool.get_vertex(i)
vertex.y = noise.get_noise_3d(vertex.x,vertex.y,vertex.z) * 60
data_tool.set_vertex(i,vertex)
data_tool.commit_to_surface(array_plane)
surface_tool.begin(Mesh.PRIMITIVE_TRIANGLES)
surface_tool.create_from(array_plane,0)
surface_tool.generate_normals()
var mesh_instance = MeshInstance3D.new()
mesh_instance.mesh = surface_tool.commit()
add_child(mesh_instance)