Hi,guys,I am recently trying to mix div and canvas together according to the post here: https://forum.playcanvas.com/t/3d-plane-with-website/2723/6,all seems fine but I am facing a problem at the last step,how to make the background div visible.
At first I tried to add the div in front of the canvas but the div is always block the 3d object no mater what their position is:
So I added the div behind the canvas and enabled transparent canvas in the render settings,tried to make the material transparent by the following code:
var material = new pc.StandardMaterial();
material.depthWrite = true;
material.redWrite = false;
material.greenWrite = false;
material.blueWrite = false;
material.alphaWrite = true;
material.blendType = pc.BLEND_NORMAL;
material.opacity = 0;
material.update();
node.material = material;
The pc.Css3Plane is a constructer which create a domElement in html and a 3d plane in game scene and merge them together,update the domElement transform according to the 3d plane every frame so they look the same to the viewer.
var css3Plane = new pc.Css3Plane();
var domElement = css3Plane.element;
var planeEntity = css3Plane.planeEntity;
// change the transform of the planeEntity will update the domElement too
planeEntity.rotate(10,10,10);
// you can attach the domElement to an existing plane in game editor,change its transform and see the result
css3Plane.attachPlane(anotherPlaneEntity);
the problem I’m facing is how to sort the z-index of the domElement and webgl 3d objects so they can occlusion correctly.A tricky solution is make the canvas transparent,render the div behind it,and set the planeEntity attached to that div transparent too so the div behind the canvas will be shown.but I don’t know the correct way to do that
Any idea why when I launch your project I get this, blank transparent planes instead of something like your last pic, the youtube screengrabs rendered:
Yeah,that’s another problem I am facing ,I guess that may be a compatibility issue?I have the same problem on the computer in my home,even on the same browser(chrome).open the console you will find the div’s position is correct but they are just not shown,It’s really wierd.