DigiHz Data Posted March 31, 2016 Share Posted March 31, 2016 I really would like us to have the attibute id in the LensFlareSystem. I have thought about this a lot, and think it would gain everyone to have it. And i do not think there will be any compatability issues either adding it. In function LensFlareSystem(name, emitter, scene) {.... I think we should add: this.id = name; And add: Scene.prototype.getLensFlareSystemById = function (id) { for (var index = 0; index < this.lensFlareSystems.length; index++) { if (this.lensFlareSystems[index].id === id) { return this.lensFlareSystems[index]; } } return null; }; And add the id it to the serialization to of course. I use babylon 2.3.max Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 31, 2016 Share Posted March 31, 2016 What's wrong with name? can't name be used here? Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 31, 2016 Share Posted March 31, 2016 Oh, and a PR is an actual change in Code/Github I would call this "change request". And maybe move it from the bugs section. Q&A would be the appropriate place for such requests. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted March 31, 2016 Author Share Posted March 31, 2016 Well to be able to set id in the same way as when you create a light, mesh, camera or material should obviously be an option for LensFlareSystems to! I am not a member on github a scene should be have LensFlareSystems with the same name, but with different id's. It is much more easy to for the end user to have better control over the LensFlareSystems this way i think. For example: In my editor....i want to load in the LensFlareSystems and get the name and id from sceneloader..... The end user has set the name and id in the .babylon file.... When i load in the .babylon file i parse the id and give it a unique id like lensflaresystem_1, lensflaresystem_2 and so on. Then the user will see the name coreectly, and the id will be unique. (This way a scene can have multipe LensFlareSystems with the same name). Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 31, 2016 Share Posted March 31, 2016 A mesh ID is set by the user, and is not unique. I (personally) never found the difference, apart from the general "name vs. id" debate, that one should be a readable string, and one can be cryptic. But, it is not unique. a Node (mesh, camera, light) has a uniqueId property, which is scene-specific and is being calculated every time the scene is loaded . So I don't see the benefit, but this is a personal opinion Maybe DK has a different take on that. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted March 31, 2016 Author Share Posted March 31, 2016 I see name as a visual reference, and id as a control reference. And i strongly believe we need both. For you to better understand, i provide code for loading in the meshes in sceneloader: function do_append_scene(){ var current_meshes = {}; $.each(scene.meshes, function (key, value){ current_meshes[key] = value; }); BABYLON.SceneLoader.Append(sceneloader_path,sceneloader_file,scene,function(scene_appended){ var meshes_added_to_scene=0; jQuery.each(scene_appended, function(index, value) { if (index=="meshes"){ $.each(scene_appended.meshes, function (key, value){ if (current_meshes[key] !== scene_appended.meshes[key]){ if(jQuery.inArray(scene_appended.meshes[key].id, lights_pseudo_meshes_appended) == -1 && jQuery.inArray(scene_appended.meshes[key].id, cameras_pseudo_meshes_appended) == -1){//if this is not in array lights_pseudo_meshes_appended and not in array cameras_pseudo_meshes_appended then...... $("#live_meshes_select").append("<option value='mesh_"+live_meshes_unique_id+"' data-id='"+live_meshes_unique_id+"'>"+scene_appended.meshes[key].name+"</option>"); scene_appended.meshes[key].id="mesh_"+live_meshes_unique_id;//set id live_meshes_unique_id++; meshes_added_to_scene++; } } }); } if (meshes_added_to_scene>0){ $('#live_meshes_select option:first-child').html('-- Select mesh --'); $("#live_mesh_delete").removeAttr("disabled", "disabled"); } console.log(meshes_added_to_scene+' meshes added to the scene.); },function (evt) {//while loading if (evt.lengthComputable) { engine.loadingUIText="Loading, please wait..." + (evt.loaded * 100 / evt.total).toFixed() + "%"; }else{ dlCount = evt.loaded / (1024 * 1024); engine.loadingUIText="Loading, please wait..." + Math.floor(dlCount * 100.0) / 100.0 + " MB already loaded."; } }); } Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 1, 2016 Share Posted April 1, 2016 I'm not opposed to adding an id field to the flensflaresystem. Please do a PR Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted April 2, 2016 Author Share Posted April 2, 2016 Deltakosh:I am glad to hear that you not opposed about adding the id. Sorry, but i do not know how to do a proper PR. I am not member on Github. Quote Link to comment Share on other sites More sharing options...
RaananW Posted April 2, 2016 Share Posted April 2, 2016 All fine, ID will be added pretty soon Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted April 3, 2016 Author Share Posted April 3, 2016 RaananW: Great! Thanks. Quote Link to comment Share on other sites More sharing options...
RaananW Posted April 3, 2016 Share Posted April 3, 2016 PR submitted (https://github.com/BabylonJS/Babylon.js/pull/1081), will be added pretty soon to 2.4 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.