24 lines
746 B
GDScript
24 lines
746 B
GDScript
extends Node
|
|
|
|
@export var chunks = 10
|
|
const value = 300
|
|
|
|
var TerrainHtread: Thread
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
TerrainHtread = Thread.new()
|
|
TerrainHtread.start(generate_chuks.bind(chunks,value,self))
|
|
|
|
func generate_chuks(_chunks,_value,parent):
|
|
for chunk in _chunks:
|
|
var checukn :Node3D= Node3D.new()
|
|
checukn.position = Vector3(randf_range(-_value,_value),0,randf_range(-_value,_value))
|
|
checukn.set_script(load("res://world_generation/grok_chnk.gd"))
|
|
parent.call_deferred("add_child",checukn)
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
pass
|
|
|
|
func _exit_tree() -> void:
|
|
TerrainHtread.wait_to_finish()
|