1. 程式人生 > >three.js 多面幾何體進行多面貼圖 (貼圖後需要再次渲染才能顯現出來)

three.js 多面幾何體進行多面貼圖 (貼圖後需要再次渲染才能顯現出來)

let materials = [];
for (var i = 0; i < 6; ++i) {
    materials.push(new THREE.MeshBasicMaterial({
        map: THREE.ImageUtils.loadTexture('../img/' + i + '.png',//圖片的路徑
        {}, function() {
                renderer.render(scene, camera);
            }),
        overdraw: true
    }));
}
var cube = new THREE.Mesh(new THREE.CubeGeometry(5, 5, 5),
    new THREE.MeshFaceMaterial(materials));
scene.add(cube);