<commit_before>function EveSpaceObject()
{
	this.name = '';
	this.mesh = null;
	this.spriteSets = [];
	this.boundingSphereCenter = vec3.create();
	this.boundingSphereRadius = 0;
	this.locators = [];
	this.turretSets = [];
	this.decals = [];
	this.spotlightSets = [];
	this.planeSets = [];
	this.curveSets = [];
    this.overlayEffects = [];

    this.shapeEllipsoidRadius = vec3.create();
    this.shapeEllipsoidCenter = vec3.create();

	this.transform = mat4.create();
	mat4.identity(this.transform);
	
	this.children = [];
	
	this._perObjectData = new Tw2PerObjectData();
	this._perObjectData.perObjectVSData = new Tw2RawData();
	this._perObjectData.perObjectVSData.Declare('WorldMat', 16);
	this._perObjectData.perObjectVSData.Declare('WorldMatLast', 16);
	this._perObjectData.perObjectVSData.Declare('Shipdata', 4);
	this._perObjectData.perObjectVSData.Declare('Clipdata1', 4);
	this._perObjectData.perObjectVSData.Declare('EllipsoidRadii', 4);
	this._perObjectData.perObjectVSData.Declare('EllipsoidCenter', 4);
	this._perObjectData.perObjectVSData.Declare('JointMat', 696);
	this._perObjectData.perObjectVSData.Create();
	
	this._perObjectData.perObjectPSData = new Tw2RawData();
	this._perObjectData.perObjectPSData.Declare('Shipdata', 4);
	this._perObjectData.perObjectPSData.Declare('Clipdata1', 4);
	this._perObjectData.perObjectPSData.Declare('Clipdata2', 4);
	this._perObjectData.perObjectPSData.Declare('ShLighting', 4 * 7);
	this._perObjectData.perObjectPSData.Declare('customMaskMatrix', 16);
	this._perObjectData.perObjectPSData.Create();

	this._perObjectData.perObjectVSData.Get('Shipdata')[1] = 1;
	this._perObjectData.perObjectPSData.Get('Shipdata')[1] = 1;
	this._perObjectData.perObjectVSData.Get('Shipdata')[3] = -10;
	this._perObjectData.perObjectPSData.Get('Shipdata')[3] = 1;

	this.animation = new Tw2AnimationController();

	this.lod = 3;
	this._tempVec = vec3.create();
}

EveSpaceObject.prototype.Initialize = function ()
{
    if (this.mesh)
    {
        this.animation.SetGeometryResource(this.mesh.geometryResource);
        for (var i = 0; i < this.decals.length; ++i)
        {
            this.decals[i].SetParentGeometry(this.mesh.geometryResource);
        }
    }
};

EveSpaceObject.prototype.ResetLod = function ()
{
    this.lod = 3;
}

EveSpaceObject.prototype.UpdateLod = function (frustum)
{
    var center = mat4.multiplyVec3(this.transform, this.boundingSphereCenter, this._tempVec);

    if (frustum.IsSphereVisible(center, this.boundingSphereRadius))
    {
        if (frustum.GetPixelSizeAccross(center, this.boundingSphereRadius) < 100)
        {
            this.lod = 1;
        }
        else
        {
            this.lod = 2;
        }
    }
    else
    {
        this.lod = 0;
    }
}

EveSpaceObject.prototype.UpdateViewDependentData = function ()
{
    for (var i = 0; i < this.children.length; ++i)
    {
        this.children[i].UpdateViewDependentData(this.transform);
    }
    mat4.transpose(this.transform, this._perObjectData.perObjectVSData.Get('WorldMat'));
    mat4.transpose(this.transform, this._perObjectData.perObjectVSData.Get('WorldMatLast'));
    var center = this._perObjectData.perObjectVSData.Get('EllipsoidCenter');
    var radii = this._perObjectData.perObjectVSData.Get('EllipsoidRadii');
    if (this.shapeEllipsoidRadius[0] > 0) {
        center[0] = this.shapeEllipsoidCenter[0];
        center[1] = this.shapeEllipsoidCenter[1];
        center[2] = this.shapeEllipsoidCenter[2];
        radii[0] = this.shapeEllipsoidRadius[0];
        radii[1] = this.shapeEllipsoidRadius[1];
        radii[2] = this.shapeEllipsoidRadius[2];
    }
    else if (this.mesh && this.mesh.geometryResource && this.mesh.geometryResource.IsGood()) {
        vec3.subtract(this.mesh.geometryResource.maxBounds, this.mesh.geometryResource.minBounds, center);
        vec3.scale(center, 0.5 * 1.732050807);
        vec3.add(this.mesh.geometryResource.maxBounds, this.mesh.geometryResource.minBounds, radii);
        vec3.scale(radii, 0.5);
    }
    if (this.animation.animations.length)
    {
        this._perObjectData.perObjectVSData.Set('JointMat', this.animation.GetBoneMatrixes(0));
    }
}

