I’m working on an editor which overlays the scene that would allow someone to edit standard materials using Blender material values. It uses metadata to hold the Blender values. I have made changes to the Blender exporter to include the metadata in the ‘output.babylon’ file. However, that data was unavailble in babylon.js.
I tweaked a local copy of ‘babylon.3.3.0.max.js’ to get everything to work. I point my tweaks to the appropriate babylon.ts files.
Babylon.js/src/Materials/material.ts
I see that the 'metadata' property has been added to 'material.ts' since version 3.3.0. However it is null in the scene.
I think by changing <line 123> from this:
/**
* Gets or sets user defined metadata
*/
public metadata: any = null;
to this:
/**
* Gets or sets user defined metadata
*/
@serialize()
public metadata: any = null;
I originally got metadata added to material by doing the following:
babylonFileLoader.ts line 88
var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
...
// Materials
if (parsedData.materials !== undefined && parsedData.materials !== null) {
for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
var parsedMaterial = parsedData.materials[index];
var mat = BABYLON.Material.Parse(parsedMaterial, scene, rootUrl);
//!!! added next line <approx.line 77838 in babylon.3.3.0.js>
mat.metadata = parsedMaterial.metadata;
container.materials.push(mat);
log += (index === 0 ? "\n\tMaterials:" : "");
log += "\n\t\t" + mat.toString(fullDetails);
}
}
It worked, but it didn’t seem to be the best solution. I found that parsing was failing in decorators.ts getMergedStore. By adding @serialize () to material metadata seemed to be a better solution. I would consider doing a pull request, but I am currently not set up to do that.