Hi, I’m trying to render a scene with a skybox created from a HDR file and the skybox shows correctly. But after I changed camera’s minZ and maxZ with calculated clip distance, the skybox can’t be seen and the background only shows the clear color. I tried to set the clearColor to (0, 0, 0, 0) , the background becomes transparent but the skybox still can’t be seen. I also changed the skyboxholder’s infiniteDistance to be true, still can’t see the skybox. Here’s the code.
await SceneLoader.AppendAsync(modelRootPath, modelFileName, this[$scene])
.then(() => {
const {min, max} =
this[$scene].meshes[0].getHierarchyBoundingVectors();
const modelRadius =
Math.max(max.x - min.x, max.y - min.y, max.z - min.z);
const far = 2 * Math.max(modelRadius, orbit.radius);
const near = far / 1000;
// after adding these two lines, the skybox disappear.
this[$camera].minZ = near;
this[$camera].maxZ = far;
});
this[$scene].stopAllAnimations();
this[$hdrTexture] = new HDRCubeTexture(
scenario.lighting, this[$scene], 256, false, false, false);
this[$scene].environmentTexture = this[$hdrTexture];
this[$hdrTexture].setReflectionTextureMatrix(
Matrix.RotationY(Tools.ToRadians(180)));
const skyboxHolder =
this[$scene].createDefaultSkybox(this[$scene].environmentTexture!, false, 128);
skyboxHolder!.rotate(Axis.Y, Math.PI, Space.WORLD);
skyboxHolder!.infiniteDistance = true;
Could you help me find what’s the problem? Thanks!