How to remove the boundingbox?

Hi all (@trevordev)
I have my meshes wrapped with a boundingbox using the MakeNotPickableAndWrapInBoundingBox command. At some stage using a JS function I need to clone the wrapped mesh.Therefore I need to remove the boundingbox. How do I do that ?

I have created a PG scenario, where if I click anywhere outside the boundingbox mesh, the boundingbox with it’s gizmo should be removed. What is the command if any exists?
https://playground.babylonjs.com/#TMBNGD#4

Well this cannot work:

@Jacob you should be able to do wrappedObject.setParent(null)

See Babylon.js Playground

1 Like

Trevor

As you can see from the PG sample, that setParent(null) does NOT do the job. On the screen it’s still the bounding box and not the wrapped mesh…
https://playground.babylonjs.com/#T9FAAW#1

pinging @Cedric as well

I’m taking a look

@Jacob

setParent will unparent the sphere and the bounding box but the bounding box is still in the scene and clickable. so if you click on the sphere, the raycast will pick the bounding box.
I didn’t manage to filter the raycast to not pick the bounding box. Doing that:

sphere.setParent(null);
boundingBox.dispose();

I get the sphere picked. But You have to recreate the bounding box after.

Thanks

dispose() in addotion to setParent does the job and YES the bounding box needs to be recreated