EveSpaceObject.prototype.GetBatches = function (mode, accumulator)
{
    if (this.mesh != null && this.lod > 0)
    {
        this.mesh.GetBatches(mode, accumulator, this._perObjectData);
    }

    var i;
    if (this.lod > 1)
    {
        for (i = 0; i < this.spriteSets.length; ++i)
        {
            this.spriteSets[i].GetBatches(mode, accumulator, this._perObjectData);
        }
        for (i = 0; i < this.spotlightSets.length; ++i)
        {
            this.spotlightSets[i].GetBatches(mode, accumulator, this._perObjectData);
        }
        for (i = 0; i < this.planeSets.length; ++i)
        {
            this.planeSets[i].GetBatches(mode, accumulator, this._perObjectData);
        }
        for (i = 0; i < this.decals.length; ++i)
        {
            this.decals[i].GetBatches(mode, accumulator, this._perObjectData);
        }
    }
    for (i = 0; i < this.children.length; ++i)
    {
        this.children[i].GetBatches(mode, accumulator, this._perObjectData);
    }
    if (this.mesh && this.mesh.geometryResource && this.mesh.geometryResource.IsGood())
    {
        for (i = 0; i < this.overlayEffects.length; ++i)
        {
            var effects = this.overlayEffects[i].GetEffects(mode);
            if (effects)
            {
                for (var j = 0; j < effects.length; ++j)
                {
                    var batch = new Tw2GeometryBatch();
                    batch.renderMode = mode;
                    batch.perObjectData = this._perObjectData;
                    batch.geometryRes = this.mesh.geometryResource;
                    batch.meshIx = this.mesh.meshIndex;
                    batch.start = 0;
                    batch.count = this.mesh.geometryResource.meshes[this.mesh.meshIndex].areas.length;
                    batch.effect = effects[j];
                    accumulator.Commit(batch);
                }
            }
        }
    }
};

EveSpaceObject.prototype.Update = function (dt)
{
    if (this.lod > 0)
    {
        var i;
        for (i = 0; i < this.spriteSets.length; ++i)
        {
            this.spriteSets[i].Update(dt);
        }
        for (i = 0; i < this.children.length; ++i)
        {
            this.children[i].Update(dt);
        }
        for (i = 0; i < this.curveSets.length; ++i)
        {
            this.curveSets[i].Update(dt);
        }
        for (i = 0; i < this.overlayEffects.length; ++i)
        {
            this.overlayEffects[i].Update(dt);
        }
        this.animation.Update(dt);
    }
};

EveSpaceObject.prototype.GetLocatorCount = function (prefix)
{
    var count = 0;
    for (var i = 0; i < this.locators.length; ++i)
    {
        if (this.locators[i].name.substr(0, prefix.length) == prefix)
        {
            ++count;
        }
    }
    return count;
};

EveSpaceObject.prototype.FindLocatorJointByName = function (name)
{
    var model = this.animation.FindModelForMesh(0);
    if (model != null)
    {
        for (var i = 0; i < model.bones.length; ++i)
        {
            if (model.bones[i].boneRes.name == name)
            {
                return model.bones[i].worldTransform;
            }
        }
    }
    return null;
};

EveSpaceObject.prototype.FindLocatorTransformByName = function (name)
{
    for (var i = 0; i < this.locators.length; ++i)
    {
        if (this.locators[i].name == name)
        {
            return this.locators[i].transform;
        }
    }
    return null;
};


EveSpaceObject.prototype.RenderDebugInfo = function (debugHelper)
{
    this.animation.RenderDebugInfo(debugHelper);
};

