LNXSDK/leenkx/blender/lnx/logicnode/math/LN_tween_rotation.py

68 lines
2.8 KiB
Python
Raw Normal View History

2025-01-22 16:18:30 +01:00
from lnx.logicnode.lnx_nodes import *
class TweenFloatNode(LnxLogicTreeNode):
"""Tween rotation.
@input Start: Start tweening
@input Stop: Stop a tweening. tweening can be re-started via the `Start`input
@input From: Tween start value
@input To: Tween final value
@input Duration: Duartion of the tween in seconds
@output Out: Executed immidiately after `Start` or `Stop` is called
@output Tick: Executed at every time step in the tween duration
@output Done: Executed when tween is successfully completed. Not executed if tweening is stopped mid-way
@output Value: Current tween value
"""
bl_idname = 'LNTweenRotationNode'
bl_label = 'Tween Rotation'
lnx_version = 1
property0: HaxeEnumProperty(
'property0',
items = [('Linear', 'Linear', 'Linear'),
('SineIn', 'SineIn', 'SineIn'),
('SineOut', 'SineOut', 'SineOut'),
('SineInOut', 'SineInOut', 'SineInOut'),
('QuadIn', 'QuadIn', 'QuadIn'),
('QuadOut', 'QuadOut', 'QuadOut'),
('QuadInOut', 'QuadInOut', 'QuadInOut'),
('CubicIn', 'CubicIn', 'CubicIn'),
('CubicOut', 'CubicOut', 'CubicOut'),
('CubicInOut', 'CubicInOut', 'CubicInOut'),
('QuartIn', 'QuartIn', 'QuartIn'),
('QuartOut', 'QuartOut', 'QuartOut'),
('QuartInOut', 'QuartInOut', 'QuartInOut'),
('QuintIn', 'QuintIn', 'QuintIn'),
('QuintOut', 'QuintOut', 'QuintOut'),
('QuintInOut', 'QuintInOut', 'QuintInOut'),
('ExpoIn', 'ExpoIn', 'ExpoIn'),
('ExpoOut', 'ExpoOut', 'ExpoOut'),
('ExpoInOut', 'ExpoInOut', 'ExpoInOut'),
('CircIn', 'CircIn', 'CircIn'),
('CircOut', 'CircOut', 'CircOut'),
('CircInOut', 'CircInOut', 'CircInOut'),
('BackIn', 'BackIn', 'BackIn'),
('BackOut', 'BackOut', 'BackOut'),
('BackInOut', 'BackInOut', 'BackInOut')],
name='', default='Linear')
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'Start')
self.add_input('LnxNodeSocketAction', 'Stop')
self.add_input('LnxRotationSocket', 'From')
self.add_input('LnxRotationSocket', 'To')
self.add_input('LnxFloatSocket', 'Duration', default_value=1.0)
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxNodeSocketAction', 'Tick')
self.add_output('LnxNodeSocketAction', 'Done')
self.add_output('LnxRotationSocket', 'Value')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
def draw_label(self) -> str:
return f'{self.bl_label}: {self.property0}'