I’m not sure whether to file this under bugs but, here goes.
this is, by all accounts, a very normal gltf file that I use for a level in a game we’re building with babylon. It loads properly on windows/mac pc browsers, in addition to android phone browsers.
However on iPhone browsers (safari, chrome, opera, tried all of them) it starts loading the model, and then the window goes black and it shuts the browser down -with no crash report, no errors in the console etc.
This is the code I use to load the model and build a navmesh:
async function createPlatforms(scene, navigationPlugin) {
let positions = [
new BABYLON.Vector3(8, 0, 0),
];
let platformPromises = positions.map(pos => createStaticMesh(scene, navigationPlugin, pos));
let meshes = await Promise.all(platformPromises);
await createNavmesh(scene, navigationPlugin, meshes.flat());
}
async function createStaticMesh(scene, navigationPlugin, position) {
return new Promise((resolve, reject) => {
new BABYLON.SceneLoader.ImportMesh(“”, “./models/Floor_v03/”, “RSS_Module_v02.gltf”, scene, function (glbMeshes, particleSystems, skeletons, animationGroups) {
glbMeshes[0].position = new BABYLON.Vector3(0, 0, -10);
glbMeshes[0].scaling = new BABYLON.Vector3(0.8, 0.8, 0.8);
glbMeshes[0].checkCollisions = true;
let groundMesh;
let obstacles = ;
glbMeshes.forEach(element => {
if (glbMeshes.indexOf(element)) {
element.checkCollisions = true;
if (element.name !== "Floor" && element.name !== "FloorShadow" && element.name !== "BoxShadow") {
obstacles.push(element);
}
else if (element.name === "Floor") {
groundMesh = element;
}
}
});
let mesh = BABYLON.Mesh.MergeMeshes(obstacles, true, true, undefined, false, true);
resolve({ groundMesh, mesh });
});
});
}
async function createNavmesh(scene, navigationPlugin, meshes) {
let navmeshParameters = {
cs: 0.25,
ch: 0.05,
walkableSlopeAngle: 90,
walkableHeight: 2.0,
walkableClimb: 1,
walkableRadius: 1,
maxEdgeLen: 12.,
maxSimplificationError: 1.3,
minRegionArea: 20,
mergeRegionArea: 20,
maxVertsPerPoly: 6,
detailSampleDist: 6,
detailSampleMaxError: 1,
};
let groundMeshes = meshes.map(m => m.groundMesh);
let obstacleMeshes = meshes.map(m => m.mesh);
navigationPlugin.createNavMesh([...groundMeshes, ...obstacleMeshes], navmeshParameters);
crowd = navigationPlugin.createCrowd(10, 0.1, scene);
}
module.exports = { createPlatforms };
I first thought that the problem was with the navmesh, so i removed that part, but still there was no change.
I loaded the model without textures, and it loaded correctly. then I started adding the textures one by one, and at one point it started crashing. but the problem wasn’t related to a single texture because it sometimes crashed and sometimes didn’t when i added/removed textures.
I’m at a loss I’d appreciate any input very much.
this is a model that loads without a problem (which has more vertex points and more textures than the one that doesn’t load)