<commit_before>
import { AbstractMesh } from "./abstractMesh";
import { Mesh } from "./mesh";
import { Material } from "../Materials/material";
import { VertexBuffer } from "./buffer";
import { VertexData } from "./mesh.vertexData";
import { Vector3 } from "../Maths/math";
import { Scene } from "../scene";

export class TrailMesh extends Mesh {
	private _generator: AbstractMesh;
	private _diameter: number;
	private _length: number;
	private _sectionPolygonPointsCount: number = 4;
	private _sectionVectors: Array<Vector3>;
	private _sectionNormalVectors: Array<Vector3>;


	constructor(name: string, generator: AbstractMesh, scene: Scene, diameter: number = 1, length: number = 60, material: Material) {
		super(name, scene);
		scene = this.getScene();

		this.layerMask = 2;
		this._generator = generator;
		this._diameter = diameter;
		this._length = length;
		this._sectionVectors = [];
		this._sectionNormalVectors = [];
		for (let i: number = 0; i < this._sectionPolygonPointsCount; i++) {
			this._sectionVectors[i] = Vector3.Zero();
			this._sectionNormalVectors[i] = Vector3.Zero();
		}
		if (material instanceof Material) {
			this.material = material;
		} else {
			this.material = scene.defaultMaterial;
		}
		this._createMesh();
	}

	private _createMesh(): void {
		let data: VertexData = new VertexData();
		let positions: Array<number> = [];
		let normals: Array<number> = [];
		let indices: Array<number> = [];

		let alpha: number = 2 * Math.PI / this._sectionPolygonPointsCount;
		for (let i: number = 0; i < this._sectionPolygonPointsCount; i++) {
			positions.push(
				Math.cos(i * alpha) * this._diameter,
				Math.sin(i * alpha) * this._diameter,
				-this._length
			);
			normals.push(
				Math.cos(i * alpha),
				Math.sin(i * alpha),
				0
			);
		}
		for (let i: number = 1; i <= this._length; i++) {
			for (let j: number = 0; j < this._sectionPolygonPointsCount; j++) {
				positions.push(
					Math.cos(j * alpha) * this._diameter,
					Math.sin(j * alpha) * this._diameter,
					-this._length + i
				);
				normals.push(
					Math.cos(j * alpha),
					Math.sin(j * alpha),
					0
				);
			}
			let l: number = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
			for (let j: number = 0; j < this._sectionPolygonPointsCount - 1; j++) {
				indices.push(
					l + j,
					l + j + this._sectionPolygonPointsCount,
					l + j + this._sectionPolygonPointsCount + 1,
				);
				indices.push(
					l + j,
					l + j + this._sectionPolygonPointsCount + 1,
					l + j + 1
				);
			}
			indices.push(
				l + this._sectionPolygonPointsCount - 1,
				l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount,
				l + this._sectionPolygonPointsCount,
			);
			indices.push(
				l + this._sectionPolygonPointsCount - 1,
				l + this._sectionPolygonPointsCount,
				l
			);
		}

		data.positions = positions;
		data.normals = normals;
		data.indices = indices;
		data.applyToMesh(this, true);
	}

	public update = () => {
		let positions = this.getVerticesData(VertexBuffer.PositionKind);
		let normals = this.getVerticesData(VertexBuffer.NormalKind);
		if (positions && normals) {
			for (let i: number = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
				positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;<commit_msg>Added constructor params comments<commit_after>
import { AbstractMesh } from "./abstractMesh";
import { Mesh } from "./mesh";
import { Material } from "../Materials/material";
import { VertexBuffer } from "./buffer";
import { VertexData } from "./mesh.vertexData";
import { Vector3 } from "../Maths/math";
import { Scene } from "../scene";

/**
 * Class used to create a trail following a mesh
 */
export class TrailMesh extends Mesh {
	private _generator: AbstractMesh;
	private _diameter: number;
	private _length: number;
	private _sectionPolygonPointsCount: number = 4;
	private _sectionVectors: Array<Vector3>;
	private _sectionNormalVectors: Array<Vector3>;

    /**
     * @constructor
     * @param name The value used by scene.getMeshByName() to do a lookup.
     * @param generator The mesh to generate a trail.
     * @param scene The scene to add this mesh to.
     * @param diameter Diameter of trailing mesh. Default is 1.
     * @param length Length of trailing mesh. Default is 60.
     * @param material Material to apply to trailing mesh. Defaults to scene default.
     */
	constructor(name: string, generator: AbstractMesh, scene: Scene, diameter: number = 1, length: number = 60, material: Material) {
		super(name, scene);
		scene = this.getScene();

		this.layerMask = 2;
		this._generator = generator;
		this._diameter = diameter;
		this._length = length;
		this._sectionVectors = [];
		this._sectionNormalVectors = [];
		for (let i: number = 0; i < this._sectionPolygonPointsCount; i++) {
			this._sectionVectors[i] = Vector3.Zero();
			this._sectionNormalVectors[i] = Vector3.Zero();
		}
		if (material instanceof Material) {
			this.material = material;
		} else {
			this.material = scene.defaultMaterial;
		}
		this._createMesh();
	}

	private _createMesh(): void {
		let data: VertexData = new VertexData();
		let positions: Array<number> = [];
		let normals: Array<number> = [];
		let indices: Array<number> = [];

		let alpha: number = 2 * Math.PI / this._sectionPolygonPointsCount;
		for (let i: number = 0; i < this._sectionPolygonPointsCount; i++) {
			positions.push(
				Math.cos(i * alpha) * this._diameter,
				Math.sin(i * alpha) * this._diameter,
				-this._length
			);
			normals.push(
				Math.cos(i * alpha),
				Math.sin(i * alpha),
				0
			);
		}
		for (let i: number = 1; i <= this._length; i++) {
			for (let j: number = 0; j < this._sectionPolygonPointsCount; j++) {
				positions.push(
					Math.cos(j * alpha) * this._diameter,
					Math.sin(j * alpha) * this._diameter,
					-this._length + i
				);
				normals.push(
					Math.cos(j * alpha),
					Math.sin(j * alpha),
					0
				);
			}
			let l: number = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
			for (let j: number = 0; j < this._sectionPolygonPointsCount - 1; j++) {
				indices.push(
					l + j,
					l + j + this._sectionPolygonPointsCount,
					l + j + this._sectionPolygonPointsCount + 1,
				);
				indices.push(
					l + j,
					l + j + this._sectionPolygonPointsCount + 1,
					l + j + 1
				);
			}
			indices.push(
				l + this._sectionPolygonPointsCount - 1,
				l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount,
				l + this._sectionPolygonPointsCount,
			);
			indices.push(
				l + this._sectionPolygonPointsCount - 1,
				l + this._sectionPolygonPointsCount,
				l
			);
		}

		data.positions = positions;
		data.normals = normals;
		data.indices = indices;
		data.applyToMesh(this, true);
	}

    /**
     * Update trailing mesh geometry.
     */
	public update() {
		let positions = this.getVerticesData(VertexBuffer.PositionKind);
		let normals = this.getVerticesData(VertexBuffer.NormalKind);
		if (positions && normals) {
			for (let i: number = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
				positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
{'fraction_non_alphanumeric': 0.13143014756585297, 'fraction_numerical': 0.008412632740311681, 'mean_word_length': 3.206496519721578, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 14, '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': '4518324', 'n_tokens_mistral': 2760, 'n_tokens_neox': 2315, 'n_words': 608}