RenderTexture update
RenderTexture added (webGL and Canvas) WebGL Render rearchitected - a little faster :) Pivot added to DisplayObject docs updated grunt file updated
This commit is contained in:
parent
ba5a79c606
commit
88b863155a
82 changed files with 14133 additions and 6332 deletions
708
docs/files/src_pixi_renderers_WebGLRenderGroup.js.html
Normal file
708
docs/files/src_pixi_renderers_WebGLRenderGroup.js.html
Normal file
|
@ -0,0 +1,708 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>src/pixi/renderers/WebGLRenderGroup.js - Pixi.JS</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.8.0/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.8.0/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="http://www.goodboydigital.com/pixijs/logo_small.png" title="Pixi.JS"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.0.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AssetLoader.html">AssetLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BaseTexture.html">BaseTexture</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapText.html">BitmapText</a></li>
|
||||
|
||||
<li><a href="../classes/CanvasRenderer.html">CanvasRenderer</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObject.html">DisplayObject</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObjectContainer.html">DisplayObjectContainer</a></li>
|
||||
|
||||
<li><a href="../classes/ImageLoader.html">ImageLoader</a></li>
|
||||
|
||||
<li><a href="../classes/InteractionData.html">InteractionData</a></li>
|
||||
|
||||
<li><a href="../classes/InteractionManager.html">InteractionManager</a></li>
|
||||
|
||||
<li><a href="../classes/MovieClip.html">MovieClip</a></li>
|
||||
|
||||
<li><a href="../classes/Point.html">Point</a></li>
|
||||
|
||||
<li><a href="../classes/Rectangle.html">Rectangle</a></li>
|
||||
|
||||
<li><a href="../classes/RenderTexture.html">RenderTexture</a></li>
|
||||
|
||||
<li><a href="../classes/Sprite.html">Sprite</a></li>
|
||||
|
||||
<li><a href="../classes/SpriteSheetLoader.html">SpriteSheetLoader</a></li>
|
||||
|
||||
<li><a href="../classes/Stage.html">Stage</a></li>
|
||||
|
||||
<li><a href="../classes/Text.html">Text</a></li>
|
||||
|
||||
<li><a href="../classes/Texture.html">Texture</a></li>
|
||||
|
||||
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLBatch.html">WebGLBatch</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/PIXI.html">PIXI</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1 class="file-heading">File: src/pixi/renderers/WebGLRenderGroup.js</h1>
|
||||
|
||||
<div class="file">
|
||||
<pre class="code prettyprint linenums">
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A WebGLBatch Enables a group of sprites to be drawn using the same settings.
|
||||
* if a group of sprites all have the same baseTexture and blendMode then they can be grouped into a batch. All the sprites in a batch can then be drawn in one go by the GPU which is hugely efficient. ALL sprites in the webGL renderer are added to a batch even if the batch only contains one sprite. Batching is handled automatically by the webGL renderer. A good tip is: the smaller the number of batchs there are, the faster the webGL renderer will run.
|
||||
* @class WebGLBatch
|
||||
* @param an instance of the webGL context
|
||||
* @return {PIXI.renderers.WebGLBatch} WebGLBatch {@link PIXI.renderers.WebGLBatch}
|
||||
*/
|
||||
PIXI.WebGLRenderGroup = function(gl)
|
||||
{
|
||||
this.gl = gl;
|
||||
this.root;
|
||||
|
||||
this.backgroundColor;
|
||||
this.batchs = [];
|
||||
this.toRemove = [];
|
||||
}
|
||||
|
||||
|
||||
// constructor
|
||||
PIXI.WebGLRenderGroup.constructor = PIXI.WebGLRenderGroup;
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.setRenderable = function(displayObject)
|
||||
{
|
||||
// has this changed??
|
||||
if(this.root)this.removeDisplayObjectAndChildren(this.root);
|
||||
|
||||
//console.log("!!!");
|
||||
// TODO what if its already has an object? should remove it
|
||||
this.root = displayObject;
|
||||
//displayObject.__renderGroup = this;
|
||||
this.addDisplayObjectAndChildren(displayObject);
|
||||
//displayObject
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.render = function(renderTexture)
|
||||
{
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
for (var i=0; i < this.toRemove.length; i++)
|
||||
{
|
||||
this.removeDisplayObjectAndChildren(this.toRemove[i]);
|
||||
};
|
||||
|
||||
this.toRemove = [];
|
||||
|
||||
this.checkVisibility(this.root, this.root.visible);
|
||||
|
||||
// will render all the elements in the group
|
||||
var renderable;
|
||||
for (var i=0; i < this.batchs.length; i++)
|
||||
{
|
||||
renderable = this.batchs[i];
|
||||
if(renderable instanceof PIXI.WebGLBatch)
|
||||
{
|
||||
this.batchs[i].render();
|
||||
}
|
||||
else if(renderable instanceof PIXI.TilingSprite)
|
||||
{
|
||||
if(renderable.visible)this.renderTilingSprite(renderable);
|
||||
}
|
||||
else if(renderable instanceof PIXI.Strip)
|
||||
{
|
||||
if(renderable.visible)this.renderStrip(renderable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, renderTexture)
|
||||
{
|
||||
var gl = this.gl;
|
||||
this.checkVisibility(displayObject, displayObject.visible);
|
||||
|
||||
|
||||
//console.log("SPECIFIC");
|
||||
// to do!
|
||||
// render part of the scene...
|
||||
|
||||
var startIndex;
|
||||
var startBatchIndex;
|
||||
|
||||
var endIndex;
|
||||
var endBatchIndex;
|
||||
|
||||
// get NEXT Renderable!
|
||||
var nextRenderable = displayObject.renderable ? displayObject : this.getNextRenderable(displayObject);
|
||||
var startBatch = nextRenderable.batch;
|
||||
|
||||
if(nextRenderable instanceof PIXI.Sprite)
|
||||
{
|
||||
startBatch = nextRenderable.batch;
|
||||
|
||||
var head = startBatch.head;
|
||||
var next = head;
|
||||
|
||||
// ok now we have the batch.. need to find the start index!
|
||||
if(head == nextRenderable)
|
||||
{
|
||||
startIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
startIndex = 1;
|
||||
|
||||
while(head.__next != nextRenderable)
|
||||
{
|
||||
startIndex++;
|
||||
head = head.__next;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
startBatch = nextRenderable;
|
||||
}
|
||||
|
||||
// Get the LAST renderable object
|
||||
var lastRenderable = displayObject;
|
||||
var endBatch;
|
||||
var lastItem = displayObject;
|
||||
while(lastItem.children.length > 0)
|
||||
{
|
||||
lastItem = lastItem.children[lastItem.children.length-1];
|
||||
if(lastItem.renderable)lastRenderable = lastItem;
|
||||
}
|
||||
|
||||
if(lastRenderable instanceof PIXI.Sprite)
|
||||
{
|
||||
endBatch = lastRenderable.batch;
|
||||
|
||||
var head = endBatch.head;
|
||||
|
||||
if(head == lastRenderable)
|
||||
{
|
||||
endIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
endIndex = 1;
|
||||
|
||||
while(head.__next != lastRenderable)
|
||||
{
|
||||
endIndex++;
|
||||
head = head.__next;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
endBatch = lastRenderable;
|
||||
}
|
||||
|
||||
// now we have first and last!
|
||||
startBatchIndex = this.batchs.indexOf(startBatch);
|
||||
endBatchIndex = this.batchs.indexOf(endBatch);
|
||||
|
||||
// DO the first batch
|
||||
if(startBatch instanceof PIXI.WebGLBatch)
|
||||
{
|
||||
startBatch.render(startIndex);
|
||||
}
|
||||
else if(startBatch instanceof PIXI.TilingSprite)
|
||||
{
|
||||
if(startBatch.visible)this.renderTilingSprite(startBatch);
|
||||
}
|
||||
else if(startBatch instanceof PIXI.Strip)
|
||||
{
|
||||
if(startBatch.visible)this.renderStrip(startBatch);
|
||||
}
|
||||
|
||||
// DO the middle batchs..
|
||||
for (var i=startBatchIndex+1; i < endBatchIndex; i++)
|
||||
{
|
||||
renderable = this.batchs[i];
|
||||
|
||||
if(renderable instanceof PIXI.WebGLBatch)
|
||||
{
|
||||
this.batchs[i].render();
|
||||
}
|
||||
else if(renderable instanceof PIXI.TilingSprite)
|
||||
{
|
||||
if(renderable.visible)this.renderTilingSprite(renderable);
|
||||
}
|
||||
else if(renderable instanceof PIXI.Strip)
|
||||
{
|
||||
if(renderable.visible)this.renderStrip(renderable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// DO the last batch..
|
||||
if(endBatch instanceof PIXI.WebGLBatch)
|
||||
{
|
||||
endBatch.render(0, endIndex+1);
|
||||
}
|
||||
else if(endBatch instanceof PIXI.TilingSprite)
|
||||
{
|
||||
if(endBatch.visible)this.renderTilingSprite(endBatch);
|
||||
}
|
||||
else if(endBatch instanceof PIXI.Strip)
|
||||
{
|
||||
if(endBatch.visible)this.renderStrip(endBatch);
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.checkVisibility = function(displayObject, globalVisible)
|
||||
{
|
||||
// give the dp a refference to its renderGroup...
|
||||
var children = displayObject.children;
|
||||
//displayObject.worldVisible = globalVisible;
|
||||
for (var i=0; i < children.length; i++)
|
||||
{
|
||||
var child = children[i];
|
||||
|
||||
// TODO optimize... shouldt 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.removeDisplayObject(child)
|
||||
this.addDisplayObject(child)
|
||||
}
|
||||
// update texture!!
|
||||
}
|
||||
|
||||
if(child.children.length > 0)
|
||||
{
|
||||
this.checkVisibility(child, child.worldVisible);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.addDisplayObject = function(displayObject)
|
||||
{
|
||||
// add a child to the render group..
|
||||
displayObject.batch = null;
|
||||
displayObject.__renderGroup = this;
|
||||
|
||||
//displayObject.cacheVisible = true;
|
||||
if(!displayObject.renderable)return;
|
||||
|
||||
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
|
||||
//displayObject.__inWebGL = true;
|
||||
|
||||
var previousSprite = this.getPreviousRenderable(displayObject);
|
||||
var nextSprite = this.getNextRenderable(displayObject);
|
||||
|
||||
|
||||
/*
|
||||
* so now we have the next renderable and the previous renderable
|
||||
*
|
||||
*/
|
||||
|
||||
if(displayObject instanceof PIXI.Sprite)
|
||||
{
|
||||
var previousBatch
|
||||
var nextBatch
|
||||
|
||||
//console.log( previousSprite)
|
||||
if(previousSprite instanceof PIXI.Sprite)
|
||||
{
|
||||
previousBatch = previousSprite.batch;
|
||||
if(previousBatch)
|
||||
{
|
||||
if(previousBatch.texture == displayObject.texture.baseTexture && previousBatch.blendMode == displayObject.blendMode)
|
||||
{
|
||||
previousBatch.insertAfter(displayObject, previousSprite);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO reword!
|
||||
previousBatch = previousSprite;
|
||||
}
|
||||
|
||||
if(nextSprite)
|
||||
{
|
||||
if(nextSprite instanceof PIXI.Sprite)
|
||||
{
|
||||
nextBatch = nextSprite.batch;
|
||||
|
||||
//batch may not exist if item was added to the display list but not to the webGL
|
||||
if(nextBatch)
|
||||
{
|
||||
if(nextBatch.texture == displayObject.texture.baseTexture && nextBatch.blendMode == displayObject.blendMode)
|
||||
{
|
||||
nextBatch.insertBefore(displayObject, nextSprite);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(nextBatch == previousBatch)
|
||||
{
|
||||
// THERE IS A SPLIT IN THIS BATCH! //
|
||||
var splitBatch = previousBatch.split(nextSprite);
|
||||
// COOL!
|
||||
// add it back into the array
|
||||
/*
|
||||
* OOPS!
|
||||
* seems the new sprite is in the middle of a batch
|
||||
* lets split it..
|
||||
*/
|
||||
var batch = PIXI.WebGLRenderer.getBatch();
|
||||
|
||||
var index = this.batchs.indexOf( previousBatch );
|
||||
batch.init(displayObject);
|
||||
this.batchs.splice(index+1, 0, batch, splitBatch);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO re-word!
|
||||
nextBatch = nextSprite;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* looks like it does not belong to any batch!
|
||||
* but is also not intersecting one..
|
||||
* time to create anew one!
|
||||
*/
|
||||
|
||||
var batch = PIXI.WebGLRenderer.getBatch();
|
||||
batch.init(displayObject);
|
||||
|
||||
if(previousBatch) // if this is invalid it means
|
||||
{
|
||||
var index = this.batchs.indexOf( previousBatch );
|
||||
this.batchs.splice(index+1, 0, batch);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.batchs.push(batch);
|
||||
}
|
||||
|
||||
}
|
||||
else if(displayObject instanceof PIXI.TilingSprite)
|
||||
{
|
||||
// add to a batch!!
|
||||
this.initTilingSprite(displayObject);
|
||||
this.batchs.push(displayObject);
|
||||
|
||||
}
|
||||
else if(displayObject instanceof PIXI.Strip)
|
||||
{
|
||||
// add to a batch!!
|
||||
this.initStrip(displayObject);
|
||||
this.batchs.push(displayObject);
|
||||
}
|
||||
|
||||
// if its somthing else... then custom codes!
|
||||
this.batchUpdate = true;
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.addDisplayObjectAndChildren = function(displayObject)
|
||||
{
|
||||
// TODO - this can be faster - but not as important right now
|
||||
|
||||
this.addDisplayObject(displayObject);
|
||||
var children = displayObject.children;
|
||||
|
||||
for (var i=0; i < children.length; i++)
|
||||
{
|
||||
this.addDisplayObjectAndChildren(children[i]);
|
||||
};
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.removeDisplayObject = function(displayObject)
|
||||
{
|
||||
// loop through children..
|
||||
// display object //
|
||||
|
||||
// add a child from the render group..
|
||||
// remove it and all its children!
|
||||
//displayObject.cacheVisible = false;//displayObject.visible;
|
||||
displayObject.__renderGroup = null;
|
||||
|
||||
if(!displayObject.renderable)return;
|
||||
|
||||
/*
|
||||
* removing is a lot quicker..
|
||||
*
|
||||
*/
|
||||
var batchToRemove;
|
||||
|
||||
if(displayObject instanceof PIXI.Sprite)
|
||||
{
|
||||
// should always have a batch!
|
||||
var batch = displayObject.batch;
|
||||
if(!batch)return; // this means the display list has been altered befre rendering
|
||||
|
||||
batch.remove(displayObject);
|
||||
|
||||
if(batch.size==0)
|
||||
{
|
||||
batchToRemove = batch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
batchToRemove = displayObject;
|
||||
}
|
||||
|
||||
/*
|
||||
* Looks like there is somthing that needs removing!
|
||||
*/
|
||||
if(batchToRemove)
|
||||
{
|
||||
var index = this.batchs.indexOf( batchToRemove );
|
||||
if(index == -1)return;// this means it was added then removed before rendered
|
||||
|
||||
// ok so.. check to see if you adjacent batchs should be joined.
|
||||
// TODO may optimise?
|
||||
if(index == 0 || index == this.batchs.length-1)
|
||||
{
|
||||
// wha - eva! just get of the empty batch!
|
||||
this.batchs.splice(index, 1);
|
||||
if(batchToRemove instanceof PIXI.WebGLBatch)PIXI.WebGLRenderer.returnBatch(batchToRemove);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.batchs[index-1] instanceof PIXI.WebGLBatch && this.batchs[index+1] instanceof PIXI.WebGLBatch)
|
||||
{
|
||||
if(this.batchs[index-1].texture == this.batchs[index+1].texture && this.batchs[index-1].blendMode == this.batchs[index+1].blendMode)
|
||||
{
|
||||
//console.log("MERGE")
|
||||
this.batchs[index-1].merge(this.batchs[index+1]);
|
||||
|
||||
if(batchToRemove instanceof PIXI.WebGLBatch)PIXI.WebGLRenderer.returnBatch(batchToRemove);
|
||||
PIXI.WebGLRenderer.returnBatch(this.batchs[index+1]);
|
||||
this.batchs.splice(index, 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.batchs.splice(index, 1);
|
||||
if(batchToRemove instanceof PIXI.WebGLBatch)PIXI.WebGLRenderer.returnBatch(batchToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displayObject)
|
||||
{
|
||||
// TODO - this can be faster - but not as important right now
|
||||
if(displayObject.__renderGroup != this)return;
|
||||
|
||||
this.removeDisplayObject(displayObject);
|
||||
var children = displayObject.children;
|
||||
|
||||
for (var i=0; i < children.length; i++)
|
||||
{
|
||||
this.removeDisplayObjectAndChildren(children[i]);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.getNextRenderable = function(displayObject)
|
||||
{
|
||||
/*
|
||||
* LOOK FOR THE NEXT SPRITE
|
||||
* This part looks for the closest next sprite that can go into a batch
|
||||
* it keeps looking until it finds a sprite or gets to the end of the display
|
||||
* scene graph
|
||||
*
|
||||
* These look a lot scarier than the actually are...
|
||||
*/
|
||||
|
||||
var nextSprite = displayObject;
|
||||
do
|
||||
{
|
||||
// moving forward!
|
||||
// if it has no children..
|
||||
if(nextSprite.children.length == 0)
|
||||
{
|
||||
// go along to the parent..
|
||||
while(nextSprite.childIndex == nextSprite.parent.children.length-1)
|
||||
{
|
||||
nextSprite = nextSprite.parent;
|
||||
if(nextSprite == this.root)//displayObject.stage)
|
||||
{
|
||||
nextSprite = null
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(nextSprite)nextSprite = nextSprite.parent.children[nextSprite.childIndex+1];
|
||||
}
|
||||
else
|
||||
{
|
||||
nextSprite = nextSprite.children[0];
|
||||
}
|
||||
|
||||
if(!nextSprite)break;
|
||||
}
|
||||
while(!nextSprite.renderable || !nextSprite.__renderGroup)
|
||||
|
||||
return nextSprite;
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.getPreviousRenderable = function(displayObject)
|
||||
{
|
||||
/*
|
||||
* LOOK FOR THE PREVIOUS SPRITE
|
||||
* This part looks for the closest previous sprite that can go into a batch
|
||||
* It keeps going back until it finds a sprite or the stage
|
||||
*/
|
||||
var previousSprite = displayObject;
|
||||
do
|
||||
{
|
||||
if(previousSprite.childIndex == 0)
|
||||
{
|
||||
previousSprite = previousSprite.parent;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
previousSprite = previousSprite.parent.children[previousSprite.childIndex-1];
|
||||
// what if the bloop has children???
|
||||
while(previousSprite.children.length != 0)
|
||||
{
|
||||
// keep diggin till we get to the last child
|
||||
previousSprite = previousSprite.children[previousSprite.children.length-1];
|
||||
}
|
||||
}
|
||||
|
||||
if(previousSprite == this.root)break;
|
||||
}
|
||||
while(!previousSprite.renderable || !previousSprite.__renderGroup);
|
||||
|
||||
return previousSprite;
|
||||
}
|
||||
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue