我正在尝试为Terrain模型创建轮廓线。为此,我将平面间隔放置,并尝试从网格中找到其交点。
我已提及this!用于使用缓冲区几何。
var obj = scene.getObjectByName('MyObj_s');
//set bounding box
var box = new THREE.Box3().setFromObject( obj );
var bmx = box.max;
var bmi = box.min;
var bsz = box.getSize();
var ctrin = Number($('#cntrin').val()); // equals = 1
if(isNaN(ctrin)){
alert("Inavlid contour interval");
return;
}
//set loops
for(var zi = bmi.z; zi < bmx.z; zi = zi + ctrin){
var geometry = new THREE.PlaneGeometry( bsz.x, bsz.y, 32 );
var material = new THREE.MeshBasicMaterial( {color: 0xffffff, side: THREE.DoubleSide, opacity: 0.1, transparent: true} );
var plane = new THREE.Mesh( geometry, material );
plane.position.x = (bmx.x + bmi.x) / 2;
plane.position.y = (bmx.y + bmi.y) / 2;
plane.position.z = zi;
scene.add( plane );
var planetoBSP = new THREE.Mesh( plane );
var bsp2 = new ThreeBSP( planetoBSP );
console.log(bsp2);
var BoxMesh = new THREE.Mesh( obj );
var bsp1 = new ThreeBSP( BoxMesh );
console.log(bsp1);
var geometry = bsp1.intersection(bsp2).toBufferGeometry();
var mesh = new THREE.Mesh( geometry, material );
}//for
我要实现的只是模型上的轮廓线。但是BSP转换存在问题。