SpaceToast Posted November 4, 2017 Share Posted November 4, 2017 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"))); Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 4, 2017 Share Posted November 4, 2017 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. Quote Link to comment Share on other sites More sharing options...
SpaceToast Posted November 4, 2017 Author Share Posted November 4, 2017 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! Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.