let headlightsRawModels = ModelManager.loadPartedRawModel(
    Resources.manager(),
    Resources.id(headlights_model),
    null
);
let headlightsModels = function(rawModels) {
    result = {};
    for (it = rawModels.entrySet().iterator(); it.hasNext(); ) {
        entry = it.next();

        if (!['FARY', 'BUF'].includes('' + entry.getKey())) continue;

        entry.getValue().setAllRenderType('light');

        entry.getValue().applyUVMirror(false, true);
        result['' + entry.getKey()] = ModelManager.uploadVertArrays(
            entry.getValue()
        );
    }
    return result;
}(headlightsRawModels);

render_queue.push(function (ctx, state, train) {
    let matrices = new Matrices();

    if (!train.isReversed()) {
        ctx.drawCarModel(headlightsModels['FARY'], 0, null);
        matrices.rotateY(Math.PI);
        ctx.drawCarModel(headlightsModels['BUF'], train.trainCars() - 1, matrices);
    } else {
        ctx.drawCarModel(headlightsModels['BUF'], 0, null);
        matrices.rotateY(Math.PI);
        ctx.drawCarModel(headlightsModels['FARY'], train.trainCars() - 1, matrices);
    }
});
