Search the Community
Showing results for tags 'babylonx'.
-
Some background followed by several related questions. I have written a Javascript file myExtensionFile.js to submit for consideration as an extension. The current format of the file consists of a public function that calls several private functions and looks like this var private1 = function(a, b) { //code here } var private2 = function(a, b) { var myx = private1(c, d); //more code here } var myExtension = function(a, b, c) { //some code var myx = private1(m, n); //more code var myy = private2(p, q); //even more code } Once loaded you call it using myExtension(a, b, c). Now I have noticed that some files in the Babylon Extensions use BABYLONX Question 1 Should myExtensionFile.js be re-written so that it is called using BABYLONX.myExtension(a, b, c)? Question 2. If I changed to using BABYLONX is this the correct way to re-write myExtensionFile.js? var private1 = function(a, b) { //code here } var private2 = function(a, b) { var myx = private1(c, d); //more code here } var BABYLONX; (function (BABYLONX) { var myExtension = function(a, b, c) { //some code var myx = private1(m, n); //more code var myy = private2(p, q); //even more code } }()); Something to do with closures (I think) but haven't got to grips with them as yet. Question 3. Would using BABYLONX in this way clash with other extensions? Question 4. I can see that using BABYLONX rather than BABYLON shows in code that an extension is needed and should be loaded but would using just BABYLON be better for continuity? Is it possible to do that? Question 5. How would you format the myExtensionFile as typescript. I know I could just change the js file extension to ts but to be 'proper' typescript should I be using modules and classes? Question 6. For someone with a limited skill set (like me) would it be useful to have an 'How To Format A Babylon Extension for Javascript and Typescript' document? When I am clear whether there could be a standard format for writing extension code, what the format looks like and how to do it I wouldn't mind having a go at the documentation. Whether I will ever have sufficient clarity is another issue.