<commit_before>var Frustum = require("../tools/frustum.js").Frustum;

var PointLightData = {
    "intensity": {type: Xflow.DATA_TYPE.FLOAT3, default: [1, 1, 1]},
    "attenuation": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, 1]},
    "position": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, 0]},
    "shadowBias": {type: Xflow.DATA_TYPE.FLOAT, default: [0.0001]},
    "castShadow": {type: Xflow.DATA_TYPE.BOOL, default: [false]},
    "on": {type: Xflow.DATA_TYPE.BOOL, default: [true]}
};

var SpotLightData = {
    "intensity": {type: Xflow.DATA_TYPE.FLOAT3, default: [1, 1, 1]},
    "attenuation": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, 1]},
    "position": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, 0]},
    "direction": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, -1]},
    "falloffAngle": {type: Xflow.DATA_TYPE.FLOAT, default: [Math.PI / 4]},
    "softness": {type: Xflow.DATA_TYPE.FLOAT, default: [0.0]},
    "shadowBias": {type: Xflow.DATA_TYPE.FLOAT, default: [0.0001]},
    "castShadow": {type: Xflow.DATA_TYPE.BOOL, default: [false]},
    "on": {type: Xflow.DATA_TYPE.BOOL, default: [true]}
};

var DirectionalLightData = {
    "intensity": {type: Xflow.DATA_TYPE.FLOAT3, default: [1, 1, 1]},
    "direction": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, -1]},
    "shadowBias": {type: Xflow.DATA_TYPE.FLOAT, default: [0.0001]},
    "castShadow": {type: Xflow.DATA_TYPE.BOOL, default: [false]},
    "on": {type: Xflow.DATA_TYPE.BOOL, default: [true]}
};


function createXflowData(config) {
    var data = XML3D.data.xflowGraph.createDataNode();
    for (var name in config) {
        var entry = config[name];
        createXflowValue(data, name, entry.type, entry.default);
    }
    return data;
}

function createXflowValue(dataNode, name, type, value) {
    var buffer = new Xflow.BufferEntry(type, new Xflow.TYPED_ARRAY_MAP[type](value));
    var inputNode = XML3D.data.xflowGraph.createInputNode();
    inputNode.data = buffer;
    inputNode.name = name;
    dataNode.appendChild(inputNode);
}

/**
 * Base class for light models
 * @param {string} id Unique id that identifies the light model
 * @param {RenderLight} light
 * @param {Xflow.DataNode} dataNode
 * @param {Object} config Configuration that contains the light model's parameters and default values
 * @constructor
 */
var LightModel = function (id, light, dataNode, config) {
    this.id = id;
    this.light = light;
    this.dataNode = dataNode;
    this.configuration = config;
    this.parameters = Object.keys(config);
    /**
     * If the light has not data, just use the default parameters
     */<commit_msg>Adapt Xflow node creation (required from rebase)<commit_after>var Frustum = require("../tools/frustum.js").Frustum;

var PointLightData = {
    "intensity": {type: Xflow.DATA_TYPE.FLOAT3, default: [1, 1, 1]},
    "attenuation": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, 1]},
    "position": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, 0]},
    "shadowBias": {type: Xflow.DATA_TYPE.FLOAT, default: [0.0001]},
    "castShadow": {type: Xflow.DATA_TYPE.BOOL, default: [false]},
    "on": {type: Xflow.DATA_TYPE.BOOL, default: [true]}
};

var SpotLightData = {
    "intensity": {type: Xflow.DATA_TYPE.FLOAT3, default: [1, 1, 1]},
    "attenuation": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, 1]},
    "position": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, 0]},
    "direction": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, -1]},
    "falloffAngle": {type: Xflow.DATA_TYPE.FLOAT, default: [Math.PI / 4]},
    "softness": {type: Xflow.DATA_TYPE.FLOAT, default: [0.0]},
    "shadowBias": {type: Xflow.DATA_TYPE.FLOAT, default: [0.0001]},
    "castShadow": {type: Xflow.DATA_TYPE.BOOL, default: [false]},
    "on": {type: Xflow.DATA_TYPE.BOOL, default: [true]}
};

var DirectionalLightData = {
    "intensity": {type: Xflow.DATA_TYPE.FLOAT3, default: [1, 1, 1]},
    "direction": {type: Xflow.DATA_TYPE.FLOAT3, default: [0, 0, -1]},
    "shadowBias": {type: Xflow.DATA_TYPE.FLOAT, default: [0.0001]},
    "castShadow": {type: Xflow.DATA_TYPE.BOOL, default: [false]},
    "on": {type: Xflow.DATA_TYPE.BOOL, default: [true]}
};


function createXflowData(config) {
    var data = new Xflow.DataNode();
    for (var name in config) {
        var entry = config[name];
        createXflowValue(data, name, entry.type, entry.default);
    }
    return data;
}

function createXflowValue(dataNode, name, type, value) {
    var buffer = new Xflow.BufferEntry(type, new Xflow.TYPED_ARRAY_MAP[type](value));
    var inputNode = new Xflow.InputNode();
    inputNode.data = buffer;
    inputNode.name = name;
    dataNode.appendChild(inputNode);
}

/**
 * Base class for light models
 * @param {string} id Unique id that identifies the light model
 * @param {RenderLight} light
 * @param {Xflow.DataNode} dataNode
 * @param {Object} config Configuration that contains the light model's parameters and default values
 * @constructor
 */
var LightModel = function (id, light, dataNode, config) {
    this.id = id;
    this.light = light;
    this.dataNode = dataNode;
    this.configuration = config;
    this.parameters = Object.keys(config);
    /**
     * If the light has not data, just use the default parameters
     */
{'fraction_non_alphanumeric': 0.16402822811367537, 'fraction_numerical': 0.02098035475872592, 'mean_word_length': 3.951841359773371, 'pattern_counts': {'":': 40, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2641142', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1838, 'n_words': 466}