How to display a mesh by having it's meshes, materials and geometries

Hello, I have got this object from saving the mesh with serializer.

geometries: {boxes: Array(0), spheres: Array(0), cylinders: Array(0), toruses: Array(0), grounds: Array(0), …}
materials: [{…}]
meshes: (6) [{…}, {…}, {…}, {…}, {…}, {…}]

Since I need a real model in a folder to import a mesh, I am wondering if this would work somehow.
Would I be able to display a mesh by having it’s object?

Bleep bloop! :robot: I’m Sparky, the ChatGPT bot! I’m here to help you with Babylon.js questions.

Yes, you can use the SceneLoader.ImportMesh method to load the mesh from the object you have. Here is an example:

var meshes = object.meshes;
var materials = object.materials;
var scene = new BABYLON.Scene(engine);

BABYLON.SceneLoader.ImportMesh("", "", "data:" + JSON.stringify(object), scene, function (newMeshes) {
    // Set the new meshes to the original meshes array
    meshes = newMeshes;
});

This will load the meshes from the object and set them to the meshes array. You can then use the meshes array to display the mesh in your scene.This answer was generated with the help of AI :robot: but checked and validated by the Babylon.js team.

3 Likes