# Hurry Curry! - a game about cooking
# Copyright (C) 2026 Hurry Curry! Contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
class_name PortalModel
extends Node3D

var target_type = 0.
var current_type = 0.
var target_size = 0.
var current_size = 0.
@onready var mat: ShaderMaterial = $Mesh.get_active_material(0)

func _process(delta: float) -> void:
	if not mat: return
	if abs(target_type - current_type) > 0.01:
		current_type = G.interpolate(current_type, target_type, delta * 15.)
		mat.set_shader_parameter("type", current_type)
	if abs(target_size - current_size) > 0.01:
		current_size = G.interpolate(current_size, target_size, delta * 5.)
		mat.set_shader_parameter("size", current_size)

func configure(size: float, type: bool):
	mat = $Mesh.get_active_material(0)
	target_type = 1. if type else -1.
	target_size = size
