WhiteRabbit Posted November 18, 2019 Share Posted November 18, 2019 (edited) Hi there, I have a collection of sprite animations happening inside of a PIXI Container. I need to take a rectangle section of this animation and display it inside of a Spine animation using a Mesh. (this seems to be working all fine) However, I am able to do get the full contents of the container and place it into my Spine animation no problem using renderTexture, but I only need a small section of its contents. I thought I would be able to do something like this.... var party = PIXI.Container(); // Sprites of people in a party inside of here var texture = PIXI.RenderTexture.create(party.width, party.height); texture.frame = new PIXI.Rectangle(100, 0, 100, party.height); // also tried texture.trim texture._updateUvs(); // on rAF update the mesh texture and apply to the mesh renderer(party,texture); slot.attachment.region.texture = texture; slot.attachment.updateUVs(); Here it looks like it should only use a section from 100 pixels in from the left and only take a 100 pixel wide slice, but it doesn't. I also thought I would create the renderTexture at the size of the slice I need.... var texture = PIXI.RenderTexture.create(100, party.height); texture.frame = new PIXI.Rectangle(100, 0, 100, party.height); // also tried texture.trim But this just takes a 100 pixel section at the left most of my container. Maybe I could apply a mask to the section I need and create a texture from that or something? Edited November 19, 2019 by WhiteRabbit ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 18, 2019 Share Posted November 18, 2019 (edited) You don't need to set "frame" of renderTexture, its not that frame that is rendered by renderer, its frame that is shown in sprite later. use var myMatrix = new PIXI.Matrix(); myMatrix.tx = -100; renderer.renderer(party, texture, undefined, myMatrix) Also: slot.attachment.region.texture = texture; slot.attachment.updateUVs(); There's no guarantee that pixi-spine can change texture that way , there's special "hackTextureBySlot" or something like that. Edited November 18, 2019 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
WhiteRabbit Posted November 19, 2019 Author Share Posted November 19, 2019 Thanks Ivan, using the transform parameter in the renderer.render call works great! ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 19, 2019 Share Posted November 19, 2019 Glad we resolved it.Welcome to the forums! WhiteRabbit 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.