khanat-client/scenes/decors/terrains/demo/grass.gd

40 lines
919 B
GDScript3
Raw Normal View History

extends Particles
export var rows = 64.0 setget set_rows, get_rows
func set_rows( value ):
2021-09-03 21:27:28 +00:00
rows = value
amount = rows * rows
update_aabb()
if process_material:
process_material.set_shader_param( "rows", rows )
func get_rows():
2021-09-03 21:27:28 +00:00
return rows
export var spacing = 1.0 setget set_spacing, get_spacing
func set_spacing( value ):
2021-09-03 21:27:28 +00:00
spacing = value
update_aabb()
if process_material:
process_material.set_shader_param( "spacing", spacing )
func get_spacing():
2021-09-03 21:27:28 +00:00
return spacing
func update_aabb():
2021-09-03 21:27:28 +00:00
var size = self.rows * self.spacing
self.visibility_aabb = AABB( -Vector3(0.5*size, 50.0, 0.5*size), Vector3(size, 100.0, size) )
func _ready():
2021-09-03 21:27:28 +00:00
self.set_rows( self.rows )
self.set_spacing( self.spacing )
func _process( delta ):
2021-09-03 21:27:28 +00:00
var viewport = self.get_viewport()
var camera = viewport.get_camera()
if camera:
var pos = camera.global_transform.origin
pos.y = 0.0
self.global_transform.origin = pos