SpineGameObject.willRender is no longer hard-coded to return true. It instead now takes a Camera parameter and performs all of the checks needed before returning. Previously, this happened during the render functions.

This commit is contained in:
Richard Davey 2020-10-16 11:37:23 +01:00
parent d35ff331b2
commit 67f24ea363

View file

@ -242,17 +242,27 @@ var SpineGameObject = new Class({
}, },
/** /**
* Overrides the default Game Object method and always returns true. * Returns `true` if this Spine Game Object both has a skeleton and
* Rendering is decided in the renderer functions. * also passes the render tests for the given Camera.
* *
* @method SpineGameObject#willRender * @method SpineGameObject#willRender
* @since 3.19.0 * @since 3.19.0
* *
* @return {boolean} Always returns `true`. * @return {boolean} `true` if this Game Object should be rendered, otherwise `false`.
*/ */
willRender: function () willRender: function (camera)
{ {
return true; var skeleton = this.skeleton;
if (!skeleton)
{
return false;
}
var GameObjectRenderMask = 15;
var childAlpha = skeleton.color.a;
return !(GameObjectRenderMask !== this.renderFlags || (this.cameraFilter !== 0 && (this.cameraFilter & camera.id)) || childAlpha === 0);
}, },
/** /**