Skip to content

Instantly share code, notes, and snippets.

@jmurzy
Last active April 2, 2022 18:52
Show Gist options
  • Save jmurzy/0d62c0b5ea88ca806c16b5e8a16deb6a to your computer and use it in GitHub Desktop.
Save jmurzy/0d62c0b5ea88ca806c16b5e8a16deb6a to your computer and use it in GitHub Desktop.
function transformOrigin(matrix, origin) {
const { x, y, z } = origin;
const translate = MatrixMath.createIdentityMatrix();
MatrixMath.reuseTranslate3dCommand(translate, x, y, z);
MatrixMath.multiplyInto(matrix, translate, matrix);
const untranslate = MatrixMath.createIdentityMatrix();
MatrixMath.reuseTranslate3dCommand(untranslate, -x, -y, -z);
MatrixMath.multiplyInto(matrix, matrix, untranslate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment