更新网格内的几何图形不会做任何事情

Ora*_*eet 12 three.js

我正在使用THREE.JS rev 49.

我的程序需要通过更改它的几何来更新网格.不幸的是,显示器似乎没有更新.

这是我的代码:

// theObject is an array of associatives :

// {
//     object1: {mesh: undefined/THREE.mesh, mat: THREE.Material, geo: THREE.Geometry}
//     object2: {mesh: undefined/THREE.mesh, mat: THREE.Material, geo: THREE.Geometry}
//     ...
// }

// In my function, theObject[i].mesh geometry must change to be theObject[i].geo.


for(i in theObjects) {

    //*
    if ( theObjects[i].mesh == undefined) {
        theObjects[i].mesh = new THREE.Mesh(theObjects[i].geo, theObjects[i].mat);

        theObjects[i].mesh.geometry.dynamic = true;
        theObjects[i].geo.verticesNeedUpdate = true;

        scenePostsurgery.add(theObjects[i].mesh);
    }  else
        theObjects[i].mesh.geometry.vertices = theObjects[i].geo.vertices;

}
Run Code Online (Sandbox Code Playgroud)

我还需要添加其他东西吗?

/ Oragon

uhu*_*ura 16

如果我理解正确,你在这里更新顶点:

else{
        theObjects[i].mesh.geometry.vertices = theObjects[i].geo.vertices;  
}
Run Code Online (Sandbox Code Playgroud)

尝试将此代码更改为:

else{
         theObjects[i].mesh.geometry.dynamic = true;
         theObjects[i].mesh.geometry.vertices = theObjects[i].geo.vertices;  
         theObjects[i].mesh.geometry.verticesNeedUpdate = true;
    }
Run Code Online (Sandbox Code Playgroud)

if(){}你创建一个网格,并在else{}你更新dynamic = true,verticesNeedUpdate = true你需要设置为网格else{}.