我不能得到THREE.LineDashedMaterial在三个js中正常工作(我正在使用r73,但刚刚尝试过r74).改变颜色很好,但破折号似乎不起作用.这是我的例子:
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));
我在我的例子中做错了什么,或者这个错误(https://github.com/mrdoob/three.js/issues/6699)仍然是一个问题?
解决方法
如果要使用THREE.Geometry和THREE.LineDashedMaterial创建一行,则需要调用
line.computeLineDistances(); // or lineSegments.computeLineDistances()
让虚线正确渲染.
three.js r.91