three.js icon indicating copy to clipboard operation
three.js copied to clipboard

when depthTest is false or depthWrite is false and a mesh and a ribbon are overlapped, mesh always cover ribbon

Open jasonjifly opened this issue 13 years ago • 2 comments

test test2

My purpose is just use webgl to simulate a line with linecap drawn with canvas 2D, I use ribbon to simulate the line, then draw a circle in the two ends of ribbon. I think all what I said above is easy. My difficulty is my line has border. So my solution is use two ribbons, one is wider than another one, the narrower one will cover the wider one, the wider one has the same color with border, I also use two circles, one is smaller, the smaller will cover the bigger, the bigger has the same color with border, I hope that ribbon covers half of circle and they must have same z coordinate. The only thing that annoys me: When I only set: this.camera.position.z = 1500; Every thing looks well.

But when I set these:

  this.camera.position.z = 1000;
  this.camera.position.y = 2;
  this.camera.lookAt(new THREE.Vector3(0, 0, 0));

Every circle in lower half part of screen covers the ribbon, this is I do not hope to see! Help!

I have upload two images, one is what I want, another one is what I don't want.

The follows are my codes:

Draw circle:

  var circleShape = new THREE.Shape();
  var circleRadius = lineWidth/2;
  circleShape.moveTo( 0, circleRadius );
  circleShape.quadraticCurveTo( circleRadius, circleRadius, circleRadius, 0 );
  circleShape.quadraticCurveTo( circleRadius, -circleRadius, 0, -circleRadius );
  circleShape.quadraticCurveTo( -circleRadius, -circleRadius, -circleRadius, 0 );
  circleShape.quadraticCurveTo( -circleRadius, circleRadius, 0, circleRadius );

   var geometry = new THREE.ShapeGeometry( circleShape );
   var material = new THREE.MeshBasicMaterial( { color: color, depthWrite: false} );
   var mesh = new THREE.Mesh (geometry, material);
   mesh.position.set( x, y, z );
   mesh.rotation.set( rx, ry, rz );
   mesh.scale.set( s, s, s );
   this.parent.add( mesh );

Draw ribbon:

     var geometry = new THREE.Geometry();
     geometry.vertices.push( ( new THREE.Vector3(point.x, point.y, 0) ) );
     geometry.vertices.push...
     geometry.vertices.push...
     var material = new THREE.MeshBasicMaterial( { color: color, depthWrite: false} );
     var line = new THREE.Ribbon( geometry, material );
     line.position.set( x, y, z );
     line.rotation.set( rx, ry, rz );
     line.scale.set( s, s, s );
     this.parent.add( line );

jasonjifly avatar Dec 17 '12 03:12 jasonjifly

I seems that no one is interested in my question.

jasonjifly avatar Dec 19 '12 03:12 jasonjifly

Ribbon is no longer part of the lib.

mrdoob avatar Oct 19 '14 02:10 mrdoob