diff --git a/bkcore/hexgl/HexGL.js b/bkcore/hexgl/HexGL.js index 657e798..f2bf8f5 100644 --- a/bkcore/hexgl/HexGL.js +++ b/bkcore/hexgl/HexGL.js @@ -19,18 +19,20 @@ bkcore.hexgl.HexGL = function(opts) this.a = window.location.href; - this.mobile = opts.mobile == undefined ? false : opts.mobile; this.active = true; this.displayHUD = opts.hud == undefined ? true : opts.hud; this.width = opts.width == undefined ? window.innerWidth : opts.width; this.height = opts.height == undefined ? window.innerHeight : opts.height; this.quality = opts.quality == undefined ? 2 : opts.quality; + + // TODO remove mobile variable + var mobile = true; + this.half = mobile && this.quality < 1; + this.difficulty = opts.difficulty == undefined ? 0 : opts.difficulty; this.player = opts.player == undefined ? "Anonym" : opts.player; - this.half = opts.half == undefined ? false : opts.half; - this.track = bkcore.hexgl.tracks[ opts.track == undefined ? 'Cityscape' : opts.track ]; this.mode = opts.mode == undefined ? 'timeattack' : opts.mode; @@ -129,17 +131,17 @@ bkcore.hexgl.HexGL.prototype.update = function() bkcore.hexgl.HexGL.prototype.init = function() { this.initHUD(); + + this.track.buildMaterials(this.quality); - this.track.buildMaterials(this.quality, this.mobile); - - this.track.buildScenes(this, this.quality, this.mobile); + this.track.buildScenes(this, this.quality); this.initGameComposer(); } bkcore.hexgl.HexGL.prototype.load = function(opts) { - this.track.load(opts, this.quality, this.mobile); + this.track.load(opts, this.quality); } bkcore.hexgl.HexGL.prototype.initGameplay = function() @@ -272,8 +274,11 @@ bkcore.hexgl.HexGL.prototype.initRenderer = function() clearColor: 0x000000 }); - - if(this.quality > 0 && !this.mobile) + // TODO remove mobile var + var mobile = true; + + // desktop + quality mid or high + if(this.quality > 0 && !mobile) { renderer.physicallyBasedShading = true; renderer.gammaInput = true; @@ -344,8 +349,14 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function() // this.composers.game.addPass( effectFXAA ); // this.extras.fxaa = effectFXAA; + // } - if(this.quality > 1 && !this.mobile) + + // TODO remove mobile var + var mobile = true; + + // desktop + quality mid or high + if(this.quality > 1 && !mobile) { var effectBloom = new THREE.BloomPass( 0.8, 25, 4 , 256); @@ -354,7 +365,11 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function() this.extras.bloom = effectBloom; } - if(!this.mobile || this.quality > 0) + // TODO remove mobile var + // desktop + quality low, mid or high + // OR + // mobile + quality mid or high + if(!mobile || this.quality > 0) this.composers.game.addPass( effectHex ); else this.composers.game.addPass( effectScreen ); @@ -370,7 +385,11 @@ bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, ma mesh.position.set( x, y, z ); parent.add(mesh); - if(this.quality > 0 && !this.mobile) + // TODO remove mobile var + var mobile = true; + + // desktop + quality mid or high + if(this.quality > 0 && !mobile) { mesh.castShadow = true; mesh.receiveShadow = true; diff --git a/bkcore/hexgl/tracks/Cityscape.js b/bkcore/hexgl/tracks/Cityscape.js index 5f5ecf2..dd6522b 100644 --- a/bkcore/hexgl/tracks/Cityscape.js +++ b/bkcore/hexgl/tracks/Cityscape.js @@ -37,10 +37,16 @@ bkcore.hexgl.tracks.Cityscape = { analyser: null, pixelRatio: 2048.0 / 6000.0, - load: function(opts, quality, mobile) + load: function(opts, quality) { + // TODO remove mobile var + var mobile = true; + this.lib = new bkcore.threejs.Loader(opts); + // desktop + quality low + // OR + // mobile + quality low or mid if((quality < 1 && !mobile) || quality < 2) // LOW { this.lib.load({ @@ -83,6 +89,9 @@ bkcore.hexgl.tracks.Cityscape = { } }); } + // desktop + quality mid or high + // OR + // mobile + quality high else // HIGH {console.log('HIGH'); this.lib.load({ @@ -139,8 +148,14 @@ bkcore.hexgl.tracks.Cityscape = { } }, - buildMaterials: function(quality, mobile) + buildMaterials: function(quality) { + // TODO remove mobile var + var mobile = true; + + // desktop + quality low + // OR + // mobile + quality low or mid if((quality < 1 && !mobile) || quality < 2) // LOW { this.materials.track = new THREE.MeshBasicMaterial({ @@ -187,6 +202,9 @@ bkcore.hexgl.tracks.Cityscape = { transparent: false }); } + // desktop + quality mid or high + // OR + // mobile + quality high else // HIGH { this.materials.track = bkcore.Utils.createNormalMaterial({ @@ -270,8 +288,11 @@ bkcore.hexgl.tracks.Cityscape = { } }, - buildScenes: function(ctx, quality, mobile) + buildScenes: function(ctx, quality) { + // TODO remove mobile var + var mobile = true; + // IMPORTANT this.analyser = this.lib.get("analysers", "track.cityscape.collision"); @@ -313,6 +334,7 @@ bkcore.hexgl.tracks.Cityscape = { sun.position.set( -4000, 1200, 1800 ); sun.lookAt(new THREE.Vector3()); + // desktop + quality mid or high if(quality > 0 && !mobile) { sun.castShadow = true; @@ -348,6 +370,8 @@ bkcore.hexgl.tracks.Cityscape = { var boosterLight = new THREE.PointLight(0x00a2ff, 4.0, 60); boosterLight.position.set(0, 0.665, -4); + + // desktop or mobile + quality mid or high if(quality > 0) ship.add(boosterLight); @@ -373,6 +397,8 @@ bkcore.hexgl.tracks.Cityscape = { boosterLight: boosterLight, useParticles: false }; + + // desktop + quality mid or high if(quality > 0 && !mobile) { fxParams.textureCloud = this.lib.get("textures", "cloud"); diff --git a/launch.coffee b/launch.coffee index 6f23649..ad8bbe3 100644 --- a/launch.coffee +++ b/launch.coffee @@ -1,6 +1,6 @@ $ = (_) -> document.getElementById _ -init = (controlType, quality, platform, godmode) -> +init = (controlType, quality, hud, godmode) -> hexGL = new bkcore.hexgl.HexGL( document: document width: window.innerWidth @@ -9,10 +9,8 @@ init = (controlType, quality, platform, godmode) -> overlay: $ 'overlay' gameover: $ 'step-5' quality: quality - difficulty: 0, - half: (platform is 1 and quality < 1) - mobile: platform is 1 - hud: platform is 0 + difficulty: 0 + hud: hud is 1 controlType: controlType godmode: godmode track: 'Cityscape' @@ -38,9 +36,10 @@ u = bkcore.Utils.getURLParameter s = [ ['controlType', ['KEYBOARD', 'TOUCH', 'LEAP MOTION CONTROLLER', 'GAMEPAD'], 0, 0, 'Controls: '] ['quality', ['LOW', 'MID', 'HIGH'], 2, 2, 'Quality: '] - ['platform', ['DESKTOP', 'MOBILE'], 0, 0, 'Platform: '] + ['hud', ['OFF', 'ON'], 1, 1, 'HUD: '] ['godmode', ['OFF', 'ON'], 0, 1, 'Godmode: '] ] + for a in s do(a)-> a[3] = u(a[0]) ? a[2] diff --git a/launch.js b/launch.js index 8e41b00..e61a259 100644 --- a/launch.js +++ b/launch.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.4.0 +// Generated by CoffeeScript 1.7.1 (function() { var $, a, getWebGL, hasWebGL, init, s, u, _fn, _i, _len; @@ -6,7 +6,7 @@ return document.getElementById(_); }; - init = function(controlType, quality, platform, godmode) { + init = function(controlType, quality, hud, godmode) { var hexGL, progressbar; hexGL = new bkcore.hexgl.HexGL({ document: document, @@ -17,9 +17,7 @@ gameover: $('step-5'), quality: quality, difficulty: 0, - half: platform === 1 && quality < 1, - mobile: platform === 1, - hud: platform === 0, + hud: hud === 1, controlType: controlType, godmode: godmode, track: 'Cityscape' @@ -46,7 +44,7 @@ u = bkcore.Utils.getURLParameter; - s = [['controlType', ['KEYBOARD', 'TOUCH', 'LEAP MOTION CONTROLLER', 'GAMEPAD'], 0, 0, 'Controls: '], ['quality', ['LOW', 'MID', 'HIGH'], 2, 2, 'Quality: '], ['platform', ['DESKTOP', 'MOBILE'], 0, 0, 'Platform: '], ['godmode', ['OFF', 'ON'], 0, 1, 'Godmode: ']]; + s = [['controlType', ['KEYBOARD', 'TOUCH', 'LEAP MOTION CONTROLLER', 'GAMEPAD'], 0, 0, 'Controls: '], ['quality', ['LOW', 'MID', 'HIGH'], 2, 2, 'Quality: '], ['hud', ['OFF', 'ON'], 1, 1, 'HUD: '], ['godmode', ['OFF', 'ON'], 0, 1, 'Godmode: ']]; _fn = function(a) { var e, f, _ref;