Skip to content
New issue

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

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

Already on GitHub? # to your account

Add mat4.multQuat #28

Open
vorg opened this issue Oct 17, 2022 · 2 comments
Open

Add mat4.multQuat #28

vorg opened this issue Oct 17, 2022 · 2 comments
Labels
type/feat A new feature

Comments

@vorg
Copy link
Member

vorg commented Oct 17, 2022

When creating modelMatrix from rotation in pex-renderer i'm missing the following function

  var tempMat4multQuatMat4 = mat4.create();
  function mat4multQuat(m, q) {
    mat4.fromQuat(tempMat4multQuatMat4, q);
    mat4.mult(m, tempMat4multQuatMat4);
    return m;
  }

Do you think it would be worth adding?

@dmnsgn
Copy link
Member

dmnsgn commented Oct 17, 2022

Looks like pex-renderer use case is actually translation + rotation.

  • Is using fromTranslationRotationScale(a, translationVec3, rotationQuat, [1,1,1]) an option?
  • or adding fromTranslationRotation(a, translationVec3, rotationQuat,) another valid option?

I think they'd be both faster than running two consecutive mat4 operations (fromQuat/mult).

@vorg
Copy link
Member Author

vorg commented Oct 17, 2022

For building camera.invViewMatrix indeed i could just default to above and scale [1,1,1] for the below i would need to assume that we use component.transform() and position,rotation,scale are set.

function updateModelMatrix(matrix, transform) {
  mat4.identity(matrix);
  if (transform.position) mat4.translate(matrix, transform.position);
  if (transform.rotation) mat4multQuat(matrix, transform.rotation);
  if (transform.scale) mat4.scale(matrix, transform.scale);
  if (transform.matrix) mat4.mult(matrix, transform.matrix);
}

@dmnsgn dmnsgn added the type/feat A new feature label Feb 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type/feat A new feature
Projects
None yet
Development

No branches or pull requests

2 participants