MattB Posted August 27, 2018 Share Posted August 27, 2018 I'm trying to setup an interface so that you can toggle on and off objects or layers. Can anyone tell me why this isn't working and maybe a better way to do it? the error is from line 66, - Cannot read property of undefined. https://playground.babylonjs.com/#EN5MK5#2 Thanks! Quote Link to comment Share on other sites More sharing options...
Guest Posted August 27, 2018 Share Posted August 27, 2018 It was a closure problem: https://playground.babylonjs.com/#EN5MK5#3 (the i variable was captured, no worry this is a common JS error ) Quote Link to comment Share on other sites More sharing options...
MattB Posted August 27, 2018 Author Share Posted August 27, 2018 oh, thank you so much Deltakosh! And thankyou for pointing me to what I need to study - I've been reading about closures and scopes. So, is a partial reason my version didn't work is because "i" went to 3 and it was looking for layerMeshes[3]? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 27, 2018 Share Posted August 27, 2018 Absolutely 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.