Jump to content

Gizmo and pivot of meshes merged


Dad72
 Share

Recommended Posts

@trevordev, Hello,

I find a bug on the gizmos when we merge objects.

If I am merging two objects and then replacing the pivot in the center of this new merge object. The gizmo is no longer on the pivot of this new objects but anywhere, corresponding to vector3(0,0,0).

http://playground.babylonjs.com/#8GY6J8#160

On my project the pivot is totally shift to several units of the object (it depends on the meshes)  See the picture :

1257664290_2018-09-1615_15_52-Greenshot.png.f202727574a048315692353a7b3f03e6.png

Link to comment
Share on other sites

@Deltakosh

In fact it is not the gizmo that is misplaced, but setPivotPoint which is not updated when objects are merged.

On this PG we can see that the gizmo is placed in the same place, whether I use setPivotPoint or not.

The point of the center of the object is the good one, it is the small white sphere which serves as indication

http://playground.babylonjs.com/#8GY6J8#161

Link to comment
Share on other sites

@trevordev,

No, it does not work completely.

If I want to select the object later, the gizmo is not well placed, it comes back as before.

Moreover, we have to select one of the two rabbits. the object is not considered as a single sectionable with pickResult.pickedMesh.

The fact of creating a new BABYLON.Mesh  makes me lose all give to serialize the merge object.

http://playground.babylonjs.com/#8GY6J8#164

The pivot seems to place correctly on the merge object. Why the gizmo can not be placed on this pivot point?

Looks like MergeMesh has a lot of different problems at home? problem of placement of the Gizmo, problem of material which disappears with multiple materials. I'm starting to wonder if I will not remove the merge from my software, because I can not do anything right.

Link to comment
Share on other sites

To get the gizmo in the right position again, maybe you could check if the selected mesh has a parent and use that if it exists to attach the gizmo.

 

Can you provide more details about what you are trying to build?

Are you looking for the ability to group any number of objects and move them around with gizmos or something else?

How would you like the serialization to work?

Link to comment
Share on other sites

I add the last two lines that allow to replace the object to merge to its original place and refreshing the BoundingInfo Speckle my object to disappear when I am too close to the object.

I can solve, it works on my project. Thanks again

let boundingInfo = meshMerged.getBoundingInfo().boundingBox;
let middlePivot = new BABYLON.Vector3(boundingInfo.center.x, boundingInfo.center.y, boundingInfo.center.z);                        
meshMerged.setPivotMatrix(BABYLON.Matrix.Translation(-boundingInfo.center.x, -boundingInfo.center.y, -boundingInfo.center.z), false);
meshMerged.bakeCurrentTransformIntoVertices();
meshMerged.setPivotMatrix(BABYLON.Matrix.Identity());                        
meshMerged.position = middlePivot;
meshMerged.refreshBoundingInfo();

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...