Jump to content

(PR) adding LensFlareSystem attribute id

DigiHz Data

Recommended Posts

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

Link to comment
Share on other sites

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).


Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;


      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

         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() + "%";
            dlCount = evt.loaded / (1024 * 1024);
            engine.loadingUIText="Loading, please wait..." + Math.floor(dlCount * 100.0) / 100.0 + " MB already loaded.";


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...