2016-03-03 145 views
3

我不能让THREE.LineDashedMaterial在三个js中正常工作(我正在使用r73,但刚刚尝试过r74)。改变颜色很好,但破折号似乎不起作用。这是我的例子:THREE.LineDashedMaterial - 破折号不起作用

var segmentCount = 200; 
var radius = 100; 
var geometry = new THREE.Geometry(); 
var material = new THREE.LineDashedMaterial({ color: 0xff0000, linewidth: 5, dashSize: 1.0, gapSize: 0.5 }); //new THREE.LineBasicMaterial({ color: 0xFFFFFF, linewidth: 10 }); 

for (var i = 0; i <= segmentCount; i++) { 
var theta = (i/segmentCount) * Math.PI * 2; 
geometry.vertices.push(
    new THREE.Vector3(
     Math.cos(theta) * radius, 
     Math.sin(theta) * radius, 
     0));    
} 


scene.add(new THREE.Line(geometry, material)); 

我做在我的例子有什么错误的是这个bug(https://github.com/mrdoob/three.js/issues/6699)仍然是一个问题?

回答

5

如果您正在使用THREE.GeometryTHREE.LineDashedMaterial创建一条线,你需要调用

geometry.computeLineDistances(); 

得到虚线正确呈现。

three.js r.74

+0

很棒,我现在可以在文档中看到。谢谢你,我暂时不会找到它:) – garrettlynch