Rotation makes object elevated with setPivot

Is this the same mesh/object that can attach to either corner of the parent and rotate? Or is it a different mesh? How many of these do you have and do they always attach to the corners of the ground or is it so that some could attach to corners of another mesh?
I would need the complete picture for this or else we might just be adding unnecessary code and create new problems on the next step…

Ok let me explain it to you

  1. There would be 8 corners to the ground - top left, top mid, top back, bottom left, bottom mid, bottom back
  2. All custom meshes will be aligned in top left part of rack (and they can be rotated there)
  3. There will be a button using which you can change alignment of this mesh to top mid, top back, bottom left, bottom mid, bottom back (which is basically updating there parent)
  4. in the example i gave you, i am trying to mimick the same, place a mesh in top left, try rotating it there, then change parent to bottom left and then again try rotation

I guess rotation i can manage, but as you see the point of parent has to be attached to proper corners o.w it affects rotation

Yes, well, what we will probably want to do here for a start is add a parent node (parent or transformNode to all of your 8 points of parenting of the ground. Next, depending on which one it is, we will adjust either width or depth with plus or minus depending on rotation (positiv or negativ).
Right now, I have a couple of things to attend to but if you give me some time, I will try set-up something for you that would match this requirement.

Thank you @mawa , i will start working on this, whatever is the progress i will send you playground link here
I have added 8 parents for now - https://playground.babylonjs.com/#72M8FM#7
updated link https://playground.babylonjs.com/#72M8FM#11

@mawa one more https://playground.babylonjs.com/#72M8FM#12 , if i reposition first mesh it looks good initially but then it does not rotate along its parent

@mawa i think i have got close to what you were saying
Babylon.js Playground here,

  1. but if i use the if condition the rotation does not work, don’t know why
    I basically want to use if condition to set different parents for 0th and 1th mesh and adjust position accordingly.
    But if i put same code outside if, it works (but then all mesh would have same parent)
  2. If both the mesh have same parent, then when we rotate parent on button click why does only one object rotate?

Looks like in the loop you created a duplicate parent for each Mesh (without changing the name).
This is likely to create some problems.
So in fine, can two meshes rotate independantly or simultaneously around a same parent location or not?

two meshes should rotate independently around same parent, so ideally a mesh would rotate for user (not all meshes of that parent)

1 Like

Well if so, we will need another approach. Or better said complete this approach.
Transforming a parent will always impact all children. And create a new parent at same location for each mesh doesn’t make sense. So, what I can think of here is to

  1. add a parent or transformNode to the 8 (parent) positions of the ground
  2. set a pivot or transformNode on each mesh that dynamically relocates to each corner of the mesh
  3. position this mesh transformNode (or pivot) to the main parent to initiate rotation or transformation around the main parent position
  4. unparent and reparent/reposition to new as required

It will take a bit of time to do that and for step2, we might have to reinstate boudingBox (or else we would need to know and declare all of height, width and depth of all meshes (I don’t know how many there are and if there can be new ones to be added).
Looks like we’re not there yet…

1 Like

once again thank you so much @mawa , let me work on it and see how it goes but i will surely get back to you :slight_smile:

1 Like

Yes, sry. It’s nearly dinner time for me (better said, time to make dinner because it won’t appear automagically :wink: but I’ll have another look at your progress tomorrow. Meanwhile, have a great time,

@mawa this is how i did it at the end https://playground.babylonjs.com/#XE64QD#14
any improvisation or thought you have would be helpful

1 Like

What can I say. It works. If it works and works for you that’s all that matters. There are nearly always different methods and approaches you can use with BJS (one reason why I luv it :smiley: Probably I would have done it slightly differently. Probably another person would have done it in another way. It all doesn’t matter as long as it works for you and you can manage/maintain it.
Let me know if you have some other issue that has not been thought off… Else GJ, :smiley: