我有一个功能,可在网格运动后每帧生成新的三维图。进行管形几何更新的函数如下所示:
function UpdateKettingMeshes(kettingMeshes, kraalElements, kettingCurvesArray, kettingShapeArray) {
for (let i = 0; i < kettingMeshes.length; i++) {
const element = kettingMeshes[i];
const elCurve = kettingCurvesArray[i];
const elShape = kettingShapeArray[i];
elCurve.v0.copy(kraalElements[i].kraal.position.clone());
elCurve.v1.copy(kraalElements[i].kraal.position.clone().add(elShape.controlPointDirection1.clone().multiplyScalar(elShape.controlPointPower1)));
elCurve.v2.copy(kraalElements[i + 1].kraal.position.clone().add(elShape.controlPointDirection2.clone().multiplyScalar(elShape.controlPointPower2)));
elCurve.v3.copy(kraalElements[i + 1].kraal.position.clone());
const geometry = new THREE.TubeGeometry( elCurve, 80, 1.2, 8, false );
element.geometry.vertices = geometry.vertices;
element.geometry.verticesNeedUpdate = true;
}
return kettingMeshes;
}
我每帧都调用此函数,如下所示:
kettingMeshData = UpdateKettingMeshes(kettingMeshData, kralenObjects, kettingCurveData, kettingShapeData);
这正常工作,没有错误,当我console.log
kettingMeshData
并检查顶点是否已更新时,我看到是这种情况,请参见下图:
但是问题是实际的网格在场景中没有改变?为什么不更新?
旁注,所有管网都位于three.group()中。
如果不清楚,请告诉我,以便我澄清!