How can I import lights if I use SceneLoader.ImportMesh

Hello, I’m new around here :wave: and I’m starting my first big project with Babylon!

I’m importing a 3D room from Blender. If I use SceneLoader.Append everything loads ok, but I can’t access the individual meshes, so I’m using SceneLoader.ImportMesh. The problem is that this method does’t load the light, nor the normalmaps as far as I have investigated.

Is it there a well known strategy to achieve this?

Thanks for any help.

PS: Excuse me for my bad writing as I’m not native english speaker.

Hi. You need use append and you always can get meshes after load your file BABYLON.SceneLoader.Append("./", “duck.gltf”, scene, function (scene) {
// there you can do anything with your loaded meshes

Thanks K,

In that order of ideas, What am I doing wrong? If I use Append as de loader method I lose control over the camera and i’m not able to use the physics as Gravity or CollisionDetection, as I have it with ImportMesh. This is how I’m using the Append with no success. I create the camera and other meshes variables outside this function:


            function (scene) {
                floor = scene.getMeshByName("Floor.000");
                ceiling01 = scene.getMeshByName("Techo.000");
                room01 = scene.getMeshByName("Room.000");
                door = scene.getMeshByName("Door.000");

                floor.metadata = "piso";
                ceiling01.metadata = "techo01";
                room01.metadata = "sala01";
                door.metadata = "door";

                light01 = scene.getLightByName("Light.000");
                light03 = scene.getLightByName("Sun");
                camera = scene.getCamera("Camera");
                targetBox = BABYLON.Mesh.CreateBox("TargetBox.000", 0.5, scene);
                targetBox.position = targetPosition;

                scene.gravity = new BABYLON.Vector3(0, -0.9, 0);

                scene.collisionsEnabled = true;

                camera.checkCollisions = true;
                camera.applyGravity = true;

                camera.ellipsoid = new BABYLON.Vector3(1.7, 1.7, 1.7);

                floor.checkCollisions = true;
                ceiling01.checkCollisions = true;
                room01.checkCollisions = true;
                door.checkCollisions = true;


With this same code, but if I use the SceneLoader.ImportMesh method, meshes and camera physics work fine, but again no lights or cameras are imported.

Any ideas?

ImportMesh playground
with import mesh you only import scene meshes and NOT lights and other stuff
and append playground
with append you load full file scenegraph. SceneLoader - Babylon.js Documentation
look difference in playground console.

And on loaded scenegraph you cant get mesh by name you can get mesh by name only in BABYLON scenegraph after load your model in loader callback “function (scene) {}”