From 8e263c3f11b65571893bfad506c09dd72d890f81 Mon Sep 17 00:00:00 2001 From: Theunis Johannes Botha Date: Sun, 20 May 2018 13:37:10 +0200 Subject: [PATCH] Update: CC - Entity Loaded - AR Football 3 (ff0fsum4zx.js) 1503 bytes modified --- ff0fsum4zx.js | 96 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/ff0fsum4zx.js b/ff0fsum4zx.js index 74b830c..c326305 100644 --- a/ff0fsum4zx.js +++ b/ff0fsum4zx.js @@ -9,6 +9,7 @@ if (data.entity === this.parentEntity) { */ this.mouseMove = R3.EntityManager.Instance.findComponentById('dwxvtxzrun'); this.touchMove = R3.EntityManager.Instance.findComponentById('p49pad0i7l'); +this.beforeRender = R3.EntityManager.Instance.findComponentById('7l8ar325qf'); /** * Meshes @@ -44,6 +45,56 @@ this.balls = []; this.activeBall = this.football.instance; +R3.CustomCode.prototype.calcPosition = function(shotAngle, lookAngle, t) { + + + +}; + +R3.CustomCode.prototype.render = function(delta) { + + this.balls.map( + + function(ball) { + + ball.t += delta; + + var u = new THREE.Vector3( + ball.speed * Math.sin(ball.directionAngle), + ball.speed * Math.sin(ball.upAngle), + ball.speed * Math.cos(ball.directionAngle) + ); + + ball.mesh.position.x = ball.s0.x + u.x * ball.t; + ball.mesh.position.y = ball.s0.y + u.y * ball.t + 0.5 * (-9.8) * ball.t * ball.t; + ball.mesh.position.z = ball.s0.z + u.z * ball.t; + + if (ball.mesh.position.y <= 0) { + ball.s0.x = ball.mesh.position.x; + ball.s0.y = 0; + ball.s0.z = ball.mesh.position.z; + ball.upAngle *= ball.bounciness; + ball.t = 0; + } + + var v = new THREE.Vector3( + -ball.v.z, + 0, + ball.v.x + ); + + + ball.mesh.rotateOnAxis(v.normalize(), -0.1); + + //object.ball.translateOnAxis(object.v, 1); + + //object.ball.position.y = object.ball.position.y + 0.5 * (-9.8) * object.t * object.t; + + + }.bind(this) + ) +}; + R3.CustomCode.prototype.move = function(data) { var x = data.x; @@ -114,20 +165,47 @@ R3.CustomCode.prototype.move = function(data) { this.kick.time = Date.now() - this.kick.start; - this.kick.speed = this.kick.distance / this.kick.time; + this.kick.speed = this.kick.distance / this.kick.time * 40; - this.kick.direction = this.playerRotation.x; + this.kick.direction = this.playerRotation.x; - this.balls.push(this.activeBall); + if (this.kick.speed > 1) { + this.kick.speed = 1; + } + + console.log(this.kick.speed); + + var v = new THREE.Vector3(0, 0, -1); + + v.multiplyScalar(this.kick.speed); + + v.applyAxisAngle( + new THREE.Vector3(0,1,0), + this.kick.direction + ); + + this.balls.push( + { + mesh : this.activeBall, + speed : 6, + mouseYTravelDistance : this.kick.distance, + directionAngle : this.kick.direction + Math.PI, + upAngle : Math.PI * this.kick.speed, + v : v, + t : 0, + s0 : new THREE.Vector3(0,0,0), + bounciness : 0.5 + } + ); this.activeBall = null; - console.log('kick', this.kick); + //console.log('kick', this.kick); } if (canKick && this.activeBall === null) { - console.log('can kick'); + //console.log('can kick'); this.activeBall = new THREE.Mesh( this.ballGeometry.instance, @@ -136,6 +214,11 @@ R3.CustomCode.prototype.move = function(data) { this.materialBlack.instance ] ); + + this.activeBall.scale.copy(this.football.instance.scale); + //this.activeBall.scale.copy(this.football.instance.scale); + + this.football.parentScene.instance.add(this.activeBall); } if (y > 0 && canKick) { @@ -148,6 +231,8 @@ R3.CustomCode.prototype.move = function(data) { * Moving down, record the distance travelled */ this.kick.distance += Math.abs(y); + + //console.log(this.kick.distance); } if (y < 0) { @@ -169,5 +254,6 @@ R3.CustomCode.prototype.move = function(data) { this.mouseMove.entityLoaded = this; this.touchMove.entityLoaded = this; +this.beforeRender.entityLoaded = this; //@ sourceURL=entityLoaded.js \ No newline at end of file