Jump to content

[SOLVED] Read-ahead of Geo, Textures, Audio


JCPalmer
 Share

Recommended Posts

I am in the process of building a wrapper class around Mesh sub-classes (actually QI.Mesh sub-classes).  This wrapper class, probably called QI.Character, will surround a generated inline geometry Mesh in a JS file.

My objective is to be able to reuse characters or busts in different demo scenes.  Once a character is picked (possibly at random), I can:

// DOM: Create the script element
var jsElem = document.createElement("script");
            
// set the type attribute
jsElem.type = "application/javascript";
            
// make the script element load file
jsElem.src = jsFileStr;

// let the main thread know it's now on the path
jsElem.onLoad = callback;

This code CAN be called in a worker thread, but anyone know if then the code could be called in the UI thread?  If so, then for a game, once your initial scene was up, you could trigger anything you needed later in a bunch of worker threads.  There is still instancing time of course, but this will remove some time.  Assuming this works, I could also think about other assets for a character as well like textures & audio files.

Link to comment
Share on other sites

Should have known this was happening in another thread already when there was an '.onLoad'.  I am a dumbass.

Yeah, I saw that thread a while back.  My interest, in addition simplifying character re-use across applications, is bringing up an initial scene placing as little as possible in the header section.  THEN after the initial scene is running with a render loop, get things that could pop up later, quietly without affecting the UI thread.  This differs from the BABYLON.SceneLoader calls in that when I get JS files, I am not actually running anything.  Just making it instantly available in the future.  Sceneloader is a get & run.

If the JS file is available, I can instance geometry usually in 0.01 secs.  End to end time including shapekeys & shader seems around 0.3 secs when reading local file texture files.  If the data for the textures could be gotten in a worker as well, I could probably drop that.  Obviously, getting textures over WWW is much longer.  Again, I would not actually run a texture constructor till needed.

QI is very spontaneous character geared.  Once a mesh is ready, you can specify one of 6 ways to arrive (2 new ways are teleport & poof using shaderbuilder).  The Q in QI stands for Queue.  You can queue what to do right after arrival in advance, and it seemlessly transitions.  Means some menacing character can teleport in the middle of the game, and try to kill you.  There is going to be a slight pause, but considering a teleport is 1.5 secs, 0.3 secs just gives them a heads up, so it almost a "feature".

If a scene came up running a scene with just some kind of UI with buttons, that would be real fast.  Getting stuff for actual "playing" could start immediately, while they are reading / setting stuff.

Link to comment
Share on other sites

Along with the rename of the topic.  There is no need to resort to worker threads for getting texture / audio assets either. 

The concept of "Separating Getting from Loading", A.K.A "Read Ahead", is actually very complementary to the async shader compilation discussion getting much attention right now at Khronos.  The notion of serializing / de-serializing entire scenes as a single unit has an upper bound.  I am not to the point of allowing .blend files with multiple layers to generate multiple source files, but I may.  Sort of like Google maps, where I am pretty sure adjacent areas are being downloaded ahead of you actually moving up / down / left / right.

Link to comment
Share on other sites

Well, from a character reuse standpoint, I may have encountered a development issue. This is the directory structure I have modified for my local version of my Github Blog repo:

-> characters
    -> images
    -> javascript
...
-> scenes
    -> QueuedInterpolation
        -> QA scene
            index.html

I am using Firefox for development to be able to read texture filesusing file://... .  I can dynamically load javascript files using a "../../../characters/javascript" url.  "../../../characters/images" for the textures fail.

I know I am not making a typo mistake.  I modified another scene, moving its files.  The url worked from the browser built-into Eclipse, but it failed from Firefox.  I can temporary measures during development, but does anyone a reason this would not work using an http:// url?

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...