Code Tidy
Little house cleaning on the code
This commit is contained in:
parent
084f749653
commit
24a784de30
10 changed files with 14 additions and 143 deletions
|
@ -86,15 +86,6 @@ PIXI.DisplayObject = function()
|
|||
*/
|
||||
this.renderable = false;
|
||||
|
||||
/**
|
||||
* [read-only] The visibility of the object based on world (parent) factors.
|
||||
*
|
||||
* @property worldVisible
|
||||
* @type Boolean
|
||||
* @readOnly
|
||||
*/
|
||||
this.worldVisible = false;
|
||||
|
||||
/**
|
||||
* [read-only] The display object container that contains this display object.
|
||||
*
|
||||
|
@ -251,17 +242,6 @@ PIXI.DisplayObject = function()
|
|||
// constructor
|
||||
PIXI.DisplayObject.prototype.constructor = PIXI.DisplayObject;
|
||||
|
||||
//TODO make visible a getter setter
|
||||
/*
|
||||
Object.defineProperty(PIXI.DisplayObject.prototype, 'visible', {
|
||||
get: function() {
|
||||
return this._visible;
|
||||
},
|
||||
set: function(value) {
|
||||
this._visible = value;
|
||||
}
|
||||
});*/
|
||||
|
||||
/**
|
||||
* [Deprecated] Indicates if the sprite will have touch and mouse interactivity. It is false by default
|
||||
* Instead of using this function you can now simply set the interactive property to true or false
|
||||
|
@ -334,12 +314,10 @@ PIXI.DisplayObject.prototype.addFilter = function(mask)
|
|||
if(this.filter)return;
|
||||
this.filter = true;
|
||||
|
||||
|
||||
// insert a filter block..
|
||||
var start = new PIXI.FilterBlock();
|
||||
var end = new PIXI.FilterBlock();
|
||||
|
||||
|
||||
start.mask = mask;
|
||||
end.mask = mask;
|
||||
|
||||
|
@ -349,9 +327,7 @@ PIXI.DisplayObject.prototype.addFilter = function(mask)
|
|||
start.open = true;
|
||||
|
||||
/*
|
||||
*
|
||||
* insert start
|
||||
*
|
||||
*/
|
||||
|
||||
var childFirst = start
|
||||
|
@ -382,9 +358,7 @@ PIXI.DisplayObject.prototype.addFilter = function(mask)
|
|||
// now insert the end filter block..
|
||||
|
||||
/*
|
||||
*
|
||||
* insert end filter
|
||||
*
|
||||
*/
|
||||
var childFirst = end
|
||||
var childLast = end
|
||||
|
@ -460,8 +434,6 @@ PIXI.DisplayObject.prototype.removeFilter = function()
|
|||
previousObject._iNext = nextObject;
|
||||
|
||||
// this is always true too!
|
||||
// if(this.last == lastBlock)
|
||||
//{
|
||||
var tempLast = lastBlock._iPrev;
|
||||
// need to make sure the parents last is updated too
|
||||
var updateLast = this;
|
||||
|
@ -480,7 +452,6 @@ PIXI.DisplayObject.prototype.removeFilter = function()
|
|||
{
|
||||
this.__renderGroup.removeFilterBlocks(startBlock, lastBlock);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -61,7 +61,7 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
|
|||
|
||||
this.children.push(child);
|
||||
|
||||
// updae the stage refference..
|
||||
// update the stage refference..
|
||||
|
||||
if(this.stage)
|
||||
{
|
||||
|
@ -96,7 +96,6 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
|
|||
nextObject = previousObject._iNext;
|
||||
|
||||
// always true in this case
|
||||
//this.last = child.last;
|
||||
// need to make sure the parents last is updated too
|
||||
var updateLast = this;
|
||||
var prevLast = previousObject;
|
||||
|
@ -160,7 +159,7 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
|
|||
}
|
||||
|
||||
// modify the list..
|
||||
var childFirst = child.first
|
||||
var childFirst = child.first;
|
||||
var childLast = child.last;
|
||||
var nextObject;
|
||||
var previousObject;
|
||||
|
@ -168,7 +167,7 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
|
|||
if(index == this.children.length)
|
||||
{
|
||||
previousObject = this.last;
|
||||
var updateLast = this;//.parent;
|
||||
var updateLast = this;
|
||||
var prevLast = this.last;
|
||||
while(updateLast)
|
||||
{
|
||||
|
@ -297,7 +296,7 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
|
|||
{
|
||||
// unlink //
|
||||
// modify the list..
|
||||
var childFirst = child.first
|
||||
var childFirst = child.first;
|
||||
var childLast = child.last;
|
||||
|
||||
var nextObject = childLast._iNext;
|
||||
|
|
|
@ -131,7 +131,9 @@ PIXI.MovieClip.prototype.updateTransform = function()
|
|||
if(!this.playing)return;
|
||||
|
||||
this.currentFrame += this.animationSpeed;
|
||||
|
||||
var round = (this.currentFrame + 0.5) | 0;
|
||||
|
||||
if(this.loop || round < this.textures.length)
|
||||
{
|
||||
this.setTexture(this.textures[round % this.textures.length]);
|
||||
|
|
|
@ -119,35 +119,3 @@ PIXI.Stage.prototype.getMousePosition = function()
|
|||
{
|
||||
return this.interactionManager.mouse.global;
|
||||
}
|
||||
/*
|
||||
PIXI.Stage.prototype.__addChild = function(child)
|
||||
{
|
||||
if(child.interactive)this.dirty = true;
|
||||
|
||||
child.stage = this;
|
||||
|
||||
if(child.children)
|
||||
{
|
||||
for (var i=0; i < child.children.length; i++)
|
||||
{
|
||||
this.__addChild(child.children[i]);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
PIXI.Stage.prototype.__removeChild = function(child)
|
||||
{
|
||||
if(child.interactive)this.dirty = true;
|
||||
|
||||
child.stage = undefined;
|
||||
|
||||
if(child.children)
|
||||
{
|
||||
for(var i=0,j=child.children.length; i<j; i++)
|
||||
{
|
||||
this.__removeChild(child.children[i]);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -38,8 +38,6 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context)
|
|||
|
||||
if(data.type == PIXI.Graphics.POLY)
|
||||
{
|
||||
//if(data.lineWidth <= 0)continue;
|
||||
|
||||
context.beginPath();
|
||||
|
||||
context.moveTo(points[0], points[1]);
|
||||
|
@ -178,8 +176,6 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
|
|||
|
||||
if(data.type == PIXI.Graphics.POLY)
|
||||
{
|
||||
//if(data.lineWidth <= 0)continue;
|
||||
|
||||
context.beginPath();
|
||||
context.moveTo(points[0], points[1]);
|
||||
|
||||
|
|
|
@ -218,16 +218,12 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
context.worldAlpha = 0;
|
||||
|
||||
PIXI.CanvasGraphics.renderGraphicsMask(displayObject.mask, context);
|
||||
// context.fillStyle = 0xFF0000;
|
||||
// context.fillRect(0, 0, 200, 200);
|
||||
context.clip();
|
||||
|
||||
displayObject.mask.worldAlpha = cacheAlpha;
|
||||
//context.globalCompositeOperation = 'lighter';
|
||||
}
|
||||
else
|
||||
{
|
||||
//context.globalCompositeOperation = 'source-over';
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
@ -321,7 +317,7 @@ PIXI.CanvasRenderer.prototype.renderTilingSprite = function(sprite)
|
|||
PIXI.CanvasRenderer.prototype.renderStrip = function(strip)
|
||||
{
|
||||
var context = this.context;
|
||||
//context.globalCompositeOperation = 'lighter';
|
||||
|
||||
// draw triangles!!
|
||||
var verticies = strip.verticies;
|
||||
var uvs = strip.uvs;
|
||||
|
@ -348,8 +344,6 @@ PIXI.CanvasRenderer.prototype.renderStrip = function(strip)
|
|||
context.lineTo(x2, y2);
|
||||
context.closePath();
|
||||
|
||||
// context.fillStyle = "white"//rgb(1, 1, 1,1));
|
||||
// context.fill();
|
||||
context.clip();
|
||||
|
||||
|
||||
|
@ -373,5 +367,4 @@ PIXI.CanvasRenderer.prototype.renderStrip = function(strip)
|
|||
context.restore();
|
||||
};
|
||||
|
||||
// context.globalCompositeOperation = 'source-over';
|
||||
}
|
||||
|
|
|
@ -79,7 +79,6 @@ PIXI.WebGLBatch.prototype.clean = function()
|
|||
this.uvs = [];
|
||||
this.indices = [];
|
||||
this.colors = [];
|
||||
//this.sprites = [];
|
||||
this.dynamicSize = 1;
|
||||
this.texture = null;
|
||||
this.last = null;
|
||||
|
@ -116,7 +115,6 @@ PIXI.WebGLBatch.prototype.init = function(sprite)
|
|||
this.dirty = true;
|
||||
this.blendMode = sprite.blendMode;
|
||||
this.texture = sprite.texture.baseTexture;
|
||||
// this.sprites.push(sprite);
|
||||
this.head = sprite;
|
||||
this.tail = sprite;
|
||||
this.size = 1;
|
||||
|
@ -149,7 +147,6 @@ PIXI.WebGLBatch.prototype.insertBefore = function(sprite, nextSprite)
|
|||
else
|
||||
{
|
||||
this.head = sprite;
|
||||
//this.head.__prev = null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,7 +234,7 @@ PIXI.WebGLBatch.prototype.split = function(sprite)
|
|||
{
|
||||
this.dirty = true;
|
||||
|
||||
var batch = new PIXI.WebGLBatch(this.gl);//PIXI._getBatch(this.gl);
|
||||
var batch = new PIXI.WebGLBatch(this.gl);
|
||||
batch.init(sprite);
|
||||
batch.texture = this.texture;
|
||||
batch.tail = this.tail;
|
||||
|
@ -247,8 +244,6 @@ PIXI.WebGLBatch.prototype.split = function(sprite)
|
|||
|
||||
sprite.__prev = null;
|
||||
// return a splite batch!
|
||||
//sprite.__prev.__next = null;
|
||||
//sprite.__prev = null;
|
||||
|
||||
// TODO this size is wrong!
|
||||
// need to recalculate :/ problem with a linked list!
|
||||
|
@ -318,13 +313,13 @@ PIXI.WebGLBatch.prototype.growBatch = function()
|
|||
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
|
||||
gl.bufferData(gl.ARRAY_BUFFER,this.verticies , gl.DYNAMIC_DRAW);
|
||||
|
||||
this.uvs = new Float32Array( this.dynamicSize * 8 )
|
||||
this.uvs = new Float32Array( this.dynamicSize * 8 );
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, this.uvs , gl.DYNAMIC_DRAW);
|
||||
|
||||
this.dirtyUVS = true;
|
||||
|
||||
this.colors = new Float32Array( this.dynamicSize * 4 )
|
||||
this.colors = new Float32Array( this.dynamicSize * 4 );
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, this.colors , gl.DYNAMIC_DRAW);
|
||||
|
||||
|
@ -525,7 +520,7 @@ PIXI.WebGLBatch.prototype.update = function()
|
|||
PIXI.WebGLBatch.prototype.render = function(start, end)
|
||||
{
|
||||
start = start || 0;
|
||||
//end = end || this.size;
|
||||
|
||||
if(end == undefined)end = this.size;
|
||||
|
||||
if(this.dirty)
|
||||
|
@ -577,9 +572,8 @@ PIXI.WebGLBatch.prototype.render = function(start, end)
|
|||
// dont need to upload!
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
||||
|
||||
//var startIndex = 0//1;
|
||||
var len = end - start;
|
||||
// console.log(this.size)
|
||||
|
||||
// DRAW THAT this!
|
||||
gl.drawElements(gl.TRIANGLES, len * 6, gl.UNSIGNED_SHORT, start * 2 * 6 );
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
|
|||
verts.push(px , py);
|
||||
verts.push(r, g, b, alpha);
|
||||
|
||||
verts.push(p2x - (px-p2x), p2y - (py - p2y));//, 4);
|
||||
verts.push(p2x - (px-p2x), p2y - (py - p2y));
|
||||
verts.push(r, g, b, alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,9 +66,6 @@ PIXI.WebGLRenderGroup.prototype.render = function(projection)
|
|||
gl.uniform2f(PIXI.shaderProgram.projectionVector, projection.x, projection.y);
|
||||
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// TODO remove this by replacing visible with getter setters..
|
||||
//this.checkVisibility(this.root, this.root.visible);
|
||||
|
||||
// will render all the elements in the group
|
||||
var renderable;
|
||||
|
||||
|
@ -150,9 +147,7 @@ PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, project
|
|||
PIXI.WebGLRenderer.updateTextures();
|
||||
|
||||
var gl = this.gl;
|
||||
//this.checkVisibility(displayObject, displayObject.visible);
|
||||
|
||||
// gl.uniformMatrix4fv(PIXI.shaderProgram.mvMatrixUniform, false, projectionMatrix);
|
||||
gl.uniform2f(PIXI.shaderProgram.projectionVector, projection.x, projection.y);
|
||||
|
||||
// to do!
|
||||
|
@ -355,45 +350,6 @@ PIXI.WebGLRenderGroup.prototype.renderSpecial = function(renderable, projection)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the visibility of a displayObject
|
||||
*
|
||||
* @method checkVisibility
|
||||
* @param displayObject {DisplayObject}
|
||||
* @param globalVisible {Boolean}
|
||||
* @private
|
||||
*/
|
||||
|
||||
/*
|
||||
PIXI.WebGLRenderGroup.prototype.checkVisibility = function(displayObject, globalVisible)
|
||||
{
|
||||
// give the dp a reference to its renderGroup...
|
||||
var children = displayObject.children;
|
||||
//displayObject.worldVisible = globalVisible;
|
||||
for (var i=0; i < children.length; i++)
|
||||
{
|
||||
var child = children[i];
|
||||
|
||||
// TODO optimize... should'nt need to loop through everything all the time
|
||||
// child.worldVisible = child.visible && globalVisible;
|
||||
|
||||
// everything should have a batch!
|
||||
// time to see whats new!
|
||||
if(child.textureChange)
|
||||
{
|
||||
child.textureChange = false;
|
||||
//if(child.worldVisible)
|
||||
//this.updateTexture(child);
|
||||
// update texture!!
|
||||
}
|
||||
|
||||
if(child.children.length > 0)
|
||||
{
|
||||
this.checkVisibility(child, child.worldVisible);
|
||||
}
|
||||
};
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Updates a webgl texture
|
||||
*
|
||||
|
|
|
@ -134,7 +134,6 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
{
|
||||
// TODO make this work
|
||||
// dont think this is needed any more?
|
||||
//if(this.__stage)this.checkVisibility(this.__stage, false)
|
||||
this.__stage = stage;
|
||||
this.stageRenderGroup.setRenderable(stage);
|
||||
}
|
||||
|
@ -151,9 +150,6 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
// update any textures
|
||||
PIXI.WebGLRenderer.updateTextures();
|
||||
|
||||
// recursivly loop through all items!
|
||||
//this.checkVisibility(stage, true);
|
||||
|
||||
// update the scene graph
|
||||
PIXI.visibleCount++;
|
||||
stage.updateTransform();
|
||||
|
@ -164,16 +160,12 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
gl.colorMask(true, true, true, this.transparent);
|
||||
gl.viewport(0, 0, this.width, this.height);
|
||||
|
||||
// set the correct matrix..
|
||||
// gl.uniformMatrix4fv(this.shaderProgram.mvMatrixUniform, false, this.projectionMatrix);
|
||||
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
||||
|
||||
gl.clearColor(stage.backgroundColorSplit[0],stage.backgroundColorSplit[1],stage.backgroundColorSplit[2], !this.transparent);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
// HACK TO TEST
|
||||
//PIXI.projectionMatrix = this.projectionMatrix;
|
||||
|
||||
this.stageRenderGroup.backgroundColor = stage.backgroundColorSplit;
|
||||
this.stageRenderGroup.render(PIXI.projection);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue