繁体   English   中英

如何在Three.js中分离网格的顶点?

[英]How to I separate vertices of a mesh in Three.js?

有没有办法分离Three.js网格的顶点? 基本上,我想用鼠标输入来撕裂3D对象。 最近,我为该Web应用程序编写了GLSL顶点着色器, 着色器通过视频的亮度来置换网格的顶点。

但是,我不知所措,我该如何选择网格的顶点并从本质上将其边缘与最近的邻居分开,而顶点着色器也可以移动对象。

使用简单的清单选择所有顶点im:

var geometry = new THREE.CubeGeometry( 30, 30, 30 ,1,1,1);
for ( var i = 0; i < geometry.vertices.length; i ++ ) {
            var vertices = [];
            for ( var v = 0; v < geometry.vertices.length; v ++ ) {
            vertices.push( geometry.vertices[ v ].clone() );
            if ( v === i ) {
                //getting only Z axis:
                //vertices[ vertices.length - 1 ].x *= 2;
                //vertices[ vertices.length - 1 ].y *= 2;
                vertices[ vertices.length - 1 ].z *= 2;
            }
            }
            geometry.morphTargets.push( { name: "target" + i, vertices: vertices } );
        }
    console.log(geometry.vertices);


//Updating the morphs with new values. We only want to influence one side of the cube
        mesh.morphTargetInfluences[0] = 1
        mesh.morphTargetInfluences[2] = 1
        mesh.morphTargetInfluences[5] = 1
        mesh.morphTargetInfluences[7] = 1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM