Planet-Miner/godot/PlanetGeneration.gd

25 lines
653 B
GDScript

@tool
extends Node3D
@export var planet_data : Resource = PlanetData.new():
get:
return planet_data
set(value):
planet_data = value
on_data_changed()
if planet_data != null and not planet_data.is_connected("changed", on_data_changed):
planet_data.connect("changed", on_data_changed)
func _ready():
planet_data = PlanetData.new()
planet_data.noise_map = FastNoiseLite.new()
planet_data.noise_map.set_noise_type(FastNoiseLite.NoiseType.TYPE_SIMPLEX)
planet_data.noise_map.frequency = 1
on_data_changed()
func on_data_changed():
for child in get_children():
var face := child as PlantetMeshFace
face.regenerate_mesh(planet_data)