Skip to content

Commit

Permalink
Use object destructuring with vectors (#6777)
Browse files Browse the repository at this point in the history
  • Loading branch information
willeastcott authored Jul 2, 2024
1 parent 80613be commit 7ae2e56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/core/math/mat3.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,7 @@ class Mat3 {
transformVector(vec, res = new Vec3()) {
const m = this.data;

const x = vec.x;
const y = vec.y;
const z = vec.z;
const { x, y, z } = vec;

res.x = x * m[0] + y * m[3] + z * m[6];
res.y = x * m[1] + y * m[4] + z * m[7];
Expand Down
17 changes: 4 additions & 13 deletions src/core/math/mat4.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,7 @@ class Mat4 {
transformPoint(vec, res = new Vec3()) {
const m = this.data;

const x = vec.x;
const y = vec.y;
const z = vec.z;
const { x, y, z } = vec;

res.x = x * m[0] + y * m[4] + z * m[8] + m[12];
res.y = x * m[1] + y * m[5] + z * m[9] + m[13];
Expand Down Expand Up @@ -423,9 +421,7 @@ class Mat4 {
transformVector(vec, res = new Vec3()) {
const m = this.data;

const x = vec.x;
const y = vec.y;
const z = vec.z;
const { x, y, z } = vec;

res.x = x * m[0] + y * m[4] + z * m[8];
res.y = x * m[1] + y * m[5] + z * m[9];
Expand Down Expand Up @@ -456,10 +452,7 @@ class Mat4 {
transformVec4(vec, res = new Vec4()) {
const m = this.data;

const x = vec.x;
const y = vec.y;
const z = vec.z;
const w = vec.w;
const { x, y, z, w } = vec;

res.x = x * m[0] + y * m[4] + z * m[8] + w * m[12];
res.y = x * m[1] + y * m[5] + z * m[9] + w * m[13];
Expand Down Expand Up @@ -642,9 +635,7 @@ class Mat4 {
setFromAxisAngle(axis, angle) {
angle *= math.DEG_TO_RAD;

const x = axis.x;
const y = axis.y;
const z = axis.z;
const { x, y, z } = axis;
const c = Math.cos(angle);
const s = Math.sin(angle);
const t = 1 - c;
Expand Down

0 comments on commit 7ae2e56

Please sign in to comment.