Giter VIP home page Giter VIP logo

Comments (19)

mrdoob avatar mrdoob commented on May 3, 2024

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).

from three.js.

kapilreddy avatar kapilreddy commented on May 3, 2024

Yes hierarchy is also a good addition. Could you please point me to the brances that actually implement pivot and hierarchy

from three.js.

pyrotechnick avatar pyrotechnick commented on May 3, 2024

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

from three.js.

mrdoob avatar mrdoob commented on May 3, 2024

A workaround was suggested. I think it was via twitter :S

from three.js.

pyrotechnick avatar pyrotechnick commented on May 3, 2024

I had a quick search but couldn't find anything relevant. Do you remember what was suggested?

from three.js.

mrdoob avatar mrdoob commented on May 3, 2024

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.

from three.js.

kapilreddy avatar kapilreddy commented on May 3, 2024

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.

from three.js.

mrdoob avatar mrdoob commented on May 3, 2024

Have you tried grouping them?
Take a look at examples/webgl_geometry_hierarchy.html

from three.js.

kapilreddy avatar kapilreddy commented on May 3, 2024

So basically children and parent properties are used to define hierarchy?? Can two parents have same children?

from three.js.

mrdoob avatar mrdoob commented on May 3, 2024

Yes and no.

from three.js.

kapilreddy avatar kapilreddy commented on May 3, 2024

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.

from three.js.

mrdoob avatar mrdoob commented on May 3, 2024

That's an interesting use case.
Wouldn't the pivot be the center of the group?

from three.js.

kapilreddy avatar kapilreddy commented on May 3, 2024

The pivot is pivot of object first in the group and not the center.

from three.js.

kapilreddy avatar kapilreddy commented on May 3, 2024

http://dl.dropbox.com/u/13195512/rubik/rubikscube.html you can check if its done wrong way here.

from three.js.

mrdoob avatar mrdoob commented on May 3, 2024

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;

from three.js.

kapilreddy avatar kapilreddy commented on May 3, 2024

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

from three.js.

shravanimmy avatar shravanimmy commented on May 3, 2024

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;

from three.js.

Mugen87 avatar Mugen87 commented on May 3, 2024

@shravanimmy Please use the forum or stackoverflow for help requests.

from three.js.

arnavzek avatar arnavzek commented on May 3, 2024

ummm...

from three.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.