40 lines
1,003 B
GDScript3
40 lines
1,003 B
GDScript3
|
extends Particles
|
||
|
|
||
|
export var rows = 64.0 setget set_rows, get_rows
|
||
|
func set_rows( value ):
|
||
|
rows = value
|
||
|
amount = rows * rows
|
||
|
update_aabb()
|
||
|
if process_material:
|
||
|
process_material.set_shader_param( "rows", rows )
|
||
|
func get_rows():
|
||
|
return rows
|
||
|
|
||
|
|
||
|
export var spacing = 1.0 setget set_spacing, get_spacing
|
||
|
func set_spacing( value ):
|
||
|
spacing = value
|
||
|
update_aabb()
|
||
|
if process_material:
|
||
|
process_material.set_shader_param( "spacing", spacing )
|
||
|
func get_spacing():
|
||
|
return spacing
|
||
|
|
||
|
|
||
|
func update_aabb():
|
||
|
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():
|
||
|
self.set_rows( self.rows )
|
||
|
self.set_spacing( self.spacing )
|
||
|
|
||
|
func _process( delta ):
|
||
|
|
||
|
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
|