Hi, I’m trying to load a complicated mesh and add collision to it. I’m doing it like so:
var url = "./Isle.glb";
app.assets.loadFromUrl(url, "container", function(err, asset) {
var entity = new pc.Entity();
entity.addComponent("model", {
type: "asset",
asset: asset.resource.model,
castShadows: true
});
entity.addComponent("collision", {
type: "mesh",
asset: asset.resource.model
});
app.root.addChild(entity);
entity.setLocalScale(10,10,10);
});
The mesh is a minecraft-style map made up of a lot of voxels. It takes 3~4 seconds to load without collision and makes my phone lag a bit. When I add the collision component, the game simply freezes.
Is there a way to add collision data to the file itself so I don’t have to do it at runtime. Also is there a better way to optimize it?
Thanks.