Terminator Posted August 2, 2016 Share Posted August 2, 2016 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, Quote Link to comment Share on other sites More sharing options...
adam Posted August 2, 2016 Share Posted August 2, 2016 You don't have to define a name. It is helpful though if you want to use scene.getMeshByName or if you are debugging and want to know what mesh your are dealing with. Terminator 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 2, 2016 Share Posted August 2, 2016 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. Quote Link to comment Share on other sites More sharing options...
adam Posted August 2, 2016 Share Posted August 2, 2016 6 minutes ago, RaananW said: you define an id, not a name This should be updated then. Is this wrong? http://doc.babylonjs.com/classes/2.4/Mesh Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 2, 2016 Share Posted August 2, 2016 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 adam 1 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.