How can I create a meshButton3D for a abstractMesh loaded by sceneLoader?

I’ m a new guy from China. Sorry for my poor English if I didn’t describe my question clearly.
I tried to load a gltf mesh from Blender and created a meshButton3D for it so that I can click it to do something. However, the postion of the mesh changed(It occured a offset I suppose) after I added control to the meshButton3D(I also did this: <BABYLON.Mesh>scene.getMeshByID("book1.003") cause meshButton3D only receive BABYLON.Mesh instead of BABYLON.AbstractMesh).
So I wonder whether there is a better way to create meshButton3D for a mesh loaded out of Babylonjs. Please tell me if you have an idea. Thanks a lot!

1 Like

Welcome aboard!

Could you make a repro of your problem in the Playground? That will be easier to answer you.

Yes. Please check this: #W8YH82#1. I displaced some of the code for some reason(I can’t visit most of the websites which offer services of file uploading etc.). Thanks a lot, anyway.

You need to create a 3D manager and add the control to it:

https://playground.babylonjs.com/#W8YH82#2

However, it still does not work, it seems the pointer events / picking don’t work as expected.

Adding @PolygonalSun in case he could have a look, as this sample from the doc does not work in 5.0 but does in 4.2: https://playground.babylonjs.com/#8Y780Y#20. I don’t know if it’s a problem with the events themselves or with picking code…

Lemme take a look and see what’s going on

Yes thanks for your relpy! I forgot to add the 3D manager in Playground actually. Some of the code needs to be modified in Playground and I missed it. I don’t sure if this error is caused by my ‘Mandatory type conversion’. I received a warning in Vscode that I would lose 111 properties if I convert AbstractMesh to Mesh, but a type error will occur if I don’t do that.

That’s very kind of you. I don’t sure if this error is caused by my ‘Mandatory type conversion’. I received a warning in Vscode that I would lose 111 properties if I convert AbstractMesh to Mesh, but a type error will occur if I don’t do that. Maybe there is a better/right way to create a 3D button for a imported mesh?