Jump to content

Why do all api calls take a name?


Recommended Posts

An API design question I've not seen answered, is why the first parameter of just about all the API calls is a name? Is it really needed? The library would be lighter, quicker and all examples would be shorter without it, so is it bringing enough functionality to make it worth that?


In all the examples I've seen you end up with not-DRY code like the below (extracted from the Height Map example in the playground):


var spot = new BABYLON.SpotLight("spot", ...);

var camera = new BABYLON.ArcRotateCamera("Camera", ...);

var groundMaterial = new BABYLON.StandardMaterial("ground", scene);

var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", ...);

var sun = BABYLON.Mesh.CreateSphere("sun", 10, 4, scene);
sun.material = new BABYLON.StandardMaterial("sun", scene);

var skybox = BABYLON.Mesh.CreateBox("skyBox", 800.0, scene);
var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);

skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("textures/skybox", scene);




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