ActionManager on mesh imported from Blender

Good morning or good evening.
I’m back for a new problem (YES!!!).

On the one hand, I apologize again for my English!!

Well, I want to change the position of my camera on a mesh when I click on the mesh in question.

The mesh is imported from Blender.
I have positioned my meshes in different positions and used an ActionManager, but here comes the problem:
Here is an example of what I described (click on a sphere and the other on the rabbit3):


There’s an error message : " rabbit3 is not defined " ??
There are no problems with the sphere.

Moreover there are things I don’t understand :

BABYLON.SceneLoader.ImportMesh(“Rabbit”, “/scenes/”, “Rabbit.babylon”, scene, function (newMeshes, particleSystems, skeletons) {
var rabbit = newMeshes [1];

BABYLON.SceneLoader.ImportMesh(“him”, “/scenes/Dude/”, “Dude.babylon”, scene, function (newMeshes2, particleSystems2, skeletons2) {
var dude = newMeshes2 [0];

What is the purpose of the :

function part (newMeshes,…)

var dude = newMeshes2[0];

var rabbit = newMeshes[1];

I’ve already looked at the Babylon course, but I still didn’t understand it.

It’s good to use the code again, but using it without understanding anything is useless!

Oh yeah, before I forget, on another post : [Change Camera Position], I asked almost the same question (except changing the camera position on a non-imported mesh) so the code keeps the same shape (with ActionManager), and I thank @Deltakosh for helping me :heart:.

ME_me :slightly_smiling_face:

The reason rabbit2 is undefined is that it is locally/privately defined within a function, so at the point you try to use it in your code it can’t ‘see’ it. If you place

rabbit2.actionManager = new BABYLON.ActionManager(scene);

inside the import mesh function it will work - but not sure it’s necessarily the ‘best’ practice. I have tended to use AddMesTasks and then use the meshes once they complete loading (onSuccess).

The assign parts

var dude = newMeshes2[0]

Is just taking the mesh in the first position [0] of the Array loaded and using that one and assigning to variable dude, so that it can be used in your code as dude. For whatever reason the rabbit mesh is in the 2nd element [1]. Not sure what is in the first element, maybe a similar mesh or other - you can see this in the object tree in Blender.

Is this just a general play around? not quite sure what you’re attempting to achieve.

1 Like

Thank you for your answer.

Sorry for for the late reply, but I was so busy that I forgot to check the forum! :face_with_head_bandage:

And to answer your question, I had to create a virtual tour in a house or a space somewhere.
And I wanted to move directly to the position of the meshs (imported from blender) when you click on them.
ME_me :slightly_smiling_face: