if scene use skybox , then mesh material disable depthTest and depthWrite no show

If the scene uses skybox via scene.background, it’s not possible to see the mesh when depthTest and depthWrite of its materials is set to false.

envMap = new THREE.CubeTextureLoader()
.setPath( 'textures/cube/skyboxsun25deg/')
.load( [ 'px.jpg', 'nx.jpg', 'py.jpg', 'ny.jpg', 'pz.jpg', 'nz.jpg' ] );
scene.background = envMap;

var lineMaterial = new THREE.MeshBasicMaterial();
lineMaterial.color.setHex( 0xDAA520 );
material.depthTest = false;
material.depthWrite = false;

var lineGeometry = new THREE.BoxBufferGeometry( 10, 10, 10 );
var lineEntity = new THREE.Mesh( lineGeometry, lineMaterial );
scene.add( lineEntity );

image

Three.js version
  • Dev
  • r98
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Author: Fantashit

1 thought on “if scene use skybox , then mesh material disable depthTest and depthWrite no show

  1. Perhaps the background should be rendered first.

    Yeah… The fact that it renders last is supposed to be to avoid drawing pixels twice. It’s a optimisation that keeps bumping into cases where it creates issues.

    I agree, we should change it so it renders first. It’ll be better to favour something robust better than something optimal but delicate.

Comments are closed.