Dad72 Posted April 2, 2014 Share Posted April 2, 2014 Is a forgotten that this function "(BABYLON.Scene.prototype.getMeshesByTags" has not been add in babylon 1.10.0?It will be add? this code: http://www.html5gamedevs.com/topic/4961-user-data-in-mesh-object/?p=30974 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 2, 2014 Share Posted April 2, 2014 Wow, we were posting on the same thread at the same time, Dad72! Different subjects, though. Funny. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted April 2, 2014 Share Posted April 2, 2014 wingnut, most of the engine are like that for good reasons. After that, I do not seek to know the reasons, I know that this is howThey are naming conventions that are often found in engines. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 2, 2014 Share Posted April 2, 2014 Well, I do want to know the reasons, and babylon.js is not other engines. It is an EASY engine. But its learning curve gets steeper with every added function. I will wait for further opinions, but thank you for yours. Quote Link to comment Share on other sites More sharing options...
gwenael Posted April 2, 2014 Share Posted April 2, 2014 As far I'm concerned, it doesn't bother me to have all these functions and internally they could use the one you suggest Wingnut but you're right they are more helpers than "must be there" functions and could easily put in the tools file and be static. We can suggest this to Deltakosh. Another suggestion I have: that would be nice to have tags and user data on meshes, why not have them on cameras and lights too? My idea is to try to put as much as possible in Node and inherit everything from there. Moreover the functions could be overriden in sub classes such as Mesh. Xanmia and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
Xanmia Posted April 3, 2014 Author Share Posted April 3, 2014 I understand what you are saying @Wingnut with the more that is added the harder Babylon.js is to learn but i think thats where Deltakosh comes in and overrides our crazy ideas . Otherwise, I like how Gwenael stated it and agree with the node approach. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 3, 2014 Share Posted April 3, 2014 Yes, I agree with node being a good place to add these things, but again, that means cameras, lights, and mesh... all get another property (in their api documentation), and then likely... scene.getMeshesByTag(tagname)scene.getLightsByTag(tagname)scene.getCamerasByTag(tagname) ... all get added to our already-bloated (imho) scene class. *sigh* 3 properties added, 3 methods added, for one feature. erf. Do that enough and you become threeJS. (dread) I would love to see ALL the getFooByFoo() stuff... moved to Tools. I doubt that will happen. "Too late", likely. BABYLON.Tools.getFooByFoo(Foo)? *nod* That would get those girly toys out of the way of us REAL men. Real men do their own lookups from three power arrays... scene.meshes, scene.lights, and scene.cameras... with manly FOR-loops. We iterate, baby. (huh?) Anyway, I have said all this 'opinion' of mine, before. As long as I get to play with babylon.js, I am cool with whatever happens. Maybe those three power arrays should be enumerables... maybe collections or vector objects... something even MORE manly. j/k Quote Link to comment Share on other sites More sharing options...
gwenael Posted April 3, 2014 Share Posted April 3, 2014 https://github.com/BabylonJS/Babylon.js/pull/170 Quote Link to comment Share on other sites More sharing options...
gwenael Posted April 4, 2014 Share Posted April 4, 2014 Eval is prohibited due to security issues with win8 Will be prohibited or already is? http://msdn.microsoft.com/en-us/library/s4esdbwz%28v=vs.94%29.aspx Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 5, 2014 Share Posted April 5, 2014 Already is (win8 apps using winjs) Quote Link to comment Share on other sites More sharing options...
gwenael Posted April 7, 2014 Share Posted April 7, 2014 Ok. Thank you. So I didn't develop BABYLON.AndOrNotEvaluator for nothing . Have you had time to check https://github.com/BabylonJS/Babylon.js/pull/170 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 7, 2014 Share Posted April 7, 2014 Checked, integrated, serialized gwenael 1 Quote Link to comment Share on other sites More sharing options...
gwenael Posted April 8, 2014 Share Posted April 8, 2014 (edited) I saw you handled my TODO list. Thanks. I'll write a wiki page for tags and Wingnut will check it and rewrite everything , won't he? Edit: wiki https://github.com/BabylonJS/Babylon.js/wiki/Tags Edited May 15, 2014 by gwenael Quote Link to comment Share on other sites More sharing options...
gwenael Posted April 8, 2014 Share Posted April 8, 2014 Answer to Wingnut's question http://www.html5gamedevs.com/topic/3865-what-do-you-want-in-babylonjs/?p=33076: I use for/in loop to loop through the properties of an object (http://www.w3schools.com/js/js_loop_for.asp) and I think using the 'var' is the proper way to use the loop but I'm not a javascript expert. I also use for/in to loop through items of an array to skip not set items (undefined but not set to undefined...). Here are some experiments that I did a while ago: http://jsfiddle.net/gwenaelhagenmuller/9pJVd/. Please read the code and what it's logged in the console. Quote Link to comment Share on other sites More sharing options...
SideraX Posted April 8, 2014 Share Posted April 8, 2014 Just a tiny warning : for-in-loop is 2 at 10 times much slower than a classic for-loop. http://jsperf.com/for-vs-foreach/75http://jsperf.com/for-loop-vs-for-in-loop Ahiru 1 Quote Link to comment Share on other sites More sharing options...
gwenael Posted April 8, 2014 Share Posted April 8, 2014 Oh my... Good to know. Need to check that. Thank you. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 8, 2014 Share Posted April 8, 2014 Thanks gwenael. And thank you too, SideraX. Good to know. Yeah, I use FOR-IN sometimes, too. I just never use the 'var' like that. I was wondering if there had been an ecma recommendation issued that said "thou shalst use a var in for-in" I see there is forEach now, too, (in the newer ECMAscript), but I'm hearing rumors that it runs slower than other FOR loops. It looks like SideraX has done the research. Since we are in this topic... I see that tags are active. Is .userData also going to be installed, or has it? Did that idea originate with Blender? Is it a place for the scene builder person to put any text they choose, and of any length? Do you think we will see/make a method to display .userData, possibly onmouseover the mesh... that pops open a little window like HTML 'alt' did in the old days? Seems I remember a longdesc="blah blah" on html elements, too. I suppose the programmer could do anything they choose with data in a .userData property... make it a pop-open, use it for notes-to-self, etc. Ok, i will stop babbling now and watch this discussion move forward on topic. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 8, 2014 Share Posted April 8, 2014 I won't add .userData because we are all using javascript and so we can add custom properties whenever we want. tags are important to organize objects but userData is just user data Quote Link to comment Share on other sites More sharing options...
holcombj67 Posted April 27, 2014 Share Posted April 27, 2014 A second note about using "for...in" loops for arrays - it will break if other scripts add stuff to the Array.prototype. I hit this problem when trying to integrate a page that had both babylon and noVNC. noVNC had added a couple of functions to the Array's prototype, and babylon tripped over them when iterating over arrays. While investigating the problem, I found this Stack Overflow discussion that lead me to find the problem. I am still considering how to best fix it. Quote Link to comment Share on other sites More sharing options...
gwenael Posted April 28, 2014 Share Posted April 28, 2014 Thanks holcombj67 for sharing this.I'm not a javascript expert and I'm aware that my answer won't solve your problem but I'm not sure it's a good practice to surcharge Array's prototype (or the prototype of any other default type). Arrays in javascript can be used as dictionaries would be used in c#, that allows to have "variables" names with space in them.var d = {};d.key1 = "value1";d.key2 = "value2";d.key 3 = "value3"; // ERRORvar d2 = [];d2["key1"] = "value1";d2["key2"] = "value2";d2["key 3"] = "value3";//d2.length = 0 => cannot do for(var index=0; index<d2.length... Quote Link to comment Share on other sites More sharing options...
kolar Posted May 6, 2014 Share Posted May 6, 2014 Third note about "for..in" loops: lack of "var" keyword creates variable in global scope (!), see: http://stackoverflow.com/questions/5717126/var-or-no-var-in-javascripts-for-in-loop . Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 6, 2014 Share Posted May 6, 2014 Wow, lots of good information about for-in, well done, all of you. I think I speak on behalf of many of the forum readers. Very interesting. Xanmia, we seriously hijacked your thread, but you are becoming a hero just the same. Quote Link to comment Share on other sites More sharing options...
Xanmia Posted May 7, 2014 Author Share Posted May 7, 2014 Hahaha, and I thought this thread was dead... Quote Link to comment Share on other sites More sharing options...
SideraX Posted May 12, 2014 Share Posted May 12, 2014 I will continue to hijak your thread ^^ When I need to use associative array in JS, I prefer use this implementation of a Hashmap : https://github.com/SideraX/sefjs/blob/master/src/utils/Hashmap.ts (I writed it after some inspiration here and there for my Entity-Component-Systems framework - which I use it to develop my game on top of Babylon) It will save the data in packed array (hole in array are bad : http://www.smashingmagazine.com/2012/11/05/writing-fast-memory-efficient-javascript/ ) for an efficient foreach and the key can be a string or an int (it will not impact the perf). Perf : for..in vs hasmap.foreach() : http://jsperf.com/hashmap-vs-natif-objectApart for some unholy optimization than V8 seems to do on object with few property (Firefox don't). Hashmap.foreach is way more fast. Perf : object[key] vs hasmap.get(key)http://jsperf.com/hasmap-vs-natif-object-getPerformence are practically the same And if you need even faster for, you can do (but you will not have the key in this case) :var val = hashmap.values();for (var i = 0, len = val.length; i < len; i++) { val[i];}Some drawback : Hashmap will take more memory and the delete method is a bit slow (needed to keep arrays packed). Maybe we can put this class in BABYLON.Tools alongside Smartarray and nobody will have excuse to use for..in again Quote Link to comment Share on other sites More sharing options...
jessepmason Posted December 18, 2015 Share Posted December 18, 2015 Hey guys I know this is a really old thread but I am curious if it is yet possible to add mesh data or tags in the Babylon file?I have looked and I don't see an option for tags or mesh data in the babylon file...so probley not but I think it could be really useful if we can set the data or tags through one of the exporters such as 3ds max or just manually by editing the babylon file Anyway I know this has been brought up in this thread already but I have just found a need for it so I thought I'd bring it up 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.