Hi, everyone. I usually create my scene by using the blender editor and exporting it to the babylon frame on the babylon editor. Recently we noticed that the scene.babylon archive is too heavy and we decided to try importing the .glb file direct to the scene script. I tried many ways to solve the problem but it doesn’t work, and my screen only displays a white background and no console problem. I was hoping you guys could help me.
The rest of the code is fine, defining the camera, gui config and all this stuff. My problem is here on these particular lines.
// import scene
BABYLON.SceneLoader.ShowLoadingScreen = false;
BABYLON.Tools.LoadFile(“auditoriotodraco.glb”, onSceneImported, onLoading);
function onLoading(evt) {
// onProgress
var loadedPercent = 0;
if (evt.lengthComputable) {
loadedPercent = (evt.loaded * 100 / evt.total).toFixed();
} else {
var dlCount = evt.loaded / (1024 * 1024);
loadedPercent = Math.floor(dlCount * 100.0) / 100.0;
}
// assuming “loadingScreenPercent” is an existing html element
document.getElementById(“loadingScreenPercent”).innerHTML = loadedPercent + “%”;
}
function onSceneImported(newMeshes, particleSystems, skeletons) {
async function draco(data){
var dracoCompression = new BABYLON.DracoCompression();
var attributes = {
// [BABYLON.VertexBuffer.UVKind]: 0,
// [BABYLON.VertexBuffer.NormalKind]: 1,
// [BABYLON.VertexBuffer.TangentKind]: 2,
[BABYLON.VertexBuffer.PositionKind]: 3
};
var vertexData = await dracoCompression.decodeMeshAsync(data, attributes);
var mesh = new BABYLON.Mesh(“dracoMesh”, scene);
var geometry = new BABYLON.Geometry(“dracoGeometry”, scene, vertexData, undefined, mesh);
return draco
}
const modalOverlay = document.querySelector(’.modal-overlay’);
scene.activeCamera = camera;
scene.gravity = new BABYLON.Vector3(0, -0.1, 0);
var camSphere = BABYLON.MeshBuilder.CreateSphere(“sphere”, {diameterY: 3, diameterX: 0.1}, scene);
camSphere.parent = camera;
camSphere.visibility = 0;
scene.registerBeforeRender();
/* Make performance better */
scene.autoClear = false;
scene.autoClearDepthAndStencil = false;
scene.blockMaterialDirtyMechanism = true;
scene.getAnimationRatio();
setTimeout(function(){
engine.hideLoadingUI();
modalOverlay.classList.add("active");
}, 5000);
}
return scene
}