我正在创建一个球体几何体。
geometry = new THREE.SphereGeometry( 200, 20, 10 );
material = new THREE.MeshLambertMaterial({ shading: THREE.FlatShading, color: 0xff0000 });
sphere = new THREE.Mesh(geometry, material);
scene.add( sphere );
我想要的是当我点击这个几何体时,面部会像下面的例子一样脱离。 (单击球体按钮以查看分离的面) http://www.mrdoob.com/lab/javascript/threejs/css3d/periodictable/
答案 0 :(得分:1)
您发布的示例的完整代码可在此处找到:http://jsfiddle.net/9XGuK/4/
具体来说,这部分示例:
var vector = new THREE.Vector3();
for ( var i = 0, l = objects.length; i < l; i ++ ) {
var phi = Math.acos( -1 + ( 2 * i ) / l );
var theta = Math.sqrt( l * Math.PI ) * phi;
var object = new THREE.Object3D();
object.position.x = 800 * Math.cos( theta ) * Math.sin( phi );
object.position.y = 800 * Math.sin( theta ) * Math.sin( phi );
object.position.z = 800 * Math.cos( phi );
vector.copy( object.position ).multiplyScalar( 2 );
object.lookAt( vector );
targets.sphere.push( object );
}
也许您可以在本地重新创建此代码,以便更好地了解它的工作原理,然后根据您的需要进行调整。