From 45883dcf3af0c7d3a12630c2301ee9aa7f1f27ff Mon Sep 17 00:00:00 2001 From: -=ybafelo Date: Mon, 14 May 2018 09:56:05 +0200 Subject: [PATCH] external mod --- bmllkpyql3.js | 14 ++++++++ madnahfvrc.js | 98 +++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 bmllkpyql3.js diff --git a/bmllkpyql3.js b/bmllkpyql3.js new file mode 100644 index 0000000..f7756a0 --- /dev/null +++ b/bmllkpyql3.js @@ -0,0 +1,14 @@ + +if (!this.entityLoaded) { + return; +} + +this.entityLoaded.move( + { + source : 'mouse', + x : data.event.movementX, + y : data.event.movementY + } +); + +//@ sourceURL=mouseMoveARFootball2.js \ No newline at end of file diff --git a/madnahfvrc.js b/madnahfvrc.js index 9a10498..3eb8c8a 100644 --- a/madnahfvrc.js +++ b/madnahfvrc.js @@ -4,6 +4,14 @@ if (data.entity === this.parentEntity) { return; } +/** + * Code Components + */ +this.mouseMove = R3.EntityManager.Instance.findComponentById('bmllkpyql3'); + +/** + * Meshes + */ this.footballPlayer = R3.EntityManager.Instance.findComponentById('fn2jjb9eou'); this.playerRotation = { @@ -12,18 +20,94 @@ this.playerRotation = { }; R3.CustomCode.prototype.move = function(data) { - - this.playerRotation.x += data.x; - this.playerRotation.y += data.y; - /** + var x = data.x; + var y = data.y; + + // if (data.source === 'mouse') { + // x *= 0.001; + // y *= 0.001; + // } + + this.playerRotation.x += x; + this.playerRotation.y += y; + + //this.footballPlayer.instance.applyMatrix(new THREE.Matrix4()); + + // var v = new THREE.Vector3(x, y, 0); + // v.normalize(); + + + /** * This is where i have to do the right order of transformations */ - console.log('todo: player rotation'); - -// this.footballPlayer.rotation.y += data. + // 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'); + this.footballPlayer.instance.rotateOnAxis(new THREE.Vector3(0, 1, 0), this.playerRotation.x * 0.001); + + this.footballPlayer.instance.translateZ(0.2); + // 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