How to one object into another object draw or added shape in Three.js?

时间:2018-02-03 07:52:42

标签: javascript three.js geometry

I Drawn in one square object and I Drawn in another one square object. This two object How to merge double line square object display. Here I attached my code. Here display only one square object display. How to visible two objects same time?

 function doubleSquareDraw(startX, startY, endX, endY, color){

   var square = new THREE.Shape();
   square.moveTo(startX, startY, 0);
   square.lineTo(endX, startY, 0);
   square.lineTo(endX, endY, 0);
   square.lineTo(startX, endY, 0);
   square.lineTo(startX, startY, 0);

   var square2 = new THREE.Path();
   square2.moveTo(startX + 4 , startY  - 4 , 0);
   square2.lineTo(endX - 4 , startY - 4 , 0);
   square2.lineTo(endX - 4, endY + 4 , 0);
   square2.lineTo(startX + 4 , endY + 4 , 0);
   square2.lineTo(startX + 4 , startY  - 4 , 0);
   square.holes.push( square2);

  var geometry = new THREE.BufferGeometry().setFromPoints(square.getPoints());  
  var doubleLineSquare = new THREE.Line(geometry, new THREE.MeshBasicMaterial({
        color: color
    }));

    return doubleLineSquare;

}

0 个答案:

没有答案