LoadAsset(scene, path, fileName) {
const result = await SceneLoader.ImportMeshAsync("", path, fileName, scene);
// Get the bounding box information (min and max)
const mesh = result.meshes[1];
const boundingInfo = mesh.getBoundingInfo();
const boundingBoxMin = boundingInfo.boundingBox.minimum;
const boundingBoxMax = boundingInfo.boundingBox.maximum;
// Dispose of the mesh
mesh.dispose();
const box = MeshBuilder.CreateBox(
`boundingBox`,
{
width: boundingBoxMax.x - boundingBoxMin.x,
height: boundingBoxMax.y - boundingBoxMin.y,
depth: boundingBoxMax.z - boundingBoxMin.z,
},
scene
);
box.position = boundingBoxMin.add(boundingBoxMax).scale(0.5);
box.url = fileName;
box.normalizeToUnitCube();
return box;
}
This is my code when I try normalizeToUnitCube method with CreateBox object it scales fine. But unable to make it work with imported meshes with draco compression. Please let me know if I am missing something?
Thank You