<commit_before>define([
	'goo/statemachine/actions/Action',
	'goo/math/Vector3'
],
/** @lends */
function(
	Action,
	Vector3
) {
	"use strict";

	function TweenMoveAction(/*id, settings*/) {
		Action.apply(this, arguments);
	}

	TweenMoveAction.prototype = Object.create(Action.prototype);
	TweenMoveAction.prototype.constructor = TweenMoveAction;

	TweenMoveAction.external = {
		name: 'Tween Move',
		description: 'Smoothly transitions between 2 locations',
		canTransition: true,
		parameters: [{
			name: 'Translation',
			key: 'to',
			type: 'position',
			description: 'Move',
			'default': [0, 0, 0]
		}, {
			name: 'Relative',
			key: 'relative',
			type: 'boolean',
			description: 'If true add, otherwise set',
			'default': true
		}, {
			name: 'Time',
			key: 'time',
			type: 'number',
			description: 'Time it takes for this movement to complete',
			'default': 1000
		}, {
			name: 'Easing 1',
			key: 'easing1',
			type: 'dropdown',
			description: 'Easing 1',
			'default': 'Linear',
			options: ['Linear', 'Quadratic', 'Exponential', 'Circular', 'Elastic', 'Back', 'Bounce']
		}, {
			name: 'Easing 2',
			key: 'easing2',
			type: 'dropdown',
			description: 'Easing 2',
			'default': 'In',
			options: ['In', 'Out', 'InOut']
		}],
		transitions: [{
			key: 'complete',
			name: 'On Completion',
			description: 'Event fired when the movement completes'
		}]
	};

	TweenMoveAction.prototype.configure = function(settings) {
		this.to = settings.to;
		this.relative = settings.relative;
		this.time = settings.time;
		if (settings.easing1 === 'Linear') {
			this.easing = window.TWEEN.Easing.Linear.None;
		} else {
			this.easing = window.TWEEN.Easing[settings.easing1][settings.easing2];
		}
		this.eventToEmit = { channel: settings.transitions.complete };
	};

	TweenMoveAction.prototype._setup = function() {
		this.tween = new window.TWEEN.Tween();
	};

	TweenMoveAction.prototype._run = function(fsm) {
		var entity = fsm.getOwnerEntity();
		var transformComponent = entity.transformComponent;
		var translation = transformComponent.transform.translation;
		var initialTranslation = new Vector3().copy(translation);

		var fakeFrom = { x: initialTranslation.x, y: initialTranslation.y, z: initialTranslation.z };
		var fakeTo;

		if (this.relative) {
			var to = Vector3.add(initialTranslation, this.to);
			fakeTo = { x: to.x, y: to.y, z: to.z };

			this.tween.from(fakeFrom).to(fakeTo, +this.time).easing(this.easing).onUpdate(function() {
				translation.setd(this.x, this.y, this.z);
				transformComponent.setUpdated();
			}).onComplete(function() {
				fsm.send(this.eventToEmit.channel);
			}.bind(this)).start();
		} else {
			fakeTo = { x: this.to[0], y: this.to[1], z: this.to[2] };

			this.tween.from(fakeFrom).to(fakeTo, +this.time).easing(this.easing).onUpdate(function() {
				translation.setd(this.x, this.y, this.z);
				transformComponent.setUpdated();
			}).onComplete(function() {
				fsm.send(this.eventToEmit.channel);
			}.bind(this)).start();
		}
	};

	return TweenMoveAction;
});<commit_msg>#451 MoveTween actions are not composable<commit_after>define([
	'goo/statemachine/actions/Action',
	'goo/math/Vector3'
],
/** @lends */
function(
	Action,
	Vector3
) {
	"use strict";

	function TweenMoveAction(/*id, settings*/) {
		Action.apply(this, arguments);
	}

	TweenMoveAction.prototype = Object.create(Action.prototype);
	TweenMoveAction.prototype.constructor = TweenMoveAction;

	TweenMoveAction.external = {
		name: 'Tween Move',
		description: 'Smoothly transitions between 2 locations',
		canTransition: true,
		parameters: [{
			name: 'Translation',
			key: 'to',
			type: 'position',
			description: 'Move',
			'default': [0, 0, 0]
		}, {
			name: 'Relative',
			key: 'relative',
			type: 'boolean',
			description: 'If true add, otherwise set',
			'default': true
		}, {
			name: 'Time',
			key: 'time',
			type: 'number',
			description: 'Time it takes for this movement to complete',
			'default': 1000
		}, {
			name: 'Easing 1',
			key: 'easing1',
			type: 'dropdown',
			description: 'Easing 1',
			'default': 'Linear',
			options: ['Linear', 'Quadratic', 'Exponential', 'Circular', 'Elastic', 'Back', 'Bounce']
		}, {
			name: 'Easing 2',
			key: 'easing2',
			type: 'dropdown',
			description: 'Easing 2',
			'default': 'In',
			options: ['In', 'Out', 'InOut']
		}],
		transitions: [{
			key: 'complete',
			name: 'On Completion',
			description: 'Event fired when the movement completes'
		}]
	};

	TweenMoveAction.prototype.configure = function(settings) {
		this.to = settings.to;
		this.relative = settings.relative;
		this.time = settings.time;
		if (settings.easing1 === 'Linear') {
			this.easing = window.TWEEN.Easing.Linear.None;
		} else {
			this.easing = window.TWEEN.Easing[settings.easing1][settings.easing2];
		}
		this.eventToEmit = { channel: settings.transitions.complete };
	};

	TweenMoveAction.prototype._setup = function() {
		this.tween = new window.TWEEN.Tween();
	};

	TweenMoveAction.prototype._run = function(fsm) {
		var entity = fsm.getOwnerEntity();
		var transformComponent = entity.transformComponent;
		var translation = transformComponent.transform.translation;
		var initialTranslation = new Vector3().copy(translation);

		var fakeFrom = { x: initialTranslation.x, y: initialTranslation.y, z: initialTranslation.z };
		var fakeTo;

		var old = { x: fakeFrom.x, y: fakeFrom.y, z: fakeFrom.z };

		if (this.relative) {
			var to = Vector3.add(initialTranslation, this.to);
			fakeTo = { x: to.x, y: to.y, z: to.z };

			this.tween.from(fakeFrom).to(fakeTo, +this.time).easing(this.easing).onUpdate(function() {
				translation.data[0] += this.x - old.x;
				translation.data[1] += this.y - old.y;
				translation.data[2] += this.z - old.z;

				old.x = this.x;
				old.y = this.y;
				old.z = this.z;

				transformComponent.setUpdated();
			}).onComplete(function() {
				fsm.send(this.eventToEmit.channel);
			}.bind(this)).start();
		} else {
			fakeTo = { x: this.to[0], y: this.to[1], z: this.to[2] };

			this.tween.from(fakeFrom).to(fakeTo, +this.time).easing(this.easing).onUpdate(function() {
				translation.data[0] += this.x - old.x;
				translation.data[1] += this.y - old.y;
				translation.data[2] += this.z - old.z;

				old.x = this.x;
				old.y = this.y;
				old.z = this.z;

				transformComponent.setUpdated();
			}).onComplete(function() {
				fsm.send(this.eventToEmit.channel);
			}.bind(this)).start();
		}
	};

	return TweenMoveAction;
});
{'fraction_non_alphanumeric': 0.17012383900928793, 'fraction_numerical': 0.008823529411764706, 'mean_word_length': 3.7333333333333334, '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': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5004422', 'n_tokens_mistral': 2589, 'n_tokens_neox': 2260, 'n_words': 463}