EveStation = EveSpaceObject;<commit_msg>Basic Documentation and Display Options for EveSpaceObject<commit_after>/**
 * EveSpaceObject
 * @parameter {String} name
 * @parameter {Number} lod
 * @parameter {Tw2Mesh} mesh
 * @parameter {Array.<EveLocator>} locators
 * @parameter {Array.<EveSpriteSet>} spriteSets
 * @parameter {Array.<EveTurretSet>} turretSets
 * @parameter {Array.<EveSpaceObjectDecal>} decals
 * @parameter {Array.<EveSpotlightSet>} spotlightSets
 * @parameter {Array.<EvePlaneSet>} planeSets
 * @parameter {Array.<Tw2CurveSet>} curveSets
 * @parameter {Array.<EveCurveLineSet>} lineSets
 * @parameter {Array.<EveMeshOverlayEffect>} overlayEffects
 * @parameter {Array.<{}>} children
 * @parameter {vec3} boundingSphereCenter
 * @parameter {Number} boundingSphereRadius
 * @parameter {vec3} shapeEllipsoidRadius
 * @parameter {vec3} shapeEllipsoidCenter
 * @parameter {mat4} transform
 * @parameter {Tw2AnimationController} animation
 * @parameter {boolean} display - Toggles rendering of the whole space object
 * @parameter {boolean} displayMesh - Toggles mesh rendering
 * @parameter {boolean} displayChildren - toggles rendering of children
 * @parameter {boolean} displaySprites - Toggles sprite set rendering
 * @parameter {boolean} displayDecals - Toggles decal rendering
 * @parameter {boolean} displaySpotlights - Toggles spotlight set rendering
 * @parameter {boolean} displayPlanes - toggles plane set rendering
 * @parameter {boolean} displayLines - toggles line set rendering
 * @parameter {boolean} displayOverlays - toggles overlay effect rendering
 * @parameter {vec3} _tempVec
 * @parameter {Tw2PerObjectData} _perObjectData
 * @constructor
 */
function EveSpaceObject()
{
    this.name = '';
    this.lod = 3;
    this.mesh = null;
    this.locators = [];

    this.spriteSets = [];
    this.turretSets = [];
    this.decals = [];
    this.spotlightSets = [];
    this.planeSets = [];
    this.curveSets = [];
    this.lineSets = [];
    this.overlayEffects = [];
    this.children = [];

    this.boundingSphereCenter = vec3.create();
    this.boundingSphereRadius = 0;
    this.shapeEllipsoidRadius = vec3.create();
    this.shapeEllipsoidCenter = vec3.create();

    this.transform = mat4.identity(mat4.create());
    this.animation = new Tw2AnimationController();

    this.display = true;
    this.displayMesh = true;
    this.displayChildren = true;
    this.displayPlanes = true;
    this.displaySpotlights = true;
    this.displayDecals = true;
    this.displaySprites = true;
    this.displayOverlays = true;
    this.displayLines = true;
    
    this._tempVec = vec3.create();

    this._perObjectData = new Tw2PerObjectData();
    this._perObjectData.perObjectVSData = new Tw2RawData();
    this._perObjectData.perObjectVSData.Declare('WorldMat', 16);
    this._perObjectData.perObjectVSData.Declare('WorldMatLast', 16);
    this._perObjectData.perObjectVSData.Declare('Shipdata', 4);
    this._perObjectData.perObjectVSData.Declare('Clipdata1', 4);
    this._perObjectData.perObjectVSData.Declare('EllipsoidRadii', 4);
    this._perObjectData.perObjectVSData.Declare('EllipsoidCenter', 4);
    this._perObjectData.perObjectVSData.Declare('JointMat', 696);
    this._perObjectData.perObjectVSData.Create();

    this._perObjectData.perObjectPSData = new Tw2RawData();
    this._perObjectData.perObjectPSData.Declare('Shipdata', 4);
    this._perObjectData.perObjectPSData.Declare('Clipdata1', 4);
    this._perObjectData.perObjectPSData.Declare('Clipdata2', 4);
    this._perObjectData.perObjectPSData.Declare('ShLighting', 4 * 7);
    this._perObjectData.perObjectPSData.Declare('customMaskMatrix', 16);
    this._perObjectData.perObjectPSData.Create();

    this._perObjectData.perObjectVSData.Get('Shipdata')[1] = 1;
    this._perObjectData.perObjectPSData.Get('Shipdata')[1] = 1;
    this._perObjectData.perObjectVSData.Get('Shipdata')[3] = -10;
    this._perObjectData.perObjectPSData.Get('Shipdata')[3] = 1;
}

