Three.js - 形状填充颜色

时间:2014-04-12 17:11:20

标签: javascript three.js shape fill

我有以下代码画一个黄色圆圈:

  var radius = 5,
    segments = 64,
    material = new THREE.LineBasicMaterial( { color: 0xF0C400 } ),
    geometry = new THREE.CircleGeometry( radius, segments );

  geometry.vertices.shift();
  var circle = new THREE.Line(geometry, material);

  circle.position.set(5,5,0);
  circle.rotation.set(1.57,0,0);
  scene.add(circle);

我唯一的问题是如何让这个圆圈充满颜色?我试图更换材料,但我仍然只看到轮廓形状..

更新:我不得不将THREE.Line改为THREE.Mesh ..!

1 个答案:

答案 0 :(得分:3)

material = new THREE.MeshBasicMaterial( { color: 0xF0C400, side: THREE.DoubleSide } );

geometry = new THREE.CircleGeometry( radius, segments );

mesh = new THREE.Mesh( geometry, material );

有关更一般的解决方案,请参阅http://threejs.org/examples/canvas_geometry_shapes.html

three.js r.66