Vousk-prod. Posted August 5, 2014 Share Posted August 5, 2014 Hi beautiful people, I'm in the process of converting all my SceneLoader.Load to SceneLoader.ImportMesh for a better management with multi scenes, and multi objects files by scene. But I have a little annoying problem: all my scenes are now totally dark... It seems that SceneLoader.ImportMesh. doesn't import lights... (maybe it takes care only of meshes, particles system and skeletons, as its name claims - and onsuccess callback args tends to confirm- ). And since we can now benefit from camera and lights animations with JCPalmer TOB (thanks man !!), does SceneLoader.ImportMesh import those nicely animated cameras ? Of course we can manually add BJS lights with some piece of code at scene init, but this is not what I need, my Blender lamps are precisely positionned, oriented, powered... and the same for the cameras. I checked in the BJS project source code but there is no SceneLoader.ImportLights or ImportCameras... Any idea, advice ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 6, 2014 Share Posted August 6, 2014 Why not using SceneLoader.Load to load a second scene and then move cameras from one scene to another? Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted August 6, 2014 Author Share Posted August 6, 2014 That's what I'm currently doing, but I'm also concerned about performance.Is the process of creating that second scene memory consuming ? How can I then cleanly delete this second one and all uneeded associated ressources ? Quote Link to comment Share on other sites More sharing options...
Temechon Posted August 6, 2014 Share Posted August 6, 2014 scene1.dispose() should do the trick It will remove the scene and all linked light, meshes, cameras... Don't forget to save what you want to save before calling this function ! Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted August 6, 2014 Author Share Posted August 6, 2014 Great ! Thanks for the tip Temechon.Don't worry I'll copy everything I need before calling this.Happy to know that nothing left after scene.dispose \o/ Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted August 31, 2014 Author Share Posted August 31, 2014 When I copy my meshes from the new scene created with SceneLoader.Load into my already existing scene, I don't have the copied meshes in my scene... I copy meshes, skeletons, materials, textures, multiMaterials, lights, cameras like this :for (var i = 0; i < scene.meshes.length; i++) { myExistingScene.meshes.push(scene.meshes[i]);}for (var i = 0; i < scene.skeletons.length; i++) { myExistingScene.skeletons.push(scene.skeletons[i]);}for (var i = 0; i < scene.materials.length; i++) { myExistingScene.materials.push(scene.materials[i]);}for (var i = 0; i < scene.multiMaterials.length; i++) { myExistingScene.multiMaterials.push(scene.multiMaterials[i]);}for (var i = 0; i < scene.textures.length; i++) { myExistingScene.textures.push(scene.textures[i]);}for (var i = 0; i < scene.cameras.length; i++) { myExistingScene.cameras.push(scene.cameras[i]);}for (var i = 0; i < scene.lights.length; i++) { myExistingScene.lights.push(scene.lights[i]);}But at the end myExistingScene does not contain the loaded meshes. lights and cameras are here, but not the meshes (and getTotalVertices() confirms that)...Any idea ? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 31, 2014 Share Posted August 31, 2014 My guess of your problem is due to the fact that the BABYLON.Node (parent of mesh) is passed scene in constructor. It copies scene to this._scene. I think this is going to make a mess for copying meshes across scenes. Option 1: Inline JS (if you do not have mesh instances)TOB generated code is passed a scene, so things are very incremental / additive. Also everything is done synchronously. I seem to remember someone having race conditions with multiple .importMesh(es) and textures files. This multi-import was the original reason for TOB. Just add a <script> tag for each .js file in the <header>. If you want to add everything from a given .js there is a convenience method initScene(scene, materialsRootDir). If you wish to pick and choose, just grab the parts of initScene() of interest, & copy to your .html. Here is the camera animation sample code:var camera_anim = (function(){ var internal = {}; internal.initScene = function(scene, materialsRootDir = "./"){ if (typeof(BABYLON.Engine.Version) === "undefined" || Number(BABYLON.Engine.Version.substr(0, 4)) < 1.14) throw "Babylon version too old"; scene.autoClear = true; scene.clearColor = new BABYLON.Color3(0,0,0); scene.ambientColor = new BABYLON.Color3(0,0,0); scene.gravity = new BABYLON.Vector3(0,-9.81,0); // define materials & skeletons before meshes internal.defineMaterials(scene, materialsRootDir); internal.defineSkeletons(scene); // instance all root meshes new internal.Cylinder_003_4("4Cylinder.003", scene); new internal.Cylinder_002_4("4Cylinder.002", scene); new internal.Cylinder_001_4("4Cylinder.001", scene); new internal.Cylinder_4("4Cylinder", scene); new internal.Cylinder_purple_001_2("2Cylinder.purple.001", scene); new internal.Cube_tex_001_3("3Cube_tex.001", scene); new internal.Cube_tex_3("3Cube_tex", scene); new internal.Ground_5("5Ground", scene); new internal.Cube_blue_1("1Cube.blue", scene); new internal.Cube_teal_1("1Cube.teal", scene); new internal.Cylinder_purple_2("2Cylinder.purple", scene); // define cameras after meshes, incase LockedTarget is in use internal.defineCameras (scene); // cannot call Shadow Gen prior to all lights & meshes being instanced internal.defineLights (scene); internal.defineShadowGen(scene); };The entire contents is inserted with: camera_anim.initScene(scene);Just one root level mesh could also be grabbed with: var cube = new camera_anim.Cube_teal_1("my name", scene); No need to run defineMaterials() or defineSkeletons(), since they are run inside each mesh constructor (but only loaded once). Option 2: (Fix SceneLoader to have the option of passing a pre existing scene)Everything then could be additive. Not sure how. I am in the process of editing babylonFileLoader.ts so Automatons can come in from a .babylon, and I think it has to be higher than that. Not saying you might get the existing code base to work, but better to improve the code base, than have spaghetti code. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 1, 2014 Share Posted September 1, 2014 On the fix the code base front, option 2, I have a one line change to BABYLON.SceneLoader.Load(). It is done without changing arguments, since multiple optional args at the end are tricky / ugly. Basically, the engine has a .scenes[ ]. When it has length 1, the stuff is dumped into the existing scene. It built successfully, but I did not test this. I also have no intention of doing a pull request. If Deltatosh thinks it is the way to go, it is only one line to retype. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 1, 2014 Share Posted September 1, 2014 As soon as I posted that, I knew of a side effect / behaviour change free way of doing it in 4 lines. This time, rename the Load method to Append / changing the engine argument to scene, then delete the create of a new scene. Add a 2 line Load method, that wrappers Append. I tested that Load still worked. Will submit pull request on request. Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted September 1, 2014 Author Share Posted September 1, 2014 Great idea JCP !A SceneLoader.Append() method will save me many tests and cases in my scenes and assets management logic. Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted September 9, 2014 Author Share Posted September 9, 2014 Have you submitted the pull request ? I do not see any change on BJS repo about that. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 10, 2014 Share Posted September 10, 2014 No, sorry. I need DK to say he will grant it. If I commit it & push it up to my GitHub fork, & he does not want to do it, then it becomes a problem. You cannot just put in a pull request for some things, only all changes. I had committed something by accident, and ended up re-creating my Github fork once already. If he does not want to do it, you will have to put it in your fork, & start "Gulping". Thanks for reminding me. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 10, 2014 Share Posted September 10, 2014 This is great . I'll clearly validate this PR without any problem Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted September 10, 2014 Author Share Posted September 10, 2014 You can create a branch before commiting on your github repository and sending the pull request, that could prevent some mess and it's then easier to cancel changes if needed. One of the best advantage of git compared to other versionning system is its so well structured branching system, concieved for coding every little piece of code in parallel branches easily without hasardous problem. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 10, 2014 Share Posted September 10, 2014 Thanks, I need to better figure out how to use git. Branches are scary, I remember I tried one with the old Microsoft SourceSafe 15 years ago. Not a fiasco I want to repeat. Will do this tomorrow morning in New York time. Do I push up both the .ts & .js, or just the .ts? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 10, 2014 Share Posted September 10, 2014 both Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 11, 2014 Share Posted September 11, 2014 Well I made the commit / push / pull request for SceneLoader.Append using the master. Starting to use branches. - First, pulled out TOB addin / blender-test dir / Automaton files, and set aside.- did: git checkout tower_of_babel.py (to revert back working directory)- fetched & merged from main repository- Created branch TOB, moved back everything but Automaton stuff- did a local commit. Now I think I am supposed to a push the TOB branch to my Github fork, right? Am using mostly Eclipse UI for git, but also have command-line git installed. See attached Eclipse picture for UI for "Push Branch to Remote". Can u describe how things are to flow (repository, merge, branch wise), please? Jeff Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted September 12, 2014 Author Share Posted September 12, 2014 Yes, you have now to push your branch to your git repository.I'm not the good one to guide you on this because I'm mostly using git locally, I barely use pulling stuff. But regarding branches I now understand pretty well this powerfull tool and I'm not scared anymore, thanks to an excellent online book. I strongly encourage you to read the branch related chapter :http://git-scm.com/book/en/Git-BranchingYou will for instance understand difference beetween merge and rebase.Enjoy ! 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.