/**
 * Initializes the EveSpaceObject
 */
EveSpaceObject.prototype.Initialize = function()
{
    if (this.mesh)
    {
        this.animation.SetGeometryResource(this.mesh.geometryResource);
        for (var i = 0; i < this.decals.length; ++i)
        {
            this.decals[i].SetParentGeometry(this.mesh.geometryResource);
        }
    }
};

/**
 * Resets the lod
 */
EveSpaceObject.prototype.ResetLod = function()
{
    this.lod = 3;
}

/**
 * Updates the lod
 * @param {Tw2Frustum} frustum
 */
EveSpaceObject.prototype.UpdateLod = function(frustum)
{
    var center = mat4.multiplyVec3(this.transform, this.boundingSphereCenter, this._tempVec);

    if (frustum.IsSphereVisible(center, this.boundingSphereRadius))
    {
        if (frustum.GetPixelSizeAccross(center, this.boundingSphereRadius) < 100)
        {
            this.lod = 1;
        }
        else
        {
            this.lod = 2;
        }
    }
    else
    {
        this.lod = 0;
    }
}

/**
 * A Per frame function that updates view dependent data
 */
EveSpaceObject.prototype.UpdateViewDependentData = function()
{
    for (var i = 0; i < this.children.length; ++i)
    {
        this.children[i].UpdateViewDependentData(this.transform);
    }

    mat4.transpose(this.transform, this._perObjectData.perObjectVSData.Get('WorldMat'));
    mat4.transpose(this.transform, this._perObjectData.perObjectVSData.Get('WorldMatLast'));
    var center = this._perObjectData.perObjectVSData.Get('EllipsoidCenter');
    var radii = this._perObjectData.perObjectVSData.Get('EllipsoidRadii');
    if (this.shapeEllipsoidRadius[0] > 0)
    {
        center[0] = this.shapeEllipsoidCenter[0];
        center[1] = this.shapeEllipsoidCenter[1];
        center[2] = this.shapeEllipsoidCenter[2];
        radii[0] = this.shapeEllipsoidRadius[0];
        radii[1] = this.shapeEllipsoidRadius[1];
        radii[2] = this.shapeEllipsoidRadius[2];
    }
    else if (this.mesh && this.mesh.geometryResource && this.mesh.geometryResource.IsGood())
    {
        vec3.subtract(this.mesh.geometryResource.maxBounds, this.mesh.geometryResource.minBounds, center);
        vec3.scale(center, 0.5 * 1.732050807);
        vec3.add(this.mesh.geometryResource.maxBounds, this.mesh.geometryResource.minBounds, radii);
        vec3.scale(radii, 0.5);
    }

    if (this.animation.animations.length)
    {
        this._perObjectData.perObjectVSData.Set('JointMat', this.animation.GetBoneMatrixes(0));
    }

    for (var s = 0; s < this.lineSets.length; ++s)
    {
        this.lineSets[s].UpdateViewDependentData(this.transform);
    }
}

/**
 * Gets line render batches
 * @param {RenderMode} mode
 * @param {Tw2BatchAccumulator} accumulator
 */
EveSpaceObject.prototype.GetLineBatches = function(mode, accumulator)
{
    for (var i = 0; i < this.lineSets.length; ++i)
    {
        this.lineSets[i].GetBatches(mode, accumulator);
    }
}

/**
 * Gets render batches
 * @param {RenderMode} mode
 * @param {Tw2BatchAccumulator} accumulator
 */
