Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js - Translating vs Moving?

Let's say I have a custom cube mesh, where the origin is at one of the corners. I would like to specify the origin of the cube to be in the center of it. I understand that I can do a translation, and it seems to work (I can prove it works by rotating the cube, which rotates about the mid-center point).

However, I've always thought that translation was simply moving to another point in 3D space (rather than setting the origin point).

Am I missing something or am I simply confusing 2 things which are actually the same thing?

* To summarize *

Note that if I want to move an object, I just simply update the position vector. And applying a translation SEEMS to be updating the origin point. My confusion comes from my understanding that a "translation" is just a fancy term for "moving" an object in 3D space. Therefore, what exactly is a translation (moving in 3d space, or updating the origin point, or both)?

like image 299
AlvinfromDiaspar Avatar asked Sep 13 '14 08:09

AlvinfromDiaspar


People also ask

What is matrix in three js?

Three. js uses matrices to encode 3D transformations---translations (position), rotations, and scaling. Every instance of Object3D has a matrix which stores that object's position, rotation, and scale.


1 Answers

A translation on geometry moves the origin:

var geometry = new THREE.CubeGeometry( 1, 1, 1 );
geometry.applyMatrix( new THREE.Matrix4().makeTranslation( 0, 0.5, 0 ) );

A translation on an Object3D moves the position:

var obj = new THREE.Mesh(geometry, material);
obj.position.set(0.5, 0.5, 0.5);
like image 142
IceCreamYou Avatar answered Oct 15 '22 18:10

IceCreamYou