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下载