JohnK Posted August 23, 2017 Share Posted August 23, 2017 Am I correct in thinking that the loading or use of meshes will be user controlled? If this is true I have only just realised this as this is not clear in the posts. If so this changes how you look at the problem. Previously I could not understand how you could mesh a file asynchronously and then use it in the main program without knowing it had been loaded by using a onSuccess or a callback. If it is user controlled then at any time the user can see what is in the library and make use of them when they appear in the library. Also if the intention was always for the user to control when the intended function would be applied to the mesh then it would have been much clearer to state this in your first post. The more you explain the intended context and use the easier it is to help. If the intention is Load meshes asynchronously into a library of meshes. User views library. User can apply functions to meshes that appear in library. Then perhaps my earlier attempt at a modelling user interface may help you. Have a look at http://cubees.github.io/ Source at https://github.com/Cubees/Cubees.github.io Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 23, 2017 Author Share Posted August 23, 2017 DING DING DING @JohnK ! You hit the NAIL on the head! YOU TOO win a box of chocolates! <3 The user uses the library, and are able to apply functions using a SIMPLE array variable to call WHICHEVER mesh they so desire. Such as mesh [ 0 ] OR mesh [ 1 ] OR both if they use a for loop. They are then able to control the object array that is being returned with ANY other function that they'd like as long as the meshes load correctly & are stored in the mesh "library" correctly. They can do like :: var LIBRARY = [ ]; LIBRARY [ 'water' ] = LoadEntity ( 'meshes/water.obj', OTHER_INIT_VARIABLES_HERE . . . ); LIBRARY [ 'grassplane' ] = LoadEntity ( 'meshes/grass.obj', OTHER_INIT_VARIABLES_HERE . . . ); THEN in the LOOP :: for ( var i = 0; i <= LIBRARY.length; i++ ) { /* Load the WATER plane with index 0 */ if ( i === 0 ) { UpdateEntity ( scene, i, xpos, ypos, zpos, OTHER_UPDATE_VARIABLES_HERE . . . ); } /*Load the GRASS plane with index 1*/ if ( i === 1 ) { UpdateEntity ( scene, i, xpos, ypos, zpos, OTHER_UPDATE_VARIABLES_HERE . . . ); } Thank You folks! <3 Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 23, 2017 Author Share Posted August 23, 2017 Wtf? This is NOT solved. Again, I don't know why my damn topics keep getting the solved symbol on them... Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 23, 2017 Author Share Posted August 23, 2017 I did NOT mark this as solved... Quote Link to comment Share on other sites More sharing options...
adam Posted August 23, 2017 Share Posted August 23, 2017 7 minutes ago, Mythros said: I did NOT mark this as solved... Maybe it was the: 12 hours ago, Mythros said: DING DING DING Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 23, 2017 Author Share Posted August 23, 2017 That was actually in response to @Wingnut & @SinhNQ & @JohnK I was answering their questions. Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 24, 2017 Author Share Posted August 24, 2017 I hope you understand me well enough... Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 24, 2017 Author Share Posted August 24, 2017 If not, I can try to explain more in depth. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 24, 2017 Share Posted August 24, 2017 First, you are the only one I have seen, saying that a solved tag got added to your topic. Maybe change your password, or log out if you share your machine. Seems unlikely, but is a valid explanation why you are the only one. If it still happens, then you can be sure it is something you are doing. For having an array of all your meshes, so that you can reference one by index when changing a property, you could just use scene.meshes. It is an array. Import Mesh assign var skullIdx from looping thru scene.meshes till you match scene.meshes[skullIdx].position.y = 3; What I think what you are really trying to do given that 'Asynchronous' is in the title of the topic, is do all net retrievals (geometry & textures) in advance, but not actually put up a mesh until needed. Right? If not, ignore the rest. ImportMesh has the side effect of actually creating something. I have an entire work flow, originating in Blender, which does this. How geometry gets to your machine is the fact that it is exported in a javascript file. You can even dynamically Download a .JS file without a script tag in your html. Appending it to the document does nothing by itself. Each exported .JS file also has a matReadAhead(), which gets all of the data for the textures in advance as well without tying up the UI thread. When you actually want something, say var mesh = new module.MyMesh("name", scene); Here is a scene where none of the .JS files for any of the busts are statically linked. You of course need to wait for the first one to transmit, but the others are already local by the time to clicked the "Next Model" button. Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 24, 2017 Author Share Posted August 24, 2017 That's correct. I'm basically just trying to be able to do var mesh = [ ]; "mesh [ 0 ] = new module.MyMesh ( 'model1', scene ); mesh [ 1 ] = new module.MyMesh ( 'model2', scene ); ", in which I can use "mesh [ 0 ]", "mesh [ 1 ]", etc... in other functions. Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 25, 2017 Author Share Posted August 25, 2017 Did I explain it well enough? The above is correct, @JCPalmer Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 25, 2017 Author Share Posted August 25, 2017 I'm so close to solving this... Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 26, 2017 Author Share Posted August 26, 2017 Anyone can help? Quote Link to comment Share on other sites More sharing options...
JohnK Posted August 26, 2017 Share Posted August 26, 2017 Weekends are always slow. Perhaps people think you have been given sufficient information for you to have another go. If looking at the library is user controlled then the user needs to click something to display current library contents. So async load library. Main code button for user to click Onclick display current library contents. You seem to have enough ability to try this. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 26, 2017 Author Share Posted August 26, 2017 no no no.. that's not what I need. I'm not trying to use a button. Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 27, 2017 Author Share Posted August 27, 2017 I just want to be able to load a model and use that loaded model's variable in other functions. that's it. Quote Link to comment Share on other sites More sharing options...
JohnK Posted August 27, 2017 Share Posted August 27, 2017 24 minutes ago, Mythros said: I just want to be able to load a model and use that loaded model's variable in other functions. that's it. In which case just call these functions inside the onload function. Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 27, 2017 Author Share Posted August 27, 2017 You're being vague... Can you not be so vague please? I don't mean this as an offense at all, but I need descriptive here so I know WHICH onload to target, HOW to do it, etc etc... Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 28, 2017 Author Share Posted August 28, 2017 After further researching of the code, there IS no onload function... Quote Link to comment Share on other sites More sharing options...
JohnK Posted August 28, 2017 Share Posted August 28, 2017 The PG in your original post https://www.babylonjs-playground.com/#1QJUDF#3 line 44 function ( newMeshes ) this is the onload (or onsuccess) function that is called when BABYLON.SceneLoader.ImportMesh has loaded all the meshes from the given file. newMeshes is defacto the library of meshes so function(newMeshes) { for(var i = 0; i < newMeshes.length; i++) { //apply my functions to newMeshes(i) } } GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 28, 2017 Author Share Posted August 28, 2017 I reformatted it in order for you to understand what I'm trying to accomplish. Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 28, 2017 Author Share Posted August 28, 2017 EDIT :: LINK RIGHT HERE @JohnK https://www.babylonjs-playground.com/#1QJUDF#33 Thank You! <3 Quote Link to comment Share on other sites More sharing options...
JohnK Posted August 28, 2017 Share Posted August 28, 2017 Whatever it is you are trying to do try it the way I suggest instead and see if you get a positive result. Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 28, 2017 Author Share Posted August 28, 2017 i did try it the way you suggested. I JUST want the variable myMesh [ ] to hold the information of the meshes for use in other functions. how hard is that to understand? I showed you EXACTLY what I need the code to accomplish inside of the Playground. First, at the top of the file, define "myMesh" as a global object :: var myMesh = [ ]; Then, in the createScene ( ) function :: myMesh [ 0 ] = LoadEntity ( entityname1, entitylocation1, entityfile1 ); myMesh [ 1 ] = LoadEntity ( entityname2, entitylocation2, entityfile2 ); Then in the UPDATE function OR OTHER functions, I want to be able to still have access to that CERTAIN mesh or those CERTAIN meshes ( by using a for loop as opposed to an assigned index ) :: myMesh [ 0 ].rotation.y -= 0.01; myMesh [ 1 ].rotation.x += 0.01; OR for ( var i = 0; i <= myMesh.length; i++ ) { if ( i === 0 ) { myMesh [ i ].rotation.x -= 0.01; myMesh [ i ].rotation.y += 0.01; } if ( i === 1 ) { myMesh [ i ].rotation.y -= 0.01; myMesh [ i ].rotation.z += 0.01; } } -------------- Thank You! <3 Quote Link to comment Share on other sites More sharing options...
Aerion Posted August 28, 2017 Author Share Posted August 28, 2017 Does that help, @JohnK? Or do I need explain it more in depth? 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.