3

我正在尝试在 Three.js 中创建一个立方体,在立方体的每个面上使用不同的图像作为纹理。

如何隐藏网格的边缘/顶点?

代码:

var container, camera, scene, renderer, cube;

init();
animate();

function init(){
    container = document.getElementById('container');
    scene = new THREE.Scene();
    camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000);
    camera.position.y = 150;
    camera.position.z = 500;
    scene.add( camera );

    var materials = [];
    for ( var i = 0; i < 6; i ++ ) {
        materials.push( new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'img/' + i + '.png') } ) );
    }

    cube = new THREE.Mesh( new THREE.CubeGeometry( 200, 200, 200, 5,5,5, materials ), new THREE.MeshFaceMaterial() );
    cube.position.y = 150;
    scene.add( cube );
    renderer = new THREE.CanvasRenderer();
    renderer.setSize( window.innerWidth, window.innerHeight);
    container.appendChild( renderer.domElement );
    }

function animate() {
    requestAnimationFrame( animate );
    render();
}

function render(){
    cube.rotation.y += 0.005;
    renderer.render( scene, camera );
}
4

3 回答 3

3

改变:

for ( var i = 0; i < 6; i ++ ) {
    materials.push( new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'img/' + i + '.jpg') } ) );
}

至:

for ( var i = 0; i < 6; i ++ ) {
    materials.push( new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'img/' + i + '.jpg'), overdraw: true } ) );
}
于 2012-08-20T17:18:28.917 回答
1

换行:

cube = new THREE.Mesh( new THREE.CubeGeometry( 200, 200, 200, 5,5,5, materials ), new THREE.MeshFaceMaterial() );

至:

cube = new THREE.Mesh( new THREE.CubeGeometry( 200, 200, 200, 1,1,1, materials ), new THREE.MeshFaceMaterial() );
于 2012-08-15T07:06:46.100 回答
0

尝试使用另一个渲染器。更改此行:

 renderer = new THREE.CanvasRenderer();

对此:

 renderer = new THREE.WebGLRenderer();
于 2014-06-01T19:19:17.960 回答