I've been trying to generate some textures using PIXI.Graphics for some Sprites. Some of these sprites have their center a bit offset, as in wayyy outside their texture, which is what I want, I want them to rotate around a certain point. So I've used Graphics.drawPolygon and passed an array of vertices to it. So far so good. After that I use the renderer to generate a Texture, and use this to create a Sprite. All seems fine, however when positioning this new sprite with my desired Anchor point, the sprite wouldn't show at the correct location (I do some simple math first on paper to know exactly where the object should show be positioned).
So I poke around some more, trying to debug this issue, and I found out that, depending on how the order of the vertices for the object is fed to the Graphics.drawPolygon, I would get different results (of course one is the correct result and the other is the "bug"). Here is an example:
As it can be seen, both Sprites show up at different locations while having the same properties (Pos, Anchor, Rotation, etc.), except how the texture was drawn:
var verts = ;
var spriteCW = new PIXI.Sprite(app.renderer.generateTexture(...));
spriteCW.anchor.x = 10; //<--- This will get me the red box on the image
verts.reverse(); // !!Reverse the order of the vertices
var spriteCCW = new PIXI.Sprite(app.renderer.generateTexture(...));
spriteCCW.anchor.x = 10; //<--- This will get me the green box on the image
This seem a little bit odd to me, should the order of the polygon affect how it is displayed through a Sprite? I know that working in 3D, the order will determine where the face of the polygon is pointing to, but not the position of the vertices. This might not even be a bug, but I'm not sure what I'm doing wrong or whats the best approach here.