Added visibility component

This commit is contained in:
2024-02-13 20:38:17 +01:00
parent 5caf5f6c71
commit 7937645028
12 changed files with 124 additions and 107 deletions

21
client/world/Generate.gd Normal file
View File

@ -0,0 +1,21 @@
extends Node3D
@export var scene: PackedScene
@export var noise: Noise
@export var size_x: float
@export var size_z: float
@export var step: float = 1
@export var density: float
@export var position_randomness := 1.0
func _ready():
for x in range(-size_x, size_x, step):
for z in range(-size_z, size_z, step):
if noise.get_noise_2d(x, z) < 1 - density * 2:
continue
var t := scene.instantiate() as Node3D
t.rotation.y = randf() * TAU
t.position.x = x + (randf() - 0.5) * position_randomness
t.position.z = z + (randf() - 0.5) * position_randomness
add_child(t)