Using multiuple textures on a sphere [Three.js]

前端 未结 1 2004
长情又很酷
长情又很酷 2021-01-24 20:32

Is it possible to load multiple textures on a sphere?

I mean to say is there any way in Three.js to split a sphere into n pieces , texture them

相关标签:
1条回答
  • 2021-01-24 21:34

    This should help: https://open.bekk.no/procedural-planet-in-webgl-and-three-js Instead of using a sphere try using a cube and expanding it into a sphere. Cube logic on the cube sphere will save you a good amount of time.

    var geometry = new THREE.BoxGeometry( 1, 1, 1, 8, 8, 8 );
    for ( var i in geometry.vertices ) {
        var vertex = geometry.vertices[ i ];
        vertex.normalize().multiplyScalar(radius);
    }
    
    var materialArray = [];
    var faceMaterial = new THREE.MeshLambertMaterial({
        color: sphereColor,
        transparent: true,
        opacity: 0.4
    });
    for (var i = 0; i < 6; i++) {
        materialArray.push(faceMaterial);
    }
    
    var material = new THREE.MeshFaceMaterial(materialArray);
    var sphere = new THREE.Mesh( geometry, material );
    scene.add( sphere );
    
    0 讨论(0)
提交回复
热议问题