The correlation between position and vertices is noteworthy. Imagine a scenario in which a mesh is situated at (0, 0, 0)
, yet appears in an entirely different location due to the large numerical values of its vertices. The vertex position essentially denotes a location that is relative to the object's position. Consider your plane defined by
new THREE.PlaneGeometry(500, 500)
:
(-250, 250, 0) (250, 250, 0)
*--------------------------*
| |
| |
| |
| (0, 0, 0) |
| O |
| |
| |
| |
*--------------------------*
(-250, 250, 0) (250, -250, 0)
The symbol O
represents the origin. Upon applying a transformation:
(-235, 250, 0) (265, 250, 0)
*--------------------------*
| |
| |
| |
| (0, 0, 0) |
| O |
| |
| |
| |
*--------------------------*
(-240, 250, 0) (260, -250, 0)
Although the parallelogram shifts slightly, the origin remains unchanged as its position was not altered intentionally. An example of a geometric shape following a similar concept can be depicted as:
(500, 250, 0) (750, 250, 0)
*--------------------------*
| |
| |
| |
(0, 0, 0) | |
O | |
| |
| |
| |
*--------------------------*
(500, 250, 0) (750, -250, 0)
Remarkably, this configuration remains valid. The primary concern lies in your objective. It is advisable to refrain from manipulating a mesh by adjusting vertex positions solely. Moreover, if your intention involves deforming the mesh along with shifting its vertices independently while keeping the mesh centered:
var boundingBox = new THREE.Box3().setFromObject(mesh);
var centerDisplacement = boundingBox.getCenter().sub(mesh.position); // Difference between current position and center
geometry.vertices[0].add(centerDisplacement);
geometry.vertices[1].add(centerDisplacement);
geometry.vertices[2].add(centerDisplacement);
geometry.vertices[3].add(centerDisplacement);
geometry.verticesNeedUpdate = true;