mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-14 16:28:42 -05:00
Better support for sprites on compound objects
This commit is contained in:
parent
34fa27ac97
commit
660294d1ae
1 changed files with 20 additions and 1 deletions
|
@ -429,9 +429,28 @@ var Vector = require('../geometry/Vector');
|
|||
|
||||
if (!body.render.visible)
|
||||
continue;
|
||||
|
||||
var numParts = body.parts.length;
|
||||
var kMin, kMax;
|
||||
|
||||
// We want to render only the main body in two cases.
|
||||
// 1. We don't have any sub-parts (numParts===1)
|
||||
// 2. We have sub-parts but are rendering a sprite.
|
||||
if ((numParts === 1) ||
|
||||
(numParts > 1 && body.render.sprite && body.render.sprite.texture && !options.wireframes)) {
|
||||
// If actually rendering sprites, only render the main body, not any of the parts.
|
||||
kMin = 0;
|
||||
kMax = 0;
|
||||
}
|
||||
else {
|
||||
// If not rendering sprites, if we have sub-parts, render only them and not the main body. If we
|
||||
// don't have sub-parts, render only the main body.
|
||||
kMin = 1;
|
||||
kMax = numParts - 1;
|
||||
}
|
||||
|
||||
// handle compound parts
|
||||
for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) {
|
||||
for (k = kMin; k <= kMax; k++) {
|
||||
part = body.parts[k];
|
||||
|
||||
if (!part.render.visible)
|
||||
|
|
Loading…
Reference in a new issue