2018-05-12 16:06:19 +02:00
|
|
|
if (data.entity === this.parentEntity) {
|
2018-05-17 15:37:56 +02:00
|
|
|
console.log('AR Football 3 Entity Loaded');
|
2018-05-12 16:06:19 +02:00
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-14 09:56:05 +02:00
|
|
|
/**
|
|
|
|
* Code Components
|
|
|
|
*/
|
|
|
|
this.mouseMove = R3.EntityManager.Instance.findComponentById('bmllkpyql3');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Meshes
|
|
|
|
*/
|
2018-05-12 16:06:19 +02:00
|
|
|
this.footballPlayer = R3.EntityManager.Instance.findComponentById('fn2jjb9eou');
|
|
|
|
|
|
|
|
this.playerRotation = {
|
|
|
|
x : 0,
|
|
|
|
y : 0
|
|
|
|
};
|
|
|
|
|
|
|
|
R3.CustomCode.prototype.move = function(data) {
|
|
|
|
|
2018-05-14 09:56:05 +02:00
|
|
|
var x = data.x;
|
|
|
|
var y = data.y;
|
|
|
|
|
2018-05-14 10:44:18 +02:00
|
|
|
if (data.source === 'mouse') {
|
|
|
|
x *= 0.01;
|
|
|
|
y *= 0.01;
|
|
|
|
}
|
2018-05-14 09:56:05 +02:00
|
|
|
|
|
|
|
this.playerRotation.x += x;
|
|
|
|
this.playerRotation.y += y;
|
|
|
|
|
2018-05-14 10:44:18 +02:00
|
|
|
this.footballPlayer.instance.matrix = new THREE.Matrix4();
|
|
|
|
this.footballPlayer.instance.matrix.decompose(
|
|
|
|
this.footballPlayer.instance.position,
|
|
|
|
this.footballPlayer.instance.quaternion,
|
|
|
|
this.footballPlayer.instance.scale
|
|
|
|
);
|
|
|
|
|
|
|
|
this.footballPlayer.instance.translateY(0.78);
|
|
|
|
|
|
|
|
this.footballPlayer.instance.rotateY(this.playerRotation.x);
|
|
|
|
|
|
|
|
this.footballPlayer.instance.translateZ(0.2);
|
|
|
|
|
|
|
|
this.footballPlayer.instance.rotateX(this.playerRotation.y);
|
2018-05-14 09:56:05 +02:00
|
|
|
|
|
|
|
// var v = new THREE.Vector3(x, y, 0);
|
|
|
|
// v.normalize();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-05-12 16:06:19 +02:00
|
|
|
* This is where i have to do the right order of transformations
|
|
|
|
*/
|
2018-05-14 09:56:05 +02:00
|
|
|
|
2018-05-14 10:44:18 +02:00
|
|
|
//this.footballPlayer.instance.rotateOnAxis(new THREE.Vector3(0, 1, 0), this.playerRotation.x * 0.001);
|
|
|
|
|
2018-05-14 09:56:05 +02:00
|
|
|
// this.footballPlayer.quaternion.axis.x = 1;
|
|
|
|
// this.footballPlayer.quaternion.axis.y = 0;
|
|
|
|
// this.footballPlayer.quaternion.axis.z = 0;
|
|
|
|
//
|
|
|
|
// this.footballPlayer.quaternion.angle = this.playerRotation.y;
|
|
|
|
//
|
|
|
|
// this.footballPlayer.updateInstance('quaternion');
|
|
|
|
|
2018-05-14 10:44:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
//this.footballPlayer.instance.rotateOnAxis(new THREE.Vector3(1, 0, 0), this.playerRotation.y * 0.001);
|
2018-05-14 09:56:05 +02:00
|
|
|
// this.footballPlayer.instance.rotateX(v.y * 0.1);
|
|
|
|
|
2018-05-14 10:44:18 +02:00
|
|
|
//this.footballPlayer.instance.translateZ(-0.2);
|
2018-05-14 09:56:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// this.footballPlayer.position.x = Math.sin(this.playerRotation.x);
|
|
|
|
// this.footballPlayer.position.z = Math.cos(this.playerRotation.x);
|
|
|
|
// this.footballPlayer.updateInstance('position');
|
|
|
|
//
|
|
|
|
// this.footballPlayer.lookAt.x = 0;
|
|
|
|
// this.footballPlayer.lookAt.y = 0;
|
|
|
|
// this.footballPlayer.lookAt.z = 0;
|
|
|
|
// this.footballPlayer.updateInstance('lookAt');
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
var v = new THREE.Vector3(this.playerRotation.y, this.playerRotation.x, 0);
|
|
|
|
v.normalize();
|
|
|
|
|
|
|
|
this.footballPlayer.quaternion.axis.x = v.x;
|
|
|
|
this.footballPlayer.quaternion.axis.y = v.y;
|
|
|
|
this.footballPlayer.quaternion.axis.z = 0;
|
|
|
|
|
|
|
|
this.footballPlayer.quaternion.angle = 1;
|
|
|
|
//this.footballPlayer.quaternion.angle = Math.abs(x) + Math.abs(y);
|
|
|
|
|
|
|
|
this.footballPlayer.updateInstance('quaternion');
|
|
|
|
console.log('todo: player rotation');
|
|
|
|
|
|
|
|
this.footballPlayer.quaternion.axis.x = 0;
|
|
|
|
this.footballPlayer.quaternion.axis.y = 1;
|
|
|
|
this.footballPlayer.quaternion.axis.z = 0;
|
|
|
|
|
|
|
|
this.footballPlayer.quaternion.angle = this.playerRotation.x;
|
|
|
|
|
|
|
|
this.footballPlayer.updateInstance('quaternion');
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-05-12 16:06:19 +02:00
|
|
|
|
|
|
|
}.bind(this)
|
|
|
|
|
2018-05-14 09:56:05 +02:00
|
|
|
this.mouseMove.entityLoaded = this;
|
2018-05-12 16:06:19 +02:00
|
|
|
|
|
|
|
//@ sourceURL=entityLoaded.js
|