From 91ced64374daaf699abe748896516d575d356591 Mon Sep 17 00:00:00 2001 From: -=ybafelo Date: Thu, 17 May 2018 12:42:33 +0200 Subject: [PATCH] Initial Commit: CC - Entity Loaded - AR Football 2 (ff0fsum4zx.js) --- ff0fsum4zx.js | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 ff0fsum4zx.js diff --git a/ff0fsum4zx.js b/ff0fsum4zx.js new file mode 100644 index 0000000..f1fce3c --- /dev/null +++ b/ff0fsum4zx.js @@ -0,0 +1,121 @@ +if (data.entity === this.parentEntity) { + console.log('AR Football 2 Entity Loaded'); +} else { + return; +} + +/** + * Code Components + */ +this.mouseMove = R3.EntityManager.Instance.findComponentById('dwxvtxzrun'); + +/** + * Meshes + */ +this.footballPlayer = R3.EntityManager.Instance.findComponentById('t537n02x0s'); + +this.playerRotation = { + x : 0, + y : 0 +}; + +R3.CustomCode.prototype.move = function(data) { + + var x = data.x; + var y = data.y; + + if (data.source === 'mouse') { + x *= 0.01; + y *= 0.01; + } + + this.playerRotation.x += x; + this.playerRotation.y += y; + + 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); + + // var v = new THREE.Vector3(x, y, 0); + // v.normalize(); + + + /** + * 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); +// this.footballPlayer.instance.rotateX(v.y * 0.1); + + //this.footballPlayer.instance.translateZ(-0.2); + + + + // + + + // + // 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) + +this.mouseMove.entityLoaded = this; + +//@ sourceURL=entityLoaded.js \ No newline at end of file