1

我正在使用three.js,并且我有一个平面形状。这个形状应该有纹理。下面你可以看到我是如何尝试的。问题是,纹理仅在形状的两个边缘以两条条纹显示。如果我为 texture.repeat 取更高的值,这个条纹会变细。我知道这里有一个相关的话题Three.JS Is it possible to render a texture on shapeGeometry?,但我不明白这对我有什么帮助。

    //Draw Floorshape
    var points_floor = [];

    points_floor.push(new THREE.Vector2(edges[edges.length-1][edges[3].length-1][0], edges[edges.length-1][edges[3].length-1][1]));
    for (var i = 0; i < edges.length; i++) {
        for (var j = 0; j < edges[i].length; j++) {
            points_floor.push(new THREE.Vector2(edges[i][j][0], edges[i][j][1]));
        }
    }

    var shape_floor = new THREE.Shape(points_floor);

    var floorGeometry = new THREE.ShapeGeometry(shape_floor);
    var texture = new THREE.ImageUtils.loadTexture("./img/tileable_wood_texture_by_ftIsis_Stock.jpg");
    texture.repeat.set(0.1, 0.1);
    texture.wrapS = texture.wrapT = THREE.RepeatWrapping;

    var materialFloor = new THREE.MeshBasicMaterial({
        map : texture,
        side : THREE.DoubleSide
    });

    var floor = new THREE.Mesh(floorGeometry, materialFloor);
    floor.overdraw = true;
4

0 回答 0