I have a door model, it has an Object3D called “body”. This body holder has 2 meshes “body_1” and “body_2” and another Object3d “pivot”, which specifies a position where I should put a handle.
It works OK, but the actual model is small, so I have to scale it. But when I scale the “body” object (I have to scale “body” and “handle” separately) it doesn’t update the position of pivot and when I try to place a handle there - it has quite wrong position.
This is how it should look like:
How can I update pivot position after scaling the doot?
Thanks for any help
Should be enough to just scale the pivot by the same amount as the window.
If the handle translation is locked to the pivot, then make sure the pivot position scales with the window scaling, by matching their own pivot points/origins. However whats the point of having a separate pivot coordinates when each model already has its own pivoting/origin coordinates. Im assuming the handle is something you want to rotate later on, the easiest fix for this is to delete the pivot and adjust the window pivot point to match the handle pivot. Or an even easier fix is to prescale your objects and apply them, and let each model have their own pivot/origin point. This can be done via code if you adjust the scaling and matrix4 positions, but the same result can be achieved 5x easier and faster in a 3D program like Blender.
Nope, it just adds scale to Object3D “pivot” but nothing really changes for handle mesh
Unfortunately current structure is mandatory, because we’re planning to do some things separately for handles, body and frame of the door, such as texturing with custom textures.
So for now I just added pivot into body holder, then I scale body. After that I copy pivot position to handle mesh.
It has to be dynamic
How do you place the handle at the pivot position? .position / .getWorldPosition? (ie. use first one if both objects are parented to the scene, use second one if one object is parented to the scene and another object is not, rethink life choices if both objects are not parented to the scene and you try to align one object from one parent to another object from another parent )
Retiring is always the best option
Both handle and pivot are placed inside one model structure, but pivot is inside “body” holder and handle itself is inside “handle” holder:
– root (Object3D)
–-- body (Object3D)
-------- body_1 (Mesh)
-------- body_2 (Mesh)
-------- pivot_1 (Object3D)
–-- handle (Object3D)
-------- handle_1 (Mesh)
For copying position I just use something like
But the resulting position is too small. Maybe I should multiply that vector somehow
I’ve left a reply above, for some reason it didn’t attach to your comment
Yes, this copies the local position - so if you copy position of an object of one parent into position of an object from another parent, it’ll stop working as soon as you apply any transformation to either parent.
Before diving into math - is there a reason why handle pivot cannot belong to the same parent as the rest of the bodies? The flatter your scene hierarchy, the less issues like that you’ll encounter on the way.
is there a reason why handle pivot cannot belong to the same parent as the rest of the bodies
What do you mean? “Body” holder includes 2 meshes and this pivot on the same level
But you want to align pivot to handle, no?
I want to place handle correctly using pivot position.
If you mean separation between “handle” and “body” holders - that’s mandatory structure to use