Skip to content

Commit

Permalink
Merge pull request #287 from guycalledfrank/sortaddalpha
Browse files Browse the repository at this point in the history
Fix alphasort
  • Loading branch information
guycalledfrank committed May 31, 2015
2 parents c60126f + 0225f6b commit 5445503
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/scene/scene_forwardrenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,15 @@ pc.extend(pc, function () {
this.culled = [];
var meshPos;
var visible;
var btype;

// Calculate the distance of transparent meshes from the camera
// and cull too
var camPos = camera._node.getPosition();
for (i = 0; i < drawCallsCount; i++) {
drawCall = drawCalls[i];
visible = true;
meshPos = null;
if (!drawCall.command) {
if (drawCall._hidden) continue; // use _hidden property to quickly hide/show meshInstances
meshInstance = drawCall;
Expand All @@ -586,9 +588,11 @@ pc.extend(pc, function () {
}

if (visible) {
if ((meshInstance.material.blendType === pc.BLEND_NORMAL) || (meshInstance.material.blendType === pc.BLEND_PREMULTIPLIED)) {
btype = meshInstance.material.blendType;
if (btype === pc.BLEND_NORMAL
|| btype === pc.BLEND_PREMULTIPLIED) {
// alpha sort
if (! meshPos) meshPos = meshInstance.aabb.center;
if (!meshPos) meshPos = meshInstance.aabb.center;
var tempx = meshPos.x - camPos.x;
var tempy = meshPos.y - camPos.y;
var tempz = meshPos.z - camPos.z;
Expand Down

0 comments on commit 5445503

Please sign in to comment.