# worldToLocal visual representation

Hi guys, I am having difficulties in visualizing how the worldToLocal method works, I understand the localToWorld but I can’t visualize the worldToLocal… I know is stupid but my brain somehow is not computing this

I would appreciate some assistance maybe something visual.

Thank you!

Example of mesh children position.x in world. Mesh parent position.x is 2 meters and his world position 2 meters too. Mesh children local position.x 3 meters. mesh children localToWorld position.x will be 2+3=5 meters. worldToLocal wiil be 3-2=1 meters. If i right.

``````localToWorld(vector) {
return vector.applyMatrix4(this.matrixWorld);
}
worldToLocal(vector) {
return vector.applyMatrix4(_m1\$1.copy(this.matrixWorld).invert());
}
``````
2 Likes

It’s just transforming the relation between two points. World-space vector is an arrow between your point and world (0,0,0) point. Local-space vector is an arrow between same your point and origin of some object.

Applying worldToLocal moves the origin from world (0,0,0) to the local (0,0,0) of the object - so that the resulting “arrow” is pointing to your point, but from the local origin.

Applying localToWorld moves the origin from object (0,0,0) to world (0,0,0) - so that the “arrow” is still pointing to your point, but from world (0,0,0).

Example (line 43 uses `worldToLocal` to transform world-space vector to local-space vector, pointing towards the same point, but with a different origin)

1 Like