要對 Three.js 本身的程式發出修改,請參考 Three.js FAQ。這頁也回答其他關於 Three.js 的問題。
解答:把 createHelix 裡創造球的程式替換成:
var helix = new THREE.Object3D();
var bottom = new THREE.Vector3();
var top = new THREE.Vector3();
var openBottom = false;
var openTop = false;
var sine_sign = clockwise ? 1 : -1;
bottom.set( radius, -height/2, 0 );
for ( var i = 1; i <= arc*radialSegments ; i++ )
{
// 從 X 軸到 Z 軸
top.set( radius *Math.cos( i* 2*Math.PI / radialSegments ),
height *(i/(arc*radialSegments)) - height/2,
sine_sign *radius* Math.sin( i *2*Math.PI / radialSegments ) );
var capsule = createCapsule( material, tube, top, bottom, tubularSegments, openTop, openBottom );
helix.add( capsule );
// 第一個膠囊產生後,不要再在底部產生球體
openBottom = true;
// 讓上一個膠囊的 top 成為下一個膠囊的 bottom
bottom.copy( top );
}
return helix;