处理windows下three.js在WebGlRender衬着没法设置线宽linewidth

    var mesh = ''
    function createLines(arr) {    
        if(mesh){
            scene.remove(mesh)
        }
        var line = new THREE.Geometry();
        line.vertices = []
        $.each(arr, function(index,content) {
            var a = scene.getObjectByName(content)
            line.vertices.push( a.position );
        });
        makeLine( line, 3 );
    }
    
    var resolution = new THREE.Vector2( window.innerWidth, window.innerHeight );
    function makeLine( geo, c ) {
        var g = new MeshLine();

        g.setGeometry( geo );
    
        var material = new MeshLineMaterial( {
            useMap: false,
            color: new THREE.Color( 0xed6a5a ),
            opacity: 1,
            resolution: resolution,
            sizeAttenuation: !false,
            lineWidth: 0.5,
            near: camera.near,
            far: camera.far
        });
        mesh = new THREE.Mesh( g.geometry, material );
        scene.add( mesh );
    }
    //arr为line在场景中经由的模子称号的数组
    createLines(arr)

页面中须要引入<script src="js/THREE.MeshLine.js"></script>
THREE.MeshLine.js下载

    原文作者:你蠢哭我咯
    原文地址: https://segmentfault.com/a/1190000010337027
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