2018-03-23 17:15:52 +00:00
|
|
|
var GameObject = require('../GameObject');
|
|
|
|
|
2018-04-04 15:22:10 +00:00
|
|
|
var ContainerCanvasRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix)
|
2018-03-23 17:15:52 +00:00
|
|
|
{
|
2018-04-04 15:22:10 +00:00
|
|
|
if (GameObject.RENDER_MASK !== container.renderFlags || (container.cameraFilter > 0 && (container.cameraFilter & camera._id)))
|
2018-03-23 17:15:52 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-04 15:22:10 +00:00
|
|
|
var children = container.children;
|
|
|
|
var transformMatrix = container.localTransform;
|
|
|
|
|
|
|
|
if (parentMatrix === undefined)
|
|
|
|
{
|
|
|
|
transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
transformMatrix.loadIdentity();
|
|
|
|
transformMatrix.multiply(parentMatrix);
|
|
|
|
transformMatrix.translate(container.x, container.y);
|
|
|
|
transformMatrix.rotate(container.rotation);
|
|
|
|
transformMatrix.scale(container.scaleX, container.scaleY);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var index = 0; index < children.length; ++index)
|
|
|
|
{
|
|
|
|
children[index].renderCanvas(renderer, children[index], interpolationPercentage, camera, transformMatrix);
|
|
|
|
}
|
2018-03-23 17:15:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = ContainerCanvasRenderer;
|