Hello everyone,
I am currently encountering a problem while embedding an iFrame on a plane within my 3D scene. Specifically:
- When I move behind the plane (positioned in mid-air), the video on the plane becomes visible in reverse from the backside.
- When the player/character stands in front of the plane, the plane’s rendering appears to be at a higher display level, causing the character to appear behind the plane—even though the character is logically in front of it.
These issues do not manifest in the editor itself, but appear once I test or play the scene in an actual runtime environment while using engine in code with react.
I would greatly appreciate any guidance on how to fix these rendering or depth-sorting discrepancies. If you have experience with similar iFrame, your suggestions or best practices would be extremely helpful.
This is the example I used: PlayCanvas 3D HTML5 Game Engine
let beforeWorld = app.scene.layers.getLayerByName("Before World");
if (!beforeWorld) {
beforeWorld = new extendedPc.Layer({ name: "Before World" });
app.scene.layers.insert(beforeWorld, 0);
}
const immediateLayer = app.scene.layers.getLayerByName("Immediate");
immediateLayer.opaqueSortMode = extendedPc.SORTMODE_NONE;
const uiLayer = app.scene.layers.getLayerByName("UI");
uiLayer.opaqueSortMode = extendedPc.SORTMODE_MANUAL;
uiLayer.transparentSortMode = extendedPc.SORTMODE_MANUAL;
const skyboxLayer = app.scene.layers.getLayerByName("Skybox");
skyboxLayer.opaqueSortMode = extendedPc.SORTMODE_NONE;
const childPlane = new extendedPc.Entity("ChildPlane");
childPlane.setLocalPosition(0, 3, -1.4391355514526367); // Position relative to the parent
childPlane.setLocalScale(1.492, 1, 1.305);
childPlane.setEulerAngles(90, 0, 0);
childPlane.addComponent("render", {
type: "plane",
});
childPlane.render.castShadows = true;
childPlane.render.castShadowsLightmap = true;
childPlane.render.receiveShadows = true;
childPlane.render.layers = [beforeWorld.id];
app.root.addChild(childPlane);
childPlane.addComponent("script");
childPlane.script.create("iframePlane", {
attributes: {
iframeUrl: URL,
pixelsPerUnit: 320,
},
});
Thank you in advance for your time and assistance.
Kind regards,