Hi again,
The game I’m working on will be part of a website. When the website is opened the PlayCanvas game should load the needed assets in the background. Once done, the game will be available for playing.
During this loading the website should be responsive.
I use the code below to load some of the assets. The problem is that during this loading the complete webpage freezes. As soon as the asset is loaded it response normally. What can I do about that?
Isn’t the idea behind this callback structure that the event loop of the website keeps running?
const url = "./assets/models/ship/Ship_2K_Compressed.glb";
app.assets.loadFromUrl(url, "container", function (err, asset) {
// create an instance using render component
const entity = asset.resource.instantiateRenderEntity({
castShadows: true,
});
console.log("Starting ...");
app.root.addChild(entity);
entity.setPosition(0, 5, 0);
entity.rotate(0, 0, -22);
entity.rotate(0, -45, 0);
entity.render.renderStyle = pc.RENDERSTYLE_WIREFRAME;
//entity.setLocalScale(20, 20, 20);
app.on("update", function (dt) {
if (entity) {
//entity.rotate(0, -20 * dt, 0);
}
});
app.start();
});