stuff
parent
c40a450f3c
commit
922d33d616
|
@ -11,4 +11,4 @@ this.entityLoaded.move(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
//@ sourceURL=mouseMoveARFootball2.js
|
//@ sourceURL=mouseMoveARFootball3.js
|
119
ff0fsum4zx.js
119
ff0fsum4zx.js
|
@ -8,23 +8,32 @@ if (data.entity === this.parentEntity) {
|
||||||
* Code Components
|
* Code Components
|
||||||
*/
|
*/
|
||||||
this.mouseMove = R3.EntityManager.Instance.findComponentById('dwxvtxzrun');
|
this.mouseMove = R3.EntityManager.Instance.findComponentById('dwxvtxzrun');
|
||||||
|
this.touchMove = R3.EntityManager.Instance.findComponentById('p49pad0i7l');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meshes
|
* Meshes
|
||||||
*/
|
*/
|
||||||
this.footballPlayer = R3.EntityManager.Instance.findComponentById('t537n02x0s');
|
this.footballPlayer = R3.EntityManager.Instance.findComponentById('t537n02x0s');
|
||||||
|
|
||||||
|
this.movingAverage = R3.Utils.MovingAverage(10);
|
||||||
|
|
||||||
this.playerRotation = {
|
this.playerRotation = {
|
||||||
x : 0,
|
x : 0,
|
||||||
y : 0
|
y : 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
R3.CustomCode.prototype.kick = function(data) {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
R3.CustomCode.prototype.move = function(data) {
|
R3.CustomCode.prototype.move = function(data) {
|
||||||
|
|
||||||
var x = data.x;
|
var x = data.x;
|
||||||
var y = data.y;
|
var y = data.y;
|
||||||
|
var speed = 0;
|
||||||
|
|
||||||
if (data.source === 'mouse') {
|
if (data.source === 'mouse' || 'touch') {
|
||||||
x *= 0.01;
|
x *= 0.01;
|
||||||
y *= 0.01;
|
y *= 0.01;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +41,32 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
this.playerRotation.x += x;
|
this.playerRotation.x += x;
|
||||||
this.playerRotation.y += y;
|
this.playerRotation.y += y;
|
||||||
|
|
||||||
|
this.timestamp = null;
|
||||||
|
|
||||||
|
var kick = false;
|
||||||
|
|
||||||
|
var canKick = false;
|
||||||
|
|
||||||
|
var movingDown = false;
|
||||||
|
|
||||||
|
if (this.playerRotation.y > Math.PI) {
|
||||||
|
canKick = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clamp player rotation to values between Math.PI * 2
|
||||||
|
*/
|
||||||
|
if (this.playerRotation.y > Math.PI * 2) {
|
||||||
|
this.playerRotation.y -= Math.PI * 2;
|
||||||
|
kick = true;
|
||||||
|
canKick = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.playerRotation.y < 0) {
|
||||||
|
this.playerRotation.y += Math.PI * 2;
|
||||||
|
canKick = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.footballPlayer.instance.matrix = new THREE.Matrix4();
|
this.footballPlayer.instance.matrix = new THREE.Matrix4();
|
||||||
this.footballPlayer.instance.matrix.decompose(
|
this.footballPlayer.instance.matrix.decompose(
|
||||||
this.footballPlayer.instance.position,
|
this.footballPlayer.instance.position,
|
||||||
|
@ -47,75 +82,45 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
|
|
||||||
this.footballPlayer.instance.rotateX(this.playerRotation.y);
|
this.footballPlayer.instance.rotateX(this.playerRotation.y);
|
||||||
|
|
||||||
// var v = new THREE.Vector3(x, y, 0);
|
if (kick) {
|
||||||
// v.normalize();
|
console.log('kick');
|
||||||
|
console.log(Number(Date.now()) - Number(this.timestamp));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canKick) {
|
||||||
|
console.log('can kick');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
if (y > 0 && canKick) {
|
||||||
* This is where i have to do the right order of transformations
|
|
||||||
*/
|
|
||||||
|
|
||||||
//this.footballPlayer.instance.rotateOnAxis(new THREE.Vector3(0, 1, 0), this.playerRotation.x * 0.001);
|
|
||||||
|
|
||||||
// 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');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//this.footballPlayer.instance.rotateOnAxis(new THREE.Vector3(1, 0, 0), this.playerRotation.y * 0.001);
|
if (this.movingDown) {
|
||||||
// this.footballPlayer.instance.rotateX(v.y * 0.1);
|
/**
|
||||||
|
* Do nothing
|
||||||
|
*/
|
||||||
|
} else {
|
||||||
|
|
||||||
//this.footballPlayer.instance.translateZ(-0.2);
|
this.timestamp = Date.now();
|
||||||
|
console.log('time stamped : ' + this.timestamp);
|
||||||
|
this.movingDown = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moving down, record the average
|
||||||
|
*/
|
||||||
|
// speed = this.movingAverage(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y < 0) {
|
||||||
//
|
this.movingDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// 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');
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
|
|
||||||
this.mouseMove.entityLoaded = this;
|
this.mouseMove.entityLoaded = this;
|
||||||
|
this.touchMove.entityLoaded = this;
|
||||||
|
|
||||||
//@ sourceURL=entityLoaded.js
|
//@ sourceURL=entityLoaded.js
|
|
@ -1,5 +1,5 @@
|
||||||
if (data.entity === this.parentEntity) {
|
if (data.entity === this.parentEntity) {
|
||||||
console.log('AR Football 2 Entity Loaded');
|
console.log('AR Football 3 Entity Loaded');
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,14 @@
|
||||||
return null;
|
|
||||||
//@ sourceURL=CustomCode (p49pad0i7l).js
|
if (!this.entityLoaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entityLoaded.move(
|
||||||
|
{
|
||||||
|
source : 'touch',
|
||||||
|
x : data.meta.totalRight - data.meta.totalLeft,
|
||||||
|
y : data.meta.totalDown - data.meta.totalUp
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
//@ sourceURL=touchMove.js
|
Loading…
Reference in New Issue