我正在尝试将多维数据集附加到特定点的另一个多维数据集。我能够碰撞并且.add()工作正常。但是,我想在父多维数据集发生冲突的位置准确添加子多维数据集。
for (var vertexIndex = 0; vertexIndex < MovingCube.geometry.vertices.length; vertexIndex++) {
var localVertex = MovingCube.geometry.vertices[vertexIndex].clone();
var globalVertex = localVertex.applyMatrix4( MovingCube.matrix );
var directionVector = globalVertex.sub( MovingCube.position );
var ray = new THREE.Raycaster( originPoint, directionVector.clone().normalize() );
var collisionResults = ray.intersectObjects( collidableMeshList );
if ( collisionResults.length > 0 && collisionResults[0].distance < directionVector.length() )
console.log(" Hit and collision detected " + SELECTED);
MovingCubeBig.add(SELECTED);
// Is there way to get collision point and attach object at that point?
}
答案 0 :(得分:0)
交叉点结果应包含point
属性。
https://github.com/mrdoob/three.js/blob/master/src/core/Raycaster.js#L255
也许你可以用它来把孩子安置在正确的位置?
此外,此示例可能有助于http://threejs.org/examples/#webgl_geometry_terrain_raycast