Localise all references to 'mobile'

Remove the mobile property and set it locally in each location
where it is used (preparation for iterating the different
platform+quality combinations which affect the graphics).

Mark each point where a decision is made based on platform+quality
with a plain English version of the combinations which take
effect and when.

Add an explicit hud property which is set from the start screen
and which is independent of the platform.
This commit is contained in:
Elliot Smith
2014-05-30 11:39:02 +01:00
parent fdc7e913fc
commit 4886f1d9d0
4 changed files with 69 additions and 27 deletions
+31 -12
View File
@@ -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;
+29 -3
View File
@@ -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");