ExtrudeGeometry漏洞性能问题

时间:2014-12-27 10:50:07

标签: three.js

我正在使用ExtrudeGeometry创建一个洞。它的工作正常,不到150(性能明智),但如果我创建更多,那么加载和挂起浏览器需要很长时间。

drill = new THREE.Path();
drill.absarc(Number(p[i + 1]) * osx,  Number(p[i + 2]) * osy, p[i + 3] * osy, -Math.PI, Math.PI, true);
path.push(drill);  

function getExtrudeSettings(amount/* , material, extrudeMaterial */) 
{
    extrudeSettings = {
        amount : amount,
        bevelEnabled : false,
        steps : 1,
        curveSegments : 10
    };
    return extrudeSettings;
}

function addGeometry(geometry, x, y, z, rx, ry, rz, s, check) 
{
    var materialFront;

    var materials;

    if (check == 1) {
        materialFront = new THREE.MeshPhongMaterial({ vertexColors:THREE.VertexColors,  emissive : 0x888888, overdraw: true});
    }
    else {
        materialFront = new THREE.MeshPhongMaterial({  vertexColors:THREE.VertexColors, emissive : 0x888888, overdraw: true});
    } 

    var mesh = new THREE.Mesh(geometry, materialFront);

    mesh.position.set(-50, 0, z - 75);
    parent.add(mesh);
}

// roundedRectShape this is the main shape

roundedRect(roundedRectShape); 
var roundedRect3d = roundedRectShape.extrude(getExtrudeSettings(3));

function roundedRect(ctx) 
{         
    var index;
    var limit;
    if (path.length > 301) { 
            limit = 300;
    }
    else {
        limit = path.length;
    }

    for (index = 0; index < path.length; index++) {
        var holes = new THREE.Path();
        holes = path[index];
        ctx.holes.push(holes);  
    } 
}

addGeometry(roundedRect3d, -150, 150, 0, 0, 0, 0, 1, 1);
addGeometry(roundedRect3d, -150, 150, -3, 0, 0, 0, 1, 3);

parent.translateY( -minY -100 );
parent.translateX( -minX );

renderer = new THREE.WebGLRenderer({ antialias : true });
renderer.setSize(window.innerWidth * 80/100, window.innerHeight * 85/100);
renderer.setClearColor(0x242424);
container.appendChild(renderer.domElement);

这是代码的一部分。 您还可以在此处找到代码http://jsfiddle.net/shiladittya/m5cfLx1g/

那么在挤出形状中创建孔的最佳方法是什么?任何建议..

0 个答案:

没有答案