我有一个非常奇怪的问题。 我用三个j创建一个场景,我想在场景的地板上投射一个圆柱顶点并构建它的路径。因此,当我添加一个圆柱体时,移动并旋转它然后将它投射到地板上,顶点,我在克隆旧圆位的圆柱体,然后进行变换。 我的错误在哪里?
function drawCircle(r,seg,color,pos,mesh){
var geometry = new THREE.CylinderGeometry(r,r,100,seg);
var material = new THREE.MeshBasicMaterial( { color: color, wireframe: true, transparent: true } );
mesh2 = new THREE.Mesh( geometry, material );
mesh2.position = pos;
mesh2.rotation.x = Math.PI/2;
scene.add(mesh2);
var lineGeometry = new THREE.Geometry();
for (var i=0; i < (mesh2.geometry.vertices.length/2)-1; i++)
{
var origin = mesh2.geometry.vertices[i].clone();
var proj = projectOntoMesh( origin, mesh );
lineGeometry.vertices.push( proj );
}
lineGeometry.computeLineDistances();
var lineMaterial = new THREE.LineBasicMaterial( { color: color } );
var line = new THREE.Line( lineGeometry, lineMaterial );
scene.add(line);
scene.remove(mesh2);
//scene.remove(sphere);
}
function projectOntoMesh(point, mesh)
{
var origin = point.clone();
var direction = point.clone();
//direction.multiplyScalar(-1);
direction.y = -direction.y*25;
//direction.x = -direction.x;
//var direction = point.clone().multiplyScalar(-1);
var ray = new THREE.Raycaster( origin, direction.normalize() );
var intersection = ray.intersectObject( mesh );
if ( intersection.length > 0 )
return intersection[ 0 ].point;
else
// console.log( "No intersection?" );
return null;
}
抱歉我的英文......