I am using @magavr/ecsy-babylon to interact with Babylon objects in an ECS style. One challenge has been that this library uses an old version of ecsy and Babylon , so I’ve been updating it to function with Babylon 4.2.
I am able to add ‘Mesh’ and ‘Material’ components to my scene, but the material is not being set to the Mesh, despite console.log telling me it is:
// This ECS Query runs every time a mesh material is added to an entity
this.queries.meshMaterial.added.forEach((entity: Entity) => {
if (!this._isUrlMesh(entity)) {
let material = entity.getMutableComponent(Material)!;
material.object = (new BABYLON.StandardMaterial(material.color!.diffuse!, getScene(this, material.scene))); // Create the material
this._updateMaterial(material);
let mesh = entity.getMutableComponent(Mesh)!; // Mesh is the ecsy component, its 'object' property is the BABYLON.Mesh
mesh.object.material = material.object; // Set the material to the BABYLON.Mesh
console.log(mesh.object) // This is not null, and shows as the BABYLON.Mesh.
console.log(mesh.object.material) // The attached material. This is not null, and shows as the material created above
}
});
When I run my app, the mesh does not have the material specified, and selecting the mesh on the inspector shows:

The ‘Active Material’ dropdown shows “None (Default Fallback)”. The material I created using the script above (#FF0000) does show in the material list, and manually selecting it from the dropdown does set the material to the mesh as expected. It also causes the “Link to Material” row to appear on the Inspector.
This feels like I am missing something simple here… Please let me know if anyone has any ideas!
