Hey guys,
Sorry this is my first time using this software so its probably something straight forward I’ve missed. I have a scene with background set to transparent using:
scene.clearColor = new BABYLON.Color4(0,0,0,0.0000000000000001);
Which works however my sphere mesh object which is using a JPG texture has become semi transparent also? Please see below for full coding:
let canvas = document.getElementById("renderCanvas");
let createScene = function () {
let scene = new BABYLON.Scene(engine);
scene.clearColor = new BABYLON.Color4(0,0,0,0.0000000000000001);
let globeMat = new BABYLON.StandardMaterial("globeMat", scene);
globeMat.diffuseTexture = new BABYLON.Texture("img/textures/earth.jpg", scene);
globeMat.diffuseColor = new BABYLON.Color3(255, 255, 255);
globeMat.specularColor = new BABYLON.Color3(255, 255, 255);
globeMat.emissiveColor = new BABYLON.Color3(255, 255, 255);
globeMat.ambientColor = new BABYLON.Color3(255, 255, 255);
let sphere = BABYLON.MeshBuilder.CreateSphere("sphere", {sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
sphere.material = globeMat;
let arcCamera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, Math.PI / 4, 5, BABYLON.Vector3.Zero(), scene);
arcCamera.setPosition(new BABYLON.Vector3(0, 0, 5));
arcCamera.target = new BABYLON.Vector3(0, 0, 0);
scene.activeCamera = arcCamera;
scene.beforeRender = function () {
arcCamera.alpha += .01;
};
return scene;
};
let engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true });
let scene = createScene();
engine.runRenderLoop(function () {
if (scene) {
scene.render();
}
});
// Resize
window.addEventListener("resize", function () {
engine.resize();
});