4

I have a set of objects that I'd like to always be visible, even if they're occluded by another object. They objects are meshes, not particles or sprites. Here's a screenshot of the effect I'm trying to mimic. This was done in C++ and OpenGL:

enter image description here

Notice the red and green triangles as well as the black lines (and the text, for that matter). They all lie on the ground plane, but they're visible even though the green machine is closer.

Can I force visbility with Three.js?

Justin
  • 1,881
  • 4
  • 20
  • 40
  • 1
    See http://stackoverflow.com/questions/12666570/how-to-change-the-zorder-of-object-with-threejs/12666937#12666937 – WestLangley Nov 08 '14 at 15:54

1 Answers1

2

you can accomplish this by disabling the depth test of the material. this means its always rendered in front of everything.

var material = new THREE.MeshBasicMaterial({color: 0xFF0000});
    material.depthTest = false;
var mesh = new THREE.Mesh(new THREE.BoxGeometry(5, 5), material);
Kevin Kuyl
  • 1,215
  • 1
  • 17
  • 31
  • The problem with this solution is the mesh does not depth test against itself, so faces in the back of the mesh can render on top. – WestLangley Nov 08 '14 at 15:55
  • This doesn't always work for me. Sometimes the objects are drawn on top, but then I rotate the camera and they're hidden again. Any idea why? – Justin Nov 08 '14 at 16:03
  • no, sorry, i have no idea. in this case, the solution WestLangley proposed (a new scene on top of the actual content) would work best. (which is no surprise, btw) – Kevin Kuyl Nov 08 '14 at 16:09
  • 1
    come to think of it, it could be because the 0,0,0 point of the grid is outside the camera frustum. if you havent changed it yet, try `mesh.frustumculled = false;` but still, as WestLangley said. the mesh doesnt depth test against itself, with a `MeshBasicMaterial` its no problem though. it's all the same color anyway. if you need more complex objects rendered, the solution westlangley proposed is still the better option. – Kevin Kuyl Nov 09 '14 at 01:24