gpt4 book ai didi

javascript - Three.js 立方体,每个面都有不同的纹理。如何隐藏边/顶点

转载 作者:行者123 更新时间:2023-11-29 10:21:03 27 4
gpt4 key购买 nike

我正在尝试在 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 );
}

最佳答案

改变:

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

关于javascript - Three.js 立方体,每个面都有不同的纹理。如何隐藏边/顶点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11961288/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com