Leap motion integration. HTML interface redesign. Merge all controls into a single index.
This commit is contained in:
+25
-24
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* HexGL
|
||||
* @author Thibaut 'BKcore' Despoulain <http://bkcore.com>
|
||||
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
|
||||
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/.
|
||||
*/
|
||||
|
||||
@@ -73,9 +73,9 @@ bkcore.hexgl.HexGL = function(opts)
|
||||
|
||||
this.initRenderer();
|
||||
|
||||
function onKeyPress(event)
|
||||
function onKeyPress(event)
|
||||
{
|
||||
if(event.keyCode == 27/*escape*/)
|
||||
if(event.keyCode == 27/*escape*/)
|
||||
{
|
||||
self.reset();
|
||||
}
|
||||
@@ -155,6 +155,7 @@ bkcore.hexgl.HexGL.prototype.initGameplay = function()
|
||||
pixelRatio: this.track.pixelRatio,
|
||||
track: this.track,
|
||||
onFinish: function() {
|
||||
self.components.shipControls.terminate();
|
||||
self.displayScore(this.finishTime, this.lapTimes);
|
||||
}
|
||||
});
|
||||
@@ -173,12 +174,12 @@ bkcore.hexgl.HexGL.prototype.displayScore = function(f, l)
|
||||
bkcore.Timer.msToTimeString(l[2])
|
||||
];
|
||||
|
||||
if(this.mobile)
|
||||
if(this.gameover !== null)
|
||||
{
|
||||
this.gameover.style.display = "block";
|
||||
this.gameover.innerHTML = tf.m + "'" + tf.s + "''" + tf.ms;
|
||||
this.containers.main.style.display = "none";
|
||||
return;
|
||||
this.gameover.children[0].innerHTML = tf.m + "'" + tf.s + "''" + tf.ms;
|
||||
this.containers.main.parentElement.style.display = "none";
|
||||
return;
|
||||
}
|
||||
|
||||
var t = this.track;
|
||||
@@ -286,7 +287,7 @@ bkcore.hexgl.HexGL.prototype.initRenderer = function()
|
||||
renderer.setSize( this.width, this.height );
|
||||
renderer.domElement.style.position = "relative";
|
||||
|
||||
this.containers.main.appendChild( renderer.domElement );
|
||||
this.containers.main.appendChild( renderer.domElement );
|
||||
this.canvas = renderer.domElement;
|
||||
this.renderer = renderer;
|
||||
this.manager = new bkcore.threejs.RenderManager(renderer);
|
||||
@@ -302,7 +303,7 @@ bkcore.hexgl.HexGL.prototype.initHUD = function()
|
||||
bg: this.track.lib.get("images", "hud.bg"),
|
||||
speed: this.track.lib.get("images", "hud.speed"),
|
||||
shield: this.track.lib.get("images", "hud.shield")
|
||||
});
|
||||
});
|
||||
this.containers.overlay.appendChild(this.hud.canvas);
|
||||
}
|
||||
|
||||
@@ -311,7 +312,7 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
|
||||
var renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
|
||||
var renderTarget = new THREE.WebGLRenderTarget( this.width, this.height, renderTargetParameters );
|
||||
|
||||
// GAME COMPOSER
|
||||
// GAME COMPOSER
|
||||
var renderSky = new THREE.RenderPass( this.manager.get("sky").scene, this.manager.get("sky").camera );
|
||||
|
||||
var renderModel = new THREE.RenderPass( this.manager.get("game").scene, this.manager.get("game").camera );
|
||||
@@ -319,8 +320,8 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
|
||||
|
||||
this.composers.game = new THREE.EffectComposer( this.renderer, renderTarget );
|
||||
|
||||
var effectScreen = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
|
||||
effectScreen.renderToScreen = true;
|
||||
var effectScreen = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
|
||||
effectScreen.renderToScreen = true;
|
||||
var effectVignette = new THREE.ShaderPass( THREE.ShaderExtras[ "vignette" ] );
|
||||
|
||||
var effectHex = new THREE.ShaderPass( bkcore.threejs.Shaders[ "hexvignette" ] );
|
||||
@@ -335,17 +336,17 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
|
||||
this.composers.game.addPass( renderSky );
|
||||
this.composers.game.addPass( renderModel );
|
||||
|
||||
if(this.quality > 0 && !this.mobile)
|
||||
{
|
||||
var effectFXAA = new THREE.ShaderPass( THREE.ShaderExtras[ "fxaa" ] );
|
||||
effectFXAA.uniforms[ 'resolution' ].value.set( 1 / this.width, 1 / this.height );
|
||||
// if(this.quality > 0 && !this.mobile)
|
||||
// {
|
||||
// var effectFXAA = new THREE.ShaderPass( THREE.ShaderExtras[ "fxaa" ] );
|
||||
// effectFXAA.uniforms[ 'resolution' ].value.set( 1 / this.width, 1 / this.height );
|
||||
|
||||
this.composers.game.addPass( effectFXAA );
|
||||
|
||||
this.extras.fxaa = effectFXAA;
|
||||
}
|
||||
// this.composers.game.addPass( effectFXAA );
|
||||
|
||||
// this.extras.fxaa = effectFXAA;
|
||||
// }
|
||||
if(this.quality > 1 && !this.mobile)
|
||||
{
|
||||
{
|
||||
var effectBloom = new THREE.BloomPass( 0.8, 25, 4 , 256);
|
||||
|
||||
this.composers.game.addPass( effectBloom );
|
||||
@@ -358,10 +359,10 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
|
||||
else
|
||||
this.composers.game.addPass( effectScreen );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, mat)
|
||||
bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, mat)
|
||||
{
|
||||
geometry.computeTangents();
|
||||
|
||||
@@ -422,4 +423,4 @@ bkcore.hexgl.HexGL.prototype.tweakShipControls = function()
|
||||
|
||||
if(this.godmode)
|
||||
c.shieldDamage = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
+166
-65
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* HexGL
|
||||
* @author Thibaut 'BKcore' Despoulain <http://bkcore.com>
|
||||
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
|
||||
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/.
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ bkcore.hexgl.ShipControls = function(ctx)
|
||||
this.thrust = 0.02;
|
||||
this.airBrake = 0.02;
|
||||
this.maxSpeed = 7.0;
|
||||
this.boosterSpeed = this.maxSpeed * 0.4;
|
||||
this.boosterSpeed = this.maxSpeed * 0.2;
|
||||
this.boosterDecay = 0.01;
|
||||
this.angularSpeed = 0.005;
|
||||
this.airAngularSpeed = 0.0065;
|
||||
@@ -75,7 +75,7 @@ bkcore.hexgl.ShipControls = function(ctx)
|
||||
this.rollAngle = 0.6;
|
||||
this.rollLerp = 0.08;
|
||||
this.rollDirection = new THREE.Vector3(0,0,1);
|
||||
|
||||
|
||||
this.gradient = 0.0;
|
||||
this.gradientTarget = 0.0;
|
||||
this.gradientLerp = 0.05;
|
||||
@@ -124,7 +124,7 @@ bkcore.hexgl.ShipControls = function(ctx)
|
||||
if(ctx.controlType == 1 && bkcore.controllers.TouchController.isCompatible())
|
||||
{
|
||||
this.touchController = new bkcore.controllers.TouchController(
|
||||
domElement, ctx.width/2,
|
||||
domElement, ctx.width/2,
|
||||
function(state, touch, event){
|
||||
if(event.touches.length >= 4)
|
||||
window.location.reload(false);
|
||||
@@ -136,12 +136,11 @@ bkcore.hexgl.ShipControls = function(ctx)
|
||||
self.key.forward = true;
|
||||
});
|
||||
}
|
||||
else if(ctx.controlType == 2 && bkcore.controllers.OrientationController.isCompatible())
|
||||
else if(ctx.controlType == 3 && bkcore.controllers.OrientationController.isCompatible())
|
||||
{
|
||||
this.orientationController = new bkcore.controllers.OrientationController(
|
||||
domElement, true,
|
||||
function(state, touch, event){
|
||||
console.log(event.touches.length);
|
||||
if(event.touches.length >= 4)
|
||||
window.location.reload(false);
|
||||
else if(event.touches.length == 3)
|
||||
@@ -152,10 +151,88 @@ bkcore.hexgl.ShipControls = function(ctx)
|
||||
self.key.forward = true;
|
||||
});
|
||||
}
|
||||
|
||||
function onKeyDown(event)
|
||||
else if(ctx.controlType == 2)
|
||||
{
|
||||
switch(event.keyCode)
|
||||
if(Leap == null)
|
||||
throw new Error("Unable to reach LeapJS!");
|
||||
|
||||
var leapInfo = this.leapInfo = document.getElementById('leapinfo');
|
||||
isServerConnected = false;
|
||||
var lb = this.leapBridge = {
|
||||
isConnected: true,
|
||||
hasHands: false,
|
||||
palmNormal: [0, 0, 0]
|
||||
};
|
||||
|
||||
function updateInfo()
|
||||
{
|
||||
if(!isServerConnected)
|
||||
{
|
||||
leapInfo.innerHTML = 'Waiting for the Leap Motion Controller server...'
|
||||
leapInfo.style.display = 'block';
|
||||
}
|
||||
else if(lb.isConnected && lb.hasHands)
|
||||
{
|
||||
leapInfo.style.display = 'none';
|
||||
}
|
||||
else if(!lb.isConnected)
|
||||
{
|
||||
leapInfo.innerHTML = 'Please connect your Leap Motion Controller.'
|
||||
leapInfo.style.display = 'block';
|
||||
}
|
||||
else if(!lb.hasHands)
|
||||
{
|
||||
leapInfo.innerHTML = 'Put your hand over the Leap Motion Controller to play.'
|
||||
leapInfo.style.display = 'block';
|
||||
}
|
||||
}
|
||||
updateInfo();
|
||||
|
||||
var lc = this.leapController = new Leap.Controller({enableGestures: false});
|
||||
lc.on('connect', function()
|
||||
{
|
||||
isServerConnected = true;
|
||||
updateInfo();
|
||||
});
|
||||
lc.on('deviceConnected', function()
|
||||
{
|
||||
lb.isConnected = true;
|
||||
updateInfo();
|
||||
});
|
||||
lc.on('deviceDisconnected', function()
|
||||
{
|
||||
lb.isConnected = false;
|
||||
updateInfo();
|
||||
});
|
||||
lc.on('frame', function(frame)
|
||||
{
|
||||
if(!lb.isConnected) return;
|
||||
hand = frame.hands[0];
|
||||
if(typeof hand === 'undefined')
|
||||
{
|
||||
if(lb.hasHands)
|
||||
{
|
||||
lb.hasHands = false;
|
||||
updateInfo();
|
||||
}
|
||||
lb.palmNormal = [0, 0, 0];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!lb.hasHands)
|
||||
{
|
||||
lb.hasHands = true;
|
||||
updateInfo();
|
||||
}
|
||||
lb.palmNormal = hand.palmNormal;
|
||||
}
|
||||
});
|
||||
lc.connect();
|
||||
}
|
||||
|
||||
function onKeyDown(event)
|
||||
{
|
||||
switch(event.keyCode)
|
||||
{
|
||||
case 38: /*up*/ self.key.forward = true; break;
|
||||
|
||||
@@ -173,7 +250,7 @@ bkcore.hexgl.ShipControls = function(ctx)
|
||||
}
|
||||
};
|
||||
|
||||
function onKeyUp(event)
|
||||
function onKeyUp(event)
|
||||
{
|
||||
switch(event.keyCode)
|
||||
{
|
||||
@@ -225,11 +302,22 @@ bkcore.hexgl.ShipControls.prototype.reset = function(position, rotation)
|
||||
|
||||
this.dummy.matrix.setPosition(this.dummy.position);
|
||||
this.dummy.matrix.setRotationFromQuaternion(this.dummy.quaternion);
|
||||
|
||||
|
||||
this.mesh.matrix.identity();
|
||||
this.mesh.applyMatrix(this.dummy.matrix);
|
||||
}
|
||||
|
||||
bkcore.hexgl.ShipControls.prototype.terminate = function()
|
||||
{
|
||||
this.destroy();
|
||||
|
||||
if(this.leapController != null)
|
||||
{
|
||||
this.leapController.disconnect();
|
||||
this.leapInfo.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
bkcore.hexgl.ShipControls.prototype.destroy = function()
|
||||
{
|
||||
this.active = false;
|
||||
@@ -239,7 +327,6 @@ bkcore.hexgl.ShipControls.prototype.destroy = function()
|
||||
this.collision.right = false;
|
||||
}
|
||||
|
||||
|
||||
bkcore.hexgl.ShipControls.prototype.fall = function()
|
||||
{
|
||||
this.active = false;
|
||||
@@ -261,8 +348,6 @@ bkcore.hexgl.ShipControls.prototype.update = function(dt)
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.active) return;
|
||||
|
||||
this.rotation.y = 0;
|
||||
this.movement.set(0,0,0);
|
||||
this.drift += (0.0 - this.drift) * this.driftLerp;
|
||||
@@ -270,57 +355,73 @@ bkcore.hexgl.ShipControls.prototype.update = function(dt)
|
||||
|
||||
var rollAmount = 0.0;
|
||||
var angularAmount = 0.0;
|
||||
var yawLeap = 0.0;
|
||||
|
||||
if(this.touchController != null)
|
||||
if(this.leapBridge != null && this.leapBridge.hasHands)
|
||||
{
|
||||
angularAmount -= this.touchController.stickVector.x/100 * this.angularSpeed * dt;
|
||||
rollAmount += this.touchController.stickVector.x/100 * this.rollAngle;
|
||||
}
|
||||
if(this.orientationController != null)
|
||||
{
|
||||
angularAmount += this.orientationController.beta/45 * this.angularSpeed * dt;
|
||||
rollAmount -= this.orientationController.beta/45 * this.rollAngle;
|
||||
rollAmount -= this.leapBridge.palmNormal[0] * 3.5 * this.rollAngle;
|
||||
yawLeap = -this.leapBridge.palmNormal[2] * 0.6;
|
||||
}
|
||||
|
||||
if(this.key.forward)
|
||||
this.speed += this.thrust * dt;
|
||||
else
|
||||
this.speed -= this.airResist * dt;
|
||||
if(this.key.left)
|
||||
{
|
||||
angularAmount += this.angularSpeed * dt;
|
||||
rollAmount -= this.rollAngle;
|
||||
}
|
||||
if(this.key.right)
|
||||
{
|
||||
angularAmount -= this.angularSpeed * dt;
|
||||
rollAmount += this.rollAngle;
|
||||
}
|
||||
if(this.key.ltrigger)
|
||||
if(this.active)
|
||||
{
|
||||
|
||||
if(this.touchController != null)
|
||||
{
|
||||
angularAmount -= this.touchController.stickVector.x/100 * this.angularSpeed * dt;
|
||||
rollAmount += this.touchController.stickVector.x/100 * this.rollAngle;
|
||||
}
|
||||
if(this.orientationController != null)
|
||||
{
|
||||
angularAmount += this.orientationController.beta/45 * this.angularSpeed * dt;
|
||||
rollAmount -= this.orientationController.beta/45 * this.rollAngle;
|
||||
}
|
||||
if(this.leapBridge != null && this.leapBridge.hasHands)
|
||||
{
|
||||
angularAmount += this.leapBridge.palmNormal[0] * 2 * this.angularSpeed * dt;
|
||||
this.speed += Math.max(0.0, (0.5 + this.leapBridge.palmNormal[2])) * 3 * this.thrust * dt;
|
||||
}
|
||||
|
||||
if(this.key.forward)
|
||||
this.speed += this.thrust * dt;
|
||||
else
|
||||
this.speed -= this.airResist * dt;
|
||||
if(this.key.left)
|
||||
angularAmount += this.airAngularSpeed * dt;
|
||||
else
|
||||
angularAmount += this.airAngularSpeed * 0.5 * dt;
|
||||
this.speed -= this.airBrake * dt;
|
||||
this.drift += (this.airDrift - this.drift) * this.driftLerp;
|
||||
this.movement.x += this.speed * this.drift * dt;
|
||||
if(this.drift > 0.0)
|
||||
this.movement.z -= this.speed * this.drift * dt;
|
||||
rollAmount -= this.rollAngle * 0.7;
|
||||
}
|
||||
if(this.key.rtrigger)
|
||||
{
|
||||
{
|
||||
angularAmount += this.angularSpeed * dt;
|
||||
rollAmount -= this.rollAngle;
|
||||
}
|
||||
if(this.key.right)
|
||||
angularAmount -= this.airAngularSpeed * dt;
|
||||
else
|
||||
angularAmount -= this.airAngularSpeed * 0.5 * dt;
|
||||
this.speed -= this.airBrake * dt;
|
||||
this.drift += (-this.airDrift - this.drift) * this.driftLerp;
|
||||
this.movement.x += this.speed * this.drift * dt;
|
||||
if(this.drift < 0.0)
|
||||
this.movement.z += this.speed * this.drift * dt;
|
||||
rollAmount += this.rollAngle * 0.7;
|
||||
{
|
||||
angularAmount -= this.angularSpeed * dt;
|
||||
rollAmount += this.rollAngle;
|
||||
}
|
||||
if(this.key.ltrigger)
|
||||
{
|
||||
if(this.key.left)
|
||||
angularAmount += this.airAngularSpeed * dt;
|
||||
else
|
||||
angularAmount += this.airAngularSpeed * 0.5 * dt;
|
||||
this.speed -= this.airBrake * dt;
|
||||
this.drift += (this.airDrift - this.drift) * this.driftLerp;
|
||||
this.movement.x += this.speed * this.drift * dt;
|
||||
if(this.drift > 0.0)
|
||||
this.movement.z -= this.speed * this.drift * dt;
|
||||
rollAmount -= this.rollAngle * 0.7;
|
||||
}
|
||||
if(this.key.rtrigger)
|
||||
{
|
||||
if(this.key.right)
|
||||
angularAmount -= this.airAngularSpeed * dt;
|
||||
else
|
||||
angularAmount -= this.airAngularSpeed * 0.5 * dt;
|
||||
this.speed -= this.airBrake * dt;
|
||||
this.drift += (-this.airDrift - this.drift) * this.driftLerp;
|
||||
this.movement.x += this.speed * this.drift * dt;
|
||||
if(this.drift < 0.0)
|
||||
this.movement.z += this.speed * this.drift * dt;
|
||||
rollAmount += this.rollAngle * 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
this.angular += (angularAmount - this.angular) * this.angularLerp;
|
||||
@@ -376,7 +477,7 @@ bkcore.hexgl.ShipControls.prototype.update = function(dt)
|
||||
this.mesh.matrix.identity();
|
||||
|
||||
// Gradient (Mesh only, no dummy physics impact)
|
||||
var gradientDelta = (this.gradientTarget - this.gradient) * this.gradientLerp;
|
||||
var gradientDelta = (this.gradientTarget - (yawLeap + this.gradient)) * this.gradientLerp;
|
||||
if(Math.abs(gradientDelta) > this.epsilon) this.gradient += gradientDelta;
|
||||
if(Math.abs(this.gradient) > this.epsilon)
|
||||
{
|
||||
@@ -505,9 +606,9 @@ bkcore.hexgl.ShipControls.prototype.collisionCheck = function(dt)
|
||||
var rPos = this.repulsionVRight.addSelf(pos);
|
||||
var lCol = this.collisionMap.getPixel(Math.round(lPos.x), Math.round(lPos.z)).r;
|
||||
var rCol = this.collisionMap.getPixel(Math.round(rPos.x), Math.round(rPos.z)).r;
|
||||
|
||||
this.repulsionAmount = Math.max(0.8,
|
||||
Math.min(this.repulsionCap,
|
||||
|
||||
this.repulsionAmount = Math.max(0.8,
|
||||
Math.min(this.repulsionCap,
|
||||
this.speed * this.repulsionRatio
|
||||
)
|
||||
);
|
||||
@@ -608,7 +709,7 @@ bkcore.hexgl.ShipControls.prototype.heightCheck = function(dt)
|
||||
x = this.heightMap.pixels.width/2 + this.tiltVector.x * this.heightPixelRatio;
|
||||
z = this.heightMap.pixels.height/2 + this.tiltVector.z * this.heightPixelRatio;
|
||||
|
||||
nheight = this.heightMap.getPixelFBilinear(x, z) / this.heightScale + this.heightBias;
|
||||
nheight = this.heightMap.getPixelFBilinear(x, z) / this.heightScale + this.heightBias;
|
||||
}
|
||||
|
||||
if(nheight < 16777)
|
||||
@@ -626,7 +727,7 @@ bkcore.hexgl.ShipControls.prototype.getRealSpeed = function(scale)
|
||||
bkcore.hexgl.ShipControls.prototype.getRealSpeedRatio = function()
|
||||
{
|
||||
return Math.min(
|
||||
this.maxSpeed,
|
||||
this.maxSpeed,
|
||||
this.speed+this.boost
|
||||
) / this.maxSpeed;
|
||||
};
|
||||
@@ -662,4 +763,4 @@ bkcore.hexgl.ShipControls.prototype.getPosition = function()
|
||||
bkcore.hexgl.ShipControls.prototype.getQuaternion = function()
|
||||
{
|
||||
return this.dummy.quaternion;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* HexGL
|
||||
* @author Thibaut 'BKcore' Despoulain <http://bkcore.com>
|
||||
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
|
||||
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/.
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ bkcore.hexgl.ShipEffects = function(opts)
|
||||
texture: opts.textureSpark,
|
||||
size: 2,
|
||||
life: 60,
|
||||
max: 500
|
||||
max: 200
|
||||
}),
|
||||
|
||||
leftClouds: new bkcore.threejs.Particles(
|
||||
@@ -59,7 +59,7 @@ bkcore.hexgl.ShipEffects = function(opts)
|
||||
size: 6,
|
||||
blending: THREE.NormalBlending,
|
||||
life: 60,
|
||||
max: 500,
|
||||
max: 200,
|
||||
spawn: new THREE.Vector3(3,-0.3,0),
|
||||
spawnRadius: new THREE.Vector3(1,1,2),
|
||||
velocity: new THREE.Vector3(0,0,-0.4),
|
||||
@@ -75,7 +75,7 @@ bkcore.hexgl.ShipEffects = function(opts)
|
||||
texture: opts.textureSpark,
|
||||
size: 2,
|
||||
life: 60,
|
||||
max: 500
|
||||
max: 200
|
||||
}),
|
||||
|
||||
rightClouds: new bkcore.threejs.Particles(
|
||||
@@ -88,7 +88,7 @@ bkcore.hexgl.ShipEffects = function(opts)
|
||||
size: 6,
|
||||
blending: THREE.NormalBlending,
|
||||
life: 60,
|
||||
max: 500,
|
||||
max: 200,
|
||||
spawn: new THREE.Vector3(-3,-0.3,0),
|
||||
spawnRadius: new THREE.Vector3(1,1,2),
|
||||
velocity: new THREE.Vector3(0,0,-0.4),
|
||||
@@ -105,7 +105,7 @@ bkcore.hexgl.ShipEffects = function(opts)
|
||||
|
||||
bkcore.hexgl.ShipEffects.prototype.update = function(dt)
|
||||
{
|
||||
var boostRatio, opacity, scale, intensity, random;
|
||||
var boostRatio, opacity, scale, intensity, random;
|
||||
|
||||
if(this.shipControls.destroyed)
|
||||
{
|
||||
@@ -144,8 +144,8 @@ bkcore.hexgl.ShipEffects.prototype.update = function(dt)
|
||||
this.particles.leftSparks.velocity.copy(this.pVel).x *= -1;
|
||||
this.particles.leftSparks.spawn.copy(this.pOffset).x *= -1;
|
||||
|
||||
if(this.shipControls.mesh)
|
||||
{
|
||||
if(this.shipControls.mesh)
|
||||
{
|
||||
// RIGHT
|
||||
this.shipControls.mesh.matrix.rotateAxis(this.particles.rightSparks.spawn);
|
||||
this.particles.rightSparks.spawn.multiplyScalar(this.pOffsetS).addSelf(this.shipControls.dummy.position);
|
||||
@@ -168,14 +168,14 @@ bkcore.hexgl.ShipEffects.prototype.update = function(dt)
|
||||
|
||||
if(this.shipControls.collision.right)
|
||||
{
|
||||
this.particles.rightSparks.emit(Math.round(30*dt));
|
||||
this.particles.rightClouds.emit(Math.round(10*dt));
|
||||
this.particles.rightSparks.emit(10);
|
||||
this.particles.rightClouds.emit(5);
|
||||
}
|
||||
|
||||
if(this.shipControls.collision.left)
|
||||
{
|
||||
this.particles.leftSparks.emit(Math.round(30*dt));
|
||||
this.particles.leftClouds.emit(Math.round(10*dt));
|
||||
this.particles.leftSparks.emit(10);
|
||||
this.particles.leftClouds.emit(5);
|
||||
}
|
||||
|
||||
this.particles.rightSparks.update(dt);
|
||||
@@ -183,4 +183,4 @@ bkcore.hexgl.ShipEffects.prototype.update = function(dt)
|
||||
this.particles.leftSparks.update(dt);
|
||||
this.particles.leftClouds.update(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* HexGL
|
||||
* @author Thibaut 'BKcore' Despoulain <http://bkcore.com>
|
||||
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
|
||||
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/.
|
||||
*/
|
||||
|
||||
@@ -23,8 +23,8 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
},
|
||||
|
||||
spawn: {
|
||||
x: -1134*2,
|
||||
y: 387,
|
||||
x: -1134*2,
|
||||
y: 387,
|
||||
z: -443*2
|
||||
},
|
||||
|
||||
@@ -46,6 +46,8 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
this.lib.load({
|
||||
textures: {
|
||||
'hex' : "textures/hud/hex.jpg",
|
||||
'spark' : "textures/particles/spark.png",
|
||||
'cloud' : "textures/particles/cloud.png",
|
||||
'ship.feisar.diffuse' : "textures/ships/feisar/diffuse.jpg",
|
||||
'booster.diffuse' : "textures/ships/feisar/booster/booster.png",
|
||||
'booster.sprite' : "textures/ships/feisar/booster/boostersprite.jpg",
|
||||
@@ -82,36 +84,36 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
});
|
||||
}
|
||||
else // HIGH
|
||||
{
|
||||
{console.log('HIGH');
|
||||
this.lib.load({
|
||||
textures: {
|
||||
'hex' : "textures/hud/hex.jpg",
|
||||
'spark' : "textures/particles/spark.png",
|
||||
'cloud' : "textures/particles/cloud.png",
|
||||
'ship.feisar.diffuse' : "textures/ships/feisar/diffuse.jpg",
|
||||
'ship.feisar.specular' : "textures/ships/feisar/specular.jpg",
|
||||
'ship.feisar.normal' : "textures/ships/feisar/normal.jpg",
|
||||
'booster.diffuse' : "textures/ships/feisar/booster/booster.png",
|
||||
'booster.sprite' : "textures/ships/feisar/booster/boostersprite.jpg",
|
||||
'track.cityscape.diffuse' : "textures/tracks/cityscape/diffuse.jpg",
|
||||
'track.cityscape.specular' : "textures/tracks/cityscape/specular.jpg",
|
||||
'track.cityscape.normal' : "textures/tracks/cityscape/normal.jpg",
|
||||
'track.cityscape.scrapers1.diffuse' : "textures/tracks/cityscape/scrapers1/diffuse.jpg",
|
||||
'track.cityscape.scrapers1.specular': "textures/tracks/cityscape/scrapers1/specular.jpg",
|
||||
'track.cityscape.scrapers1.normal' : "textures/tracks/cityscape/scrapers1/normal.jpg",
|
||||
'track.cityscape.scrapers2.diffuse' : "textures/tracks/cityscape/scrapers2/diffuse.jpg",
|
||||
'track.cityscape.scrapers2.specular': "textures/tracks/cityscape/scrapers2/specular.jpg",
|
||||
'track.cityscape.scrapers2.normal' : "textures/tracks/cityscape/scrapers2/normal.jpg",
|
||||
'track.cityscape.start.diffuse' : "textures/tracks/cityscape/start/diffuse.jpg",
|
||||
'track.cityscape.start.specular' : "textures/tracks/cityscape/start/specular.jpg",
|
||||
'track.cityscape.start.normal' : "textures/tracks/cityscape/start/normal.jpg",
|
||||
'track.cityscape.start.banner' : "textures/tracks/cityscape/start/start.jpg",
|
||||
'bonus.base.diffuse' : "textures/bonus/base/diffuse.jpg",
|
||||
'bonus.base.normal' : "textures/bonus/base/normal.jpg",
|
||||
'bonus.base.specular' : "textures/bonus/base/specular.jpg"
|
||||
'hex' : "textures.full/hud/hex.jpg",
|
||||
'spark' : "textures.full/particles/spark.png",
|
||||
'cloud' : "textures.full/particles/cloud.png",
|
||||
'ship.feisar.diffuse' : "textures.full/ships/feisar/diffuse.jpg",
|
||||
'ship.feisar.specular' : "textures.full/ships/feisar/specular.jpg",
|
||||
'ship.feisar.normal' : "textures.full/ships/feisar/normal.jpg",
|
||||
'booster.diffuse' : "textures.full/ships/feisar/booster/booster.png",
|
||||
'booster.sprite' : "textures.full/ships/feisar/booster/boostersprite.jpg",
|
||||
'track.cityscape.diffuse' : "textures.full/tracks/cityscape/diffuse.jpg",
|
||||
'track.cityscape.specular' : "textures.full/tracks/cityscape/specular.jpg",
|
||||
'track.cityscape.normal' : "textures.full/tracks/cityscape/normal.jpg",
|
||||
'track.cityscape.scrapers1.diffuse' : "textures.full/tracks/cityscape/scrapers1/diffuse.jpg",
|
||||
'track.cityscape.scrapers1.specular': "textures.full/tracks/cityscape/scrapers1/specular.jpg",
|
||||
'track.cityscape.scrapers1.normal' : "textures.full/tracks/cityscape/scrapers1/normal.jpg",
|
||||
'track.cityscape.scrapers2.diffuse' : "textures.full/tracks/cityscape/scrapers2/diffuse.jpg",
|
||||
'track.cityscape.scrapers2.specular': "textures.full/tracks/cityscape/scrapers2/specular.jpg",
|
||||
'track.cityscape.scrapers2.normal' : "textures.full/tracks/cityscape/scrapers2/normal.jpg",
|
||||
'track.cityscape.start.diffuse' : "textures.full/tracks/cityscape/start/diffuse.jpg",
|
||||
'track.cityscape.start.specular' : "textures.full/tracks/cityscape/start/specular.jpg",
|
||||
'track.cityscape.start.normal' : "textures.full/tracks/cityscape/start/normal.jpg",
|
||||
'track.cityscape.start.banner' : "textures.full/tracks/cityscape/start/start.jpg",
|
||||
'bonus.base.diffuse' : "textures.full/bonus/base/diffuse.jpg",
|
||||
'bonus.base.normal' : "textures.full/bonus/base/normal.jpg",
|
||||
'bonus.base.specular' : "textures.full/bonus/base/specular.jpg"
|
||||
},
|
||||
texturesCube: {
|
||||
'skybox.dawnclouds' : "textures/skybox/dawnclouds/%1.jpg"
|
||||
'skybox.dawnclouds' : "textures.full/skybox/dawnclouds/%1.jpg"
|
||||
},
|
||||
geometries: {
|
||||
'bonus.base' : "geometries/bonus/base/base.js",
|
||||
@@ -125,13 +127,13 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
'track.cityscape.bonus.speed' : "geometries/tracks/cityscape/bonus/speed.js"
|
||||
},
|
||||
analysers: {
|
||||
'track.cityscape.collision' : "textures/tracks/cityscape/collision.png",
|
||||
'track.cityscape.height' : "textures/tracks/cityscape/height.png"
|
||||
'track.cityscape.collision' : "textures.full/tracks/cityscape/collision.png",
|
||||
'track.cityscape.height' : "textures.full/tracks/cityscape/height.png"
|
||||
},
|
||||
images: {
|
||||
'hud.bg' : "textures/hud/hud-bg.png",
|
||||
'hud.speed' : "textures/hud/hud-fg-speed.png",
|
||||
'hud.shield' : "textures/hud/hud-fg-shield.png"
|
||||
'hud.bg' : "textures.full/hud/hud-bg.png",
|
||||
'hud.speed' : "textures.full/hud/hud-fg-speed.png",
|
||||
'hud.shield' : "textures.full/hud/hud-fg-shield.png"
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -161,7 +163,7 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
});
|
||||
|
||||
this.materials.booster = new THREE.MeshBasicMaterial({
|
||||
map: this.lib.get("textures", "booster.diffuse"),
|
||||
map: this.lib.get("textures", "booster.diffuse"),
|
||||
transparent: true
|
||||
});
|
||||
|
||||
@@ -177,11 +179,11 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
|
||||
this.materials.start = new THREE.MeshBasicMaterial({
|
||||
map: this.lib.get("textures", "track.cityscape.start.diffuse"),
|
||||
ambient: 0xcccccc
|
||||
ambient: 0xcccccc
|
||||
});
|
||||
|
||||
this.materials.startBanner = new THREE.MeshBasicMaterial({
|
||||
map: this.lib.get("textures", "track.cityscape.start.banner"),
|
||||
map: this.lib.get("textures", "track.cityscape.start.banner"),
|
||||
transparent: false
|
||||
});
|
||||
}
|
||||
@@ -223,7 +225,7 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
});
|
||||
|
||||
this.materials.booster = new THREE.MeshBasicMaterial({
|
||||
map: this.lib.get("textures", "booster.diffuse"),
|
||||
map: this.lib.get("textures", "booster.diffuse"),
|
||||
transparent: true
|
||||
});
|
||||
|
||||
@@ -262,7 +264,7 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
});
|
||||
|
||||
this.materials.startBanner = new THREE.MeshBasicMaterial({
|
||||
map: this.lib.get("textures", "track.cityscape.start.banner"),
|
||||
map: this.lib.get("textures", "track.cityscape.start.banner"),
|
||||
transparent: false
|
||||
});
|
||||
}
|
||||
@@ -299,9 +301,9 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
|
||||
var ambient = 0xbbbbbb, diffuse = 0xffffff, specular = 0xffffff, shininess = 42, scale = 23;
|
||||
|
||||
// MAIN SCENE
|
||||
// MAIN SCENE
|
||||
var camera = new THREE.PerspectiveCamera( 70, ctx.width / ctx.height, 1, 60000 );
|
||||
|
||||
|
||||
var scene = new THREE.Scene();
|
||||
scene.add( camera );
|
||||
scene.add( new THREE.AmbientLight( ambient ) );
|
||||
@@ -330,15 +332,15 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
|
||||
// SHIP
|
||||
var ship = ctx.createMesh(scene, this.lib.get("geometries", "ship.feisar"), -1134*2, 10, -443*2, this.materials.ship);
|
||||
|
||||
|
||||
var booster = ctx.createMesh(ship, this.lib.get("geometries", "booster"), 0, 0.665, -3.8, this.materials.booster);
|
||||
booster.depthWrite = false;
|
||||
|
||||
var boosterSprite = new THREE.Sprite({
|
||||
map: this.lib.get("textures", "booster.sprite"),
|
||||
blending: THREE.AdditiveBlending,
|
||||
useScreenCoordinates: false,
|
||||
color: 0xffffff
|
||||
var boosterSprite = new THREE.Sprite({
|
||||
map: this.lib.get("textures", "booster.sprite"),
|
||||
blending: THREE.AdditiveBlending,
|
||||
useScreenCoordinates: false,
|
||||
color: 0xffffff
|
||||
});
|
||||
boosterSprite.scale.set(0.02, 0.02, 0.02);
|
||||
boosterSprite.mergeWith3D = false;
|
||||
@@ -408,7 +410,7 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
var dt = delta/16.6;
|
||||
|
||||
this.objects.components.shipControls.update(dt);
|
||||
|
||||
|
||||
this.objects.components.shipEffects.update(dt);
|
||||
|
||||
this.objects.components.cameraChase.update(dt, this.objects.components.shipControls.getSpeedRatio());
|
||||
@@ -424,9 +426,9 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
|
||||
this.objects.composers.game.render(dt);
|
||||
if(this.objects.hud) this.objects.hud.update(
|
||||
this.objects.components.shipControls.getRealSpeed(100),
|
||||
this.objects.components.shipControls.getRealSpeedRatio(),
|
||||
this.objects.components.shipControls.getShield(100),
|
||||
this.objects.components.shipControls.getRealSpeed(100),
|
||||
this.objects.components.shipControls.getRealSpeedRatio(),
|
||||
this.objects.components.shipControls.getShield(100),
|
||||
this.objects.components.shipControls.getShieldRatio()
|
||||
);
|
||||
if(this.objects.components.shipControls.getShieldRatio() < 0.2)
|
||||
@@ -444,4 +446,4 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
lowFPS: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user