extends Node3D

@export var chunk_size = 16
@export var world_size = 6
@export var threshold = 0.2

var chunk_scene = preload("res://SurfaceNetsWorld/chunk.tscn")

var ComputeSdf = preload("res://SurfaceNetsWorld/compute_samples.gd")
var gpu_sdf

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	gpu_sdf = ComputeSdf.new()
	gpu_sdf.create_device(chunk_size)
	for x in range(world_size):
		for y in range(world_size):
			for z in range(world_size):
				var chunk: Node = chunk_scene.instantiate()
				chunk.chunk_size = chunk_size
				chunk.threshold = threshold
				chunk.position = Vector3(x * chunk_size, y * chunk_size, z * chunk_size)
				chunk.generate_chunk(gpu_sdf)
				await Engine.get_main_loop().process_frame
				add_child(chunk)
		


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass
