ian Posted September 5, 2017 Share Posted September 5, 2017 If we do ModelFinish.initScene(scene); we initialize scene of ModelFinish.js. That works fine. Is there any way how to get object ModelFinish from document ? is there any way similar like this so as maybe var objModel = document.getObject"ModelFInish") and then initilization object objModel.initScene(scene) ??? Greetings Ian Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 6, 2017 Share Posted September 6, 2017 This belongs in Questions forum. The answer is no, because ModelFinish is not an Object. It is the same as the name of a Module if it had been generated from Typescript (a variable in JS). It is the exact same thing as BABYLON is. You cannot do var blah = document.getObject"BABYLON"). BABYLON is ALREADY a variable. If you wish to call it ObjModel instead of ModelFinish, then just export it again as ObjModel.JS. Or var ObjModel = ModelFinish; Quote Link to comment Share on other sites More sharing options...
ian Posted September 6, 2017 Author Share Posted September 6, 2017 if you imagine I have models .js (exported ToB models) in database. I know only name of .js file or name of model. code looks like. This code works OK, but I would like to change ModelFInish.initScene(scene) with something like var objOfToBModel = some_javascript_factory_object.getObject("ModelFInish"); and then do objOfToBModel.initScene( scene ); var scritpToBLevel = document.createElement("script"); scritpToBLevel.src = url; document.head.appendChild( scritpToBLevel ); scritpToBLevel.onload = function () { ModelFInish.initScene(scene); ... ... I have ModelFInish.js (from ToB) ModelFinish.initScene(scene) is fixed in code. I would like to get ModelFinish object somehow from document or any other javascript objects with name "ModelFInish". I know ModelFInish name of js file from database. But I don't know if there is any javascript object like factory to get ModelFinish javascrip object with name "ModelFInish". something like var objOfToBModel = some_javascript_factory_object.getObjec("ModelFInish"); and then do objOfToBModel.initScene( scene ); greetings Ian Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 7, 2017 Share Posted September 7, 2017 Referencing a .js dynamically rather than putting it in a script tag inside the html header is the same for all .js files. I had been going to do this for initScene, but it is not fully coded for entire scenes, just single character exports. This has been shelved for 1.1, since this is not currently needed by me. I was also doing read ahead to get the data for textures before it was needed. Skipping that simplifies things. Just make your some_javascript_factory_object class, and putting a getObjec() function inside. Quote Link to comment Share on other sites More sharing options...
ian Posted September 8, 2017 Author Share Posted September 8, 2017 I know how maybe. Maybe I just have to make all exported ToB ja files with same name and than I don't need factory ... I will simplify this for now. But does JavaScript have no such thing we could get BABYLON variable/object with names/strings. Like for example var obj = document.getVariableByName("BABYLON"); so if JavaScript variable document or any other generic jacascript's variable contain factory like getVariableByName Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 8, 2017 Share Posted September 8, 2017 Simple is good. Just use directories & relative paths. ian 1 Quote Link to comment Share on other sites More sharing options...
ian Posted September 8, 2017 Author Share Posted September 8, 2017 Yes. If I have 3 or more different levels/scene. I have to export all of them with same ToB ja names (for example FinishModelToB.js). And then put them in database. And code will always be FinishModelToB.initScene( scene ); This should solve this problem. And I/we will not need general factory function in JavaScript. 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.