These are chat archives for pixijs/pixi.js

21st
Feb 2017
Bryce Neal
@prettymuchbryce
Feb 21 2017 03:00
I have a tilemap and I am trying to add a custom shader to it in the form of using a filter. I want to "hide" certain tiles in the sprite by setting their gl_FragColor to black. Is there a way to get access to the underlying pixels of the Container ? vTextureCoord seems to give me coordinates relative to the screen ? but my container is nested in other containers and has position/scale set.
tamarin
@tamarintech
Feb 21 2017 17:56
I could use some help with a rotation question. Basic use is I want two entities to face each other. I have working code in canvas, but when I use the same approach with pixijs everything seems off by 90 degrees. :worried:
I don't understand.
Working code in canvas var angleInRads = Math.atan2(deltaY, deltaX);
"Working" code in pixi.js var angle = Math.atan2(dy, dx) + Math.PI/2;
I don't understand why I + Math.PI/2 in pixi.
Enriko Riba
@enriko-riba
Feb 21 2017 19:38
@tamarintech don't know about canvas but Math.atan2() returns the angle between the positive X axis and the point (x, y). In other words 0 radians is the +x direction, 1 radian is the -x direction. PIXI defines rotation of 0 radians as the -y direction, PI/2 radians as the +x diretion. Beats me why this is so but I guess there must be a valid reason :-)
Anyway this makes an obvious difference of PI/2 radians between those two systems (JS Math and PIXI)
tamarin
@tamarintech
Feb 21 2017 19:39
Ah, so does it "make sense" that my solution is coming back as -90 when the target is "north" and offseting it by 90 for a rotation of 0 works?
I thought maybe I had messed up loading/placing sprites somehow. :)
Enriko Riba
@enriko-riba
Feb 21 2017 19:41
yes, "north" is from -0 to -PI and south from +0 to PI :-)
the above is for "south" in clockwise and "north" in counterclockwise direction