How to drag more than one object multiple times :)

Well here is another question from the newbie :smiley: I actually am experimenting with a scene of 3 meshes: a sphere and 2 cones. I want to drag the objects with my mouse and put them in the scene wherever i want.

So i did this:

 sphere.isPickable = true;
cone.isPickable = true;
cone2.isPickable = true;

var actualmesh;

 scene.onPointerDown = function (evt, pickResult) {
    // We try to pick an object
    if (pickResult.hit && pickResult.pickedMesh.isPickable==true) {
      actualmesh = pickResult.pickedMesh;
      actualmesh.addBehavior(pointerDragBehavior);
    }
};

 scene.onPointerUp = function (evt, pickResult) {
     actualmesh.addBehavior(pointerDragBehavior.release);
 }

However if I do so, I can move the objects, but only the latest one picked keeps moveable. To me it seems that I did not get the point with poitnerDragBehaviour clearly and how to attach my meshes properly to it. Maybe someone can lend a helping hand and advice how to perform this properly :slight_smile:

take a look at this example Markus:
https://www.babylonjs-playground.com/#UZ23UH#0

1 Like

thanks a lot :slight_smile: I found the example before but hoped there would be an easier way by using pointerDragBehavior :))

well I analyzed the example and was able to implement it in my scene. I can now handle pickable and not pickable meshes as well. thanks a lot. #solved