mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added optimizer scripts and some code style improvements
This commit is contained in:
parent
6b472dc134
commit
5f5fec5b10
16 changed files with 397 additions and 36 deletions
|
|
@ -11,13 +11,12 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
|||
"use strict";
|
||||
|
||||
function DomController() {
|
||||
this.canvas = document.getElementById("canvas");
|
||||
this.canvas = null;
|
||||
this.stats = null;
|
||||
this.ping = null;
|
||||
this.nickContainer = null;
|
||||
this.fpsContainer = "";
|
||||
|
||||
this.devToolsContainer = document.getElementById("menuBar");
|
||||
this.devToolsContainer = null;
|
||||
|
||||
this.initDevTools();
|
||||
}
|
||||
|
|
@ -27,6 +26,9 @@ function (Settings, Nc, Screenfull, Graph, PointerLockManager) {
|
|||
var self = this;
|
||||
var li, button, label;
|
||||
|
||||
this.canvas = document.getElementById("canvas");
|
||||
this.devToolsContainer = document.getElementById("menuBar");
|
||||
|
||||
// create back to menu button
|
||||
li = document.createElement("li");
|
||||
li.id = "back-to-menu";
|
||||
|
|
|
|||
|
|
@ -9,13 +9,6 @@ define([
|
|||
function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var AVAILABLE_MESH_FILTERS = {
|
||||
"blur": PIXI.BlurFilter,
|
||||
"desaturate": PIXI.GrayFilter,
|
||||
"pixelate": PIXI.PixelateFilter,
|
||||
"colorRangeReplace": ColorRangeReplaceFilter,
|
||||
};
|
||||
|
||||
function Layer (name, parallaxSpeed) {
|
||||
Parent.call(this, name, parallaxSpeed);
|
||||
|
|
@ -60,6 +53,15 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter) {
|
|||
|
||||
Layer.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Layer.prototype.getAvailableMeshFilters = function() {
|
||||
return {
|
||||
"blur": PIXI.BlurFilter,
|
||||
"desaturate": PIXI.GrayFilter,
|
||||
"pixelate": PIXI.PixelateFilter,
|
||||
"colorRangeReplace": ColorRangeReplaceFilter,
|
||||
};
|
||||
};
|
||||
|
||||
Layer.prototype.getContainer = function() {
|
||||
return this.container;
|
||||
};
|
||||
|
|
@ -135,11 +137,11 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter) {
|
|||
|
||||
Layer.prototype.addFilter = function(mesh, filterName, options) {
|
||||
|
||||
if (!AVAILABLE_MESH_FILTERS.hasOwnProperty(filterName)) {
|
||||
if (!this.getAvailableMeshFilters().hasOwnProperty(filterName)) {
|
||||
throw new Exception('Filter ' + filterName + ' is not available');
|
||||
}
|
||||
|
||||
var MeshFilter = AVAILABLE_MESH_FILTERS[filterName];
|
||||
var MeshFilter = this.getAvailableMeshFilters()[filterName];
|
||||
var filter = new MeshFilter();
|
||||
|
||||
switch (filterName) {
|
||||
|
|
@ -189,7 +191,7 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter) {
|
|||
return;
|
||||
}
|
||||
|
||||
var MeshFilter = AVAILABLE_MESH_FILTERS[options.filter];
|
||||
var MeshFilter = this.getAvailableMeshFilters()[options.filter];
|
||||
|
||||
filters = filters.filter(function(filter){
|
||||
return !filter instanceof MeshFilter;
|
||||
|
|
@ -271,9 +273,6 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter) {
|
|||
this.container.x += Settings.STAGE_WIDTH / 2;
|
||||
this.container.y += Settings.STAGE_HEIGHT / 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
return Layer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue