说我找到了使用raycaster发现的交叉点。
intersects[0]
如何让这个相交的脸世界正常?
希望我已经正确地提出了这个问题。 换句话说: 如何获取网格表面上的点的方向?
答案 0 :(得分:4)
正常情况可以在脸上看到。
例如
intersects[0].face.normal
典型的交叉返回以下内容:
{
"distance": 511.4062319788414,
"point": {
"x": -49.99999999999999,
"y": -2.3972604422461297,
"z": -8.950476224522788
},
"face": {
"a": 2,
"b": 3,
"c": 1,
"normal": {
"x": 1,
"y": 0,
"z": 0
},
"vertexNormals": [{
"x": 1,
"y": 0,
"z": 0
}, {
"x": 1,
"y": 0,
"z": 0
}, {
"x": 1,
"y": 0,
"z": 0
}],
"color": {},
"vertexColors": [],
"vertexTangents": [],
"materialIndex": 0
},
"faceIndex": 1,
"object": {
"metadata": {
"version": 4.3,
"type": "Object",
"generator": "ObjectExporter"
},
"geometries": [{
"uuid": "D12DB865-0BA3-4B38-BB18-92CBCFD5D630",
"type": "BoxGeometry",
"width": 20,
"height": 20,
"depth": 20
}],
"materials": [{
"uuid": "B405897C-0A60-44A8-B057-683EFA53E895",
"type": "MeshLambertMaterial",
"color": 16716340,
"ambient": 16777215,
"emissive": 0
}],
"object": {
"uuid": "34E07648-DA46-42B8-A1B1-7C87A67315B9",
"type": "Mesh",
"name": "cube1",
"geometry": "D12DB865-0BA3-4B38-BB18-92CBCFD5D630",
"material": "B405897C-0A60-44A8-B057-683EFA53E895",
"matrix": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -60, 0, 0, 1]
}
}
}
要转换为世界标准,其中对象是拾取的项目,请使用
var normalMatrix = new THREE.Matrix3().getNormalMatrix( object.matrixWorld );
console.log(normal.clone().applyMatrix3( normalMatrix ).normalize());