Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

another bug in m3.js #391

Open
MaudDibb opened this issue Mar 2, 2022 · 3 comments
Open

another bug in m3.js #391

MaudDibb opened this issue Mar 2, 2022 · 3 comments

Comments

@MaudDibb
Copy link

MaudDibb commented Mar 2, 2022

translation ended up giving me massively skewed projections when doing 2d transforms.

translate does:

1 0 0
0 1 0
tx ty 1

it needs to do:

1 0 tx
0 1 ty
0 0 1

function translation(tx, ty, dst) {
dst = dst || new MatType(9);

dst[0] = 1;
dst[1] = 0;
dst[2] = tx;
dst[3] = 0;
dst[4] = 1;
dst[5] = ty;
dst[6] = 0;
dst[7] = 0;
dst[8] = 1;

return dst;

}

@greggman
Copy link
Member

greggman commented Mar 2, 2022

Works fine for me

https://jsgist.org/?src=06108e06ea91816334f0b3fe3ff30a4f

Have you read this article?

@MaudDibb
Copy link
Author

MaudDibb commented Mar 3, 2022

i was going off your example on pan/zoom on your q&a page
When i tried it, I have it drawing a square centered at 0,0. Instead of seeing a square in the center of the screen tho, i got a stretched diagonal rectangle that extended from the top/left to the bottom/right of the screen. when i swapped the tx/ty values to the new positions in translation, the square appeared normally thru various zoom operations. Maybe im doing something wrong, i dunno. That fixed it for me tho. Im not using twgl tho, I just doing plain js for the webgl stuff, and m3 to do the 3x3 matrix math

@greggman
Copy link
Member

greggman commented Mar 3, 2022

I don't know what to tell you. The example on that page you linked to is using m3.js. Twgl is irrelevant. Here's the sample running without twgl

https://jsgist.org/?src=f63d7a962389b73f2a7f8e0b3776c361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants