Obtain position, rotation, scale from mesh to store onto a db

Hi to all , and thank you for a great library.
I am currently creating a prototype that allows our system users to import assets onto a precreated environment.
Once imported , i create a UtilityLayer and a BoundingBoxGizmo

 BABYLON.SceneLoader.LoadAssetContainer(My_ASSET_URL, "", scene.value, function (container) {
        var meshes = container.meshes;
        container.addAllToScene();
        // Scale and position the loaded model (First mesh loaded from gltf is the root node)
        meshes[0].position.set(initpos.x, initpos.y, initpos.z)
        meshes[0].scaling.scaleInPlace(1)
        var gltfMesh = meshes[0]
        var boundingBox = BABYLON.BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox(gltfMesh)
        
        var utilLayer = new BABYLON.UtilityLayerRenderer(scene.value)
        utilLayer.utilityLayerScene.autoClearDepthAndStencil = false;
        var gizmo = new BABYLON.BoundingBoxGizmo(BABYLON.Color3.FromHexString("#dd5400"), utilLayer)
        gizmo.attachedMesh = boundingBox;
        // // Create behaviors to drag and scale with pointers in VR
        var sixDofDragBehavior = new BABYLON.SixDofDragBehavior()
        boundingBox.addBehavior(sixDofDragBehavior)
        var multiPointerScaleBehavior = new BABYLON.MultiPointerScaleBehavior()
        boundingBox.addBehavior(multiPointerScaleBehavior)
        boundingBox.actionManager = new BABYLON.ActionManager(scene.value)
      // Actions to listen to scale end, rotate end etc.

}

My question is what values should i be getting to be able to store onto my db , in order to reposition the same asset onto the edited place ?
I already tried a number of things by applying listeners for the gizmo.onRotationSphereDragEndObservable and for gizmo.onScaleBoxDragEndObservable , but i am lost into what exact values i need to store (boundingbox, sixDofDragBehavior, gizmo, gltf).
also please let me know if possible the correct way to render them on the specific position with rotation and scaling coming from db.
Thank you in advance

Hello and welcome to the Babylon community! You’ll probably want to be saving the position, rotation/rotationQuaternion (be aware that if rotationQuaternion is used it supersedes rotation) and scaling :slight_smile:

Thank you very much for the quick response.
my problem is that if i get the meshe’s position and rotation/rotationQuartenium, this returns zero , since probably it is now a child of the bounding box.

Then you’ll want the ones from the bounding box.

Thank you very much for your help,
I discovered my mistake in the process. the solution is to get the position, rotationQuaternion and scaling of the bounding box, and in order for the model to load in the correct position i need to create the bounding box again , atach the mesh and then apply the properties to the bounding box.
By applying the transformations directly to the mesh i am getting wrong placement.
thanks again

2 Likes