Jump to content

ToB - get object of scene?


ian
 Share

Recommended Posts

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

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...