EveSpaceObject.prototype.GetBatches = function(mode, accumulator)
{
    if (this.display)
    {
        if (this.displayMesh && this.mesh != null && this.lod > 0)
        {
            this.mesh.GetBatches(mode, accumulator, this._perObjectData);
        }

        if (this.lod > 1)
        {
            var i;

            if (this.displaySprites)
            {
                for (i = 0; i < this.spriteSets.length; ++i)
                {
                    this.spriteSets[i].GetBatches(mode, accumulator, this._perObjectData);
                }
            }

            if (this.displaySpotlights)
            {
                for (i = 0; i < this.spotlightSets.length; ++i)
                {
                    this.spotlightSets[i].GetBatches(mode, accumulator, this._perObjectData);
                }
            }

            if (this.displayPlanes)
            {
                for (i = 0; i < this.planeSets.length; ++i)
                {
                    this.planeSets[i].GetBatches(mode, accumulator, this._perObjectData);
                }
            }

            if (this.displayDecals)
            {
                for (i = 0; i < this.decals.length; ++i)
                {
                    this.decals[i].GetBatches(mode, accumulator, this._perObjectData);
                }
            }

            if (this.displayLines)
            {
                this.GetLineBatches(mode, accumulator);
            }
        }

        if (this.displayChildren)
        {
            for (i = 0; i < this.children.length; ++i)
            {
                this.children[i].GetBatches(mode, accumulator, this._perObjectData);
            }
        }

        if (this.displayOverlays && this.mesh && this.mesh.geometryResource && this.mesh.geometryResource.IsGood())
        {
            for (i = 0; i < this.overlayEffects.length; ++i)
            {
                var effects = this.overlayEffects[i].GetEffects(mode);
                if (effects)
                {
                    for (var j = 0; j < effects.length; ++j)
                    {
                        var batch = new Tw2GeometryBatch();
                        batch.renderMode = mode;
                        batch.perObjectData = this._perObjectData;
                        batch.geometryRes = this.mesh.geometryResource;
                        batch.meshIx = this.mesh.meshIndex;
                        batch.start = 0;
                        batch.count = this.mesh.geometryResource.meshes[this.mesh.meshIndex].areas.length;
                        batch.effect = effects[j];
                        accumulator.Commit(batch);
                    }
                }
            }
        }
    }
};

/**
 * Per frame update
 * @param {Number} dt - delta time
 */
EveSpaceObject.prototype.Update = function(dt)
{
    if (this.lod > 0)
    {
        var i;
        for (i = 0; i < this.spriteSets.length; ++i)
        {
            this.spriteSets[i].Update(dt);
        }
        for (i = 0; i < this.children.length; ++i)
        {
            this.children[i].Update(dt);
        }
        for (i = 0; i < this.curveSets.length; ++i)
        {
            this.curveSets[i].Update(dt);
        }
        for (i = 0; i < this.overlayEffects.length; ++i)
        {
            this.overlayEffects[i].Update(dt);
        }
        this.animation.Update(dt);
    }
};

/**
 * Gets locator count for a specific locator group
 * @param {String} prefix
 * @returns {number}
 */
EveSpaceObject.prototype.GetLocatorCount = function(prefix)
{
    var count = 0;
    for (var i = 0; i < this.locators.length; ++i)
    {
        if (this.locators[i].name.substr(0, prefix.length) == prefix)
        {
            ++count;
        }
    }
    return count;
};

/**
 * Finds a locator joint by it's name
 * @param {String} name
 * @returns {null|mat4}
 */
EveSpaceObject.prototype.FindLocatorJointByName = function(name)
{
    var model = this.animation.FindModelForMesh(0);
    if (model != null)
    {
        for (var i = 0; i < model.bones.length; ++i)
        {
            if (model.bones[i].boneRes.name == name)
            {
                return model.bones[i].worldTransform;
            }
        }
    }
    return null;
};

/**
 * Finds a locator transform by it's name
 * @param {String} name
 * @returns {null|mat4}
 */
EveSpaceObject.prototype.FindLocatorTransformByName = function(name)
{
    for (var i = 0; i < this.locators.length; ++i)
    {
        if (this.locators[i].name == name)
        {
            return this.locators[i].transform;
        }
    }
    return null;
};

/**
 * RenderDebugInfo
 * @param debugHelper
 */
EveSpaceObject.prototype.RenderDebugInfo = function(debugHelper)
{
    this.animation.RenderDebugInfo(debugHelper);
};

/**
 * EveStation inherits from EveSpaceObject
 * @type {EveSpaceObject}
 */
EveStation = EveSpaceObject;
{'fraction_non_alphanumeric': 0.13027916964924838, 'fraction_numerical': 0.012066673483996319, 'mean_word_length': 2.48272792022792, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 21, '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': '6242631', 'n_tokens_mistral': 6472, 'n_tokens_neox': 6190, 'n_words': 1032}