In three.js renderDepth of the mesh seems to be ignored

866 Views Asked by At

I'd like to render a mesh on top of everything else, this solution works fine: Three.js - Geometry on top of another

I was wondering if the same could be achievable with mesh.renderDepth, but I couldn't make it work so far. Seems like renderDepth only has an effect if material.depthTest or depthWrite is set to false, but then depth ordering is of course wrong within the same object: http://jsfiddle.net/SF9tX/22/

var cube = new THREE.Mesh(geometry, material);
cube.renderDepth = 1;
scene.add(cube);

var cube2 = new THREE.Mesh(geometry, material);
cube2.position.x = 1;
cube2.renderDepth = 2;
scene.add(cube2);

// with any one of these lines the renderDepth has an effect
// but then of course the depth test/write is wrong within the same object
// material.depthWrite = false;
// material.depthTest = false;
1

There are 1 best solutions below

0
On

For r70 is renderDept function removed. https://github.com/mrdoob/three.js/issues/5496