JCPalmer Posted January 22, 2015 Share Posted January 22, 2015 I need to store a boolean property in a BABYLON.Mesh that is not defined in it, for cloning purposes. This is no problem for javascript:meshVar.castShadows = true;Tower of Babel generates both a .js and .ts. The above line will not compile. Was looking @ .bind, but this seems to be for functions. Anyone know the way to do this? A related question is how would you then access it later? Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 22, 2015 Share Posted January 22, 2015 Fastest way:meshVar["castShadows"] = true;Best way would be to create an interface with the property. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 22, 2015 Author Share Posted January 22, 2015 Works. Also, am generating this module function to access castShadows, for anyone searching in future: function freshenShadowRenderLists(scene) { if (!BABYLON.Engine.Version || Number(BABYLON.Engine.Version.substr(0, BABYLON.Engine.Version.lastIndexOf("."))) < 2.0) throw "Babylon version too old"; BABYLON.Tools.Log('In freshenShadowRenderLists'); var renderList = []; for (var i = 0; i < scene.meshes.length; i++){ if (scene.meshes[i]["castShadows"]) renderList.push(scene.meshes[i]); } for (var i = 0; i < scene.lights.length; i++){ if (scene.lights[i]._shadowGenerator) scene.lights[i]._shadowGenerator.getShadowMap().renderList = renderList; } } module_name.freshenShadowRenderLists = freshenShadowRenderLists;Am in testing phase for TOB 2.0. Have modified the first test to do mesh factory cloning. https://googledrive.com/host/0B6-s6ZjHyEwUUW9HX1lqbnFLRzA Looking at console: Gus mesh requested: Gus mesh & children meshes instanced ShadowGenerator built with embedded freshenShadowRenderLists() call. Gus mesh requested: Gus mesh & children meshes clonedSince Cloned after freshenShadowRenderLists(), no shadow for it.First Click "Orphan - Conceive" toggle to see shadows of kids with parentClick "Refresh Shadows" to get clone shadowed The reason I am publishing this is I have changed to a spot light, which handles shadows in BJS 2.0. There is a minor problem though. If the very center of the spot is in shadow, the diffuse light still comes through. Looks like Gus has a bullet hole. 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.