extends Decal
class_name ParticleDecal

@export var lifetime : float = 1
@export var gradient : Gradient
@export var scale_curve : Curve
@export var rotate : int

var lifetime_now : float

func on_process(delta:float):
	lifetime_now += delta
	var rate = lifetime_now / lifetime
	if rate > 1:
		return
		
	#色带
	if gradient:
		modulate = gradient.sample(rate)
	else:
		modulate.a = 1 - rate
	
	#缩放曲线
	if scale_curve:
		var scale_sample = scale_curve.sample(rate)
		scale = Vector3(scale_sample,1,scale_sample)
	
	#旋转
	rotation_degrees.y = rotate * rate
	
