javascript - 在 THREE.js 面中反转顶点顺序

标签 javascript three.js

我需要反转几何体表面的顶点顺序。 例如:

// create geometry
var geometry = new THREE.Geometry();
// create vertices
geometry.vertices.push( new THREE.Vector3( 0,   0,   0 ) );
geometry.vertices.push( new THREE.Vector3( 0,   100, 0 ) );
geometry.vertices.push( new THREE.Vector3( 100, 0,   0 ) );
// create face
var face = new THREE.Face3( 0, 1, 2 );
geometry.faces.push ( face );
// compute normals
geometry.computeFaceNormals();
geometry.computeVertexNormals();
// add to scene
var mesh = new THREE.Mesh(
    geometry,
    new THREE.MeshBasicMaterial({color: 0x00ffff})
);
scene.add( mesh );

现在我需要将面中的顶点顺序从 0,1,2 更改为 2,1,0。但是,当我手动执行此操作时,无论我将哪个更新标志设置为 true,它都不起作用。

问题 - 是否可以动态反转顶点顺序,如果可以,那么如何?

重要 - 在这种情况下最好避免对几何体使用负比例。最好避免重新创建对象。

三个.js:r73

最佳答案

delete mesh.geometry.__directGeometry;

这应该应用您的更改。由于某些原因,r72 和 r73 中的 __directGeometry 没有自动更新。

关于javascript - 在 THREE.js 面中反转顶点顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33496057/

相关文章:

javascript - ng-dirty 没有按预期工作

javascript - 内联此范围 'binding'

javascript - 检查我的脚本中的对象类型?

javascript - Three.js 拖动控件固定与相机的距离

javascript - ThreeJS 停止渲染

three.js - ColladaLoader : Could not find the skeleton for the skin

javascript - 在 XUL JavaScript 中执行 XSLT 转换文件时出现问题

javascript - 如何使固定标题在滚动时改变颜色

javascript - 无法在 OBJLoader 内补间对象

javascript - Three.js:围绕原点平滑相机倾斜