Babylon material factory
Creates babylon materials from an abstract data format. All textures are referenced at your will as an user-defined URL resolver. will be called.
This library is coded in ES6.
Add the npm package babylon-material-factory to your project:
npm install babylon-material-factory babylonjs --save
git clone firstname.lastname@example.org:wanadev/babylon-material-factory.git
Please not that the BabylonJS dependency is configured to be a peer one. Thus, you'll need to provide the dependency by yourself.
const materialFactory = ;// Set the URL resolver..materialFactory;// Creates a BABYLON.StandardMaterial.materialFactory;
When not set, the default URL resolver supposes that the
is an URL. Which means it's implementation looks like:
generateMaterial accepts a list of data that are stored
in a plain object way:
Validity of each parameter is not checked: it is just applied
to a object through the
applyData(material, data) function.
This means, even if BabylonJS's API change in the future,
this library won't need any update.
However, for non-basic attributes (those which are not numbers nor strings),
you will need to create an object with
Material's param: texture
Within the material object, one can specify a texture:
NOTE: One can specify an
"url" property directly with no
In that case, no URL resolver is needed.
You can specify if you want a BABYLON.Texture (default) or a
BABYLON.CubeTexture with the
Material's param: color
A color is defined as such:
value is any parsable
Material's param: fresnelParameters
A FresnelParameter is defined as such:
By default, a
BABYLON.StandardMaterial is created, however a
BABYLON.PBRMaterial can be instanciated with: