更新网格内的几何图形没有任何作用 [英] Updating a geometry inside a mesh does nothing

查看:33
本文介绍了更新网格内的几何图形没有任何作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 THREE.JS rev 49.

I am using THREE.JS rev 49.

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

My program needs to update a mesh by changing it's geometry. Unfortunately the display does not seem to update.

这是我的代码:

// 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;

}

我需要添加其他东西吗?

Do I have to add something else ?

/奥拉贡

推荐答案

如果我理解正确,您正在此处更新顶点:

If I understood correctly you are updating vertices here:

else{
        theObjects[i].mesh.geometry.vertices = theObjects[i].geo.vertices;  
}

尝试将此代码更改为:

else{
         theObjects[i].mesh.geometry.dynamic = true;
         theObjects[i].mesh.geometry.vertices = theObjects[i].geo.vertices;  
         theObjects[i].mesh.geometry.verticesNeedUpdate = true;
    }

if(){} 中创建网格,在 else{} 中更新,以便 dynamic = trueverticesNeedUpdate= true 您需要设置为 else{} 中的网格.

In if(){} you create a mesh and in else{} you update so dynamic = true and verticesNeedUpdate = true you need to set to mesh which is in else{}.

这篇关于更新网格内的几何图形没有任何作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