Artifacts happening with the Universal camera and intersecting meshes

I have come across something that looks like a bug to me:
When 2 meshes, scripted in Babylonjs, intersect and a universal (free) camera is used, the intersecting faces start jittering. It does not happen when I create an optimized mesh outside Babylonjs and import it.
Seems like a bug to me so I post it here.
Of course i may be missing something ;-p … is there a simple line of code that can resolve it?


var createScene = function () {
var scene = new BABYLON.Scene(engine);

var baseLight = new BABYLON.HemisphericLight("baseLight", new BABYLON.Vector3(0, 10, 0), scene);

var box2 = BABYLON.MeshBuilder.CreateBox("b2", {width:10,height:3,depth:.2}, scene);
box2.rotation.y = Math.PI/4;
var box3 = BABYLON.MeshBuilder.CreateBox("b3", {width:.2,height:3,depth:10}, scene);
box3.rotation.y = Math.PI/4;

var mat1 = new BABYLON.StandardMaterial("textureGrass", scene);
mat1.diffuseTexture = new BABYLON.Texture("textures/grass.jpg", scene);

var mat2 = new BABYLON.StandardMaterial("textureWood", scene);
mat2.diffuseTexture = new BABYLON.Texture("textures/wood.jpg", scene);
mat2.diffuseColor = new BABYLON.Color3(0.89, 0.08, 0.08);

box2.material = mat1;
box3.material = mat2;

// FreeCamera >> You can move around the world with mouse and keyboard (LEFT/RIGHT/UP/DOWN)
var freeCamera = new BABYLON.UniversalCamera("UniversalCamera", new BABYLON.Vector3(0, 1, -15), scene);
freeCamera.attachControl(canvas, true);
freeCamera.minZ = 0.0001;
freeCamera.speed = 0.1;
freeCamera.angularSpeed = 0.025;
freeCamera.angle = Math.PI/2;
freeCamera.direction = new BABYLON.Vector3(Math.cos(freeCamera.angle), 0, Math.sin(freeCamera.angle));

freeCamera.attachControl(canvas, true);

return scene;

I am very new to all of this and have not been able to create a playground page yet so i post the code here.

Your are experiencing z-fighting because you set a camera minZ value too low, use 0.1 instead for eg:

Thank you so VERY MUCH!
I better take the subject out of the bugs section then :wink: