Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
only render attachments when visible
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital committed Jun 5, 2024
1 parent 6cb00e8 commit 16b0cb9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
25 changes: 15 additions & 10 deletions src/Spine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,25 @@ export class Spine extends Container implements View

const { slot, container } = slotAttachment;

const bone = slot.bone;
container.visible = this.skeleton.drawOrder.includes(slot);

container.position.set(bone.worldX, bone.worldY);
if (container.visible)
{
const bone = slot.bone;

container.position.set(bone.worldX, bone.worldY);

container.scale.x = bone.getWorldScaleX();
container.scale.y = bone.getWorldScaleY();
container.scale.x = bone.getWorldScaleX();
container.scale.y = bone.getWorldScaleY();

const rotationX = bone.getWorldRotationX() * DEG_TO_RAD;
const rotationY = bone.getWorldRotationY() * DEG_TO_RAD;
const rotationX = bone.getWorldRotationX() * DEG_TO_RAD;
const rotationY = bone.getWorldRotationY() * DEG_TO_RAD;

container.rotation = Math.atan2(
Math.sin(rotationX) + Math.sin(rotationY),
Math.cos(rotationX) + Math.cos(rotationY)
);
container.rotation = Math.atan2(
Math.sin(rotationX) + Math.sin(rotationY),
Math.cos(rotationX) + Math.cos(rotationY)
);
}
}

this.onViewUpdate();
Expand Down
12 changes: 10 additions & 2 deletions src/SpinePipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/

import { BigPool, collectAllRenderables, extensions, ExtensionType, type Renderer, type RenderPipe, Texture } from 'pixi.js';
import {
BigPool,
collectAllRenderables,
extensions, ExtensionType,
InstructionSet,
type Renderer,
type RenderPipe,
Texture
} from 'pixi.js';
import { BatchableClippedSpineSlot } from './BatchableClippedSpineSlot';
import { BatchableSpineSlot } from './BatchableSpineSlot';
import { Spine } from './Spine';
Expand Down Expand Up @@ -81,7 +89,7 @@ export class SpinePipe implements RenderPipe<Spine>
this._returnActiveBatches();
}

addRenderable(spine: Spine, instructionSet)
addRenderable(spine: Spine, instructionSet:InstructionSet)
{
const batcher = this.renderer.renderPipes.batch;

Expand Down

0 comments on commit 16b0cb9

Please sign in to comment.