Jump to content

Best Practice for Loading Scene Meshes in the Background


018
 Share

Recommended Posts

I have a scene generated from the Blender export.  It has a variety of different meshes, but I really only want them loaded so that I can access them later as a level is generated (and then I would make InstancedMeshes from them).  I can load them and set them out far out of view, but is there a better way? 

Thanks.

Link to comment
Share on other sites

Best practice would be to either load everything at start, meshes you don't need from start can be set to mesh.isEnabled( false );

Or if you have different "levels" you can load meshes between levels, adding a loading scene when changing from level 1 to level 2, etc, and loading them there. 

What's best for you really depends on the number and quality(size) of your meshes :),
So lets say if you have 50+ MB total, the second option would probably be best (if possible),
since not all players will reach every level and actually use every mesh, loading them at start is just wasting bandwidth and adding unnecessary loading time which may make some players leave before the game even starts :)

Link to comment
Share on other sites

Using Blender / .BABYLON exporter, there is a 'Load Disabled' checkbox in the exporter properties for a mesh.  If going that route, this would disable it by default.  Less code to put in the onready callback. 

I hesitate to mention it due to lack of documentation  (this is way out of date), but the Tower of Babel source code exporter does have an alternative.  You add a script tag for the exported .JS file that has the inline geometry in your html file.  This gets downloaded at the beginning, and also parsed, but nothing is created.  When you wish a mesh to appear, just instance it:

var myMesh = new module.Meshclass('name', scene, materialsDirectory);

Seeing as you only have 3 posts, I would not try this, but it does have advantages.  You can also pick from 5 ways to have your mesh displayed from Blender:

  • Expand
  • Gather
  • Fire shown about midway
  • Just Make Visible
  • Custom (a JavaScript class coded by you)
Link to comment
Share on other sites

Make a container object and load all your meshes on runtime and when they load have them assign on the container object like:  presets[mesh1.name] or something g like that and when you need it you just reference the object in the preset object and clone it so var newObject  = presets[presetname].clone()

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