Jump to content

why we define an object name


Terminator
 Share

Recommended Posts

Hello,

let's say we added a sphere:

var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);

we already have access to the variable name "sphere", but why we define an object name "sphere1", where it is useful and how we can access it, can anyone provide an example?

Thanks,

Link to comment
Share on other sites

Also a note - you define an id, not a name. which is then copied to the name as well. Both can be changed.

This is, as Adam said, for the sake of organization. And notice that it is not unique. This about "name" as "class" in HTML . you can filter according to ID, to class, to tags, to uniqueId. And of course you can always keep a reference and never use those parameters. It's your call.

Link to comment
Share on other sites

they are actually the same. The variable is called name (i remember it was ID, but I am getting old, apparently), and is being set as both id and name :

https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.node.ts#L70

So, all in all, the documentation is more right than me :) 

But that doesn't change the way to use those. Both id and name can be used to filter nodes when working with a large number of them

 

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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