Gradient material
You can get the gradient material:
- Using npm with npm install --save babylonjs babylonjs-materials
- With a direct reference to: https://cdn.babylonjs.com/materialsLibrary/babylonjs.materials.min.js
Using the gradient material
The material creates a smooth gradient with two colors:
var sphere = BABYLON.Mesh.CreateSphere("sphere", 32, 2, scene);var gradientMaterial = new BABYLON.GradientMaterial("grad", scene);gradientMaterial.topColor = BABYLON.Color3.Red(); // Set the gradient top colorgradientMaterial.bottomColor = BABYLON.Color3.Blue(); // Set the gradient bottom colorgradientMaterial.offset = 0.25;sphere.material = gradientMaterial;
The gradient material can be configured with:
topColor
andbottomColor
are the two colors used in this gradient materialoffset
is a number used to offset the color on the Y axisscale
is a number used to scale the color on the Y axissmoothness
is a number (between 0 and 10) which can be used to define the speed of the color change along Y axis (1 by default)