Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ysfzrn/127ba892bfb6fbbfe4e97a674d86cfb3 to your computer and use it in GitHub Desktop.
Save ysfzrn/127ba892bfb6fbbfe4e97a674d86cfb3 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