threejs 畫二維圓(圓弧)


畫圓:
var radius = 40,
segments = 64,
material = new THREE.LineBasicMaterial({ color: 0x0000ff }),
geometry = new THREE.CircleGeometry(radius, segments);

// Remove center vertex
geometry.vertices.shift();

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

 

 
使用THREE.Line會導致最后一點和第一點未鏈接,可用
this.scene.add(new THREE.LineLoop(geometry, material));

 

 
 
畫圓也可用(該方法可自行設置畫圓弧)
let points = [],
length = 100,
circle = 40;
for (let i = 0; i <= length; i++) {
  points.push(new THREE.Vector2(circle * Math.cos(Math.PI * 2 * i / length), circle * Math.sin(Math.PI * 2 * i / length)))
}
let shape = new THREE.Shape(points);
let arcGeometry = shape.makeGeometry()
let arcMaterial = new THREE.LineBasicMaterial({ color: 0x38d3f5 });
let arc = new THREE.Line(arcGeometry, arcMaterial);

 

this.scene.add(arc)
注:該方法畫圓最后無法閉合


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM