Closed kapilreddy closed 13 years ago
Depending of what you're after you could just offset all the vertices instead. But I agree, having a pivot could be useful. I haven't had a chance to implement yet (there have been some branches that implemented that, plus hierarchy, but haven't had a chance to properly merge them and test it yet).
Yes hierarchy is also a good addition. Could you please point me to the brances that actually implement pivot and hierarchy
Why has this been closed? Hierarchy will be an essential feature moving forwards although I cannot find any trace of support yet...correct me if I am wrong.
I'll open an issue for Hierarchy
A workaround was suggested. I think it was via twitter :S
I had a quick search but couldn't find anything relevant. Do you remember what was suggested?
Basically, offset the vertices instead. If you want the pivot to be at 100,0,0... offset all the vertices -100,0,0. Not an ideal solution but is a good workaround and saves a bunch of computations.
Hey i am back on it after a while but seems like offseting vertices is not a good idea if you want alot of objects rotating on a same pivot.
Have you tried grouping them?
Take a look at examples/webgl_geometry_hierarchy.html
So basically children and parent properties are used to define hierarchy?? Can two parents have same children?
Yes and no.
Still the problem remains how to define pivot of group. I am trying to make a rubik's cube I can now changing grouping of small groups according to mousemove vector but pivot of each group still giving problem.
That's an interesting use case. Wouldn't the pivot be the center of the group?
The pivot is pivot of object first in the group and not the center.
http://dl.dropbox.com/u/13195512/rubik/rubikscube.html you can check if its done wrong way here.
Hope this illustrates:
var group = new THREE.Object3D();
var geometry = new Cube( 10, 10, 10 );
var material = new THREE.MeshBasicMaterial( { color: 0x00ffff } );
var cube1 = new THREE.Mesh( geometry, material );
cube1.position.x = 30;
cube1.position.z = 30;
group.addChild( cube1 );
var cube2 = new THREE.Mesh( geometry, material );
cube2.position.x = 30;
cube2.position.z = - 30;
group.addChild( cube2 );
var cube3 = new THREE.Mesh( geometry, material );
cube3.position.x = - 30;
cube3.position.z = - 30;
group.addChild( cube3 );
scene.addObject( group );
group.rotation.y += 0.5;
Yes that is ok if i want the pivot to be fixed but as you can imagine pivot and group in case of rubik's cube would be dynamic
i have a wind turbine. i want to rotate the wind turbine. wind turbine is a 3d object. when i am trying to rotating it is getting displaced from it center. the rotation is not perfect. it maybe an issue with my pivot point. pls help
var pointToRotateAround;
var objectToRotate;
var pivot = new THREE.Object3D();
//loading 3d turbine
var loader = new THREE.JSONLoader();
loader.load("model/fan.js", handle_load11);
function handle_load11(geometry){
fan1 = new THREE.Mesh(geometry, material);
fan1.scale.set(8,8,8);
position=fan1.position;
var box = new THREE.Box3().setFromObject( fan1 );
geometry.applyMatrix( new THREE.Matrix4().makeTranslation(position.x, position.y, position.z) );
box.center( fan1.position ); // this re-sets the mesh position
fan1.position.multiplyScalar( -1);
var axis = new THREE.Vector3(-0.5 ,0, 0 )
pivot.position= axis;
//pivot.position=fan1.position;
pivot.add(fan1);
scene.add(pivot);
}
//rotating turbine
pivot.rotation.x += .2;
ummm...
A pivot for rotation for a objects would useful. Right now I am doing that using a locus equation but in built feature would be useful