SceneLoad.load not working / using blender exporter


This is yet again a follow up on my last post. I have this playground:

The scene has an imported scene from blender. It has a rectangle scope, a plane that will show the scope sight, and a random camera. I would like to use the camera from the scene as the camera used for the render target texture, What can I do? Any help?

SceneLoader.ImportMesh will only import meshes: use SceneLoader.load instead.

1 Like


Wait, what am I doing wrong?

BABYLON.SceneLoader.Load("", "", "scope%20test.babylon", scene, function (newStuff) {
        splan = newStuff[1];
        splan.material = material;
        renderTargetTexture.activeCamera = newStuff[2];
        //var scam = newMeshes[2];

(Pg #7 if you want to try it.)

How do you think this could work?

renderTargetTexture.activeCamera = newMeshes[2];

Cameras are not meshes :slight_smile:

This is better:

1 Like

I see, but I’m trying to use sceneloader.load. I have a camera exported in the scene from blender called scopecam

I want to use that as the camera showing on the scope.

I might be wrong but

gives you array of cameras that you have in the scene. So instead of part of your code where you search meshes with that name

if (newMeshes[0].name == scopecam) alert(“lol”);

you need scene.cameras[i].name == scopecam.


This alerts you with 2 cameras, scope2 and camera. When I change line 61 to be BABYLON.SceneLoader.Load, the playground freezes. It’s not loading the camera from the .babylon file.

well it works with Append at least:

It also works with Load but it will generate a new scene

1 Like

So, Append is like a totally new scene? Now how would I not have it do that but also have the camera be the render target texture?

No Append is the opposite. It appends to the current scene
Load will create a new scene

1 Like

Oh. Why can’t I move the camera? The active camera is set to the one from the blender scene.

Because you need to restore the active camera as the Append has used its own:

1 Like

Ok, but why does adding a texture the scopeplan (newMeshes[1]) freeze it again?

NM I put the line that reasigns the camera at the beginning, but now scopeplan doesn’t show anything.

Just hover your mouse over newMeshes

Append callback returns the scene not the list of meshes:

1 Like

so, How do I set the texture of scopeplan to material? (used scope here because it is the big mesh and easier to see, i guess)

Something like that:
scene.getMeshByName("scopeplan").material = ...

1 Like

This doesn’t seem to work :confused:

What is “scope” ? I feel like there is a JavaScript problem here :slight_smile:
You have to use a string in the getByName and scope seems undefined in your PG


It’s the big rectangle

Like DK said. You need to have string inside getMeshByName(‘scope’);