简体   繁体   English

Three.js ExtrudeGeometry 纹理

[英]Three.js ExtrudeGeometry Texture

Textures are not shown on my extruded geometry.我的挤压几何体上没有显示纹理。 What am I doing wrong?我究竟做错了什么?

const shape = new THREE.Shape();
shape.autoClose = true;
shape.moveTo(walls[0].p1.x, -walls[0].p1.z);
shape.moveTo(walls[0].p2.x, -walls[0].p2.z);
for (var j = 1; j < walls.length; j++) {
    shape.lineTo(walls[j].p1.x, -walls[j].p1.z);
    shape.lineTo(walls[j].p2.x, -walls[j].p2.z);
}
var extrudeSettings = {
    steps: 1, depth: 5, bevelEnabled: false//, material: 0, extrudeMaterial: 1
};
const floor_material = new THREE.MeshPhongMaterial({ color: 0xaaaaaa });
const loader = new THREE.TextureLoader();

const Texture = loader.load("assets/textures/grassbw.jpg", texture => {
    floor_material.map = texture;
    floor_material.needsUpdate = true;
});

Texture.wrapS = Texture.wrapT = THREE.RepeatWrapping;
Texture.repeat.set(60, 60);
Texture.rotation = Math.PI / 2;
const geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings);
geometry.computeFaceNormals();
const mesh = new THREE.Mesh(geometry, floor_material);
mesh.receiveShadow = true;
mesh.updateMatrix();

ok, my repeat was to big.好的,我的重复太大了。 Changed it to 0…005 and I can see the texture now.将其更改为 0…005,我现在可以看到纹理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM