gryff Posted September 29, 2014 Share Posted September 29, 2014 I'm trying to get my head around the functionality that allows lights to only illuminate certain meshes - namely using includedOnlyMeshes and excludedMeshes . And I seem to have run into a problem which hopefully you can see with this playground example Lights The example has two spheres, sphere(centre screen) and sphere2 (right side). Down the script four lights are set up and there are some marked lines of code for "turning off" the red and green lights for the centre sphere. The red light is "turned off" by using this line of code:light0.includedOnlyMeshes = [sphere2];which tells the red light to only illuminate the sphere2. Seems to work fine I then try to turn off the green light on the centre sphere with this line of code:light1.excludedMeshes = [sphere];which tells the green light not to illuminate the centre sphere. It does not work So is it my code or has something changed in BJS with the addition of "includedOnlyMeshes"? Any help appreciated before I pull out all my hair cheers, gryff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 29, 2014 Share Posted September 29, 2014 ARRGGGGGGGGGGGGGG!!!!! It was an awful copy/paste bug. Shame on me! I updated the version on github Quote Link to comment Share on other sites More sharing options...
Soulangel Posted November 24, 2014 Share Posted November 24, 2014 Hi, I would like use the ambient light only for specific mesh and his children,I understand that this is not possible because it only tested if the mesh given in parameter is in the list. Is it possible to test with the method Node.isDescendantOf on the mesh ? I guess not because it would consume too. Soulangel Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 24, 2014 Share Posted November 24, 2014 Unfortunately no due to performance issues:( Quote Link to comment Share on other sites More sharing options...
Venerated1 Posted April 3, 2017 Share Posted April 3, 2017 Okay, so... assuming that I'm not the only one who didn't see an answer on this thread, here is what I found: light.excludedMeshes.push(mesh0); light.excludedMeshes.push(mesh1); effectively removes meshes from the light source. http://www.babylonjs-playground.com/#1DLERH#1 I just made it so "sphere" only has the blue light with light0.excludedMeshes.push(sphere); light1.excludedMeshes.push(sphere); ALSO, to use light.includedOnlyMeshes.push(sphere); you first need to disable the light then enable it after... see the edit on my next comment. But this is what it looks like from the other direction: http://www.babylonjs-playground.com/#1DLERH#2 Quote Link to comment Share on other sites More sharing options...
Venerated1 Posted April 3, 2017 Share Posted April 3, 2017 Oh, I just realized that light.includedOnlyMeshes.push(mesh3); probably doesn't work because you probably have to clear the array first. EDIT: Clearing the array doesn't seem to change anything. However disabling the light and then enabling it again after seems to work fine! Like this: lightSaturn.setEnabled(false); lightSaturn.includedOnlyMeshes.push(saturn); lightSaturn.includedOnlyMeshes.push(rings); lightSaturn.setEnabled(true); So, hopefully that's useful. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 4, 2017 Share Posted April 4, 2017 The setEnabled should not be required I had a bug but now it should be ok http://www.babylonjs-playground.com/#1DLERH#3 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.