手记

THREE.JS中球型结构公式

<script>    
    var vector = new THREE.Vector3();
    var spherical = new THREE.Spherical();

    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();

        spherical.set( 800, phi, theta );

        object.position.setFromSpherical( spherical );

        vector.copy( object.position ).multiplyScalar( 2 );

        object.lookAt( vector );

</script>
2人推荐
随时随地看视频
慕课网APP