假设我有一个像这样的球体:
var geometry = new THREE.SphereGeometry( 1, 32, 32 );
window.sphere = new THREE.Mesh( geometry, material );
scene.add( window.sphere );
然后我如何围绕球体的直径画一条线?优选平行于x轴。这里的最终目标是使用这样的线与文本一起来说明尺寸(例如,这个球体是10米宽)。
答案 0 :(得分:2)
你可以使用这个技巧:
var material = new THREE.MeshBasicMaterial( { color: 0xaaaaaa } );
var geometry = new THREE.SphereGeometry( 32, 32, 32 );
var sphere = new THREE.Mesh( geometry, material );
scene.add( sphere );
var geometry = new THREE.TorusGeometry( 31.9, 0.16, 64, 100 );
var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
var torus = new THREE.Mesh( geometry, material );
torus.rotation.x = Math.PI/2;
scene.add( torus );
http://jsfiddle.net/10hemttk/36/
更新。好吧,这种方式更正确:
var rad = 32,
delta = 0.05,
segs = 64,
material = null,
geometry = null,
circle = null,
sphere = null;
material = new THREE.LineBasicMaterial( { color: 0xffff00 } ),
geometry = new THREE.CircleGeometry( rad+delta, segs ),
geometry.vertices.shift();
circle = new THREE.Line( geometry, material );
circle.rotation.x = Math.PI/2;
scene.add( circle );
material = new THREE.MeshBasicMaterial( { color: 0xaaaaaa } );
geometry = new THREE.SphereGeometry( rad, segs, segs );
sphere = new THREE.Mesh( geometry, material );
scene.add( sphere );