I am trying to create a sphere that is on the map and affected by all the light sources. I've got it to react to ambient light. Any thoughts? And maybe I am just missing something easy here.
JavaScript:
mv3d.createSphere = function() {
// Create sphere
var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", { diameter: 4, segments: 32 }, mv3d.scene);
sphere.x = 18;
sphere.y = 15;
sphere.z = 1.1;
sphere.isEvent = true;
var sphereMat = new BABYLON.StandardMaterial("sphereMat", mv3d.scene);
sphereMat.diffuseColor = new BABYLON.Color3(1, 1, 1);
sphereMat.diffuseTexture = new BABYLON.Texture("img/MV3D/errorTexture.png", mv3d.scene);
sphere.material = sphereMat;
// Access lights from the map
var mapLights = mv3d.scene.lights;
// Check if there are lights on the map
if (mapLights && mapLights.length > 0) {
// Use the first light as the ambient light source (you may need to adjust based on your specific use case)
sphereMat.ambientColor = mapLights[0].diffuse; // Assuming the ambient color is the same as the diffuse color of the light
}
};