diff --git a/packages/core/src/Background.ts b/packages/core/src/Background.ts index 7e0f5ece5f..53c55097fa 100644 --- a/packages/core/src/Background.ts +++ b/packages/core/src/Background.ts @@ -86,24 +86,24 @@ export class Background { switch (this._textureFillMode) { case BackgroundTextureFillMode.Fill: - positions[0].setValue(-1, -1, -1); - positions[1].setValue(1, -1, -1); - positions[2].setValue(-1, 1, -1); - positions[3].setValue(1, 1, -1); + positions[0].setValue(-1, -1, 1); + positions[1].setValue(1, -1, 1); + positions[2].setValue(-1, 1, 1); + positions[3].setValue(1, 1, 1); break; case BackgroundTextureFillMode.AspectFitWidth: const fitWidthScale = 1 / ((this._texture.width * (height / width)) / height); - positions[0].setValue(-1, -fitWidthScale, -1); - positions[1].setValue(1, -fitWidthScale, -1); - positions[2].setValue(-1, fitWidthScale, -1); - positions[3].setValue(1, fitWidthScale, -1); + positions[0].setValue(-1, -fitWidthScale, 1); + positions[1].setValue(1, -fitWidthScale, 1); + positions[2].setValue(-1, fitWidthScale, 1); + positions[3].setValue(1, fitWidthScale, 1); break; case BackgroundTextureFillMode.AspectFitHeight: const fitHeightScale = (this._texture.width * (height / width)) / height; - positions[0].setValue(-fitHeightScale, -1, -1); - positions[1].setValue(fitHeightScale, -1, -1); - positions[2].setValue(-fitHeightScale, 1, -1); - positions[3].setValue(fitHeightScale, 1, -1); + positions[0].setValue(-fitHeightScale, -1, 1); + positions[1].setValue(fitHeightScale, -1, 1); + positions[2].setValue(-fitHeightScale, 1, 1); + positions[3].setValue(fitHeightScale, 1, 1); break; } _backgroundTextureMesh.setPositions(positions); diff --git a/packages/core/src/Engine.ts b/packages/core/src/Engine.ts index 5c431a8a5e..7b1eba4cfb 100644 --- a/packages/core/src/Engine.ts +++ b/packages/core/src/Engine.ts @@ -27,6 +27,7 @@ import { RenderState } from "./shader/state/RenderState"; import { Texture2D, TextureCubeFace, TextureCubeMap, TextureFormat } from "./texture"; import { PhysicsManager } from "./PhysicsManager"; import { ModelMesh, PrimitiveMesh } from "./mesh"; +import { CompareFunction } from "./shader"; /** TODO: delete */ const engineFeatureManager = new FeatureManager(); @@ -190,6 +191,7 @@ export class Engine extends EventDispatcher { this._backgroundTextureMaterial = new Material(this, Shader.find("background-texture")); this._backgroundTextureMaterial.isGCIgnored = true; + this._backgroundTextureMaterial.renderState.depthState.compareFunction = CompareFunction.LessEqual; this._backgroundTextureMesh = PrimitiveMesh.createPlane(this, 2, 2, 1, 1, false); this._backgroundTextureMesh.isGCIgnored = true;