Skip to content

Commit

Permalink
_cons to cons
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemledelec committed Mar 13, 2018
1 parent f4b7fe7 commit a3bd349
Show file tree
Hide file tree
Showing 11 changed files with 5,027 additions and 457 deletions.
5,351 changes: 4,946 additions & 405 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -22,14 +22,14 @@
},
"homepage": "http://www.openglobus.org",
"dependencies": {
"google-closure-library": "^20170910.0.0"
"webpack-cli": "^2.0.11"
},
"devDependencies": {
"babel-eslint": "^8.0.0",
"eslint": "^4.0.0",
"eslint-config-defaults": "^9.0.0",
"eslint-plugin-react": "^7.3.0",
"webpack": "^4.0.1"
"webpack": "^4.1.1"
},
"keywords": [
"map",
Expand Down
4 changes: 2 additions & 2 deletions src/og/console.js → src/og/cons.js
Expand Up @@ -4,7 +4,7 @@
* Console logging singleton object.
* @class
*/
export class Console {
export class Cons {
constructor() {
this._container = document.createElement("div");
this._container.classList.add("ogConsole");
Expand Down Expand Up @@ -95,5 +95,5 @@ export class Console {
}
}

export const _cons = new Console();
export const cons = new Cons();

3 changes: 3 additions & 0 deletions src/og/index.js
@@ -0,0 +1,3 @@
'use strict';

import { Globe } from './Globe.js';
2 changes: 1 addition & 1 deletion src/og/quadTree/EntityCollectionNode.js
Expand Up @@ -221,7 +221,7 @@ EntityCollectionNode.prototype.collectRenderCollectionsPASS2 = function (visible
var cam = p.renderer.activeCamera;

var altVis = (cam.eye.distance(this.bsphere.center) - this.bsphere.radius <
quadTree.Node.VISIBLE_DISTANCE * Math.sqrt(cam._lonLat.height)) || cam._lonLat.height > 10000;
quadTree.VISIBLE_DISTANCE * Math.sqrt(cam._lonLat.height)) || cam._lonLat.height > 10000;

if (this.count > 0 && altVis &&
p.renderer.activeCamera.frustum.containsSphere(this.bsphere) > 0) {
Expand Down
3 changes: 1 addition & 2 deletions src/og/quadTree/Node.js
Expand Up @@ -13,7 +13,6 @@ import { EPSG4326 } from '../proj/EPSG4326.js';
import { EPSG3857 } from '../proj/EPSG3857.js';
import { Vec3 } from '../math/Vec3.js';

const VISIBLE_DISTANCE = 3570;

/**
* Returns triangle coordinate array from inside of the source triangle array.
Expand Down Expand Up @@ -302,7 +301,7 @@ Node.prototype.renderTree = function (maxZoom) {
var onlyTerrain = !inFrustum && underBottom;

var altVis = cam.eye.distance(seg.bsphere.center) - seg.bsphere.radius <
VISIBLE_DISTANCE * Math.sqrt(h);
quadTree.VISIBLE_DISTANCE * Math.sqrt(h);

if (inFrustum || onlyTerrain || this._cameraInside) {
if (seg.tileZoom < 2 && seg.normalMapReady) {
Expand Down
2 changes: 2 additions & 0 deletions src/og/quadTree/quadTree.js
Expand Up @@ -4,6 +4,8 @@

'use strict';

export const VISIBLE_DISTANCE = 3570;

export const NW = 0;
export const NE = 1;
export const SW = 2;
Expand Down
6 changes: 3 additions & 3 deletions src/og/renderer/renderer.js
Expand Up @@ -11,7 +11,7 @@ import { randomi } from '../math.js';
import { RendererEvents } from './RendererEvents.js';
import { Vec2 } from '../math/Vec2.js';
import { Vec3 } from '../math/Vec3.js';
import { _cons } from '../Console.js';
import { cons } from '../cons.js';
import { ShaderProgram } from '../webgl/ShaderProgram.js';
import { types } from '../webgl/types.js';
import { input } from '../input/input.js';
Expand Down Expand Up @@ -302,7 +302,7 @@ class Renderer {

//Bind console key
this.events.on("charkeypress", input.KEY_APOSTROPHE, function () {
_cons.setVisibility(!_cons.getVisibility());
cons.setVisibility(!cons.getVisibility());
});

this.handler.onCanvasResize = function (obj) {
Expand Down Expand Up @@ -376,7 +376,7 @@ class Renderer {
this._renderNodesArr.unshift(renderNode);
this.renderNodes[renderNode.name] = renderNode;
} else {
_cons.logWrn("og.Renderer(370) - node name: " + renderNode.name + " allready exists.");
cons.logWrn("og.Renderer(370) - node name: " + renderNode.name + " allready exists.");
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/og/webgl/ShaderProgram.js
Expand Up @@ -5,7 +5,7 @@
'use strict';

import { callbacks } from './callbacks.js';
import { _cons } from '../console.js';
import { cons } from '../cons.js';

/**
* Represents more comfortable using WebGL shader program.
Expand Down Expand Up @@ -155,7 +155,7 @@ class ShaderProgram {
this.gl.shaderSource(shader, src);
this.gl.compileShader(shader);
if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
_cons.logErr("og/shaderProgram/ShaderProgram:" + this.name + " - " + this.gl.getShaderInfoLog(shader) + ".");
cons.logErr("og/shaderProgram/ShaderProgram:" + this.name + " - " + this.gl.getShaderInfoLog(shader) + ".");
return false;
}
return true;
Expand Down Expand Up @@ -239,7 +239,7 @@ class ShaderProgram {
gl.linkProgram(this._p);

if (!gl.getProgramParameter(this._p, gl.LINK_STATUS)) {
_cons.logErr("og/shaderProgram/ShaderProgram:" + this.name + " - couldn't initialise shaders. " + gl.getProgramInfoLog(this._p) + ".");
cons.logErr("og/shaderProgram/ShaderProgram:" + this.name + " - couldn't initialise shaders. " + gl.getProgramInfoLog(this._p) + ".");
gl.deleteProgram(this._p);
return;
}
Expand All @@ -260,7 +260,7 @@ class ShaderProgram {
this._p[a] = gl.getAttribLocation(this._p, a);

if (this._p[a] == undefined) {
_cons.logErr("og/shaderProgram/ShaderProgram:" + this.name + " - attribute '" + a + "' is not exists.");
cons.logErr("og/shaderProgram/ShaderProgram:" + this.name + " - attribute '" + a + "' is not exists.");
gl.deleteProgram(this._p);
return;
}
Expand All @@ -280,7 +280,7 @@ class ShaderProgram {
this._p[u] = gl.getUniformLocation(this._p, u);

if (this._p[u] == undefined) {
_cons.logErr("og/shaderProgram/ShaderProgram:" + this.name + " - uniform '" + u + "' is not exists.");
cons.logErr("og/shaderProgram/ShaderProgram:" + this.name + " - uniform '" + u + "' is not exists.");
gl.deleteProgram(this._p);
return;
}
Expand Down
10 changes: 5 additions & 5 deletions src/og/webgl/handler.js
Expand Up @@ -4,7 +4,7 @@

'use strict';

import { _cons } from '../Console.js';
import { cons } from '../cons.js';
import { Clock } from '../Clock.js';
import { ImageCanvas } from '../ImageCanvas.js';
import { ShaderController } from './ShaderController.js';
Expand Down Expand Up @@ -172,10 +172,10 @@ class Handler {
//ctx.canvas = canvas;
}
catch (ex) {
_cons.logErr("exception during the GL context initialization");
cons.logErr("exception during the GL context initialization");
}
if (!ctx) {
_cons.logErr("could not initialise WebGL");
cons.logErr("could not initialise WebGL");
}
return ctx;
}
Expand Down Expand Up @@ -432,7 +432,7 @@ class Handler {
if (notActivate)
sc._activated = false;
} else {
!COMPILED && _cons.logWrn("og.webgl.Handler:284 - shader program: '" + program.name + "' is allready exists.");
!COMPILED && cons.logWrn("og.webgl.Handler:284 - shader program: '" + program.name + "' is allready exists.");
}
return program;
}
Expand Down Expand Up @@ -497,7 +497,7 @@ class Handler {
if (ext) {
this.extensions[extensionStr] = ext;
} else if (showLog) {
!COMPILED && _cons.logWrn("og.webgl.Handler: extension '" + extensionStr + "' doesn't initialize.");
!COMPILED && cons.logWrn("og.webgl.Handler: extension '" + extensionStr + "' doesn't initialize.");
}
}
return this.extensions && this.extensions[extensionStr];
Expand Down
89 changes: 57 additions & 32 deletions webpack.config.js
@@ -1,39 +1,64 @@
'use strict';

const webpack = require('webpack');
const path = require('path');

const NODE_ENV = process.env.NODE_ENV.trim().toLowerCase() || 'development';

const libraryName = 'og';

module.exports = {
entry: "./src/og/og.js",

output: {
filename: './dist/og.js',
library: 'og'
},

watch: NODE_ENV == "development",

watchOptions:{
aggregateTimeout: 100
},

devtool: NODE_ENV === "development" ? "source-map": "",

plugins:[
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'NODE_ENV': JSON.stringify(NODE_ENV)
})
]
};

if(NODE_ENV == "production"){

const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

module.exports.plugins.push(
new UglifyJsPlugin()
);
}
if (NODE_ENV == "development") {

let outputFile = libraryName + '.js';

module.exports = {
entry: __dirname + "/src/og/index.js",
output: {
path: __dirname + '/dist',
filename: outputFile,
library: libraryName
},
watch: true,
watchOptions: {
aggregateTimeout: 100
},
devtool: "source-map",
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'NODE_ENV': JSON.stringify(NODE_ENV)
})
],
resolve: {
extensions: ['.js']
}
};

} else if (NODE_ENV == "production") {

const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

let outputFile = libraryName + '.min.js';

module.exports = {
entry: __dirname + "/src/og/index.js",
output: {
path: __dirname + '/dist',
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},

plugins: [
new webpack.DefinePlugin({
'NODE_ENV': JSON.stringify(NODE_ENV)
}),
new UglifyJsPlugin()
],

resolve: {
extensions: ['.js']
}
};
}

0 comments on commit a3bd349

Please sign in to comment.