Jump to content

Referencing Lights Imported From Blender


SpaceToast
 Share

Recommended Posts

How would I reference a light imported from Blender? I'm appending a scene with a directional light (sun) as follows:

BABYLON.SceneLoader.Append("", "museumScene.babylon", scene);

Now, if I add a "fire when fully imported" function to return the array of lights in the scene, I see my sun in the console just as I'd expect:

BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, console.log(scene.lights));

However, if I try to reference the sun in the normal way, I only get null:

BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, console.log(scene.getLightByName("sun")));

 

Link to comment
Share on other sites

SpaceToast!  heh.  What a great name. 

I wonder what a scene.render() BEFORE the console.log... would do.

I wonder what scene lights could be found in... scene.executeWhenReady(function() { here } );

Just a couple of things to try.  Probably nothing useful, though.  :)

Link to comment
Share on other sites

Your intuition was right, Wingnut. Not a Babylon problem. It was one of those Javascript issues I can never seem to keep straight:

BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, function() {console.log(scene.getLightByName("sun"));});

...creates a find-the-sun function that will be called when the loader finishes. This works!

BABYLON.SceneLoader.Append("", "museumScene.babylon", scene, console.log(scene.getLightByName("sun")));

...fires console.log() immediately when Append() runs, rather than waiting for the loader to finish. Hence, so sun!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...