Forum

Loading lights from multiple scenes

28 July 2017 10:58
I'm working on a 3d app that is split between multiple scenes. I have a single master scene that contains common objects like the camera object, and several environment scenes that each contain their own lights. In my app I'm loading the master scene with scenes.load() first, and then loading one of the environment scenes. The trouble I'm having is that the b4w runtime isn't loading the lights from any scenes loaded after the initial scene. Is it possible to load the lights from my environment scenes?
28 July 2017 11:48
If you have a look at the Cartoon Interior example project in your SDK, it loads a number of items dynamically. These have lights. The blend files can be found in blend4web_sdk/blender/tutorials/cartoon_interior/



*Edit*
After doing some checking, these loaded lights don't seem to effect the scene.
28 July 2017 14:25
Actually, lamps cannot be loaded dynamically. The only solution is to have them all in the initial scene and turn on/off at a proper time by using the set_light_energy or hide_object/show_object methods.
Blend4Web Team
28 July 2017 17:56
Good to know Ivan, thanks.

Pedwards, if you want to try what Ivan suggested, here is a post about hiding and showing lights using logic nodes with examples you can download.
31 July 2017 03:09
Thanks a lot for your answers guys!
20 August 2017 17:15
Hi,

I'm new to B4W.

When I'm using
set_light_energy
from
preloader_callback


while
preloader_callback
is being called after scene has finished loaded:
m_data.load(file, loaded_callback, preloader_callback, false);


the
set_light_energy
seems to work fine but when I'm trying to use it after the scene has finished loading
set_light_energy
doesn't work.

Can anyone please help me with this one?
20 August 2017 17:30
Hi Ranbuch,
In order to debug code, I need to see the complete project. Or you can make a small demo project that has the same issue. Use the "Export Project" function in your project manager to export a project zip file that I can then import.
21 August 2017 06:38
O.K. I'll give it a try.

In the meantime, can you please refer me to some online demo with lights change if you have one?
21 August 2017 07:40
What is your ultimate goal? Maybe if I knew what you planned to do, I could suggest something.

Here is an example of a light being turned on and off.
22 August 2017 06:27
I need to allow the top Window alter the light energy of the scene within the iframe.

I can alter the scene with a function that I've wrote with
setTimeout
but unable to do the same with a button click or a
postMessage
event from the top Window.

    It's the same function The
    this
    
    is always the
    window
    
    object I've tried to invoke the function with
    apply
    
    but it doesn't seems to work. When debugging the
    set_light_energy
    
    method, in both cases it looks pretty much similar.

Thank you for your help.
 
Please register or log in to leave a reply.