Skip to content

Commit 431b54e

Browse files
author
Thibaut Despoulain
committed
Leap motion integration. HTML interface redesign. Merge all controls into a single index.
1 parent 8c420e5 commit 431b54e

17 files changed

+929
-210
lines changed

bkcore/hexgl/HexGL.js

+25-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* HexGL
33
* @author Thibaut 'BKcore' Despoulain <http://bkcore.com>
4-
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
4+
* @license This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License.
55
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/.
66
*/
77

@@ -73,9 +73,9 @@ bkcore.hexgl.HexGL = function(opts)
7373

7474
this.initRenderer();
7575

76-
function onKeyPress(event)
76+
function onKeyPress(event)
7777
{
78-
if(event.keyCode == 27/*escape*/)
78+
if(event.keyCode == 27/*escape*/)
7979
{
8080
self.reset();
8181
}
@@ -155,6 +155,7 @@ bkcore.hexgl.HexGL.prototype.initGameplay = function()
155155
pixelRatio: this.track.pixelRatio,
156156
track: this.track,
157157
onFinish: function() {
158+
self.components.shipControls.terminate();
158159
self.displayScore(this.finishTime, this.lapTimes);
159160
}
160161
});
@@ -173,12 +174,12 @@ bkcore.hexgl.HexGL.prototype.displayScore = function(f, l)
173174
bkcore.Timer.msToTimeString(l[2])
174175
];
175176

176-
if(this.mobile)
177+
if(this.gameover !== null)
177178
{
178179
this.gameover.style.display = "block";
179-
this.gameover.innerHTML = tf.m + "'" + tf.s + "''" + tf.ms;
180-
this.containers.main.style.display = "none";
181-
return;
180+
this.gameover.children[0].innerHTML = tf.m + "'" + tf.s + "''" + tf.ms;
181+
this.containers.main.parentElement.style.display = "none";
182+
return;
182183
}
183184

184185
var t = this.track;
@@ -286,7 +287,7 @@ bkcore.hexgl.HexGL.prototype.initRenderer = function()
286287
renderer.setSize( this.width, this.height );
287288
renderer.domElement.style.position = "relative";
288289

289-
this.containers.main.appendChild( renderer.domElement );
290+
this.containers.main.appendChild( renderer.domElement );
290291
this.canvas = renderer.domElement;
291292
this.renderer = renderer;
292293
this.manager = new bkcore.threejs.RenderManager(renderer);
@@ -302,7 +303,7 @@ bkcore.hexgl.HexGL.prototype.initHUD = function()
302303
bg: this.track.lib.get("images", "hud.bg"),
303304
speed: this.track.lib.get("images", "hud.speed"),
304305
shield: this.track.lib.get("images", "hud.shield")
305-
});
306+
});
306307
this.containers.overlay.appendChild(this.hud.canvas);
307308
}
308309

@@ -311,16 +312,16 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
311312
var renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
312313
var renderTarget = new THREE.WebGLRenderTarget( this.width, this.height, renderTargetParameters );
313314

314-
// GAME COMPOSER
315+
// GAME COMPOSER
315316
var renderSky = new THREE.RenderPass( this.manager.get("sky").scene, this.manager.get("sky").camera );
316317

317318
var renderModel = new THREE.RenderPass( this.manager.get("game").scene, this.manager.get("game").camera );
318319
renderModel.clear = false;
319320

320321
this.composers.game = new THREE.EffectComposer( this.renderer, renderTarget );
321322

322-
var effectScreen = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
323-
effectScreen.renderToScreen = true;
323+
var effectScreen = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
324+
effectScreen.renderToScreen = true;
324325
var effectVignette = new THREE.ShaderPass( THREE.ShaderExtras[ "vignette" ] );
325326

326327
var effectHex = new THREE.ShaderPass( bkcore.threejs.Shaders[ "hexvignette" ] );
@@ -335,17 +336,17 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
335336
this.composers.game.addPass( renderSky );
336337
this.composers.game.addPass( renderModel );
337338

338-
if(this.quality > 0 && !this.mobile)
339-
{
340-
var effectFXAA = new THREE.ShaderPass( THREE.ShaderExtras[ "fxaa" ] );
341-
effectFXAA.uniforms[ 'resolution' ].value.set( 1 / this.width, 1 / this.height );
339+
// if(this.quality > 0 && !this.mobile)
340+
// {
341+
// var effectFXAA = new THREE.ShaderPass( THREE.ShaderExtras[ "fxaa" ] );
342+
// effectFXAA.uniforms[ 'resolution' ].value.set( 1 / this.width, 1 / this.height );
342343

343-
this.composers.game.addPass( effectFXAA );
344-
345-
this.extras.fxaa = effectFXAA;
346-
}
344+
// this.composers.game.addPass( effectFXAA );
345+
346+
// this.extras.fxaa = effectFXAA;
347+
// }
347348
if(this.quality > 1 && !this.mobile)
348-
{
349+
{
349350
var effectBloom = new THREE.BloomPass( 0.8, 25, 4 , 256);
350351

351352
this.composers.game.addPass( effectBloom );
@@ -358,10 +359,10 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
358359
else
359360
this.composers.game.addPass( effectScreen );
360361

361-
362+
362363
}
363364

364-
bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, mat)
365+
bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, mat)
365366
{
366367
geometry.computeTangents();
367368

@@ -422,4 +423,4 @@ bkcore.hexgl.HexGL.prototype.tweakShipControls = function()
422423

423424
if(this.godmode)
424425
c.shieldDamage = 0.0;
425-
}
426+
}

0 commit comments

Comments
 (0)