我在three.js中使用图表。我确实绘制了不同形状的物体。怎么做?

时间:2018-02-02 12:47:02

标签: javascript canvas three.js

我使用var shape = new THREE.Shape();moveTolineTo使用但不是完整填充图,而closePath()不能使用lineTo。请告诉答案。

这是我的代码。

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 geometry = square.makeGeometry();  
 var square = new THREE.Line(geometry, new THREE.LineBasicMaterial({
           color: color
        }));

 return square;   

1 个答案:

答案 0 :(得分:0)

我在makeGeometry方法中使用不完全填充我的closePath。现在我查了我的代码var geometry = new THREE.BufferGeometry().setFromPoints(display.getPoints());。这种类型正确地完全填充了我的图表。

    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);  // closePath



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

 return square;