{
"frog06150_tailgate": {
    "information":{
        "authors":"BeamNG",
        "name":"Tailgate",
        "value":500,
    },
    "slotType" : "frog06150_tailgate",
    "slots": [
        ["type", "default", "description"],
        ["frog06150_lettering","frog06150_lettering_v8_4WD","Lettering"],
        ["frog06150_tailgatepanel","","Tailgate Panel"],
        ["frog06150_duallysignals_R","","Rear Marker Lights"],
    ],
    "flexbodies": [
         ["mesh", "[group]:", "nonFlexMaterials"],
         ["frog06150_tailgate", ["pickup_tailgate"],[],{"pos":{"x":0.0, "y":0.0, "z":0.0}}],
    ],
    // tdev - this is the latest format - 14th of March 2021
    "triggers":[
        ["id", "label", "idRef:", "idX:", "idY:", "type", "size", "baseRotation", "rotation", "translation", "baseTranslation"],
        ["tailgate", "", "t1","t1r","t2", "box", {"x":0.15, "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.075, "y":0.18, "z":-0.07}, {"deformGroup":"pickup_tailgate_R"}],
    ],
    "triggerEventLinks":[
        ["triggerId:triggers", "action", "targetEventId:events"],
        ["tailgate", "action0", "toggle_doors"]
    ],
    "events":[
        ["id", "title", "desc"],
        ["toggle_doors", "ui.inputActions.van.toggle_doors.title", "ui.inputActions.van.toggle_doors.description", {"onDown": "electrics.values.tailgate = 1-(electrics.values.tailgate or 0)", "order": 1}]
    ],
    "nodes": [
         ["id", "posX", "posY", "posZ"],
         {"frictionCoef":0.5},
         {"nodeMaterial":"|NM_METAL"},
         //--TAILGATE--
         {"collision":true},
         {"selfCollision":true},
         {"group":["pickup_tailgate","pickup_tailgate_standard"]},
         {"nodeWeight":3.055},
         ["t1rr", -0.82000, 3.39107, 1.24939],
         {"nodeWeight":0.94},
         ["t1r", -0.42000, 3.39107, 1.24939],
         ["t1", 0.00000, 3.39107, 1.24939],
         ["t1l", 0.42000, 3.39107, 1.24939],
         {"nodeWeight":3.055},
         ["t1ll", 0.82000, 3.39107, 1.24939],

         ["t2rr", -0.82000, 3.41107, 0.73939],
         ["t2r", -0.42000, 3.41107, 0.73939],
         ["t2", 0.00000, 3.41107, 0.73939],
         ["t2l", 0.42000, 3.41107, 0.73939],
         ["t2ll", 0.82000, 3.41107, 0.73939],
         //rigidifier
         {"selfCollision":false},
         {"collision":false},
         {"group":""},
         {"nodeWeight":0.94},
         ["t3", 0.00000, 3.12107, 1.00939],
    ],
    "beams": [
          ["id1:", "id2:"],
          //--TAILGATE--
          {"beamPrecompression":1, "beamType":"|NORMAL", "beamLongBound":1.0, "beamShortBound":1.0},
          {"beamSpring":1777390,"beamDamp":244.4},
          {"beamDeform":21525,"beamStrength":"FLT_MAX"},
          //tailgate main shape
          {"deformLimitExpansion":1.2},
          ["t1rr","t1r"],
          ["t1r","t1", {"deformGroup":"duallysignal_R_break", "deformationTriggerRatio":0.01}],
          ["t1","t1l", {"deformGroup":"duallysignal_R_break", "deformationTriggerRatio":0.01}],
          ["t1l","t1ll"],

          ["t2rr","t2r"],
          ["t2r","t2"],
          ["t2","t2l"],
          ["t2l","t2ll"],

          ["t1rr","t2rr"],
          ["t1r","t2r"],
          ["t1","t2", {"deformGroup":"duallysignal_R_break", "deformationTriggerRatio":0.01}],
          ["t1l","t2l"],
          ["t1ll","t2ll"],

          //surficial crossing
          {"deformLimitExpansion":""},
          {"beamDeform":8225,"beamStrength":"FLT_MAX"},
          ["t1rr","t2r"],
          ["t1r","t2rr"],
          ["t1r","t2"],
          ["t1","t2r", {"deformGroup":"duallysignal_R_break", "deformationTriggerRatio":0.01}],
          ["t1","t2l", {"deformGroup":"duallysignal_R_break", "deformationTriggerRatio":0.01}],
          ["t1l","t2"],
          ["t1l","t2ll"],
          ["t1ll","t2l"],

          //rigidifier
          {"beamSpring":1213390,"beamDamp":244.4},
          {"beamDeform":8050,"beamStrength":"FLT_MAX"},
          ["t1rr","t3"],
          ["t1r","t3"],
          ["t1","t3", {"deformGroup":"duallysignal_R_break", "deformationTriggerRatio":0.01}],
          ["t1l","t3"],
          ["t1ll","t3"],
          ["t2rr","t3"],
          ["t2r","t3"],
          ["t2","t3"],
          ["t2l","t3"],
          ["t2ll","t3"],

          //hinge
          {"disableTriangleBreaking":true},
          {"beamPrecompression":1, "beamType":"|NORMAL", "beamLongBound":1.0, "beamShortBound":1.0},
          {"beamSpring":1213390,"beamDamp":244.4},
          {"beamDeform":10500,"beamStrength":29904},
          {"breakGroup":"tailgatehinge_a"},
          ["t2rr","bd10rr"],
          ["t2rr","bd5rr"],
          ["t2l","bd10ll"],
          ["t2","bd10rr", {"deformGroup":"duallysignal_R_break", "deformationTriggerRatio":0.01}],

          ["t2rr","bd9rr"],
          ["t2l","bd9ll"],
          ["t2ll","bd9ll"],

          {"breakGroup":"tailgatehinge_b"},
          ["t2","bd10ll", {"deformGroup":"duallysignal_R_break", "deformationTriggerRatio":0.01}],
          ["t2r","bd10rr"],
          ["t2ll","bd10ll"],
          ["t2ll","bd5ll"],

          ["t2","bd9ll"],
          ["t2r","bd9rr"],
          ["t2","bd9rr"],
          {"breakGroup":""},

          //latch
          {"beamSpring":1777390,"beamDamp":244.4},
          {"beamDeform":9975,"beamStrength":18067},
          {"breakGroup":"tailgatelatch"},
          /*
          ["t1rr","b5rr"],
          ["t1ll","b5ll"],
          ["t1rr","b4rr"],
          ["t1ll","b4ll"],
          ["t2rr","b5rr"],
          ["t2ll","b5ll"],
          */
          {"breakGroup":""},

          //--TAILGATE SUPPORT BEAMS--
          {"beamType":"|SUPPORT","beamLongBound":4},
          {"beamSpring":470940,"beamDamp":244.4},
          {"beamDeform":3500,"beamStrength":199360},
          ["t2rr", "bd9rr"],
          ["t2r", "bd9r"],
          ["t2l", "bd9l"],
          ["t2ll", "bd9ll"],
          ["t2rr", "bd10rr"],
          ["t2rr", "bd14rr"],
          ["t2ll", "bd10ll"],
          ["t2ll", "bd14ll"],
          ["t2r", "bd10rr"],
          ["t2l", "bd10ll"],
          ["t1rr", "bd4rr"],
          ["t1ll", "bd4ll"],
          ["t1ll", "bd5ll", {"beamLongBound":25}],
          ["t1rr", "bd5rr", {"beamLongBound":25}],
          ["t1l", "bd5ll"],
          ["t1r", "bd5rr"],
          {"disableTriangleBreaking":false},
          {"beamPrecompression":1, "beamType":"|NORMAL", "beamLongBound":1.0, "beamShortBound":1.0},
          {"deformLimitExpansion":1.2},
    ],
    "triangles": [
            ["id1:","id2:","id3:"],
            //tailgate
            {"groundModel":"metal"},
            {"group":"pickup_tailgateouter"},
            {"dragCoef":7.5},
            ["t2rr","t1rr","t2r"],
            ["t1rr","t1r","t2r"],
            ["t2r","t1r","t2"],
            ["t1r","t1","t2"],
            ["t1l","t2l","t2"],
            ["t1l","t2","t1"],
            ["t1ll","t2ll","t2l"],
            ["t1ll","t2l","t1l"],
            {"dragCoef":0},
    ],
},
}
