How to load assets runtime


#1

Is it possible to load assets little by little during play? Fbx can be heavy to preload at startup only


Heavy bugs within the 'scene change' functionality
#2

FBX: not really
The converted model JSON however, can be loaded at runtime.

There are two ways:

  1. Untick the preload box on the asset and use the asset registry to load it at runtime. (see project examples here: https://developer.playcanvas.com/en/tutorials/?tags=assets and tutorials here: https://developer.playcanvas.com/en/tutorials/using-assets/)
  2. Host the model/textures/etc assets somewhere else and load them at runtime. (see posts here: Load 3D models at run time from a PlayCanvas application)

Option 1 is the easiest out of the two.


#3

Is there another option to load an asset directly from memory (e.g. Json in a variable)?

Something like this?

my_json = JSON.parse(my_json);

var loader = new pc.ResourceLoader();
var new_model = loader.open("model", my_json);
    
var asset = new pc.Asset(
        "test", 
        "model",
        null,
        new_model
);

#4

@Mystik See: How to create/load asset from Json variable (not from file or url)?


#5

Personally I am now moving in a direction of loading scenes (with new assets within those). This troubleshoots the cost problem, but it raises other issues concerning ‘scene change’ in PlayCanvas as a whole.


#6

The most present issues relating ‘scene change’: Heavy bugs within the 'scene change' functionality