{
"sprtg_tailgate3": {
    "information":{
        "authors":"BeamNG",
        "name":"Tailgate Facelift",
        "value":400,
    },
    "slotType" : "sprtg_tailgate2",
    "slots": [
        ["type", "default", "description"],
        ["sprtg_tailgateglass3","sprtg_tailgateglass3", "Tailgate Glass"],
        ["sprtg_spoiler","","Spoiler"],
        ["sprtg_licenseplate_RT","sprtg_licenseplate_R_EU","Plates", {"nodeMove":{"x":0.0,"y":0.0588,"z":0.005}}],
    ],
    "flexbodies": [
        ["mesh", "[group]:", "nonFlexMaterials"],
        ["sprtg_tailgate3", ["sprtg_tailgate"]],
        ["sprtg_tailgate2.001", ["sprtg_tailgate"]],
        ["sprtg_tailgate_carp", ["sprtg_tailgate"]],
        ["sprtg_wiper_R", ["sprtg_tailgate"]],
        ["sprtg_logo_tailgate_b", ["sprtg_tailgate"]],

        {"deformGroup":"tailgateglass_break", "deformMaterialBase":"sprtg_blacke", "deformMaterialDamaged":"sprtg_blacke"},
        ["sprtg_tailgate_chmsl", ["sprtg_tailgate"]],

        {"deformGroup":"tailgatelight_L_break", "deformMaterialBase":"sprtg_blacke", "deformMaterialDamaged":"sprtg_blacke"},
        ["sprtg_tailgate_a_light_L3", ["sprtg_tailgate"],[]{"deformSound":"event:>Destruction>Vehicle>Glass>glassbreaksound3", "deformVolume":0.3}],
        {"deformGroup":"tailgatelight_R_break", "deformMaterialBase":"sprtg_blacke", "deformMaterialDamaged":"sprtg_blacke"},
        ["sprtg_tailgate_a_light_R3", ["sprtg_tailgate"],[]{"deformSound":"event:>Destruction>Vehicle>Glass>glassbreaksound4", "deformVolume":0.3}],

        {"deformGroup":"tailgatelight_L_break", "deformMaterialBase":"sprtg_glass", "deformMaterialDamaged":"sprtg_glass_dmg"},
        ["sprtg_tailgate_a_lightglass_L3", ["sprtg_tailgate"]],
        {"deformGroup":"tailgatelight_R_break", "deformMaterialBase":"sprtg_glass", "deformMaterialDamaged":"sprtg_glass_dmg"},
        ["sprtg_tailgate_a_lightglass_R3", ["sprtg_tailgate"]],
        {"deformGroup":""},
    ],
    "props": [
        ["func", "mesh", "idRef:", "idX:", "idY:", "baseRotation", "rotation", "translation", "min", "max", "offset", "multiplier"],
        //chmsl
        {
            "lightInnerAngle":0,
            "lightOuterAngle":120,
            "lightRange":8,
            "lightColor":{"r":255, "g":10, "b":0, "a":255},
            "lightAttenuation":{"x":0, "y":1, "z":1},
            "lightCastShadows":false,
            "flareName":"vehicleBrakeLightFlare",
        },
        ["brakelights", "SPOTLIGHT", "t2r", "t2l", "t3rr", {"x":120,"y":0,"z":0}, {"x":0,"y":0,"z":0}, {"x":0,"y":0,"z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.5,"y":0.2,"z":-0.05},"flareScale":0.0,"lightBrightness":0.06,"deformGroup":"tailgateglass_break"}],
        //taillights
        {
            "lightInnerAngle":0,
            "lightOuterAngle":120,
            "lightRange":8,
            "lightColor":{"r":255, "g":10, "b":0, "a":255},
            "lightAttenuation":{"x":0, "y":1, "z":1},
            "lightCastShadows":false,
            "flareName":"vehicleBrakeLightFlare",
        },
        ["brakelights" ,         "SPOTLIGHT"        , "t4rr", "t4r", "t3rr", {"x":-70, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.2, "y":0.1, "z":0.01},"flareScale":0.0,"lightBrightness":0.06,"deformGroup":"tailgatelight_R_break"}],
        ["brakelights" ,         "SPOTLIGHT"        , "t4ll", "t4l", "t3ll", {"x":-110, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.2, "y":0.1, "z":-0.01},"flareScale":0.0,"lightBrightness":0.06,"deformGroup":"tailgatelight_L_break"}],
        ["lowhighbeam" ,         "SPOTLIGHT"        , "t4rr", "t4r", "t3rr", {"x":-70, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.2, "y":0.03, "z":0.01},"flareScale":0.0,"lightBrightness":0.04,"lightRange":8,"deformGroup":"tailgatelight_R_break"}],
        ["lowhighbeam" ,         "SPOTLIGHT"        , "t4ll", "t4l", "t3ll", {"x":-110, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.2, "y":0.03, "z":-0.01},"flareScale":0.0,"lightBrightness":0.04,"lightRange":8,"deformGroup":"tailgatelight_L_break"}],
        //turn signals
        {"lightColor":{"r":255, "g":200, "b":20, "a":255},},
        ["signal_R" ,         "SPOTLIGHT"        , "t4rr", "t4r", "t3rr", {"x":-70, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.1, "y":-0.1, "z":0.0},"flareScale":0.0,"lightBrightness":0.05,"deformGroup":"tailgatelight_R_break"}],
        ["signal_L" ,         "SPOTLIGHT"        , "t4ll", "t4l", "t3ll", {"x":-110, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.1 "y":-0.1, "z":0.0},"flareScale":0.0,"lightBrightness":0.05,"deformGroup":"tailgatelight_L_break"}],
        {
            "lightInnerAngle":0,
            "lightOuterAngle":120,
            "lightRange":8,
            "lightColor":{"r":255, "g":255, "b":200, "a":255},
            "lightAttenuation":{"x":0, "y":1, "z":1},
            "lightCastShadows":false,
            "flareName":"vehicleReverseLightFlare",
            "cookieName":"art/special/BNG_light_cookie_headlight.dds"
            "texSize":512,
            "shadowSoftness":0.5,
        },
        ["reverse" ,         "SPOTLIGHT"        , "t4rr", "t4r", "t3rr", {"x":-60, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.52, "y":-0.1, "z":-0.02},"flareScale":0.0,"lightBrightness":0.2,"deformGroup":"tailgatelight_R_break"}],
        ["reverse" ,         "SPOTLIGHT"        , "t4ll", "t4l", "t3ll", {"x":-120, "y":0, "z":0} , {"x":0, "y":0, "z":0}    , {"x":0, "y":0, "z":0}, 0, 0, 0, 1, {"baseTranslation":{"x":0.52 "y":-0.1, "z":0.02},"flareScale":0.0,"lightBrightness":0.2,"deformGroup":"tailgatelight_L_break"}],
    ],
    "controller": [
        ["fileName"],
        ["advancedCouplerControl", {"name":"tailgateCoupler"}],
    ]
    "tailgateCoupler":{
        "groupType": "autoCoupling",
        "couplerNodes":[
            ["cid1",    "cid2",     "autoCouplingStrength",    "autoCouplingRadius",   "autoCouplingLockRadius",   "autoCouplingSpeed", "couplingStartRadius",  "breakGroup"]
            ["r4",      "t7",        40000,                     0.01,                   0.005,                      0.2,                 0.1,                   "tailgate_latch"]
        ]
        "attachSoundVolume":1,
        "detachSoundVolume":1,
        "soundNode:":["r4"]
        "attachSoundEvent": "event:>Vehicle>Latches>Trunk>modern_05_close",
        "detachSoundEvent": "event:>Vehicle>Latches>Trunk>modern_05_open",
        "breakSoundEvent":""
        "openForceMagnitude": 0,
        "openForceDuration": 0,
        "closeForceMagnitude": 525,
        "closeForceDuration": 3.0,
    }
    "triggers":[
        ["id", "label", "idRef:", "idX:", "idY:", "type", "size", "baseRotation", "rotation", "translation", "baseTranslation"],
        ["tailgate", "", "t5","t5r","t4", "box", {"x":0.08, "y":0.08, "z":0.08}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":-0.04, "y":-0.0, "z":-0.07}],
    ],
    "triggerEventLinks":[
        ["triggerId:triggers", "action", "targetEventId:events"],
        ["tailgate", "action0", "tailgateLatch"],
    ],
    "events":[
        ["id", "title", "desc"],
        ["tailgateLatch", "ui.inputActions.sprtg.tailgateLatch.title", "ui.inputActions.sprtg.tailgateLatch.description", {"onUp":"controller.getControllerSafe('tailgateCoupler').toggleGroup()"}],
    ],
    "nodes": [
        ["id", "posX", "posY", "posZ"],
         //--TAILGATE--
         {"collision":true},
         {"selfCollision":true},
         {"nodeMaterial":"|NM_METAL"},
         {"frictionCoef":0.5},
         {"group":"sprtg_tailgate"},
         {"nodeWeight":1.1},
         ["t1r",-0.599,1.7036,1.5009, {"nodeWeight":1.5}],
         ["t1",-0.0000,1.7136,1.5449, {"group":["tailgatefix","sprtg_tailgate"]}],
         ["t1l",0.599,1.7036,1.5009, {"nodeWeight":1.5}],

         ["t2r",-0.587,1.9625,1.4639],
         ["t2",-0.0000,2.0695,1.4769],
         ["t2l",0.587,1.9625,1.4639],

         {"nodeWeight":1.3},
         ["t3r",-0.25,2.28,1.1917],
         ["t3l",0.25,2.28,1.1917],

         ["t4rr",-0.607,2.357,1.0767],
         ["t4r",-0.28,2.398,1.1027],
         ["t4",0.0,2.408,1.1057],
         ["t4l",0.28,2.398,1.1027],
         ["t4ll",0.607,2.357,1.0767],

         ["t5rr",-0.563,2.338,0.6257,{"selfCollision":false}],
         ["t5r",-0.277,2.4,0.6107],
         ["t5",0.0,2.41,0.6107],
         ["t5l",0.277,2.4,0.6107],
         ["t5ll",0.563,2.338,0.6257,{"selfCollision":false}]

         {"collision":false},
         {"selfCollision":false},
         {"nodeWeight":2.5},
         {"group":""},
         ["t6",0.0,2.0030,0.818],
         {"group":""},

         //latch node
         {"nodeWeight":0.8},
         ["t7", 0.0, 2.32, 0.5927],
    ],
    "beams": [
          ["id1:", "id2:"],
          //--TAILGATE--
          {"beamType":"|NORMAL", "beamLongBound":1.0, "beamShortBound":1.0},
          {"beamSpring":1201000,"beamDamp":100},
          {"beamDeform":32550,"beamStrength":"FLT_MAX"},
          //tailgate main shape
          {"deformLimitExpansion":1.2},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.005},
          ["t3ll", "t2ll"],
          ["t2ll", "t1l"],
          ["t3rr", "t2rr"],
          ["t2rr", "t1r"],
          ["t2r", "t1r"],
          ["t2", "t1"],
          ["t2l", "t1l"],
          ["t1l", "t1"],
          ["t1", "t1r"],
          ["t2l", "t2"],
          ["t2", "t2r"],
          ["t2r", "t2rr"],
          ["t2l", "t2ll"],
          ["t3ll", "t3l"],
          ["t3l", "t3r"],
          ["t3r", "t3rr"],
          {"deformGroup":"tailgatelight_R_break", "deformationTriggerRatio":0.005},
          ["t3rr", "t4rr"],
          ["t4rr", "t5rr"],
          ["t3r", "t4r"],
          ["t4r", "t5r"],
          ["t5rr", "t5r"],
          ["t4rr", "t4r"],
          ["t3rr", "t3r"],
          {"deformGroup":"tailgatelight_L_break", "deformationTriggerRatio":0.005},
          ["t3ll", "t4ll"],
          ["t4ll", "t5ll"],
          ["t3l", "t4l"],
          ["t4l", "t5l"],
          ["t5ll", "t5l"],
          ["t4ll", "t4l"],
          ["t3ll", "t3l"],
          {"deformGroup":""},
          ["t5l", "t5"],
          ["t5", "t5r"],
          ["t4r", "t4"],
          ["t4", "t4l"],
          ["t3l", "t3r"],
          ["t5", "t4"],

          //surficial crossing
          {"deformLimitExpansion":""},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.005},
          {"beamDeform":14550,"beamStrength":"FLT_MAX"},
          ["t2l", "t3ll"],
          ["t2r", "t3rr"],
          ["t3rr", "t1r"],
          ["t3ll", "t1l"],
          ["t1l", "t2"],
          ["t1", "t2l"],
          ["t1", "t2r"],
          ["t2", "t1r"],
          {"deformGroup":"tailgatelight_R_break", "deformationTriggerRatio":0.005},
          ["t5rr", "t4r"],
          ["t5r", "t4rr"],
          ["t4rr", "t3r"],
          ["t4r", "t3rr"],
          {"deformGroup":"tailgatelight_L_break", "deformationTriggerRatio":0.005},
          ["t5ll", "t4l"],
          ["t5l", "t4ll"],
          ["t4ll", "t3l"],
          ["t4l", "t3ll"],
          {"deformGroup":""},
          ["t4l", "t3r"],
          ["t4r", "t3l"],
          ["t3l", "t4"],
          ["t4", "t3r"],
          ["t4", "t5r"],
          ["t4r", "t5"],
          ["t5", "t4l"],
          ["t4", "t5l"],

          //corners
          {"beamDeform":10550,"beamStrength":"FLT_MAX"},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.01},
          ["t2ll", "t1"],
          ["t2ll", "t2"],
          ["t2rr", "t2"],
          ["t2rr", "t1"],
          ["t2rr", "t1l"],
          ["t2ll", "t1r"],
          ["t3ll", "t2"],
          ["t3rr", "t2"],
          ["t3r", "t2r"],
          ["t3l", "t2l"],
          ["t3r", "t2l"],
          ["t3l", "t2r"],
          {"deformGroup":""},

          //rigids
          {"beamSpring":801000,"beamDamp":120},
          {"beamDeform":5550,"beamStrength":"FLT_MAX"},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.01},
          ["t3ll", "t3r"],
          ["t3rr", "t3l"],
          ["t4ll", "t2l"],
          ["t4rr", "t2r"],
          ["t4rr", "t2rr"],
          ["t4ll", "t2ll"],
          {"deformGroup":"tailgatelight_R_break", "deformationTriggerRatio":0.005},
          ["t5rr", "t3rr"],
          ["t5r", "t3r"],
          {"deformGroup":"tailgatelight_L_break", "deformationTriggerRatio":0.005},
          ["t5ll", "t3ll"],
          ["t5l", "t3l"],
          {"deformGroup":""},
          ["t4ll", "t4"],
          ["t5ll", "t5"],
          ["t4rr", "t4"],
          ["t5rr", "t5"],
          ["t5l", "t5r"],
          ["t4l", "t4r"],
          ["t5", "t3l"],
          ["t5", "t3r"],

          //rigidifier
          {"beamSpring":2201000,"beamDamp":30},
          {"beamDeform":5000,"beamStrength":"FLT_MAX"},
          {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.05},
          ["t6", "t1"],
          ["t6", "t1r"],
          ["t6", "t1l"],
          ["t6", "t2"],
          ["t6", "t2r"],
          ["t6", "t2l"],
          ["t6", "t2rr"],
          ["t6", "t2ll"],
          ["t6", "t3r"],
          ["t6", "t3l"],
          ["t6", "t3rr"],
          ["t6", "t3ll"],
          ["t6", "t4rr"],
          ["t6", "t4r"],
          ["t6", "t4ll"],
          ["t6", "t4l"],
          ["t6", "t4"],
          ["t6", "t5"],
          ["t6", "t5r"],
          ["t6", "t5l"],
          ["t6", "t5rr"],
          ["t6", "t5ll"],
          {"deformGroup":""},

          //latch node
          {"beamSpring":601000,"beamDamp":250},
          {"beamDeform":6000,"beamStrength":"FLT_MAX"},
          ["t7", "t3l"],
          ["t7", "t3r"],
          ["t7", "t3ll"],
          ["t7", "t3rr"],
          ["t7", "t4ll"],
          ["t7", "t4rr"],
          ["t7", "t4l"],
          ["t7", "t4r"],
          ["t7", "t5"],

          //tailgate hinge
          {"beamSpring":1201000,"beamDamp":120},
          {"beamDeform":18000,"beamStrength":44000},
          {"breakGroup":"tailgatehinge_R"},
          ["t1r", "rf4r", {"deformGroup":"tailgatelight_R_break", "deformationTriggerRatio":0.1}],
          ["t1r", "rf3r", {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.1}],
          ["t1r", "rf4"],
          ["t1r", "p10r"],
          ["t1r", "p9r"],
          {"breakGroup":"tailgatehinge_L"},
          ["t1l", "rf4l", {"deformGroup":"tailgatelight_L_break", "deformationTriggerRatio":0.1}],
          ["t1l", "rf3l", {"deformGroup":"tailgateglass_break", "deformationTriggerRatio":0.1}],
          ["t1l", "rf4"],
          ["t1l", "p10l"],
          ["t1l", "p9l"],
          {"breakGroup":""},

          //gas struts
          {"breakGroupType":1},
          {"beamSpring":300,"beamDamp":200},
          {"beamDeform":4000,"beamStrength":10000},
          {"beamPrecompression":4.5},
          ["t3rr", "r4rr", {"breakGroup":"tailgatehinge_R"}],
          ["t3ll", "r4ll", {"breakGroup":"tailgatehinge_L"}],
          {"beamPrecompression":1},
          {"breakGroupType":0},
          {"breakGroup":""},

          //pop open
          {"beamPrecompression":1.03,"beamSpring":50000,"beamDamp":1320,"beamDeform":40000,"beamStrength":10000,"breakGroupType":1,"beamType":"|SUPPORT", "beamLongBound":25},
          ["t5r", "r2rr", {"breakGroup":"tailgatehinge_R"}],
          ["t5l", "r2ll", {"breakGroup":"tailgatehinge_L"}],
          {"beamPrecompression":1},
          {"breakGroupType":0},

          //tailgate support beams
          {"beamType":"|SUPPORT", "beamLongBound":4},
          {"beamSpring":1001000,"beamDamp":50},
          {"beamDeform":7500,"beamStrength":230000},
          ["t1r", "rf3r"],
          ["t1l", "rf3l"],
          ["t2rr", "p9r"],
          ["t2ll", "p9l"],
          ["t3rr", "q2r"],
          ["t3ll", "q2l"],
          ["t5ll", "r2ll"],
          ["t5rr", "r2rr"],
          ["t5", "r2"],
          ["t5rr", "r3rr"],
          ["t5ll", "r3ll"],
          ["t2r", "q2r"],
          ["t1r", "q2r"],
          ["t1l", "q2l"],
          ["t2l", "q2l"],
          ["t1r", "rf4"],
          ["t2r", "rf4"],
          ["t1l", "rf4"],
          ["t2l", "rf4"],
          {"beamPrecompression":0.8},
          ["t2l", "rf3l"],
          ["t2r", "rf3r"],
          {"beamPrecompression":1, "beamType":"|NORMAL", "beamLongBound":1.0, "beamShortBound":1.0},
          {"deformLimitExpansion":1.2},
    ],
    "triangles": [
            ["id1:","id2:","id3:"],
            //tailgate
            {"group":"sprtg_tailgate"},
            {"dragCoef":8},
            ["t3l", "t4", "t3r"],
            ["t3r", "t4", "t4r"],
            ["t3l", "t4l", "t4"],
            ["t4", "t5", "t4r"],
            ["t4l", "t5", "t4"],
            ["t4r", "t5", "t5r"],
            ["t4l", "t5l", "t5"],
            ["t5r", "t5rr", "t4rr"],
            ["t4rr", "t4r", "t5r"],
            ["t4l", "t4ll", "t5l"],
            ["t4ll", "t5ll", "t5l"],
            ["t3r", "t4r", "t3rr"],
            ["t3rr", "t4r", "t4rr"],
            ["t3ll", "t4l", "t3l"],
            ["t3ll", "t4ll", "t4l"],
            ["t2r", "t3rr", "t2rr"],
            ["t2r", "t2rr", "t1r"],
            ["t2l", "t2ll", "t3ll"],
            ["t1l", "t2ll", "t2l"],
            ["t1", "t2r", "t1r"],
            ["t1", "t2", "t2r"],
            ["t1l", "t2l", "t1"],
            ["t1", "t2l", "t2"],
            ["t2", "t3l", "t3r"],
            ["t2l", "t3l", "t2"],
            ["t2", "t3r", "t2r"],
            ["t2r", "t3r", "t3rr"],
            ["t2l", "t3ll", "t3l"],
    ],
},
}