Highlight + importmesh

Hi,

I am trying to have an imported mesh highligthed on a “mouse over” event.

I’ve been able to have it work with simple created geometry but not with imported mesh.

Here is a working version of highlight/click and drag with simple geometry :

https://www.babylonjs-playground.com/#1KUJ0A#383

Here is the version working (with not working code in comment) :
https://www.babylonjs-playground.com/#12CWQQ#55

Please change #55 to #54 to have the non-working version (new user cannot post more that 2 links…).

I receive the error “cannot read property ‘uniqueid’ of undefined”.

It seems I don’t understand how the context works.

Hi,

Working! here is the final code :

https://www.babylonjs-playground.com/#1KUJ0A#385

Finally got it working, needed to add a few things :
https://www.babylonjs-playground.com/#12CWQQ#62

var head = new BABYLON.Mesh(“name”,scene);

(my import was from sketchfab, meshes[0] didn’t work. I needed to use meshes[1]. I don’t understand the difference but one has .subMeshes and not the other)

Add a verification if the mesh was loaded before using it (highlighting it)

Thank you,

Hi. I think meshes[0] it’s root node. You can open model in Babylon inspector and look at hierarchy

1 Like