I’ve asked in another forum but I thought I would like to be more clear on my problem. I am having trouble in rotating the upper part of my model around a pivot point, like seen here:
I have looked at this question here and tried the example, but I also want to account for how to calculate the pivot point when it changes when the lower part rotates.
Edit: Here is what my current rotation looks like based on the linked question’s example:
Any help is appreciated!
This isn’t the complete answer, but take a look at the changes I made to the fiddle to get it working more as you described - https://jsfiddle.net/eh5zqa4r/1/
When you add the ‘pivot’ to Mesh1, it’s adding pivot to the Mesh1 geometries center. You want to move the pivot by half of the Mesh1 geometry height (which puts the pivot back to WORLD 0,0,0). Then when you add Mesh2 to Pivot, it’s back to the center of the world and rotates around the point in your visualisation. Take a look here too - https://stackoverflow.com/a/28860849
When I use pivots, I also attach a sphere to its position so you can visualise where the pivot point is in your world to help see what’s going on.
Hope this helps.
Thank you so much! Your solution has helped a lot, especially with repositioning the pivot back to world coordinates. I appreciate it!
Hi this has helped me a lot but do you know how I can get rid of the stationary rectangle in the jsfiddle?
I’ve been trying to remove it for ages and nothing has worked.
No problem. If you compare the two jsfiddles you should be able to see the commented out code to prevent the static rectangle being added to the scene and adding the rotating rectangle directly to the pivot.
I have the same question and did not quite understand everything.
If i have a mesh with position (1,1,1) and it is 1,1,1 big and want to rotate it at the point (1.9,1.5,1.5) i would have to code it like this, right?
var geometry = new THREE.PlaneGeometry( 1, 1, 1 );
var material = new THREE.MeshNormalMaterial();
var mesh = new THREE.Mesh( geometry, material );
pivot = new THREE.Group();
scene.add( pivot );
//Now i have to counter the position or not?? Because the pivot is translating my object…
Can somebody help me
I just signed up to write a thank you, it has been a headscratcher for me, trying to change the pivot point to do scaling upwards, you saved me!