A newbie problem about Local Space and Object Space

Hello there!
recently I looked into Local Space and Object Space.
I found this :

`Object space`

Object space is the coordinate system from an object's point of view. 
The origin of object space is at the object's pivot point, 
and its axes are rotated with the object.

`Local coordinates`

Local space is similar to object space,
however it uses the origin and axes of the object's parent node in the hierarchy of objects. 
This is useful when you haven't transformed the object itself,
but it is part of a group that is transformed.

One way to understand local space is to imagine an object sitting within a box. 
All of the points on the object's surface are then given with respect to one corner of the box.
If you pick up the entire box and move it around the room, 
the coordinates of the object—with respect to the box—do not change: 
the coordinates of the box with respect to the room are changing. 
Focus on the two different descriptions: 
the object with respect to the box (the object's position in local space), 
and the box with respect to the room (the position of the object in worldspace).

I’m confused with those terms.
I have a example bellow :

const geometry = new THREE.CylinderGeometry( 5, 5, 20, 32 );
const material = new THREE.MeshBasicMaterial( {color: 0xffff00} );
const cylinder = new THREE.Mesh( geometry, material );

cylinder.translateZ(100)
cylinder.rotateX(Math.PI/2);

Can someone explain to me what happened to Cylinder’s Local Space relative to World Space?
Docs :

#.translateZ ( distance : Float ) : this

Translates object along z axis in object space by distance units.

#.rotateX ( rad : Float ) : this

rad - the angle to rotate in radians.

Rotates the object around x axis in local space. 

Edit 1: add some breaks on the explanation so it can be more readable

translateZ move local coordinates

At least in three.js there are only the terms local and world space. Object space is used as a synonym for local space.

Before translateZ executed,it’s Local Space Axes are the same to the World Space Axes.Yes?
After translateZ executed , what happened to it’s Local Space Axes?Does it moved too?Or it still the same to the World Space?

Ah!By the way, If

cylinder.add(new THREE.AxesHelper(50))

Can this Axes stand for it’s Local Space Axes?

I dont know english very good.
Then you translate local space, its change vertices coordinates, world space is default.
Position of object is world space → if object without parent.
World position of vertices is sum of object position(scale,rotation) and local space of vertices.
Example. Object position was 0,0,0. Local vertice position was 1,1,2.
Then world space position of one vertice will 0+1,0+1,0+2 = 1,1,2.
Then translateZ vertice position to 4 will 1,1,2+4= 1,1,6
Then worls space of one vertice will 0+1,0+1,0+6 = 1,1,6.
Add 3 to Object positionZ will 0,0,0+3=0,0,3.
World space position of one vertice will 0+1,0+1,3+6=1,1,9

I mean “World position of vertices” is matrixWorld*mesh.geometry.position (local vertices positions)
World position of object is mesh.position

No, since the AxesHelper will also honor the transformation of the cylinder’s ancestors.

I’m still not quite comprehend this Local Space term.In threeJS Local Space means the object itself or it’s parent(ancestors)?If it means the latter ,then an object is added to scene,it’s Local Space is the World Space?

Thanks for replying!I think I understand what you mean.So Local Space means it’s parent’s Space?if it’s directly added to the scene,then it’s the World Space?

If no parent. Then local position of object = world position of object.
If have parent. Then world position of object = parent.position+object.position
Or parent.worldMatrix*object.matrix
Few amount of peoples change scene position thats why we mean that object without parent. But in real all objects have parent in it is Scene.

1 Like

OK,I got this one , another problem is RotateX,it doesn’t seems it rotate along world space(it’s parent space) X axes,more of like Z axes or it’s own X axes?

Its not parent rotation. Mesh have mesh.rotation._x and mesh.rotation.x
mesh.rotation.x is Object’s local rotation (Euler angles) in radians.
mesh.rotation._x dont know but then change rotation.x then rotation._x get same value