qqdarren Posted May 12, 2015 Share Posted May 12, 2015 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); Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted May 12, 2015 Share Posted May 12, 2015 There are methods to get things by name. Kind of useful when you are trying to get a materialByName from a an export from Blender or the other one, the Adobe thing. You can set it to null for your own create stuff. If it makes you feel any worse, there is also an 'id' field. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted May 12, 2015 Share Posted May 12, 2015 And an Auto generated Unique id :-)Name is actually useful when dealing with many meshes , cameras and materials. 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.