How to remove the matrix effect

Hello Three js team,

A quick help please. I want to know how we can remove the applied matrix from an vector.

Like

vector3 = vector3.applyMatrix4(matrix)

now vector3 have some matrix4 effect and i noticed my x,y,z also updated i want to redo this effect means

something like vector3.redo…

so i get back my original vector3

Thanks

Vector methods mutate the source vector (ex. vector.add(vector2) will change the original vector.)
You can use clone() to preserve the original vector.

const vectorA = new THREE.Vector3(1.0, 2.0, 3.0);
const vectorB = vectorA.clone().applyMatrix4(matrix); // vectorA will remain untouched

No this is not i am looking for. Actually i am taking some points and applying the matrix4 to place them properly in the model. Now my task is to again save them back to the db but for this i have to remove the applied matrix effects.

Is there any way to redo the matrix effect ?

An example

This is my vector point
{x: -1973.239999999998, y: 1731.13836, z: 15}

This is my matrix

{
“elements”: [
0.8660254037844387,
0.49999999999999994,
0,
0,
-0.49999999999999994,
0.8660254037844387,
0,
0,
0,
0,
1,
0,
-348.7943970038309,
-5653.1347137137145,
0,
1
]
}

This is my transformed point

{
“x”: -2923.239544767435,
“y”: -5140.544916487983,
“z”: 15
}

I want to transform this transformed point back to the vector point

See this thread as to whether it is something you should be aiming for performance-wise (instead of just saving the original coordinates to point.userData.)

Three does have a Matrix4.invert() method (in earlier builds it’s Matrix4.toInverse.)

1 Like

@mjurczyk thanks, i thought this was a solution but you gave me confidence and i put in my code it works.

Thanks a lot