<commit_before>define(['goo/math/Vector3', 'goo/math/Matrix3x3', 'goo/math/Matrix4x4', 'goo/util/Handy'],
	/** @lends Transform */
	function (Vector3, Matrix3x3, Matrix4x4, Handy) {
	"use strict";

	/**
	 * @class Transform models a transformation in 3d space as: Y = M*X+T, with M being a Matrix3 and T is a Vector3. Generally M will be a rotation
	 *        only matrix in which case it is represented by the matrix and scale fields as R*S, where S is a positive scale vector. For non-uniform
	 *        scales and reflections, use setMatrix, which will consider M as being a general 3x3 matrix and disregard anything set in scale.
	 */
	function Transform() {
		this.matrix = new Matrix4x4();

		this.translation = new Vector3();
		this.rotation = new Matrix3x3();
		this.scale = new Vector3(1, 1, 1);

		this.tmpVec = new Vector3();
		this.tmpMat1 = new Matrix3x3();
		this.tmpMat2 = new Matrix3x3();
	}

	// TODO: sort this crap out!
	Transform.prototype.multiply = function (a, b) {
		Matrix4x4.combine(a.matrix, b.matrix, this.matrix);

		this.tmpMat1.data.set(a.rotation.data);
		this.tmpMat1.multiplyDiagonalPost(a.scale, this.tmpMat1);
		this.tmpMat2.data.set(b.rotation.data);
		this.tmpMat2.multiplyDiagonalPost(b.scale, this.tmpMat2);
		Matrix3x3.combine(this.tmpMat1, this.tmpMat2, this.rotation);
		this.translation.setv(b.translation);
		this.tmpMat1.applyPost(this.translation).addv(a.translation);
		this.scale.setv(a.scale).mulv(b.scale);
	};

	Transform.prototype.setIdentity = function () {
		this.matrix.setIdentity();

		this.translation.setv(Vector3.ZERO);
		this.rotation.setIdentity();
		this.scale.setv(Vector3.ONE);
	};

	Transform.prototype.applyForward = function (point, store) {
		store.setv(point);

		// store.set(store.x * this.scale.x, store.y * this.scale.y, store.z * this.scale.z);
		// this.rotation.applyPost(store);
		// store.add(this.translation);

		this.matrix.applyPostPoint(store);

		return store;
	};

	Transform.prototype.applyForwardVector = function (vector, store) {
		store.copy(vector);

		store.set(store.x * this.scale.x, store.y * this.scale.y, store.z * this.scale.z);
		this.rotation.applyPost(store);

		return store;
	};

	Transform.prototype.update = function () {
		var rd = this.matrix;
		var d = this.rotation;

		rd.e00 = this.scale.x * d.e00;
		rd.e01 = this.scale.y * d.e01;
		rd.e02 = this.scale.z * d.e02;
		rd.e10 = this.scale.x * d.e10;
		rd.e11 = this.scale.y * d.e11;
		rd.e12 = this.scale.z * d.e12;
		rd.e20 = this.scale.x * d.e20;
		rd.e21 = this.scale.y * d.e21;
		rd.e22 = this.scale.z * d.e22;

		rd.e30 = 0.0;
		rd.e31 = 0.0;
		rd.e32 = 0.0;

		rd.e03 = this.translation.x;
		rd.e13 = this.translation.y;
		rd.e23 = this.translation.z;
		rd.e33 = 1.0;
	};

	Transform.prototype.copy = function (transform) {
		this.matrix.copy(transform.matrix);

		this.translation.copy(transform.translation);
		this.rotation.copy(transform.rotation);
		this.scale.copy(transform.scale);
	};

	/**
	 * Set this transform's rotation to rotation around X, Y and Z axis.
	 * The rotation is applied in XYZ order.
	 */
	Transform.prototype.setRotationXYZ = function (x, y, z) {
		this.rotation.fromAngles(x, y, z);
	};

	/**
	 * @description Sets the transform to look in a specific direction.
	 * @param {Vector3} position Target position.
	 * @param {Vector3} up Up vector.
	 * @returns {Matrix3x3} Self for chaining.
	 */
	Transform.prototype.lookAt = function (position, up) {
		this.tmpVec.copy(this.translation).sub(position).normalize();<commit_msg>Ok, last optimization for tonight<commit_after>define(['goo/math/Vector3', 'goo/math/Matrix3x3', 'goo/math/Matrix4x4', 'goo/util/Handy'],
	/** @lends Transform */
	function (Vector3, Matrix3x3, Matrix4x4, Handy) {
	"use strict";

	/**
	 * @class Transform models a transformation in 3d space as: Y = M*X+T, with M being a Matrix3 and T is a Vector3. Generally M will be a rotation
	 *        only matrix in which case it is represented by the matrix and scale fields as R*S, where S is a positive scale vector. For non-uniform
	 *        scales and reflections, use setMatrix, which will consider M as being a general 3x3 matrix and disregard anything set in scale.
	 */
	function Transform() {
		this.matrix = new Matrix4x4();

		this.translation = new Vector3();
		this.rotation = new Matrix3x3();
		this.scale = new Vector3(1, 1, 1);

		this.tmpVec = new Vector3();
		this.tmpMat1 = new Matrix3x3();
		this.tmpMat2 = new Matrix3x3();
	}

	// TODO: sort this crap out!
	Transform.prototype.multiply = function (a, b) {
		Matrix4x4.combine(a.matrix, b.matrix, this.matrix);

		this.tmpMat1.data.set(a.rotation.data);
		this.tmpMat1.multiplyDiagonalPost(a.scale, this.tmpMat1);
		this.tmpMat2.data.set(b.rotation.data);
		this.tmpMat2.multiplyDiagonalPost(b.scale, this.tmpMat2);
		Matrix3x3.combine(this.tmpMat1, this.tmpMat2, this.rotation);
		this.translation.setv(b.translation);
		this.tmpMat1.applyPost(this.translation).addv(a.translation);
		this.scale.setv(a.scale).mulv(b.scale);
	};

	Transform.prototype.setIdentity = function () {
		this.matrix.setIdentity();

		this.translation.setv(Vector3.ZERO);
		this.rotation.setIdentity();
		this.scale.setv(Vector3.ONE);
	};

	Transform.prototype.applyForward = function (point, store) {
		store.setv(point);

		// store.set(store.x * this.scale.x, store.y * this.scale.y, store.z * this.scale.z);
		// this.rotation.applyPost(store);
		// store.add(this.translation);

		this.matrix.applyPostPoint(store);

		return store;
	};

	Transform.prototype.applyForwardVector = function (vector, store) {
		store.copy(vector);

		store.set(store.x * this.scale.x, store.y * this.scale.y, store.z * this.scale.z);
		this.rotation.applyPost(store);

		return store;
	};

	Transform.prototype.update = function () {
		var target = this.matrix.data;
		var rotation = this.rotation.data;
		var scale = this.scale.data;
		var translation = this.translation.data;

		target[0] = scale[0] * rotation[0];
		target[1] = scale[0] * rotation[1];
		target[2] = scale[0] * rotation[2];
		target[3] = 0.0;
		target[4] = scale[1] * rotation[3];
		target[5] = scale[1] * rotation[4];
		target[6] = scale[1] * rotation[5];
		target[7] = 0.0;
		target[8] = scale[2] * rotation[6];
		target[9] = scale[2] * rotation[7];
		target[10] = scale[2] * rotation[8];
		target[11] = 0.0;
		target[12] = translation[0];
		target[13] = translation[1];
		target[14] = translation[2];
		target[15] = 1.0;
	};

	Transform.prototype.copy = function (transform) {
		this.matrix.copy(transform.matrix);

		this.translation.copy(transform.translation);
		this.rotation.copy(transform.rotation);
		this.scale.copy(transform.scale);
	};

	/**
	 * Set this transform's rotation to rotation around X, Y and Z axis.
	 * The rotation is applied in XYZ order.
	 */
	Transform.prototype.setRotationXYZ = function (x, y, z) {
		this.rotation.fromAngles(x, y, z);
	};

	/**
	 * @description Sets the transform to look in a specific direction.
	 * @param {Vector3} position Target position.
	 * @param {Vector3} up Up vector.
	 * @returns {Matrix3x3} Self for chaining.
	 */
	Transform.prototype.lookAt = function (position, up) {
		this.tmpVec.copy(this.translation).sub(position).normalize();
{'fraction_non_alphanumeric': 0.1500069319284625, 'fraction_numerical': 0.028975460973242755, 'mean_word_length': 3.7398160315374507, 'pattern_counts': {'":': 0, '<': 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': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2234825', 'n_tokens_mistral': 2772, 'n_tokens_neox': 2531, 'n_words': 577}