I want to use babylon file and only have glb file. So I use a webpage to convert glb to babylon file.Finally I get a babylon file,but the model in babylon file seems have som meshes with wrong position.
This is origin glb file.
This is webpage used to convert glb to babylon.
This is babylon file exported by webpage.
Hello! Have you tried to use the Sandbox (sandbox.babylonjs.com) to convert from GLB to babylon? Is the result the same?
1 Like
I tried loading the final1_old.glb
into the sandbox and export to .babylon
and then reload in sandbox. That seems to be working.
@xiaopangoo You seem to be mucking with the ids/names in the scene before exporting. Does it work if you don’t muck with the names?
//material.id处理
for(var i=0; i<scene.meshes.length;i++){
var newId = createUuid();
console.log(i + '--' + scene.meshes[i].name);
console.log(scene.meshes[i].material);
if(scene.meshes[i].material){
console.log(i + '--' + scene.meshes[i].material.id+ '--' + newId);
scene.meshes[i].material.id = newId;
scene.meshes[i].material.name = newId;
}
}
//geometry.uniqueId,geometry.id处理
for(var i=0; i<scene.meshes.length;i++){
var newId = createUuid();
console.log(i + '--' + scene.meshes[i].name);
console.log(scene.meshes[i].geometry);
if(scene.meshes[i].geometry){
console.log(i + '--' + scene.meshes[i].geometry.id+ '--' + scene.meshes[i].geometry.uniqueId + '--' + newId);
scene.meshes[i].geometry.id = newId;
scene.meshes[i].geometry.uniqueId = newId;
}
}
//skeletonId处理
for(var i=0; i<scene.skeletons.length;i++){
var newId = createUuid();
console.log(i + '--' + scene.skeletons[i].id + '--' + newId);
scene.skeletons[i].id = newId;
scene.skeletons[i].name = newId;
}
//id,uniqueId处理
for(var i=0;i<scene.getNodes().length;i++){
var tmpNode = scene.getNodes()[i];
console.log(i+'--' + tmpNode.name + '--' + tmpNode.id + '--'+ tmpNode.uniqueId );
//根节点名字处理
if(i === 0){
tmpNode.name = fileName.split('.')[0];
}
tmpNode.id = createUuid();
tmpNode.uniqueId = tmpNode.id;
console.log(i+'--' + tmpNode.name + '--' + tmpNode.id + '--'+ tmpNode.uniqueId );
console.log(tmpNode.parent);
}
Hello @xiaopangoo just checking in, are you still having issues?