Merge pull request #22 from townxelliot/no-mobile-setting-take2-21

Remove platform option and use HUD option instead
This commit is contained in:
Thibaut Despoulain
2014-06-01 18:35:17 -07:00
5 changed files with 68 additions and 38 deletions
+27 -17
View File
@@ -19,25 +19,30 @@ 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;
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;
this.controlType = opts.controlType == undefined ? 1 : opts.controlType;
// 0 == low, 1 == mid, 2 == high, 3 == very high
// the old platform+quality combinations map to these new quality values
// as follows:
// mobile + low quality => 0 (LOW)
// mobile + mid quality OR desktop + low quality => 1 (MID)
// mobile + high quality => 2 (HIGH)
// desktop + mid or high quality => 3 (VERY HIGH)
this.quality = opts.quality == undefined ? 3 : opts.quality;
if(this.half)
if(this.quality === 0)
{
this.width /= 2;
this.height /=2;
@@ -129,17 +134,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 +277,8 @@ bkcore.hexgl.HexGL.prototype.initRenderer = function()
clearColor: 0x000000
});
if(this.quality > 0 && !this.mobile)
// desktop + quality mid or high
if(this.quality > 2)
{
renderer.physicallyBasedShading = true;
renderer.gammaInput = true;
@@ -344,8 +349,11 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
// this.composers.game.addPass( effectFXAA );
// this.extras.fxaa = effectFXAA;
// }
if(this.quality > 1 && !this.mobile)
// desktop + quality mid or high
if(this.quality > 2)
{
var effectBloom = new THREE.BloomPass( 0.8, 25, 4 , 256);
@@ -354,12 +362,13 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
this.extras.bloom = effectBloom;
}
if(!this.mobile || this.quality > 0)
// desktop + quality low, mid or high
// OR
// mobile + quality mid or high
if(this.quality > 0)
this.composers.game.addPass( effectHex );
else
this.composers.game.addPass( effectScreen );
}
bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, mat)
@@ -370,7 +379,8 @@ 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)
// desktop + quality mid or high
if(this.quality > 2)
{
mesh.castShadow = true;
mesh.receiveShadow = true;
+30 -7
View File
@@ -37,11 +37,14 @@ bkcore.hexgl.tracks.Cityscape = {
analyser: null,
pixelRatio: 2048.0 / 6000.0,
load: function(opts, quality, mobile)
load: function(opts, quality)
{
this.lib = new bkcore.threejs.Loader(opts);
if((quality < 1 && !mobile) || quality < 2) // LOW
// desktop + quality low
// OR
// mobile + quality low or mid
if(quality < 2) // LOW
{
this.lib.load({
textures: {
@@ -83,6 +86,9 @@ bkcore.hexgl.tracks.Cityscape = {
}
});
}
// desktop + quality mid or high
// OR
// mobile + quality high
else // HIGH
{console.log('HIGH');
this.lib.load({
@@ -139,9 +145,12 @@ bkcore.hexgl.tracks.Cityscape = {
}
},
buildMaterials: function(quality, mobile)
buildMaterials: function(quality)
{
if((quality < 1 && !mobile) || quality < 2) // LOW
// desktop + quality low
// OR
// mobile + quality low or mid
if(quality < 2) // LOW
{
this.materials.track = new THREE.MeshBasicMaterial({
map: this.lib.get("textures", "track.cityscape.diffuse"),
@@ -187,6 +196,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,7 +282,7 @@ bkcore.hexgl.tracks.Cityscape = {
}
},
buildScenes: function(ctx, quality, mobile)
buildScenes: function(ctx, quality)
{
// IMPORTANT
this.analyser = this.lib.get("analysers", "track.cityscape.collision");
@@ -313,7 +325,8 @@ bkcore.hexgl.tracks.Cityscape = {
sun.position.set( -4000, 1200, 1800 );
sun.lookAt(new THREE.Vector3());
if(quality > 0 && !mobile)
// desktop + quality mid or high
if(quality > 2)
{
sun.castShadow = true;
sun.shadowCameraNear = 50;
@@ -348,6 +361,14 @@ bkcore.hexgl.tracks.Cityscape = {
var boosterLight = new THREE.PointLight(0x00a2ff, 4.0, 60);
boosterLight.position.set(0, 0.665, -4);
// desktop + quality low, mid or high
// OR
// mobile + quality mid or high
// NB booster is now enabled on desktop + low quality,
// when it wasn't before; this is because this booster setting
// is the only difference between mobile + mid quality
// and desktop + low quality, so I merged them for convenience
if(quality > 0)
ship.add(boosterLight);
@@ -373,7 +394,9 @@ bkcore.hexgl.tracks.Cityscape = {
boosterLight: boosterLight,
useParticles: false
};
if(quality > 0 && !mobile)
// desktop + quality mid or high
if(quality > 2)
{
fxParams.textureCloud = this.lib.get("textures", "cloud");
fxParams.textureSpark = this.lib.get("textures", "spark");