{"version":1,"id":"reactails","groups":[{"id":"reactails","name":"ReacTails","parameters":[{"parameter_name":"ReacTailController","label":"ReacTail Controller","min":0,"max":2000000000000,"default_value":0,"script":"-- ReacTail Controller\n-- Keep all shared ReacTails controls here. Wave outputs decode this controller value.\n-- Map ReacTailWave# outputs to model tail sections; do not map this controller to VTS.\n--\n-- Configurable:\n-- @inspect min=0 max=2 step=0.01\nlocal normal_speed = 0.20\n-- @inspect min=0 max=4 step=0.01\nlocal happy_speed = 0.70\n-- @inspect min=0 max=2 step=0.01\nlocal sad_speed = 0.07\n-- @inspect min=0 max=90 step=1\nlocal delay = 25.0\n-- @inspect min=0 max=1.5 step=0.01\nlocal amplitude = 1.0\n\nlocal smile_trigger = 0.55\nlocal eye_wide_happy_boost = 0.15\nlocal speed_change_plus = 2.0\nlocal speed_change_minus = 3.0\nlocal phase_offset_degrees = 0.0\n\nlocal function clamp(value, min_value, max_value)\n    if value < min_value then return min_value end\n    if value > max_value then return max_value end\n    return value\nend\n\nlocal smile = (src.MouthSmileLeft + src.MouthSmileRight) * 0.5\nif src.MouthSmile > smile then\n    smile = src.MouthSmile\nend\nsmile = clamp(smile, 0.0, 1.0)\nlocal eye_wide = (src.EyeWideLeft + src.EyeWideRight) * 0.5\n\nlocal frown = (src.MouthFrownLeft + src.MouthFrownRight) * 0.5\nlocal brow_down = (src.BrowDownLeft + src.BrowDownRight) * 0.5\nlocal eye_blink = (src.EyeBlinkLeft + src.EyeBlinkRight) * 0.5\nlocal eye_relaxed = (1.0 - eye_wide) * 0.5 + (eye_blink * 0.5)\nlocal sad = ((src.BrowInnerUp * 0.35) + (brow_down * 0.25) + (frown * 0.4) + (eye_relaxed * 0.1) - (smile * 0.35) - 0.12) / 0.85\nsad = clamp(sad, 0.0, 1.0)\n\nlocal target = eye_wide * eye_wide_happy_boost\nif smile >= smile_trigger then\n    target = 1.0\nend\ntarget = clamp(target, 0.0, 1.0)\n\nlocal blend = load(\"reactails_blend\", 0.0)\nlocal change_speed = speed_change_minus\nif target > blend then\n    change_speed = speed_change_plus\nend\nlocal step = change_speed * dt()\nstep = clamp(step, 0.0, 1.0)\nblend = clamp(blend + (target - blend) * step, 0.0, 1.0)\nsave(\"reactails_blend\", blend)\n\nlocal speed = normal_speed + (happy_speed - normal_speed) * blend\nspeed = speed + (sad_speed - speed) * sad\nif speed < 0.0 then speed = 0.0 end\n\nlocal angle = load(\"reactails_angle\", 0.0)\nangle = angle + speed * 360.0 * dt()\nwhile angle >= 360.0 do angle = angle - 360.0 end\nwhile angle < 0.0 do angle = angle + 360.0 end\nsave(\"reactails_angle\", angle)\n\nlocal display_angle = angle + phase_offset_degrees\nwhile display_angle >= 360.0 do display_angle = display_angle - 360.0 end\nwhile display_angle < 0.0 do display_angle = display_angle + 360.0 end\n\nlocal phase_units = math.floor(display_angle * 100.0 + 0.5)\nlocal offset_units = math.floor(clamp(delay, 0.0, 90.0) * 100.0 + 0.5)\nlocal amplitude_units = math.floor(clamp(amplitude, 0.0, 1.5) * 1000.0 + 0.5)\nreturn amplitude_units * 1000000000.0 + offset_units * 100000.0 + phase_units\n"},{"parameter_name":"ReacTailWave1","label":"ReacTail Wave 1","min":-1,"max":1,"default_value":0,"script":"-- ReacTail Wave 1\n-- Map this output to tail section 1.\nlocal section_index = 0.0\nlocal packed = src.ReacTailController\nlocal amplitude_units = math.floor(packed / 1000000000.0)\npacked = packed - amplitude_units * 1000000000.0\nlocal offset_units = math.floor(packed / 100000.0)\nlocal phase_units = packed - offset_units * 100000.0\nlocal amplitude = amplitude_units / 1000.0\nlocal section_offset_degrees = offset_units / 100.0\nlocal phase = phase_units / 100.0 - section_offset_degrees * section_index\nlocal value = math.sin(phase * 3.141592653589793 / 180.0) * amplitude\nif value < param_min() then value = param_min() end\nif value > param_max() then value = param_max() end\nreturn value\n"},{"parameter_name":"ReacTailWave2","label":"ReacTail Wave 2","min":-1,"max":1,"default_value":0,"script":"-- ReacTail Wave 2\n-- Map this output to tail section 2.\nlocal section_index = 1.0\nlocal packed = src.ReacTailController\nlocal amplitude_units = math.floor(packed / 1000000000.0)\npacked = packed - amplitude_units * 1000000000.0\nlocal offset_units = math.floor(packed / 100000.0)\nlocal phase_units = packed - offset_units * 100000.0\nlocal amplitude = amplitude_units / 1000.0\nlocal section_offset_degrees = offset_units / 100.0\nlocal phase = phase_units / 100.0 - section_offset_degrees * section_index\nlocal value = math.sin(phase * 3.141592653589793 / 180.0) * amplitude\nif value < param_min() then value = param_min() end\nif value > param_max() then value = param_max() end\nreturn value\n"},{"parameter_name":"ReacTailWave3","label":"ReacTail Wave 3","min":-1,"max":1,"default_value":0,"script":"-- ReacTail Wave 3\n-- Map this output to tail section 3.\nlocal section_index = 2.0\nlocal packed = src.ReacTailController\nlocal amplitude_units = math.floor(packed / 1000000000.0)\npacked = packed - amplitude_units * 1000000000.0\nlocal offset_units = math.floor(packed / 100000.0)\nlocal phase_units = packed - offset_units * 100000.0\nlocal amplitude = amplitude_units / 1000.0\nlocal section_offset_degrees = offset_units / 100.0\nlocal phase = phase_units / 100.0 - section_offset_degrees * section_index\nlocal value = math.sin(phase * 3.141592653589793 / 180.0) * amplitude\nif value < param_min() then value = param_min() end\nif value > param_max() then value = param_max() end\nreturn value\n"},{"parameter_name":"ReacTailWave4","label":"ReacTail Wave 4","min":-1,"max":1,"default_value":0,"script":"-- ReacTail Wave 4\n-- Map this output to tail section 4.\nlocal section_index = 3.0\nlocal packed = src.ReacTailController\nlocal amplitude_units = math.floor(packed / 1000000000.0)\npacked = packed - amplitude_units * 1000000000.0\nlocal offset_units = math.floor(packed / 100000.0)\nlocal phase_units = packed - offset_units * 100000.0\nlocal amplitude = amplitude_units / 1000.0\nlocal section_offset_degrees = offset_units / 100.0\nlocal phase = phase_units / 100.0 - section_offset_degrees * section_index\nlocal value = math.sin(phase * 3.141592653589793 / 180.0) * amplitude\nif value < param_min() then value = param_min() end\nif value > param_max() then value = param_max() end\nreturn value\n"},{"parameter_name":"ReacTailWave5","label":"ReacTail Wave 5","min":-1,"max":1,"default_value":0,"script":"-- ReacTail Wave 5\n-- Map this output to tail section 5.\nlocal section_index = 4.0\nlocal packed = src.ReacTailController\nlocal amplitude_units = math.floor(packed / 1000000000.0)\npacked = packed - amplitude_units * 1000000000.0\nlocal offset_units = math.floor(packed / 100000.0)\nlocal phase_units = packed - offset_units * 100000.0\nlocal amplitude = amplitude_units / 1000.0\nlocal section_offset_degrees = offset_units / 100.0\nlocal phase = phase_units / 100.0 - section_offset_degrees * section_index\nlocal value = math.sin(phase * 3.141592653589793 / 180.0) * amplitude\nif value < param_min() then value = param_min() end\nif value > param_max() then value = param_max() end\nreturn value\n"},{"parameter_name":"ReacTailWave6","label":"ReacTail Wave 6","min":-1,"max":1,"default_value":0,"script":"-- ReacTail Wave 6\n-- Map this output to tail section 6.\nlocal section_index = 5.0\nlocal packed = src.ReacTailController\nlocal amplitude_units = math.floor(packed / 1000000000.0)\npacked = packed - amplitude_units * 1000000000.0\nlocal offset_units = math.floor(packed / 100000.0)\nlocal phase_units = packed - offset_units * 100000.0\nlocal amplitude = amplitude_units / 1000.0\nlocal section_offset_degrees = offset_units / 100.0\nlocal phase = phase_units / 100.0 - section_offset_degrees * section_index\nlocal value = math.sin(phase * 3.141592653589793 / 180.0) * amplitude\nif value < param_min() then value = param_min() end\nif value > param_max() then value = param_max() end\nreturn value\n"},{"parameter_name":"ReacTailWave7","label":"ReacTail Wave 7","min":-1,"max":1,"default_value":0,"script":"-- ReacTail Wave 7\n-- Map this output to tail section 7.\nlocal section_index = 6.0\nlocal packed = src.ReacTailController\nlocal amplitude_units = math.floor(packed / 1000000000.0)\npacked = packed - amplitude_units * 1000000000.0\nlocal offset_units = math.floor(packed / 100000.0)\nlocal phase_units = packed - offset_units * 100000.0\nlocal amplitude = amplitude_units / 1000.0\nlocal section_offset_degrees = offset_units / 100.0\nlocal phase = phase_units / 100.0 - section_offset_degrees * section_index\nlocal value = math.sin(phase * 3.141592653589793 / 180.0) * amplitude\nif value < param_min() then value = param_min() end\nif value > param_max() then value = param_max() end\nreturn value\n"},{"parameter_name":"ReacTailWave8","label":"ReacTail Wave 8","min":-1,"max":1,"default_value":0,"script":"-- ReacTail Wave 8\n-- Map this output to tail section 8.\nlocal section_index = 7.0\nlocal packed = src.ReacTailController\nlocal amplitude_units = math.floor(packed / 1000000000.0)\npacked = packed - amplitude_units * 1000000000.0\nlocal offset_units = math.floor(packed / 100000.0)\nlocal phase_units = packed - offset_units * 100000.0\nlocal amplitude = amplitude_units / 1000.0\nlocal section_offset_degrees = offset_units / 100.0\nlocal phase = phase_units / 100.0 - section_offset_degrees * section_index\nlocal value = math.sin(phase * 3.141592653589793 / 180.0) * amplitude\nif value < param_min() then value = param_min() end\nif value > param_max() then value = param_max() end\nreturn value\n"},{"parameter_name":"ReacTailWave9","label":"ReacTail Wave 9","min":-1,"max":1,"default_value":0,"script":"-- ReacTail Wave 9\n-- Map this output to tail section 9.\nlocal section_index = 8.0\nlocal packed = src.ReacTailController\nlocal amplitude_units = math.floor(packed / 1000000000.0)\npacked = packed - amplitude_units * 1000000000.0\nlocal offset_units = math.floor(packed / 100000.0)\nlocal phase_units = packed - offset_units * 100000.0\nlocal amplitude = amplitude_units / 1000.0\nlocal section_offset_degrees = offset_units / 100.0\nlocal phase = phase_units / 100.0 - section_offset_degrees * section_index\nlocal value = math.sin(phase * 3.141592653589793 / 180.0) * amplitude\nif value < param_min() then value = param_min() end\nif value > param_max() then value = param_max() end\nreturn value\n"}]}],"mappings":{}}