Update: CC - Entity Loaded - AR Football 3 (ff0fsum4zx.js) 173 bytes modified

beta.r3js.org
Theunis Johannes Botha 2018-05-21 16:16:32 +02:00
parent 5345ae998f
commit 13415f8a90
1 changed files with 22 additions and 14 deletions

View File

@ -61,7 +61,15 @@ this.debug = false;
this.gravity = -9.8; this.gravity = -9.8;
this.initialSpeed = 10; this.initialSpeed = 5;
this.startRayZ = -2;
this.endRayZ = -2.5;
this.playerY = 0.155;
this.ballY = 0.0355;
if (this.debug) { if (this.debug) {
this.arrowHelper = new THREE.ArrowHelper( this.arrowHelper = new THREE.ArrowHelper(
@ -86,9 +94,9 @@ R3.CustomCode.prototype.render = function(delta) {
ball.stopped = true; ball.stopped = true;
} }
ball.speed -= delta * 2; ball.speed -= delta / 2;
ball.t += delta; ball.t += delta / 2;
var u = new THREE.Vector3( var u = new THREE.Vector3(
ball.speed * Math.sin(ball.directionAngle), ball.speed * Math.sin(ball.directionAngle),
@ -103,9 +111,9 @@ R3.CustomCode.prototype.render = function(delta) {
/** /**
* Bounce * Bounce
*/ */
if (ball.mesh.position.y <= 0.18) { if (ball.mesh.position.y <= this.ballY) {
ball.s0.x = ball.mesh.position.x; ball.s0.x = ball.mesh.position.x;
ball.s0.y = 0.18; ball.s0.y = this.ballY;
ball.s0.z = ball.mesh.position.z; ball.s0.z = ball.mesh.position.z;
ball.upAngle *= ball.bounciness; ball.upAngle *= ball.bounciness;
ball.t = 0; ball.t = 0;
@ -166,8 +174,8 @@ R3.CustomCode.prototype.render = function(delta) {
if ( if (
!ball.scored && !ball.scored &&
ball.mesh.position.z < -4 && ball.mesh.position.z < this.startRayZ &&
ball.mesh.position.z > -5 ball.mesh.position.z > this.endRayZ
) { ) {
this.raycaster.set(ball.mesh.position, direction); this.raycaster.set(ball.mesh.position, direction);
@ -292,7 +300,7 @@ R3.CustomCode.prototype.move = function(data) {
); );
this.activeBall.scale.copy(this.football.instance.scale); this.activeBall.scale.copy(this.football.instance.scale);
this.activeBall.position.y = 0.18; this.activeBall.position.y = this.ballY;
this.football.parentScene.instance.add(this.activeBall); this.football.parentScene.instance.add(this.activeBall);
} }
@ -304,11 +312,11 @@ R3.CustomCode.prototype.move = function(data) {
this.footballPlayer.instance.scale this.footballPlayer.instance.scale
); );
this.footballPlayer.instance.translateY(0.78); this.footballPlayer.instance.translateY(this.playerY);
this.footballPlayer.instance.rotateY(this.playerRotation.x); this.footballPlayer.instance.rotateY(this.playerRotation.x);
this.footballPlayer.instance.translateZ(0.3); this.footballPlayer.instance.translateZ(this.ballY);
this.footballPlayer.instance.rotateX(this.playerRotation.y); this.footballPlayer.instance.rotateX(this.playerRotation.y);
@ -366,8 +374,8 @@ R3.CustomCode.prototype.move = function(data) {
v : v, v : v,
vRotationAxis : vRotationAxis, vRotationAxis : vRotationAxis,
t : 0, t : 0,
s0 : new THREE.Vector3(0,0.18,0), s0 : new THREE.Vector3(0,this.ballY,0),
s1 : new THREE.Vector3(0,0.18,0), s1 : new THREE.Vector3(0,this.ballY,0),
bounciness : 0.5, bounciness : 0.5,
scored : false, scored : false,
scoredThroughGoal : null, scoredThroughGoal : null,
@ -383,8 +391,8 @@ R3.CustomCode.prototype.move = function(data) {
}.bind(this) }.bind(this)
this.footballPlayer.instance.translateY(0.78); this.footballPlayer.instance.translateY(this.playerY);
this.football.instance.position.y = 0.18; this.football.instance.position.y = this.ballY;
this.mouseMove.entityLoaded = this; this.mouseMove.entityLoaded = this;
this.touchMove.entityLoaded = this; this.touchMove.entityLoaded = this;