if (data.entity === this.parentEntity) { console.log('AR Football 2 Entity Loaded'); } else { return; } /** * Code Components */ this.mouseMove = R3.EntityManager.Instance.findComponentById('dwxvtxzrun'); this.touchMove = R3.EntityManager.Instance.findComponentById('p49pad0i7l'); /** * Meshes */ this.footballPlayer = R3.EntityManager.Instance.findComponentById('t537n02x0s'); this.movingAverage = R3.Utils.MovingAverage(10); this.playerRotation = { x : 0, y : 0 }; R3.CustomCode.prototype.kick = function(data) { }; R3.CustomCode.prototype.move = function(data) { var x = data.x; var y = data.y; var speed = 0; if (data.source === 'mouse' || 'touch') { x *= 0.01; y *= 0.01; } this.playerRotation.x += x; 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.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); if (kick) { console.log('kick'); console.log(Number(Date.now()) - Number(this.timestamp)); } if (canKick) { console.log('can kick'); } if (y > 0 && canKick) { if (this.movingDown) { /** * Do nothing */ } else { 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; } }.bind(this) this.mouseMove.entityLoaded = this; this.touchMove.entityLoaded = this; //@ sourceURL=entityLoaded.js