Update: CC - Entity Loaded - AR Football 4 (6aae13w4xh.js) 881 bytes modified
parent
343f2ca31f
commit
80794de999
511
6aae13w4xh.js
511
6aae13w4xh.js
|
@ -10,8 +10,6 @@ if (data.entity === this.parentEntity) {
|
||||||
this.mouseMove = R3.EntityManager.Instance.findComponentById('5d3rqq75xi');
|
this.mouseMove = R3.EntityManager.Instance.findComponentById('5d3rqq75xi');
|
||||||
this.touchMove = R3.EntityManager.Instance.findComponentById('7w3d7hfzal');
|
this.touchMove = R3.EntityManager.Instance.findComponentById('7w3d7hfzal');
|
||||||
this.beforeRender = R3.EntityManager.Instance.findComponentById('8l80lykq42');
|
this.beforeRender = R3.EntityManager.Instance.findComponentById('8l80lykq42');
|
||||||
this.keyDown = R3.EntityManager.Instance.findComponentById('70v12hvjrw');
|
|
||||||
this.keyUp = R3.EntityManager.Instance.findComponentById('xlq24tbwpo');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meshes
|
* Meshes
|
||||||
|
@ -39,8 +37,8 @@ this.materialBlack = R3.EntityManager.Instance.findComponentById('kf4zpiz60p');
|
||||||
this.arScene = R3.EntityManager.Instance.findComponentById('qs396wehbv');
|
this.arScene = R3.EntityManager.Instance.findComponentById('qs396wehbv');
|
||||||
|
|
||||||
this.playerRotation = {
|
this.playerRotation = {
|
||||||
x : 0,
|
x : 0,
|
||||||
y : 0
|
y : 0
|
||||||
};
|
};
|
||||||
|
|
||||||
R3.CustomCode.TIME_LIMIT = 45;
|
R3.CustomCode.TIME_LIMIT = 45;
|
||||||
|
@ -85,10 +83,6 @@ this.invertY = true;
|
||||||
|
|
||||||
this.invertX = true;
|
this.invertX = true;
|
||||||
|
|
||||||
this.preparing = false;
|
|
||||||
|
|
||||||
this.looking = null;
|
|
||||||
|
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
this.arrowHelper = new THREE.ArrowHelper(
|
this.arrowHelper = new THREE.ArrowHelper(
|
||||||
new THREE.Vector3(0,0,-1),
|
new THREE.Vector3(0,0,-1),
|
||||||
|
@ -118,53 +112,13 @@ R3.CustomCode.prototype.render = function(delta) {
|
||||||
|
|
||||||
this.totalTime -= delta;
|
this.totalTime -= delta;
|
||||||
|
|
||||||
R3.Event.Emit(
|
R3.Event.Emit(
|
||||||
R3.Event.GAME_DATA,
|
R3.Event.GAME_DATA,
|
||||||
{
|
{
|
||||||
type : 'timer',
|
type : 'timer',
|
||||||
time : this.totalTime
|
time : this.totalTime
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
if (this.preparing === true) {
|
|
||||||
this.move(
|
|
||||||
{
|
|
||||||
x : 0,
|
|
||||||
y : delta * -200
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.preparing === false && this.playerRotation.y < 0) {
|
|
||||||
this.move(
|
|
||||||
{
|
|
||||||
x : 0,
|
|
||||||
y : delta * 1000
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.looking === 'left') {
|
|
||||||
this.move(
|
|
||||||
{
|
|
||||||
x : delta * -700,
|
|
||||||
y : 0
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.looking === 'right') {
|
|
||||||
this.move(
|
|
||||||
{
|
|
||||||
x : delta * 700,
|
|
||||||
y : 0
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.activeBall === null) {
|
|
||||||
this.createActiveBall();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.totalTime <= 0) {
|
if (this.totalTime <= 0) {
|
||||||
|
|
||||||
|
@ -185,210 +139,209 @@ R3.CustomCode.prototype.render = function(delta) {
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
),
|
),
|
||||||
totalBalls : this.balls.length
|
totalBalls : this.balls.length
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.totalTime)
|
if (this.totalTime)
|
||||||
|
|
||||||
this.balls.map(
|
this.balls.map(
|
||||||
|
|
||||||
function(ball) {
|
function(ball) {
|
||||||
|
|
||||||
if (ball.stopped) {
|
if (ball.stopped) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (ball.speed <= 0) {
|
|
||||||
ball.stopped = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ball.speed -= delta / 2;
|
|
||||||
|
|
||||||
ball.t += delta / 2;
|
|
||||||
|
|
||||||
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 * (this.gravity) * ball.t * ball.t;
|
|
||||||
ball.mesh.position.z = ball.s0.z + u.z * ball.t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bounce
|
|
||||||
*/
|
|
||||||
if (ball.mesh.position.y <= this.ballY) {
|
|
||||||
ball.s0.x = ball.mesh.position.x;
|
|
||||||
ball.s0.y = this.ballY;
|
|
||||||
ball.s0.z = ball.mesh.position.z;
|
|
||||||
ball.upAngle *= ball.bounciness;
|
|
||||||
ball.t = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check for goal collision
|
|
||||||
*/
|
|
||||||
var goalDistanceL = this.goalL.position.distanceTo(ball.mesh.position);
|
|
||||||
var goalDistanceR = this.goalR.position.distanceTo(ball.mesh.position);
|
|
||||||
|
|
||||||
if (goalDistanceL < (this.goalL.geometry.instance.boundingSphere.radius - ball.mesh.geometry.boundingSphere.radius)) {
|
|
||||||
if (ball.scored === false) {
|
|
||||||
console.log('left goal!');
|
|
||||||
ball.scored = true;
|
|
||||||
ball.scoredThroughGoal = 'left';
|
|
||||||
R3.Event.Emit(
|
|
||||||
R3.Event.PLAY_AUDIO,
|
|
||||||
{
|
|
||||||
name : 'Audio - Crowd Cheer'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
R3.Event.Emit(
|
|
||||||
R3.Event.GAME_DATA,
|
|
||||||
{
|
|
||||||
type : 'score',
|
|
||||||
goal : 'left'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (goalDistanceR < (this.goalR.geometry.instance.boundingSphere.radius - ball.mesh.geometry.boundingSphere.radius)) {
|
if (ball.speed <= 0) {
|
||||||
if (ball.scored === false) {
|
ball.stopped = true;
|
||||||
console.log('right goal!');
|
|
||||||
ball.scored = true;
|
|
||||||
ball.scoredThroughGoal = 'right';
|
|
||||||
R3.Event.Emit(
|
|
||||||
R3.Event.PLAY_AUDIO,
|
|
||||||
{
|
|
||||||
name : 'Audio - Crowd Cheer'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
R3.Event.Emit(
|
|
||||||
R3.Event.GAME_DATA,
|
|
||||||
{
|
|
||||||
type : 'score',
|
|
||||||
goal : 'right'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
ball.speed -= delta / 2;
|
||||||
* Check for goal reflection
|
|
||||||
*/
|
|
||||||
var futureTime = ball.t + delta;
|
|
||||||
|
|
||||||
ball.s1.x = ball.s0.x + u.x * futureTime;
|
ball.t += delta / 2;
|
||||||
ball.s1.y = ball.s0.y + u.y * futureTime + 0.5 * (this.gravity) * futureTime * futureTime;
|
|
||||||
ball.s1.z = ball.s0.z + u.z * futureTime;
|
|
||||||
|
|
||||||
//var distance = ball.mesh.position.distanceTo(ball.s1);
|
var u = new THREE.Vector3(
|
||||||
|
ball.speed * Math.sin(ball.directionAngle),
|
||||||
|
ball.speed * Math.sin(ball.upAngle),
|
||||||
|
ball.speed * Math.cos(ball.directionAngle)
|
||||||
|
);
|
||||||
|
|
||||||
var direction = ball.s1.sub(ball.mesh.position).normalize();
|
ball.mesh.position.x = ball.s0.x + u.x * ball.t;
|
||||||
|
ball.mesh.position.y = ball.s0.y + u.y * ball.t + 0.5 * (this.gravity) * ball.t * ball.t;
|
||||||
|
ball.mesh.position.z = ball.s0.z + u.z * ball.t;
|
||||||
|
|
||||||
if (this.debug) {
|
/**
|
||||||
this.arrowHelper.position.copy(ball.mesh.position);
|
* Bounce
|
||||||
this.arrowHelper.setDirection(direction);
|
*/
|
||||||
this.arrowHelper.setLength(1);
|
if (ball.mesh.position.y <= this.ballY) {
|
||||||
}
|
ball.s0.x = ball.mesh.position.x;
|
||||||
|
ball.s0.y = this.ballY;
|
||||||
|
ball.s0.z = ball.mesh.position.z;
|
||||||
|
ball.upAngle *= ball.bounciness;
|
||||||
|
ball.t = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
/**
|
||||||
!ball.scored &&
|
* Check for goal collision
|
||||||
ball.mesh.position.z < this.startRayZ &&
|
*/
|
||||||
ball.mesh.position.z > this.endRayZ
|
var goalDistanceL = this.goalL.position.distanceTo(ball.mesh.position);
|
||||||
) {
|
var goalDistanceR = this.goalR.position.distanceTo(ball.mesh.position);
|
||||||
|
|
||||||
this.raycaster.set(ball.mesh.position, direction);
|
if (goalDistanceL < (this.goalL.geometry.instance.boundingSphere.radius - ball.mesh.geometry.boundingSphere.radius)) {
|
||||||
this.raycaster.intersectObjects([
|
if (ball.scored === false) {
|
||||||
this.goalWithHoles.instance
|
console.log('left goal!');
|
||||||
]).map(
|
ball.scored = true;
|
||||||
function(intersect) {
|
ball.scoredThroughGoal = 'left';
|
||||||
|
R3.Event.Emit(
|
||||||
if (intersect.distance < ball.mesh.geometry.boundingSphere.radius) {
|
R3.Event.PLAY_AUDIO,
|
||||||
|
{
|
||||||
var normal = new THREE.Vector3(
|
name : 'Audio - Crowd Cheer'
|
||||||
intersect.object.geometry.getAttribute('normal').array[0],
|
}
|
||||||
intersect.object.geometry.getAttribute('normal').array[1],
|
);
|
||||||
intersect.object.geometry.getAttribute('normal').array[2]
|
R3.Event.Emit(
|
||||||
);
|
R3.Event.GAME_DATA,
|
||||||
|
{
|
||||||
var reflect = direction.reflect(normal);
|
type : 'score',
|
||||||
|
goal : 'left'
|
||||||
var angle = direction.angleTo(reflect);
|
}
|
||||||
|
);
|
||||||
ball.directionAngle = angle;
|
|
||||||
ball.s0.x = ball.mesh.position.x;
|
|
||||||
ball.s0.y = ball.mesh.position.y;
|
|
||||||
ball.s0.z = ball.mesh.position.z;
|
|
||||||
ball.upAngle *= ball.bounciness;
|
|
||||||
ball.speed *= ball.bounciness * 1.5;
|
|
||||||
ball.t = 0;
|
|
||||||
|
|
||||||
ball.v.copy(direction);
|
|
||||||
|
|
||||||
ball.vRotationAxis.x *= -1;
|
|
||||||
ball.vRotationAxis.z *= -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if (ball.mesh.position.z <= -5 && !ball.scored && ball.lastIntersect) {
|
if (goalDistanceR < (this.goalR.geometry.instance.boundingSphere.radius - ball.mesh.geometry.boundingSphere.radius)) {
|
||||||
// console.log(ball.lastIntersect);
|
if (ball.scored === false) {
|
||||||
// }
|
console.log('right goal!');
|
||||||
|
ball.scored = true;
|
||||||
|
ball.scoredThroughGoal = 'right';
|
||||||
|
R3.Event.Emit(
|
||||||
|
R3.Event.PLAY_AUDIO,
|
||||||
|
{
|
||||||
|
name : 'Audio - Crowd Cheer'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
R3.Event.Emit(
|
||||||
|
R3.Event.GAME_DATA,
|
||||||
|
{
|
||||||
|
type : 'score',
|
||||||
|
goal : 'right'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for goal reflection
|
||||||
|
*/
|
||||||
|
var futureTime = ball.t + delta;
|
||||||
|
|
||||||
|
ball.s1.x = ball.s0.x + u.x * futureTime;
|
||||||
|
ball.s1.y = ball.s0.y + u.y * futureTime + 0.5 * (this.gravity) * futureTime * futureTime;
|
||||||
|
ball.s1.z = ball.s0.z + u.z * futureTime;
|
||||||
|
|
||||||
|
//var distance = ball.mesh.position.distanceTo(ball.s1);
|
||||||
|
|
||||||
|
var direction = ball.s1.sub(ball.mesh.position).normalize();
|
||||||
|
|
||||||
|
if (this.debug) {
|
||||||
|
this.arrowHelper.position.copy(ball.mesh.position);
|
||||||
|
this.arrowHelper.setDirection(direction);
|
||||||
|
this.arrowHelper.setLength(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!ball.scored &&
|
||||||
|
ball.mesh.position.z < this.startRayZ &&
|
||||||
|
ball.mesh.position.z > this.endRayZ
|
||||||
|
) {
|
||||||
|
|
||||||
|
this.raycaster.set(ball.mesh.position, direction);
|
||||||
|
this.raycaster.intersectObjects([
|
||||||
|
this.goalWithHoles.instance
|
||||||
|
]).map(
|
||||||
|
function(intersect) {
|
||||||
|
|
||||||
|
if (intersect.distance < ball.mesh.geometry.boundingSphere.radius) {
|
||||||
|
|
||||||
|
var normal = new THREE.Vector3(
|
||||||
|
intersect.object.geometry.getAttribute('normal').array[0],
|
||||||
|
intersect.object.geometry.getAttribute('normal').array[1],
|
||||||
|
intersect.object.geometry.getAttribute('normal').array[2]
|
||||||
|
);
|
||||||
|
|
||||||
|
var reflect = direction.reflect(normal);
|
||||||
|
|
||||||
|
var angle = direction.angleTo(reflect);
|
||||||
|
|
||||||
|
ball.directionAngle = angle;
|
||||||
|
ball.s0.x = ball.mesh.position.x;
|
||||||
|
ball.s0.y = ball.mesh.position.y;
|
||||||
|
ball.s0.z = ball.mesh.position.z;
|
||||||
|
ball.upAngle *= ball.bounciness;
|
||||||
|
ball.speed *= ball.bounciness * 1.5;
|
||||||
|
ball.t = 0;
|
||||||
|
|
||||||
|
ball.v.copy(direction);
|
||||||
|
|
||||||
|
ball.vRotationAxis.x *= -1;
|
||||||
|
ball.vRotationAxis.z *= -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (ball.mesh.position.z <= -5 && !ball.scored && ball.lastIntersect) {
|
||||||
|
// console.log(ball.lastIntersect);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotate the ball
|
* Rotate the ball
|
||||||
*/
|
*/
|
||||||
ball.mesh.rotateOnAxis(ball.vRotationAxis, -ball.speed * 0.04);
|
ball.mesh.rotateOnAxis(ball.vRotationAxis, -ball.speed * 0.04);
|
||||||
|
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
R3.CustomCode.prototype.move = function(data) {
|
R3.CustomCode.prototype.move = function(data) {
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
|
|
||||||
if (data && data.x) {
|
if (data && data.x) {
|
||||||
if (this.invertX) {
|
if (this.invertX) {
|
||||||
x = data.x;
|
x = data.x;
|
||||||
} else {
|
} else {
|
||||||
x = -data.x;
|
x = -data.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var y = 0;
|
var y = 0;
|
||||||
|
|
||||||
if (data && data.y) {
|
if (data && data.y) {
|
||||||
|
|
||||||
if (this.invertY) {
|
if (this.invertY) {
|
||||||
y = data.y;
|
y = data.y;
|
||||||
} else {
|
} else {
|
||||||
y = -data.y;
|
y = -data.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
x *= 0.0025;
|
x *= 0.0025;
|
||||||
y *= 0.0075;
|
y *= 0.0075;
|
||||||
|
|
||||||
|
|
||||||
this.playerRotation.x += x;
|
this.playerRotation.x += x;
|
||||||
this.playerRotation.y += y;
|
this.playerRotation.y += y;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clamp player rotation to values between 0 and Math.PI * 2
|
* Clamp player rotation to values between 0 and Math.PI * 2
|
||||||
*/
|
*/
|
||||||
if (this.playerRotation.y > 0) {
|
if (this.playerRotation.y > Math.PI) {
|
||||||
this.playerRotation.y = 0;
|
this.playerRotation.y = Math.PI;
|
||||||
this.kick = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.playerRotation.y < -Math.PI) {
|
if (this.playerRotation.y < -Math.PI) {
|
||||||
|
@ -403,39 +356,41 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
this.playerRotation.x = -Math.PI / 2;
|
this.playerRotation.x = -Math.PI / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (this.playerRotation.y <= 0) {
|
if (this.playerRotation.y <= 0) {
|
||||||
// this.canKick = true;
|
this.canKick = true;
|
||||||
// }
|
}
|
||||||
|
|
||||||
//if (this.canKick && this.playerRotation.y === 0) {
|
if (this.canKick && this.playerRotation.y > 0) {
|
||||||
// this.canKick = false;
|
this.canKick = false;
|
||||||
// this.kick = true;
|
this.kick = true;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (y > 0 && this.canKick) {
|
if (y > 0 && this.canKick) {
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Moving down, initialize start time and record the distance travelled
|
|
||||||
// */
|
|
||||||
// if (this.startTime === null) {
|
|
||||||
// this.startTime = Date.now();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //this.kickDistance += Math.abs(y);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (y < 0) {
|
|
||||||
// /**
|
|
||||||
// * We are no longer moving down, also reset our Y distance counter
|
|
||||||
// * @type {boolean}
|
|
||||||
// */
|
|
||||||
// //this.kickDistance = 0;
|
|
||||||
// this.startTime = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moving down, initialize start time and record the distance travelled
|
||||||
|
*/
|
||||||
|
if (this.startTime === null) {
|
||||||
|
this.startTime = Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.kickDistance += Math.abs(y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y < 0) {
|
||||||
|
/**
|
||||||
|
* We are no longer moving down, also reset our Y distance counter
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.kickDistance = 0;
|
||||||
|
this.startTime = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (this.canKick && this.activeBall === null) {
|
||||||
|
this.createActiveBall();
|
||||||
|
}
|
||||||
|
|
||||||
this.footballPlayer.instance.matrix = new THREE.Matrix4();
|
this.footballPlayer.instance.matrix = new THREE.Matrix4();
|
||||||
this.footballPlayer.instance.matrix.decompose(
|
this.footballPlayer.instance.matrix.decompose(
|
||||||
|
@ -456,12 +411,10 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
|
|
||||||
this.kick = false;
|
this.kick = false;
|
||||||
|
|
||||||
//this.shooting = false;
|
if (this.startTime === null) {
|
||||||
|
console.warn('no kick start time');
|
||||||
// if (this.startTime === null) {
|
return;
|
||||||
// console.warn('no kick start time');
|
}
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
R3.Event.Emit(
|
R3.Event.Emit(
|
||||||
R3.Event.PLAY_AUDIO,
|
R3.Event.PLAY_AUDIO,
|
||||||
|
@ -470,11 +423,9 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
//var kickDuration = 1;//Date.now() - this.startTime;
|
var kickDuration = Date.now() - this.startTime;
|
||||||
|
|
||||||
var speed = this.kickDistance;
|
var speed = this.kickDistance / kickDuration * 20;
|
||||||
|
|
||||||
console.log('speed = ' + speed);
|
|
||||||
|
|
||||||
// if (speed > 1.5) {
|
// if (speed > 1.5) {
|
||||||
// speed = 1.5;
|
// speed = 1.5;
|
||||||
|
@ -484,10 +435,10 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
|
|
||||||
var v = new THREE.Vector3(0, 0, -1);
|
var v = new THREE.Vector3(0, 0, -1);
|
||||||
|
|
||||||
v.multiplyScalar(speed);
|
v.multiplyScalar(speed);
|
||||||
|
|
||||||
v.applyAxisAngle(
|
v.applyAxisAngle(
|
||||||
new THREE.Vector3(0,1,0),
|
new THREE.Vector3(0,1,0),
|
||||||
this.playerRotation.x
|
this.playerRotation.x
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -497,7 +448,7 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
v.x
|
v.x
|
||||||
).normalize();
|
).normalize();
|
||||||
|
|
||||||
this.balls.push(
|
this.balls.push(
|
||||||
{
|
{
|
||||||
mesh : this.activeBall,
|
mesh : this.activeBall,
|
||||||
speed : this.initialSpeed,
|
speed : this.initialSpeed,
|
||||||
|
@ -506,7 +457,7 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
kickDuration : this.kickDuration,
|
kickDuration : this.kickDuration,
|
||||||
kickDistance : this.kickDistance,
|
kickDistance : this.kickDistance,
|
||||||
kickSpeed : speed,
|
kickSpeed : speed,
|
||||||
upAngle : speed,
|
upAngle : Math.PI * speed,
|
||||||
v : v,
|
v : v,
|
||||||
vRotationAxis : vRotationAxis,
|
vRotationAxis : vRotationAxis,
|
||||||
t : 0,
|
t : 0,
|
||||||
|
@ -519,10 +470,10 @@ R3.CustomCode.prototype.move = function(data) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.activeBall = null;
|
this.activeBall = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this);
|
}.bind(this)
|
||||||
|
|
||||||
|
|
||||||
R3.Event.Subscribe(
|
R3.Event.Subscribe(
|
||||||
|
@ -546,40 +497,6 @@ R3.Event.Subscribe(
|
||||||
this.mouseMove.entityLoaded = null;
|
this.mouseMove.entityLoaded = null;
|
||||||
this.touchMove.entityLoaded = null;
|
this.touchMove.entityLoaded = null;
|
||||||
this.beforeRender.entityLoaded = null;
|
this.beforeRender.entityLoaded = null;
|
||||||
this.keyDown.entityLoaded = null;
|
|
||||||
this.keyUp.entityLoaded = null;
|
|
||||||
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
R3.Event.Subscribe(
|
|
||||||
R3.Event.GAME_DATA,
|
|
||||||
function(data) {
|
|
||||||
|
|
||||||
if (data.type === 'shoot') {
|
|
||||||
this.preparing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.type === 'shoot_release') {
|
|
||||||
this.preparing = false;
|
|
||||||
this.kickDistance = Math.abs(this.playerRotation.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.type === 'left') {
|
|
||||||
this.looking = 'left';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.type === 'right') {
|
|
||||||
this.looking = 'right';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.type === 'right_release') {
|
|
||||||
this.looking = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.type === 'left_release') {
|
|
||||||
this.looking = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
@ -669,8 +586,6 @@ R3.Event.Subscribe(
|
||||||
this.mouseMove.entityLoaded = this;
|
this.mouseMove.entityLoaded = this;
|
||||||
this.touchMove.entityLoaded = this;
|
this.touchMove.entityLoaded = this;
|
||||||
this.beforeRender.entityLoaded = this;
|
this.beforeRender.entityLoaded = this;
|
||||||
this.keyDown.entityLoaded = this;
|
|
||||||
this.keyUp.entityLoaded = this;
|
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue