<commit_before>/**
 * CG Tecnico Invaders
 * CG45179 16'17
 *
 * @author: <NAME> ( ist181045 )
 * @author: <NAME> ( ist181586 )
 * @author: <NAME> ( ist181700 )
 */

import { Vector3 }  from '../lib/threejs/math/Vector3';

import Collidable from '../Collidable';

class Entity extends Collidable {

	constructor ( x, y, z ) {

		super( x, y, z );

		this.type = 'Entity';

		this.MAX_VELOCITY = 1000;

		this.updateBoundries = true;

		this.moving       = false;
		this.direction    = new Vector3();
		this.velocity     = new Vector3();
		this.acceleration = 300;
		this.friction     = 350;

	}

	setDirection ( x, y, z ) {

		this.direction.set( x, y, z ).normalize();

	}

	update ( dt ) {

		super.update();

		let updatePos = false;

		let v   = this.velocity.length();
		let dvf = this.friction * dt;

		let dot = this.direction.dot( this.velocity );

		if ( this.moving ) {

			updatePos = true;

			if ( v !== this.MAX_VELOCITY ) {

				let dv = this.acceleration * dt;

				if ( v + dv > this.MAX_VELOCITY ) {

					this.velocity.setLength( this.MAX_VELOCITY );

				} else if ( v !== dot ) {

					this.velocity.addScaledVector( this.direction, dvf );

				}

				this.velocity.addScaledVector( this.direction, dv );

			}

		} else if ( v > dvf ) {

			updatePos = true;

			if ( v !== dot ) {

				this.direction.copy( this.velocity ).normalize();

			}

			this.velocity.addScaledVector( this.direction, -dvf );

		} else {

			this.velocity.setLength( 0 );

		}

		if ( updatePos ) {

			let ds = this.velocity.clone();

			this.position.add( ds.multiplyScalar( dt ) );
			this.boundingBox.translate( ds );
			this.boundingSphere.translate( ds );

		}<commit_msg>Switch setLength for setScalar<commit_after>/**
 * CG Tecnico Invaders
 * CG45179 16'17
 *
 * @author: <NAME> ( ist181045 )
 * @author: <NAME> ( ist181586 )
 * @author: <NAME> ( ist181700 )
 */

import { Vector3 }  from '../lib/threejs/math/Vector3';

import Collidable from '../Collidable';

class Entity extends Collidable {

	constructor ( x, y, z ) {

		super( x, y, z );

		this.type = 'Entity';

		this.MAX_VELOCITY = 1000;

		this.updateBoundries = true;

		this.moving       = false;
		this.direction    = new Vector3();
		this.velocity     = new Vector3();
		this.acceleration = 300;
		this.friction     = 350;

	}

	setDirection ( x, y, z ) {

		this.direction.set( x, y, z ).normalize();

	}

	update ( dt ) {

		super.update();

		let updatePos = false;

		let v   = this.velocity.length();
		let dvf = this.friction * dt;

		let dot = this.direction.dot( this.velocity );

		if ( this.moving ) {

			updatePos = true;

			if ( v !== this.MAX_VELOCITY ) {

				let dv = this.acceleration * dt;

				if ( v + dv > this.MAX_VELOCITY ) {

					this.velocity.setLength( this.MAX_VELOCITY );

				} else if ( v !== dot ) {

					this.velocity.addScaledVector( this.direction, dvf );

				}

				this.velocity.addScaledVector( this.direction, dv );

			}

		} else if ( v > dvf ) {

			updatePos = true;

			if ( v !== dot ) {

				this.direction.copy( this.velocity ).normalize();

			}

			this.velocity.addScaledVector( this.direction, -dvf );

		} else {

			this.velocity.setScalar( 0 );

		}

		if ( updatePos ) {

			let ds = this.velocity.clone();

			this.position.add( ds.multiplyScalar( dt ) );
			this.boundingBox.translate( ds );
			this.boundingSphere.translate( ds );

		}
{'fraction_non_alphanumeric': 0.1501929355891956, 'fraction_numerical': 0.024933214603739984, 'mean_word_length': 2.5399159663865545, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '4403244', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1182, 'n_words': 275}