From 85acbbf3e3a2e0c96ef1e59f4e80f7998eff5cde Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Mon, 14 May 2018 10:44:18 +0200 Subject: [PATCH] fix motion --- madnahfvrc.js | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/madnahfvrc.js b/madnahfvrc.js index 3eb8c8a..6653ff4 100644 --- a/madnahfvrc.js +++ b/madnahfvrc.js @@ -24,15 +24,28 @@ R3.CustomCode.prototype.move = function(data) { var x = data.x; var y = data.y; - // if (data.source === 'mouse') { - // x *= 0.001; - // y *= 0.001; - // } + if (data.source === 'mouse') { + x *= 0.01; + y *= 0.01; + } this.playerRotation.x += x; this.playerRotation.y += y; - //this.footballPlayer.instance.applyMatrix(new THREE.Matrix4()); + 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(); @@ -41,16 +54,9 @@ R3.CustomCode.prototype.move = function(data) { /** * This is where i have to do the right order of transformations */ - // 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.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; @@ -59,10 +65,12 @@ R3.CustomCode.prototype.move = function(data) { // // this.footballPlayer.updateInstance('quaternion'); - this.footballPlayer.instance.rotateOnAxis(new THREE.Vector3(1, 0, 0), this.playerRotation.y * 0.001); + + + //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.instance.translateZ(-0.2);